@payloadcms/tanstack-start 4.0.0-internal.ccea85d → 4.0.0-internal.cd47d20

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 (234) 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/elements/RouterAdapter/index.d.ts.map +1 -1
  14. package/dist/elements/RouterAdapter/index.js +18 -3
  15. package/dist/elements/RouterAdapter/index.js.map +1 -1
  16. package/dist/exports/client.d.ts +0 -2
  17. package/dist/exports/client.d.ts.map +1 -1
  18. package/dist/exports/client.js +0 -2
  19. package/dist/exports/client.js.map +1 -1
  20. package/dist/exports/layouts.d.ts +2 -4
  21. package/dist/exports/layouts.d.ts.map +1 -1
  22. package/dist/exports/layouts.js +0 -1
  23. package/dist/exports/layouts.js.map +1 -1
  24. package/dist/exports/rsc.browser.d.ts +4 -1
  25. package/dist/exports/rsc.browser.d.ts.map +1 -1
  26. package/dist/exports/rsc.browser.js +4 -1
  27. package/dist/exports/rsc.browser.js.map +1 -1
  28. package/dist/exports/rsc.d.ts +0 -1
  29. package/dist/exports/rsc.d.ts.map +1 -1
  30. package/dist/exports/rsc.js +0 -1
  31. package/dist/exports/rsc.js.map +1 -1
  32. package/dist/exports/server.d.ts +3 -5
  33. package/dist/exports/server.d.ts.map +1 -1
  34. package/dist/exports/server.js +2 -4
  35. package/dist/exports/server.js.map +1 -1
  36. package/dist/exports/shared.d.ts +2 -0
  37. package/dist/exports/shared.d.ts.map +1 -0
  38. package/dist/exports/shared.js +3 -0
  39. package/dist/exports/shared.js.map +1 -0
  40. package/dist/index.d.ts +1 -6
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +1 -6
  43. package/dist/index.js.map +1 -1
  44. package/dist/layouts/Root/getLayoutData.d.ts +24 -2
  45. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  46. package/dist/layouts/Root/getLayoutData.js +11 -5
  47. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  48. package/dist/routes/adminRoutes.d.ts +10 -13
  49. package/dist/routes/adminRoutes.d.ts.map +1 -1
  50. package/dist/routes/adminRoutes.js +53 -45
  51. package/dist/routes/adminRoutes.js.map +1 -1
  52. package/dist/routes/apiRoute.d.ts +5 -0
  53. package/dist/routes/apiRoute.d.ts.map +1 -1
  54. package/dist/routes/apiRoute.js +6 -1
  55. package/dist/routes/apiRoute.js.map +1 -1
  56. package/dist/routes/layoutRoute.d.ts +5 -4
  57. package/dist/routes/layoutRoute.d.ts.map +1 -1
  58. package/dist/routes/layoutRoute.js +3 -1
  59. package/dist/routes/layoutRoute.js.map +1 -1
  60. package/dist/utilities/devConfigReload.server.d.ts +2 -0
  61. package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
  62. package/dist/utilities/devConfigReload.server.js +38 -0
  63. package/dist/utilities/devConfigReload.server.js.map +1 -0
  64. package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
  65. package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
  66. package/dist/utilities/devConfigReloadEvent.js +9 -0
  67. package/dist/utilities/devConfigReloadEvent.js.map +1 -0
  68. package/dist/utilities/getRequestI18n.server.d.ts +1 -1
  69. package/dist/utilities/getRequestI18n.server.js +1 -1
  70. package/dist/utilities/getRequestI18n.server.js.map +1 -1
  71. package/dist/utilities/graphqlHandler.server.js +2 -2
  72. package/dist/utilities/graphqlHandler.server.js.map +1 -1
  73. package/dist/utilities/{handleAPIRoute.d.ts → handleAPIRoute.server.d.ts} +1 -1
  74. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  75. package/dist/utilities/{handleAPIRoute.js → handleAPIRoute.server.js} +1 -1
  76. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  77. package/dist/utilities/handleServerFunctions.d.ts +1 -19
  78. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  79. package/dist/utilities/handleServerFunctions.js +6 -57
  80. package/dist/utilities/handleServerFunctions.js.map +1 -1
  81. package/dist/utilities/initAdminContext.server.d.ts +9 -0
  82. package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
  83. package/dist/utilities/initAdminContext.server.js +13 -0
  84. package/dist/utilities/initAdminContext.server.js.map +1 -0
  85. package/dist/utilities/loadAdminPage.d.ts +7 -4
  86. package/dist/utilities/loadAdminPage.d.ts.map +1 -1
  87. package/dist/utilities/loadAdminPage.js +12 -24
  88. package/dist/utilities/loadAdminPage.js.map +1 -1
  89. package/dist/utilities/loadLayoutData.d.ts +3 -1
  90. package/dist/utilities/loadLayoutData.d.ts.map +1 -1
  91. package/dist/utilities/loadLayoutData.js +2 -3
  92. package/dist/utilities/loadLayoutData.js.map +1 -1
  93. package/dist/utilities/meta.js +1 -1
  94. package/dist/utilities/meta.js.map +1 -1
  95. package/dist/utilities/routerSearch.d.ts +1 -1
  96. package/dist/utilities/routerSearch.js +1 -1
  97. package/dist/utilities/routerSearch.js.map +1 -1
  98. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  99. package/dist/utilities/serializeForRsc.js +6 -1
  100. package/dist/utilities/serializeForRsc.js.map +1 -1
  101. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  102. package/dist/utilities/serverFunctionClient.js +6 -1
  103. package/dist/utilities/serverFunctionClient.js.map +1 -1
  104. package/dist/utilities/toSerializable.d.ts +9 -0
  105. package/dist/utilities/toSerializable.d.ts.map +1 -1
  106. package/dist/utilities/toSerializable.js +19 -3
  107. package/dist/utilities/toSerializable.js.map +1 -1
  108. package/dist/withPayload/config/external.d.ts +44 -0
  109. package/dist/withPayload/config/external.d.ts.map +1 -0
  110. package/dist/withPayload/config/external.js +96 -0
  111. package/dist/withPayload/config/external.js.map +1 -0
  112. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
  113. package/dist/{vite → withPayload}/config/optimizeDeps.js +27 -7
  114. package/dist/withPayload/config/optimizeDeps.js.map +1 -0
  115. package/dist/withPayload/config/scss.d.ts.map +1 -0
  116. package/dist/withPayload/config/scss.js.map +1 -0
  117. package/dist/withPayload/devConfigReload.d.ts +14 -0
  118. package/dist/withPayload/devConfigReload.d.ts.map +1 -0
  119. package/dist/withPayload/devConfigReload.js +84 -0
  120. package/dist/withPayload/devConfigReload.js.map +1 -0
  121. package/dist/withPayload/importProtection.d.ts.map +1 -0
  122. package/dist/{vite → withPayload}/importProtection.js +2 -2
  123. package/dist/withPayload/importProtection.js.map +1 -0
  124. package/dist/{vite → withPayload}/index.d.ts +19 -0
  125. package/dist/withPayload/index.d.ts.map +1 -0
  126. package/dist/{vite → withPayload}/index.js +61 -11
  127. package/dist/withPayload/index.js.map +1 -0
  128. package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
  129. package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
  130. package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
  131. package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
  132. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  133. package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
  134. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
  135. package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.js +1 -1
  136. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
  137. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
  138. package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
  139. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
  140. package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
  141. package/package.json +15 -14
  142. package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
  143. package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
  144. package/dist/elements/DocumentHeaderClient/index.js +0 -116
  145. package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
  146. package/dist/elements/RenderComponent/index.d.ts +0 -10
  147. package/dist/elements/RenderComponent/index.d.ts.map +0 -1
  148. package/dist/elements/RenderComponent/index.js +0 -12
  149. package/dist/elements/RenderComponent/index.js.map +0 -1
  150. package/dist/exports/vite.d.ts +0 -3
  151. package/dist/exports/vite.d.ts.map +0 -1
  152. package/dist/exports/vite.js +0 -3
  153. package/dist/exports/vite.js.map +0 -1
  154. package/dist/layouts/Root/index.d.ts +0 -32
  155. package/dist/layouts/Root/index.d.ts.map +0 -1
  156. package/dist/layouts/Root/index.js +0 -53
  157. package/dist/layouts/Root/index.js.map +0 -1
  158. package/dist/rsc/renderPayloadRSC.d.ts +0 -6
  159. package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
  160. package/dist/rsc/renderPayloadRSC.js +0 -6
  161. package/dist/rsc/renderPayloadRSC.js.map +0 -1
  162. package/dist/utilities/devReloadStrategy.d.ts +0 -10
  163. package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
  164. package/dist/utilities/devReloadStrategy.js +0 -27
  165. package/dist/utilities/devReloadStrategy.js.map +0 -1
  166. package/dist/utilities/getExistingAuthToken.d.ts +0 -7
  167. package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
  168. package/dist/utilities/getExistingAuthToken.js +0 -18
  169. package/dist/utilities/getExistingAuthToken.js.map +0 -1
  170. package/dist/utilities/getPreferences.d.ts +0 -10
  171. package/dist/utilities/getPreferences.d.ts.map +0 -1
  172. package/dist/utilities/getPreferences.js +0 -33
  173. package/dist/utilities/getPreferences.js.map +0 -1
  174. package/dist/utilities/getRequestLocale.d.ts +0 -7
  175. package/dist/utilities/getRequestLocale.d.ts.map +0 -1
  176. package/dist/utilities/getRequestLocale.js +0 -20
  177. package/dist/utilities/getRequestLocale.js.map +0 -1
  178. package/dist/utilities/handleAPIRoute.d.ts.map +0 -1
  179. package/dist/utilities/handleAPIRoute.js.map +0 -1
  180. package/dist/utilities/importMap.server.d.ts +0 -8
  181. package/dist/utilities/importMap.server.d.ts.map +0 -1
  182. package/dist/utilities/importMap.server.js +0 -11
  183. package/dist/utilities/importMap.server.js.map +0 -1
  184. package/dist/utilities/initReq.server.d.ts +0 -19
  185. package/dist/utilities/initReq.server.d.ts.map +0 -1
  186. package/dist/utilities/initReq.server.js +0 -87
  187. package/dist/utilities/initReq.server.js.map +0 -1
  188. package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
  189. package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
  190. package/dist/utilities/serverFunctionHandlers.js +0 -17
  191. package/dist/utilities/serverFunctionHandlers.js.map +0 -1
  192. package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
  193. package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
  194. package/dist/utilities/setPayloadAuthCookie.js +0 -31
  195. package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
  196. package/dist/vite/config/external.d.ts +0 -11
  197. package/dist/vite/config/external.d.ts.map +0 -1
  198. package/dist/vite/config/external.js +0 -48
  199. package/dist/vite/config/external.js.map +0 -1
  200. package/dist/vite/config/optimizeDeps.d.ts.map +0 -1
  201. package/dist/vite/config/optimizeDeps.js.map +0 -1
  202. package/dist/vite/config/scss.d.ts.map +0 -1
  203. package/dist/vite/config/scss.js.map +0 -1
  204. package/dist/vite/importProtection.d.ts.map +0 -1
  205. package/dist/vite/importProtection.js.map +0 -1
  206. package/dist/vite/index.d.ts.map +0 -1
  207. package/dist/vite/index.js.map +0 -1
  208. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +0 -1
  209. package/dist/vite/workarounds/clientModuleResolution.js.map +0 -1
  210. package/dist/vite/workarounds/devTransforms.d.ts.map +0 -1
  211. package/dist/vite/workarounds/devTransforms.js.map +0 -1
  212. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +0 -1
  213. package/dist/vite/workarounds/reactDomServerInRsc.js.map +0 -1
  214. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +0 -1
  215. package/dist/vite/workarounds/stripDistStyleImports.js.map +0 -1
  216. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +0 -1
  217. package/dist/vite/workarounds/stubPrettierInClient.js.map +0 -1
  218. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +0 -1
  219. package/dist/vite/workarounds/wrapCjsForClient.js.map +0 -1
  220. /package/dist/{vite → withPayload}/config/optimizeDeps.d.ts +0 -0
  221. /package/dist/{vite → withPayload}/config/scss.d.ts +0 -0
  222. /package/dist/{vite → withPayload}/config/scss.js +0 -0
  223. /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
  224. /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.d.ts +0 -0
  225. /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.js +0 -0
  226. /package/dist/{vite → withPayload}/workarounds/devTransforms.d.ts +0 -0
  227. /package/dist/{vite → withPayload}/workarounds/devTransforms.js +0 -0
  228. /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.d.ts +0 -0
  229. /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.js +0 -0
  230. /package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.d.ts +0 -0
  231. /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.d.ts +0 -0
  232. /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.js +0 -0
  233. /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.d.ts +0 -0
  234. /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.js +0 -0
