@payloadcms/tanstack-start 4.0.0-beta.1 → 4.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/adapters/handleServerFunctions.d.ts +2 -1
  2. package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
  3. package/dist/adapters/handleServerFunctions.js +12 -4
  4. package/dist/adapters/handleServerFunctions.js.map +1 -1
  5. package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
  6. package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
  7. package/dist/adapters/layout/RootProviders/index.js +21 -0
  8. package/dist/adapters/layout/RootProviders/index.js.map +1 -0
  9. package/dist/adapters/layout/index.d.ts +7 -4
  10. package/dist/adapters/layout/index.d.ts.map +1 -1
  11. package/dist/adapters/layout/index.js +3 -1
  12. package/dist/adapters/layout/index.js.map +1 -1
  13. package/dist/adapters/layout/lazy.d.ts +1 -5
  14. package/dist/adapters/layout/lazy.d.ts.map +1 -1
  15. package/dist/adapters/layout/lazy.js +9 -15
  16. package/dist/adapters/layout/lazy.js.map +1 -1
  17. package/dist/adapters/layout/outlet.d.ts +4 -0
  18. package/dist/adapters/layout/outlet.d.ts.map +1 -0
  19. package/dist/adapters/layout/outlet.js +9 -0
  20. package/dist/adapters/layout/outlet.js.map +1 -0
  21. package/dist/adapters/layout/server.d.ts +7 -13
  22. package/dist/adapters/layout/server.d.ts.map +1 -1
  23. package/dist/adapters/layout/server.js +18 -16
  24. package/dist/adapters/layout/server.js.map +1 -1
  25. package/dist/adapters/server.d.ts.map +1 -1
  26. package/dist/adapters/server.js +2 -29
  27. package/dist/adapters/server.js.map +1 -1
  28. package/dist/adapters/views/index.d.ts +5 -2
  29. package/dist/adapters/views/index.d.ts.map +1 -1
  30. package/dist/adapters/views/index.js +10 -4
  31. package/dist/adapters/views/index.js.map +1 -1
  32. package/dist/adapters/views/lazy.js +2 -2
  33. package/dist/adapters/views/lazy.js.map +1 -1
  34. package/dist/adapters/views/server.d.ts +5 -2
  35. package/dist/adapters/views/server.d.ts.map +1 -1
  36. package/dist/adapters/views/server.js +12 -3
  37. package/dist/adapters/views/server.js.map +1 -1
  38. package/dist/exports/client/layout.d.ts +2 -0
  39. package/dist/exports/client/layout.d.ts.map +1 -0
  40. package/dist/exports/client/layout.js +4 -0
  41. package/dist/exports/client/layout.js.map +1 -0
  42. package/dist/exports/client.d.ts +1 -1
  43. package/dist/exports/client.d.ts.map +1 -1
  44. package/dist/exports/client.js +1 -1
  45. package/dist/exports/client.js.map +1 -1
  46. package/dist/exports/server.d.ts +0 -2
  47. package/dist/exports/server.d.ts.map +1 -1
  48. package/dist/exports/server.js +0 -2
  49. package/dist/exports/server.js.map +1 -1
  50. package/dist/routes/rest/handler.server.d.ts +2 -3
  51. package/dist/routes/rest/handler.server.d.ts.map +1 -1
  52. package/dist/routes/rest/handler.server.js +3 -7
  53. package/dist/routes/rest/handler.server.js.map +1 -1
  54. package/dist/utilities/serverFunctionClient.d.ts +2 -23
  55. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  56. package/dist/utilities/serverFunctionClient.js +12 -106
  57. package/dist/utilities/serverFunctionClient.js.map +1 -1
  58. package/package.json +22 -22
  59. package/dist/utilities/serializeForRsc.d.ts +0 -26
  60. package/dist/utilities/serializeForRsc.d.ts.map +0 -1
  61. package/dist/utilities/serializeForRsc.js +0 -127
  62. package/dist/utilities/serializeForRsc.js.map +0 -1
  63. package/dist/utilities/toSerializable.d.ts +0 -11
  64. package/dist/utilities/toSerializable.d.ts.map +0 -1
  65. package/dist/utilities/toSerializable.js +0 -127
  66. package/dist/utilities/toSerializable.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/views/index.tsx"],"sourcesContent":["'use client'\n\nimport { lazyRouteComponent, notFound, redirect } from '@tanstack/react-router'\n\nimport { getAdminMeta } from '../metadata.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\n// The admin UI loads with the admin routes only, so front-end routes never download it. The\n// router preloads lazy route components before rendering, so admin pages don't flash.\nconst AdminPage = lazyRouteComponent(() => import('./lazy.js'), 'AdminPage')\nconst AdminNotFound = lazyRouteComponent(() => import('./lazy.js'), 'AdminNotFound')\n\nconst adminRouteOptions = ({\n forwardNotFoundPayload,\n load,\n resolveSplat,\n}: {\n /**\n * Ships the server-rendered NotFound tree through `notFound()`'s `data` so a\n * `notFoundComponent` can render it with the full admin chrome. Routes without\n * one throw bare.\n */\n forwardNotFoundPayload: boolean\n load: AdminLoad\n /** The route's splat, i.e. the path after `/admin/`. */\n resolveSplat: (params: any) => string\n}) => ({\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // Both admin routes must use the same boundary type so index ↔ splat\n // navigation preserves the existing admin subtree.\n notFoundComponent: AdminNotFound,\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, resolveSplat(params), location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound(\n forwardNotFoundPayload\n ? { data: { routeKey: data.routeKey, rscPayload: data.rscPayload } }\n : undefined,\n )\n }\n return data\n },\n staleReloadMode: 'blocking' as const,\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n})\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: true,\n load,\n resolveSplat: (params) => params._splat ?? '',\n })\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Not-found\n * results omit the RSC payload and fall back to `NotFoundClient`.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: false,\n load,\n resolveSplat: () => '',\n })\n}\n"],"names":["lazyRouteComponent","notFound","redirect","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","AdminNotFound","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","notFoundComponent","loader","handler","location","params","_notFound","routeKey","rscPayload","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","payloadAdminIndexRoute"],"mappings":"AAAA;AAEA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,yBAAwB;AAE/E,SAASC,YAAY,QAAQ,iBAAgB;AAW7C,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAOC,MAAiBC,OAAeN;IACvD,MAAMO,OAAO,MAAMF,KA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AAwB;QACxBV;QACAW,cAAc,CAACS,SAAWA,OAAOjB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS6B,uBAAuB,EAAEhC,IAAI,EAAuB;IAClE,OAAOS,kBAAkB;QACvBC,wBAAwB;QACxBV;QACAW,cAAc,IAAM;IACtB;AACF"}
1
+ {"version":3,"sources":["../../../src/adapters/views/index.tsx"],"sourcesContent":["'use client'\n\nimport { lazyRouteComponent, notFound, redirect } from '@tanstack/react-router'\n\nimport { getAdminMeta } from '../metadata.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n signal?: AbortSignal\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async ({\n load,\n searchStr,\n signal,\n splat,\n}: {\n load: AdminLoad\n searchStr: string\n signal: AbortSignal\n splat: string\n}) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) }, signal })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\n// The admin UI loads with the admin routes only, so front-end routes never download it. The\n// router preloads lazy route components before rendering, so admin pages don't flash.\nconst AdminPage = lazyRouteComponent(() => import('./lazy.js'), 'AdminPage')\nconst AdminNotFound = lazyRouteComponent(() => import('./lazy.js'), 'AdminNotFound')\n\nconst adminRouteOptions = ({\n forwardNotFoundPayload,\n load,\n resolveSplat,\n}: {\n /**\n * Ships the server-rendered NotFound tree through `notFound()`'s `data` so a\n * `notFoundComponent` can render it with the full admin chrome. Routes without\n * one throw bare.\n */\n forwardNotFoundPayload: boolean\n load: AdminLoad\n /** The route's splat, i.e. the path after `/admin/`. */\n resolveSplat: (params: any) => string\n}) => ({\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // Both admin routes must use the same boundary type so index ↔ splat\n // navigation preserves the existing admin subtree.\n notFoundComponent: AdminNotFound,\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({\n abortController,\n location,\n params,\n }: {\n abortController: AbortController\n location: any\n params: any\n }) => {\n const data = await runLoader({\n load,\n searchStr: location.searchStr,\n signal: abortController.signal,\n splat: resolveSplat(params),\n })\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound(\n forwardNotFoundPayload\n ? { data: { routeKey: data.routeKey, rscPayload: data.rscPayload } }\n : undefined,\n )\n }\n return data\n },\n staleReloadMode: 'blocking' as const,\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n})\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: true,\n load,\n resolveSplat: (params) => params._splat ?? '',\n })\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Not-found\n * results omit the RSC payload and fall back to `NotFoundClient`.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: false,\n load,\n resolveSplat: () => '',\n })\n}\n"],"names":["lazyRouteComponent","notFound","redirect","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","signal","splat","data","_splat","search","_redirect","to","AdminPage","AdminNotFound","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","notFoundComponent","loader","handler","abortController","location","params","_notFound","routeKey","rscPayload","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","payloadAdminIndexRoute"],"mappings":"AAAA;AAEA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,yBAAwB;AAE/E,SAASC,YAAY,QAAQ,iBAAgB;AAY7C,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAO,EACvBC,IAAI,EACJL,SAAS,EACTM,MAAM,EACNC,KAAK,EAMN;IACC,MAAMC,OAAO,MAAMH,KAAK;QAAEG,MAAM;YAAEC,QAAQF;YAAOG,QAAQX,eAAeC;QAAW;QAAGM;IAAO;IAC7F,IAAIE,MAAMG,WAAW;QACnB,qHAAqH;QACrH,MAAMd,SAAS;YAAEe,IAAIJ,KAAKG,SAAS;QAAC;IACtC;IACA,OAAOH;AACT;AAEA,4FAA4F;AAC5F,sFAAsF;AACtF,MAAMK,YAAYlB,mBAAmB,IAAM,MAAM,CAAC,cAAc;AAChE,MAAMmB,gBAAgBnB,mBAAmB,IAAM,MAAM,CAAC,cAAc;AAEpE,MAAMoB,oBAAoB,CAAC,EACzBC,sBAAsB,EACtBX,IAAI,EACJY,YAAY,EAWb,GAAM,CAAA;QACLC,WAAWL;QACXM,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKtB,aAAasB,YAAYC;QACzE,qEAAqE;QACrE,mDAAmD;QACnDC,mBAAmBR;QACnB,0EAA0E;QAC1E,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,4DAA4D;QAC5DS,QAAQ;YACNC,SAAS,OAAO,EACdC,eAAe,EACfC,QAAQ,EACRC,MAAM,EAKP;gBACC,MAAMnB,OAAO,MAAMJ,UAAU;oBAC3BC;oBACAL,WAAW0B,SAAS1B,SAAS;oBAC7BM,QAAQmB,gBAAgBnB,MAAM;oBAC9BC,OAAOU,aAAaU;gBACtB;gBACA,IAAInB,MAAMoB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMhC,SACJoB,yBACI;wBAAER,MAAM;4BAAEqB,UAAUrB,KAAKqB,QAAQ;4BAAEC,YAAYtB,KAAKsB,UAAU;wBAAC;oBAAE,IACjEC;gBAER;gBACA,OAAOvB;YACT;YACAwB,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAEvB,MAAM,EAAuC,GAAM,CAAA;gBAChEwB,WAAWC,KAAKC,SAAS,CAAC1B;YAC5B,CAAA;QACA2B,gBAAgB,CAAC3B,SAAoCA;IACvD,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAAS4B,uBAAuB,EAAEjC,IAAI,EAAuB;IAClE,OAAOU,kBAAkB;QACvBC,wBAAwB;QACxBX;QACAY,cAAc,CAACU,SAAWA,OAAOlB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS8B,uBAAuB,EAAElC,IAAI,EAAuB;IAClE,OAAOU,kBAAkB;QACvBC,wBAAwB;QACxBX;QACAY,cAAc,IAAM;IACtB;AACF"}
@@ -26,7 +26,7 @@ export function AdminPage() {
26
26
  isRscPayloadDeferred
27
27
  ]);
28
28
  return /*#__PURE__*/ _jsx(Fragment, {
29
- children: rscPayload
29
+ children: rscPayload?.page
30
30
  });
31
31
  }
