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

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 (82) hide show
  1. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  2. package/dist/elements/RouterAdapter/index.js +38 -15
  3. package/dist/elements/RouterAdapter/index.js.map +1 -1
  4. package/dist/exports/client.d.ts +4 -0
  5. package/dist/exports/client.d.ts.map +1 -1
  6. package/dist/exports/client.js +4 -0
  7. package/dist/exports/client.js.map +1 -1
  8. package/dist/exports/layouts.d.ts +1 -0
  9. package/dist/exports/layouts.d.ts.map +1 -1
  10. package/dist/exports/layouts.js +1 -0
  11. package/dist/exports/layouts.js.map +1 -1
  12. package/dist/exports/server.d.ts +2 -1
  13. package/dist/exports/server.d.ts.map +1 -1
  14. package/dist/exports/server.js +2 -1
  15. package/dist/exports/server.js.map +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  21. package/dist/layouts/Root/getLayoutData.js +36 -0
  22. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  23. package/dist/layouts/Root/index.d.ts +7 -0
  24. package/dist/layouts/Root/index.d.ts.map +1 -1
  25. package/dist/layouts/Root/index.js.map +1 -1
  26. package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
  27. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  28. package/dist/layouts/Root/withPayloadRoot.js +92 -0
  29. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  30. package/dist/routes/adminRoutes.d.ts +105 -0
  31. package/dist/routes/adminRoutes.d.ts.map +1 -0
  32. package/dist/routes/adminRoutes.js +97 -0
  33. package/dist/routes/adminRoutes.js.map +1 -0
  34. package/dist/routes/apiRoute.d.ts +29 -0
  35. package/dist/routes/apiRoute.d.ts.map +1 -0
  36. package/dist/routes/apiRoute.js +38 -0
  37. package/dist/routes/apiRoute.js.map +1 -0
  38. package/dist/routes/layoutRoute.d.ts +23 -0
  39. package/dist/routes/layoutRoute.d.ts.map +1 -0
  40. package/dist/routes/layoutRoute.js +51 -0
  41. package/dist/routes/layoutRoute.js.map +1 -0
  42. package/dist/utilities/handleAPIRoute.d.ts +11 -0
  43. package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
  44. package/dist/utilities/handleAPIRoute.js +17 -0
  45. package/dist/utilities/handleAPIRoute.js.map +1 -0
  46. package/dist/utilities/importMap.server.d.ts +4 -5
  47. package/dist/utilities/importMap.server.d.ts.map +1 -1
  48. package/dist/utilities/importMap.server.js +5 -6
  49. package/dist/utilities/importMap.server.js.map +1 -1
  50. package/dist/utilities/loadAdminPage.d.ts +54 -0
  51. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  52. package/dist/utilities/loadAdminPage.js +217 -0
  53. package/dist/utilities/loadAdminPage.js.map +1 -0
  54. package/dist/utilities/loadLayoutData.d.ts +15 -0
  55. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  56. package/dist/utilities/loadLayoutData.js +23 -0
  57. package/dist/utilities/loadLayoutData.js.map +1 -0
  58. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  59. package/dist/utilities/serializeForRsc.js +17 -0
  60. package/dist/utilities/serializeForRsc.js.map +1 -1
  61. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  62. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  63. package/dist/utilities/serverFunctionClient.js +109 -0
  64. package/dist/utilities/serverFunctionClient.js.map +1 -0
  65. package/dist/vite/constants.d.ts +7 -2
  66. package/dist/vite/constants.d.ts.map +1 -1
  67. package/dist/vite/constants.js +53 -5
  68. package/dist/vite/constants.js.map +1 -1
  69. package/dist/vite/plugin.js +10 -13
  70. package/dist/vite/plugin.js.map +1 -1
  71. package/dist/vite/plugins/devTransforms.d.ts +11 -0
  72. package/dist/vite/plugins/devTransforms.d.ts.map +1 -1
  73. package/dist/vite/plugins/devTransforms.js +13 -2
  74. package/dist/vite/plugins/devTransforms.js.map +1 -1
  75. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -1
  76. package/dist/vite/plugins/stripDistStyleImports.js +54 -3
  77. package/dist/vite/plugins/stripDistStyleImports.js.map +1 -1
  78. package/package.json +7 -7
  79. package/dist/auth/switchLanguage.d.ts +0 -6
  80. package/dist/auth/switchLanguage.d.ts.map +0 -1
  81. package/dist/auth/switchLanguage.js +0 -11
  82. package/dist/auth/switchLanguage.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\n/**\n * Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`\n * on `<html>` synchronously, before first paint, from Payload's theme and\n * language cookies. This is the no-flash equivalent of what `RootProvider`'s\n * `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd\n * document head so the admin panel never flashes light mode (or LTR for RTL\n * locales) on the first render. Mirrors `detectTheme` in\n * `@payloadcms/ui`'s `ThemeProvider`.\n */\nexport function buildThemeInitScript(cookiePrefix: string = 'payload'): string {\n const rtl = JSON.stringify(rtlLanguages)\n return `(function(){try{var d=document.documentElement;var c=document.cookie.split('; ');function r(n){var row=c.find(function(x){return x.indexOf(n+'=')===0});return row?row.split('=')[1]:null}var t=r('${cookiePrefix}-theme');if(t!=='light'&&t!=='dark'){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}d.setAttribute('data-theme',t);var l=r('${cookiePrefix}-lng');if(l){d.setAttribute('lang',l);d.setAttribute('dir',${rtl}.indexOf(l)!==-1?'rtl':'ltr')}}catch(e){}})()`\n}\n\n/**\n * The no-flash theme bootstrap script for the default (`payload`) cookie\n * prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the\n * document `<head>` to set `data-theme`/`lang`/`dir` before first paint.\n */\nexport const THEME_INIT_SCRIPT: string = buildThemeInitScript()\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n /**\n * The `config.cookiePrefix` used to read the theme/language cookies in the\n * no-flash bootstrap script. Defaults to `'payload'`.\n */\n readonly cookiePrefix?: string\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash\n * theme script, the `@layer` ordering style, `@payloadcms/ui` styles,\n * `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of\n * the admin tree) as `children`.\n */\nexport function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps) {\n const themeInitScript = cookiePrefix ? buildThemeInitScript(cookiePrefix) : THEME_INIT_SCRIPT\n\n return (\n // `lang`/`dir` are set on `<html>` by `themeInitScript` before first paint\n // from the `*-lng` cookie, so a static `lang` here would be incorrect.\n // eslint-disable-next-line jsx-a11y/html-has-lang -- set dynamically by the inline bootstrap script\n <html suppressHydrationWarning>\n <head>\n <script dangerouslySetInnerHTML={{ __html: themeInitScript }} />\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n /**\n * The `config.cookiePrefix` used by the no-flash theme bootstrap script.\n * Defaults to `'payload'`.\n */\n cookiePrefix?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin', cookiePrefix } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell cookiePrefix={cookiePrefix}>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["rtlLanguages","HeadContent","Scripts","useRouterState","React","buildThemeInitScript","cookiePrefix","rtl","JSON","stringify","THEME_INIT_SCRIPT","PayloadAdminShell","children","themeInitScript","html","suppressHydrationWarning","head","script","dangerouslySetInnerHTML","__html","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","select","s","pathname","location","startsWith"],"mappings":"AAAA;;AACA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAEzB;;;;;;;;CAQC,GACD,OAAO,SAASC,qBAAqBC,eAAuB,SAAS;IACnE,MAAMC,MAAMC,KAAKC,SAAS,CAACT;IAC3B,OAAO,CAAC,mMAAmM,EAAEM,aAAa,2KAA2K,EAAEA,aAAa,2DAA2D,EAAEC,IAAI,6CAA6C,CAAC;AACrgB;AAEA;;;;CAIC,GACD,OAAO,MAAMG,oBAA4BL,uBAAsB;AAW/D;;;;;;CAMC,GACD,OAAO,SAASM,kBAAkB,EAAEC,QAAQ,EAAEN,YAAY,EAA0B;IAClF,MAAMO,kBAAkBP,eAAeD,qBAAqBC,gBAAgBI;IAE5E,OACE,2EAA2E;IAC3E,uEAAuE;IACvE,oGAAoG;kBACpG,MAACI;QAAKC,wBAAwB;;0BAC5B,MAACC;;kCACC,KAACC;wBAAOC,yBAAyB;4BAAEC,QAAQN;wBAAgB;;kCAC3D,KAACO;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACnB;;;0BAEH,MAACoB;;oBACET;kCACD,KAACV;;;;;AAIT;AAgBA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASoB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAEnB,YAAY,EAAE,GAAGkB;IAEhD,OAAO,SAASE,iBAAiB,EAAEd,QAAQ,EAAiC;QAC1E,MAAMe,eAAexB,eAAe;YAClCyB,QAAQ,CAACC;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaL,cAAcK,SAASE,UAAU,CAAC,GAAGP,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAAChB;gBAAkBL,cAAcA;0BAAeM;;QACzD;QAEA,qBAAO,KAACW;sBAAWX;;IACrB;AACF"}
@@ -0,0 +1,105 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Loader supplied by the app — a TanStack Start `createServerFn` that delegates
4
+ * to `loadAdminPage`. Typed loosely because the server-fn's call signature is
5
+ * generated by the Start compiler.
6
+ */
7
+ export type AdminLoad = (opts: {
8
+ data: {
9
+ _splat: string;
10
+ search: Record<string, string | string[]>;
11
+ };
12
+ }) => Promise<any>;
13
+ declare function AdminPage(): import("react").JSX.Element;
14
+ declare function AdminNotFound(props: {
15
+ data?: {
16
+ routeKey?: string;
17
+ rscPayload?: ReactNode;
18
+ };
19
+ }): import("react").JSX.Element;
20
+ /**
21
+ * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
22
+ * server-built NotFound page (shipped via the `notFound()` error's
23
+ * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
24
+ * client view.
25
+ */
26
+ export declare function payloadAdminSplatRoute({ load }: {
27
+ load: AdminLoad;
28
+ }): {
29
+ component: typeof AdminPage;
30
+ head: ({ loaderData }: {
31
+ loaderData?: any;
32
+ }) => {
33
+ links: {
34
+ href: string;
35
+ media?: string;
36
+ rel: string;
37
+ sizes?: string;
38
+ type?: string;
39
+ }[];
40
+ meta: ({
41
+ charSet: string;
42
+ } | {
43
+ content: string;
44
+ name: string;
45
+ } | {
46
+ content: string;
47
+ property: string;
48
+ } | {
49
+ title: string;
50
+ })[];
51
+ };
52
+ loader: ({ location, params }: {
53
+ location: any;
54
+ params: any;
55
+ }) => Promise<any>;
56
+ loaderDeps: ({ search }: {
57
+ search: Record<string, unknown>;
58
+ }) => {
59
+ searchKey: string;
60
+ };
61
+ notFoundComponent: typeof AdminNotFound;
62
+ validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
63
+ };
64
+ /**
65
+ * Route options for the admin index route (`/_payload/admin/`). Same loader as the
66
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss.
67
+ */
68
+ export declare function payloadAdminIndexRoute({ load }: {
69
+ load: AdminLoad;
70
+ }): {
71
+ component: typeof AdminPage;
72
+ head: ({ loaderData }: {
73
+ loaderData?: any;
74
+ }) => {
75
+ links: {
76
+ href: string;
77
+ media?: string;
78
+ rel: string;
79
+ sizes?: string;
80
+ type?: string;
81
+ }[];
82
+ meta: ({
83
+ charSet: string;
84
+ } | {
85
+ content: string;
86
+ name: string;
87
+ } | {
88
+ content: string;
89
+ property: string;
90
+ } | {
91
+ title: string;
92
+ })[];
93
+ };
94
+ loader: ({ location }: {
95
+ location: any;
96
+ }) => Promise<any>;
97
+ loaderDeps: ({ search }: {
98
+ search: Record<string, unknown>;
99
+ }) => {
100
+ searchKey: string;
101
+ };
102
+ validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
103
+ };
104
+ export {};
105
+ //# sourceMappingURL=adminRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIhD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE;IAC7B,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACpE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAclB,iBAAS,SAAS,gCAQjB;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,+BAMrF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;;2BAGzC;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;mCAEN;QAAE,QAAQ,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE;6BAQ1C;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;;;;6BAInC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAEnD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;;2BAGzC;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;2BACd;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE;6BAQrB;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;;;6BAGnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAEnD"}
@@ -0,0 +1,97 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { NotFoundClient } from '@payloadcms/ui';
4
+ import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
5
+ import { Fragment } from 'react';
6
+ import { getAdminMeta } from '../utilities/meta.js';
7
+ const searchToRecord = (searchStr)=>Object.fromEntries(new URLSearchParams(searchStr));
8
+ const runLoader = async (load, splat, searchStr)=>{
9
+ const data = await load({
10
+ data: {
11
+ _splat: splat,
12
+ search: searchToRecord(searchStr)
13
+ }
14
+ });
15
+ if (data?._redirect) {
16
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects
17
+ throw redirect({
18
+ to: data._redirect
19
+ });
20
+ }
21
+ return data;
22
+ };
23
+ function AdminPage() {
24
+ // RSC Flight payload — render directly. Key by the loader-derived `routeKey`
25
+ // (not `location.pathname`, which updates before `useLoaderData` during a
26
+ // transition and would remount with the previous payload) so navigating to a
27
+ // different admin page remounts the view, mirroring Next route-segment
28
+ // semantics. Search params are excluded so search-only changes reconcile in place.
29
+ const data = useLoaderData({
30
+ strict: false
31
+ });
32
+ return /*#__PURE__*/ _jsx(Fragment, {
33
+ children: data?.rscPayload
34
+ }, data?.routeKey);
35
+ }
36
+ function AdminNotFound(props) {
37
+ const rscPayload = props?.data?.rscPayload;
38
+ if (!rscPayload) {
39
+ return /*#__PURE__*/ _jsx(NotFoundClient, {});
40
+ }
41
+ return /*#__PURE__*/ _jsx(Fragment, {
42
+ children: rscPayload
43
+ }, props?.data?.routeKey);
44
+ }
45
+ /**
46
+ * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
47
+ * server-built NotFound page (shipped via the `notFound()` error's
48
+ * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
49
+ * client view.
50
+ */ export function payloadAdminSplatRoute({ load }) {
51
+ return {
52
+ component: AdminPage,
53
+ head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
54
+ // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.
55
+ loader: async ({ location, params })=>{
56
+ const data = await runLoader(load, params._splat ?? '', location.searchStr);
57
+ if (data?._notFound) {
58
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
59
+ throw notFound({
60
+ data: {
61
+ routeKey: data.routeKey,
62
+ rscPayload: data.rscPayload
63
+ }
64
+ });
65
+ }
66
+ return data;
67
+ },
68
+ loaderDeps: ({ search })=>({
69
+ searchKey: JSON.stringify(search)
70
+ }),
71
+ notFoundComponent: AdminNotFound,
72
+ validateSearch: (search)=>search
73
+ };
74
+ }
75
+ /**
76
+ * Route options for the admin index route (`/_payload/admin/`). Same loader as the
77
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss.
78
+ */ export function payloadAdminIndexRoute({ load }) {
79
+ return {
80
+ component: AdminPage,
81
+ head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
82
+ loader: async ({ location })=>{
83
+ const data = await runLoader(load, '', location.searchStr);
84
+ if (data?._notFound) {
85
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
86
+ throw notFound();
87
+ }
88
+ return data;
89
+ },
90
+ loaderDeps: ({ search })=>({
91
+ searchKey: JSON.stringify(search)
92
+ }),
93
+ validateSearch: (search)=>search
94
+ };
95
+ }
96
+
97
+ //# sourceMappingURL=adminRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.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\nfunction AdminPage() {\n // RSC Flight payload — render directly. Key by the loader-derived `routeKey`\n // (not `location.pathname`, which updates before `useLoaderData` during a\n // transition and would remount with the previous payload) so navigating to a\n // different admin page remounts the view, mirroring Next route-segment\n // semantics. Search params are excluded so search-only changes reconcile in place.\n const data = useLoaderData({ strict: false })\n return <Fragment key={data?.routeKey}>{data?.rscPayload}</Fragment>\n}\n\nfunction AdminNotFound(props: { data?: { routeKey?: string; rscPayload?: ReactNode } }) {\n const rscPayload = props?.data?.rscPayload\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={props?.data?.routeKey}>{rscPayload}</Fragment>\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 {\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loader: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, params._splat ?? '', 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({ data: { routeKey: data.routeKey, rscPayload: data.rscPayload } })\n }\n return data\n },\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n notFoundComponent: AdminNotFound,\n validateSearch: (search: Record<string, unknown>) => search,\n }\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Same loader as the\n * splat route but throws a bare `notFound()` (no rscPayload) on miss.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return {\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n loader: async ({ location }: { location: any }) => {\n const data = await runLoader(load, '', 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 }\n return data\n },\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n }\n}\n"],"names":["NotFoundClient","notFound","redirect","useLoaderData","Fragment","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","routeKey","AdminNotFound","props","payloadAdminSplatRoute","component","head","loaderData","metadata","loader","location","params","_notFound","loaderDeps","searchKey","JSON","stringify","notFoundComponent","validateSearch","payloadAdminIndexRoute"],"mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,yBAAwB;AAC1E,SAASC,QAAQ,QAAwB,QAAO;AAEhD,SAASC,YAAY,QAAQ,uBAAsB;AAWnD,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAOC,MAAiBC,OAAeN;IACvD,MAAMO,OAAO,MAAMF,KAAK;QAAEE,MAAM;YAAEC,QAAQF;YAAOG,QAAQV,eAAeC;QAAW;IAAE;IACrF,IAAIO,MAAMG,WAAW;QACnB,qHAAqH;QACrH,MAAMf,SAAS;YAAEgB,IAAIJ,KAAKG,SAAS;QAAC;IACtC;IACA,OAAOH;AACT;AAEA,SAASK;IACP,6EAA6E;IAC7E,0EAA0E;IAC1E,6EAA6E;IAC7E,uEAAuE;IACvE,mFAAmF;IACnF,MAAML,OAAOX,cAAc;QAAEiB,QAAQ;IAAM;IAC3C,qBAAO,KAAChB;kBAA+BU,MAAMO;OAAvBP,MAAMQ;AAC9B;AAEA,SAASC,cAAcC,KAA+D;IACpF,MAAMH,aAAaG,OAAOV,MAAMO;IAChC,IAAI,CAACA,YAAY;QACf,qBAAO,KAACrB;IACV;IACA,qBAAO,KAACI;kBAAsCiB;OAAxBG,OAAOV,MAAMQ;AACrC;AAEA;;;;;CAKC,GACD,OAAO,SAASG,uBAAuB,EAAEb,IAAI,EAAuB;IAClE,OAAO;QACLc,WAAWP;QACXQ,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKvB,aAAauB,YAAYC;QACzE,2EAA2E;QAC3EC,QAAQ,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;YACjE,MAAMlB,OAAO,MAAMH,UAAUC,MAAMoB,OAAOjB,MAAM,IAAI,IAAIgB,SAASxB,SAAS;YAC1E,IAAIO,MAAMmB,WAAW;gBACnB,qHAAqH;gBACrH,MAAMhC,SAAS;oBAAEa,MAAM;wBAAEQ,UAAUR,KAAKQ,QAAQ;wBAAED,YAAYP,KAAKO,UAAU;oBAAC;gBAAE;YAClF;YACA,OAAOP;QACT;QACAoB,YAAY,CAAC,EAAElB,MAAM,EAAuC,GAAM,CAAA;gBAChEmB,WAAWC,KAAKC,SAAS,CAACrB;YAC5B,CAAA;QACAsB,mBAAmBf;QACnBgB,gBAAgB,CAACvB,SAAoCA;IACvD;AACF;AAEA;;;CAGC,GACD,OAAO,SAASwB,uBAAuB,EAAE5B,IAAI,EAAuB;IAClE,OAAO;QACLc,WAAWP;QACXQ,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKvB,aAAauB,YAAYC;QACzEC,QAAQ,OAAO,EAAEC,QAAQ,EAAqB;YAC5C,MAAMjB,OAAO,MAAMH,UAAUC,MAAM,IAAImB,SAASxB,SAAS;YACzD,IAAIO,MAAMmB,WAAW;gBACnB,qHAAqH;gBACrH,MAAMhC;YACR;YACA,OAAOa;QACT;QACAoB,YAAY,CAAC,EAAElB,MAAM,EAAuC,GAAM,CAAA;gBAChEmB,WAAWC,KAAKC,SAAS,CAACrB;YAC5B,CAAA;QACAuB,gBAAgB,CAACvB,SAAoCA;IACvD;AACF"}
@@ -0,0 +1,29 @@
1
+ import type { SanitizedConfig } from 'payload';
2
+ type ApiRouteHandler = (ctx: {
3
+ request: Request;
4
+ }) => Promise<Response>;
5
+ /**
6
+ * Builds the method handlers for the Payload REST/GraphQL catch-all
7
+ * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
8
+ * import) since the package cannot resolve the consumer's config.
9
+ *
10
+ * Spread the result into a literal `server.handlers` key so TanStack Start's
11
+ * client compiler can statically see — and prune — the server-only route:
12
+ *
13
+ * ```ts
14
+ * export const Route = createFileRoute('/_payload/api/$')({
15
+ * server: {
16
+ * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
17
+ * },
18
+ * })
19
+ * ```
20
+ *
21
+ * The compiler only strips a literal `server:` key from a route-options object
22
+ * expression; wrapping the whole options object in a factory call hides the
23
+ * key, leaking the config graph into the client bundle.
24
+ */
25
+ export declare function payloadApiHandlers({ getConfig, }: {
26
+ getConfig: () => Promise<SanitizedConfig>;
27
+ }): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler>;
28
+ export {};
29
+ //# sourceMappingURL=apiRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.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;;;;;;;;;;;;;;;;;;;GAmBG;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"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Builds the method handlers for the Payload REST/GraphQL catch-all
3
+ * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
4
+ * import) since the package cannot resolve the consumer's config.
5
+ *
6
+ * Spread the result into a literal `server.handlers` key so TanStack Start's
7
+ * client compiler can statically see — and prune — the server-only route:
8
+ *
9
+ * ```ts
10
+ * export const Route = createFileRoute('/_payload/api/$')({
11
+ * server: {
12
+ * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
13
+ * },
14
+ * })
15
+ * ```
16
+ *
17
+ * The compiler only strips a literal `server:` key from a route-options object
18
+ * expression; wrapping the whole options object in a factory call hides the
19
+ * key, leaking the config graph into the client bundle.
20
+ */ export function payloadApiHandlers({ getConfig }) {
21
+ const handler = async ({ request })=>{
22
+ const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
23
+ return handleAPIRoute({
24
+ config: await getConfig(),
25
+ request
26
+ });
27
+ };
28
+ return {
29
+ DELETE: handler,
30
+ GET: handler,
31
+ OPTIONS: handler,
32
+ PATCH: handler,
33
+ POST: handler,
34
+ PUT: handler
35
+ };
36
+ }
37
+
38
+ //# sourceMappingURL=apiRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/routes/apiRoute.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 * 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 * 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('../utilities/handleAPIRoute.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;;;;;;;;;;;;;;;;;;;CAmBC,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"}
@@ -0,0 +1,23 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { RootProvider } from '@payloadcms/ui';
3
+ /**
4
+ * Loader supplied by the app — a TanStack Start `createServerFn` that delegates
5
+ * to `loadLayoutData`. Typed loosely because the server-fn's call signature is
6
+ * generated by the Start compiler.
7
+ */
8
+ export type LayoutLoad = () => Promise<Record<string, unknown>>;
9
+ /**
10
+ * Route options for the Payload admin layout (`/_payload`). Maps the layout
11
+ * loader data onto `RootProvider` and renders the admin chrome (progress bar,
12
+ * custom-provider tree or router `<Outlet />`, portal mount). The app supplies
13
+ * `load` (the layout-data server fn) and `serverFunction` (the server-function
14
+ * client wired into `RootProvider`); everything else is adapter-owned.
15
+ */
16
+ export declare function payloadLayoutRoute({ load, serverFunction, }: {
17
+ load: LayoutLoad;
18
+ serverFunction: ComponentProps<typeof RootProvider>['serverFunction'];
19
+ }): {
20
+ component: () => import("react").JSX.Element;
21
+ loader: () => Promise<Record<string, unknown>>;
22
+ };
23
+ //# sourceMappingURL=layoutRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layoutRoute.d.ts","sourceRoot":"","sources":["../../src/routes/layoutRoute.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK1D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,cAAc,GACf,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc,EAAE,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACtE;;;EAkCA"}
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { ProgressBar, RootProvider } from '@payloadcms/ui';
4
+ import { Outlet, useLoaderData } from '@tanstack/react-router';
5
+ import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
6
+ /**
7
+ * Route options for the Payload admin layout (`/_payload`). Maps the layout
8
+ * loader data onto `RootProvider` and renders the admin chrome (progress bar,
9
+ * custom-provider tree or router `<Outlet />`, portal mount). The app supplies
10
+ * `load` (the layout-data server fn) and `serverFunction` (the server-function
11
+ * client wired into `RootProvider`); everything else is adapter-owned.
12
+ */ export function payloadLayoutRoute({ load, serverFunction }) {
13
+ function PayloadLayout() {
14
+ const data = useLoaderData({
15
+ strict: false
16
+ });
17
+ return /*#__PURE__*/ _jsxs(_Fragment, {
18
+ children: [
19
+ /*#__PURE__*/ _jsxs(RootProvider, {
20
+ config: data.clientConfig,
21
+ dateFNSKey: data.dateFNSKey,
22
+ fallbackLang: data.fallbackLang,
23
+ highContrastMode: false,
24
+ isNavOpen: data.isNavOpen,
25
+ languageCode: data.languageCode,
26
+ languageOptions: data.languageOptions,
27
+ locale: data.locale,
28
+ permissions: data.user ? data.permissions : null,
29
+ RouterAdapter: TanStackRouterAdapter,
30
+ serverFunction: serverFunction,
31
+ theme: data.theme,
32
+ translations: data.translations,
33
+ user: data.user,
34
+ children: [
35
+ /*#__PURE__*/ _jsx(ProgressBar, {}),
36
+ data.providers ?? /*#__PURE__*/ _jsx(Outlet, {})
37
+ ]
38
+ }),
39
+ /*#__PURE__*/ _jsx("div", {
40
+ id: "portal"
41
+ })
42
+ ]
43
+ });
44
+ }
45
+ return {
46
+ component: PayloadLayout,
47
+ loader: ()=>load()
48
+ };
49
+ }
50
+
51
+ //# sourceMappingURL=layoutRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { Outlet, useLoaderData } from '@tanstack/react-router'\n\nimport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadLayoutData`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type LayoutLoad = () => Promise<Record<string, unknown>>\n\n/**\n * Route options for the Payload admin layout (`/_payload`). Maps the layout\n * loader data onto `RootProvider` and renders the admin chrome (progress bar,\n * custom-provider tree or router `<Outlet />`, portal mount). The app supplies\n * `load` (the layout-data server fn) and `serverFunction` (the server-function\n * client wired into `RootProvider`); everything else is adapter-owned.\n */\nexport function payloadLayoutRoute({\n load,\n serverFunction,\n}: {\n load: LayoutLoad\n serverFunction: ComponentProps<typeof RootProvider>['serverFunction']\n}) {\n function PayloadLayout() {\n const data = useLoaderData({ strict: false })\n\n return (\n <>\n <RootProvider\n config={data.clientConfig}\n dateFNSKey={data.dateFNSKey}\n fallbackLang={data.fallbackLang}\n highContrastMode={false}\n isNavOpen={data.isNavOpen}\n languageCode={data.languageCode}\n languageOptions={data.languageOptions}\n locale={data.locale}\n permissions={data.user ? data.permissions : null}\n RouterAdapter={TanStackRouterAdapter}\n serverFunction={serverFunction}\n theme={data.theme}\n translations={data.translations}\n user={data.user}\n >\n <ProgressBar />\n {/* `data.providers` is the custom-provider tree (config.admin.components.providers)\n already wrapping the router <Outlet />; falls back to a bare <Outlet /> when\n no custom providers are configured. */}\n {data.providers ?? <Outlet />}\n </RootProvider>\n <div id=\"portal\" />\n </>\n )\n }\n\n return { component: PayloadLayout, loader: () => load() }\n}\n"],"names":["ProgressBar","RootProvider","Outlet","useLoaderData","TanStackRouterAdapter","payloadLayoutRoute","load","serverFunction","PayloadLayout","data","strict","config","clientConfig","dateFNSKey","fallbackLang","highContrastMode","isNavOpen","languageCode","languageOptions","locale","permissions","user","RouterAdapter","theme","translations","providers","div","id","component","loader"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,YAAY,QAAQ,iBAAgB;AAC1D,SAASC,MAAM,EAAEC,aAAa,QAAQ,yBAAwB;AAE9D,SAASC,qBAAqB,QAAQ,qCAAoC;AAS1E;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,cAAc,EAIf;IACC,SAASC;QACP,MAAMC,OAAON,cAAc;YAAEO,QAAQ;QAAM;QAE3C,qBACE;;8BACE,MAACT;oBACCU,QAAQF,KAAKG,YAAY;oBACzBC,YAAYJ,KAAKI,UAAU;oBAC3BC,cAAcL,KAAKK,YAAY;oBAC/BC,kBAAkB;oBAClBC,WAAWP,KAAKO,SAAS;oBACzBC,cAAcR,KAAKQ,YAAY;oBAC/BC,iBAAiBT,KAAKS,eAAe;oBACrCC,QAAQV,KAAKU,MAAM;oBACnBC,aAAaX,KAAKY,IAAI,GAAGZ,KAAKW,WAAW,GAAG;oBAC5CE,eAAelB;oBACfG,gBAAgBA;oBAChBgB,OAAOd,KAAKc,KAAK;oBACjBC,cAAcf,KAAKe,YAAY;oBAC/BH,MAAMZ,KAAKY,IAAI;;sCAEf,KAACrB;wBAIAS,KAAKgB,SAAS,kBAAI,KAACvB;;;8BAEtB,KAACwB;oBAAIC,IAAG;;;;IAGd;IAEA,OAAO;QAAEC,WAAWpB;QAAeqB,QAAQ,IAAMvB;IAAO;AAC1D"}
@@ -0,0 +1,11 @@
1
+ import type { SanitizedConfig } from 'payload';
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`.
6
+ */
7
+ export declare function handleAPIRoute({ config, request, }: {
8
+ config: SanitizedConfig;
9
+ request: Request;
10
+ }): Promise<Response>;
11
+ //# sourceMappingURL=handleAPIRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleAPIRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.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,17 @@
1
+ import { handleEndpoints } from 'payload';
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`.
6
+ */ 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
+ return handleEndpoints({
11
+ config,
12
+ path,
13
+ request
14
+ });
15
+ }
16
+
17
+ //# sourceMappingURL=handleAPIRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/handleAPIRoute.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,9 +1,8 @@
1
1
  /**
2
- * Returns the default output path for the generated import map file
3
- * in a TanStack Start project.
4
- *
5
- * TanStack Start projects typically use `src/` as the source root,
6
- * so the import map is placed there.
2
+ * Returns the default output path for the generated import map file in a
3
+ * TanStack Start project. Matches the `app/_payload/` convention that Payload's
4
+ * import map auto-discovery probes, so the file is found without a custom
5
+ * `admin.importMap.importMapFile` override.
7
6
  */
8
7
  export declare function getImportMapOutputPath(rootDir?: string): string;
9
8
  //# sourceMappingURL=importMap.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"importMap.server.d.ts","sourceRoot":"","sources":["../../src/utilities/importMap.server.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D"}
1
+ {"version":3,"file":"importMap.server.d.ts","sourceRoot":"","sources":["../../src/utilities/importMap.server.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -1,12 +1,11 @@
1
1
  import path from 'node:path';
2
2
  /**
3
- * Returns the default output path for the generated import map file
4
- * in a TanStack Start project.
5
- *
6
- * TanStack Start projects typically use `src/` as the source root,
7
- * so the import map is placed there.
3
+ * Returns the default output path for the generated import map file in a
4
+ * TanStack Start project. Matches the `app/_payload/` convention that Payload's
5
+ * import map auto-discovery probes, so the file is found without a custom
6
+ * `admin.importMap.importMapFile` override.
8
7
  */ export function getImportMapOutputPath(rootDir) {
9
- return path.resolve(rootDir || process.cwd(), 'src', 'payload-import-map.ts');
8
+ return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js');
10
9
  }
11
10
 
12
11
  //# sourceMappingURL=importMap.server.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file\n * in a TanStack Start project.\n *\n * TanStack Start projects typically use `src/` as the source root,\n * so the import map is placed there.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'src', 'payload-import-map.ts')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;;CAMC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO;AACvD"}
1
+ {"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file in a\n * TanStack Start project. Matches the `app/_payload/` convention that Payload's\n * import map auto-discovery probes, so the file is found without a custom\n * `admin.importMap.importMapFile` override.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;CAKC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO,YAAY;AACnE"}
@@ -0,0 +1,54 @@
1
+ import type { ImportMap, SanitizedConfig } from 'payload';
2
+ import type { AdminPageMetadata } from './meta.js';
3
+ export type LoadAdminPageArgs = {
4
+ config: SanitizedConfig;
5
+ importMap: ImportMap;
6
+ search?: Record<string, string | string[]>;
7
+ splat?: string;
8
+ };
9
+ export type LoadAdminPageResult = {
10
+ _notFound: true;
11
+ routeKey?: string;
12
+ rscPayload?: React.ReactNode;
13
+ } | {
14
+ _redirect: string;
15
+ } | {
16
+ metadata: AdminPageMetadata;
17
+ /**
18
+ * Stable identity for this rendered route (the splat, i.e. the path
19
+ * after `/admin/`). The client keys the rendered subtree by this so the
20
+ * view remounts exactly when a new payload arrives. Keying by
21
+ * `location.pathname` instead races: the pathname updates before
22
+ * `useLoaderData()` during a transition, so the subtree would remount
23
+ * with the *previous* payload and then reconcile the fresh payload in
24
+ * place — leaving client providers (DocumentInfo, etc.) holding stale
25
+ * `useState` values from the prior document. Search params are excluded
26
+ * so search-only changes (e.g. list-view filtering) reconcile in place.
27
+ */
28
+ routeKey: string;
29
+ rscPayload: React.ReactNode;
30
+ };
31
+ /**
32
+ * Renders an admin page for TanStack Start and returns a serializable loader
33
+ * result. The framework adapter wraps this in a `createServerFn` that supplies
34
+ * the app's `config` and generated `importMap`.
35
+ *
36
+ * 1. Initializes the Payload request via the shared `renderRoot` orchestrator
37
+ * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
38
+ * page-render `ServerAdapter` records navigation intent and throws the
39
+ * framework-agnostic error contract.
40
+ * 2. Pipes the resulting React server tree through `renderServerComponent`
41
+ * to produce a Flight payload the client consumes directly.
42
+ * 3. Resolves page metadata via the same shared `generatePageMetadata`
43
+ * Next.js uses, returning plain serializable strings for `head()`.
44
+ *
45
+ * Navigation surfaces two ways and both become a `_notFound` / `_redirect`
46
+ * sentinel the route loader re-throws as native TanStack nav:
47
+ * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
48
+ * by the try/catch below;
49
+ * - thrown deep inside a streamed view component (e.g. `DocumentView` access
50
+ * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
51
+ * so it's read from the `nav` holder after `renderServerComponent` resolves.
52
+ */
53
+ export declare function loadAdminPage({ config, importMap, search, splat, }: LoadAdminPageArgs): Promise<LoadAdminPageResult>;
54
+ //# sourceMappingURL=loadAdminPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GACpE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;CAC5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiIlD"}