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

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 (243) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/auth/login.d.ts +3 -16
  3. package/dist/auth/login.d.ts.map +1 -1
  4. package/dist/auth/login.js +6 -46
  5. package/dist/auth/login.js.map +1 -1
  6. package/dist/auth/logout.d.ts +2 -5
  7. package/dist/auth/logout.d.ts.map +1 -1
  8. package/dist/auth/logout.js +6 -47
  9. package/dist/auth/logout.js.map +1 -1
  10. package/dist/auth/refresh.d.ts +2 -4
  11. package/dist/auth/refresh.d.ts.map +1 -1
  12. package/dist/auth/refresh.js +6 -49
  13. package/dist/auth/refresh.js.map +1 -1
  14. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  15. package/dist/elements/RouterAdapter/index.js +72 -19
  16. package/dist/elements/RouterAdapter/index.js.map +1 -1
  17. package/dist/exports/client.d.ts +4 -2
  18. package/dist/exports/client.d.ts.map +1 -1
  19. package/dist/exports/client.js +4 -2
  20. package/dist/exports/client.js.map +1 -1
  21. package/dist/exports/layouts.d.ts +2 -3
  22. package/dist/exports/layouts.d.ts.map +1 -1
  23. package/dist/exports/layouts.js +1 -1
  24. package/dist/exports/layouts.js.map +1 -1
  25. package/dist/exports/rsc.browser.d.ts +4 -1
  26. package/dist/exports/rsc.browser.d.ts.map +1 -1
  27. package/dist/exports/rsc.browser.js +4 -1
  28. package/dist/exports/rsc.browser.js.map +1 -1
  29. package/dist/exports/rsc.d.ts +0 -1
  30. package/dist/exports/rsc.d.ts.map +1 -1
  31. package/dist/exports/rsc.js +0 -1
  32. package/dist/exports/rsc.js.map +1 -1
  33. package/dist/exports/server.d.ts +5 -4
  34. package/dist/exports/server.d.ts.map +1 -1
  35. package/dist/exports/server.js +4 -3
  36. package/dist/exports/server.js.map +1 -1
  37. package/dist/exports/shared.d.ts +2 -0
  38. package/dist/exports/shared.d.ts.map +1 -0
  39. package/dist/exports/shared.js +3 -0
  40. package/dist/exports/shared.js.map +1 -0
  41. package/dist/index.d.ts +1 -4
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +1 -4
  44. package/dist/index.js.map +1 -1
  45. package/dist/layouts/Root/getLayoutData.d.ts +24 -2
  46. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  47. package/dist/layouts/Root/getLayoutData.js +43 -1
  48. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  49. package/dist/layouts/Root/withPayloadRoot.d.ts +41 -0
  50. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  51. package/dist/layouts/Root/withPayloadRoot.js +91 -0
  52. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  53. package/dist/node/cssLoader.d.mts +24 -2
  54. package/dist/node/cssLoader.d.mts.map +1 -1
  55. package/dist/routes/adminRoutes.d.ts +108 -0
  56. package/dist/routes/adminRoutes.d.ts.map +1 -0
  57. package/dist/routes/adminRoutes.js +115 -0
  58. package/dist/routes/adminRoutes.js.map +1 -0
  59. package/dist/routes/apiRoute.d.ts +34 -0
  60. package/dist/routes/apiRoute.d.ts.map +1 -0
  61. package/dist/routes/apiRoute.js +43 -0
  62. package/dist/routes/apiRoute.js.map +1 -0
  63. package/dist/routes/layoutRoute.d.ts +27 -0
  64. package/dist/routes/layoutRoute.d.ts.map +1 -0
  65. package/dist/routes/layoutRoute.js +58 -0
  66. package/dist/routes/layoutRoute.js.map +1 -0
  67. package/dist/utilities/devConfigReload.server.d.ts +2 -0
  68. package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
  69. package/dist/utilities/devConfigReload.server.js +38 -0
  70. package/dist/utilities/devConfigReload.server.js.map +1 -0
  71. package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
  72. package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
  73. package/dist/utilities/devConfigReloadEvent.js +9 -0
  74. package/dist/utilities/devConfigReloadEvent.js.map +1 -0
  75. package/dist/utilities/getRequestLocale.d.ts.map +1 -1
  76. package/dist/utilities/getRequestLocale.js +1 -2
  77. package/dist/utilities/getRequestLocale.js.map +1 -1
  78. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  79. package/dist/utilities/handleAPIRoute.server.d.ts +11 -0
  80. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  81. package/dist/utilities/handleAPIRoute.server.js +17 -0
  82. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  83. package/dist/utilities/handleServerFunctions.d.ts +1 -19
  84. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  85. package/dist/utilities/handleServerFunctions.js +8 -56
  86. package/dist/utilities/handleServerFunctions.js.map +1 -1
  87. package/dist/utilities/initReq.server.d.ts +1 -0
  88. package/dist/utilities/initReq.server.d.ts.map +1 -1
  89. package/dist/utilities/initReq.server.js +3 -0
  90. package/dist/utilities/initReq.server.js.map +1 -1
  91. package/dist/utilities/loadAdminPage.d.ts +57 -0
  92. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  93. package/dist/utilities/loadAdminPage.js +231 -0
  94. package/dist/utilities/loadAdminPage.js.map +1 -0
  95. package/dist/utilities/loadLayoutData.d.ts +17 -0
  96. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  97. package/dist/utilities/loadLayoutData.js +22 -0
  98. package/dist/utilities/loadLayoutData.js.map +1 -0
  99. package/dist/utilities/meta.d.ts +1 -0
  100. package/dist/utilities/meta.d.ts.map +1 -1
  101. package/dist/utilities/meta.js +2 -1
  102. package/dist/utilities/meta.js.map +1 -1
  103. package/dist/utilities/routerSearch.d.ts +40 -0
  104. package/dist/utilities/routerSearch.d.ts.map +1 -0
  105. package/dist/utilities/routerSearch.js +45 -0
  106. package/dist/utilities/routerSearch.js.map +1 -0
  107. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  108. package/dist/utilities/serializeForRsc.js +17 -0
  109. package/dist/utilities/serializeForRsc.js.map +1 -1
  110. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  111. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  112. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  113. package/dist/utilities/serverFunctionClient.js +109 -0
  114. package/dist/utilities/serverFunctionClient.js.map +1 -0
  115. package/dist/utilities/toSerializable.d.ts +9 -0
  116. package/dist/utilities/toSerializable.d.ts.map +1 -1
  117. package/dist/utilities/toSerializable.js +13 -2
  118. package/dist/utilities/toSerializable.js.map +1 -1
  119. package/dist/withPayload/config/external.d.ts +44 -0
  120. package/dist/withPayload/config/external.d.ts.map +1 -0
  121. package/dist/withPayload/config/external.js +96 -0
  122. package/dist/withPayload/config/external.js.map +1 -0
  123. package/dist/withPayload/config/optimizeDeps.d.ts +25 -0
  124. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
  125. package/dist/withPayload/config/optimizeDeps.js +127 -0
  126. package/dist/withPayload/config/optimizeDeps.js.map +1 -0
  127. package/dist/withPayload/config/scss.d.ts +14 -0
  128. package/dist/withPayload/config/scss.d.ts.map +1 -0
  129. package/dist/withPayload/config/scss.js +28 -0
  130. package/dist/withPayload/config/scss.js.map +1 -0
  131. package/dist/withPayload/devConfigReload.d.ts +14 -0
  132. package/dist/withPayload/devConfigReload.d.ts.map +1 -0
  133. package/dist/withPayload/devConfigReload.js +84 -0
  134. package/dist/withPayload/devConfigReload.js.map +1 -0
  135. package/dist/withPayload/importProtection.d.ts.map +1 -0
  136. package/dist/{vite → withPayload}/importProtection.js +2 -2
  137. package/dist/withPayload/importProtection.js.map +1 -0
  138. package/dist/withPayload/index.d.ts +112 -0
  139. package/dist/withPayload/index.d.ts.map +1 -0
  140. package/dist/withPayload/index.js +302 -0
  141. package/dist/withPayload/index.js.map +1 -0
  142. package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
  143. package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
  144. package/dist/withPayload/workarounds/devTransforms.d.ts +19 -0
  145. package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
  146. package/dist/{vite/plugins → withPayload/workarounds}/devTransforms.js +18 -2
  147. package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
  148. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  149. package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
  150. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
  151. package/dist/withPayload/workarounds/stripDistStyleImports.js +140 -0
  152. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
  153. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts +13 -0
  154. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
  155. package/dist/withPayload/workarounds/stubPrettierInClient.js +32 -0
  156. package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
  157. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
  158. package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
  159. package/package.json +20 -14
  160. package/dist/@types/assets.d.js +0 -2
  161. package/dist/@types/assets.d.js.map +0 -1
  162. package/dist/auth/switchLanguage.d.ts +0 -6
  163. package/dist/auth/switchLanguage.d.ts.map +0 -1
  164. package/dist/auth/switchLanguage.js +0 -11
  165. package/dist/auth/switchLanguage.js.map +0 -1
  166. package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
  167. package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
  168. package/dist/elements/DocumentHeaderClient/index.js +0 -116
  169. package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
  170. package/dist/elements/RenderComponent/index.d.ts +0 -10
  171. package/dist/elements/RenderComponent/index.d.ts.map +0 -1
  172. package/dist/elements/RenderComponent/index.js +0 -12
  173. package/dist/elements/RenderComponent/index.js.map +0 -1
  174. package/dist/exports/vite.d.ts +0 -3
  175. package/dist/exports/vite.d.ts.map +0 -1
  176. package/dist/exports/vite.js +0 -3
  177. package/dist/exports/vite.js.map +0 -1
  178. package/dist/layouts/Root/index.d.ts +0 -25
  179. package/dist/layouts/Root/index.d.ts.map +0 -1
  180. package/dist/layouts/Root/index.js +0 -51
  181. package/dist/layouts/Root/index.js.map +0 -1
  182. package/dist/rsc/renderPayloadRSC.d.ts +0 -6
  183. package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
  184. package/dist/rsc/renderPayloadRSC.js +0 -6
  185. package/dist/rsc/renderPayloadRSC.js.map +0 -1
  186. package/dist/utilities/devReloadStrategy.d.ts +0 -10
  187. package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
  188. package/dist/utilities/devReloadStrategy.js +0 -27
  189. package/dist/utilities/devReloadStrategy.js.map +0 -1
  190. package/dist/utilities/getExistingAuthToken.d.ts +0 -7
  191. package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
  192. package/dist/utilities/getExistingAuthToken.js +0 -18
  193. package/dist/utilities/getExistingAuthToken.js.map +0 -1
  194. package/dist/utilities/getPreferences.d.ts +0 -10
  195. package/dist/utilities/getPreferences.d.ts.map +0 -1
  196. package/dist/utilities/getPreferences.js +0 -33
  197. package/dist/utilities/getPreferences.js.map +0 -1
  198. package/dist/utilities/getRequestTheme.d.ts +0 -10
  199. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  200. package/dist/utilities/getRequestTheme.js +0 -25
  201. package/dist/utilities/getRequestTheme.js.map +0 -1
  202. package/dist/utilities/importMap.server.d.ts +0 -9
  203. package/dist/utilities/importMap.server.d.ts.map +0 -1
  204. package/dist/utilities/importMap.server.js +0 -12
  205. package/dist/utilities/importMap.server.js.map +0 -1
  206. package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
  207. package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
  208. package/dist/utilities/serverFunctionHandlers.js +0 -17
  209. package/dist/utilities/serverFunctionHandlers.js.map +0 -1
  210. package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
  211. package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
  212. package/dist/utilities/setPayloadAuthCookie.js +0 -31
  213. package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
  214. package/dist/vite/constants.d.ts +0 -37
  215. package/dist/vite/constants.d.ts.map +0 -1
  216. package/dist/vite/constants.js +0 -129
  217. package/dist/vite/constants.js.map +0 -1
  218. package/dist/vite/importProtection.d.ts.map +0 -1
  219. package/dist/vite/importProtection.js.map +0 -1
  220. package/dist/vite/plugin.d.ts +0 -38
  221. package/dist/vite/plugin.d.ts.map +0 -1
  222. package/dist/vite/plugin.js +0 -182
  223. package/dist/vite/plugin.js.map +0 -1
  224. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  225. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  226. package/dist/vite/plugins/devTransforms.d.ts +0 -8
  227. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  228. package/dist/vite/plugins/devTransforms.js.map +0 -1
  229. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  230. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  231. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  232. package/dist/vite/plugins/stripDistStyleImports.js +0 -89
  233. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  234. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  235. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  236. /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
  237. /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.d.ts +0 -0
  238. /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.js +0 -0
  239. /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.d.ts +0 -0
  240. /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.js +0 -0
  241. /package/dist/{vite/plugins → withPayload/workarounds}/stripDistStyleImports.d.ts +0 -0
  242. /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.d.ts +0 -0
  243. /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.js +0 -0
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { NotFoundClient, useRouteTransition } from '@payloadcms/ui';
4
+ import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
5
+ import { Fragment, useDeferredValue, useEffect } 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
+ // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.
25
+ // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.
26
+ const data = useLoaderData({
27
+ strict: false
28
+ });
29
+ // Route state comes from an external store, so a new RSC payload that suspends
30
+ // on code-split client references can reveal the router's null fallback.
31
+ // Keep the current payload painted until the next one is renderable.
32
+ const rscPayload = useDeferredValue(data?.rscPayload);
33
+ const { holdRouteTransition } = useRouteTransition();
34
+ const isRscPayloadDeferred = rscPayload !== data?.rscPayload;
35
+ useEffect(()=>{
36
+ if (!isRscPayloadDeferred) {
37
+ return;
38
+ }
39
+ const releaseRouteTransition = holdRouteTransition();
40
+ return ()=>releaseRouteTransition();
41
+ }, [
42
+ holdRouteTransition,
43
+ isRscPayloadDeferred
44
+ ]);
45
+ return /*#__PURE__*/ _jsx(Fragment, {
46
+ children: rscPayload
47
+ });
48
+ }
49
+ function AdminNotFound({ data }) {
50
+ // TanStack exposes not-found data as unknown; this route only receives the shape thrown below.
51
+ const { routeKey, rscPayload } = data ?? {};
52
+ if (!rscPayload) {
53
+ return /*#__PURE__*/ _jsx(NotFoundClient, {});
54
+ }
55
+ return /*#__PURE__*/ _jsx(Fragment, {
56
+ children: rscPayload
57
+ }, routeKey);
58
+ }
59
+ const adminRouteOptions = ({ forwardNotFoundPayload, load, resolveSplat })=>({
60
+ component: AdminPage,
61
+ head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
62
+ // Both admin routes must use the same boundary type so index ↔ splat
63
+ // navigation preserves the existing admin subtree.
64
+ notFoundComponent: AdminNotFound,
65
+ // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
66
+ // sibling route option — router-core only reads it off a non-function loader)
67
+ // makes stale-match revalidation await the fresh loader before committing,
68
+ // instead of the default background SWR that flashes the pre-navigation list
69
+ // (e.g. a just-created doc missing) until the reload lands.
70
+ loader: {
71
+ handler: async ({ location, params })=>{
72
+ const data = await runLoader(load, resolveSplat(params), location.searchStr);
73
+ if (data?._notFound) {
74
+ // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
75
+ throw notFound(forwardNotFoundPayload ? {
76
+ data: {
77
+ routeKey: data.routeKey,
78
+ rscPayload: data.rscPayload
79
+ }
80
+ } : undefined);
81
+ }
82
+ return data;
83
+ },
84
+ staleReloadMode: 'blocking'
85
+ },
86
+ // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.
87
+ loaderDeps: ({ search })=>({
88
+ searchKey: JSON.stringify(search)
89
+ }),
90
+ validateSearch: (search)=>search
91
+ });
92
+ /**
93
+ * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
94
+ * server-built NotFound page (shipped via the `notFound()` error's
95
+ * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
96
+ * client view.
97
+ */ export function payloadAdminSplatRoute({ load }) {
98
+ return adminRouteOptions({
99
+ forwardNotFoundPayload: true,
100
+ load,
101
+ resolveSplat: (params)=>params._splat ?? ''
102
+ });
103
+ }
104
+ /**
105
+ * Route options for the admin index route (`/_payload/admin/`). Not-found
106
+ * results omit the RSC payload and fall back to `NotFoundClient`.
107
+ */ export function payloadAdminIndexRoute({ load }) {
108
+ return adminRouteOptions({
109
+ forwardNotFoundPayload: false,
110
+ load,
111
+ resolveSplat: ()=>''
112
+ });
113
+ }
114
+
115
+ //# sourceMappingURL=adminRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode, useDeferredValue, useEffect } 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 // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.\n // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.\n const data = useLoaderData({ strict: false })\n\n // Route state comes from an external store, so a new RSC payload that suspends\n // on code-split client references can reveal the router's null fallback.\n // Keep the current payload painted until the next one is renderable.\n const rscPayload = useDeferredValue(data?.rscPayload)\n const { holdRouteTransition } = useRouteTransition()\n const isRscPayloadDeferred = rscPayload !== data?.rscPayload\n\n useEffect(() => {\n if (!isRscPayloadDeferred) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRscPayloadDeferred])\n\n return <Fragment>{rscPayload}</Fragment>\n}\n\ntype AdminNotFoundData = { routeKey?: string; rscPayload?: ReactNode }\n\nfunction AdminNotFound({ data }: NotFoundRouteProps) {\n // TanStack exposes not-found data as unknown; this route only receives the shape thrown below.\n const { routeKey, rscPayload } = (data ?? {}) as AdminNotFoundData\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={routeKey}>{rscPayload}</Fragment>\n}\n\nconst adminRouteOptions = ({\n forwardNotFoundPayload,\n load,\n resolveSplat,\n}: {\n /**\n * Ships the server-rendered NotFound tree through `notFound()`'s `data` so a\n * `notFoundComponent` can render it with the full admin chrome. Routes without\n * one throw bare.\n */\n forwardNotFoundPayload: boolean\n load: AdminLoad\n /** The route's splat, i.e. the path after `/admin/`. */\n resolveSplat: (params: any) => string\n}) => ({\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // Both admin routes must use the same boundary type so index ↔ splat\n // navigation preserves the existing admin subtree.\n notFoundComponent: AdminNotFound,\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, resolveSplat(params), location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound(\n forwardNotFoundPayload\n ? { data: { routeKey: data.routeKey, rscPayload: data.rscPayload } }\n : undefined,\n )\n }\n return data\n },\n staleReloadMode: 'blocking' as const,\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n})\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: true,\n load,\n resolveSplat: (params) => params._splat ?? '',\n })\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Not-found\n * results omit the RSC payload and fall back to `NotFoundClient`.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: false,\n load,\n resolveSplat: () => '',\n })\n}\n"],"names":["NotFoundClient","useRouteTransition","notFound","redirect","useLoaderData","Fragment","useDeferredValue","useEffect","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","holdRouteTransition","isRscPayloadDeferred","releaseRouteTransition","AdminNotFound","routeKey","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","notFoundComponent","loader","handler","location","params","_notFound","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","payloadAdminIndexRoute"],"mappings":"AAAA;;AAIA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,iBAAgB;AACnE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,yBAAwB;AAC1E,SAASC,QAAQ,EAAkBC,gBAAgB,EAAEC,SAAS,QAAQ,QAAO;AAE7E,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,MAAMjB,SAAS;YAAEkB,IAAIJ,KAAKG,SAAS;QAAC;IACtC;IACA,OAAOH;AACT;AAEA,SAASK;IACP,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAML,OAAOb,cAAc;QAAEmB,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAalB,iBAAiBW,MAAMO;IAC1C,MAAM,EAAEC,mBAAmB,EAAE,GAAGxB;IAChC,MAAMyB,uBAAuBF,eAAeP,MAAMO;IAElDjB,UAAU;QACR,IAAI,CAACmB,sBAAsB;YACzB;QACF;QAEA,MAAMC,yBAAyBF;QAE/B,OAAO,IAAME;IACf,GAAG;QAACF;QAAqBC;KAAqB;IAE9C,qBAAO,KAACrB;kBAAUmB;;AACpB;AAIA,SAASI,cAAc,EAAEX,IAAI,EAAsB;IACjD,+FAA+F;IAC/F,MAAM,EAAEY,QAAQ,EAAEL,UAAU,EAAE,GAAIP,QAAQ,CAAC;IAC3C,IAAI,CAACO,YAAY;QACf,qBAAO,KAACxB;IACV;IACA,qBAAO,KAACK;kBAAyBmB;OAAXK;AACxB;AAEA,MAAMC,oBAAoB,CAAC,EACzBC,sBAAsB,EACtBhB,IAAI,EACJiB,YAAY,EAWb,GAAM,CAAA;QACLC,WAAWX;QACXY,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAK3B,aAAa2B,YAAYC;QACzE,qEAAqE;QACrE,mDAAmD;QACnDC,mBAAmBT;QACnB,0EAA0E;QAC1E,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,4DAA4D;QAC5DU,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;gBAClE,MAAMxB,OAAO,MAAMH,UAAUC,MAAMiB,aAAaS,SAASD,SAAS9B,SAAS;gBAC3E,IAAIO,MAAMyB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMxC,SACJ6B,yBACI;wBAAEd,MAAM;4BAAEY,UAAUZ,KAAKY,QAAQ;4BAAEL,YAAYP,KAAKO,UAAU;wBAAC;oBAAE,IACjEmB;gBAER;gBACA,OAAO1B;YACT;YACA2B,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAE1B,MAAM,EAAuC,GAAM,CAAA;gBAChE2B,WAAWC,KAAKC,SAAS,CAAC7B;YAC5B,CAAA;QACA8B,gBAAgB,CAAC9B,SAAoCA;IACvD,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAAS+B,uBAAuB,EAAEnC,IAAI,EAAuB;IAClE,OAAOe,kBAAkB;QACvBC,wBAAwB;QACxBhB;QACAiB,cAAc,CAACS,SAAWA,OAAOvB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAASiC,uBAAuB,EAAEpC,IAAI,EAAuB;IAClE,OAAOe,kBAAkB;QACvBC,wBAAwB;QACxBhB;QACAiB,cAAc,IAAM;IACtB;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,27 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { RootProvider } from '@payloadcms/ui';
3
+ import type { LoadLayoutDataResult } from '../utilities/loadLayoutData.js';
4
+ /**
5
+ * Loader supplied by the app — a TanStack Start `createServerFn` that delegates
6
+ * to `loadLayoutData`. Typed loosely because the server-fn's call signature is
7
+ * generated by the Start compiler.
8
+ */
9
+ export type LayoutLoad = () => Promise<LoadLayoutDataResult>;
10
+ /**
11
+ * Route options for the Payload admin layout (`/_payload`). Maps the layout
12
+ * loader data onto `RootProvider` and renders the admin chrome (progress bar,
13
+ * custom-provider tree or router `<Outlet />`, portal mount). The app supplies
14
+ * `load` (the layout-data server fn) and `serverFunction` (the server-function
15
+ * client wired into `RootProvider`); everything else is adapter-owned.
16
+ */
17
+ export declare function payloadLayoutRoute({ load, serverFunction, }: {
18
+ load: LayoutLoad;
19
+ serverFunction: ComponentProps<typeof RootProvider>['serverFunction'];
20
+ }): {
21
+ component: () => import("react").JSX.Element;
22
+ loader: {
23
+ handler: () => Promise<import("../utilities/toSerializable.js").SerializableRecord>;
24
+ staleReloadMode: 'blocking';
25
+ };
26
+ };
27
+ //# 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;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAI1E;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE5D;;;;;;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;IAsCG,SAAS;IACT,MAAM;QAAI,OAAO;QAAgB,eAAe,EAAE,UAAU;;EAE/D"}
@@ -0,0 +1,58 @@
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
+ embed: data.isEmbedded,
23
+ fallbackLang: data.fallbackLang,
24
+ highContrastMode: false,
25
+ isNavOpen: data.isNavOpen,
26
+ languageCode: data.languageCode,
27
+ languageOptions: data.languageOptions,
28
+ locale: data.locale,
29
+ permissions: data.user ? data.permissions : null,
30
+ RouterAdapter: TanStackRouterAdapter,
31
+ serverFunction: serverFunction,
32
+ theme: data.theme,
33
+ translations: data.translations,
34
+ user: data.user,
35
+ children: [
36
+ /*#__PURE__*/ _jsx(ProgressBar, {}),
37
+ data.providers ?? /*#__PURE__*/ _jsx(Outlet, {})
38
+ ]
39
+ }),
40
+ /*#__PURE__*/ _jsx("div", {
41
+ id: "portal"
42
+ })
43
+ ]
44
+ });
45
+ }
46
+ // `staleReloadMode` lives on the loader *object* — router-core only reads it
47
+ // off a non-function loader — so stale-match revalidation blocks on the fresh
48
+ // loader instead of flashing stale layout data via the default background SWR.
49
+ return {
50
+ component: PayloadLayout,
51
+ loader: {
52
+ handler: ()=>load(),
53
+ staleReloadMode: 'blocking'
54
+ }
55
+ };
56
+ }
57
+
58
+ //# 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 type { LoadLayoutDataResult } from '../utilities/loadLayoutData.js'\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<LoadLayoutDataResult>\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 embed={data.isEmbedded}\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' as const },\n }\n}\n"],"names":["ProgressBar","RootProvider","Outlet","useLoaderData","TanStackRouterAdapter","payloadLayoutRoute","load","serverFunction","PayloadLayout","data","strict","config","clientConfig","dateFNSKey","embed","isEmbedded","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;AAI9D,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,OAAOL,KAAKM,UAAU;oBACtBC,cAAcP,KAAKO,YAAY;oBAC/BC,kBAAkB;oBAClBC,WAAWT,KAAKS,SAAS;oBACzBC,cAAcV,KAAKU,YAAY;oBAC/BC,iBAAiBX,KAAKW,eAAe;oBACrCC,QAAQZ,KAAKY,MAAM;oBACnBC,aAAab,KAAKc,IAAI,GAAGd,KAAKa,WAAW,GAAG;oBAC5CE,eAAepB;oBACfG,gBAAgBA;oBAChBkB,OAAOhB,KAAKgB,KAAK;oBACjBC,cAAcjB,KAAKiB,YAAY;oBAC/BH,MAAMd,KAAKc,IAAI;;sCAEf,KAACvB;wBAIAS,KAAKkB,SAAS,kBAAI,KAACzB;;;8BAEtB,KAAC0B;oBAAIC,IAAG;;;;IAGd;IAEA,6EAA6E;IAC7E,8EAA8E;IAC9E,+EAA+E;IAC/E,OAAO;QACLC,WAAWtB;QACXuB,QAAQ;YAAEC,SAAS,IAAM1B;YAAQ2B,iBAAiB;QAAoB;IACxE;AACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=devConfigReload.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devConfigReload.server.d.ts","sourceRoot":"","sources":["../../src/utilities/devConfigReload.server.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { registerDevReloadStrategy } from 'payload';
2
+ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
3
+ /**
4
+ * Subscribes the Payload instance to the config-changed event that the
5
+ * `payload:dev-config-reload` Vite plugin broadcasts.
6
+ *
7
+ * Imported for its side effect by `initReq.server.ts`, the adapter's only
8
+ * `getPayload` call site, so the strategy is registered before an instance can
9
+ * be built. Registration is module-scoped on both ends: this runs inside the
10
+ * app's server graph and so resolves the same copy of `payload` that
11
+ * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
12
+ * its own listener against its own copy.
13
+ *
14
+ * Vite re-evaluates this module on a program reload, which drops the listeners
15
+ * the previous instance had collected. `getPayload` reconnects on its next call
16
+ * because the registered strategy is a new object - see `connectDevReload`.
17
+ *
18
+ * `import.meta.hot` is only defined during dev serve, so this is inert in a
19
+ * production build.
20
+ */ const hot = import.meta.hot;
21
+ if (hot) {
22
+ const listeners = new Set();
23
+ hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
24
+ for (const onReload of listeners){
25
+ onReload();
26
+ }
27
+ });
28
+ registerDevReloadStrategy({
29
+ connect: (onReload)=>{
30
+ listeners.add(onReload);
31
+ return ()=>{
32
+ listeners.delete(onReload);
33
+ };
34
+ }
35
+ });
36
+ }
37
+
38
+ //# sourceMappingURL=devConfigReload.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `initReq.server.ts`, the adapter's only\n * `getPayload` call site, so the strategy is registered before an instance can\n * be built. Registration is module-scoped on both ends: this runs inside the\n * app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n const listeners = new Set<() => void>()\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n registerDevReloadStrategy({\n connect: (onReload) => {\n listeners.add(onReload)\n\n return () => {\n listeners.delete(onReload)\n }\n },\n })\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","listeners","Set","on","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;;;CAiBC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACP,MAAMC,YAAY,IAAIC;IAEtBF,IAAIG,EAAE,CAACJ,8BAA8B;QACnC,KAAK,MAAMK,YAAYH,UAAW;YAChCG;QACF;IACF;IAEAN,0BAA0B;QACxBO,SAAS,CAACD;YACRH,UAAUK,GAAG,CAACF;YAEd,OAAO;gBACLH,UAAUM,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
3
+ * the Payload config (or anything it imports) changes on disk.
4
+ *
5
+ * Kept in its own module so the Vite plugin can name the event without pulling
6
+ * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
7
+ */
8
+ export declare const PAYLOAD_CONFIG_CHANGED_EVENT = "payload:config-changed";
9
+ //# sourceMappingURL=devConfigReloadEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devConfigReloadEvent.d.ts","sourceRoot":"","sources":["../../src/utilities/devConfigReloadEvent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,2BAA2B,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
3
+ * the Payload config (or anything it imports) changes on disk.
4
+ *
5
+ * Kept in its own module so the Vite plugin can name the event without pulling
6
+ * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
7
+ */ export const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed';
8
+
9
+ //# sourceMappingURL=devConfigReloadEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/devConfigReloadEvent.ts"],"sourcesContent":["/**\n * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when\n * the Payload config (or anything it imports) changes on disk.\n *\n * Kept in its own module so the Vite plugin can name the event without pulling\n * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.\n */\nexport const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed'\n"],"names":["PAYLOAD_CONFIG_CHANGED_EVENT"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,+BAA+B,yBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"getRequestLocale.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAOrD,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkCjG"}
1
+ {"version":3,"file":"getRequestLocale.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKrD,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkCjG"}
@@ -1,6 +1,5 @@
1
- import { upsertPreferences } from '@payloadcms/ui/rsc';
1
+ import { getPreferences, upsertPreferences } from '@payloadcms/ui/rsc';
2
2
  import { findLocaleFromCode } from '@payloadcms/ui/shared';
