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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  3. package/dist/elements/RouterAdapter/index.js +55 -16
  4. package/dist/elements/RouterAdapter/index.js.map +1 -1
  5. package/dist/exports/client.d.ts +4 -0
  6. package/dist/exports/client.d.ts.map +1 -1
  7. package/dist/exports/client.js +4 -0
  8. package/dist/exports/client.js.map +1 -1
  9. package/dist/exports/layouts.d.ts +1 -0
  10. package/dist/exports/layouts.d.ts.map +1 -1
  11. package/dist/exports/layouts.js +1 -0
  12. package/dist/exports/layouts.js.map +1 -1
  13. package/dist/exports/server.d.ts +4 -2
  14. package/dist/exports/server.d.ts.map +1 -1
  15. package/dist/exports/server.js +4 -2
  16. package/dist/exports/server.js.map +1 -1
  17. package/dist/exports/vite.d.ts +2 -2
  18. package/dist/exports/vite.d.ts.map +1 -1
  19. package/dist/exports/vite.js +1 -1
  20. package/dist/exports/vite.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  26. package/dist/layouts/Root/getLayoutData.js +37 -1
  27. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  28. package/dist/layouts/Root/index.d.ts +9 -2
  29. package/dist/layouts/Root/index.d.ts.map +1 -1
  30. package/dist/layouts/Root/index.js +4 -2
  31. package/dist/layouts/Root/index.js.map +1 -1
  32. package/dist/layouts/Root/withPayloadRoot.d.ts +41 -0
  33. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  34. package/dist/layouts/Root/withPayloadRoot.js +91 -0
  35. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  36. package/dist/node/cssLoader.d.mts +24 -2
  37. package/dist/node/cssLoader.d.mts.map +1 -1
  38. package/dist/routes/adminRoutes.d.ts +111 -0
  39. package/dist/routes/adminRoutes.d.ts.map +1 -0
  40. package/dist/routes/adminRoutes.js +108 -0
  41. package/dist/routes/adminRoutes.js.map +1 -0
  42. package/dist/routes/apiRoute.d.ts +34 -0
  43. package/dist/routes/apiRoute.d.ts.map +1 -0
  44. package/dist/routes/apiRoute.js +43 -0
  45. package/dist/routes/apiRoute.js.map +1 -0
  46. package/dist/routes/layoutRoute.d.ts +26 -0
  47. package/dist/routes/layoutRoute.d.ts.map +1 -0
  48. package/dist/routes/layoutRoute.js +57 -0
  49. package/dist/routes/layoutRoute.js.map +1 -0
  50. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  51. package/dist/utilities/handleAPIRoute.server.d.ts +11 -0
  52. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  53. package/dist/utilities/handleAPIRoute.server.js +17 -0
  54. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  55. package/dist/utilities/importMap.server.d.ts +4 -5
  56. package/dist/utilities/importMap.server.d.ts.map +1 -1
  57. package/dist/utilities/importMap.server.js +5 -6
  58. package/dist/utilities/importMap.server.js.map +1 -1
  59. package/dist/utilities/loadAdminPage.d.ts +54 -0
  60. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  61. package/dist/utilities/loadAdminPage.js +239 -0
  62. package/dist/utilities/loadAdminPage.js.map +1 -0
  63. package/dist/utilities/loadLayoutData.d.ts +15 -0
  64. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  65. package/dist/utilities/loadLayoutData.js +23 -0
  66. package/dist/utilities/loadLayoutData.js.map +1 -0
  67. package/dist/utilities/meta.d.ts +1 -0
  68. package/dist/utilities/meta.d.ts.map +1 -1
  69. package/dist/utilities/meta.js +2 -1
  70. package/dist/utilities/meta.js.map +1 -1
  71. package/dist/utilities/routerSearch.d.ts +40 -0
  72. package/dist/utilities/routerSearch.d.ts.map +1 -0
  73. package/dist/utilities/routerSearch.js +45 -0
  74. package/dist/utilities/routerSearch.js.map +1 -0
  75. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  76. package/dist/utilities/serializeForRsc.js +17 -0
  77. package/dist/utilities/serializeForRsc.js.map +1 -1
  78. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  79. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  80. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  81. package/dist/utilities/serverFunctionClient.js +109 -0
  82. package/dist/utilities/serverFunctionClient.js.map +1 -0
  83. package/dist/vite/config/external.d.ts +26 -0
  84. package/dist/vite/config/external.d.ts.map +1 -0
  85. package/dist/vite/config/external.js +72 -0
  86. package/dist/vite/config/external.js.map +1 -0
  87. package/dist/vite/config/optimizeDeps.d.ts +25 -0
  88. package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
  89. package/dist/vite/config/optimizeDeps.js +123 -0
  90. package/dist/vite/config/optimizeDeps.js.map +1 -0
  91. package/dist/vite/config/scss.d.ts +14 -0
  92. package/dist/vite/config/scss.d.ts.map +1 -0
  93. package/dist/vite/config/scss.js +28 -0
  94. package/dist/vite/config/scss.js.map +1 -0
  95. package/dist/vite/index.d.ts +99 -0
  96. package/dist/vite/index.d.ts.map +1 -0
  97. package/dist/vite/index.js +258 -0
  98. package/dist/vite/index.js.map +1 -0
  99. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
  100. package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
  101. package/dist/vite/workarounds/devTransforms.d.ts +19 -0
  102. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
  103. package/dist/vite/{plugins → workarounds}/devTransforms.js +18 -2
  104. package/dist/vite/workarounds/devTransforms.js.map +1 -0
  105. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  106. package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
  107. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
  108. package/dist/vite/workarounds/stripDistStyleImports.js +140 -0
  109. package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
  110. package/dist/vite/workarounds/stubPrettierInClient.d.ts +13 -0
  111. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
  112. package/dist/vite/workarounds/stubPrettierInClient.js +32 -0
  113. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
  114. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
  115. package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
  116. package/package.json +12 -7
  117. package/dist/@types/assets.d.js +0 -2
  118. package/dist/@types/assets.d.js.map +0 -1
  119. package/dist/auth/switchLanguage.d.ts +0 -6
  120. package/dist/auth/switchLanguage.d.ts.map +0 -1
  121. package/dist/auth/switchLanguage.js +0 -11
  122. package/dist/auth/switchLanguage.js.map +0 -1
  123. package/dist/utilities/getRequestTheme.d.ts +0 -10
  124. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  125. package/dist/utilities/getRequestTheme.js +0 -25
  126. package/dist/utilities/getRequestTheme.js.map +0 -1
  127. package/dist/vite/constants.d.ts +0 -37
  128. package/dist/vite/constants.d.ts.map +0 -1
  129. package/dist/vite/constants.js +0 -129
  130. package/dist/vite/constants.js.map +0 -1
  131. package/dist/vite/plugin.d.ts +0 -38
  132. package/dist/vite/plugin.d.ts.map +0 -1
  133. package/dist/vite/plugin.js +0 -182
  134. package/dist/vite/plugin.js.map +0 -1
  135. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  136. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  137. package/dist/vite/plugins/devTransforms.d.ts +0 -8
  138. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  139. package/dist/vite/plugins/devTransforms.js.map +0 -1
  140. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  141. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  142. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  143. package/dist/vite/plugins/stripDistStyleImports.js +0 -89
  144. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  145. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  146. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  147. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
  148. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
  149. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
  150. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
  151. /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
  152. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
  153. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