@@ -0,0 +1,38 @@
1
+ import { registerDevReloadStrategy } from 'payload';
2
+ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
3
+ /**
4
+ * Subscribes the Payload instance to the config-changed event that the
5
+ * `payload:dev-config-reload` Vite plugin broadcasts.
6
+ *
7
+ * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only
8
+ * `getPayload` call site, so the strategy is registered before an instance can
9
+ * be built. Registration is module-scoped on both ends: this runs inside the
10
+ * app's server graph and so resolves the same copy of `payload` that
11
+ * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
12
+ * its own listener against its own copy.
13
+ *
14
+ * Vite re-evaluates this module on a program reload, which drops the listeners
15
+ * the previous instance had collected. `getPayload` reconnects on its next call
16
+ * because the registered strategy is a new object - see `connectDevReload`.
17
+ *
18
+ * `import.meta.hot` is only defined during dev serve, so this is inert in a
19
+ * production build.
20
+ */ const hot = import.meta.hot;
21
+ if (hot) {
22
+ const listeners = new Set();
23
+ hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
24
+ for (const onReload of listeners){
25
+ onReload();
26
+ }
27
+ });
28
+ registerDevReloadStrategy({
29
+ connect: (onReload)=>{
30
+ listeners.add(onReload);
31
+ return ()=>{
32
+ listeners.delete(onReload);
33
+ };
34
+ }
35
+ });
36
+ }
37
+
38
+ //# sourceMappingURL=devConfigReload.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only\n * `getPayload` call site, so the strategy is registered before an instance can\n * be built. Registration is module-scoped on both ends: this runs inside the\n * app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n const listeners = new Set<() => void>()\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n registerDevReloadStrategy({\n connect: (onReload) => {\n listeners.add(onReload)\n\n return () => {\n listeners.delete(onReload)\n }\n },\n })\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","listeners","Set","on","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;;;CAiBC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACP,MAAMC,YAAY,IAAIC;IAEtBF,IAAIG,EAAE,CAACJ,8BAA8B;QACnC,KAAK,MAAMK,YAAYH,UAAW;YAChCG;QACF;IACF;IAEAN,0BAA0B;QACxBO,SAAS,CAACD;YACRH,UAAUK,GAAG,CAACF;YAEd,OAAO;gBACLH,UAAUM,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
3
+ * the Payload config (or anything it imports) changes on disk.
4
+ *
5
+ * Kept in its own module so the Vite plugin can name the event without pulling
6
+ * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
7
+ */
8
+ export declare const PAYLOAD_CONFIG_CHANGED_EVENT = "payload:config-changed";
9
+ //# sourceMappingURL=devConfigReloadEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devConfigReloadEvent.d.ts","sourceRoot":"","sources":["../../src/utilities/devConfigReloadEvent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,2BAA2B,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
3
+ * the Payload config (or anything it imports) changes on disk.
4
+ *
5
+ * Kept in its own module so the Vite plugin can name the event without pulling
6
+ * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
7
+ */ export const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed';
8
+
9
+ //# sourceMappingURL=devConfigReloadEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/devConfigReloadEvent.ts"],"sourcesContent":["/**\n * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when\n * the Payload config (or anything it imports) changes on disk.\n *\n * Kept in its own module so the Vite plugin can name the event without pulling\n * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.\n */\nexport const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed'\n"],"names":["PAYLOAD_CONFIG_CHANGED_EVENT"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,+BAA+B,yBAAwB"}
@@ -2,7 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
2
2
  import type { SanitizedConfig } from 'payload';
