@payloadcms/tanstack-start 4.0.0-internal.a0ef1b8 → 4.0.0-internal.c7d5de4

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 (153) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  3. package/dist/elements/RouterAdapter/index.js +55 -16
  4. package/dist/elements/RouterAdapter/index.js.map +1 -1
  5. package/dist/exports/client.d.ts +4 -0
  6. package/dist/exports/client.d.ts.map +1 -1
  7. package/dist/exports/client.js +4 -0
  8. package/dist/exports/client.js.map +1 -1
  9. package/dist/exports/layouts.d.ts +1 -0
  10. package/dist/exports/layouts.d.ts.map +1 -1
  11. package/dist/exports/layouts.js +1 -0
  12. package/dist/exports/layouts.js.map +1 -1
  13. package/dist/exports/server.d.ts +4 -2
  14. package/dist/exports/server.d.ts.map +1 -1
  15. package/dist/exports/server.js +4 -2
  16. package/dist/exports/server.js.map +1 -1
  17. package/dist/exports/vite.d.ts +2 -2
  18. package/dist/exports/vite.d.ts.map +1 -1
  19. package/dist/exports/vite.js +1 -1
  20. package/dist/exports/vite.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  26. package/dist/layouts/Root/getLayoutData.js +37 -1
  27. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  28. package/dist/layouts/Root/index.d.ts +9 -2
  29. package/dist/layouts/Root/index.d.ts.map +1 -1
  30. package/dist/layouts/Root/index.js +4 -2
  31. package/dist/layouts/Root/index.js.map +1 -1
  32. package/dist/layouts/Root/withPayloadRoot.d.ts +41 -0
  33. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  34. package/dist/layouts/Root/withPayloadRoot.js +91 -0
  35. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  36. package/dist/node/cssLoader.d.mts +24 -2
  37. package/dist/node/cssLoader.d.mts.map +1 -1
  38. package/dist/routes/adminRoutes.d.ts +111 -0
  39. package/dist/routes/adminRoutes.d.ts.map +1 -0
  40. package/dist/routes/adminRoutes.js +108 -0
  41. package/dist/routes/adminRoutes.js.map +1 -0
  42. package/dist/routes/apiRoute.d.ts +34 -0
  43. package/dist/routes/apiRoute.d.ts.map +1 -0
  44. package/dist/routes/apiRoute.js +43 -0
  45. package/dist/routes/apiRoute.js.map +1 -0
  46. package/dist/routes/layoutRoute.d.ts +26 -0
  47. package/dist/routes/layoutRoute.d.ts.map +1 -0
  48. package/dist/routes/layoutRoute.js +57 -0
  49. package/dist/routes/layoutRoute.js.map +1 -0
  50. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  51. package/dist/utilities/handleAPIRoute.server.d.ts +11 -0
  52. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  53. package/dist/utilities/handleAPIRoute.server.js +17 -0
  54. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  55. package/dist/utilities/importMap.server.d.ts +4 -5
  56. package/dist/utilities/importMap.server.d.ts.map +1 -1
  57. package/dist/utilities/importMap.server.js +5 -6
  58. package/dist/utilities/importMap.server.js.map +1 -1
  59. package/dist/utilities/loadAdminPage.d.ts +54 -0
  60. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  61. package/dist/utilities/loadAdminPage.js +239 -0
  62. package/dist/utilities/loadAdminPage.js.map +1 -0
  63. package/dist/utilities/loadLayoutData.d.ts +15 -0
  64. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  65. package/dist/utilities/loadLayoutData.js +23 -0
  66. package/dist/utilities/loadLayoutData.js.map +1 -0
  67. package/dist/utilities/meta.d.ts +1 -0
  68. package/dist/utilities/meta.d.ts.map +1 -1
  69. package/dist/utilities/meta.js +2 -1
  70. package/dist/utilities/meta.js.map +1 -1
  71. package/dist/utilities/routerSearch.d.ts +40 -0
  72. package/dist/utilities/routerSearch.d.ts.map +1 -0
  73. package/dist/utilities/routerSearch.js +45 -0
  74. package/dist/utilities/routerSearch.js.map +1 -0
  75. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  76. package/dist/utilities/serializeForRsc.js +17 -0
  77. package/dist/utilities/serializeForRsc.js.map +1 -1
  78. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  79. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  80. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  81. package/dist/utilities/serverFunctionClient.js +109 -0
  82. package/dist/utilities/serverFunctionClient.js.map +1 -0
  83. package/dist/vite/config/external.d.ts +26 -0
  84. package/dist/vite/config/external.d.ts.map +1 -0
  85. package/dist/vite/config/external.js +72 -0
  86. package/dist/vite/config/external.js.map +1 -0
  87. package/dist/vite/config/optimizeDeps.d.ts +25 -0
  88. package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
  89. package/dist/vite/config/optimizeDeps.js +123 -0
  90. package/dist/vite/config/optimizeDeps.js.map +1 -0
  91. package/dist/vite/config/scss.d.ts +14 -0
  92. package/dist/vite/config/scss.d.ts.map +1 -0
  93. package/dist/vite/config/scss.js +28 -0
  94. package/dist/vite/config/scss.js.map +1 -0
  95. package/dist/vite/index.d.ts +99 -0
  96. package/dist/vite/index.d.ts.map +1 -0
  97. package/dist/vite/index.js +258 -0
  98. package/dist/vite/index.js.map +1 -0
  99. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
  100. package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
  101. package/dist/vite/workarounds/devTransforms.d.ts +19 -0
  102. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
  103. package/dist/vite/{plugins → workarounds}/devTransforms.js +18 -2
  104. package/dist/vite/workarounds/devTransforms.js.map +1 -0
  105. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  106. package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
  107. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
  108. package/dist/vite/workarounds/stripDistStyleImports.js +140 -0
  109. package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
  110. package/dist/vite/workarounds/stubPrettierInClient.d.ts +13 -0
  111. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
  112. package/dist/vite/workarounds/stubPrettierInClient.js +32 -0
  113. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
  114. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
  115. package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
  116. package/package.json +12 -7
  117. package/dist/@types/assets.d.js +0 -2
  118. package/dist/@types/assets.d.js.map +0 -1
  119. package/dist/auth/switchLanguage.d.ts +0 -6
  120. package/dist/auth/switchLanguage.d.ts.map +0 -1
  121. package/dist/auth/switchLanguage.js +0 -11
  122. package/dist/auth/switchLanguage.js.map +0 -1
  123. package/dist/utilities/getRequestTheme.d.ts +0 -10
  124. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  125. package/dist/utilities/getRequestTheme.js +0 -25
  126. package/dist/utilities/getRequestTheme.js.map +0 -1
  127. package/dist/vite/constants.d.ts +0 -37
  128. package/dist/vite/constants.d.ts.map +0 -1
  129. package/dist/vite/constants.js +0 -129
  130. package/dist/vite/constants.js.map +0 -1
  131. package/dist/vite/plugin.d.ts +0 -38
  132. package/dist/vite/plugin.d.ts.map +0 -1
  133. package/dist/vite/plugin.js +0 -182
  134. package/dist/vite/plugin.js.map +0 -1
  135. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  136. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  137. package/dist/vite/plugins/devTransforms.d.ts +0 -8
  138. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  139. package/dist/vite/plugins/devTransforms.js.map +0 -1
  140. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  141. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  142. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  143. package/dist/vite/plugins/stripDistStyleImports.js +0 -89
  144. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  145. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  146. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  147. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
  148. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
  149. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
  150. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
  151. /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
  152. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
  153. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