32
32
  export function AdminNotFound({ data }) {
@@ -36,7 +36,7 @@ export function AdminNotFound({ data }) {
36
36
  return /*#__PURE__*/ _jsx(NotFoundClient, {});
37
37
  }
38
38
  return /*#__PURE__*/ _jsx(Fragment, {
39
- children: rscPayload
39
+ children: rscPayload.page
40
40
  }, routeKey);
41
41
  }
42
42
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/views/lazy.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode, useDeferredValue, useEffect } from 'react'\n\nexport function AdminPage() {\n // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.\n // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.\n const data = useLoaderData({ strict: false })\n\n // Route state comes from an external store, so a new RSC payload that suspends\n // on code-split client references can reveal the router's null fallback.\n // Keep the current payload painted until the next one is renderable.\n const rscPayload = useDeferredValue(data?.rscPayload)\n const { holdRouteTransition } = useRouteTransition()\n const isRscPayloadDeferred = rscPayload !== data?.rscPayload\n\n useEffect(() => {\n if (!isRscPayloadDeferred) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRscPayloadDeferred])\n\n return <Fragment>{rscPayload}</Fragment>\n}\n\ntype AdminNotFoundData = { routeKey?: string; rscPayload?: ReactNode }\n\nexport function AdminNotFound({ data }: NotFoundRouteProps) {\n // TanStack exposes not-found data as unknown; this route only receives the shape thrown below.\n const { routeKey, rscPayload } = (data ?? {}) as AdminNotFoundData\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={routeKey}>{rscPayload}</Fragment>\n}\n"],"names":["NotFoundClient","useRouteTransition","useLoaderData","Fragment","useDeferredValue","useEffect","AdminPage","data","strict","rscPayload","holdRouteTransition","isRscPayloadDeferred","releaseRouteTransition","AdminNotFound","routeKey"],"mappings":"AAAA;;AAIA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,iBAAgB;AACnE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,QAAQ,EAAkBC,gBAAgB,EAAEC,SAAS,QAAQ,QAAO;AAE7E,OAAO,SAASC;IACd,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAMC,OAAOL,cAAc;QAAEM,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAaL,iBAAiBG,MAAME;IAC1C,MAAM,EAAEC,mBAAmB,EAAE,GAAGT;IAChC,MAAMU,uBAAuBF,eAAeF,MAAME;IAElDJ,UAAU;QACR,IAAI,CAACM,sBAAsB;YACzB;QACF;QAEA,MAAMC,yBAAyBF;QAE/B,OAAO,IAAME;IACf,GAAG;QAACF;QAAqBC;KAAqB;IAE9C,qBAAO,KAACR;kBAAUM;;AACpB;AAIA,OAAO,SAASI,cAAc,EAAEN,IAAI,EAAsB;IACxD,+FAA+F;IAC/F,MAAM,EAAEO,QAAQ,EAAEL,UAAU,EAAE,GAAIF,QAAQ,CAAC;IAC3C,IAAI,CAACE,YAAY;QACf,qBAAO,KAACT;IACV;IACA,qBAAO,KAACG;kBAAyBM;OAAXK;AACxB"}
1
+ {"version":3,"sources":["../../../src/adapters/views/lazy.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { useLoaderData } from '@tanstack/react-router'\nimport { Fragment, useDeferredValue, useEffect } from 'react'\n\nexport function AdminPage() {\n // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.\n // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.\n const data = useLoaderData({ strict: false })\n\n // Route state comes from an external store, so a new RSC payload that suspends\n // on code-split client references can reveal the router's null fallback.\n // Keep the current payload painted until the next one is renderable.\n const rscPayload = useDeferredValue(data?.rscPayload)\n const { holdRouteTransition } = useRouteTransition()\n const isRscPayloadDeferred = rscPayload !== data?.rscPayload\n\n useEffect(() => {\n if (!isRscPayloadDeferred) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRscPayloadDeferred])\n\n return <Fragment>{rscPayload?.page}</Fragment>\n}\n\ntype AdminNotFoundData = { routeKey?: string; rscPayload?: { page: React.ReactNode } }\n\nexport function AdminNotFound({ data }: NotFoundRouteProps) {\n // TanStack exposes not-found data as unknown; this route only receives the shape thrown below.\n const { routeKey, rscPayload } = (data ?? {}) as AdminNotFoundData\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={routeKey}>{rscPayload.page}</Fragment>\n}\n"],"names":["NotFoundClient","useRouteTransition","useLoaderData","Fragment","useDeferredValue","useEffect","AdminPage","data","strict","rscPayload","holdRouteTransition","isRscPayloadDeferred","releaseRouteTransition","page","AdminNotFound","routeKey"],"mappings":"AAAA;;AAIA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,iBAAgB;AACnE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,QAAQ,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,QAAO;AAE7D,OAAO,SAASC;IACd,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAMC,OAAOL,cAAc;QAAEM,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAaL,iBAAiBG,MAAME;IAC1C,MAAM,EAAEC,mBAAmB,EAAE,GAAGT;IAChC,MAAMU,uBAAuBF,eAAeF,MAAME;IAElDJ,UAAU;QACR,IAAI,CAACM,sBAAsB;YACzB;QACF;QAEA,MAAMC,yBAAyBF;QAE/B,OAAO,IAAME;IACf,GAAG;QAACF;QAAqBC;KAAqB;IAE9C,qBAAO,KAACR;kBAAUM,YAAYI;;AAChC;AAIA,OAAO,SAASC,cAAc,EAAEP,IAAI,EAAsB;IACxD,+FAA+F;IAC/F,MAAM,EAAEQ,QAAQ,EAAEN,UAAU,EAAE,GAAIF,QAAQ,CAAC;IAC3C,IAAI,CAACE,YAAY;QACf,qBAAO,KAACT;IACV;IACA,qBAAO,KAACG;kBAAyBM,WAAWI,IAAI;OAA1BE;AACxB"}
@@ -1,4 +1,4 @@
1
- import type { RenderableServerComponent } from '@tanstack/react-start/rsc';
1
+ import type { RenderableServerComponentBuilder } from '@tanstack/react-start/rsc';
2
2
  import type { ImportMap, SanitizedConfig } from 'payload';
3
3
  import type { AdminPageMetadata } from '../metadata.js';
4
4
  export type LoadAdminPageArgs = {
@@ -7,7 +7,10 @@ export type LoadAdminPageArgs = {
7
7
  search?: Record<string, string | string[]>;
8
8
  splat?: string;
9
9
  };
10
- type RSCPayload = RenderableServerComponent<React.ReactElement>;
10
+ type RSCPayload = RenderableServerComponentBuilder<{
11
+ page: React.ReactElement;
12
+ routeKey: string;
13
+ }>;
11
14
  export type LoadAdminPageResult = {
12
15
  _notFound: true;
13
16
  routeKey?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/views/server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAKzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAOvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,KAAK,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAAE,GAC/D;IAAE,SAAS,EAAE,MAAM,C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AU,CAAA;CACvB,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyJlD"}
@@ -1,5 +1,6 @@
1
1
  import { getViewportContent } from '@payloadcms/ui/shared';
2
2
  import { renderServerComponent } from '@tanstack/react-start/rsc';
3
+ import { getRequest } from '@tanstack/react-start/server';
3
4
  import { getRequestI18n } from '../../utilities/getRequestI18n.server.js';
4
5
  import { initAdminContext } from '../../utilities/initAdminContext.server.js';
5
6
  import { toAdminPageMetadata } from '../metadata.js';
@@ -81,7 +82,10 @@ import { createPageRenderServerAdapter } from '../server.js';
81
82
  }),
82
83
  searchParams: Promise.resolve(searchParams)
83
84
  });
