@payloadcms/tanstack-start 4.0.0-internal.293e026 → 4.0.0-internal.4c792ad
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.
- package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
- package/dist/elements/RouterAdapter/index.js +38 -15
- package/dist/elements/RouterAdapter/index.js.map +1 -1
- package/dist/exports/client.d.ts +4 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +1 -0
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -0
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/server.d.ts +2 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +2 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +36 -0
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +7 -0
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
- package/dist/layouts/Root/withPayloadRoot.js +92 -0
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
- package/dist/routes/adminRoutes.d.ts +100 -0
- package/dist/routes/adminRoutes.d.ts.map +1 -0
- package/dist/routes/adminRoutes.js +97 -0
- package/dist/routes/adminRoutes.js.map +1 -0
- package/dist/routes/apiRoute.d.ts +29 -0
- package/dist/routes/apiRoute.d.ts.map +1 -0
- package/dist/routes/apiRoute.js +38 -0
- package/dist/routes/apiRoute.js.map +1 -0
- package/dist/routes/layoutRoute.d.ts +23 -0
- package/dist/routes/layoutRoute.d.ts.map +1 -0
- package/dist/routes/layoutRoute.js +51 -0
- package/dist/routes/layoutRoute.js.map +1 -0
- package/dist/utilities/handleAPIRoute.d.ts +11 -0
- package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
- package/dist/utilities/handleAPIRoute.js +17 -0
- package/dist/utilities/handleAPIRoute.js.map +1 -0
- package/dist/utilities/importMap.server.d.ts +4 -5
- package/dist/utilities/importMap.server.d.ts.map +1 -1
- package/dist/utilities/importMap.server.js +5 -6
- package/dist/utilities/importMap.server.js.map +1 -1
- package/dist/utilities/loadAdminPage.d.ts +64 -0
- package/dist/utilities/loadAdminPage.d.ts.map +1 -0
- package/dist/utilities/loadAdminPage.js +217 -0
- package/dist/utilities/loadAdminPage.js.map +1 -0
- package/dist/utilities/loadLayoutData.d.ts +41 -0
- package/dist/utilities/loadLayoutData.d.ts.map +1 -0
- package/dist/utilities/loadLayoutData.js +24 -0
- package/dist/utilities/loadLayoutData.js.map +1 -0
- package/dist/utilities/serverFunctionClient.d.ts +29 -0
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
- package/dist/utilities/serverFunctionClient.js +109 -0
- package/dist/utilities/serverFunctionClient.js.map +1 -0
- package/dist/vite/constants.d.ts +7 -2
- package/dist/vite/constants.d.ts.map +1 -1
- package/dist/vite/constants.js +53 -5
- package/dist/vite/constants.js.map +1 -1
- package/dist/vite/plugin.js +8 -12
- package/dist/vite/plugin.js.map +1 -1
- package/package.json +7 -7
- package/dist/auth/switchLanguage.d.ts +0 -6
- package/dist/auth/switchLanguage.d.ts.map +0 -1
- package/dist/auth/switchLanguage.js +0 -11
- package/dist/auth/switchLanguage.js.map +0 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
2
|
+
import { getRequestI18n } from './getRequestI18n.server.js';
|
|
3
|
+
import { initReq } from './initReq.server.js';
|
|
4
|
+
import { createPageRenderServerAdapter } from './serverAdapter.server.js';
|
|
5
|
+
const resolveTitle = (title)=>{
|
|
6
|
+
if (!title) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (typeof title === 'string') {
|
|
10
|
+
return title;
|
|
11
|
+
}
|
|
12
|
+
if ('absolute' in title) {
|
|
13
|
+
return title.absolute;
|
|
14
|
+
}
|
|
15
|
+
return title.default;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into
|
|
19
|
+
* the plain, serializable `AdminPageMetadata` the route loader ships to the
|
|
20
|
+
* client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and
|
|
21
|
+
* other non-serializable values that seroval cannot cross the wire, so only the
|
|
22
|
+
* fields `getAdminMeta` renders are extracted.
|
|
23
|
+
*/ const toAdminPageMetadata = (meta)=>{
|
|
24
|
+
const og = meta.openGraph;
|
|
25
|
+
const rawImages = og?.images;
|
|
26
|
+
const imagesArray = rawImages ? Array.isArray(rawImages) ? rawImages : [
|
|
27
|
+
rawImages
|
|
28
|
+
] : [];
|
|
29
|
+
const images = imagesArray.map((image)=>typeof image === 'string' ? {
|
|
30
|
+
url: image
|
|
31
|
+
} : image?.url ? {
|
|
32
|
+
alt: image.alt,
|
|
33
|
+
height: image.height,
|
|
34
|
+
url: String(image.url),
|
|
35
|
+
width: image.width
|
|
36
|
+
} : undefined).filter(Boolean);
|
|
37
|
+
const rawIcons = meta.icons;
|
|
38
|
+
const iconList = Array.isArray(rawIcons) ? rawIcons : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon) ? rawIcons.icon : [];
|
|
39
|
+
const icons = iconList.map((icon)=>typeof icon === 'string' ? {
|
|
40
|
+
rel: 'icon',
|
|
41
|
+
url: icon
|
|
42
|
+
} : icon?.url ? {
|
|
43
|
+
type: icon.type,
|
|
44
|
+
media: icon.media,
|
|
45
|
+
rel: icon.rel ?? 'icon',
|
|
46
|
+
sizes: icon.sizes,
|
|
47
|
+
url: String(icon.url)
|
|
48
|
+
} : undefined).filter(Boolean);
|
|
49
|
+
const keywords = meta.keywords;
|
|
50
|
+
return {
|
|
51
|
+
description: typeof meta.description === 'string' ? meta.description : undefined,
|
|
52
|
+
icons: icons?.length ? icons : undefined,
|
|
53
|
+
keywords: typeof keywords === 'string' ? keywords : Array.isArray(keywords) ? keywords.join(', ') : undefined,
|
|
54
|
+
openGraph: og ? {
|
|
55
|
+
description: typeof og.description === 'string' ? og.description : undefined,
|
|
56
|
+
images: images?.length ? images : undefined,
|
|
57
|
+
siteName: typeof og.siteName === 'string' ? og.siteName : undefined,
|
|
58
|
+
title: typeof og.title === 'string' ? og.title : undefined
|
|
59
|
+
} : undefined,
|
|
60
|
+
robots: typeof meta.robots === 'string' ? meta.robots : undefined,
|
|
61
|
+
title: resolveTitle(meta.title)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Renders an admin page for TanStack Start and returns a serializable loader
|
|
66
|
+
* result. The framework adapter wraps this in a `createServerFn` that supplies
|
|
67
|
+
* the app's `config` and generated `importMap`.
|
|
68
|
+
*
|
|
69
|
+
* 1. Initializes the Payload request via the shared `renderRoot` orchestrator
|
|
70
|
+
* from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
|
|
71
|
+
* page-render `ServerAdapter` records navigation intent and throws the
|
|
72
|
+
* framework-agnostic error contract.
|
|
73
|
+
* 2. Pipes the resulting React server tree through `renderServerComponent`
|
|
74
|
+
* to produce a Flight payload the client consumes directly.
|
|
75
|
+
* 3. Resolves page metadata via the same shared `generatePageMetadata`
|
|
76
|
+
* Next.js uses, returning plain serializable strings for `head()`.
|
|
77
|
+
*
|
|
78
|
+
* Navigation surfaces two ways and both become a `_notFound` / `_redirect`
|
|
79
|
+
* sentinel the route loader re-throws as native TanStack nav:
|
|
80
|
+
* - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
|
|
81
|
+
* by the try/catch below;
|
|
82
|
+
* - thrown deep inside a streamed view component (e.g. `DocumentView` access
|
|
83
|
+
* denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
|
|
84
|
+
* so it's read from the `nav` holder after `renderServerComponent` resolves.
|
|
85
|
+
*/ export async function loadAdminPage({ config, importMap, search, splat }) {
|
|
86
|
+
const { renderRoot } = await import('@payloadcms/ui/views/Root');
|
|
87
|
+
const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews');
|
|
88
|
+
const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata');
|
|
89
|
+
const splatSegments = splat ? splat.split('/').filter(Boolean) : [];
|
|
90
|
+
// Match Next's optional-catch-all behavior: the admin root (`/admin`) has no
|
|
91
|
+
// segments. Passing an empty array makes the shared `renderRoot` build
|
|
92
|
+
// `currentRoute` as `/admin/` (trailing slash), which no longer equals
|
|
93
|
+
// `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.
|
|
94
|
+
// Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated
|
|
95
|
+
// redirect lands on a clean `/admin/login`.
|
|
96
|
+
const segments = splatSegments.length > 0 ? splatSegments : undefined;
|
|
97
|
+
const searchParams = search ?? {};
|
|
98
|
+
// Records navigation requested via `req.server.*` (including throws swallowed
|
|
99
|
+
// by RSC streaming deep inside view components). Read after the render.
|
|
100
|
+
const nav = {};
|
|
101
|
+
const pageServerAdapter = createPageRenderServerAdapter(nav);
|
|
102
|
+
// `renderRoot` calls `initReq` itself with its own overrides (query
|
|
103
|
+
// re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
|
|
104
|
+
// page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
|
|
105
|
+
// is recorded + thrown rather than escaping as raw TanStack nav.
|
|
106
|
+
const boundInitReq = (args)=>initReq({
|
|
107
|
+
configPromise: args.configPromise,
|
|
108
|
+
importMap: args.importMap,
|
|
109
|
+
overrides: args.overrides,
|
|
110
|
+
serverAdapter: pageServerAdapter
|
|
111
|
+
});
|
|
112
|
+
const notFound = ()=>{
|
|
113
|
+
nav.type = 'notFound';
|
|
114
|
+
throw new Error('not-found');
|
|
115
|
+
};
|
|
116
|
+
const redirect = (url)=>{
|
|
117
|
+
nav.type = 'redirect';
|
|
118
|
+
nav.url = url;
|
|
119
|
+
throw new Error(`redirect:${url}`);
|
|
120
|
+
};
|
|
121
|
+
// Build the 404 result the route loader re-throws as TanStack `notFound()`.
|
|
122
|
+
//
|
|
123
|
+
// Throwing `notFound()` is the only way to set the SSR document status to 404
|
|
124
|
+
// (it's read from `router.stores.statusCode`, set by a not-found match — NOT
|
|
125
|
+
// from `setResponseStatus`, which only affects the RSC RPC response). But the
|
|
126
|
+
// matching `notFoundComponent` is a client component with no access to the
|
|
127
|
+
// Payload `req`, so it can't build the admin chrome on its own. To match Next
|
|
128
|
+
// (whose not-found route renders the full admin layout — nav sidebar, etc. —
|
|
129
|
+
// around the NotFound body, see `renderNotFoundPage`), we render that same
|
|
130
|
+
// shared `renderNotFoundPage` tree here, server-side, and ship its Flight
|
|
131
|
+
// payload through the `notFound()` error so the client renders it verbatim.
|
|
132
|
+
// For users without admin access `renderNotFoundPage` returns the bare
|
|
133
|
+
// `NotFoundClient`, preserving the access-denied behavior.
|
|
134
|
+
const renderNotFound = async ()=>{
|
|
135
|
+
const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page');
|
|
136
|
+
const notFoundNode = await renderNotFoundPage({
|
|
137
|
+
config: Promise.resolve(config),
|
|
138
|
+
importMap,
|
|
139
|
+
initReq: (args)=>initReq({
|
|
140
|
+
configPromise: args.configPromise,
|
|
141
|
+
importMap: args.importMap,
|
|
142
|
+
overrides: args.overrides
|
|
143
|
+
}),
|
|
144
|
+
params: Promise.resolve({
|
|
145
|
+
segments: splatSegments
|
|
146
|
+
}),
|
|
147
|
+
searchParams: Promise.resolve(searchParams)
|
|
148
|
+
});
|
|
149
|
+
const rscPayload = await renderServerComponent(notFoundNode);
|
|
150
|
+
return {
|
|
151
|
+
_notFound: true,
|
|
152
|
+
routeKey: splat ?? '',
|
|
153
|
+
rscPayload
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
try {
|
|
157
|
+
const node = await renderRoot({
|
|
158
|
+
adminViews: defaultAdminViews,
|
|
159
|
+
config: Promise.resolve(config),
|
|
160
|
+
importMap,
|
|
161
|
+
initReq: boundInitReq,
|
|
162
|
+
notFound,
|
|
163
|
+
// `segments` is intentionally `undefined` for the admin root (`/admin`),
|
|
164
|
+
// matching Next's optional catch-all; `renderRoot` handles it at runtime.
|
|
165
|
+
params: Promise.resolve({
|
|
166
|
+
segments
|
|
167
|
+
}),
|
|
168
|
+
redirect,
|
|
169
|
+
searchParams: Promise.resolve(searchParams)
|
|
170
|
+
});
|
|
171
|
+
const rscPayload = await renderServerComponent(node);
|
|
172
|
+
// Navigation thrown deep inside a streamed view component (e.g. access
|
|
173
|
+
// denied → notFound, already-authenticated → redirect) is swallowed into
|
|
174
|
+
// the RSC stream and never rejects the render. Honor it from the holder,
|
|
175
|
+
// discarding the (broken) payload from the aborted render.
|
|
176
|
+
if (nav.type === 'redirect' && nav.url) {
|
|
177
|
+
return {
|
|
178
|
+
_redirect: nav.url
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (nav.type === 'notFound') {
|
|
182
|
+
return await renderNotFound();
|
|
183
|
+
}
|
|
184
|
+
// Resolve metadata through the same shared generator Next.js uses. Only
|
|
185
|
+
// plain strings cross the wire (the full `MetaConfig` carries a `URL`
|
|
186
|
+
// `metadataBase` and icons that seroval cannot serialize).
|
|
187
|
+
const i18n = await getRequestI18n({
|
|
188
|
+
config
|
|
189
|
+
});
|
|
190
|
+
const meta = await generatePageMetadata({
|
|
191
|
+
adminViews: defaultAdminViews,
|
|
192
|
+
config,
|
|
193
|
+
i18n,
|
|
194
|
+
params: {
|
|
195
|
+
segments
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
return {
|
|
199
|
+
metadata: toAdminPageMetadata(meta),
|
|
200
|
+
routeKey: splat ?? '',
|
|
201
|
+
rscPayload
|
|
202
|
+
};
|
|
203
|
+
} catch (err) {
|
|
204
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
205
|
+
if (nav.type === 'notFound' || message === 'not-found') {
|
|
206
|
+
return await renderNotFound();
|
|
207
|
+
}
|
|
208
|
+
if (nav.type === 'redirect' || message.startsWith('redirect:')) {
|
|
209
|
+
return {
|
|
210
|
+
_redirect: nav.url ?? message.slice('redirect:'.length)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//# sourceMappingURL=loadAdminPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\n/**\n * The serializable RSC handle returned by `renderServerComponent`, not raw\n * `React.ReactNode`. TanStack's `createServerFn` return-type guard recognizes\n * this handle as wire-serializable; widening it to `React.ReactNode` surfaces a\n * `SerializationError<\"JSX is not be serializable\">` at every consuming server\n * function.\n */\ntype RenderedRsc = Awaited<ReturnType<typeof renderServerComponent<React.ReactElement>>>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RenderedRsc }\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: RenderedRsc\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\n}\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n\n // `renderRoot` calls `initReq` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initReq: boundInitReq,\n notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: toAdminPageMetadata(meta),\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["renderServerComponent","getRequestI18n","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","boundInitReq","args","configPromise","overrides","serverAdapter","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","_redirect","i18n","metadata","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AAsCzE,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,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IC,OAAO,GAAGvD,OAAOsD;QAC5D,IAAIxB,IAAIrB,IAAI,KAAK,cAAc8C,YAAY,aAAa;YACtD,OAAO,MAAMf;QACf;QACA,IAAIV,IAAIrB,IAAI,KAAK,cAAc8C,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEL,WAAWrB,IAAIjC,GAAG,IAAI0D,QAAQE,KAAK,CAAC,YAAY3C,MAAM;YAAE;QACnE;QACA,MAAMwC;IACR;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ImportMap, SanitizedConfig } from 'payload';
|
|
2
|
+
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
3
|
+
import { getLayoutData } from '../layouts/Root/getLayoutData.js';
|
|
4
|
+
/** Plain JSON value. See `clientConfig` on {@link LoadLayoutDataResult}. */
|
|
5
|
+
type JSONSerializable = {
|
|
6
|
+
[key: string]: JSONSerializable;
|
|
7
|
+
} | boolean | JSONSerializable[] | null | number | string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The serializable RSC handle returned by `renderServerComponent`, recognized
|
|
10
|
+
* by TanStack's `createServerFn` return-type guard. See `loadAdminPage`.
|
|
11
|
+
*/
|
|
12
|
+
type RenderedRsc = Awaited<ReturnType<typeof renderServerComponent<React.ReactElement>>>;
|
|
13
|
+
/**
|
|
14
|
+
* Serializable layout payload returned to the `/_payload` route loader. Mirrors
|
|
15
|
+
* `getLayoutData`'s result, with two fields re-typed so TanStack's serialization
|
|
16
|
+
* guard accepts the wrapping `createServerFn`:
|
|
17
|
+
* - `providers` is the rendered RSC handle, not the unrendered element tree.
|
|
18
|
+
* - `clientConfig` is surfaced as plain JSON. `ClientConfig`'s static type
|
|
19
|
+
* carries deep `unknown`/function members (field schemas) that the guard
|
|
20
|
+
* rejects even though `toSerializable` strips them at runtime. The layout
|
|
21
|
+
* route reads it via loosely-typed `useLoaderData`, so the narrowing is inert.
|
|
22
|
+
*/
|
|
23
|
+
export type LoadLayoutDataResult = {
|
|
24
|
+
clientConfig: JSONSerializable;
|
|
25
|
+
providers?: RenderedRsc;
|
|
26
|
+
} & Omit<Awaited<ReturnType<typeof getLayoutData>>, 'clientConfig' | 'providers'>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the admin layout data for TanStack Start and returns a serializable
|
|
29
|
+
* payload for the `/_payload` route loader. The framework adapter wraps this in
|
|
30
|
+
* a `createServerFn` that supplies the app's `config` and generated `importMap`.
|
|
31
|
+
*
|
|
32
|
+
* `toSerializable` strips React elements, so the custom-providers element tree
|
|
33
|
+
* (`config.admin.components.providers`) is rendered to an RSC payload separately
|
|
34
|
+
* and re-attached.
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadLayoutData({ config, importMap, }: {
|
|
37
|
+
config: SanitizedConfig;
|
|
38
|
+
importMap: ImportMap;
|
|
39
|
+
}): Promise<LoadLayoutDataResult>;
|
|
40
|
+
export {};
|
|
41
|
+
//# 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;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGhE,4EAA4E;AAC5E,KAAK,gBAAgB,GACjB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,GACnC,OAAO,GACP,gBAAgB,EAAE,GAClB,IAAI,GACJ,MAAM,GACN,MAAM,GACN,SAAS,CAAA;AAEb;;;GAGG;AACH,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;AAExF;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,gBAAgB,CAAA;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAA;CACxB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,CAAA;AAEjF;;;;;;;;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,CAQhC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
clientConfig: data.clientConfig,
|
|
20
|
+
providers: providers ? await renderServerComponent(providers) : undefined
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//# 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/** Plain JSON value. See `clientConfig` on {@link LoadLayoutDataResult}. */\ntype JSONSerializable =\n | { [key: string]: JSONSerializable }\n | boolean\n | JSONSerializable[]\n | null\n | number\n | string\n | undefined\n\n/**\n * The serializable RSC handle returned by `renderServerComponent`, recognized\n * by TanStack's `createServerFn` return-type guard. See `loadAdminPage`.\n */\ntype RenderedRsc = Awaited<ReturnType<typeof renderServerComponent<React.ReactElement>>>\n\n/**\n * Serializable layout payload returned to the `/_payload` route loader. Mirrors\n * `getLayoutData`'s result, with two fields re-typed so TanStack's serialization\n * guard accepts the wrapping `createServerFn`:\n * - `providers` is the rendered RSC handle, not the unrendered element tree.\n * - `clientConfig` is surfaced as plain JSON. `ClientConfig`'s static type\n * carries deep `unknown`/function members (field schemas) that the guard\n * rejects even though `toSerializable` strips them at runtime. The layout\n * route reads it via loosely-typed `useLoaderData`, so the narrowing is inert.\n */\nexport type LoadLayoutDataResult = {\n clientConfig: JSONSerializable\n providers?: RenderedRsc\n} & Omit<Awaited<ReturnType<typeof getLayoutData>>, 'clientConfig' | 'providers'>\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<LoadLayoutDataResult> {\n const { providers, ...data } = await getLayoutData({ configPromise: config, importMap })\n\n return {\n ...toSerializable(data),\n clientConfig: data.clientConfig as unknown as JSONSerializable,\n providers: providers ? await renderServerComponent(providers as any) : undefined,\n }\n}\n"],"names":["renderServerComponent","getLayoutData","toSerializable","loadLayoutData","config","importMap","providers","data","configPromise","clientConfig","undefined"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAEjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAiCpD;;;;;;;;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,GAAGH,eAAeK,KAAK;QACvBE,cAAcF,KAAKE,YAAY;QAC/BH,WAAWA,YAAY,MAAMN,sBAAsBM,aAAoBI;IACzE;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the client-side `ServerFunctionClient` wired into
|
|
4
|
+
* `RootProvider.serverFunction`, given the app's `createServerFn`-based
|
|
5
|
+
* dispatcher (`runServerFn`).
|
|
6
|
+
*
|
|
7
|
+
* Strips functions / symbols / RegExps / React elements from the args before
|
|
8
|
+
* dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
|
|
9
|
+
* those, but TanStack Start's seroval-based wire format errors instead. We
|
|
10
|
+
* mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
|
|
11
|
+
* `ServerFunctionsProvider`) that may pass the live form state — which can
|
|
12
|
+
* carry stray functions — keep working without each call site sanitising.
|
|
13
|
+
*
|
|
14
|
+
* Delegates to `runServerFn`, so the response (including any RSC handles for
|
|
15
|
+
* server-rendered custom components) is decoded by TanStack Start back into
|
|
16
|
+
* renderable React nodes on the client.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createServerFunctionClient({ runServerFn, }: {
|
|
19
|
+
runServerFn: (input: {
|
|
20
|
+
data: ServerFunctionClientArgs;
|
|
21
|
+
}) => Promise<unknown>;
|
|
22
|
+
}): ServerFunctionClient;
|
|
23
|
+
/**
|
|
24
|
+
* Recursively removes values TanStack Start's seroval wire format cannot
|
|
25
|
+
* serialize (functions, symbols, RegExps, React elements, cyclic refs) and
|
|
26
|
+
* normalizes `Date` subclasses to plain `Date`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function stripUnserializable(value: unknown, cache?: WeakMap<object, unknown>, ancestors?: WeakSet<object>): unknown;
|
|
29
|
+
//# sourceMappingURL=serverFunctionClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7E,GAAG,oBAAoB,CAKvB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAiB,EAC/C,SAAS,GAAE,OAAO,CAAC,MAAM,CAAiB,GACzC,OAAO,CA4FT"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the client-side `ServerFunctionClient` wired into
|
|
3
|
+
* `RootProvider.serverFunction`, given the app's `createServerFn`-based
|
|
4
|
+
* dispatcher (`runServerFn`).
|
|
5
|
+
*
|
|
6
|
+
* Strips functions / symbols / RegExps / React elements from the args before
|
|
7
|
+
* dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
|
|
8
|
+
* those, but TanStack Start's seroval-based wire format errors instead. We
|
|
9
|
+
* mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
|
|
10
|
+
* `ServerFunctionsProvider`) that may pass the live form state — which can
|
|
11
|
+
* carry stray functions — keep working without each call site sanitising.
|
|
12
|
+
*
|
|
13
|
+
* Delegates to `runServerFn`, so the response (including any RSC handles for
|
|
14
|
+
* server-rendered custom components) is decoded by TanStack Start back into
|
|
15
|
+
* renderable React nodes on the client.
|
|
16
|
+
*/ export function createServerFunctionClient({ runServerFn }) {
|
|
17
|
+
return async (args)=>{
|
|
18
|
+
const safeArgs = stripUnserializable(args);
|
|
19
|
+
return await runServerFn({
|
|
20
|
+
data: safeArgs
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Recursively removes values TanStack Start's seroval wire format cannot
|
|
26
|
+
* serialize (functions, symbols, RegExps, React elements, cyclic refs) and
|
|
27
|
+
* normalizes `Date` subclasses to plain `Date`.
|
|
28
|
+
*/ export function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
|
|
29
|
+
if (value === null || value === undefined) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
const t = typeof value;
|
|
33
|
+
if (t === 'function' || t === 'symbol') {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (t !== 'object') {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
const obj = value;
|
|
40
|
+
if (typeof obj.$$typeof === 'symbol') {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (ancestors.has(obj)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (cache.has(obj)) {
|
|
47
|
+
return cache.get(obj);
|
|
48
|
+
}
|
|
49
|
+
if (obj instanceof Date) {
|
|
50
|
+
// Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,
|
|
51
|
+
// used by the schedule-publish drawer) are `instanceof Date` but have a
|
|
52
|
+
// different `constructor`, which TanStack Start's seroval serializer
|
|
53
|
+
// rejects with "The value [object Date] ... cannot be parsed/serialized".
|
|
54
|
+
return new Date(obj.getTime());
|
|
55
|
+
}
|
|
56
|
+
if (obj instanceof RegExp) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
ancestors.add(obj);
|
|
60
|
+
if (obj instanceof Map) {
|
|
61
|
+
const cleaned = new Map();
|
|
62
|
+
cache.set(obj, cleaned);
|
|
63
|
+
for (const [k, v] of obj){
|
|
64
|
+
const cv = stripUnserializable(v, cache, ancestors);
|
|
65
|
+
if (cv !== undefined) {
|
|
66
|
+
cleaned.set(k, cv);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
ancestors.delete(obj);
|
|
70
|
+
return cleaned;
|
|
71
|
+
}
|
|
72
|
+
if (obj instanceof Set) {
|
|
73
|
+
const cleaned = new Set();
|
|
74
|
+
cache.set(obj, cleaned);
|
|
75
|
+
for (const v of obj){
|
|
76
|
+
const cv = stripUnserializable(v, cache, ancestors);
|
|
77
|
+
if (cv !== undefined) {
|
|
78
|
+
cleaned.add(cv);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
ancestors.delete(obj);
|
|
82
|
+
return cleaned;
|
|
83
|
+
}
|
|
84
|
+
if (Array.isArray(obj)) {
|
|
85
|
+
const arr = [];
|
|
86
|
+
cache.set(obj, arr);
|
|
87
|
+
for (const item of obj){
|
|
88
|
+
arr.push(stripUnserializable(item, cache, ancestors));
|
|
89
|
+
}
|
|
90
|
+
ancestors.delete(obj);
|
|
91
|
+
return arr;
|
|
92
|
+
}
|
|
93
|
+
if (ArrayBuffer.isView(obj)) {
|
|
94
|
+
ancestors.delete(obj);
|
|
95
|
+
return obj;
|
|
96
|
+
}
|
|
97
|
+
const result = {};
|
|
98
|
+
cache.set(obj, result);
|
|
99
|
+
for (const key of Object.keys(obj)){
|
|
100
|
+
const v = stripUnserializable(obj[key], cache, ancestors);
|
|
101
|
+
if (v !== undefined) {
|
|
102
|
+
result[key] = v;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
ancestors.delete(obj);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=serverFunctionClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\n/**\n * Builds the client-side `ServerFunctionClient` wired into\n * `RootProvider.serverFunction`, given the app's `createServerFn`-based\n * dispatcher (`runServerFn`).\n *\n * Strips functions / symbols / RegExps / React elements from the args before\n * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped\n * those, but TanStack Start's seroval-based wire format errors instead. We\n * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in\n * `ServerFunctionsProvider`) that may pass the live form state — which can\n * carry stray functions — keep working without each call site sanitising.\n *\n * Delegates to `runServerFn`, so the response (including any RSC handles for\n * server-rendered custom components) is decoded by TanStack Start back into\n * renderable React nodes on the client.\n */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<unknown>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const safeArgs = stripUnserializable(args) as ServerFunctionClientArgs\n return await runServerFn({ data: safeArgs })\n }) as ServerFunctionClient\n}\n\n/**\n * Recursively removes values TanStack Start's seroval wire format cannot\n * serialize (functions, symbols, RegExps, React elements, cyclic refs) and\n * normalizes `Date` subclasses to plain `Date`.\n */\nexport function stripUnserializable(\n value: unknown,\n cache: WeakMap<object, unknown> = new WeakMap(),\n ancestors: WeakSet<object> = new WeakSet(),\n): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return undefined\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,\n // used by the schedule-publish drawer) are `instanceof Date` but have a\n // different `constructor`, which TanStack Start's seroval serializer\n // rejects with \"The value [object Date] ... cannot be parsed/serialized\".\n return new Date(obj.getTime())\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(stripUnserializable(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = stripUnserializable(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["createServerFunctionClient","runServerFn","args","safeArgs","stripUnserializable","data","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","getTime","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASA,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAWC,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BqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQF,GAAG,CAACM;YACd;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIO,MAAMC,OAAO,CAACjB,MAAM;QACtB,MAAMkB,MAAiB,EAAE;QACzBxB,MAAMgB,GAAG,CAACV,KAAKkB;QACf,KAAK,MAAMC,QAAQnB,IAAK;YACtBkB,IAAIE,IAAI,CAAC7B,oBAAoB4B,MAAMzB,OAAOE;QAC5C;QACAA,UAAUkB,MAAM,CAACd;QACjB,OAAOkB;IACT;IAEA,IAAIG,YAAYC,MAAM,CAACtB,MAAM;QAC3BJ,UAAUkB,MAAM,CAACd;QACjB,OAAOA;IACT;IAEA,MAAMuB,SAAkC,CAAC;IACzC7B,MAAMgB,GAAG,CAACV,KAAKuB;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC1B,KAAM;QAClC,MAAMY,IAAIrB,oBAAoBS,GAAG,CAACwB,IAAI,EAAE9B,OAAOE;QAC/C,IAAIgB,MAAMd,WAAW;YACnByB,MAAM,CAACC,IAAI,GAAGZ;QAChB;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
|
package/dist/vite/constants.d.ts
CHANGED
|
@@ -16,8 +16,13 @@ export declare const ssrExternalPackages: string[];
|
|
|
16
16
|
export declare const payloadNoExternalPatterns: Array<RegExp | string>;
|
|
17
17
|
/**
|
|
18
18
|
* The subset of `payloadNoExternalPatterns` that needs to participate in the
|
|
19
|
-
* RSC environment.
|
|
20
|
-
*
|
|
19
|
+
* RSC environment. Plugins and storage adapters must be included: they register
|
|
20
|
+
* custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`
|
|
21
|
+
* `TenantSelectionProvider`) that render in the RSC graph via
|
|
22
|
+
* `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`
|
|
23
|
+
* never transforms its `'use client'` modules into client references, so the
|
|
24
|
+
* component executes server-side and crashes on the first hook
|
|
25
|
+
* (`Cannot read properties of null (reading 'useState')`).
|
|
21
26
|
*/
|
|
22
27
|
export declare const payloadRscNoExternalPatterns: Array<RegExp | string>;
|
|
23
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0BvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0BvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO/D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA8E/C,CAAA"}
|
package/dist/vite/constants.js
CHANGED
|
@@ -46,13 +46,20 @@
|
|
|
46
46
|
];
|
|
47
47
|
/**
|
|
48
48
|
* The subset of `payloadNoExternalPatterns` that needs to participate in the
|
|
49
|
-
* RSC environment.
|
|
50
|
-
*
|
|
49
|
+
* RSC environment. Plugins and storage adapters must be included: they register
|
|
50
|
+
* custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`
|
|
51
|
+
* `TenantSelectionProvider`) that render in the RSC graph via
|
|
52
|
+
* `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`
|
|
53
|
+
* never transforms its `'use client'` modules into client references, so the
|
|
54
|
+
* component executes server-side and crashes on the first hook
|
|
55
|
+
* (`Cannot read properties of null (reading 'useState')`).
|
|
51
56
|
*/ export const payloadRscNoExternalPatterns = [
|
|
52
57
|
'@payloadcms/ui',
|
|
53
58
|
'@payloadcms/translations',
|
|
54
59
|
'@payloadcms/tanstack-start',
|
|
55
|
-
/^@payloadcms\/richtext-lexical
|
|
60
|
+
/^@payloadcms\/richtext-lexical/,
|
|
61
|
+
/^@payloadcms\/plugin-/,
|
|
62
|
+
/^@payloadcms\/storage-/
|
|
56
63
|
];
|
|
57
64
|
/**
|
|
58
65
|
* Packages we know contain Node-only code or top-level side effects requiring
|
|
@@ -111,7 +118,20 @@
|
|
|
111
118
|
'@payloadcms/ui > md5',
|
|
112
119
|
'payload > deepmerge',
|
|
113
120
|
'payload > pluralize',
|
|
114
|
-
|
|
121
|
+
// `scheduler` is a transitive dep of `react-dom`, not a direct dependency of
|
|
122
|
+
// the app, so a bare `'scheduler'` specifier fails to resolve from an isolated
|
|
123
|
+
// install (`test/node_modules` built with `pnpm i --ignore-workspace`), where
|
|
124
|
+
// it isn't hoisted to the top level. Path it through `react-dom` so the
|
|
125
|
+
// optimizer resolves the exact copy the runtime loads.
|
|
126
|
+
'react-dom > scheduler',
|
|
127
|
+
// `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the
|
|
128
|
+
// React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.
|
|
129
|
+
// Because its parent is excluded, the optimizer never crawls in to discover
|
|
130
|
+
// this entry, so Vite serves `react/compiler-runtime` raw. That file is
|
|
131
|
+
// CommonJS (`module.exports = require(...)`), so the named `c` export can't be
|
|
132
|
+
// statically extracted and every client component throws "does not provide an
|
|
133
|
+
// export named 'c'". Pre-bundling it lets esbuild synthesize the named export.
|
|
134
|
+
'react/compiler-runtime',
|
|
115
135
|
// Transitive deps that Vite otherwise discovers *after* the initial crawl
|
|
116
136
|
// (react-select pulls in @floating-ui at runtime; react-is is reached via
|
|
117
137
|
// react-transition-group/prop-types; the default date-fns locale is loaded
|
|
@@ -123,7 +143,35 @@
|
|
|
123
143
|
'@payloadcms/ui > react-select > @floating-ui/dom',
|
|
124
144
|
'@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',
|
|
125
145
|
'@payloadcms/ui > react-select > prop-types > react-is',
|
|
126
|
-
'@payloadcms/ui > date-fns/locale/en-US'
|
|
146
|
+
'@payloadcms/ui > date-fns/locale/en-US',
|
|
147
|
+
// Further late discoveries observed re-optimizing mid-run in CI cold starts
|
|
148
|
+
// (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / ajv /
|
|
149
|
+
// dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
|
|
150
|
+
// render; form-state diffing reaches `dequal/lite` (a distinct entry point
|
|
151
|
+
// from the already-listed `dequal`); client-side field validation reaches
|
|
152
|
+
// `ajv` *through `payload`* — it is `ssrExternal` server-side but still
|
|
153
|
+
// bundled into the client, and must be pathed via `payload` so the optimizer
|
|
154
|
+
// pre-bundles the exact copy the runtime loads.
|
|
155
|
+
'@payloadcms/ui > @dnd-kit/modifiers',
|
|
156
|
+
'@payloadcms/ui > dequal/lite',
|
|
157
|
+
'payload > ajv',
|
|
158
|
+
// The storage client-upload suites (esp. vercel-blob) crawl part of the
|
|
159
|
+
// `payload` server runtime into the client bundle and discover these late,
|
|
160
|
+
// triggering several "optimized dependencies changed. reloading" waves that
|
|
161
|
+
// reload the page mid-test (the bulk-upload drawer's Create New button /
|
|
162
|
+
// dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the
|
|
163
|
+
// whole observed set so the first pass is complete.
|
|
164
|
+
'payload > undici',
|
|
165
|
+
'payload > jose',
|
|
166
|
+
'payload > dataloader',
|
|
167
|
+
'payload > path-to-regexp',
|
|
168
|
+
'payload > console-table-printer',
|
|
169
|
+
'payload > ci-info',
|
|
170
|
+
'payload > image-size',
|
|
171
|
+
'payload > image-size/fromFile',
|
|
172
|
+
'payload > ipaddr.js',
|
|
173
|
+
'payload > range-parser',
|
|
174
|
+
'payload > sanitize-filename'
|
|
127
175
|
];
|
|
128
176
|
|
|
129
177
|
//# sourceMappingURL=constants.js.map
|