@@ -1,12 +1,11 @@
1
1
  import path from 'node:path';
2
2
  /**
3
- * Returns the default output path for the generated import map file
4
- * in a TanStack Start project.
5
- *
6
- * TanStack Start projects typically use `src/` as the source root,
7
- * so the import map is placed there.
3
+ * Returns the default output path for the generated import map file in a
4
+ * TanStack Start project. Matches the `app/_payload/` convention that Payload's
5
+ * import map auto-discovery probes, so the file is found without a custom
6
+ * `admin.importMap.importMapFile` override.
8
7
  */ export function getImportMapOutputPath(rootDir) {
9
- return path.resolve(rootDir || process.cwd(), 'src', 'payload-import-map.ts');
8
+ return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js');
10
9
  }
11
10
 
12
11
  //# sourceMappingURL=importMap.server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file\n * in a TanStack Start project.\n *\n * TanStack Start projects typically use `src/` as the source root,\n * so the import map is placed there.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'src', 'payload-import-map.ts')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;;CAMC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO;AACvD"}
1
+ {"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file in a\n * TanStack Start project. Matches the `app/_payload/` convention that Payload's\n * import map auto-discovery probes, so the file is found without a custom\n * `admin.importMap.importMapFile` override.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;CAKC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO,YAAY;AACnE"}
@@ -0,0 +1,54 @@
1
+ import type { ImportMap, SanitizedConfig } from 'payload';
2
+ import type { AdminPageMetadata } from './meta.js';
3
+ export type LoadAdminPageArgs = {
4
+ config: SanitizedConfig;
5
+ importMap: ImportMap;
6
+ search?: Record<string, string | string[]>;
7
+ splat?: string;
8
+ };
9
+ export type LoadAdminPageResult = {
10
+ _notFound: true;
11
+ routeKey?: string;
12
+ rscPayload?: React.ReactNode;
13
+ } | {
14
+ _redirect: string;
15
+ } | {
16
+ metadata: AdminPageMetadata;
17
+ /**
18
+ * Stable identity for this rendered route (the splat, i.e. the path
19
+ * after `/admin/`). The client keys the rendered subtree by this so the
20
+ * view remounts exactly when a new payload arrives. Keying by
21
+ * `location.pathname` instead races: the pathname updates before
22
+ * `useLoaderData()` during a transition, so the subtree would remount
23
+ * with the *previous* payload and then reconcile the fresh payload in
24
+ * place — leaving client providers (DocumentInfo, etc.) holding stale
25
+ * `useState` values from the prior document. Search params are excluded
26
+ * so search-only changes (e.g. list-view filtering) reconcile in place.
27
+ */
28
+ routeKey: string;
29
+ rscPayload: React.ReactNode;
30
+ };
31
+ /**
32
+ * Renders an admin page for TanStack Start and returns a serializable loader
33
+ * result. The framework adapter wraps this in a `createServerFn` that supplies
34
+ * the app's `config` and generated `importMap`.
35
+ *
36
+ * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
37
+ * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
38
+ * page-render `ServerAdapter` records navigation intent and throws the
39
+ * framework-agnostic error contract.
40
+ * 2. Pipes the resulting React server tree through `renderServerComponent`
41
+ * to produce a Flight payload the client consumes directly.
42
+ * 3. Resolves page metadata via the same shared `generatePageMetadata`
43
+ * Next.js uses, returning plain serializable strings for `head()`.
44
+ *
45
+ * Navigation surfaces two ways and both become a `_notFound` / `_redirect`
46
+ * sentinel the route loader re-throws as native TanStack nav:
47
+ * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
48
+ * by the try/catch below;
49
+ * - thrown deep inside a streamed view component (e.g. `DocumentView` access
50
+ * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
51
+ * so it's read from the `nav` holder after `renderServerComponent` resolves.
52
+ */
53
+ export declare function loadAdminPage({ config, importMap, search, splat, }: LoadAdminPageArgs): Promise<LoadAdminPageResult>;
54
+ //# sourceMappingURL=loadAdminPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;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,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,CA2JlD"}
@@ -0,0 +1,239 @@
1
+ import { getViewportContent } from '@payloadcms/ui/shared';
2
+ import { renderServerComponent } from '@tanstack/react-start/rsc';
3
+ import { getRequestI18n } from './getRequestI18n.server.js';
4
+ import { initReq } from './initReq.server.js';
5
+ import { createPageRenderServerAdapter } from './serverAdapter.server.js';
6
+ const resolveTitle = (title)=>{
7
+ if (!title) {
8
+ return undefined;
9
+ }
10
+ if (typeof title === 'string') {
11
+ return title;
12
+ }
13
+ if ('absolute' in title) {
14
+ return title.absolute;
15
+ }
16
+ return title.default;
17
+ };
18
+ /**
19
+ * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into
20
+ * the plain, serializable `AdminPageMetadata` the route loader ships to the
21
+ * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and
22
+ * other non-serializable values that seroval cannot cross the wire, so only the
23
+ * fields `getAdminMeta` renders are extracted.
24
+ */ const toAdminPageMetadata = (meta)=>{
25
+ const og = meta.openGraph;
26
+ const rawImages = og?.images;
27
+ const imagesArray = rawImages ? Array.isArray(rawImages) ? rawImages : [
28
+ rawImages
29
+ ] : [];
30
+ const images = imagesArray.map((image)=>typeof image === 'string' ? {
31
+ url: image
32
+ } : image?.url ? {
33
+ alt: image.alt,
34
+ height: image.height,
35
+ url: String(image.url),
36
+ width: image.width
37
+ } : undefined).filter(Boolean);
38
+ const rawIcons = meta.icons;
39
+ const iconList = Array.isArray(rawIcons) ? rawIcons : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon) ? rawIcons.icon : [];
40
+ const icons = iconList.map((icon)=>typeof icon === 'string' ? {
41
+ rel: 'icon',
42
+ url: icon
43
+ } : icon?.url ? {
44
+ type: icon.type,
45
+ media: icon.media,
46
+ rel: icon.rel ?? 'icon',
47
+ sizes: icon.sizes,
48
+ url: String(icon.url)
49
+ } : undefined).filter(Boolean);
50
+ const keywords = meta.keywords;
51
+ return {
52
+ description: typeof meta.description === 'string' ? meta.description : undefined,
53
+ icons: icons?.length ? icons : undefined,
54
+ keywords: typeof keywords === 'string' ? keywords : Array.isArray(keywords) ? keywords.join(', ') : undefined,
55
+ openGraph: og ? {
56
+ description: typeof og.description === 'string' ? og.description : undefined,
57
+ images: images?.length ? images : undefined,
58
+ siteName: typeof og.siteName === 'string' ? og.siteName : undefined,
59
+ title: typeof og.title === 'string' ? og.title : undefined
60
+ } : undefined,
61
+ robots: typeof meta.robots === 'string' ? meta.robots : undefined,
62
+ title: resolveTitle(meta.title)
63
+ };
64
+ };
65
+ /**
66
+ * Renders an admin page for TanStack Start and returns a serializable loader
67
+ * result. The framework adapter wraps this in a `createServerFn` that supplies
68
+ * the app's `config` and generated `importMap`.
69
+ *
70
+ * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
71
+ * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
72
+ * page-render `ServerAdapter` records navigation intent and throws the
73
+ * framework-agnostic error contract.
74
+ * 2. Pipes the resulting React server tree through `renderServerComponent`
75
+ * to produce a Flight payload the client consumes directly.
76
+ * 3. Resolves page metadata via the same shared `generatePageMetadata`
77
+ * Next.js uses, returning plain serializable strings for `head()`.
78
+ *
79
+ * Navigation surfaces two ways and both become a `_notFound` / `_redirect`
80
+ * sentinel the route loader re-throws as native TanStack nav:
81
+ * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
82
+ * by the try/catch below;
83
+ * - thrown deep inside a streamed view component (e.g. `DocumentView` access
84
+ * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
85
+ * so it's read from the `nav` holder after `renderServerComponent` resolves.
86
+ */ export async function loadAdminPage({ config, importMap, search, splat }) {
87
+ const { renderRoot } = await import('@payloadcms/ui/views/Root');
88
+ const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews');
89
+ const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata');
90
+ const splatSegments = splat ? splat.split('/').filter(Boolean) : [];
91
+ // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no
92
+ // segments. Passing an empty array makes the shared `renderRoot` build
93
+ // `currentRoute` as `/admin/` (trailing slash), which no longer equals
94
+ // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.
95
+ // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated
96
+ // redirect lands on a clean `/admin/login`.
97
+ const segments = splatSegments.length > 0 ? splatSegments : undefined;
98
+ const searchParams = search ?? {};
99
+ // Records navigation requested via `req.server.*` (including throws swallowed
100
+ // by RSC streaming deep inside view components). Read after the render.
101
+ const nav = {};
102
+ const pageServerAdapter = createPageRenderServerAdapter(nav);
103
+ let userAgent;
104
+ // `renderRoot` calls `initReq` itself with its own overrides (query
105
+ // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
106
+ // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
107
+ // is recorded + thrown rather than escaping as raw TanStack nav.
108
+ const boundInitReq = async (args)=>{
109
+ const result = await initReq({
110
+ configPromise: args.configPromise,
111
+ importMap: args.importMap,
112
+ overrides: args.overrides,
113
+ serverAdapter: pageServerAdapter
114
+ });
115
+ userAgent = result.headers.get('user-agent') ?? undefined;
116
+ return result;
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
+ // Build the 404 result the route loader re-throws as TanStack `notFound()`.
128
+ //
129
+ // Throwing `notFound()` is the only way to set the SSR document status to 404
130
+ // (it's read from `router.stores.statusCode`, set by a not-found match — NOT
131
+ // from `setResponseStatus`, which only affects the RSC RPC response). But the
132
+ // matching `notFoundComponent` is a client component with no access to the
133
+ // Payload `req`, so it can't build the admin chrome on its own. To match Next
134
+ // (whose not-found route renders the full admin layout — nav sidebar, etc. —
135
+ // around the NotFound body, see `renderNotFoundPage`), we render that same
136
+ // shared `renderNotFoundPage` tree here, server-side, and ship its Flight
137
+ // payload through the `notFound()` error so the client renders it verbatim.
138
+ // For users without admin access `renderNotFoundPage` returns the bare
139
+ // `NotFoundClient`, preserving the access-denied behavior.
140
+ const renderNotFound = async ()=>{
141
+ const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page');
142
+ const notFoundNode = await renderNotFoundPage({
143
+ config: Promise.resolve(config),
144
+ importMap,
145
+ initReq: (args)=>initReq({
146
+ configPromise: args.configPromise,
147
+ importMap: args.importMap,
148
+ overrides: args.overrides
149
+ }),
150
+ params: Promise.resolve({
151
+ segments: splatSegments
152
+ }),
153
+ searchParams: Promise.resolve(searchParams)
154
+ });
155
+ const rscPayload = await renderServerComponent(notFoundNode);
156
+ return {
157
+ _notFound: true,
158
+ routeKey: splat ?? '',
159
+ rscPayload
160
+ };
161
+ };
162
+ try {
163
+ const node = await renderRoot({
164
+ adminViews: defaultAdminViews,
165
+ config: Promise.resolve(config),
166
+ importMap,
167
+ initReq: boundInitReq,
168
+ notFound,
169
+ // `segments` is intentionally `undefined` for the admin root (`/admin`),
170
+ // matching Next's optional catch-all; `renderRoot` handles it at runtime.
171
+ params: Promise.resolve({
172
+ segments
173
+ }),
174
+ redirect,
175
+ searchParams: Promise.resolve(searchParams)
176
+ });
177
+ const rscPayload = await renderServerComponent(node);
178
+ // The server-function (client-nav RPC) path returns the flight stream unread —
179
+ // unlike the router/SSR path, which awaits a decode that drives the render to
180
+ // completion. So streamed side effects (e.g. DocumentView's autosave-create
181
+ // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to
182
+ // completion to force the render (populating `nav`), then hand the client a fresh
183
+ // replayable stream from that buffer.
184
+ if (!nav.type) {
185
+ const wrapper = rscPayload[Symbol.for('tanstack.rsc.stream')];
186
+ if (typeof wrapper?.createReplayStream === 'function') {
187
+ const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer();
188
+ wrapper.createReplayStream = ()=>new Response(buffer).body;
189
+ }
190
+ }
191
+ // Navigation thrown deep inside a streamed view component (e.g. access
192
+ // denied → notFound, already-authenticated → redirect) is swallowed into
193
+ // the RSC stream and never rejects the render. Honor it from the holder,
194
+ // discarding the (broken) payload from the aborted render.
195
+ if (nav.type === 'redirect' && nav.url) {
196
+ return {
197
+ _redirect: nav.url
198
+ };
199
+ }
200
+ if (nav.type === 'notFound') {
201
+ return await renderNotFound();
202
+ }
203
+ // Resolve metadata through the same shared generator Next.js uses. Only
204
+ // plain strings cross the wire (the full `MetaConfig` carries a `URL`
205
+ // `metadataBase` and icons that seroval cannot serialize).
206
+ const i18n = await getRequestI18n({
207
+ config
208
+ });
209
+ const meta = await generatePageMetadata({
210
+ adminViews: defaultAdminViews,
211
+ config,
212
+ i18n,
213
+ params: {
214
+ segments
215
+ }
216
+ });
217
+ return {
218
+ metadata: {
219
+ ...toAdminPageMetadata(meta),
220
+ viewport: getViewportContent(userAgent)
221
+ },
222
+ routeKey: splat ?? '',
223
+ rscPayload
224
+ };
225
+ } catch (err) {
226
+ const message = err instanceof Error ? err.message : String(err);
227
+ if (nav.type === 'notFound' || message === 'not-found') {
228
+ return await renderNotFound();
229
+ }
230
+ if (nav.type === 'redirect' || message.startsWith('redirect:')) {
231
+ return {
232
+ _redirect: nav.url ?? message.slice('redirect:'.length)
233
+ };
234
+ }
235
+ throw err;
236
+ }
237
+ }
238
+
239
+ //# 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 { 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 { 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,wBAAuB;AAC1D,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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,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,IAAIhC,IAAIrB,IAAI,KAAK,cAAcqB,IAAIjC,GAAG,EAAE;YACtC,OAAO;gBAAEkE,WAAWjC,IAAIjC,GAAG;YAAC;QAC9B;QACA,IAAIiC,IAAIrB,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"}
@@ -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"}
@@ -0,0 +1,23 @@
1
+ import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { getLayoutData } from '../layouts/Root/getLayoutData.js';
3
+ import { toSerializable } from './toSerializable.js';
4
+ /**
5
+ * Resolves the admin layout data for TanStack Start and returns a serializable
6
+ * payload for the `/_payload` route loader. The framework adapter wraps this in
7
+ * a `createServerFn` that supplies the app's `config` and generated `importMap`.
8
+ *
9
+ * `toSerializable` strips React elements, so the custom-providers element tree
10
+ * (`config.admin.components.providers`) is rendered to an RSC payload separately
11
+ * and re-attached.
12
+ */ export async function loadLayoutData({ config, importMap }) {
13
+ const { providers, ...data } = await getLayoutData({
14
+ configPromise: config,
15
+ importMap
16
+ });
17
+ return {
18
+ ...toSerializable(data),
19
+ providers: providers ? await renderServerComponent(providers) : undefined
20
+ };
21
+ }
22
+
23
+ //# sourceMappingURL=loadLayoutData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/loadLayoutData.ts"],"sourcesContent":["import type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport { getLayoutData } from '../layouts/Root/getLayoutData.js'\nimport { toSerializable } from './toSerializable.js'\n\n/**\n * Resolves the admin layout data for TanStack Start and returns a serializable\n * payload for the `/_payload` route loader. The framework adapter wraps this in\n * a `createServerFn` that supplies the app's `config` and generated `importMap`.\n *\n * `toSerializable` strips React elements, so the custom-providers element tree\n * (`config.admin.components.providers`) is rendered to an RSC payload separately\n * and re-attached.\n */\nexport async function loadLayoutData({\n config,\n importMap,\n}: {\n config: SanitizedConfig\n importMap: ImportMap\n}): Promise<Record<string, unknown>> {\n const { providers, ...data } = await getLayoutData({ configPromise: config, importMap })\n\n return {\n ...(toSerializable(data) as Record<string, unknown>),\n providers: providers ? await renderServerComponent(providers as any) : undefined,\n }\n}\n"],"names":["renderServerComponent","getLayoutData","toSerializable","loadLayoutData","config","importMap","providers","data","configPromise","undefined"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAEjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAEpD;;;;;;;;CAQC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,SAAS,EAIV;IACC,MAAM,EAAEC,SAAS,EAAE,GAAGC,MAAM,GAAG,MAAMN,cAAc;QAAEO,eAAeJ;QAAQC;IAAU;IAEtF,OAAO;QACL,GAAIH,eAAeK,KAAK;QACxBD,WAAWA,YAAY,MAAMN,sBAAsBM,aAAoBG;IACzE;AACF"}
@@ -49,6 +49,7 @@ export type AdminPageMetadata = {
49
49
  };
50
50
  robots?: string;
51
51
  title?: string;
52
+ viewport?: string;
52
53
  };