3
3
  /**
4
4
  * Resolves the client `I18n` for the current TanStack Start request without a
5
- * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
5
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
6
6
  * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
7
7
  * needs `config` + `i18n` to translate admin-page titles.
8
8
  */
@@ -3,7 +3,7 @@ import { getRequest } from '@tanstack/react-start/server';
3
3
  import { getRequestLanguage, parseCookies } from 'payload';
4
4
  /**
5
5
  * Resolves the client `I18n` for the current TanStack Start request without a
6
- * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
6
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
7
7
  * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
8
8
  * needs `config` + `i18n` to translate admin-page titles.
9
9
  */ export async function getRequestI18n({ config }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
@@ -1,4 +1,4 @@
1
- import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequest, headersWithCors, logError, mergeHeaders } from 'payload';
1
+ import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
2
2
  const handleError = async ({ err, payload, req })=>{
3
3
  const status = err.originalError?.status || 500;
4
4
  let errorMessage = err.message;
@@ -72,7 +72,7 @@ const getGraphql = async (config)=>{
72
72
  * Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.
73
73
  */ export const handleGraphQL = async ({ config, request })=>{
74
74
  const originalRequest = request.clone();
75
- const req = await createPayloadRequest({
75
+ const req = await createPayloadRequestFromWebRequest({
76
76
  canSetHeaders: true,
77
77
  config,
78
78
  request
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/graphqlHandler.server.ts"],"sourcesContent":["import type { Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport {\n addDataAndFileToRequest,\n addLocalesToRequestFromData,\n createPayloadRequest,\n headersWithCors,\n logError,\n mergeHeaders,\n} from 'payload'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: any\n payload: Payload\n req: PayloadRequest\n}): Promise<any> => {\n const status = err.originalError?.status || 500\n let errorMessage = err.message\n logError({ err, payload })\n\n if (!payload.config.debug && status === 500) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: any = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached: { graphql: any; promise: null | Promise<any> } = { graphql: null, promise: null }\n\nconst getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n const graphqlPackage = '@payloadcms/graphql'\n const { configToSchema } = await import(/* @vite-ignore */ graphqlPackage)\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\n/**\n * Handles GraphQL HTTP requests for TanStack Start apps.\n * Mirrors the behaviour of `@payloadcms/next`'s GraphQL route handler.\n *\n * Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.\n */\nexport const handleGraphQL = async ({\n config,\n request,\n}: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n request: Request\n}): Promise<Response> => {\n const originalRequest = request.clone()\n\n const req = await createPayloadRequest({\n canSetHeaders: true,\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const graphqlHttpHandlerPath = 'graphql-http/lib/use/fetch'\n const { createHandler } = await import(/* @vite-ignore */ graphqlHttpHandlerPath)\n\n const headers: Record<string, string> = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (_request: any, args: any, result: any) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: _request,\n result,\n })\n : result\n if (response.errors) {\n const errors = await Promise.all(\n response.errors.map((error: any) => {\n return handleError({ err: error, payload, req })\n }),\n )\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_: any, args: any, defaultRules: any) =>\n defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key of Object.keys(headers)) {\n resHeaders.append(key, headers[key]!)\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n}\n"],"names":["addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","logError","mergeHeaders","handleError","err","payload","req","status","originalError","errorMessage","message","config","debug","response","extensions","name","undefined","data","stack","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","error","graphqlResult","Promise","resolve","cached","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","graphqlPackage","configToSchema","schema","e","handleGraphQL","request","originalRequest","clone","canSetHeaders","validationRules","graphqlHttpHandlerPath","createHandler","headers","apiResponse","onOperation","_request","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","Object","keys","append","Response","body","responseHeaders"],"mappings":"AAEA,SACEA,uBAAuB,EACvBC,2BAA2B,EAC3BC,oBAAoB,EACpBC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP,UAAS;AAEhB,MAAMC,cAAc,OAAO,EACzBC,GAAG,EACHC,OAAO,EACPC,GAAG,EAKJ;IACC,MAAMC,SAASH,IAAII,aAAa,EAAED,UAAU;IAC5C,IAAIE,eAAeL,IAAIM,OAAO;IAC9BT,SAAS;QAAEG;QAAKC;IAAQ;IAExB,IAAI,CAACA,QAAQM,MAAM,CAACC,KAAK,IAAIL,WAAW,KAAK;QAC3CE,eAAe;IACjB;IAEA,IAAII,WAAgB;QAClBC,YAAY;YACVC,MAAMX,KAAKI,eAAeO,QAAQC;YAClCC,MAAM,AAACb,OAAOA,IAAII,aAAa,IAAIJ,IAAII,aAAa,CAACS,IAAI,IAAKD;YAC9DE,OAAOb,QAAQM,MAAM,CAACC,KAAK,GAAGR,IAAIc,KAAK,GAAGF;YAC1CG,YAAYZ;QACd;QACAa,WAAWhB,IAAIgB,SAAS;QACxBV,SAASD;QACTY,MAAMjB,IAAIiB,IAAI;IAChB;IAEA,MAAMhB,QAAQM,MAAM,CAACW,KAAK,CAACC,UAAU,EAAEC,OAAO,OAAOC,SAASC;QAC5D,MAAMD;QAEN,MAAME,SAAS,MAAMD,KAAK;YACxBE,SAAStB,IAAIsB,OAAO;YACpBC,OAAOzB;YACP0B,eAAejB;YACfP;QACF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,gBAAgB,GAAGD;IAE1D,MAAME,UAAkC,CAAC;IACzC,MAAMC,cAAc,MAAMF,cAAc;QACtCvB,SAAS;YAAEwB;YAAS9C;QAAI;QACxBgD,aAAa,OAAOC,UAAeC,MAAW7B;YAC5C,MAAMd,WACJ,OAAOR,QAAQS,UAAU,KAAK,aAC1B,MAAMT,QAAQS,UAAU,CAAC;gBACvB0C;gBACAlD,KAAKiD;gBACL5B;YACF,KACAA;YACN,IAAId,SAAS4C,MAAM,EAAE;gBACnB,MAAMA,SAAS,MAAM1B,QAAQ2B,GAAG,CAC9B7C,SAAS4C,MAAM,CAACE,GAAG,CAAC,CAAC9B;oBACnB,OAAO1B,YAAY;wBAAEC,KAAKyB;wBAAOxB;wBAASC;oBAAI;gBAChD;gBAEF,OAAO;oBAAE,GAAGO,QAAQ;oBAAE4C;gBAAO;YAC/B;YACA,OAAO5C;QACT;QACA6B;QACAO,iBAAiB,CAACW,GAAQJ,MAAWK,eACnCA,aAAaC,MAAM,CAACb,gBAAgBO;IACxC,GAAGV;IAEH,MAAMiB,aAAa/D,gBAAgB;QACjCoD,SAAS,IAAIY,QAAQX,YAAYD,OAAO;QACxC9C;IACF;IAEA,KAAK,MAAM2D,OAAOC,OAAOC,IAAI,CAACf,SAAU;QACtCW,WAAWK,MAAM,CAACH,KAAKb,OAAO,CAACa,IAAI;IACrC;IAEA,OAAO,IAAII,SAAShB,YAAYiB,IAAI,EAAE;QACpClB,SAAS9C,IAAIiE,eAAe,GAAGrE,aAAaI,IAAIiE,eAAe,EAAER,cAAcA;QAC/ExD,QAAQ8C,YAAY9C,MAAM;IAC5B;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/graphqlHandler.server.ts"],"sourcesContent":["import type { Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport {\n addDataAndFileToRequest,\n addLocalesToRequestFromData,\n createPayloadRequestFromWebRequest,\n headersWithCors,\n logError,\n mergeHeaders,\n} from 'payload'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: any\n payload: Payload\n req: PayloadRequest\n}): Promise<any> => {\n const status = err.originalError?.status || 500\n let errorMessage = err.message\n logError({ err, payload })\n\n if (!payload.config.debug && status === 500) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: any = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached: { graphql: any; promise: null | Promise<any> } = { graphql: null, promise: null }\n\nconst getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n const graphqlPackage = '@payloadcms/graphql'\n const { configToSchema } = await import(/* @vite-ignore */ graphqlPackage)\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\n/**\n * Handles GraphQL HTTP requests for TanStack Start apps.\n * Mirrors the behaviour of `@payloadcms/next`'s GraphQL route handler.\n *\n * Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.\n */\nexport const handleGraphQL = async ({\n config,\n request,\n}: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n request: Request\n}): Promise<Response> => {\n const originalRequest = request.clone()\n\n const req = await createPayloadRequestFromWebRequest({\n canSetHeaders: true,\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const graphqlHttpHandlerPath = 'graphql-http/lib/use/fetch'\n const { createHandler } = await import(/* @vite-ignore */ graphqlHttpHandlerPath)\n\n const headers: Record<string, string> = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (_request: any, args: any, result: any) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: _request,\n result,\n })\n : result\n if (response.errors) {\n const errors = await Promise.all(\n response.errors.map((error: any) => {\n return handleError({ err: error, payload, req })\n }),\n )\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_: any, args: any, defaultRules: any) =>\n defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key of Object.keys(headers)) {\n resHeaders.append(key, headers[key]!)\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n}\n"],"names":["addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequestFromWebRequest","headersWithCors","logError","mergeHeaders","handleError","err","payload","req","status","originalError","errorMessage","message","config","debug","response","extensions","name","undefined","data","stack","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","error","graphqlResult","Promise","resolve","cached","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","graphqlPackage","configToSchema","schema","e","handleGraphQL","request","originalRequest","clone","canSetHeaders","validationRules","graphqlHttpHandlerPath","createHandler","headers","apiResponse","onOperation","_request","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","Object","keys","append","Response","body","responseHeaders"],"mappings":"AAEA,SACEA,uBAAuB,EACvBC,2BAA2B,EAC3BC,kCAAkC,EAClCC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP,UAAS;AAEhB,MAAMC,cAAc,OAAO,EACzBC,GAAG,EACHC,OAAO,EACPC,GAAG,EAKJ;I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YACA,OAAO5C;QACT;QACA6B;QACAO,iBAAiB,CAACW,GAAQJ,MAAWK,eACnCA,aAAaC,MAAM,CAACb,gBAAgBO;IACxC,GAAGV;IAEH,MAAMiB,aAAa/D,gBAAgB;QACjCoD,SAAS,IAAIY,QAAQX,YAAYD,OAAO;QACxC9C;IACF;IAEA,KAAK,MAAM2D,OAAOC,OAAOC,IAAI,CAACf,SAAU;QACtCW,WAAWK,MAAM,CAACH,KAAKb,OAAO,CAACa,IAAI;IACrC;IAEA,OAAO,IAAII,SAAShB,YAAYiB,IAAI,EAAE;QACpClB,SAAS9C,IAAIiE,eAAe,GAAGrE,aAAaI,IAAIiE,eAAe,EAAER,cAAcA;QAC/ExD,QAAQ8C,YAAY9C,MAAM;IAC5B;AACF,EAAC"}
@@ -8,4 +8,4 @@ export declare function handleAPIRoute({ config, request, }: {
8
8
  config: SanitizedConfig;
9
9
  request: Request;
10
10
  }): Promise<Response>;
11
- //# sourceMappingURL=handleAPIRoute.d.ts.map
11
+ //# sourceMappingURL=handleAPIRoute.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleAPIRoute.server.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
@@ -14,4 +14,4 @@ import { handleEndpoints } from 'payload';
14
14
  });
15
15
  }
16
16
 
17
- //# sourceMappingURL=handleAPIRoute.js.map
17
+ //# sourceMappingURL=handleAPIRoute.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/handleAPIRoute.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
@@ -1,20 +1,2 @@
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;
1
+ export declare const handleServerFunctions: import("payload").ServerFunctionHandler;
20
2
  //# sourceMappingURL=handleServerFunctions.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,yCAGhC,CAAA"}
@@ -1,60 +1,9 @@
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';
1
+ import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions';
2
+ import { initAdminContext } from './initAdminContext.server.js';
9
3
  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
- };
4
+ export const handleServerFunctions = createServerFunctionHandler({
5
+ initAdminContext,
6
+ transformResult: serializeForRsc
7
+ });
59
8
 
60
9
  //# sourceMappingURL=handleServerFunctions.js.map
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions'\n\nimport { initAdminContext } from './initAdminContext.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\n\nexport const handleServerFunctions = createServerFunctionHandler({\n initAdminContext,\n transformResult: serializeForRsc,\n})\n"],"names":["createServerFunctionHandler","initAdminContext","serializeForRsc","handleServerFunctions","transformResult"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iDAAgD;AAE5F,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,OAAO,MAAMC,wBAAwBH,4BAA4B;IAC/DC;IACAG,iBAAiBF;AACnB,GAAE"}
@@ -0,0 +1,9 @@
1
+ import type { ServerAdapter } from 'payload';
2
+ import type { InitAdminContextArgs } from 'payload/internal';
3
+ import './devConfigReload.server.js';
4
+ type TanStackInitAdminContextArgs = {
5
+ serverAdapter?: ServerAdapter;
6
+ } & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>;
7
+ export declare const initAdminContext: ({ serverAdapter, ...args }: TanStackInitAdminContextArgs) => Promise<import("payload").AdminContext>;
8
+ export {};
9
+ //# sourceMappingURL=initAdminContext.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initAdminContext.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initAdminContext.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAO5D,OAAO,6BAA6B,CAAA;AAGpC,KAAK,4BAA4B,GAAG;IAClC,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC,CAAA;AAExE,eAAO,MAAM,gBAAgB,+BAG1B,4BAA4B,4CAK3B,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { getRequest } from '@tanstack/react-start/server';
2
+ import { initAdminContext as initPayloadAdminContext } from 'payload/internal';
3
+ // Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.
4
+ // Side-effect only, and a no-op outside of dev serve.
5
+ import './devConfigReload.server.js';
6
+ import { tanstackServerAdapter } from './serverAdapter.server.js';
7
+ export const initAdminContext = ({ serverAdapter = tanstackServerAdapter, ...args })=>initPayloadAdminContext({
8
+ ...args,
9
+ requestURL: getRequest().url,
10
+ serverAdapter
11
+ });
12
+
13
+ //# sourceMappingURL=initAdminContext.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/initAdminContext.server.ts"],"sourcesContent":["import type { ServerAdapter } from 'payload'\nimport type { InitAdminContextArgs } from 'payload/internal'\n\nimport { getRequest } from '@tanstack/react-start/server'\nimport { initAdminContext as initPayloadAdminContext } from 'payload/internal'\n\n// Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.\n// Side-effect only, and a no-op outside of dev serve.\nimport './devConfigReload.server.js'\nimport { tanstackServerAdapter } from './serverAdapter.server.js'\n\ntype TanStackInitAdminContextArgs = {\n serverAdapter?: ServerAdapter\n} & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>\n\nexport const initAdminContext = ({\n serverAdapter = tanstackServerAdapter,\n ...args\n}: TanStackInitAdminContextArgs) =>\n initPayloadAdminContext({\n ...args,\n requestURL: getRequest().url,\n serverAdapter,\n })\n"],"names":["getRequest","initAdminContext","initPayloadAdminContext","tanstackServerAdapter","serverAdapter","args","requestURL","url"],"mappings":"AAGA,SAASA,UAAU,QAAQ,+BAA8B;AACzD,SAASC,oBAAoBC,uBAAuB,QAAQ,mBAAkB;AAE9E,4FAA4F;AAC5F,sDAAsD;AACtD,OAAO,8BAA6B;AACpC,SAASC,qBAAqB,QAAQ,4BAA2B;AAMjE,OAAO,MAAMF,mBAAmB,CAAC,EAC/BG,gBAAgBD,qBAAqB,EACrC,GAAGE,MAC0B,GAC7BH,wBAAwB;QACtB,GAAGG,IAAI;QACPC,YAAYN,aAAaO,GAAG;QAC5BH;IACF,GAAE"}
@@ -1,3 +1,4 @@
1
+ import type { RenderableServerComponent } from '@tanstack/react-start/rsc';
1
2
  import type { ImportMap, SanitizedConfig } from 'payload';
