@payloadcms/tanstack-start 4.0.0-canary.8

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 (216) hide show
  1. package/LICENSE.md +22 -0
  2. package/dist/auth/login.d.ts +17 -0
  3. package/dist/auth/login.d.ts.map +1 -0
  4. package/dist/auth/login.js +50 -0
  5. package/dist/auth/login.js.map +1 -0
  6. package/dist/auth/logout.d.ts +9 -0
  7. package/dist/auth/logout.d.ts.map +1 -0
  8. package/dist/auth/logout.js +51 -0
  9. package/dist/auth/logout.js.map +1 -0
  10. package/dist/auth/refresh.d.ts +8 -0
  11. package/dist/auth/refresh.d.ts.map +1 -0
  12. package/dist/auth/refresh.js +53 -0
  13. package/dist/auth/refresh.js.map +1 -0
  14. package/dist/elements/DocumentHeaderClient/index.d.ts +16 -0
  15. package/dist/elements/DocumentHeaderClient/index.d.ts.map +1 -0
  16. package/dist/elements/DocumentHeaderClient/index.js +116 -0
  17. package/dist/elements/DocumentHeaderClient/index.js.map +1 -0
  18. package/dist/elements/RenderComponent/index.d.ts +10 -0
  19. package/dist/elements/RenderComponent/index.d.ts.map +1 -0
  20. package/dist/elements/RenderComponent/index.js +12 -0
  21. package/dist/elements/RenderComponent/index.js.map +1 -0
  22. package/dist/elements/RouterAdapter/index.d.ts +3 -0
  23. package/dist/elements/RouterAdapter/index.d.ts.map +1 -0
  24. package/dist/elements/RouterAdapter/index.js +141 -0
  25. package/dist/elements/RouterAdapter/index.js.map +1 -0
  26. package/dist/exports/client.d.ts +8 -0
  27. package/dist/exports/client.d.ts.map +1 -0
  28. package/dist/exports/client.js +10 -0
  29. package/dist/exports/client.js.map +1 -0
  30. package/dist/exports/layouts.d.ts +6 -0
  31. package/dist/exports/layouts.d.ts.map +1 -0
  32. package/dist/exports/layouts.js +5 -0
  33. package/dist/exports/layouts.js.map +1 -0
  34. package/dist/exports/rsc.browser.d.ts +12 -0
  35. package/dist/exports/rsc.browser.d.ts.map +1 -0
  36. package/dist/exports/rsc.browser.js +12 -0
  37. package/dist/exports/rsc.browser.js.map +1 -0
  38. package/dist/exports/rsc.d.ts +5 -0
  39. package/dist/exports/rsc.d.ts.map +1 -0
  40. package/dist/exports/rsc.js +6 -0
  41. package/dist/exports/rsc.js.map +1 -0
  42. package/dist/exports/server.d.ts +17 -0
  43. package/dist/exports/server.d.ts.map +1 -0
  44. package/dist/exports/server.js +18 -0
  45. package/dist/exports/server.js.map +1 -0
  46. package/dist/exports/vite.d.ts +3 -0
  47. package/dist/exports/vite.d.ts.map +1 -0
  48. package/dist/exports/vite.js +3 -0
  49. package/dist/exports/vite.js.map +1 -0
  50. package/dist/index.d.ts +6 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +7 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/layouts/Root/getLayoutData.d.ts +12 -0
  55. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -0
  56. package/dist/layouts/Root/getLayoutData.js +91 -0
  57. package/dist/layouts/Root/getLayoutData.js.map +1 -0
  58. package/dist/layouts/Root/index.d.ts +32 -0
  59. package/dist/layouts/Root/index.d.ts.map +1 -0
  60. package/dist/layouts/Root/index.js +51 -0
  61. package/dist/layouts/Root/index.js.map +1 -0
  62. package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
  63. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  64. package/dist/layouts/Root/withPayloadRoot.js +92 -0
  65. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  66. package/dist/node/cssLoader.d.mts +3 -0
  67. package/dist/node/cssLoader.d.mts.map +1 -0
  68. package/dist/node/cssLoader.js +70 -0
  69. package/dist/node/cssLoader.js.map +1 -0
  70. package/dist/node/cssLoader.mjs +75 -0
  71. package/dist/node/registerCssLoader.d.mts +2 -0
  72. package/dist/node/registerCssLoader.d.mts.map +1 -0
  73. package/dist/node/registerCssLoader.js +10 -0
  74. package/dist/node/registerCssLoader.js.map +1 -0
  75. package/dist/node/registerCssLoader.mjs +10 -0
  76. package/dist/routes/adminRoutes.d.ts +111 -0
  77. package/dist/routes/adminRoutes.d.ts.map +1 -0
  78. package/dist/routes/adminRoutes.js +108 -0
  79. package/dist/routes/adminRoutes.js.map +1 -0
  80. package/dist/routes/apiRoute.d.ts +29 -0
  81. package/dist/routes/apiRoute.d.ts.map +1 -0
  82. package/dist/routes/apiRoute.js +38 -0
  83. package/dist/routes/apiRoute.js.map +1 -0
  84. package/dist/routes/layoutRoute.d.ts +26 -0
  85. package/dist/routes/layoutRoute.d.ts.map +1 -0
  86. package/dist/routes/layoutRoute.js +57 -0
  87. package/dist/routes/layoutRoute.js.map +1 -0
  88. package/dist/rsc/CollectionCards.d.ts +4 -0
  89. package/dist/rsc/CollectionCards.d.ts.map +1 -0
  90. package/dist/rsc/CollectionCards.js +12 -0
  91. package/dist/rsc/CollectionCards.js.map +1 -0
  92. package/dist/rsc/HierarchyTypeFieldServer.d.ts +9 -0
  93. package/dist/rsc/HierarchyTypeFieldServer.d.ts.map +1 -0
  94. package/dist/rsc/HierarchyTypeFieldServer.js +35 -0
  95. package/dist/rsc/HierarchyTypeFieldServer.js.map +1 -0
  96. package/dist/rsc/renderOnDemand.d.ts +15 -0
  97. package/dist/rsc/renderOnDemand.d.ts.map +1 -0
  98. package/dist/rsc/renderOnDemand.js +25 -0
  99. package/dist/rsc/renderOnDemand.js.map +1 -0
  100. package/dist/rsc/renderPayloadRSC.d.ts +6 -0
  101. package/dist/rsc/renderPayloadRSC.d.ts.map +1 -0
  102. package/dist/rsc/renderPayloadRSC.js +6 -0
  103. package/dist/rsc/renderPayloadRSC.js.map +1 -0
  104. package/dist/utilities/devReloadStrategy.d.ts +10 -0
  105. package/dist/utilities/devReloadStrategy.d.ts.map +1 -0
  106. package/dist/utilities/devReloadStrategy.js +27 -0
  107. package/dist/utilities/devReloadStrategy.js.map +1 -0
  108. package/dist/utilities/getExistingAuthToken.d.ts +7 -0
  109. package/dist/utilities/getExistingAuthToken.d.ts.map +1 -0
  110. package/dist/utilities/getExistingAuthToken.js +18 -0
  111. package/dist/utilities/getExistingAuthToken.js.map +1 -0
  112. package/dist/utilities/getPreferences.d.ts +10 -0
  113. package/dist/utilities/getPreferences.d.ts.map +1 -0
  114. package/dist/utilities/getPreferences.js +33 -0
  115. package/dist/utilities/getPreferences.js.map +1 -0
  116. package/dist/utilities/getRequestI18n.server.d.ts +12 -0
  117. package/dist/utilities/getRequestI18n.server.d.ts.map +1 -0
  118. package/dist/utilities/getRequestI18n.server.js +25 -0
  119. package/dist/utilities/getRequestI18n.server.js.map +1 -0
  120. package/dist/utilities/getRequestLocale.d.ts +7 -0
  121. package/dist/utilities/getRequestLocale.d.ts.map +1 -0
  122. package/dist/utilities/getRequestLocale.js +20 -0
  123. package/dist/utilities/getRequestLocale.js.map +1 -0
  124. package/dist/utilities/getRequestTheme.d.ts +10 -0
  125. package/dist/utilities/getRequestTheme.d.ts.map +1 -0
  126. package/dist/utilities/getRequestTheme.js +25 -0
  127. package/dist/utilities/getRequestTheme.js.map +1 -0
  128. package/dist/utilities/graphqlHandler.server.d.ts +12 -0
  129. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -0
  130. package/dist/utilities/graphqlHandler.server.js +129 -0
  131. package/dist/utilities/graphqlHandler.server.js.map +1 -0
  132. package/dist/utilities/handleAPIRoute.d.ts +11 -0
  133. package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
  134. package/dist/utilities/handleAPIRoute.js +17 -0
  135. package/dist/utilities/handleAPIRoute.js.map +1 -0
  136. package/dist/utilities/handleServerFunctions.d.ts +20 -0
  137. package/dist/utilities/handleServerFunctions.d.ts.map +1 -0
  138. package/dist/utilities/handleServerFunctions.js +60 -0
  139. package/dist/utilities/handleServerFunctions.js.map +1 -0
  140. package/dist/utilities/importMap.server.d.ts +8 -0
  141. package/dist/utilities/importMap.server.d.ts.map +1 -0
  142. package/dist/utilities/importMap.server.js +11 -0
  143. package/dist/utilities/importMap.server.js.map +1 -0
  144. package/dist/utilities/initReq.server.d.ts +19 -0
  145. package/dist/utilities/initReq.server.d.ts.map +1 -0
  146. package/dist/utilities/initReq.server.js +87 -0
  147. package/dist/utilities/initReq.server.js.map +1 -0
  148. package/dist/utilities/loadAdminPage.d.ts +54 -0
  149. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  150. package/dist/utilities/loadAdminPage.js +230 -0
  151. package/dist/utilities/loadAdminPage.js.map +1 -0
  152. package/dist/utilities/loadLayoutData.d.ts +15 -0
  153. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  154. package/dist/utilities/loadLayoutData.js +23 -0
  155. package/dist/utilities/loadLayoutData.js.map +1 -0
  156. package/dist/utilities/meta.d.ts +70 -0
  157. package/dist/utilities/meta.d.ts.map +1 -0
  158. package/dist/utilities/meta.js +142 -0
  159. package/dist/utilities/meta.js.map +1 -0
  160. package/dist/utilities/serializeForRsc.d.ts +26 -0
  161. package/dist/utilities/serializeForRsc.d.ts.map +1 -0
  162. package/dist/utilities/serializeForRsc.js +122 -0
  163. package/dist/utilities/serializeForRsc.js.map +1 -0
  164. package/dist/utilities/serverAdapter.server.d.ts +36 -0
  165. package/dist/utilities/serverAdapter.server.d.ts.map +1 -0
  166. package/dist/utilities/serverAdapter.server.js +130 -0
  167. package/dist/utilities/serverAdapter.server.js.map +1 -0
  168. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  169. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  170. package/dist/utilities/serverFunctionClient.js +109 -0
  171. package/dist/utilities/serverFunctionClient.js.map +1 -0
  172. package/dist/utilities/serverFunctionHandlers.d.ts +18 -0
  173. package/dist/utilities/serverFunctionHandlers.d.ts.map +1 -0
  174. package/dist/utilities/serverFunctionHandlers.js +17 -0
  175. package/dist/utilities/serverFunctionHandlers.js.map +1 -0
  176. package/dist/utilities/setPayloadAuthCookie.d.ts +9 -0
  177. package/dist/utilities/setPayloadAuthCookie.d.ts.map +1 -0
  178. package/dist/utilities/setPayloadAuthCookie.js +31 -0
  179. package/dist/utilities/setPayloadAuthCookie.js.map +1 -0
  180. package/dist/utilities/toSerializable.d.ts +2 -0
  181. package/dist/utilities/toSerializable.d.ts.map +1 -0
  182. package/dist/utilities/toSerializable.js +111 -0
  183. package/dist/utilities/toSerializable.js.map +1 -0
  184. package/dist/vite/constants.d.ts +42 -0
  185. package/dist/vite/constants.d.ts.map +1 -0
  186. package/dist/vite/constants.js +177 -0
  187. package/dist/vite/constants.js.map +1 -0
  188. package/dist/vite/importProtection.d.ts +14 -0
  189. package/dist/vite/importProtection.d.ts.map +1 -0
  190. package/dist/vite/importProtection.js +54 -0
  191. package/dist/vite/importProtection.js.map +1 -0
  192. package/dist/vite/plugin.d.ts +38 -0
  193. package/dist/vite/plugin.d.ts.map +1 -0
  194. package/dist/vite/plugin.js +177 -0
  195. package/dist/vite/plugin.js.map +1 -0
  196. package/dist/vite/plugins/clientModuleResolution.d.ts +14 -0
  197. package/dist/vite/plugins/clientModuleResolution.d.ts.map +1 -0
  198. package/dist/vite/plugins/clientModuleResolution.js +98 -0
  199. package/dist/vite/plugins/clientModuleResolution.js.map +1 -0
  200. package/dist/vite/plugins/devTransforms.d.ts +19 -0
  201. package/dist/vite/plugins/devTransforms.d.ts.map +1 -0
  202. package/dist/vite/plugins/devTransforms.js +67 -0
  203. package/dist/vite/plugins/devTransforms.js.map +1 -0
  204. package/dist/vite/plugins/reactDomServerInRsc.d.ts +27 -0
  205. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +1 -0
  206. package/dist/vite/plugins/reactDomServerInRsc.js +90 -0
  207. package/dist/vite/plugins/reactDomServerInRsc.js.map +1 -0
  208. package/dist/vite/plugins/stripDistStyleImports.d.ts +21 -0
  209. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -0
  210. package/dist/vite/plugins/stripDistStyleImports.js +140 -0
  211. package/dist/vite/plugins/stripDistStyleImports.js.map +1 -0
  212. package/dist/vite/plugins/wrapCjsForClient.d.ts +15 -0
  213. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +1 -0
  214. package/dist/vite/plugins/wrapCjsForClient.js +106 -0
  215. package/dist/vite/plugins/wrapCjsForClient.js.map +1 -0
  216. package/package.json +106 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/handleAPIRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