@@ -0,0 +1,91 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir';
4
+ import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
5
+ import React from 'react';
6
+ /**
7
+ * The `<html>` document shell for Payload admin routes — the TanStack Start
8
+ * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
9
+ * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
10
+ * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin
11
+ * panel renders themed with the correct text direction on the first paint with no
12
+ * client bootstrap script — the same server-side path Next's `RootLayout`
13
+ * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
14
+ */ export function PayloadAdminShell({ children }) {
15
+ const htmlProps = useRouterState({
16
+ select: (state)=>{
17
+ for (const match of state.matches){
18
+ const data = match.loaderData;
19
+ if (data?.theme && data?.languageCode) {
20
+ return {
21
+ 'data-theme': data.theme,
22
+ dir: getLanguageDir({
23
+ languageCode: data.languageCode
24
+ }),
25
+ lang: data.languageCode
26
+ };
27
+ }
28
+ }
29
+ // No layout data yet (fresh session before the loader resolves): default
30
+ // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the
31
+ // document sidebar divider) still match, matching Next's `ltr` default.
32
+ return {
33
+ dir: 'ltr'
34
+ };
35
+ }
36
+ });
37
+ return(// eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available
38
+ /*#__PURE__*/ _jsxs("html", {
39
+ ...htmlProps,
40
+ suppressHydrationWarning: true,
41
+ children: [
42
+ /*#__PURE__*/ _jsxs("head", {
43
+ children: [
44
+ /*#__PURE__*/ _jsx("style", {
45
+ children: `@layer payload-default, payload;`
46
+ }),
47
+ /*#__PURE__*/ _jsx(HeadContent, {})
48
+ ]
49
+ }),
50
+ /*#__PURE__*/ _jsxs("body", {
51
+ children: [
52
+ children,
53
+ /*#__PURE__*/ _jsx(Scripts, {})
54
+ ]
55
+ })
56
+ ]
57
+ }));
58
+ }
59
+ /**
60
+ * Wraps your application's root document shell so Payload owns its own
61
+ * `<html>` chrome on admin routes while your shell renders everywhere else.
62
+ *
63
+ * Attach the result to the root route's `shellComponent`; it is the single
64
+ * integration touch point — no root loader and no manual data threading:
65
+ *
66
+ * ```tsx
67
+ * export const Route = createRootRoute({
68
+ * shellComponent: withPayloadRoot(MarketingRoot),
69
+ * })
70
+ * ```
71
+ */ export function withPayloadRoot(RootShell, options = {}) {
72
+ const { adminRoute = '/admin' } = options;
73
+ return function PayloadRootShell({ children }) {
74
+ const isAdminRoute = useRouterState({
75
+ select: (s)=>{
76
+ const { pathname } = s.location;
77
+ return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`);
78
+ }
79
+ });
80
+ if (isAdminRoute) {
81
+ return /*#__PURE__*/ _jsx(PayloadAdminShell, {
82
+ children: children
83
+ });
84
+ }
85
+ return /*#__PURE__*/ _jsx(RootShell, {
86
+ children: children
87
+ });
88
+ };
89
+ }
90
+
91
+ //# sourceMappingURL=withPayloadRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport type { Theme } from '@payloadcms/ui'\n\nimport { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\ntype AdminHTMLProps = {\n 'data-theme'?: Theme\n dir: 'ltr' | 'rtl'\n lang?: string\n}\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets\n * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data\n * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin\n * panel renders themed with the correct text direction on the first paint with no\n * client bootstrap script — the same server-side path Next's `RootLayout`\n * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.\n */\nexport function PayloadAdminShell({ children }: PayloadAdminShellProps) {\n const htmlProps = useRouterState({\n select: (state): AdminHTMLProps => {\n for (const match of state.matches) {\n const data = match.loaderData as { languageCode?: string; theme?: Theme } | undefined\n\n if (data?.theme && data?.languageCode) {\n return {\n 'data-theme': data.theme,\n dir: getLanguageDir({ languageCode: data.languageCode }),\n lang: data.languageCode,\n }\n }\n }\n\n // No layout data yet (fresh session before the loader resolves): default\n // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the\n // document sidebar divider) still match, matching Next's `ltr` default.\n return { dir: 'ltr' }\n },\n })\n\n return (\n // eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available\n <html {...htmlProps} suppressHydrationWarning>\n <head>\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\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' } = 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>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["getLanguageDir","HeadContent","Scripts","useRouterState","React","PayloadAdminShell","children","htmlProps","select","state","match","matches","data","loaderData","theme","languageCode","dir","lang","html","suppressHydrationWarning","head","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","s","pathname","location","startsWith"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,0CAAyC;AACxE,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAYzB;;;;;;;;CAQC,GACD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,EAA0B;IACpE,MAAMC,YAAYJ,eAAe;QAC/BK,QAAQ,CAACC;YACP,KAAK,MAAMC,SAASD,MAAME,OAAO,CAAE;gBACjC,MAAMC,OAAOF,MAAMG,UAAU;gBAE7B,IAAID,MAAME,SAASF,MAAMG,cAAc;oBACrC,OAAO;wBACL,cAAcH,KAAKE,KAAK;wBACxBE,KAAKhB,eAAe;4BAAEe,cAAcH,KAAKG,YAAY;wBAAC;wBACtDE,MAAML,KAAKG,YAAY;oBACzB;gBACF;YACF;YAEA,yEAAyE;YACzE,oEAAoE;YACpE,wEAAwE;YACxE,OAAO;gBAAEC,KAAK;YAAM;QACtB;IACF;IAEA,OACE,mHAAmH;kBACnH,MAACE;QAAM,GAAGX,SAAS;QAAEY,wBAAwB;;0BAC3C,MAACC;;kCACC,KAACC;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACpB;;;0BAEH,MAACqB;;oBACEhB;kCACD,KAACJ;;;;;AAIT;AAWA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASqB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAE,GAAGD;IAElC,OAAO,SAASE,iBAAiB,EAAErB,QAAQ,EAAiC;QAC1E,MAAMsB,eAAezB,eAAe;YAClCK,QAAQ,CAACqB;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaJ,cAAcI,SAASE,UAAU,CAAC,GAAGN,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAACvB;0BAAmBC;;QAC7B;QAEA,qBAAO,KAACkB;sBAAWlB;;IACrB;AACF"}
@@ -1,3 +1,25 @@
1
- export function resolve(specifier: any, context: any, nextResolve: any): Promise<any>;
2
- export function load(url: any, context: any, nextLoad: any): Promise<any>;
1
+ /**
2
+ * Node ESM loader hook that swallows static asset imports (CSS/SCSS/LESS,
3
+ * images, fonts, audio, video, etc.) encountered while running the dev
4
+ * server.
5
+ *
6
+ * Vite is supposed to intercept asset imports during SSR/RSC by treating
7
+ * the package as `noExternal`, but that resolution path silently breaks down
8
+ * when a dependency is installed from a packed tarball under
9
+ * `node_modules/.pnpm/<pkg>@file+packed+...`. In that scenario Vite hands the
10
+ * import to Node's native ESM loader, which has no opinion about `.css` /
11
+ * `.svg` / `.png` files and throws `ERR_UNKNOWN_FILE_EXTENSION`. That single
12
+ * throw cascades into every admin route showing "Something went wrong!"
13
+ * because the SSR tree dies inside `<MatchInnerImpl>`.
14
+ *
15
+ * Registering this loader (with `--import` or `register()`) makes Node treat
16
+ * any asset specifier as an empty ES module, which is exactly what we
17
+ * already do client-side for SSR.
18
+ *
19
+ * The loader is intentionally minimal and side-effect free; it only kicks in
20
+ * for asset specifiers and falls through to the default loader for
21
+ * everything else.
22
+ */
23
+ export declare function resolve(specifier: any, context: any, nextResolve: any): Promise<any>;
24
+ export declare function load(url: any, context: any, nextLoad: any): Promise<any>;
3
25
  //# sourceMappingURL=cssLoader.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cssLoader.d.mts","sourceRoot":"","sources":["../../src/node/cssLoader.mjs"],"names":[],"mappings":"AAsDA,sFASC;AAED,0EASC"}
1
+ {"version":3,"file":"cssLoader.d.mts","sourceRoot":"","sources":["../../src/node/cssLoader.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiCH,wBAAsB,OAAO,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,EAAE,WAAW,KAAA,gBAS5D;AAED,wBAAsB,IAAI,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,EAAE,QAAQ,KAAA,gBAShD"}
@@ -0,0 +1,111 @@
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: {
53
+ handler: ({ location, params }: {
54
+ location: any;
55
+ params: any;
56
+ }) => Promise<any>;
57
+ staleReloadMode: string;
58
+ };
59
+ loaderDeps: ({ search }: {
60
+ search: Record<string, unknown>;
61
+ }) => {
62
+ searchKey: string;
63
+ };
64
+ notFoundComponent: typeof AdminNotFound;
65
+ validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
66
+ };
67
+ /**
68
+ * Route options for the admin index route (`/_payload/admin/`). Same loader as the
69
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss.
70
+ */
71
+ export declare function payloadAdminIndexRoute({ load }: {
72
+ load: AdminLoad;
73
+ }): {
74
+ component: typeof AdminPage;
75
+ head: ({ loaderData }: {
76
+ loaderData?: any;
77
+ }) => {
78
+ links: {
79
+ href: string;
80
+ media?: string;
81
+ rel: string;
82
+ sizes?: string;
83
+ type?: string;
84
+ }[];
85
+ meta: ({
86
+ charSet: string;
87
+ } | {
88
+ content: string;
89
+ name: string;
90
+ } | {
91
+ content: string;
92
+ property: string;
93
+ } | {
94
+ title: string;
95
+ })[];
96
+ };
97
+ loader: {
98
+ handler: ({ location }: {
99
+ location: any;
100
+ }) => Promise<any>;
101
+ staleReloadMode: string;
102
+ };
103
+ loaderDeps: ({ search }: {
104
+ search: Record<string, unknown>;
105
+ }) => {
106
+ searchKey: string;
107
+ };
108
+ validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
109
+ };
110
+ export {};
111
+ //# 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;IAEhE,SAAS;IACT,IAAI,mBAAmB;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;IAM3C,MAAM;QACJ,OAAO,yBAA+B;YAAE,QAAQ,EAAE,GAAG,CAAC;YAAC,MAAM,EAAE,GAAG,CAAA;SAAE;QAQpE,eAAe;;IAGjB,UAAU,eAAe;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;QAC1D,SAAS;;IAEX,iBAAiB;IACjB,cAAc,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAEnD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;IAEhE,SAAS;IACT,IAAI,mBAAmB;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;IAC3C,MAAM;QACJ,OAAO,iBAAuB;YAAE,QAAQ,EAAE,GAAG,CAAA;SAAE;QAQ/C,eAAe;;IAEjB,UAAU,eAAe;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;QAC1D,SAAS;;IAEX,cAAc,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAEnD"}
@@ -0,0 +1,108 @@
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
+ // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
55
+ // sibling route option — router-core only reads it off a non-function loader)
56
+ // makes stale-match revalidation await the fresh loader before committing,
57
+ // instead of the default background SWR that flashes the pre-navigation list
58
+ // (e.g. a just-created doc missing) until the reload lands.
59
+ loader: {
60
+ handler: async ({ location, params })=>{
61
+ const data = await runLoader(load, params._splat ?? '', location.searchStr);
62
+ if (data?._notFound) {
63
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
64
+ throw notFound({
65
+ data: {
66
+ routeKey: data.routeKey,
67
+ rscPayload: data.rscPayload
68
+ }
69
+ });
70
+ }
71
+ return data;
72
+ },
73
+ staleReloadMode: 'blocking'
74
+ },
75
+ // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.
76
+ loaderDeps: ({ search })=>({
77
+ searchKey: JSON.stringify(search)
78
+ }),
79
+ notFoundComponent: AdminNotFound,
80
+ validateSearch: (search)=>search
81
+ };
82
+ }
83
+ /**
84
+ * Route options for the admin index route (`/_payload/admin/`). Same loader as the
85
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss.
86
+ */ export function payloadAdminIndexRoute({ load }) {
87
+ return {
88
+ component: AdminPage,
89
+ head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
90
+ loader: {
91
+ handler: async ({ location })=>{
92
+ const data = await runLoader(load, '', location.searchStr);
93
+ if (data?._notFound) {
94
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
95
+ throw notFound();
96
+ }
97
+ return data;
98
+ },
99
+ staleReloadMode: 'blocking'
100
+ },
101
+ loaderDeps: ({ search })=>({
102
+ searchKey: JSON.stringify(search)
103
+ }),
104
+ validateSearch: (search)=>search
105
+ };
106
+ }
107
+
108
+ //# 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 // `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, 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 staleReloadMode: 'blocking',\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 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: {\n handler: 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 staleReloadMode: 'blocking',\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","handler","location","params","_notFound","staleReloadMode","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,0EAA0E;QAC1E,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,4DAA4D;QAC5DC,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;gBAClE,MAAMnB,OAAO,MAAMH,UAAUC,MAAMqB,OAAOlB,MAAM,IAAI,IAAIiB,SAASzB,SAAS;gBAC1E,IAAIO,MAAMoB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMjC,SAAS;wBAAEa,MAAM;4BAAEQ,UAAUR,KAAKQ,QAAQ;4BAAED,YAAYP,KAAKO,UAAU;wBAAC;oBAAE;gBAClF;gBACA,OAAOP;YACT;YACAqB,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAEpB,MAAM,EAAuC,GAAM,CAAA;gBAChEqB,WAAWC,KAAKC,SAAS,CAACvB;YAC5B,CAAA;QACAwB,mBAAmBjB;QACnBkB,gBAAgB,CAACzB,SAAoCA;IACvD;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS0B,uBAAuB,EAAE9B,IAAI,EAAuB;IAClE,OAAO;QACLc,WAAWP;QACXQ,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKvB,aAAauB,YAAYC;QACzEC,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAqB;gBAC7C,MAAMlB,OAAO,MAAMH,UAAUC,MAAM,IAAIoB,SAASzB,SAAS;gBACzD,IAAIO,MAAMoB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMjC;gBACR;gBACA,OAAOa;YACT;YACAqB,iBAAiB;QACnB;QACAC,YAAY,CAAC,EAAEpB,MAAM,EAAuC,GAAM,CAAA;gBAChEqB,WAAWC,KAAKC,SAAS,CAACvB;YAC5B,CAAA;QACAyB,gBAAgB,CAACzB,SAAoCA;IACvD;AACF"}
@@ -0,0 +1,34 @@
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
+ * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
11
+ * the server-only `handleAPIRoute` graph never reaches the client bundle.
12
+ *
13
+ * Spread the result into a literal `server.handlers` key so TanStack Start's
14
+ * client compiler can statically see — and prune — the server-only route:
15
+ *
16
+ * ```ts
17
+ * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
18
+ *
19
+ * export const Route = createFileRoute('/_payload/api/$')({
20
+ * server: {
21
+ * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
22
+ * },
23
+ * })
24
+ * ```
25
+ *
26
+ * The compiler only strips a literal `server:` key from a route-options object
27
+ * expression; wrapping the whole options object in a factory call hides the
28
+ * key, leaking the config graph into the client bundle.
29
+ */
30
+ export declare function payloadApiHandlers({ getConfig, }: {
31
+ getConfig: () => Promise<SanitizedConfig>;
32
+ }): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler>;
33
+ export {};
34
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
@@ -0,0 +1,43 @@
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
+ * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
7
+ * the server-only `handleAPIRoute` graph never reaches the client bundle.
8
+ *
9
+ * Spread the result into a literal `server.handlers` key so TanStack Start's
10
+ * client compiler can statically see — and prune — the server-only route:
11
+ *
12
+ * ```ts
13
+ * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
14
+ *
15
+ * export const Route = createFileRoute('/_payload/api/$')({
16
+ * server: {
17
+ * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
18
+ * },
19
+ * })
20
+ * ```
21
+ *
22
+ * The compiler only strips a literal `server:` key from a route-options object
23
+ * expression; wrapping the whole options object in a factory call hides the
24
+ * key, leaking the config graph into the client bundle.
25
+ */ export function payloadApiHandlers({ getConfig }) {
26
+ const handler = async ({ request })=>{
27
+ const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js');
28
+ return handleAPIRoute({
29
+ config: await getConfig(),
30
+ request
31
+ });
32
+ };
33
+ return {
34
+ DELETE: handler,
35
+ GET: handler,
36
+ OPTIONS: handler,
37
+ PATCH: handler,
38
+ POST: handler,
39
+ PUT: handler
40
+ };
41
+ }
42
+
43
+ //# 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 * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so\n * the server-only `handleAPIRoute` graph never reaches the client bundle.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
@@ -0,0 +1,26 @@
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: {
22
+ handler: () => Promise<Record<string, unknown>>;
23
+ staleReloadMode: string;
24
+ };
25
+ };
26
+ //# 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;IAqCG,SAAS;IACT,MAAM;QAAI,OAAO;QAAgB,eAAe;;EAEnD"}
@@ -0,0 +1,57 @@
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
+ // `staleReloadMode` lives on the loader *object* — router-core only reads it
46
+ // off a non-function loader — so stale-match revalidation blocks on the fresh
47
+ // loader instead of flashing stale layout data via the default background SWR.
48
+ return {
49
+ component: PayloadLayout,
50
+ loader: {
51
+ handler: ()=>load(),
52
+ staleReloadMode: 'blocking'
53
+ }
54
+ };
55
+ }
56
+
57
+ //# 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 // `staleReloadMode` lives on the loader *object* — router-core only reads it\n // off a non-function loader — so stale-match revalidation blocks on the fresh\n // loader instead of flashing stale layout data via the default background SWR.\n return {\n component: PayloadLayout,\n loader: { handler: () => load(), staleReloadMode: 'blocking' },\n }\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","handler","staleReloadMode"],"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,6EAA6E;IAC7E,8EAA8E;IAC9E,+EAA+E;IAC/E,OAAO;QACLC,WAAWpB;QACXqB,QAAQ;YAAEC,SAAS,IAAMxB;YAAQyB,iBAAiB;QAAW;IAC/D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"graphqlHandler.server.d.ts","sourceRoot":"","sources":["../../src/utilities/graphqlHandler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,SAAS,CAAA;AAyFvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAU,sBAGjC;IACD,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CAAC,QAAQ,CA2DnB,CAAA"}
1
+ {"version":3,"file":"graphqlHandler.server.d.ts","sourceRoot":"","sources":["../../src/utilities/graphqlHandler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,SAAS,CAAA;AAyFvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,yBAGvB;IACD,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CAAC,QAAQ,CA2DnB,CAAA"}
@@ -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.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleAPIRoute.server.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
@@ -0,0 +1,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.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/handleAPIRoute.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,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"}