2
3
  import type { AdminPageMetadata } from './meta.js';
3
4
  export type LoadAdminPageArgs = {
@@ -6,10 +7,11 @@ export type LoadAdminPageArgs = {
6
7
  search?: Record<string, string | string[]>;
7
8
  splat?: string;
8
9
  };
10
+ type RSCPayload = RenderableServerComponent<React.ReactElement>;
9
11
  export type LoadAdminPageResult = {
10
12
  _notFound: true;
11
13
  routeKey?: string;
12
- rscPayload?: React.ReactNode;
14
+ rscPayload?: RSCPayload;
13
15
  } | {
14
16
  _redirect: string;
15
17
  } | {
@@ -26,15 +28,15 @@ export type LoadAdminPageResult = {
26
28
  * so search-only changes (e.g. list-view filtering) reconcile in place.
27
29
  */
28
30
  routeKey: string;
29
- rscPayload: React.ReactNode;
31
+ rscPayload: RSCPayload;
30
32
  };
31
33
  /**
32
34
  * Renders an admin page for TanStack Start and returns a serializable loader
33
35
  * result. The framework adapter wraps this in a `createServerFn` that supplies
34
36
  * the app's `config` and generated `importMap`.
35
37
  *
36
- * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
37
- * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
38
+ * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator
39
+ * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected
38
40
  * page-render `ServerAdapter` records navigation intent and throws the
39
41
  * framework-agnostic error contract.
40
42
  * 2. Pipes the resulting React server tree through `renderServerComponent`
@@ -51,4 +53,5 @@ export type LoadAdminPageResult = {
51
53
  * so it's read from the `nav` holder after `renderServerComponent` resolves.
52
54
  */
53
55
  export declare function loadAdminPage({ config, importMap, search, splat, }: LoadAdminPageArgs): Promise<LoadAdminPageResult>;
56
+ export {};
54
57
  //# sourceMappingURL=loadAdminPage.d.ts.map
@@ -1 +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;AAKrE,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,U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Q,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA+IlD"}
@@ -1,7 +1,7 @@
1
- import { getViewportContent } from '@payloadcms/ui/layouts';
1
+ import { getViewportContent } from '@payloadcms/ui/shared';
2
2
  import { renderServerComponent } from '@tanstack/react-start/rsc';
3
3
  import { getRequestI18n } from './getRequestI18n.server.js';
4
- import { initReq } from './initReq.server.js';
4
+ import { initAdminContext } from './initAdminContext.server.js';
5
5
  import { createPageRenderServerAdapter } from './serverAdapter.server.js';
6
6
  const resolveTitle = (title)=>{
7
7
  if (!title) {
@@ -67,8 +67,8 @@ const resolveTitle = (title)=>{
67
67
  * result. The framework adapter wraps this in a `createServerFn` that supplies
68
68
  * the app's `config` and generated `importMap`.
69
69
  *
70
- * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
71
- * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
70
+ * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator
71
+ * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected
72
72
  * page-render `ServerAdapter` records navigation intent and throws the
73
73
  * framework-agnostic error contract.
74
74
  * 2. Pipes the resulting React server tree through `renderServerComponent`
@@ -101,12 +101,12 @@ const resolveTitle = (title)=>{
101
101
  const nav = {};
102
102
  const pageServerAdapter = createPageRenderServerAdapter(nav);
103
103
  let userAgent;
104
- // `renderRoot` calls `initReq` itself with its own overrides (query
104
+ // `renderRoot` calls `initAdminContext` itself with its own overrides (query
105
105
  // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
106
106
  // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
107
107
  // is recorded + thrown rather than escaping as raw TanStack nav.
108
- const boundInitReq = async (args)=>{
109
- const result = await initReq({
108
+ const boundInitAdminContext = async (args)=>{
109
+ const result = await initAdminContext({
110
110
  configPromise: args.configPromise,
111
111
  importMap: args.importMap,
112
112
  overrides: args.overrides,
@@ -115,15 +115,6 @@ const resolveTitle = (title)=>{
115
115
  userAgent = result.headers.get('user-agent') ?? undefined;
116
116
  return result;
117
117
  };
118
- const notFound = ()=>{
119
- nav.type = 'notFound';
120
- throw new Error('not-found');
121
- };
122
- const redirect = (url)=>{
123
- nav.type = 'redirect';
124
- nav.url = url;
125
- throw new Error(`redirect:${url}`);
126
- };
127
118
  // Build the 404 result the route loader re-throws as TanStack `notFound()`.
128
119
  //
129
120
  // Throwing `notFound()` is the only way to set the SSR document status to 404
@@ -142,11 +133,7 @@ const resolveTitle = (title)=>{
142
133
  const notFoundNode = await renderNotFoundPage({
143
134
  config: Promise.resolve(config),
144
135
  importMap,
145
- initReq: (args)=>initReq({
146
- configPromise: args.configPromise,
147
- importMap: args.importMap,
148
- overrides: args.overrides
149
- }),
136
+ initAdminContext,
150
137
  params: Promise.resolve({
151
138
  segments: splatSegments
152
139
  }),
@@ -164,14 +151,15 @@ const resolveTitle = (title)=>{
164
151
  adminViews: defaultAdminViews,
165
152
  config: Promise.resolve(config),
166
153
  importMap,
167
- initReq: boundInitReq,
168
- notFound,
154
+ initAdminContext: boundInitAdminContext,
155
+ key: splat ?? '',
156
+ notFound: pageServerAdapter.notFound,
169
157
  // `segments` is intentionally `undefined` for the admin root (`/admin`),
170
158
  // matching Next's optional catch-all; `renderRoot` handles it at runtime.
171
159
  params: Promise.resolve({
172
160
  segments
173
161
  }),
174
- redirect,
162
+ redirect: pageServerAdapter.redirect,
175
163
  searchParams: Promise.resolve(searchParams)
176
164
  });
177
165
  const rscPayload = await renderServerComponent(node);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/layouts'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: React.ReactNode }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: React.ReactNode\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\n}\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initReq` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = async (args) => {\n const result = await initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.headers.get('user-agent') ?? undefined\n return result\n }\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initReq: boundInitReq,\n notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequestI18n","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","userAgent","boundInitReq","args","result","configPromise","overrides","serverAdapter","headers","get","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","viewport","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AA6BzE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IACA,IAAI,OAAOD,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,IAAI,cAAcA,OAAO;QACvB,OAAOA,MAAME,QAAQ;IACvB;IACA,OAAOF,MAAMG,OAAO;AACtB;AAEA;;;;;;CAMC,GACD,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,KAAKD,KAAKE,SAAS;IASzB,MAAMC,YAAYF,IAAIG;IACtB,MAAMC,cAAcF,YAAaG,MAAMC,OAAO,CAACJ,aAAaA,YAAY;QAACA;KAAU,GAAI,EAAE;IACzF,MAAMC,SAASC,YACZG,GAAG,CAAC,CAACC,QACJ,OAAOA,UAAU,WACb;YAAEC,KAAKD;QAAM,IACbA,OAAOC,MACL;YAAEC,KAAKF,MAAME,GAAG;YAAEC,QAAQH,MAAMG,MAAM;YAAEF,KAAKG,OAAOJ,MAAMC,GAAG;YAAGI,OAAOL,MAAMK,KAAK;QAAC,IACnFlB,WAEPmB,MAAM,CAACC;IAEV,MAAMC,WAAWjB,KAAKkB,KAAK;IAC3B,MAAMC,WAAWb,MAAMC,OAAO,CAACU,YAC3BA,WACAA,YAAY,OAAOA,aAAa,YAAYX,MAAMC,OAAO,CAACU,SAASG,IAAI,IACrEH,SAASG,IAAI,GACb,EAAE;IACR,MAAMF,QAAQC,SACXX,GAAG,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rB,IAAI,KAAK,YAAY;YAC3B,OAAO,MAAMmC;QACf;QAEA,wEAAwE;QACxE,sEAAsE;QACtE,2DAA2D;QAC3D,MAAMoB,OAAO,MAAMtF,eAAe;YAAEyC;QAAO;QAC3C,MAAMhC,OAAO,MAAMsC,qBAAqB;YACtC6B,YAAY9B;YACZL;YACA6C;YACAf,QAAQ;gBAAErB;YAAS;QACrB;QAEA,OAAO;YACLqC,UAAU;gBACR,GAAG/E,oBAAoBC,KAAK;gBAC5B+E,UAAU1F,mBAAmBwD;YAC/B;YACAoB,UAAU9B,SAAS;YACnB4B;QACF;IACF,EAAE,OAAOiB,KAAK;QACZ,MAAMC,UAAUD,eAAezB,QAAQyB,IAAIC,OAAO,GAAGpE,OAAOmE;QAC5D,IAAIrC,IAAIrB,IAAI,KAAK,cAAc2D,YAAY,aAAa;YACtD,OAAO,MAAMxB;QACf;QACA,IAAId,IAAIrB,IAAI,KAAK,cAAc2D,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEN,WAAWjC,IAAIjC,GAAG,IAAIuE,QAAQE,KAAK,CAAC,YAAYxD,MAAM;YAAE;QACnE;QACA,MAAMqD;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { RenderableServerComponent } from '@tanstack/react-start/rsc'\nimport type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initAdminContext } from './initAdminContext.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\ntype RSCPayload = RenderableServerComponent<React.ReactElement>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RSCPayload }\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: RSCPayload\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. Gets the Payload admin context via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initAdminContext` 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 boundInitAdminContext: Parameters<typeof renderRoot>[0]['initAdminContext'] = async (\n args,\n ) => {\n const result = await initAdminContext({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.headers.get('user-agent') ?? undefined\n return result\n }\n\n // 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 initAdminContext,\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 initAdminContext: boundInitAdminContext,\n key: splat ?? '',\n notFound: pageServerAdapter.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: pageServerAdapter.redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequestI18n","initAdminContext","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","userAgent","boundInitAdminContext","args","result","configPromise","overrides","serverAdapter","headers","get","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","key","notFound","redirect","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","viewport","err","message","Error","startsWith","slice"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,6BAA6B,QAAQ,4BAA2B;AA+BzE,MAAMC,eAAe,CAACC;IACpB,IA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AAQG,KAAK,CAAC,YAAYzD,MAAM;YAAE;QACnE;QACA,MAAMqD;IACR;AACF"}
@@ -1,4 +1,6 @@
1
1
  import type { ImportMap, SanitizedConfig } from 'payload';
2
+ import type { SerializableRecord } from './toSerializable.js';
3
+ export type LoadLayoutDataResult = SerializableRecord;
2
4
  /**
3
5
  * Resolves the admin layout data for TanStack Start and returns a serializable
4
6
  * payload for the `/_payload` route loader. The framework adapter wraps this in
@@ -11,5 +13,5 @@ import type { ImportMap, SanitizedConfig } from 'payload';
11
13
  export declare function loadLayoutData({ config, importMap, }: {
12
14
  config: SanitizedConfig;
13
15
  importMap: ImportMap;
14
- }): Promise<Record<string, unknown>>;
16
+ }): Promise<LoadLayoutDataResult>;
15
17
  //# sourceMappingURL=loadLayoutData.d.ts.map
@@ -1 +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"}
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;AAIzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAK7D,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,CAAA;AAErD;;;;;;;;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,oBAAoB,CAAC,CAMhC"}
@@ -14,10 +14,9 @@ import { toSerializable } from './toSerializable.js';
14
14
  configPromise: config,
15
15
  importMap
16
16
  });
17
- return {
18
- ...toSerializable(data),
17
+ return toSerializable(data, {
19
18
  providers: providers ? await renderServerComponent(providers) : undefined
20
- };
19
+ });
21
20
  }
22
21
 
23
22
  //# sourceMappingURL=loadLayoutData.js.map