@@ -0,0 +1,20 @@
1
+ import type { ServerFunctionHandler } from 'payload';
2
+ /**
3
+ * Server function dispatcher for TanStack Start.
4
+ *
5
+ * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
6
+ * exact same set of handlers — both adapters share `sharedServerFunctions`
7
+ * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
8
+ *
9
+ * Pipes the result through `serializeForRsc`, which converts any React
10
+ * elements left in the response (e.g. `state[path].customComponents.Field`
11
+ * produced by `buildFormState`, the `List` / `Document` nodes returned by
12
+ * `render-list` / `render-document`) into RSC "renderable handles" via
13
+ * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
14
+ * `$RSC` serialization adapter then ships those handles to the client as
15
+ * Flight payloads — so this dispatcher must be invoked from a context that
16
+ * uses TanStack's wire format (e.g. `createServerFn`), not raw
17
+ * `JSON.stringify`.
18
+ */
19
+ export declare const handleServerFunctions: ServerFunctionHandler;
20
+ //# sourceMappingURL=handleServerFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAwB/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAkCnC,CAAA"}
@@ -0,0 +1,60 @@
1
+ import { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn';
2
+ import { _internal_renderFieldHandler } from '@payloadcms/ui/rsc';
3
+ import { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry';
4
+ import { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn';
5
+ import { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn';
6
+ import { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots';
7
+ import { RenderRSCComponent } from '../rsc/renderPayloadRSC.js';
8
+ import { initReq } from './initReq.server.js';
9
+ import { serializeForRsc } from './serializeForRsc.js';
10
+ import { switchLanguageHandler } from './serverFunctionHandlers.js';
11
+ const baseServerFunctions = {
12
+ ...sharedServerFunctions,
13
+ 'get-default-layout': getDefaultLayoutHandler,
14
+ 'render-document-slots': renderDocumentSlotsHandler,
15
+ 'render-field': _internal_renderFieldHandler,
16
+ 'render-tab': renderTabHandler,
17
+ 'render-widget': renderWidgetHandler,
18
+ 'switch-language': switchLanguageHandler
19
+ };
20
+ /**
21
+ * Server function dispatcher for TanStack Start.
22
+ *
23
+ * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
24
+ * exact same set of handlers — both adapters share `sharedServerFunctions`
25
+ * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
26
+ *
27
+ * Pipes the result through `serializeForRsc`, which converts any React
28
+ * elements left in the response (e.g. `state[path].customComponents.Field`
29
+ * produced by `buildFormState`, the `List` / `Document` nodes returned by
30
+ * `render-list` / `render-document`) into RSC "renderable handles" via
31
+ * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
32
+ * `$RSC` serialization adapter then ships those handles to the client as
33
+ * Flight payloads — so this dispatcher must be invoked from a context that
34
+ * uses TanStack's wire format (e.g. `createServerFn`), not raw
35
+ * `JSON.stringify`.
36
+ */ export const handleServerFunctions = async (args)=>{
37
+ const { name: fnKey, args: fnArgs, config: configPromise, importMap, serverFunctions: extraServerFunctions } = args;
38
+ const { cookies, locale, permissions, req } = await initReq({
39
+ configPromise,
40
+ importMap
41
+ });
42
+ const augmentedArgs = {
43
+ ...fnArgs,
44
+ cookies,
45
+ importMap,
46
+ locale,
47
+ mode: 'rsc',
48
+ permissions,
49
+ renderComponent: RenderRSCComponent,
50
+ req
51
+ };
52
+ const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
53
+ if (!fn) {
54
+ throw new Error(`Unknown Server Function: ${fnKey}`);
55
+ }
56
+ const result = await fn(augmentedArgs);
57
+ return await serializeForRsc(result);
58
+ };
59
+
60
+ //# sourceMappingURL=handleServerFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { DefaultServerFunctionArgs, ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn'\nimport { _internal_renderFieldHandler } from '@payloadcms/ui/rsc'\nimport { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry'\nimport { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn'\nimport { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn'\nimport { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots'\n\nimport { RenderRSCComponent } from '../rsc/renderPayloadRSC.js'\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\nimport { switchLanguageHandler } from './serverFunctionHandlers.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n ...sharedServerFunctions,\n 'get-default-layout': getDefaultLayoutHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-tab': renderTabHandler,\n 'render-widget': renderWidgetHandler,\n 'switch-language': switchLanguageHandler,\n}\n\n/**\n * Server function dispatcher for TanStack Start.\n *\n * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the\n * exact same set of handlers — both adapters share `sharedServerFunctions`\n * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.\n *\n * Pipes the result through `serializeForRsc`, which converts any React\n * elements left in the response (e.g. `state[path].customComponents.Field`\n * produced by `buildFormState`, the `List` / `Document` nodes returned by\n * `render-list` / `render-document`) into RSC \"renderable handles\" via\n * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's\n * `$RSC` serialization adapter then ships those handles to the client as\n * Flight payloads — so this dispatcher must be invoked from a context that\n * uses TanStack's wire format (e.g. `createServerFn`), not raw\n * `JSON.stringify`.\n */\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req } = await initReq({\n configPromise,\n importMap,\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n mode: 'rsc',\n permissions,\n renderComponent: RenderRSCComponent,\n req,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n const result = await fn(augmentedArgs)\n\n return await serializeForRsc(result)\n}\n"],"names":["renderTabHandler","_internal_renderFieldHandler","sharedServerFunctions","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentSlotsHandler","RenderRSCComponent","initReq","serializeForRsc","switchLanguageHandler","baseServerFunctions","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","cookies","locale","permissions","req","augmentedArgs","mode","renderComponent","fn","Error","result"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,4DAA2D;AAC5F,SAASC,4BAA4B,QAAQ,qBAAoB;AACjE,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,uBAAuB,QAAQ,gGAA+F;AACvI,SAASC,mBAAmB,QAAQ,4FAA2F;AAC/H,SAASC,0BAA0B,QAAQ,oDAAmD;AAE9F,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,qBAAqB,QAAQ,8BAA6B;AAEnE,MAAMC,sBAAgE;IACpE,GAAGR,qBAAqB;IACxB,sBAAsBC;IACtB,yBAAyBE;IACzB,gBAAgBJ;IAChB,cAAcD;IACd,iBAAiBI;IACjB,mBAAmBK;AACrB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAME,wBAA+C,OAAOC;IACjE,MAAM,EACJC,MAAMC,KAAK,EACXF,MAAMG,MAAM,EACZC,QAAQC,aAAa,EACrBC,SAAS,EACTC,iBAAiBC,oBAAoB,EACtC,GAAGR;IAEJ,MAAM,EAAES,OAAO,EAAEC,MAAM,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAG,MAAMjB,QAAQ;QAC1DU;QACAC;IACF;IAEA,MAAMO,gBAA2C;QAC/C,GAAGV,MAAM;QACTM;QACAH;QACAI;QACAI,MAAM;QACNH;QACAI,iBAAiBrB;QACjBkB;IACF;IAEA,MAAMI,KAAKR,sBAAsB,CAACN,MAAM,IAAIJ,mBAAmB,CAACI,MAAM;IAEtE,IAAI,CAACc,IAAI;QACP,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEf,OAAO;IACrD;IAEA,MAAMgB,SAAS,MAAMF,GAAGH;IAExB,OAAO,MAAMjB,gBAAgBsB;AAC/B,EAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the default output path for the generated import map file in a
3
+ * TanStack Start project. Matches the `app/_payload/` convention that Payload's
4
+ * import map auto-discovery probes, so the file is found without a custom
5
+ * `admin.importMap.importMapFile` override.
6
+ */
7
+ export declare function getImportMapOutputPath(rootDir?: string): string;
8
+ //# sourceMappingURL=importMap.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importMap.server.d.ts","sourceRoot":"","sources":["../../src/utilities/importMap.server.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,11 @@
1
+ import path from 'node:path';
2
+ /**
3
+ * Returns the default output path for the generated import map file in a
4
+ * TanStack Start project. Matches the `app/_payload/` convention that Payload's
5
+ * import map auto-discovery probes, so the file is found without a custom
6
+ * `admin.importMap.importMapFile` override.
7
+ */ export function getImportMapOutputPath(rootDir) {
8
+ return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js');
9
+ }
10
+
11
+ //# sourceMappingURL=importMap.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file in a\n * TanStack Start project. Matches the `app/_payload/` convention that Payload's\n * import map auto-discovery probes, so the file is found without a custom\n * `admin.importMap.importMapFile` override.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;CAKC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO,YAAY;AACnE"}
@@ -0,0 +1,19 @@
1
+ import type { ImportMap, InitReqResult, SanitizedConfig, ServerAdapter } from 'payload';
2
+ import { createLocalReq } from 'payload';
3
+ /**
4
+ * Initializes a Payload request object from the current TanStack Start server context.
5
+ * Uses `getRequest()` from `@tanstack/react-start/server` to access the incoming request.
6
+ */
7
+ export declare function initReq({ configPromise, importMap, overrides, serverAdapter, }: {
8
+ configPromise: Promise<SanitizedConfig> | SanitizedConfig;
9
+ importMap: ImportMap;
10
+ overrides?: Parameters<typeof createLocalReq>[0];
11
+ /**
12
+ * `ServerAdapter` attached to `req.server`. Defaults to the native
13
+ * `tanstackServerAdapter` (throws TanStack `redirect`/`notFound`). The admin
14
+ * page render passes an error-contract adapter so navigation thrown mid-render
15
+ * is caught at the loader boundary and re-thrown as native TanStack nav.
16
+ */
17
+ serverAdapter?: ServerAdapter;
18
+ }): Promise<InitReqResult>;
19
+ //# sourceMappingURL=initReq.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initReq.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,wBAAsB,OAAO,CAAC,EAC5B,aAAa,EACb,SAAS,EACT,SAAS,EACT,aAAqC,GACtC,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,OAAO,CAAC,aAAa,CAAC,CAkFzB"}
@@ -0,0 +1,87 @@
1
+ import { initI18n } from '@payloadcms/translations';
2
+ import { getRequest } from '@tanstack/react-start/server';
3
+ import { createLocalReq, executeAuthStrategies, getAccessResults, getPayload, getRequestLanguage, parseCookies } from 'payload';
4
+ import * as qs from 'qs-esm';
5
+ import { getRequestLocale } from './getRequestLocale.js';
6
+ import { tanstackServerAdapter } from './serverAdapter.server.js';
7
+ /**
8
+ * Initializes a Payload request object from the current TanStack Start server context.
9
+ * Uses `getRequest()` from `@tanstack/react-start/server` to access the incoming request.
10
+ */ export async function initReq({ configPromise, importMap, overrides, serverAdapter = tanstackServerAdapter }) {
11
+ const webRequest = getRequest();
12
+ const headers = new Headers(webRequest.headers);
13
+ const cookies = parseCookies(headers);
14
+ const config = await configPromise;
15
+ const payload = await getPayload({
16
+ config,
17
+ importMap
18
+ });
19
+ const languageCode = getRequestLanguage({
20
+ config,
21
+ cookies,
22
+ headers
23
+ });
24
+ const i18n = await initI18n({
25
+ config: config.i18n,
26
+ context: 'client',
27
+ language: languageCode
28
+ });
29
+ const { responseHeaders, user } = await executeAuthStrategies({
30
+ headers,
31
+ payload
32
+ });
33
+ const { req: reqOverrides, ...optionsOverrides } = overrides || {};
34
+ // Parse the active URL's query string so that `req.query` (and thus
35
+ // `getRequestLocale`, access checks, etc.) reflect things like `?locale=es`
36
+ // even when the caller (e.g. the root layout loader) hasn't explicitly
37
+ // forwarded `searchParams` via overrides. `createLocalReq` only defaults
38
+ // `req.query` to `{}` and never reads the request URL itself.
39
+ let queryFromUrl;
40
+ try {
41
+ const urlObject = new URL(webRequest.url);
42
+ if (urlObject.search) {
43
+ queryFromUrl = qs.parse(urlObject.search, {
44
+ depth: 10,
45
+ ignoreQueryPrefix: true
46
+ });
47
+ }
48
+ } catch {
49
+ queryFromUrl = undefined;
50
+ }
51
+ const req = await createLocalReq({
52
+ req: {
53
+ headers,
54
+ host: headers.get('host') ?? undefined,
55
+ i18n: i18n,
56
+ query: queryFromUrl,
57
+ responseHeaders,
58
+ // Expose the `ServerAdapter` so framework-agnostic server functions can
59
+ // set cookies / redirect via `req.server` (mirrors the Next.js adapter,
60
+ // which passes `nextServerAdapter`). Required by handlers like
61
+ // `switch-language`. Defaults to the native adapter; the page render
62
+ // overrides it with the error-contract adapter.
63
+ server: serverAdapter,
64
+ url: webRequest.url,
65
+ user,
66
+ ...reqOverrides || {}
67
+ },
68
+ ...optionsOverrides || {}
69
+ }, payload);
70
+ const locale = await getRequestLocale({
71
+ req
72
+ });
73
+ req.locale = locale?.code;
74
+ const permissions = await getAccessResults({
75
+ req
76
+ });
77
+ return {
78
+ cookies,
79
+ headers,
80
+ languageCode,
81
+ locale,
82
+ permissions,
83
+ req
84
+ };
85
+ }
86
+
87
+ //# sourceMappingURL=initReq.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/initReq.server.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { ImportMap, InitReqResult, SanitizedConfig, ServerAdapter } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport {\n createLocalReq,\n executeAuthStrategies,\n getAccessResults,\n getPayload,\n getRequestLanguage,\n parseCookies,\n} from 'payload'\nimport * as qs from 'qs-esm'\n\nimport { getRequestLocale } from './getRequestLocale.js'\nimport { tanstackServerAdapter } from './serverAdapter.server.js'\n\n/**\n * Initializes a Payload request object from the current TanStack Start server context.\n * Uses `getRequest()` from `@tanstack/react-start/server` to access the incoming request.\n */\nexport async function initReq({\n configPromise,\n importMap,\n overrides,\n serverAdapter = tanstackServerAdapter,\n}: {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n overrides?: Parameters<typeof createLocalReq>[0]\n /**\n * `ServerAdapter` attached to `req.server`. Defaults to the native\n * `tanstackServerAdapter` (throws TanStack `redirect`/`notFound`). The admin\n * page render passes an error-contract adapter so navigation thrown mid-render\n * is caught at the loader boundary and re-thrown as native TanStack nav.\n */\n serverAdapter?: ServerAdapter\n}): Promise<InitReqResult> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const config = await configPromise\n const payload = await getPayload({ config, importMap })\n\n const languageCode = getRequestLanguage({\n config,\n cookies,\n headers,\n })\n\n const i18n: I18nClient = await initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n\n const { responseHeaders, user } = await executeAuthStrategies({\n headers,\n payload,\n })\n\n const { req: reqOverrides, ...optionsOverrides } = overrides || {}\n\n // Parse the active URL's query string so that `req.query` (and thus\n // `getRequestLocale`, access checks, etc.) reflect things like `?locale=es`\n // even when the caller (e.g. the root layout loader) hasn't explicitly\n // forwarded `searchParams` via overrides. `createLocalReq` only defaults\n // `req.query` to `{}` and never reads the request URL itself.\n let queryFromUrl: Record<string, unknown> | undefined\n try {\n const urlObject = new URL(webRequest.url)\n if (urlObject.search) {\n queryFromUrl = qs.parse(urlObject.search, {\n depth: 10,\n ignoreQueryPrefix: true,\n }) as Record<string, unknown>\n }\n } catch {\n queryFromUrl = undefined\n }\n\n const req = await createLocalReq(\n {\n req: {\n headers,\n host: headers.get('host') ?? undefined,\n i18n: i18n as I18n,\n query: queryFromUrl,\n responseHeaders,\n // Expose the `ServerAdapter` so framework-agnostic server functions can\n // set cookies / redirect via `req.server` (mirrors the Next.js adapter,\n // which passes `nextServerAdapter`). Required by handlers like\n // `switch-language`. Defaults to the native adapter; the page render\n // overrides it with the error-contract adapter.\n server: serverAdapter,\n url: webRequest.url,\n user,\n ...(reqOverrides || {}),\n },\n ...(optionsOverrides || {}),\n },\n payload,\n )\n\n const locale = await getRequestLocale({ req })\n\n req.locale = locale?.code\n\n const permissions = await getAccessResults({ req })\n\n return {\n cookies,\n headers,\n languageCode,\n locale,\n permissions,\n req,\n }\n}\n"],"names":["initI18n","getRequest","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","qs","getRequestLocale","tanstackServerAdapter","initReq","configPromise","importMap","overrides","serverAdapter","webRequest","headers","Headers","cookies","config","payload","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","queryFromUrl","urlObject","URL","url","search","parse","depth","ignoreQueryPrefix","undefined","host","get","query","server","locale","code","permissions"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,YAAY,QACP,UAAS;AAChB,YAAYC,QAAQ,SAAQ;AAE5B,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,qBAAqB,QAAQ,4BAA2B;AAEjE;;;CAGC,GACD,OAAO,eAAeC,QAAQ,EAC5BC,aAAa,EACbC,SAAS,EACTC,SAAS,EACTC,gBAAgBL,qBAAqB,EAYtC;IACC,MAAMM,aAAaf;IACnB,MAAMgB,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUZ,aAAaU;IAE7B,MAAMG,SAAS,MAAMR;IACrB,MAAMS,UAAU,MAAMhB,WAAW;QAAEe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edConfig } from 'payload';
2
+ import type { AdminPageMetadata } from './meta.js';
3
+ export type LoadAdminPageArgs = {
4
+ config: SanitizedConfig;
5
+ importMap: ImportMap;
6
+ search?: Record<string, string | string[]>;
7
+ splat?: string;
8
+ };
9
+ export type LoadAdminPageResult = {
10
+ _notFound: true;
11
+ routeKey?: string;
12
+ rscPayload?: React.ReactNode;
13
+ } | {
14
+ _redirect: string;
15
+ } | {
16
+ metadata: AdminPageMetadata;
17
+ /**
18
+ * Stable identity for this rendered route (the splat, i.e. the path
19
+ * after `/admin/`). The client keys the rendered subtree by this so the
20
+ * view remounts exactly when a new payload arrives. Keying by
21
+ * `location.pathname` instead races: the pathname updates before
22
+ * `useLoaderData()` during a transition, so the subtree would remount
23
+ * with the *previous* payload and then reconcile the fresh payload in
24
+ * place — leaving client providers (DocumentInfo, etc.) holding stale
25
+ * `useState` values from the prior document. Search params are excluded
26
+ * so search-only changes (e.g. list-view filtering) reconcile in place.
27
+ */
28
+ routeKey: string;
29
+ rscPayload: React.ReactNode;
30
+ };
31
+ /**
32
+ * Renders an admin page for TanStack Start and returns a serializable loader
33
+ * result. The framework adapter wraps this in a `createServerFn` that supplies
34
+ * the app's `config` and generated `importMap`.
35
+ *
36
+ * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
37
+ * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
38
+ * page-render `ServerAdapter` records navigation intent and throws the
39
+ * framework-agnostic error contract.
40
+ * 2. Pipes the resulting React server tree through `renderServerComponent`
41
+ * to produce a Flight payload the client consumes directly.
42
+ * 3. Resolves page metadata via the same shared `generatePageMetadata`
43
+ * Next.js uses, returning plain serializable strings for `head()`.
44
+ *
45
+ * Navigation surfaces two ways and both become a `_notFound` / `_redirect`
46
+ * sentinel the route loader re-throws as native TanStack nav:
47
+ * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
48
+ * by the try/catch below;
49
+ * - thrown deep inside a streamed view component (e.g. `DocumentView` access
50
+ * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
51
+ * so it's read from the `nav` holder after `renderServerComponent` resolves.
52
+ */
53
+ export declare function loadAdminPage({ config, importMap, search, splat, }: LoadAdminPageArgs): Promise<LoadAdminPageResult>;
54
+ //# sourceMappingURL=loadAdminPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GACpE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;CAC5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoJlD"}
@@ -0,0 +1,230 @@
1
+ import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { getRequestI18n } from './getRequestI18n.server.js';
3
+ import { initReq } from './initReq.server.js';
4
+ import { createPageRenderServerAdapter } from './serverAdapter.server.js';
5
+ const resolveTitle = (title)=>{
6
+ if (!title) {
7
+ return undefined;
8
+ }
9
+ if (typeof title === 'string') {
10
+ return title;
11
+ }
12
+ if ('absolute' in title) {
13
+ return title.absolute;
14
+ }
15
+ return title.default;
16
+ };
17
+ /**
18
+ * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into
19
+ * the plain, serializable `AdminPageMetadata` the route loader ships to the
20
+ * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and
21
+ * other non-serializable values that seroval cannot cross the wire, so only the
22
+ * fields `getAdminMeta` renders are extracted.
23
+ */ const toAdminPageMetadata = (meta)=>{
24
+ const og = meta.openGraph;
25
+ const rawImages = og?.images;
26
+ const imagesArray = rawImages ? Array.isArray(rawImages) ? rawImages : [
27
+ rawImages
28
+ ] : [];
29
+ const images = imagesArray.map((image)=>typeof image === 'string' ? {
30
+ url: image
31
+ } : image?.url ? {
32
+ alt: image.alt,
33
+ height: image.height,
34
+ url: String(image.url),
35
+ width: image.width
36
+ } : undefined).filter(Boolean);
37
+ const rawIcons = meta.icons;
38
+ const iconList = Array.isArray(rawIcons) ? rawIcons : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon) ? rawIcons.icon : [];
39
+ const icons = iconList.map((icon)=>typeof icon === 'string' ? {
40
+ rel: 'icon',
41
+ url: icon
42
+ } : icon?.url ? {
43
+ type: icon.type,
44
+ media: icon.media,
45
+ rel: icon.rel ?? 'icon',
46
+ sizes: icon.sizes,
47
+ url: String(icon.url)
48
+ } : undefined).filter(Boolean);
49
+ const keywords = meta.keywords;
50
+ return {
51
+ description: typeof meta.description === 'string' ? meta.description : undefined,
52
+ icons: icons?.length ? icons : undefined,
53
+ keywords: typeof keywords === 'string' ? keywords : Array.isArray(keywords) ? keywords.join(', ') : undefined,
54
+ openGraph: og ? {
55
+ description: typeof og.description === 'string' ? og.description : undefined,
56
+ images: images?.length ? images : undefined,
57
+ siteName: typeof og.siteName === 'string' ? og.siteName : undefined,
58
+ title: typeof og.title === 'string' ? og.title : undefined
59
+ } : undefined,
60
+ robots: typeof meta.robots === 'string' ? meta.robots : undefined,
61
+ title: resolveTitle(meta.title)
62
+ };
63
+ };
64
+ /**
65
+ * Renders an admin page for TanStack Start and returns a serializable loader
66
+ * result. The framework adapter wraps this in a `createServerFn` that supplies
67
+ * the app's `config` and generated `importMap`.
68
+ *
69
+ * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
70
+ * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
71
+ * page-render `ServerAdapter` records navigation intent and throws the
72
+ * framework-agnostic error contract.
73
+ * 2. Pipes the resulting React server tree through `renderServerComponent`
74
+ * to produce a Flight payload the client consumes directly.
75
+ * 3. Resolves page metadata via the same shared `generatePageMetadata`
76
+ * Next.js uses, returning plain serializable strings for `head()`.
77
+ *
78
+ * Navigation surfaces two ways and both become a `_notFound` / `_redirect`
79
+ * sentinel the route loader re-throws as native TanStack nav:
80
+ * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
81
+ * by the try/catch below;
82
+ * - thrown deep inside a streamed view component (e.g. `DocumentView` access
83
+ * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
84
+ * so it's read from the `nav` holder after `renderServerComponent` resolves.
85
+ */ export async function loadAdminPage({ config, importMap, search, splat }) {
86
+ const { renderRoot } = await import('@payloadcms/ui/views/Root');
87
+ const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews');
88
+ const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata');
89
+ const splatSegments = splat ? splat.split('/').filter(Boolean) : [];
90
+ // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no
91
+ // segments. Passing an empty array makes the shared `renderRoot` build
92
+ // `currentRoute` as `/admin/` (trailing slash), which no longer equals
93
+ // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.
94
+ // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated
95
+ // redirect lands on a clean `/admin/login`.
96
+ const segments = splatSegments.length > 0 ? splatSegments : undefined;
97
+ const searchParams = search ?? {};
98
+ // Records navigation requested via `req.server.*` (including throws swallowed
99
+ // by RSC streaming deep inside view components). Read after the render.
100
+ const nav = {};
101
+ const pageServerAdapter = createPageRenderServerAdapter(nav);
102
+ // `renderRoot` calls `initReq` itself with its own overrides (query
103
+ // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
104
+ // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
105
+ // is recorded + thrown rather than escaping as raw TanStack nav.
106
+ const boundInitReq = (args)=>initReq({
107
+ configPromise: args.configPromise,
108
+ importMap: args.importMap,
109
+ overrides: args.overrides,
110
+ serverAdapter: pageServerAdapter
111
+ });
112
+ const notFound = ()=>{
113
+ nav.type = 'notFound';
114
+ throw new Error('not-found');
115
+ };
116
+ const redirect = (url)=>{
117
+ nav.type = 'redirect';
118
+ nav.url = url;
119
+ throw new Error(`redirect:${url}`);
120
+ };
121
+ // Build the 404 result the route loader re-throws as TanStack `notFound()`.
122
+ //
123
+ // Throwing `notFound()` is the only way to set the SSR document status to 404
124
+ // (it's read from `router.stores.statusCode`, set by a not-found match — NOT
125
+ // from `setResponseStatus`, which only affects the RSC RPC response). But the
126
+ // matching `notFoundComponent` is a client component with no access to the
127
+ // Payload `req`, so it can't build the admin chrome on its own. To match Next
128
+ // (whose not-found route renders the full admin layout — nav sidebar, etc. —
129
+ // around the NotFound body, see `renderNotFoundPage`), we render that same
130
+ // shared `renderNotFoundPage` tree here, server-side, and ship its Flight
131
+ // payload through the `notFound()` error so the client renders it verbatim.
132
+ // For users without admin access `renderNotFoundPage` returns the bare
133
+ // `NotFoundClient`, preserving the access-denied behavior.
134
+ const renderNotFound = async ()=>{
135
+ const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page');
136
+ const notFoundNode = await renderNotFoundPage({
137
+ config: Promise.resolve(config),
138
+ importMap,
139
+ initReq: (args)=>initReq({
140
+ configPromise: args.configPromise,
141
+ importMap: args.importMap,
142
+ overrides: args.overrides
143
+ }),
144
+ params: Promise.resolve({
145
+ segments: splatSegments
146
+ }),
147
+ searchParams: Promise.resolve(searchParams)
148
+ });
149
+ const rscPayload = await renderServerComponent(notFoundNode);
150
+ return {
151
+ _notFound: true,
152
+ routeKey: splat ?? '',
153
+ rscPayload
154
+ };
155
+ };
156
+ try {
157
+ const node = await renderRoot({
158
+ adminViews: defaultAdminViews,
159
+ config: Promise.resolve(config),
160
+ importMap,
161
+ initReq: boundInitReq,
162
+ notFound,
163
+ // `segments` is intentionally `undefined` for the admin root (`/admin`),
164
+ // matching Next's optional catch-all; `renderRoot` handles it at runtime.
165
+ params: Promise.resolve({
166
+ segments
167
+ }),
168
+ redirect,
169
+ searchParams: Promise.resolve(searchParams)
170
+ });
171
+ const rscPayload = await renderServerComponent(node);
172
+ // The server-function (client-nav RPC) path returns the flight stream unread —
173
+ // unlike the router/SSR path, which awaits a decode that drives the render to
174
+ // completion. So streamed side effects (e.g. DocumentView's autosave-create
175
+ // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to
176
+ // completion to force the render (populating `nav`), then hand the client a fresh
177
+ // replayable stream from that buffer.
178
+ if (!nav.type) {
179
+ const wrapper = rscPayload[Symbol.for('tanstack.rsc.stream')];
180
+ if (typeof wrapper?.createReplayStream === 'function') {
181
+ const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer();
182
+ wrapper.createReplayStream = ()=>new Response(buffer).body;
183
+ }
184
+ }
185
+ // Navigation thrown deep inside a streamed view component (e.g. access
186
+ // denied → notFound, already-authenticated → redirect) is swallowed into
187
+ // the RSC stream and never rejects the render. Honor it from the holder,
188
+ // discarding the (broken) payload from the aborted render.
189
+ if (nav.type === 'redirect' && nav.url) {
190
+ return {
191
+ _redirect: nav.url
192
+ };
193
+ }
194
+ if (nav.type === 'notFound') {
195
+ return await renderNotFound();
196
+ }
197
+ // Resolve metadata through the same shared generator Next.js uses. Only
198
+ // plain strings cross the wire (the full `MetaConfig` carries a `URL`
199
+ // `metadataBase` and icons that seroval cannot serialize).
200
+ const i18n = await getRequestI18n({
201
+ config
202
+ });
203
+ const meta = await generatePageMetadata({
204
+ adminViews: defaultAdminViews,
205
+ config,
206
+ i18n,
207
+ params: {
208
+ segments
209
+ }
210
+ });
211
+ return {
212
+ metadata: toAdminPageMetadata(meta),
213
+ routeKey: splat ?? '',
214
+ rscPayload
215
+ };
216
+ } catch (err) {
217
+ const message = err instanceof Error ? err.message : String(err);
218
+ if (nav.type === 'notFound' || message === 'not-found') {
219
+ return await renderNotFound();
220
+ }
221
+ if (nav.type === 'redirect' || message.startsWith('redirect:')) {
222
+ return {
223
+ _redirect: nav.url ?? message.slice('redirect:'.length)
224
+ };
225
+ }
226
+ throw err;
227
+ }
228
+ }
229
+
230
+ //# sourceMappingURL=loadAdminPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: React.ReactNode }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: React.ReactNode\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\n}\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n\n // `renderRoot` calls `initReq` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initReq: boundInitReq,\n notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: toAdminPageMetadata(meta),\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["renderServerComponent","getRequestI18n","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","boundInitReq","args","configPromise","overrides","serverAdapter","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","err","message","startsWith","slice"],"mappings":"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,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BAAuB;YACpC,IAAI,OAAOF,SAASG,uBAAuB,YAAY;gBACrD,MAAMC,SAAS,MAAM,IAAIC,SAASL,QAAQG,kBAAkB,IAAIG,WAAW;gBAC3EN,QAAQG,kBAAkB,GAAG,IAAM,IAAIE,SAASD,QAAQG,IAAI;YAC9D;QACF;QAEA,uEAAuE;QACvE,yEAAyE;QACzE,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI5B,IAAIrB,IAAI,KAAK,cAAcqB,IAAIjC,GAAG,EAAE;YACtC,OAAO;gBAAE8D,WAAW7B,IAAIjC,GAAG;YAAC;QAC9B;QACA,IAAIiC,IAAIrB,IAAI,KAAK,YAAY;YAC3B,OAAO,MAAM+B;QACf;QAEA,wEAAwE;QACxE,sEAAsE;QACtE,2DAA2D;QAC3D,MAAMoB,OAAO,MAAMlF,eAAe;YAAEyC;QAAO;QAC3C,MAAMhC,OAAO,MAAMsC,qBAAqB;YACtCyB,YAAY1B;YACZL;YACAyC;YACAf,QAAQ;gBAAEjB;YAAS;QACrB;QAEA,OAAO;YACLiC,UAAU3E,oBAAoBC;YAC9B6D,UAAU1B,SAAS;YACnBwB;QACF;IACF,EAAE,OAAOgB,KAAK;QACZ,MAAMC,UAAUD,eAAexB,QAAQwB,IAAIC,OAAO,GAAG/D,OAAO8D;QAC5D,IAAIhC,IAAIrB,IAAI,KAAK,cAAcsD,YAAY,aAAa;YACtD,OAAO,MAAMvB;QACf;QACA,IAAIV,IAAIrB,IAAI,KAAK,cAAcsD,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEL,WAAW7B,IAAIjC,GAAG,IAAIkE,QAAQE,KAAK,CAAC,YAAYnD,MAAM;YAAE;QACnE;QACA,MAAMgD;IACR;AACF"}
@@ -0,0 +1,15 @@
1
+ import type { ImportMap, SanitizedConfig } from 'payload';
2
+ /**
3
+ * Resolves the admin layout data for TanStack Start and returns a serializable
4
+ * payload for the `/_payload` route loader. The framework adapter wraps this in
5
+ * a `createServerFn` that supplies the app's `config` and generated `importMap`.
6
+ *
7
+ * `toSerializable` strips React elements, so the custom-providers element tree
8
+ * (`config.admin.components.providers`) is rendered to an RSC payload separately
9
+ * and re-attached.
10
+ */
11
+ export declare function loadLayoutData({ config, importMap, }: {
12
+ config: SanitizedConfig;
13
+ importMap: ImportMap;
14
+ }): Promise<Record<string, unknown>>;
15
+ //# sourceMappingURL=loadLayoutData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadLayoutData.d.ts","sourceRoot":"","sources":["../../src/utilities/loadLayoutData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAOzD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAOnC"}