3
- import { getPreferences } from './getPreferences.js';
4
3
  export async function getRequestLocale({ req }) {
5
4
  if (req.payload.config.localization) {
6
5
  const localeFromParams = req.query.locale;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\nimport { getPreferences } from './getPreferences.js'\n\ntype GetRequestLocaleArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocaleArgs): Promise<Locale | undefined> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (req.user && localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n const userLocale =\n req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )\n\n return (\n userLocale ??\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n ) ??\n undefined\n )\n }\n\n return undefined\n}\n"],"names":["upsertPreferences","findLocaleFromCode","getPreferences","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","user","key","value","userLocale","id","collection","defaultLocale","undefined"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,kBAAkB,QAAQ,wBAAuB;AAE1D,SAASC,cAAc,QAAQ,sBAAqB;AAMpD,OAAO,eAAeC,iBAAiB,EAAEC,GAAG,EAAwB;IAClE,IAAIA,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACnC,MAAMC,mBAAmBJ,IAAIK,KAAK,CAACC,MAAM;QAEzC,IAAIN,IAAIO,IAAI,IAAIH,kBAAkB;YAChC,MAAMR,kBAAkC;gBAAEY,KAAK;gBAAUR;gBAAKS,OAAOL;YAAiB;QACxF;QAEA,MAAMM,aACJV,IAAIO,IAAI,IACRV,mBACEG,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,oBAEI,CAAA,MAAMN,eACJ,UACAE,IAAIC,OAAO,EACXD,IAAIO,IAAI,CAACI,EAAE,EACXX,IAAIO,IAAI,CAACK,UAAU,CACrB,GACCH;QAGT,OACEC,cACAb,mBACEG,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACU,aAAa,IAAI,SAEnDC;IAEJ;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { getPreferences, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\ntype GetRequestLocaleArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocaleArgs): Promise<Locale | undefined> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (req.user && localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n const userLocale =\n req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )\n\n return (\n userLocale ??\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n ) ??\n undefined\n )\n }\n\n return undefined\n}\n"],"names":["getPreferences","upsertPreferences","findLocaleFromCode","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","user","key","value","userLocale","id","collection","defaultLocale","undefined"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,qBAAoB;AACtE,SAASC,kBAAkB,QAAQ,wBAAuB;AAM1D,OAAO,eAAeC,iBAAiB,EAAEC,GAAG,EAAwB;IAClE,IAAIA,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACnC,MAAMC,mBAAmBJ,IAAIK,KAAK,CAACC,MAAM;QAEzC,IAAIN,IAAIO,IAAI,IAAIH,kBAAkB;YAChC,MAAMP,kBAAkC;gBAAEW,KAAK;gBAAUR;gBAAKS,OAAOL;YAAiB;QACxF;QAEA,MAAMM,aACJV,IAAIO,IAAI,IACRT,mBACEE,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,oBAEI,CAAA,MAAMR,eACJ,UACAI,IAAIC,OAAO,EACXD,IAAIO,IAAI,CAACI,EAAE,EACXX,IAAIO,IAAI,CAACK,UAAU,CACrB,GACCH;QAGT,OACEC,cACAZ,mBACEE,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACU,aAAa,IAAI,SAEnDC;IAEJ;IAEA,OAAOA;AACT"}
@@ -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,20 +1,2 @@
1
- import type { ServerFunctionHandler } from 'payload';
2
- /**
3
- * Server function dispatcher for TanStack Start.
4
- *
5
- * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
6
- * exact same set of handlers — both adapters share `sharedServerFunctions`
7
- * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
8
- *
9
- * Pipes the result through `serializeForRsc`, which converts any React
10
- * elements left in the response (e.g. `state[path].customComponents.Field`
11
- * produced by `buildFormState`, the `List` / `Document` nodes returned by
12
- * `render-list` / `render-document`) into RSC "renderable handles" via
13
- * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
14
- * `$RSC` serialization adapter then ships those handles to the client as
15
- * Flight payloads — so this dispatcher must be invoked from a context that
16
- * uses TanStack's wire format (e.g. `createServerFn`), not raw
17
- * `JSON.stringify`.
18
- */
19
- export declare const handleServerFunctions: ServerFunctionHandler;
1
+ export declare const handleServerFunctions: import("payload").ServerFunctionHandler;
20
2
  //# sourceMappingURL=handleServerFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAwB/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAkCnC,CAAA"}
1
+ {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,yCAGhC,CAAA"}
@@ -1,60 +1,12 @@
1
- import { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn';
2
- import { _internal_renderFieldHandler } from '@payloadcms/ui/rsc';
3
- import { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry';
4
- import { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn';
5
- import { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn';
6
- import { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots';
7
- import { RenderRSCComponent } from '../rsc/renderPayloadRSC.js';
1
+ import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions';
8
2
  import { initReq } from './initReq.server.js';
9
3
  import { serializeForRsc } from './serializeForRsc.js';
10
- import { switchLanguageHandler } from './serverFunctionHandlers.js';
11
- const baseServerFunctions = {
12
- ...sharedServerFunctions,
13
- 'get-default-layout': getDefaultLayoutHandler,
14
- 'render-document-slots': renderDocumentSlotsHandler,
15
- 'render-field': _internal_renderFieldHandler,
16
- 'render-tab': renderTabHandler,
17
- 'render-widget': renderWidgetHandler,
18
- 'switch-language': switchLanguageHandler
19
- };
20
- /**
21
- * Server function dispatcher for TanStack Start.
22
- *
23
- * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
24
- * exact same set of handlers — both adapters share `sharedServerFunctions`
25
- * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
26
- *
27
- * Pipes the result through `serializeForRsc`, which converts any React
28
- * elements left in the response (e.g. `state[path].customComponents.Field`
29
- * produced by `buildFormState`, the `List` / `Document` nodes returned by
30
- * `render-list` / `render-document`) into RSC "renderable handles" via
31
- * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
32
- * `$RSC` serialization adapter then ships those handles to the client as
33
- * Flight payloads — so this dispatcher must be invoked from a context that
34
- * uses TanStack's wire format (e.g. `createServerFn`), not raw
35
- * `JSON.stringify`.
36
- */ export const handleServerFunctions = async (args)=>{
37
- const { name: fnKey, args: fnArgs, config: configPromise, importMap, serverFunctions: extraServerFunctions } = args;
38
- const { cookies, locale, permissions, req } = await initReq({
39
- configPromise,
40
- importMap
41
- });
42
- const augmentedArgs = {
43
- ...fnArgs,
44
- cookies,
45
- importMap,
46
- locale,
47
- mode: 'rsc',
48
- permissions,
49
- renderComponent: RenderRSCComponent,
50
- req
51
- };
52
- const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
53
- if (!fn) {
54
- throw new Error(`Unknown Server Function: ${fnKey}`);
55
- }
56
- const result = await fn(augmentedArgs);
57
- return await serializeForRsc(result);
58
- };
4
+ export const handleServerFunctions = createServerFunctionHandler({
5
+ initReq: ({ configPromise, importMap })=>initReq({
6
+ configPromise,
7
+ importMap
8
+ }),
9
+ transformResult: serializeForRsc
10
+ });
59
11
 
60
12
  //# sourceMappingURL=handleServerFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { DefaultServerFunctionArgs, ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn'\nimport { _internal_renderFieldHandler } from '@payloadcms/ui/rsc'\nimport { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry'\nimport { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn'\nimport { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn'\nimport { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots'\n\nimport { RenderRSCComponent } from '../rsc/renderPayloadRSC.js'\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\nimport { switchLanguageHandler } from './serverFunctionHandlers.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n ...sharedServerFunctions,\n 'get-default-layout': getDefaultLayoutHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-tab': renderTabHandler,\n 'render-widget': renderWidgetHandler,\n 'switch-language': switchLanguageHandler,\n}\n\n/**\n * Server function dispatcher for TanStack Start.\n *\n * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the\n * exact same set of handlers — both adapters share `sharedServerFunctions`\n * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.\n *\n * Pipes the result through `serializeForRsc`, which converts any React\n * elements left in the response (e.g. `state[path].customComponents.Field`\n * produced by `buildFormState`, the `List` / `Document` nodes returned by\n * `render-list` / `render-document`) into RSC \"renderable handles\" via\n * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's\n * `$RSC` serialization adapter then ships those handles to the client as\n * Flight payloads — so this dispatcher must be invoked from a context that\n * uses TanStack's wire format (e.g. `createServerFn`), not raw\n * `JSON.stringify`.\n */\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req } = await initReq({\n configPromise,\n importMap,\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n mode: 'rsc',\n permissions,\n renderComponent: RenderRSCComponent,\n req,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n const result = await fn(augmentedArgs)\n\n return await serializeForRsc(result)\n}\n"],"names":["renderTabHandler","_internal_renderFieldHandler","sharedServerFunctions","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentSlotsHandler","RenderRSCComponent","initReq","serializeForRsc","switchLanguageHandler","baseServerFunctions","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","cookies","locale","permissions","req","augmentedArgs","mode","renderComponent","fn","Error","result"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,4DAA2D;AAC5F,SAASC,4BAA4B,QAAQ,qBAAoB;AACjE,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,uBAAuB,QAAQ,gGAA+F;AACvI,SAASC,mBAAmB,QAAQ,4FAA2F;AAC/H,SAASC,0BAA0B,QAAQ,oDAAmD;AAE9F,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,qBAAqB,QAAQ,8BAA6B;AAEnE,MAAMC,sBAAgE;IACpE,GAAGR,qBAAqB;IACxB,sBAAsBC;IACtB,yBAAyBE;IACzB,gBAAgBJ;IAChB,cAAcD;IACd,iBAAiBI;IACjB,mBAAmBK;AACrB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAME,wBAA+C,OAAOC;IACjE,MAAM,EACJC,MAAMC,KAAK,EACXF,MAAMG,MAAM,EACZC,QAAQC,aAAa,EACrBC,SAAS,EACTC,iBAAiBC,oBAAoB,EACtC,GAAGR;IAEJ,MAAM,EAAES,OAAO,EAAEC,MAAM,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAG,MAAMjB,QAAQ;QAC1DU;QACAC;IACF;IAEA,MAAMO,gBAA2C;QAC/C,GAAGV,MAAM;QACTM;QACAH;QACAI;QACAI,MAAM;QACNH;QACAI,iBAAiBrB;QACjBkB;IACF;IAEA,MAAMI,KAAKR,sBAAsB,CAACN,MAAM,IAAIJ,mBAAmB,CAACI,MAAM;IAEtE,IAAI,CAACc,IAAI;QACP,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEf,OAAO;IACrD;IAEA,MAAMgB,SAAS,MAAMF,GAAGH;IAExB,OAAO,MAAMjB,gBAAgBsB;AAC/B,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions'\n\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\n\nexport const handleServerFunctions = createServerFunctionHandler({\n initReq: ({ configPromise, importMap }) => initReq({ configPromise, importMap }),\n transformResult: serializeForRsc,\n})\n"],"names":["createServerFunctionHandler","initReq","serializeForRsc","handleServerFunctions","configPromise","importMap","transformResult"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iDAAgD;AAE5F,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,OAAO,MAAMC,wBAAwBH,4BAA4B;IAC/DC,SAAS,CAAC,EAAEG,aAAa,EAAEC,SAAS,EAAE,GAAKJ,QAAQ;YAAEG;YAAeC;QAAU;IAC9EC,iBAAiBJ;AACnB,GAAE"}
@@ -1,5 +1,6 @@
1
1
  import type { ImportMap, InitReqResult, SanitizedConfig, ServerAdapter } from 'payload';
2
2
  import { createLocalReq } from 'payload';
3
+ import './devConfigReload.server.js';
3
4
  /**
4
5
  * Initializes a Payload request object from the current TanStack Start server context.
5
6
  * Uses `getRequest()` from `@tanstack/react-start/server` to access the incoming request.
@@ -1 +1 @@
1
- {"version":3,"file":"initReq.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,wBAAsB,OAAO,CAAC,EAC5B,aAAa,EACb,SAAS,EACT,SAAS,EACT,aAAqC,GACtC,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,OAAO,CAAC,aAAa,CAAC,CAkFzB"}
1
+ {"version":3,"file":"initReq.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAKhB,OAAO,6BAA6B,CAAA;AAIpC;;;GAGG;AACH,wBAAsB,OAAO,CAAC,EAC5B,aAAa,EACb,SAAS,EACT,SAAS,EACT,aAAqC,GACtC,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,OAAO,CAAC,aAAa,CAAC,CAkFzB"}