53
54
  /**
54
55
  * Builds TanStack Router `head()` `meta` + `links` entries for an admin page
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/utilities/meta.ts"],"names":[],"mappings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AAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,iBAAiB,GAAG;IAC1D,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,IAAI,EAAE,SAAS,EAAE,CAAA;CAClB,CA0EA"}
@@ -1,3 +1,4 @@
1
+ import { getViewportContent } from '@payloadcms/ui/shared';
1
2
  /**
2
3
  * Builds TanStack Router `head()` `meta` + `links` entries for an admin page
3
4
  * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders
@@ -16,7 +17,7 @@
16
17
  },
17
18
  {
18
19
  name: 'viewport',
19
- content: 'width=device-width, initial-scale=1'
20
+ content: metadata?.viewport ?? getViewportContent()
20
21
  }
21
22
  ];
22
23
  const links = [];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["type MetaEntry =\n | { charSet: string }\n | { content: string; name: string }\n | { content: string; property: string }\n | { title: string }\n\ntype LinkEntry = {\n href: string\n media?: string\n rel: string\n sizes?: string\n type?: string\n}\n\ntype AdminPageIcon = {\n media?: string\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\n\ntype AdminPageOGImage = {\n alt?: string\n height?: number\n url: string\n width?: number\n}\n\n/**\n * Resolved admin-page metadata produced by the admin-page server function.\n *\n * The server function resolves the framework-agnostic `MetaConfig` (via the\n * shared `generatePageMetadata` in `@payloadcms/ui`) down to plain serializable\n * values, so the route loader can ship it across the wire and feed it to\n * `getAdminMeta` in `head()`.\n */\nexport type AdminPageMetadata = {\n description?: string\n icons?: AdminPageIcon[]\n keywords?: string\n openGraph?: {\n description?: string\n images?: AdminPageOGImage[]\n siteName?: string\n title?: string\n }\n robots?: string\n title?: string\n}\n\n/**\n * Builds TanStack Router `head()` `meta` + `links` entries for an admin page\n * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders\n * natively from the same `MetaConfig` (title, description, robots, keywords,\n * OpenGraph, Twitter — derived from OpenGraph — and icon links).\n *\n * ```ts\n * export const Route = createFileRoute('/admin/$')({\n * head: ({ loaderData }) => getAdminMeta(loaderData?.metadata),\n * })\n * ```\n */\nexport function getAdminMeta(metadata?: AdminPageMetadata): {\n links: LinkEntry[]\n meta: MetaEntry[]\n} {\n const meta: MetaEntry[] = [\n { charSet: 'utf-8' },\n { name: 'viewport', content: 'width=device-width, initial-scale=1' },\n ]\n const links: LinkEntry[] = []\n\n if (!metadata) {\n return { links, meta }\n }\n\n if (metadata.title) {\n meta.push({ title: metadata.title })\n }\n if (metadata.description) {\n meta.push({ name: 'description', content: metadata.description })\n }\n if (metadata.keywords) {\n meta.push({ name: 'keywords', content: metadata.keywords })\n }\n if (metadata.robots) {\n meta.push({ name: 'robots', content: metadata.robots })\n }\n\n const og = metadata.openGraph\n if (og) {\n if (og.title) {\n meta.push({ content: og.title, property: 'og:title' })\n }\n if (og.description) {\n meta.push({ content: og.description, property: 'og:description' })\n }\n if (og.siteName) {\n meta.push({ content: og.siteName, property: 'og:site_name' })\n }\n\n for (const image of og.images ?? []) {\n meta.push({ content: image.url, property: 'og:image' })\n if (image.width) {\n meta.push({ content: String(image.width), property: 'og:image:width' })\n }\n if (image.height) {\n meta.push({ content: String(image.height), property: 'og:image:height' })\n }\n if (image.alt) {\n meta.push({ content: image.alt, property: 'og:image:alt' })\n }\n }\n\n // Twitter card is inherited from OpenGraph (matches Next.js metadata resolution).\n const firstImage = og.images?.[0]\n if (firstImage) {\n meta.push({ name: 'twitter:card', content: 'summary_large_image' })\n meta.push({ name: 'twitter:image', content: firstImage.url })\n }\n if (og.title) {\n meta.push({ name: 'twitter:title', content: og.title })\n }\n if (og.description) {\n meta.push({ name: 'twitter:description', content: og.description })\n }\n }\n\n for (const icon of metadata.icons ?? []) {\n links.push({\n href: icon.url,\n rel: icon.rel ?? 'icon',\n ...(icon.media ? { media: icon.media } : {}),\n ...(icon.sizes ? { sizes: icon.sizes } : {}),\n ...(icon.type ? { type: icon.type } : {}),\n })\n }\n\n return { links, meta }\n}\n"],"names":["getAdminMeta","metadata","meta","charSet","name","content","links","title","push","description","keywords","robots","og","openGraph","property","siteName","image","images","url","width","String","height","alt","firstImage","icon","icons","href","rel","media","sizes","type"],"mappings":"AAmDA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAAS;QAAsC;KACpE;IACD,MAAMC,QAAqB,EAAE;IAE7B,IAAI,CAACL,UAAU;QACb,OAAO;YAAEK;YAAOJ;QAAK;IACvB;IAEA,IAAID,SAASM,KAAK,EAAE;QAClBL,KAAKM,IAAI,CAAC;YAAED,OAAON,SAASM,KAAK;QAAC;IACpC;IACA,IAAIN,SAASQ,WAAW,EAAE;QACxBP,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAeC,SAASJ,SAASQ,WAAW;QAAC;IACjE;IACA,IAAIR,SAASS,QAAQ,EAAE;QACrBR,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAYC,SAASJ,SAASS,QAAQ;QAAC;IAC3D;IACA,IAAIT,SAASU,MAAM,EAAE;QACnBT,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAUC,SAASJ,SAASU,MAAM;QAAC;IACvD;IAEA,MAAMC,KAAKX,SAASY,SAAS;IAC7B,IAAID,IAAI;QACN,IAAIA,GAAGL,KAAK,EAAE;YACZL,KAAKM,IAAI,CAA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W;YAAC;QACnE;IACF;IAEA,KAAK,MAAMe,QAAQvB,SAASwB,KAAK,IAAI,EAAE,CAAE;QACvCnB,MAAME,IAAI,CAAC;YACTkB,MAAMF,KAAKN,GAAG;YACdS,KAAKH,KAAKG,GAAG,IAAI;YACjB,GAAIH,KAAKI,KAAK,GAAG;gBAAEA,OAAOJ,KAAKI,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIJ,KAAKK,KAAK,GAAG;gBAAEA,OAAOL,KAAKK,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIL,KAAKM,IAAI,GAAG;gBAAEA,MAAMN,KAAKM,IAAI;YAAC,IAAI,CAAC,CAAC;QAC1C;IACF;IAEA,OAAO;QAAExB;QAAOJ;IAAK;AACvB"}
1
+ {"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["import { getViewportContent } from '@payloadcms/ui/shared'\n\ntype MetaEntry =\n | { charSet: string }\n | { content: string; name: string }\n | { content: string; property: string }\n | { title: string }\n\ntype LinkEntry = {\n href: string\n media?: string\n rel: string\n sizes?: string\n type?: string\n}\n\ntype AdminPageIcon = {\n media?: string\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\n\ntype AdminPageOGImage = {\n alt?: string\n height?: number\n url: string\n width?: number\n}\n\n/**\n * Resolved admin-page metadata produced by the admin-page server function.\n *\n * The server function resolves the framework-agnostic `MetaConfig` (via the\n * shared `generatePageMetadata` in `@payloadcms/ui`) down to plain serializable\n * values, so the route loader can ship it across the wire and feed it to\n * `getAdminMeta` in `head()`.\n */\nexport type AdminPageMetadata = {\n description?: string\n icons?: AdminPageIcon[]\n keywords?: string\n openGraph?: {\n description?: string\n images?: AdminPageOGImage[]\n siteName?: string\n title?: string\n }\n robots?: string\n title?: string\n viewport?: string\n}\n\n/**\n * Builds TanStack Router `head()` `meta` + `links` entries for an admin page\n * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders\n * natively from the same `MetaConfig` (title, description, robots, keywords,\n * OpenGraph, Twitter — derived from OpenGraph — and icon links).\n *\n * ```ts\n * export const Route = createFileRoute('/admin/$')({\n * head: ({ loaderData }) => getAdminMeta(loaderData?.metadata),\n * })\n * ```\n */\nexport function getAdminMeta(metadata?: AdminPageMetadata): {\n links: LinkEntry[]\n meta: MetaEntry[]\n} {\n const meta: MetaEntry[] = [\n { charSet: 'utf-8' },\n { name: 'viewport', content: metadata?.viewport ?? getViewportContent() },\n ]\n const links: LinkEntry[] = []\n\n if (!metadata) {\n return { links, meta }\n }\n\n if (metadata.title) {\n meta.push({ title: metadata.title })\n }\n if (metadata.description) {\n meta.push({ name: 'description', content: metadata.description })\n }\n if (metadata.keywords) {\n meta.push({ name: 'keywords', content: metadata.keywords })\n }\n if (metadata.robots) {\n meta.push({ name: 'robots', content: metadata.robots })\n }\n\n const og = metadata.openGraph\n if (og) {\n if (og.title) {\n meta.push({ content: og.title, property: 'og:title' })\n }\n if (og.description) {\n meta.push({ content: og.description, property: 'og:description' })\n }\n if (og.siteName) {\n meta.push({ content: og.siteName, property: 'og:site_name' })\n }\n\n for (const image of og.images ?? []) {\n meta.push({ content: image.url, property: 'og:image' })\n if (image.width) {\n meta.push({ content: String(image.width), property: 'og:image:width' })\n }\n if (image.height) {\n meta.push({ content: String(image.height), property: 'og:image:height' })\n }\n if (image.alt) {\n meta.push({ content: image.alt, property: 'og:image:alt' })\n }\n }\n\n // Twitter card is inherited from OpenGraph (matches Next.js metadata resolution).\n const firstImage = og.images?.[0]\n if (firstImage) {\n meta.push({ name: 'twitter:card', content: 'summary_large_image' })\n meta.push({ name: 'twitter:image', content: firstImage.url })\n }\n if (og.title) {\n meta.push({ name: 'twitter:title', content: og.title })\n }\n if (og.description) {\n meta.push({ name: 'twitter:description', content: og.description })\n }\n }\n\n for (const icon of metadata.icons ?? []) {\n links.push({\n href: icon.url,\n rel: icon.rel ?? 'icon',\n ...(icon.media ? { media: icon.media } : {}),\n ...(icon.sizes ? { sizes: icon.sizes } : {}),\n ...(icon.type ? { type: icon.type } : {}),\n })\n }\n\n return { links, meta }\n}\n"],"names":["getViewportContent","getAdminMeta","metadata","meta","charSet","name","content","viewport","links","title","push","description","keywords","robots","og","openGraph","property","siteName","image","images","url","width","String","height","alt","firstImage","icon","icons","href","rel","media","sizes","type"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,wBAAuB;AAsD1D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAASJ,UAAUK,YAAYP;QAAqB;KACzE;IACD,MAAMQ,QAAqB,EAAE;IAE7B,IAAI,CAACN,UAAU;QACb,OAAO;YAAEM;YAAOL;QAAK;IACvB;IAEA,IAAID,SAASO,KAAK,EAAE;QAClBN,KAAKO,IAAI,CAAC;YAAED,OAAOP,SAASO,KAAK;QAAC;IACpC;IACA,IAAIP,SAASS,WAAW,EAAE;QACxBR,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAeC,SAASJ,SAASS,WAAW;QAAC;IACjE;IACA,IAAIT,SAASU,QAAQ,EAAE;QACrBT,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAYC,SAASJ,SAASU,QAAQ;QAAC;IAC3D;IACA,IAAIV,SAASW,MAAM,EAAE;QACnBV,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAUC,SAASJ,SAASW,MAAM;QAAC;IACvD;IAEA,MAAMC,KAAKZ,SAASa,SAAS;IAC7B,IAAID,IAAI;QACN,IAAIA,GAAGL,KAAK,EAAE;YACZN,KAAKO,IAAI,CAAC;gBAAEJ,SAASQ,GAAGL,KAAK;gBAAEO,UAAU;YAAW;QACtD;QACA,IAAIF,GAAGH,WAAW,EAAE;YAClBR,KAAKO,IAAI,CAAC;gBAAEJ,SAASQ,GAAGH,WAAW;gBAAEK,UAAU;YAAiB;QAClE;QACA,IAAIF,GAAGG,QAAQ,EAAE;YACfd,KAAKO,IAAI,CAAC;gB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AK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIJ,KAAKK,KAAK,GAAG;gBAAEA,OAAOL,KAAKK,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIL,KAAKM,IAAI,GAAG;gBAAEA,MAAMN,KAAKM,IAAI;YAAC,IAAI,CAAC,CAAC;QAC1C;IACF;IAEA,OAAO;QAAExB;QAAOL;IAAK;AACvB"}
@@ -0,0 +1,40 @@
1
+ import * as qs from 'qs-esm';
2
+ /**
3
+ * `parseSearch` for TanStack Router's `createRouter`, required for Payload's
4
+ * admin UI. Pair with {@link payloadStringifySearch}.
5
+ *
6
+ * Payload serializes query state (notably the list-view `where` filter) with
7
+ * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
8
+ * Router's default serializer treats each bracketed string as a flat key and
9
+ * JSON-encodes values, so it never round-trips Payload's nested query: every
10
+ * navigation re-encodes the already-encoded value, exponentially nesting it
11
+ * (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
12
+ * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
13
+ * the URL idempotent and the nested `where` intact across navigations.
14
+ *
15
+ * This is a router-global serializer: it applies to every route, not just
16
+ * `/admin`. On your own routes, search values arrive as strings (qs does no
17
+ * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
18
+ * you need numbers or booleans.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createRouter } from '@tanstack/react-router'
23
+ * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'
24
+ *
25
+ * export function getRouter() {
26
+ * return createRouter({
27
+ * parseSearch: payloadParseSearch,
28
+ * routeTree,
29
+ * stringifySearch: payloadStringifySearch,
30
+ * })
31
+ * }
32
+ * ```
33
+ */
34
+ export declare const payloadParseSearch: (searchStr: string) => qs.ParsedQs;
35
+ /**
36
+ * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
37
+ * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
38
+ */
39
+ export declare const payloadStringifySearch: (search: Record<string, unknown>) => string;
40
+ //# sourceMappingURL=routerSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerSearch.d.ts","sourceRoot":"","sources":["../../src/utilities/routerSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,kBAAkB,cAAe,MAAM,gBACS,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAGrE,CAAA"}
@@ -0,0 +1,45 @@
1
+ import * as qs from 'qs-esm';
2
+ /**
3
+ * `parseSearch` for TanStack Router's `createRouter`, required for Payload's
4
+ * admin UI. Pair with {@link payloadStringifySearch}.
5
+ *
6
+ * Payload serializes query state (notably the list-view `where` filter) with
7
+ * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
8
+ * Router's default serializer treats each bracketed string as a flat key and
9
+ * JSON-encodes values, so it never round-trips Payload's nested query: every
10
+ * navigation re-encodes the already-encoded value, exponentially nesting it
11
+ * (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
12
+ * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
13
+ * the URL idempotent and the nested `where` intact across navigations.
14
+ *
15
+ * This is a router-global serializer: it applies to every route, not just
16
+ * `/admin`. On your own routes, search values arrive as strings (qs does no
17
+ * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
18
+ * you need numbers or booleans.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createRouter } from '@tanstack/react-router'
23
+ * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'
24
+ *
25
+ * export function getRouter() {
26
+ * return createRouter({
27
+ * parseSearch: payloadParseSearch,
28
+ * routeTree,
29
+ * stringifySearch: payloadStringifySearch,
30
+ * })
31
+ * }
32
+ * ```
33
+ */ export const payloadParseSearch = (searchStr)=>qs.parse(searchStr, {
34
+ depth: 10,
35
+ ignoreQueryPrefix: true
36
+ });
37
+ /**
38
+ * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
39
+ * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
40
+ */ export const payloadStringifySearch = (search)=>{
41
+ const searchStr = qs.stringify(search);
42
+ return searchStr ? `?${searchStr}` : '';
43
+ };
44
+
45
+ //# sourceMappingURL=routerSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/routerSearch.ts"],"sourcesContent":["import * as qs from 'qs-esm'\n\n/**\n * `parseSearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadStringifySearch}.\n *\n * Payload serializes query state (notably the list-view `where` filter) with\n * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack\n * Router's default serializer treats each bracketed string as a flat key and\n * JSON-encodes values, so it never round-trips Payload's nested query: every\n * navigation re-encodes the already-encoded value, exponentially nesting it\n * (`[true,\"[true,\\\"[true…\"]`) until the filter is unusable. Parsing and\n * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps\n * the URL idempotent and the nested `where` intact across navigations.\n *\n * This is a router-global serializer: it applies to every route, not just\n * `/admin`. On your own routes, search values arrive as strings (qs does no\n * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where\n * you need numbers or booleans.\n *\n * @example\n * ```ts\n * import { createRouter } from '@tanstack/react-router'\n * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'\n *\n * export function getRouter() {\n * return createRouter({\n * parseSearch: payloadParseSearch,\n * routeTree,\n * stringifySearch: payloadStringifySearch,\n * })\n * }\n * ```\n */\nexport const payloadParseSearch = (searchStr: string) =>\n qs.parse(searchStr, { depth: 10, ignoreQueryPrefix: true })\n\n/**\n * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.\n */\nexport const payloadStringifySearch = (search: Record<string, unknown>) => {\n const searchStr = qs.stringify(search)\n return searchStr ? `?${searchStr}` : ''\n}\n"],"names":["qs","payloadParseSearch","searchStr","parse","depth","ignoreQueryPrefix","payloadStringifySearch","search","stringify"],"mappings":"AAAA,YAAYA,QAAQ,SAAQ;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,MAAMC,qBAAqB,CAACC,YACjCF,GAAGG,KAAK,CAACD,WAAW;QAAEE,OAAO;QAAIC,mBAAmB;IAAK,GAAE;AAE7D;;;CAGC,GACD,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAML,YAAYF,GAAGQ,SAAS,CAACD;IAC/B,OAAOL,YAAY,CAAC,CAAC,EAAEA,WAAW,GAAG;AACvC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
1
+ {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -1,4 +1,5 @@
1
1
  import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { createElement, Fragment } from 'react';
2
3
  /**
3
4
  * Recursively walk a server-function return value and prepare it for transit
4
5
  * to the client as an RSC payload.
@@ -78,6 +79,22 @@ async function walk(value, cache, ancestors) {
78
79
  return cleaned;
79
80
  }
80
81
  if (Array.isArray(obj)) {
82
+ // An array consisting entirely of React elements (e.g. a field's
83
+ // `beforeInput` / `afterInput` component list, produced by
84
+ // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
85
+ // Converting each element individually below turns every item into its own
86
+ // `renderServerComponent` handle, which drops the element's React `key` —
87
+ // the client then renders `{[handle, handle]}` as unkeyed array children
88
+ // and React warns "Each child in a list should have a unique key prop".
89
+ // Payload always renders these component arrays wholesale (`{BeforeInput}`),
90
+ // so collapsing them into one Fragment-rendered handle is render-equivalent
91
+ // and keeps the per-element keys intact inside the single Flight payload.
92
+ const items = obj.filter((item)=>item !== null && item !== undefined);
93
+ const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
94
+ if (isReactElementArray) {
95
+ ancestors.delete(obj);
96
+ return await renderServerComponent(createElement(Fragment, null, ...obj));
97
+ }
81
98
  const arr = [];
82
99
  cache.set(obj, arr);
83
100
  for (const item of obj){