@payloadcms/tanstack-start 4.0.0-internal.f05c47f → 4.0.0-internal.f15737c
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/adapters/handleServerFunctions.d.ts.map +1 -0
- package/dist/adapters/handleServerFunctions.js +9 -0
- package/dist/adapters/handleServerFunctions.js.map +1 -0
- package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout/index.d.ts} +29 -4
- package/dist/adapters/layout/index.d.ts.map +1 -0
- package/dist/adapters/layout/index.js +105 -0
- package/dist/adapters/layout/index.js.map +1 -0
- package/dist/adapters/layout/lazy.d.ts +11 -0
- package/dist/adapters/layout/lazy.d.ts.map +1 -0
- package/dist/adapters/layout/lazy.js +23 -0
- package/dist/adapters/layout/lazy.js.map +1 -0
- package/dist/adapters/layout/server.d.ts +29 -0
- package/dist/adapters/layout/server.d.ts.map +1 -0
- package/dist/adapters/layout/server.js +65 -0
- package/dist/adapters/layout/server.js.map +1 -0
- package/dist/{utilities/meta.d.ts → adapters/metadata.d.ts} +10 -1
- package/dist/adapters/metadata.d.ts.map +1 -0
- package/dist/{utilities/meta.js → adapters/metadata.js} +60 -1
- package/dist/adapters/metadata.js.map +1 -0
- package/dist/{elements/RouterAdapter/index.d.ts → adapters/router.d.ts} +1 -1
- package/dist/adapters/router.d.ts.map +1 -0
- package/dist/{elements/RouterAdapter/index.js → adapters/router.js} +10 -2
- package/dist/adapters/router.js.map +1 -0
- package/dist/{utilities/serverAdapter.server.d.ts → adapters/server.d.ts} +1 -1
- package/dist/adapters/server.d.ts.map +1 -0
- package/dist/{utilities/serverAdapter.server.js → adapters/server.js} +1 -1
- package/dist/adapters/server.js.map +1 -0
- package/dist/{routes/adminRoutes.d.ts → adapters/views/index.d.ts} +5 -9
- package/dist/adapters/views/index.d.ts.map +1 -0
- package/dist/{routes/adminRoutes.js → adapters/views/index.js} +7 -42
- package/dist/adapters/views/index.js.map +1 -0
- package/dist/adapters/views/lazy.d.ts +4 -0
- package/dist/adapters/views/lazy.d.ts.map +1 -0
- package/dist/adapters/views/lazy.js +43 -0
- package/dist/adapters/views/lazy.js.map +1 -0
- package/dist/{utilities/loadAdminPage.d.ts → adapters/views/server.d.ts} +4 -4
- package/dist/adapters/views/server.d.ts.map +1 -0
- package/dist/{utilities/loadAdminPage.js → adapters/views/server.js} +12 -74
- package/dist/adapters/views/server.js.map +1 -0
- package/dist/auth/login.js +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.js +1 -1
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.js +1 -1
- package/dist/auth/refresh.js.map +1 -1
- package/dist/exports/client.d.ts +2 -4
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +2 -4
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +2 -3
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -2
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/server.d.ts +7 -9
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +7 -9
- package/dist/exports/server.js.map +1 -1
- package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -1
- package/dist/routes/graphql/handler.server.d.ts.map +1 -0
- package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +3 -3
- package/dist/routes/graphql/handler.server.js.map +1 -0
- package/dist/{utilities/handleAPIRoute.server.d.ts → routes/rest/handler.server.d.ts} +1 -1
- package/dist/routes/rest/handler.server.d.ts.map +1 -0
- package/dist/{utilities/handleAPIRoute.server.js → routes/rest/handler.server.js} +1 -1
- package/dist/routes/rest/handler.server.js.map +1 -0
- package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -0
- package/dist/routes/{apiRoute.js → rest/index.js} +2 -2
- package/dist/routes/rest/index.js.map +1 -0
- package/dist/rsc/CollectionCards.js +1 -1
- package/dist/rsc/CollectionCards.js.map +1 -1
- package/dist/utilities/devConfigReload.server.js +28 -3
- package/dist/utilities/devConfigReload.server.js.map +1 -1
- package/dist/utilities/getRequestI18n.server.d.ts +1 -1
- package/dist/utilities/getRequestI18n.server.js +1 -1
- package/dist/utilities/getRequestI18n.server.js.map +1 -1
- package/dist/utilities/initAdminContext.server.d.ts +9 -0
- package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
- package/dist/utilities/initAdminContext.server.js +13 -0
- package/dist/utilities/initAdminContext.server.js.map +1 -0
- package/dist/utilities/serializeForRsc.d.ts.map +1 -1
- package/dist/utilities/serializeForRsc.js +6 -1
- package/dist/utilities/serializeForRsc.js.map +1 -1
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +6 -1
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/utilities/toSerializable.d.ts.map +1 -1
- package/dist/utilities/toSerializable.js +6 -1
- package/dist/utilities/toSerializable.js.map +1 -1
- package/dist/withPayload/config/external.js +1 -1
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
- package/dist/withPayload/config/optimizeDeps.js +37 -4
- package/dist/withPayload/config/optimizeDeps.js.map +1 -1
- package/dist/withPayload/index.d.ts +8 -10
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +11 -13
- package/dist/withPayload/index.js.map +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
- package/package.json +10 -11
- package/dist/elements/RouterAdapter/index.d.ts.map +0 -1
- package/dist/elements/RouterAdapter/index.js.map +0 -1
- package/dist/layouts/Root/getLayoutData.d.ts +0 -34
- package/dist/layouts/Root/getLayoutData.d.ts.map +0 -1
- package/dist/layouts/Root/getLayoutData.js +0 -97
- package/dist/layouts/Root/getLayoutData.js.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.js +0 -91
- package/dist/layouts/Root/withPayloadRoot.js.map +0 -1
- package/dist/node/cssLoader.d.mts +0 -25
- package/dist/node/cssLoader.d.mts.map +0 -1
- package/dist/node/cssLoader.js +0 -70
- package/dist/node/cssLoader.js.map +0 -1
- package/dist/node/cssLoader.mjs +0 -75
- package/dist/node/registerCssLoader.d.mts +0 -2
- package/dist/node/registerCssLoader.d.mts.map +0 -1
- package/dist/node/registerCssLoader.js +0 -10
- package/dist/node/registerCssLoader.js.map +0 -1
- package/dist/node/registerCssLoader.mjs +0 -10
- package/dist/routes/adminRoutes.d.ts.map +0 -1
- package/dist/routes/adminRoutes.js.map +0 -1
- package/dist/routes/apiRoute.d.ts.map +0 -1
- package/dist/routes/apiRoute.js.map +0 -1
- package/dist/routes/layoutRoute.d.ts +0 -27
- package/dist/routes/layoutRoute.d.ts.map +0 -1
- package/dist/routes/layoutRoute.js +0 -58
- package/dist/routes/layoutRoute.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -19
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/graphqlHandler.server.d.ts.map +0 -1
- package/dist/utilities/graphqlHandler.server.js.map +0 -1
- package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.server.js.map +0 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +0 -1
- package/dist/utilities/handleServerFunctions.js +0 -12
- package/dist/utilities/handleServerFunctions.js.map +0 -1
- package/dist/utilities/initReq.server.d.ts +0 -20
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -90
- package/dist/utilities/initReq.server.js.map +0 -1
- package/dist/utilities/loadAdminPage.d.ts.map +0 -1
- package/dist/utilities/loadAdminPage.js.map +0 -1
- package/dist/utilities/loadLayoutData.d.ts +0 -17
- package/dist/utilities/loadLayoutData.d.ts.map +0 -1
- package/dist/utilities/loadLayoutData.js +0 -22
- package/dist/utilities/loadLayoutData.js.map +0 -1
- package/dist/utilities/meta.d.ts.map +0 -1
- package/dist/utilities/meta.js.map +0 -1
- package/dist/utilities/serverAdapter.server.d.ts.map +0 -1
- package/dist/utilities/serverAdapter.server.js.map +0 -1
- /package/dist/{utilities → adapters}/handleServerFunctions.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addDataAndFileToRequest, addLocalesToRequestFromData,
|
|
1
|
+
import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
|
|
2
2
|
const handleError = async ({ err, payload, req })=>{
|
|
3
3
|
const status = err.originalError?.status || 500;
|
|
4
4
|
let errorMessage = err.message;
|
|
@@ -72,7 +72,7 @@ const getGraphql = async (config)=>{
|
|
|
72
72
|
* Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.
|
|
73
73
|
*/ export const handleGraphQL = async ({ config, request })=>{
|
|
74
74
|
const originalRequest = request.clone();
|
|
75
|
-
const req = await
|
|
75
|
+
const req = await createPayloadRequestFromWebRequest({
|
|
76
76
|
canSetHeaders: true,
|
|
77
77
|
config,
|
|
78
78
|
request
|
|
@@ -126,4 +126,4 @@ const getGraphql = async (config)=>{
|
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
//# sourceMappingURL=
|
|
129
|
+
//# sourceMappingURL=handler.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/graphql/handler.server.ts"],"sourcesContent":["import type { Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport {\n addDataAndFileToRequest,\n addLocalesToRequestFromData,\n createPayloadRequestFromWebRequest,\n headersWithCors,\n logError,\n mergeHeaders,\n} from 'payload'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: any\n payload: Payload\n req: PayloadRequest\n}): Promise<any> => {\n const status = err.originalError?.status || 500\n let errorMessage = err.message\n logError({ err, payload })\n\n if (!payload.config.debug && status === 500) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: any = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached: { graphql: any; promise: null | Promise<any> } = { graphql: null, promise: null }\n\nconst getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n const graphqlPackage = '@payloadcms/graphql'\n const { configToSchema } = await import(/* @vite-ignore */ graphqlPackage)\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\n/**\n * Handles GraphQL HTTP requests for TanStack Start apps.\n * Mirrors the behaviour of `@payloadcms/next`'s GraphQL route handler.\n *\n * Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.\n */\nexport const handleGraphQL = async ({\n config,\n request,\n}: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n request: Request\n}): Promise<Response> => {\n const originalRequest = request.clone()\n\n const req = await createPayloadRequestFromWebRequest({\n canSetHeaders: true,\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const graphqlHttpHandlerPath = 'graphql-http/lib/use/fetch'\n const { createHandler } = await import(/* @vite-ignore */ graphqlHttpHandlerPath)\n\n const headers: Record<string, string> = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (_request: any, args: any, result: any) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: _request,\n result,\n })\n : result\n if (response.errors) {\n const errors = await Promise.all(\n response.errors.map((error: any) => {\n return handleError({ err: error, payload, req })\n }),\n )\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_: any, args: any, defaultRules: any) =>\n defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key of Object.keys(headers)) {\n resHeaders.append(key, headers[key]!)\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n}\n"],"names":["addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequestFromWebRequest","headersWithCors","logError","mergeHeaders","handleError","err","payload","req","status","originalError","errorMessage","message","config","debug","response","extensions","name","undefined","data","stack","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","error","graphqlResult","Promise","resolve","cached","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","graphqlPackage","configToSchema","schema","e","handleGraphQL","request","originalRequest","clone","canSetHeaders","validationRules","graphqlHttpHandlerPath","createHandler","headers","apiResponse","onOperation","_request","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","Object","keys","append","Response","body","responseHeaders"],"mappings":"AAEA,SACEA,uBAAuB,EACvBC,2BAA2B,EAC3BC,kCAAkC,EAClCC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP,UAAS;AAEhB,MAAMC,cAAc,OAAO,EACzBC,GAAG,EACHC,OAAO,EACPC,GAAG,EAKJ;IACC,MAAM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O5C;QACT;QACA6B;QACAO,iBAAiB,CAACW,GAAQJ,MAAWK,eACnCA,aAAaC,MAAM,CAACb,gBAAgBO;IACxC,GAAGV;IAEH,MAAMiB,aAAa/D,gBAAgB;QACjCoD,SAAS,IAAIY,QAAQX,YAAYD,OAAO;QACxC9C;IACF;IAEA,KAAK,MAAM2D,OAAOC,OAAOC,IAAI,CAACf,SAAU;QACtCW,WAAWK,MAAM,CAACH,KAAKb,OAAO,CAACa,IAAI;IACrC;IAEA,OAAO,IAAII,SAAShB,YAAYiB,IAAI,EAAE;QACpClB,SAAS9C,IAAIiE,eAAe,GAAGrE,aAAaI,IAAIiE,eAAe,EAAER,cAAcA;QAC/ExD,QAAQ8C,YAAY9C,MAAM;IAC5B;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.server.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/handler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/handler.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
|
|
@@ -31,4 +31,4 @@ export declare function payloadApiHandlers({ getConfig, }: {
|
|
|
31
31
|
getConfig: () => Promise<SanitizedConfig>;
|
|
32
32
|
}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler>;
|
|
33
33
|
export {};
|
|
34
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* key, leaking the config graph into the client bundle.
|
|
25
25
|
*/ export function payloadApiHandlers({ getConfig }) {
|
|
26
26
|
const handler = async ({ request })=>{
|
|
27
|
-
const { handleAPIRoute } = await import('
|
|
27
|
+
const { handleAPIRoute } = await import('./handler.server.js');
|
|
28
28
|
return handleAPIRoute({
|
|
29
29
|
config: await getConfig(),
|
|
30
30
|
request
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/index.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so\n * the server-only `handleAPIRoute` graph never reaches the client bundle.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('./handler.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CollectionCardsClient } from '@payloadcms/ui';
|
|
2
3
|
import { getCollectionCardsData } from '@payloadcms/ui/server';
|
|
3
|
-
import { CollectionCardsClient } from '@payloadcms/ui/widgets/CollectionCards/index.client';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
export async function CollectionCards(props) {
|
|
6
6
|
const data = await getCollectionCardsData(props.req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rsc/CollectionCards.tsx"],"sourcesContent":["import type { WidgetServerProps } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/rsc/CollectionCards.tsx"],"sourcesContent":["import type { WidgetServerProps } from 'payload'\n\nimport { CollectionCardsClient } from '@payloadcms/ui'\nimport { getCollectionCardsData } from '@payloadcms/ui/server'\nimport React from 'react'\n\nexport async function CollectionCards(props: WidgetServerProps) {\n const data = await getCollectionCardsData(props.req)\n\n return <CollectionCardsClient {...data} />\n}\n"],"names":["CollectionCardsClient","getCollectionCardsData","React","CollectionCards","props","data","req"],"mappings":";AAEA,SAASA,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,sBAAsB,QAAQ,wBAAuB;AAC9D,OAAOC,WAAW,QAAO;AAEzB,OAAO,eAAeC,gBAAgBC,KAAwB;IAC5D,MAAMC,OAAO,MAAMJ,uBAAuBG,MAAME,GAAG;IAEnD,qBAAO,KAACN;QAAuB,GAAGK,IAAI;;AACxC"}
|
|
@@ -4,7 +4,7 @@ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
|
4
4
|
* Subscribes the Payload instance to the config-changed event that the
|
|
5
5
|
* `payload:dev-config-reload` Vite plugin broadcasts.
|
|
6
6
|
*
|
|
7
|
-
* Imported for its side effect by `
|
|
7
|
+
* Imported for its side effect by `initAdminContext.server.ts`, the adapter's only
|
|
8
8
|
* `getPayload` call site, so the strategy is registered before an instance can
|
|
9
9
|
* be built. Registration is module-scoped on both ends: this runs inside the
|
|
10
10
|
* app's server graph and so resolves the same copy of `payload` that
|
|
@@ -19,20 +19,45 @@ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
|
19
19
|
* production build.
|
|
20
20
|
*/ const hot = import.meta.hot;
|
|
21
21
|
if (hot) {
|
|
22
|
+
registerDevReloadStrategy(createConfigChangedStrategy({
|
|
23
|
+
hot
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds a dev reload strategy that forwards the config-changed event to every
|
|
28
|
+
* connected instance.
|
|
29
|
+
*
|
|
30
|
+
* After a program reload, the first request to re-import this module replaces
|
|
31
|
+
* the old listener with a new one, but the cached Payload instance only connects
|
|
32
|
+
* to it on its next `getPayload` call - and a request such as a frontend page
|
|
33
|
+
* render may never make one. An event that lands in that gap has no one to
|
|
34
|
+
* notify, so it is held and replayed to the next connection instead of being
|
|
35
|
+
* dropped - which would otherwise leave the instance serving the old config
|
|
36
|
+
* indefinitely.
|
|
37
|
+
*/ function createConfigChangedStrategy({ hot }) {
|
|
22
38
|
const listeners = new Set();
|
|
39
|
+
let hasPendingReload = false;
|
|
23
40
|
hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
|
|
41
|
+
if (listeners.size === 0) {
|
|
42
|
+
hasPendingReload = true;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
24
45
|
for (const onReload of listeners){
|
|
25
46
|
onReload();
|
|
26
47
|
}
|
|
27
48
|
});
|
|
28
|
-
|
|
49
|
+
return {
|
|
29
50
|
connect: (onReload)=>{
|
|
30
51
|
listeners.add(onReload);
|
|
52
|
+
if (hasPendingReload) {
|
|
53
|
+
hasPendingReload = false;
|
|
54
|
+
onReload();
|
|
55
|
+
}
|
|
31
56
|
return ()=>{
|
|
32
57
|
listeners.delete(onReload);
|
|
33
58
|
};
|
|
34
59
|
}
|
|
35
|
-
}
|
|
60
|
+
};
|
|
36
61
|
}
|
|
37
62
|
|
|
38
63
|
//# sourceMappingURL=devConfigReload.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only\n * `getPayload` call site, so the strategy is registered before an instance can\n * be built. Registration is module-scoped on both ends: this runs inside the\n * app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n registerDevReloadStrategy(createConfigChangedStrategy({ hot }))\n}\n\n/**\n * Builds a dev reload strategy that forwards the config-changed event to every\n * connected instance.\n *\n * After a program reload, the first request to re-import this module replaces\n * the old listener with a new one, but the cached Payload instance only connects\n * to it on its next `getPayload` call - and a request such as a frontend page\n * render may never make one. An event that lands in that gap has no one to\n * notify, so it is held and replayed to the next connection instead of being\n * dropped - which would otherwise leave the instance serving the old config\n * indefinitely.\n */\nfunction createConfigChangedStrategy({ hot }: { hot: ViteHotContext }): {\n connect: (onReload: () => void) => () => void\n} {\n const listeners = new Set<() => void>()\n let hasPendingReload = false\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n if (listeners.size === 0) {\n hasPendingReload = true\n return\n }\n\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n return {\n connect: (onReload) => {\n listeners.add(onReload)\n\n if (hasPendingReload) {\n hasPendingReload = false\n onReload()\n }\n\n return () => {\n listeners.delete(onReload)\n }\n },\n }\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","createConfigChangedStrategy","listeners","Set","hasPendingReload","on","size","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;;;CAiBC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACPF,0BAA0BG,4BAA4B;QAAED;IAAI;AAC9D;AAEA;;;;;;;;;;;CAWC,GACD,SAASC,4BAA4B,EAAED,GAAG,EAA2B;IAGnE,MAAME,YAAY,IAAIC;IACtB,IAAIC,mBAAmB;IAEvBJ,IAAIK,EAAE,CAACN,8BAA8B;QACnC,IAAIG,UAAUI,IAAI,KAAK,GAAG;YACxBF,mBAAmB;YACnB;QACF;QAEA,KAAK,MAAMG,YAAYL,UAAW;YAChCK;QACF;IACF;IAEA,OAAO;QACLC,SAAS,CAACD;YACRL,UAAUO,GAAG,CAACF;YAEd,IAAIH,kBAAkB;gBACpBA,mBAAmB;gBACnBG;YACF;YAEA,OAAO;gBACLL,UAAUQ,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
|
|
|
2
2
|
import type { SanitizedConfig } from 'payload';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the client `I18n` for the current TanStack Start request without a
|
|
5
|
-
* full `
|
|
5
|
+
* full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
|
|
6
6
|
* `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
|
|
7
7
|
* needs `config` + `i18n` to translate admin-page titles.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,7 @@ import { getRequest } from '@tanstack/react-start/server';
|
|
|
3
3
|
import { getRequestLanguage, parseCookies } from 'payload';
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the client `I18n` for the current TanStack Start request without a
|
|
6
|
-
* full `
|
|
6
|
+
* full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
|
|
7
7
|
* `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
|
|
8
8
|
* needs `config` + `i18n` to translate admin-page titles.
|
|
9
9
|
*/ export async function getRequestI18n({ config }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServerAdapter } from 'payload';
|
|
2
|
+
import type { InitAdminContextArgs } from 'payload/internal';
|
|
3
|
+
import './devConfigReload.server.js';
|
|
4
|
+
type TanStackInitAdminContextArgs = {
|
|
5
|
+
serverAdapter?: ServerAdapter;
|
|
6
|
+
} & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>;
|
|
7
|
+
export declare const initAdminContext: ({ serverAdapter, ...args }: TanStackInitAdminContextArgs) => Promise<import("payload").AdminContext>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=initAdminContext.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initAdminContext.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initAdminContext.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAO5D,OAAO,6BAA6B,CAAA;AAGpC,KAAK,4BAA4B,GAAG;IAClC,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC,CAAA;AAExE,eAAO,MAAM,gBAAgB,+BAG1B,4BAA4B,4CAK3B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getRequest } from '@tanstack/react-start/server';
|
|
2
|
+
import { initAdminContext as initPayloadAdminContext } from 'payload/internal';
|
|
3
|
+
// Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.
|
|
4
|
+
// Side-effect only, and a no-op outside of dev serve.
|
|
5
|
+
import './devConfigReload.server.js';
|
|
6
|
+
import { tanstackServerAdapter } from '../adapters/server.js';
|
|
7
|
+
export const initAdminContext = ({ serverAdapter = tanstackServerAdapter, ...args })=>initPayloadAdminContext({
|
|
8
|
+
...args,
|
|
9
|
+
requestURL: getRequest().url,
|
|
10
|
+
serverAdapter
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=initAdminContext.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/initAdminContext.server.ts"],"sourcesContent":["import type { ServerAdapter } from 'payload'\nimport type { InitAdminContextArgs } from 'payload/internal'\n\nimport { getRequest } from '@tanstack/react-start/server'\nimport { initAdminContext as initPayloadAdminContext } from 'payload/internal'\n\n// Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.\n// Side-effect only, and a no-op outside of dev serve.\nimport './devConfigReload.server.js'\nimport { tanstackServerAdapter } from '../adapters/server.js'\n\ntype TanStackInitAdminContextArgs = {\n serverAdapter?: ServerAdapter\n} & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>\n\nexport const initAdminContext = ({\n serverAdapter = tanstackServerAdapter,\n ...args\n}: TanStackInitAdminContextArgs) =>\n initPayloadAdminContext({\n ...args,\n requestURL: getRequest().url,\n serverAdapter,\n })\n"],"names":["getRequest","initAdminContext","initPayloadAdminContext","tanstackServerAdapter","serverAdapter","args","requestURL","url"],"mappings":"AAGA,SAASA,UAAU,QAAQ,+BAA8B;AACzD,SAASC,oBAAoBC,uBAAuB,QAAQ,mBAAkB;AAE9E,4FAA4F;AAC5F,sDAAsD;AACtD,OAAO,8BAA6B;AACpC,SAASC,qBAAqB,QAAQ,wBAAuB;AAM7D,OAAO,MAAMF,mBAAmB,CAAC,EAC/BG,gBAAgBD,qBAAqB,EACrC,GAAGE,MAC0B,GAC7BH,wBAAwB;QACtB,GAAGG,IAAI;QACPC,YAAYN,aAAaO,GAAG;QAC5BH;IACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;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 { setOwnProperty } from 'payload/shared';
|
|
2
3
|
import { createElement, Fragment } from 'react';
|
|
3
4
|
/**
|
|
4
5
|
* Recursively walk a server-function return value and prepare it for transit
|
|
@@ -112,7 +113,11 @@ async function walk(value, cache, ancestors) {
|
|
|
112
113
|
for (const key of Object.keys(obj)){
|
|
113
114
|
const v = await walk(obj[key], cache, ancestors);
|
|
114
115
|
if (v !== undefined) {
|
|
115
|
-
|
|
116
|
+
setOwnProperty({
|
|
117
|
+
key,
|
|
118
|
+
target: result,
|
|
119
|
+
value: v
|
|
120
|
+
});
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
ancestors.delete(obj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { createElement, Fragment } from 'react'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<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 await renderServerComponent(value as React.ReactElement)\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 return obj\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 = await walk(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 = await walk(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 // An array consisting entirely of React elements (e.g. a field's\n // `beforeInput` / `afterInput` component list, produced by\n // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.\n // Converting each element individually below turns every item into its own\n // `renderServerComponent` handle, which drops the element's React `key` —\n // the client then renders `{[handle, handle]}` as unkeyed array children\n // and React warns \"Each child in a list should have a unique key prop\".\n // Payload always renders these component arrays wholesale (`{BeforeInput}`),\n // so collapsing them into one Fragment-rendered handle is render-equivalent\n // and keeps the per-element keys intact inside the single Flight payload.\n const items = obj.filter((item) => item !== null && item !== undefined)\n const isReactElementArray =\n items.length > 0 &&\n items.every(\n (item)
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { setOwnProperty } from 'payload/shared'\nimport { createElement, Fragment } from 'react'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<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 await renderServerComponent(value as React.ReactElement)\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 return obj\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 = await walk(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 = await walk(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 // An array consisting entirely of React elements (e.g. a field's\n // `beforeInput` / `afterInput` component list, produced by\n // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.\n // Converting each element individually below turns every item into its own\n // `renderServerComponent` handle, which drops the element's React `key` —\n // the client then renders `{[handle, handle]}` as unkeyed array children\n // and React warns \"Each child in a list should have a unique key prop\".\n // Payload always renders these component arrays wholesale (`{BeforeInput}`),\n // so collapsing them into one Fragment-rendered handle is render-equivalent\n // and keeps the per-element keys intact inside the single Flight payload.\n const items = obj.filter((item) => item !== null && item !== undefined)\n const isReactElementArray =\n items.length > 0 &&\n items.every(\n (item) =>\n typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(\n createElement(Fragment, null, ...(obj as React.ReactNode[])),\n )\n }\n\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(await walk(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 = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","setOwnProperty","createElement","Fragment","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","items","filter","item","isReactElementArray","length","every","arr","push","ArrayBuffer","isView","result","key","Object","keys","target"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,QAAO;AAE/C;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMd,sBAAsBK;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAD,UAAUS,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBX,MAAMa,GAAG,CAAC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E,YAAYC,MAAM,CAAC1B,MAAM;QAC3BH,UAAUgB,MAAM,CAACb;QACjB,OAAOA;IACT;IAEA,MAAM2B,SAAkC,CAAC;IACzC/B,MAAMa,GAAG,CAACT,KAAK2B;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC9B,KAAM;QAClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAAC4B,IAAI,EAAEhC,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnBV,eAAe;gBAAEwC;gBAAKG,QAAQJ;gBAAQnC,OAAOmB;YAAE;QACjD;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
|
|
@@ -1 +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;
|
|
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;AAI7E;;;;;;;;;;;;;;;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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setOwnProperty } from 'payload/shared';
|
|
1
2
|
/**
|
|
2
3
|
* Builds the client-side `ServerFunctionClient` wired into
|
|
3
4
|
* `RootProvider.serverFunction`, given the app's `createServerFn`-based
|
|
@@ -99,7 +100,11 @@
|
|
|
99
100
|
for (const key of Object.keys(obj)){
|
|
100
101
|
const v = stripUnserializable(obj[key], cache, ancestors);
|
|
101
102
|
if (v !== undefined) {
|
|
102
|
-
|
|
103
|
+
setOwnProperty({
|
|
104
|
+
key,
|
|
105
|
+
target: result,
|
|
106
|
+
value: v
|
|
107
|
+
});
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
ancestors.delete(obj);
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\nimport { setOwnProperty } from 'payload/shared'\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 setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["setOwnProperty","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","target"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAE/C;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAWC,oBAAoBF;QACrC,OAAO,MAAMD,YAAY;YAAEI,MAAMF;QAAS;IAC5C;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASC,oBACdE,KAAc,EACdC,QAAkC,IAAIC,SAA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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;YACnBZ,eAAe;gBAAEsC;gBAAKG,QAAQJ;gBAAQ9B,OAAOmB;YAAE;QACjD;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSerializable.d.ts","sourceRoot":"","sources":["../../src/utilities/toSerializable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"toSerializable.d.ts","sourceRoot":"","sources":["../../src/utilities/toSerializable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAIlF,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;AA+HpG;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;AAC9C,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GACtC,kBAAkB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setOwnProperty } from 'payload/shared';
|
|
1
2
|
/**
|
|
2
3
|
* Recursively strip values that seroval cannot serialize (React elements,
|
|
3
4
|
* functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.
|
|
@@ -98,7 +99,11 @@
|
|
|
98
99
|
for (const key of Object.keys(obj)){
|
|
99
100
|
const v = stripUnserializable(obj[key], cache, ancestors);
|
|
100
101
|
if (v !== undefined) {
|
|
101
|
-
|
|
102
|
+
setOwnProperty({
|
|
103
|
+
key,
|
|
104
|
+
target: result,
|
|
105
|
+
value: v
|
|
106
|
+
});
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
ancestors.delete(obj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/toSerializable.ts"],"sourcesContent":["import type { Serializable, SerializableExtensions } from '@tanstack/react-router'\n\n/** A record sanitized for TanStack's server-function transport. */\nexport type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable']\n\n/**\n * Recursively strip values that seroval cannot serialize (React elements,\n * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.\n *\n * TanStack Start uses seroval to transfer server function return values to\n * the client. Payload's `getClientConfig` / `getLayoutData` may include\n * callback functions or RegExp instances that seroval chokes on. Running\n * the data through this function before returning from a `createServerFn`\n * handler keeps the transfer safe.\n *\n * For server functions whose payloads contain React elements (e.g. the\n * shared `form-state` / `render-list` / `render-document` handlers), use\n * `serializeForRsc` instead — it converts elements into RSC handles rather\n * than stripping them.\n *\n * Uses a WeakMap cache so that shared object references (e.g. the same array\n * referenced by both `doc.hasMany` and `formState.hasMany.value`) are\n * returned correctly instead of being dropped as \"already seen\".\n *\n * A separate `ancestors` WeakSet tracks objects currently being recursed into.\n * If an object is encountered while it is still on the recursion stack, the\n * reference is circular and is replaced with `undefined` to keep the output\n * JSON-safe. Once recursion completes the object is removed from `ancestors`,\n * so sibling/cousin references to the same (fully-processed) object still\n * resolve to the cached clone.\n */\nfunction stripUnserializable(\n value: unknown,\n cache = new WeakMap<object, unknown>(),\n ancestors = new WeakSet<object>(),\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 return obj\n }\n\n // RegExp: seroval's SSR bootstrap emits regex literals with broken escape\n // sequences (e.g. `/!\\\\[.../` instead of `/!\\[.../`), crashing the client\n // script that populates `window.$_TSR` and preventing hydration. Rich-text\n // feature transformer regexes aren't needed on the client (they drive\n // server-side markdown import/export), so strip them here.\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
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/toSerializable.ts"],"sourcesContent":["import type { Serializable, SerializableExtensions } from '@tanstack/react-router'\n\nimport { setOwnProperty } from 'payload/shared'\n\n/** A record sanitized for TanStack's server-function transport. */\nexport type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable']\n\n/**\n * Recursively strip values that seroval cannot serialize (React elements,\n * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.\n *\n * TanStack Start uses seroval to transfer server function return values to\n * the client. Payload's `getClientConfig` / `getLayoutData` may include\n * callback functions or RegExp instances that seroval chokes on. Running\n * the data through this function before returning from a `createServerFn`\n * handler keeps the transfer safe.\n *\n * For server functions whose payloads contain React elements (e.g. the\n * shared `form-state` / `render-list` / `render-document` handlers), use\n * `serializeForRsc` instead — it converts elements into RSC handles rather\n * than stripping them.\n *\n * Uses a WeakMap cache so that shared object references (e.g. the same array\n * referenced by both `doc.hasMany` and `formState.hasMany.value`) are\n * returned correctly instead of being dropped as \"already seen\".\n *\n * A separate `ancestors` WeakSet tracks objects currently being recursed into.\n * If an object is encountered while it is still on the recursion stack, the\n * reference is circular and is replaced with `undefined` to keep the output\n * JSON-safe. Once recursion completes the object is removed from `ancestors`,\n * so sibling/cousin references to the same (fully-processed) object still\n * resolve to the cached clone.\n */\nfunction stripUnserializable(\n value: unknown,\n cache = new WeakMap<object, unknown>(),\n ancestors = new WeakSet<object>(),\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 return obj\n }\n\n // RegExp: seroval's SSR bootstrap emits regex literals with broken escape\n // sequences (e.g. `/!\\\\[.../` instead of `/!\\[.../`), crashing the client\n // script that populates `window.$_TSR` and preventing hydration. Rich-text\n // feature transformer regexes aren't needed on the client (they drive\n // server-side markdown import/export), so strip them here.\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 setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n\n/**\n * Removes values unsupported by TanStack's serializer. Trusted serializable\n * additions are merged afterward so opaque handles such as RSC payloads are\n * preserved while the source record is sanitized.\n */\nexport function toSerializable<T>(value: T): T\nexport function toSerializable(\n value: Record<string, unknown>,\n additions: Record<string, Serializable>,\n): SerializableRecord\nexport function toSerializable(value: unknown, additions?: Record<string, Serializable>): unknown {\n const serialized = stripUnserializable(value)\n\n if (additions) {\n if (typeof serialized !== 'object' || serialized === null || Array.isArray(serialized)) {\n throw new TypeError('Serializable additions require an object source')\n }\n\n const result = { ...serialized, ...additions } satisfies Record<string, unknown>\n\n return result as SerializableRecord\n }\n\n return serialized\n}\n"],"names":["setOwnProperty","stripUnserializable","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys","target","toSerializable","additions","serialized","TypeError"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAK/C;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,SAASC,oBACPC,KAAc,EACdC,QAAQ,IAAIC,SAA0B,EACtCC,YAAY,IAAIC,SAAiB;IAEjC,IAAIJ,UAAU,QAAQA,UAAUK,WAAW;QACzC,OAAOL;IACT;IAEA,MAAMM,IAAI,OAAON;IACjB,IAAIM,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAON;IACT;IAEA,MAAMO,MAAMP;IAEZ,IAAI,OAAOO,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAOH;IACT;IAEA,IAAIF,UAAUM,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIJ,MAAMQ,GAAG,CAACF,MAAM;QAClB,OAAON,MAAMS,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,sEAAsE;IACtE,2DAA2D;IAC3D,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAF,UAAUU,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBb,MAAMe,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAKpB,oBAAoBmB,GAAGjB,OAAOE;YACzC,IAAIgB,OAAOd,W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;QACtB;QAEA,MAAMR,SAAS;YAAE,GAAGO,UAAU;YAAE,GAAGD,SAAS;QAAC;QAE7C,OAAON;IACT;IAEA,OAAOO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Packages externalized during dev serve (`ssr.external`). Node's loader resolves\n * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break\n * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment\n * throws when transformed rather than required).\n *\n * Safe here whoever declared the entry: Node resolves from the importing package,\n * so pnpm's isolated layout never applies. The build is stricter — see\n * {@link buildBundledPackages}.\n */\nexport const ssrExternalPackages: string[] = [\n '
|
|
1
|
+
{"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Packages externalized during dev serve (`ssr.external`). Node's loader resolves\n * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break\n * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment\n * throws when transformed rather than required).\n *\n * Safe here whoever declared the entry: Node resolves from the importing package,\n * so pnpm's isolated layout never applies. The build is stricter — see\n * {@link buildBundledPackages}.\n */\nexport const ssrExternalPackages: string[] = [\n 'zod',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\n/**\n * Entries of {@link ssrExternalPackages} that must bundle in the production build.\n *\n * Externalizing only works for specifiers resolvable from the project root. These\n * are leaf deps of Payload packages, so under pnpm they live in `.pnpm/…` and a bare\n * specifier in a root-resolved chunk is invisible — `ERR_MODULE_NOT_FOUND` at\n * runtime, or a build-time resolve failure under Nitro's re-bundle pass.\n *\n * `pluralize` also needs forcing back via `noExternal` (see `withPayload`); the\n * storage leaves don't, since their adapters are already `noExternal`.\n */\nexport const buildBundledPackages: string[] = [\n 'pluralize',\n // Leaf deps of the `@payloadcms/storage-*` adapters.\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@azure/storage-blob',\n '@google-cloud/storage',\n]\n\n/**\n * External packages for the production `vite build` only (not dev serve).\n *\n * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each\n * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from\n * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under\n * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from\n * `dist/`, since pnpm does not hoist it; see {@link buildBundledPackages}.\n *\n * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to\n * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's\n * transform can resolve — an externalized copy would hit Node's raw resolver and\n * fail on the `.js`→`.ts` mismatch.\n */\nexport const buildExternalPackages: string[] = [\n 'payload',\n 'payload/node',\n '@payloadcms/drizzle',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-d1-sqlite',\n ...ssrExternalPackages.filter((pkg) => !buildBundledPackages.includes(pkg)),\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","buildBundledPackages","buildExternalPackages","filter","pkg","includes","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;;;;;;;CASC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,uBAAiC;IAC5C;IACA,qDAAqD;IACrD;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,wBAAkC;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;OACGF,oBAAoBG,MAAM,CAAC,CAACC,MAAQ,CAACH,qBAAqBI,QAAQ,CAACD;CACvE,CAAA;AAED,OAAO,MAAME,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA0D/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA+E/C,CAAA"}
|
|
@@ -27,10 +27,43 @@
|
|
|
27
27
|
'@azure/storage-blob',
|
|
28
28
|
// Preserve RSC client boundaries on storage admin upload handlers.
|
|
29
29
|
'@payloadcms/storage-azure',
|
|
30
|
+
'@payloadcms/storage-r2',
|
|
30
31
|
'@payloadcms/storage-vercel-blob',
|
|
31
32
|
'@aws-sdk/client-s3',
|
|
32
33
|
'@aws-sdk/s3-request-presigner',
|
|
33
|
-
'@google-cloud/storage'
|
|
34
|
+
'@google-cloud/storage',
|
|
35
|
+
// Packages whose admin component barrel re-exports `'use client'` modules
|
|
36
|
+
// without carrying the directive itself. Pre-bundling one puts those modules
|
|
37
|
+
// in the optimized dep chunk *and* in the `rsc` environment as client
|
|
38
|
+
// references, which `@vitejs/plugin-rsc` warns about ("client component
|
|
39
|
+
// dependency is inconsistently optimized") once per component. Barrels that
|
|
40
|
+
// start with `'use client'` (e.g. `richtext-lexical`, `plugin-stripe`) don't
|
|
41
|
+
// warn and stay pre-bundled. Only shows up in published installs; workspace
|
|
42
|
+
// source is never pre-bundled.
|
|
43
|
+
'@payloadcms/plugin-cloud-storage',
|
|
44
|
+
'@payloadcms/plugin-ecommerce',
|
|
45
|
+
'@payloadcms/plugin-form-builder',
|
|
46
|
+
'@payloadcms/plugin-import-export',
|
|
47
|
+
'@payloadcms/plugin-multi-tenant',
|
|
48
|
+
'@payloadcms/plugin-search',
|
|
49
|
+
'@payloadcms/plugin-sentry',
|
|
50
|
+
'@payloadcms/plugin-seo',
|
|
51
|
+
// Database adapters and their drivers. The client scan reaches them through the
|
|
52
|
+
// Payload config (it follows server functions' `import('@payload-config')`
|
|
53
|
+
// without TanStack's server-fn stripping), so Vite would pre-bundle the whole
|
|
54
|
+
// driver for a browser that never loads it. Mongoose 9 has no browser build, so
|
|
55
|
+
// that bundles `mongodb`, whose optional `@aws-sdk/credential-providers` peer —
|
|
56
|
+
// when linked, as in the monorepo via `@payloadcms/payload-cloud` — fails the
|
|
57
|
+
// same `MISSING_EXPORT` way. Published installs reach the adapter packages;
|
|
58
|
+
// the monorepo, which resolves them to source, reaches the drivers.
|
|
59
|
+
'@payloadcms/db-d1-sqlite',
|
|
60
|
+
'@payloadcms/db-mongodb',
|
|
61
|
+
'@payloadcms/db-postgres',
|
|
62
|
+
'@payloadcms/db-sqlite',
|
|
63
|
+
'@payloadcms/db-vercel-postgres',
|
|
64
|
+
'@payloadcms/drizzle',
|
|
65
|
+
'mongodb',
|
|
66
|
+
'mongoose'
|
|
34
67
|
];
|
|
35
68
|
/**
|
|
36
69
|
* Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
|
|
@@ -94,16 +127,16 @@
|
|
|
94
127
|
'@payloadcms/ui > react-select > prop-types > react-is',
|
|
95
128
|
'@payloadcms/ui > date-fns/locale/en-US',
|
|
96
129
|
// Further late discoveries observed re-optimizing mid-run in CI cold starts
|
|
97
|
-
// (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers /
|
|
130
|
+
// (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / zod /
|
|
98
131
|
// dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
|
|
99
132
|
// render; form-state diffing reaches `dequal/lite` (a distinct entry point
|
|
100
133
|
// from the already-listed `dequal`); client-side field validation reaches
|
|
101
|
-
// `
|
|
134
|
+
// `zod` *through `payload`* — it is `ssrExternal` server-side but still
|
|
102
135
|
// bundled into the client, and must be pathed via `payload` so the optimizer
|
|
103
136
|
// pre-bundles the exact copy the runtime loads.
|
|
104
137
|
'@payloadcms/ui > @dnd-kit/modifiers',
|
|
105
138
|
'@payloadcms/ui > dequal/lite',
|
|
106
|
-
'payload >
|
|
139
|
+
'payload > zod',
|
|
107
140
|
// The storage client-upload suites (esp. vercel-blob) crawl part of the
|
|
108
141
|
// `payload` server runtime into the client bundle and discover these late,
|
|
109
142
|
// triggering several "optimized dependencies changed. reloading" waves that
|