84
- const rscPayload = await renderServerComponent(notFoundNode);
85
+ const rscPayload = await renderServerComponent({
86
+ page: notFoundNode,
87
+ routeKey: splat ?? ''
88
+ });
85
89
  return {
86
90
  _notFound: true,
87
91
  routeKey: splat ?? '',
@@ -104,7 +108,10 @@ import { createPageRenderServerAdapter } from '../server.js';
104
108
  redirect: pageServerAdapter.redirect,
105
109
  searchParams: Promise.resolve(searchParams)
106
110
  });
107
- const rscPayload = await renderServerComponent(node);
111
+ const rscPayload = await renderServerComponent({
112
+ page: node,
113
+ routeKey: splat ?? ''
114
+ });
108
115
  // The server-function (client-nav RPC) path returns the flight stream unread —
109
116
  // unlike the router/SSR path, which awaits a decode that drives the render to
110
117
  // completion. So streamed side effects (e.g. DocumentView's autosave-create
@@ -114,7 +121,9 @@ import { createPageRenderServerAdapter } from '../server.js';
114
121
  if (!nav.type) {
115
122
  const wrapper = rscPayload[Symbol.for('tanstack.rsc.stream')];
116
123
  if (typeof wrapper?.createReplayStream === 'function') {
117
- const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer();
124
+ const buffer = await new Response(wrapper.createReplayStream().pipeThrough(new TransformStream(), {
125
+ signal: getRequest().signal
126
+ })).arrayBuffer();
118
127
  wrapper.createReplayStream = ()=>new Response(buffer).body;
119
128
  }
120
129
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/views/server.tsx"],"sourcesContent":["import type { RenderableServerComponent } from '@tanstack/react-start/rsc'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from '../metadata.js'\n\nimport { getRequestI18n } from '../../utilities/getRequestI18n.server.js'\nimport { initAdminContext } from '../../utilities/initAdminContext.server.js'\nimport { toAdminPageMetadata } from '../metadata.js'\nimport { createPageRenderServerAdapter } from '../server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\ntype RSCPayload = RenderableServerComponent<React.ReactElement>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RSCPayload }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: RSCPayload\n }\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initAdminContext` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitAdminContext: Parameters<typeof renderRoot>[0]['initAdminContext'] = async (\n args,\n ) => {\n const result = await initAdminContext({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.req.headers.get('user-agent') ?? undefined\n return result\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initAdminContext,\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initAdminContext: boundInitAdminContext,\n key: splat ?? '',\n notFound: pageServerAdapter.notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect: pageServerAdapter.redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequestI18n","initAdminContext","toAdminPageMetadata","createPageRenderServerAdapter","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","filter","Boolean","segments","length","undefined","searchParams","nav","pageServerAdapter","userAgent","boundInitAdminContext","args","result","configPromise","overrides","serverAdapter","req","headers","get","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","key","notFound","redirect","type","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","url","_redirect","i18n","meta","metadata","viewport","err","message","Error","String","startsWith","slice"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,2CAA0C;AACzE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,6BAA6B,QAAQ,eAAc;AA+B5D;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,eAAeC,cAAc,EAClCC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,KAAK,EACa;IAClB,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;IACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC3C,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;IAE9C,MAAMC,gBAAgBJ,QAAQA,MAAMK,KAAK,CAAC,KAAKC,MAAM,CAACC,WAAW,EAAE;IACnE,6EAA6E;IAC7E,uEAAuE;IACvE,uEAAuE;IACvE,8EAA8E;IAC9E,6EAA6E;IAC7E,4CAA4C;IAC5C,MAAMC,WAAWJ,cAAcK,MAAM,GAAG,IAAIL,gBAAgBM;IAC5D,MAAMC,eAAeZ,UAAU,CAAC;IAEhC,8EAA8E;IAC9E,wEAAwE;IACxE,MAAMa,MAAwD,CAAC;IAC/D,MAAMC,oBAAoBlB,8BAA8BiB;IACxD,IAAIE;IAEJ,6EAA6E;IAC7E,0EAA0E;IAC1E,yEAAyE;IACzE,iEAAiE;IACjE,MAAMC,wBAA8E,OAClFC;QAEA,MAAMC,SAAS,MAAMxB,iBAAiB;YACpCyB,eAAeF,KAA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"],"sourcesContent":["import type { RenderableServerComponentBuilder } from '@tanstack/react-start/rsc'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { getRequest } from '@tanstack/react-start/server'\n\nimport type { AdminPageMetadata } from '../metadata.js'\n\nimport { getRequestI18n } from '../../utilities/getRequestI18n.server.js'\nimport { initAdminContext } from '../../utilities/initAdminContext.server.js'\nimport { toAdminPageMetadata } from '../metadata.js'\nimport { createPageRenderServerAdapter } from '../server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\ntype RSCPayload = RenderableServerComponentBuilder<{\n page: React.ReactElement\n routeKey: string\n}>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RSCPayload }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: RSCPayload\n }\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initAdminContext` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitAdminContext: Parameters<typeof renderRoot>[0]['initAdminContext'] = async (\n args,\n ) => {\n const result = await initAdminContext({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.req.headers.get('user-agent') ?? undefined\n return result\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initAdminContext,\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent({\n page: notFoundNode as React.ReactElement,\n routeKey: splat ?? '',\n })\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initAdminContext: boundInitAdminContext,\n key: splat ?? '',\n notFound: pageServerAdapter.notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect: pageServerAdapter.redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent({\n page: node as React.ReactElement,\n routeKey: splat ?? '',\n })\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(\n wrapper.createReplayStream().pipeThrough(new TransformStream(), {\n signal: getRequest().signal,\n }),\n ).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequest","getRequestI18n","initAdminContext","toAdminPageMetadata","createPageRenderServerAdapter","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","filter","Boolean","segments","length","undefined","searchParams","nav","pageServerAdapter","userAgent","boundInitAdminContext","args","result","configPromise","overrides","serverAdapter","req","headers","get","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","page","routeKey","_notFound","node","adminViews","key","notFound","redirect","type","wrapper","Symbol","for","createReplayStream","buffer","Response","pipeThrough","TransformStream","signal","arrayBuffer","body","url","_redirect","i18n","meta","metadata","viewport","err","message","Error","String","startsWith","slice"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,UAAU,QAAQ,+BAA8B;AAIzD,SAASC,cAAc,QAAQ,2CAA0C;AACzE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,6BAA6B,QAAQ,eAAc;AAkC5D;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,eAAeC,cAAc,EAClCC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,KAAK,EACa;IAClB,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;IACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC3C,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;IAE9C,MAAMC,gBAAgBJ,QAAQA,MAAMK,KAAK,CAAC,KAAKC,MAAM,CAACC,WAAW,EAAE;IACnE,6EAA6E;IAC7E,uEAAuE;IACvE,uEAAuE;IACvE,8EAA8E;IAC9E,6EAA6E;IAC7E,4CAA4C;IAC5C,MAAMC,WAAWJ,cAAcK,MAAM,GAAG,IAAIL,gBAAgBM;IAC5D,MAAMC,eAAeZ,UAAU,CAAC;IAEhC,8EAA8E;IAC9E,wEAAwE;IACxE,MAAMa,MAAwD,CAAC;IAC/D,MAAMC,oBAAoBlB,8BAA8BiB;IACxD,IAAIE;IAEJ,6EAA6E;IAC7E,0EAA0E;IAC1E,yEAAyE;IACzE,iEAAiE;IACjE,MAAMC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ACA,IAAIZ,IAAI2B,IAAI,KAAK,cAAcmB,QAAQG,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAET,WAAWxC,IAAIuC,GAAG,IAAIO,QAAQI,KAAK,CAAC,YAAYrD,MAAM;YAAE;QACnE;QACA,MAAMgD;IACR;AACF"}
@@ -0,0 +1,2 @@
1
+ export { PayloadRootProviders } from '../../adapters/layout/RootProviders/index.js';
2
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/exports/client/layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
@@ -0,0 +1,4 @@
1
+ 'use client';
2
+ export { PayloadRootProviders } from '../../adapters/layout/RootProviders/index.js';
3
+
4
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exports/client/layout.ts"],"sourcesContent":["'use client'\n\nexport { PayloadRootProviders } from '../../adapters/layout/RootProviders/index.js'\n"],"names":["PayloadRootProviders"],"mappings":"AAAA;AAEA,SAASA,oBAAoB,QAAQ,+CAA8C"}
@@ -1,4 +1,4 @@
1
1
  export { type LayoutLoad, PayloadAdminShell, type PayloadAdminShellProps, payloadLayoutRoute, withPayloadRoot, type WithPayloadRootOptions, } from '../adapters/layout/index.js';
2
2
  export { type AdminLoad, payloadAdminIndexRoute, payloadAdminSplatRoute, } from '../adapters/views/index.js';
3
- export { createServerFunctionClient, stripUnserializable, } from '../utilities/serverFunctionClient.js';
3
+ export { createServerFunctionClient } from '../utilities/serverFunctionClient.js';
4
4
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,sCAAsC,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  export { PayloadAdminShell, payloadLayoutRoute, withPayloadRoot } from '../adapters/layout/index.js';
3
3
  export { payloadAdminIndexRoute, payloadAdminSplatRoute } from '../adapters/views/index.js';
4
- export { createServerFunctionClient, stripUnserializable } from '../utilities/serverFunctionClient.js';
4
+ export { createServerFunctionClient } from '../utilities/serverFunctionClient.js';
5
5
 
6
6
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport {\n type LayoutLoad,\n PayloadAdminShell,\n type PayloadAdminShellProps,\n payloadLayoutRoute,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../adapters/layout/index.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../adapters/views/index.js'\nexport {\n createServerFunctionClient,\n stripUnserializable,\n} from '../utilities/serverFunctionClient.js'\n"],"names":["PayloadAdminShell","payloadLayoutRoute","withPayloadRoot","payloadAdminIndexRoute","payloadAdminSplatRoute","createServerFunctionClient","stripUnserializable"],"mappings":"AAAA;AAEA,SAEEA,iBAAiB,EAEjBC,kBAAkB,EAClBC,eAAe,QAEV,8BAA6B;AACpC,SAEEC,sBAAsB,EACtBC,sBAAsB,QACjB,6BAA4B;AACnC,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,uCAAsC"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport {\n type LayoutLoad,\n PayloadAdminShell,\n type PayloadAdminShellProps,\n payloadLayoutRoute,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../adapters/layout/index.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../adapters/views/index.js'\nexport { createServerFunctionClient } from '../utilities/serverFunctionClient.js'\n"],"names":["PayloadAdminShell","payloadLayoutRoute","withPayloadRoot","payloadAdminIndexRoute","payloadAdminSplatRoute","createServerFunctionClient"],"mappings":"AAAA;AAEA,SAEEA,iBAAiB,EAEjBC,kBAAkB,EAClBC,eAAe,QAEV,8BAA6B;AACpC,SAEEC,sBAAsB,EACtBC,sBAAsB,QACjB,6BAA4B;AACnC,SAASC,0BAA0B,QAAQ,uCAAsC"}
@@ -9,7 +9,5 @@ export { handleGraphQL } from '../routes/graphql/handler.server.js';
9
9
  export { handleAPIRoute } from '../routes/rest/handler.server.js';
10
10
  export { payloadApiHandlers } from '../routes/rest/index.js';
11
11
  export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
12
- export { serializeForRsc } from '../utilities/serializeForRsc.js';
13
- export { type SerializableRecord, toSerializable } from '../utilities/toSerializable.js';
14
12
  export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
15
13
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY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AAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}
@@ -9,8 +9,6 @@ export { handleGraphQL } from '../routes/graphql/handler.server.js';
9
9
  export { handleAPIRoute } from '../routes/rest/handler.server.js';
10
10
  export { payloadApiHandlers } from '../routes/rest/index.js';
11
11
  export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
12
- export { serializeForRsc } from '../utilities/serializeForRsc.js';
13
- export { toSerializable } from '../utilities/toSerializable.js';
14
12
  export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
15
13
 
16
14
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { handleServerFunctions } from '../adapters/handleServerFunctions.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../adapters/metadata.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../adapters/server.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../adapters/views/server.js'\nexport { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { handleGraphQL } from '../routes/graphql/handler.server.js'\nexport { handleAPIRoute } from '../routes/rest/handler.server.js'\nexport { payloadApiHandlers } from '../routes/rest/index.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport { serializeForRsc } from '../utilities/serializeForRsc.js'\nexport { type SerializableRecord, toSerializable } from '../utilities/toSerializable.js'\nexport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\n"],"names":["handleServerFunctions","getAdminMeta","createPageRenderServerAdapter","tanstackServerAdapter","loadAdminPage","login","logout","refresh","handleGraphQL","handleAPIRoute","payloadApiHandlers","getRequestI18n","serializeForRsc","toSerializable","getRequestTheme"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,uCAAsC;AAC5E,SAAiCC,YAAY,QAAQ,0BAAyB;AAC9E,SACEC,6BAA6B,EAE7BC,qBAAqB,QAChB,wBAAuB;AAC9B,SACEC,aAAa,QAGR,8BAA6B;AACpC,SAASC,KAAK,QAAQ,mBAAkB;AACxC,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,OAAO,QAAQ,qBAAoB;AAC5C,SAASC,aAAa,QAAQ,sCAAqC;AACnE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAAkCC,cAAc,QAAQ,iCAAgC;AACxF,SAASC,eAAe,QAAQ,2CAA0C"}
1
+ {"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { handleServerFunctions } from '../adapters/handleServerFunctions.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../adapters/metadata.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../adapters/server.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../adapters/views/server.js'\nexport { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { handleGraphQL } from '../routes/graphql/handler.server.js'\nexport { handleAPIRoute } from '../routes/rest/handler.server.js'\nexport { payloadApiHandlers } from '../routes/rest/index.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\n"],"names":["handleServerFunctions","getAdminMeta","createPageRenderServerAdapter","tanstackServerAdapter","loadAdminPage","login","logout","refresh","handleGraphQL","handleAPIRoute","payloadApiHandlers","getRequestI18n","getRequestTheme"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,uCAAsC;AAC5E,SAAiCC,YAAY,QAAQ,0BAAyB;AAC9E,SACEC,6BAA6B,EAE7BC,qBAAqB,QAChB,wBAAuB;AAC9B,SACEC,aAAa,QAGR,8BAA6B;AACpC,SAASC,KAAK,QAAQ,mBAAkB;AACxC,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,OAAO,QAAQ,qBAAoB;AAC5C,SAASC,aAAa,QAAQ,sCAAqC;AACnE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,eAAe,QAAQ,2CAA0C"}
@@ -1,8 +1,7 @@
1
1
  import type { SanitizedConfig } from 'payload';
2
2
  /**
3
- * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL
4
- * endpoint handler. The framework adapter wires this into the `/api/$` route's
5
- * server handlers, supplying the app's resolved `config`.
3
+ * Routes a TanStack Start API request to Payload's endpoint handler. The framework adapter
4
+ * wires this into the app's API route and supplies the resolved `config`.
6
5
  */
7
6
  export declare function handleAPIRoute({ config, request, }: {
8
7
  config: SanitizedConfig;
@@ -1 +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"}
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;;;GAGG;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,CAMpB"}
@@ -1,15 +1,11 @@
1
1
  import { handleEndpoints } from 'payload';
2
2
  /**
3
- * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL
4
- * endpoint handler. The framework adapter wires this into the `/api/$` route's
5
- * server handlers, supplying the app's resolved `config`.
3
+ * Routes a TanStack Start API request to Payload's endpoint handler. The framework adapter
4
+ * wires this into the app's API route and supplies the resolved `config`.
6
5
  */ export async function handleAPIRoute({ config, request }) {
7
- const url = new URL(request.url);
8
- const slugParts = url.pathname.replace(/^\/api\/?/, '').split('/').filter(Boolean);
9
- const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api';
10
6
  return handleEndpoints({
11
7
  config,
12
- path,
8
+ path: new URL(request.url).pathname,
13
9
  request
14
10
  });
15
11
  }
@@ -1 +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"}
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 to Payload's endpoint handler. The framework adapter\n * wires this into the app's API route and supplies the resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n return handleEndpoints({\n config,\n path: new URL(request.url).pathname,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","path","URL","url","pathname"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;CAGC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,OAAOH,gBAAgB;QACrBE;QACAE,MAAM,IAAIC,IAAIF,QAAQG,GAAG,EAAEC,QAAQ;QACnCJ;IACF;AACF"}
@@ -1,29 +1,8 @@
1
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
- */
2
+ /** Builds the admin dispatcher with native Flight response decoding. */
18
3
  export declare function createServerFunctionClient({ runServerFn, }: {
19
4
  runServerFn: (input: {
20
5
  data: ServerFunctionClientArgs;
21
- }) => Promise<unknown>;
6
+ }) => Promise<Response>;
22
7
  }): 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
8
  //# sourceMappingURL=serverFunctionClient.d.ts.map
@@ -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;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
+ {"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,wEAAwE;AACxE,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC9E,GAAG,oBAAoB,CAoBvB"}
@@ -1,114 +1,20 @@
1
- import { setOwnProperty } from 'payload/shared';
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
- */ export function createServerFunctionClient({ runServerFn }) {
1
+ /** Builds the admin dispatcher with native Flight response decoding. */ export function createServerFunctionClient({ runServerFn }) {
18
2
  return async (args)=>{
19
- const safeArgs = stripUnserializable(args);
20
- return await runServerFn({
21
- data: safeArgs
3
+ const response = await runServerFn({
4
+ data: args
22
5
  });
23
- };
24
- }
25
- /**
26
- * Recursively removes values TanStack Start's seroval wire format cannot
27
- * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
28
- * normalizes `Date` subclasses to plain `Date`.
29
- */ export function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
30
- if (value === null || value === undefined) {
31
- return value;
32
- }
33
- const t = typeof value;
34
- if (t === 'function' || t === 'symbol') {
35
- return undefined;
36
- }
37
- if (t !== 'object') {
38
- return value;
39
- }
40
- const obj = value;
41
- if (typeof obj.$$typeof === 'symbol') {
42
- return undefined;
43
- }
44
- if (ancestors.has(obj)) {
45
- return undefined;
46
- }
47
- if (cache.has(obj)) {
48
- return cache.get(obj);
49
- }
50
- if (obj instanceof Date) {
51
- // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,
52
- // used by the schedule-publish drawer) are `instanceof Date` but have a
53
- // different `constructor`, which TanStack Start's seroval serializer
54
- // rejects with "The value [object Date] ... cannot be parsed/serialized".
55
- return new Date(obj.getTime());
56
- }
57
- if (obj instanceof RegExp) {
58
- return undefined;
59
- }
60
- ancestors.add(obj);
61
- if (obj instanceof Map) {
62
- const cleaned = new Map();
63
- cache.set(obj, cleaned);
64
- for (const [k, v] of obj){
65
- const cv = stripUnserializable(v, cache, ancestors);
66
- if (cv !== undefined) {
67
- cleaned.set(k, cv);
68
- }
6
+ if (!response.ok) {
7
+ throw new Error(`Payload server function failed with status ${response.status}`);
69
8
  }
70
- ancestors.delete(obj);
71
- return cleaned;
72
- }
73
- if (obj instanceof Set) {
74
- const cleaned = new Set();
75
- cache.set(obj, cleaned);
76
- for (const v of obj){
77
- const cv = stripUnserializable(v, cache, ancestors);
78
- if (cv !== undefined) {
79
- cleaned.add(cv);
80
- }
9
+ if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {
10
+ throw new Error('Expected a React Flight response from the Payload server function');
81
11
  }
82
- ancestors.delete(obj);
83
- return cleaned;
84
- }
85
- if (Array.isArray(obj)) {
86
- const arr = [];
87
- cache.set(obj, arr);
88
- for (const item of obj){
89
- arr.push(stripUnserializable(item, cache, ancestors));
12
+ if (!response.body) {
13
+ throw new Error('The Payload server function returned an empty Flight response');
90
14
  }
91
- ancestors.delete(obj);
92
- return arr;
93
- }
94
- if (ArrayBuffer.isView(obj)) {
95
- ancestors.delete(obj);
96
- return obj;
97
- }
98
- const result = {};
99
- cache.set(obj, result);
100
- for (const key of Object.keys(obj)){
101
- const v = stripUnserializable(obj[key], cache, ancestors);
102
- if (v !== undefined) {
103
- setOwnProperty({
104
- key,
105
- target: result,
106
- value: v
107
- });
108
- }
109
- }
110
- ancestors.delete(obj);
111
- return result;
15
+ const { createFromReadableStream } = await import('@tanstack/react-start/rsc');
16
+ return await createFromReadableStream(response.body);
17
+ };
112
18
  }
113
19
 
114
20
  //# sourceMappingURL=serverFunctionClient.js.map
@@ -1 +1 @@
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,SAAS,EAC/CC,YAA6B,IAAIC,SAAS;IAE1C,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,2EAA2E;QAC3E,wEAAwE;QACxE,qEAAqE;QACrE,0EAA0E;QAC1E,OAAO,IAAIA,KAAKJ,IAAIK,OAAO;IAC7B;IAEA,IAAIL,eAAeM,QAAQ;QACzB,OAAOR;IACT;IAEAF,UAAUW,GAAG,CAACP;IAEd,IAAIA,eAAeQ,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBd,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIZ,IAAK;YACxB,MAAMa,KAAKtB,oBAAoBqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIT,eAAee,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBrB,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAMG,KAAKZ,IAAK;YACnB,MAAMa,KAAKtB,oBAAoBqB,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;YACnBZ,eAAe;gBAAEsC;gBAAKG,QAAQJ;gBAAQ9B,OAAOmB;YAAE;QACjD;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\n/** Builds the admin dispatcher with native Flight response decoding. */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<Response>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const response = await runServerFn({ data: args })\n\n if (!response.ok) {\n throw new Error(`Payload server function failed with status ${response.status}`)\n }\n\n if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {\n throw new Error('Expected a React Flight response from the Payload server function')\n }\n\n if (!response.body) {\n throw new Error('The Payload server function returned an empty Flight response')\n }\n\n const { createFromReadableStream } = await import('@tanstack/react-start/rsc')\n\n return await createFromReadableStream(response.body)\n }) as ServerFunctionClient\n}\n"],"names":["createServerFunctionClient","runServerFn","args","response","data","ok","Error","status","headers","get","split","trim","body","createFromReadableStream"],"mappings":"AAEA,sEAAsE,GACtE,OAAO,SAASA,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAW,MAAMF,YAAY;YAAEG,MAAMF;QAAK;QAEhD,IAAI,CAACC,SAASE,EAAE,EAAE;YAChB,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEH,SAASI,MAAM,EAAE;QACjF;QAEA,IAAIJ,SAASK,OAAO,CAACC,GAAG,CAAC,iBAAiBC,MAAM,IAAI,CAAC,EAAE,EAAEC,WAAW,oBAAoB;YACtF,MAAM,IAAIL,MAAM;QAClB;QAEA,IAAI,CAACH,SAASS,IAAI,EAAE;YAClB,MAAM,IAAIN,MAAM;QAClB;QAEA,MAAM,EAAEO,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC;QAElD,OAAO,MAAMA,yBAAyBV,SAASS,IAAI;IACrD;AACF"}