@payloadcms/tanstack-start 4.0.0-internal.164164a → 4.0.0-internal.16f218d

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 (195) hide show
  1. package/dist/adapters/handleServerFunctions.d.ts +3 -0
  2. package/dist/adapters/handleServerFunctions.d.ts.map +1 -0
  3. package/dist/adapters/handleServerFunctions.js +17 -0
  4. package/dist/adapters/handleServerFunctions.js.map +1 -0
  5. package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
  6. package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
  7. package/dist/adapters/layout/RootProviders/index.js +21 -0
  8. package/dist/adapters/layout/RootProviders/index.js.map +1 -0
  9. package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout/index.d.ts} +32 -4
  10. package/dist/adapters/layout/index.d.ts.map +1 -0
  11. package/dist/adapters/layout/index.js +107 -0
  12. package/dist/adapters/layout/index.js.map +1 -0
  13. package/dist/adapters/layout/lazy.d.ts +7 -0
  14. package/dist/adapters/layout/lazy.d.ts.map +1 -0
  15. package/dist/adapters/layout/lazy.js +17 -0
  16. package/dist/adapters/layout/lazy.js.map +1 -0
  17. package/dist/adapters/layout/outlet.d.ts +4 -0
  18. package/dist/adapters/layout/outlet.d.ts.map +1 -0
  19. package/dist/adapters/layout/outlet.js +9 -0
  20. package/dist/adapters/layout/outlet.js.map +1 -0
  21. package/dist/adapters/layout/server.d.ts +23 -0
  22. package/dist/adapters/layout/server.d.ts.map +1 -0
  23. package/dist/adapters/layout/server.js +65 -0
  24. package/dist/adapters/layout/server.js.map +1 -0
  25. package/dist/{utilities/meta.d.ts → adapters/metadata.d.ts} +10 -1
  26. package/dist/adapters/metadata.d.ts.map +1 -0
  27. package/dist/{utilities/meta.js → adapters/metadata.js} +60 -1
  28. package/dist/adapters/metadata.js.map +1 -0
  29. package/dist/{elements/RouterAdapter/index.d.ts → adapters/router.d.ts} +1 -1
  30. package/dist/adapters/router.d.ts.map +1 -0
  31. package/dist/{elements/RouterAdapter/index.js → adapters/router.js} +43 -17
  32. package/dist/adapters/router.js.map +1 -0
  33. package/dist/{utilities/serverAdapter.server.d.ts → adapters/server.d.ts} +1 -1
  34. package/dist/adapters/server.d.ts.map +1 -0
  35. package/dist/{utilities/serverAdapter.server.js → adapters/server.js} +3 -30
  36. package/dist/adapters/server.js.map +1 -0
  37. package/dist/{routes/adminRoutes.d.ts → adapters/views/index.d.ts} +14 -28
  38. package/dist/adapters/views/index.d.ts.map +1 -0
  39. package/dist/adapters/views/index.js +101 -0
  40. package/dist/adapters/views/index.js.map +1 -0
  41. package/dist/adapters/views/lazy.d.ts +4 -0
  42. package/dist/adapters/views/lazy.d.ts.map +1 -0
  43. package/dist/adapters/views/lazy.js +44 -0
  44. package/dist/adapters/views/lazy.js.map +1 -0
  45. package/dist/{utilities/loadAdminPage.d.ts → adapters/views/server.d.ts} +12 -6
  46. package/dist/adapters/views/server.d.ts.map +1 -0
  47. package/dist/{utilities/loadAdminPage.js → adapters/views/server.js} +25 -78
  48. package/dist/adapters/views/server.js.map +1 -0
  49. package/dist/auth/login.js +1 -1
  50. package/dist/auth/login.js.map +1 -1
  51. package/dist/auth/logout.js +1 -1
  52. package/dist/auth/logout.js.map +1 -1
  53. package/dist/auth/refresh.js +1 -1
  54. package/dist/auth/refresh.js.map +1 -1
  55. package/dist/exports/client/layout.d.ts +2 -0
  56. package/dist/exports/client/layout.d.ts.map +1 -0
  57. package/dist/exports/client/layout.js +4 -0
  58. package/dist/exports/client/layout.js.map +1 -0
  59. package/dist/exports/client.d.ts +3 -6
  60. package/dist/exports/client.d.ts.map +1 -1
  61. package/dist/exports/client.js +3 -6
  62. package/dist/exports/client.js.map +1 -1
  63. package/dist/exports/layouts.d.ts +2 -3
  64. package/dist/exports/layouts.d.ts.map +1 -1
  65. package/dist/exports/layouts.js +1 -2
  66. package/dist/exports/layouts.js.map +1 -1
  67. package/dist/exports/routes.d.ts +2 -0
  68. package/dist/exports/routes.d.ts.map +1 -0
  69. package/dist/exports/routes.js +3 -0
  70. package/dist/exports/routes.js.map +1 -0
  71. package/dist/exports/server.d.ts +6 -11
  72. package/dist/exports/server.d.ts.map +1 -1
  73. package/dist/exports/server.js +6 -11
  74. package/dist/exports/server.js.map +1 -1
  75. package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -3
  76. package/dist/routes/graphql/handler.server.d.ts.map +1 -0
  77. package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +9 -6
  78. package/dist/routes/graphql/handler.server.js.map +1 -0
  79. package/dist/routes/rest/handler.server.d.ts +11 -0
  80. package/dist/routes/rest/handler.server.d.ts.map +1 -0
  81. package/dist/routes/rest/handler.server.js +14 -0
  82. package/dist/routes/rest/handler.server.js.map +1 -0
  83. package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +5 -4
  84. package/dist/routes/rest/index.d.ts.map +1 -0
  85. package/dist/routes/{apiRoute.js → rest/index.js} +6 -5
  86. package/dist/routes/rest/index.js.map +1 -0
  87. package/dist/rsc/CollectionCards.js +1 -1
  88. package/dist/rsc/CollectionCards.js.map +1 -1
  89. package/dist/utilities/devConfigReload.server.d.ts +2 -0
  90. package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
  91. package/dist/utilities/devConfigReload.server.js +61 -0
  92. package/dist/utilities/devConfigReload.server.js.map +1 -0
  93. package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
  94. package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
  95. package/dist/utilities/devConfigReloadEvent.js +9 -0
  96. package/dist/utilities/devConfigReloadEvent.js.map +1 -0
  97. package/dist/utilities/getRequestI18n.server.d.ts +1 -1
  98. package/dist/utilities/getRequestI18n.server.js +1 -1
  99. package/dist/utilities/getRequestI18n.server.js.map +1 -1
  100. package/dist/utilities/initAdminContext.server.d.ts +9 -0
  101. package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
  102. package/dist/utilities/initAdminContext.server.js +13 -0
  103. package/dist/utilities/initAdminContext.server.js.map +1 -0
  104. package/dist/utilities/serverFunctionClient.d.ts +2 -23
  105. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  106. package/dist/utilities/serverFunctionClient.js +12 -101
  107. package/dist/utilities/serverFunctionClient.js.map +1 -1
  108. package/dist/withPayload/config/external.d.ts +19 -21
  109. package/dist/withPayload/config/external.d.ts.map +1 -1
  110. package/dist/withPayload/config/external.js +38 -32
  111. package/dist/withPayload/config/external.js.map +1 -1
  112. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
  113. package/dist/withPayload/config/optimizeDeps.js +44 -7
  114. package/dist/withPayload/config/optimizeDeps.js.map +1 -1
  115. package/dist/withPayload/devConfigReload.d.ts +14 -0
  116. package/dist/withPayload/devConfigReload.d.ts.map +1 -0
  117. package/dist/withPayload/devConfigReload.js +84 -0
  118. package/dist/withPayload/devConfigReload.js.map +1 -0
  119. package/dist/withPayload/importProtection.js +1 -1
  120. package/dist/withPayload/importProtection.js.map +1 -1
  121. package/dist/withPayload/index.d.ts +24 -11
  122. package/dist/withPayload/index.d.ts.map +1 -1
  123. package/dist/withPayload/index.js +50 -19
  124. package/dist/withPayload/index.js.map +1 -1
  125. package/dist/withPayload/workarounds/stripDistStyleImports.js +1 -1
  126. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
  127. package/package.json +35 -29
  128. package/dist/elements/RouterAdapter/index.d.ts.map +0 -1
  129. package/dist/elements/RouterAdapter/index.js.map +0 -1
  130. package/dist/layouts/Root/getLayoutData.d.ts +0 -34
  131. package/dist/layouts/Root/getLayoutData.d.ts.map +0 -1
  132. package/dist/layouts/Root/getLayoutData.js +0 -97
  133. package/dist/layouts/Root/getLayoutData.js.map +0 -1
  134. package/dist/layouts/Root/withPayloadRoot.d.ts.map +0 -1
  135. package/dist/layouts/Root/withPayloadRoot.js +0 -91
  136. package/dist/layouts/Root/withPayloadRoot.js.map +0 -1
  137. package/dist/node/cssLoader.d.mts +0 -25
  138. package/dist/node/cssLoader.d.mts.map +0 -1
  139. package/dist/node/cssLoader.js +0 -70
  140. package/dist/node/cssLoader.js.map +0 -1
  141. package/dist/node/cssLoader.mjs +0 -75
  142. package/dist/node/registerCssLoader.d.mts +0 -2
  143. package/dist/node/registerCssLoader.d.mts.map +0 -1
  144. package/dist/node/registerCssLoader.js +0 -10
  145. package/dist/node/registerCssLoader.js.map +0 -1
  146. package/dist/node/registerCssLoader.mjs +0 -10
  147. package/dist/routes/adminRoutes.d.ts.map +0 -1
  148. package/dist/routes/adminRoutes.js +0 -116
  149. package/dist/routes/adminRoutes.js.map +0 -1
  150. package/dist/routes/apiRoute.d.ts.map +0 -1
  151. package/dist/routes/apiRoute.js.map +0 -1
  152. package/dist/routes/layoutRoute.d.ts +0 -26
  153. package/dist/routes/layoutRoute.d.ts.map +0 -1
  154. package/dist/routes/layoutRoute.js +0 -58
  155. package/dist/routes/layoutRoute.js.map +0 -1
  156. package/dist/utilities/devReloadStrategy.d.ts +0 -10
  157. package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
  158. package/dist/utilities/devReloadStrategy.js +0 -27
  159. package/dist/utilities/devReloadStrategy.js.map +0 -1
  160. package/dist/utilities/getRequestLocale.d.ts +0 -7
  161. package/dist/utilities/getRequestLocale.d.ts.map +0 -1
  162. package/dist/utilities/getRequestLocale.js +0 -19
  163. package/dist/utilities/getRequestLocale.js.map +0 -1
  164. package/dist/utilities/graphqlHandler.server.d.ts.map +0 -1
  165. package/dist/utilities/graphqlHandler.server.js.map +0 -1
  166. package/dist/utilities/handleAPIRoute.server.d.ts +0 -11
  167. package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
  168. package/dist/utilities/handleAPIRoute.server.js +0 -17
  169. package/dist/utilities/handleAPIRoute.server.js.map +0 -1
  170. package/dist/utilities/handleServerFunctions.d.ts +0 -2
  171. package/dist/utilities/handleServerFunctions.d.ts.map +0 -1
  172. package/dist/utilities/handleServerFunctions.js +0 -12
  173. package/dist/utilities/handleServerFunctions.js.map +0 -1
  174. package/dist/utilities/initReq.server.d.ts +0 -19
  175. package/dist/utilities/initReq.server.d.ts.map +0 -1
  176. package/dist/utilities/initReq.server.js +0 -87
  177. package/dist/utilities/initReq.server.js.map +0 -1
  178. package/dist/utilities/loadAdminPage.d.ts.map +0 -1
  179. package/dist/utilities/loadAdminPage.js.map +0 -1
  180. package/dist/utilities/loadLayoutData.d.ts +0 -15
  181. package/dist/utilities/loadLayoutData.d.ts.map +0 -1
  182. package/dist/utilities/loadLayoutData.js +0 -23
  183. package/dist/utilities/loadLayoutData.js.map +0 -1
  184. package/dist/utilities/meta.d.ts.map +0 -1
  185. package/dist/utilities/meta.js.map +0 -1
  186. package/dist/utilities/serializeForRsc.d.ts +0 -26
  187. package/dist/utilities/serializeForRsc.d.ts.map +0 -1
  188. package/dist/utilities/serializeForRsc.js +0 -122
  189. package/dist/utilities/serializeForRsc.js.map +0 -1
  190. package/dist/utilities/serverAdapter.server.d.ts.map +0 -1
  191. package/dist/utilities/serverAdapter.server.js.map +0 -1
  192. package/dist/utilities/toSerializable.d.ts +0 -2
  193. package/dist/utilities/toSerializable.d.ts.map +0 -1
  194. package/dist/utilities/toSerializable.js +0 -111
  195. package/dist/utilities/toSerializable.js.map +0 -1
@@ -1,16 +1,17 @@
1
+ import '../../utilities/devConfigReload.server.js';
1
2
  /**
2
3
  * Builds the method handlers for the Payload REST/GraphQL catch-all
3
4
  * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
4
5
  * import) since the package cannot resolve the consumer's config.
5
6
  *
6
- * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
7
- * the server-only `handleAPIRoute` graph never reaches the client bundle.
7
+ * Imported from `@payloadcms/tanstack-start/routes` so API routes do not load
8
+ * the admin rendering graph from the shared server entrypoint.
8
9
  *
9
10
  * Spread the result into a literal `server.handlers` key so TanStack Start's
10
11
  * client compiler can statically see — and prune — the server-only route:
11
12
  *
12
13
  * ```ts
13
- * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
14
+ * import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
14
15
  *
15
16
  * export const Route = createFileRoute('/_payload/api/$')({
16
17
  * server: {
@@ -24,7 +25,7 @@
24
25
  * key, leaking the config graph into the client bundle.
25
26
  */ export function payloadApiHandlers({ getConfig }) {
26
27
  const handler = async ({ request })=>{
27
- const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js');
28
+ const { handleAPIRoute } = await import('./handler.server.js');
28
29
  return handleAPIRoute({
29
30
  config: await getConfig(),
30
31
  request
@@ -40,4 +41,4 @@
40
41
  };
41
42
  }
42
43
 
43
- //# sourceMappingURL=apiRoute.js.map
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/routes/rest/index.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport '../../utilities/devConfigReload.server.js'\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/routes` so API routes do not load\n * the admin rendering graph from the shared server entrypoint.\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/routes'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('./handler.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAEA,OAAO,4CAA2C;AAIlD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CollectionCardsClient } from '@payloadcms/ui';
2
3
  import { getCollectionCardsData } from '@payloadcms/ui/server';
3
- import { CollectionCardsClient } from '@payloadcms/ui/widgets/CollectionCards/index.client';
4
4
  import React from 'react';
5
5
  export async function CollectionCards(props) {
6
6
  const data = await getCollectionCardsData(props.req);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rsc/CollectionCards.tsx"],"sourcesContent":["import type { WidgetServerProps } from 'payload'\n\nimport { getCollectionCardsData } from '@payloadcms/ui/server'\nimport { CollectionCardsClient } from '@payloadcms/ui/widgets/CollectionCards/index.client'\nimport React from 'react'\n\nexport async function CollectionCards(props: WidgetServerProps) {\n const data = await getCollectionCardsData(props.req)\n\n return <CollectionCardsClient {...data} />\n}\n"],"names":["getCollectionCardsData","CollectionCardsClient","React","CollectionCards","props","data","req"],"mappings":";AAEA,SAASA,sBAAsB,QAAQ,wBAAuB;AAC9D,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,OAAOC,WAAW,QAAO;AAEzB,OAAO,eAAeC,gBAAgBC,KAAwB;IAC5D,MAAMC,OAAO,MAAML,uBAAuBI,MAAME,GAAG;IAEnD,qBAAO,KAACL;QAAuB,GAAGI,IAAI;;AACxC"}
1
+ {"version":3,"sources":["../../src/rsc/CollectionCards.tsx"],"sourcesContent":["import type { WidgetServerProps } from 'payload'\n\nimport { CollectionCardsClient } from '@payloadcms/ui'\nimport { getCollectionCardsData } from '@payloadcms/ui/server'\nimport React from 'react'\n\nexport async function CollectionCards(props: WidgetServerProps) {\n const data = await getCollectionCardsData(props.req)\n\n return <CollectionCardsClient {...data} />\n}\n"],"names":["CollectionCardsClient","getCollectionCardsData","React","CollectionCards","props","data","req"],"mappings":";AAEA,SAASA,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,sBAAsB,QAAQ,wBAAuB;AAC9D,OAAOC,WAAW,QAAO;AAEzB,OAAO,eAAeC,gBAAgBC,KAAwB;IAC5D,MAAMC,OAAO,MAAMJ,uBAAuBG,MAAME,GAAG;IAEnD,qBAAO,KAACN;QAAuB,GAAGK,IAAI;;AACxC"}
@@ -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,61 @@
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 by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.
8
+ * Registration is module-scoped on both ends: this runs inside the app's server graph and so resolves the same copy of `payload` that
9
+ * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
10
+ * its own listener against its own copy.
11
+ *
12
+ * Vite re-evaluates this module on a program reload, which drops the listeners
13
+ * the previous instance had collected. `getPayload` reconnects on its next call
14
+ * because the registered strategy is a new object - see `connectDevReload`.
15
+ *
16
+ * `import.meta.hot` is only defined during dev serve, so this is inert in a
17
+ * production build.
18
+ */ const hot = import.meta.hot;
19
+ if (hot) {
20
+ registerDevReloadStrategy(createConfigChangedStrategy({
21
+ hot
22
+ }));
23
+ }
24
+ /**
25
+ * Builds a dev reload strategy that forwards the config-changed event to every
26
+ * connected instance.
27
+ *
28
+ * After a program reload, the first request to re-import this module replaces
29
+ * the old listener with a new one, but the cached Payload instance only connects
30
+ * to it on its next `getPayload` call - and a request such as a frontend page
31
+ * render may never make one. An event that lands in that gap has no one to
32
+ * notify, so it is held and replayed to the next connection instead of being
33
+ * dropped - which would otherwise leave the instance serving the old config
34
+ * indefinitely.
35
+ */ function createConfigChangedStrategy({ hot }) {
36
+ const listeners = new Set();
37
+ let hasPendingReload = false;
38
+ hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
39
+ if (listeners.size === 0) {
40
+ hasPendingReload = true;
41
+ return;
42
+ }
43
+ for (const onReload of listeners){
44
+ onReload();
45
+ }
46
+ });
47
+ return {
48
+ connect: (onReload)=>{
49
+ listeners.add(onReload);
50
+ if (hasPendingReload) {
51
+ hasPendingReload = false;
52
+ onReload();
53
+ }
54
+ return ()=>{
55
+ listeners.delete(onReload);
56
+ };
57
+ }
58
+ };
59
+ }
60
+
61
+ //# 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 by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.\n * Registration is module-scoped on both ends: this runs inside the app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n registerDevReloadStrategy(createConfigChangedStrategy({ hot }))\n}\n\n/**\n * Builds a dev reload strategy that forwards the config-changed event to every\n * connected instance.\n *\n * After a program reload, the first request to re-import this module replaces\n * the old listener with a new one, but the cached Payload instance only connects\n * to it on its next `getPayload` call - and a request such as a frontend page\n * render may never make one. An event that lands in that gap has no one to\n * notify, so it is held and replayed to the next connection instead of being\n * dropped - which would otherwise leave the instance serving the old config\n * indefinitely.\n */\nfunction createConfigChangedStrategy({ hot }: { hot: ViteHotContext }): {\n connect: (onReload: () => void) => () => void\n} {\n const listeners = new Set<() => void>()\n let hasPendingReload = false\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n if (listeners.size === 0) {\n hasPendingReload = true\n return\n }\n\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n return {\n connect: (onReload) => {\n listeners.add(onReload)\n\n if (hasPendingReload) {\n hasPendingReload = false\n onReload()\n }\n\n return () => {\n listeners.delete(onReload)\n }\n },\n }\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","createConfigChangedStrategy","listeners","Set","hasPendingReload","on","size","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;CAeC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACPF,0BAA0BG,4BAA4B;QAAED;IAAI;AAC9D;AAEA;;;;;;;;;;;CAWC,GACD,SAASC,4BAA4B,EAAED,GAAG,EAA2B;IAGnE,MAAME,YAAY,IAAIC;IACtB,IAAIC,mBAAmB;IAEvBJ,IAAIK,EAAE,CAACN,8BAA8B;QACnC,IAAIG,UAAUI,IAAI,KAAK,GAAG;YACxBF,mBAAmB;YACnB;QACF;QAEA,KAAK,MAAMG,YAAYL,UAAW;YAChCK;QACF;IACF;IAEA,OAAO;QACLC,SAAS,CAACD;YACRL,UAAUO,GAAG,CAACF;YAEd,IAAIH,kBAAkB;gBACpBA,mBAAmB;gBACnBG;YACF;YAEA,OAAO;gBACLL,UAAUQ,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
@@ -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"}
@@ -2,7 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
2
2
  import type { SanitizedConfig } from 'payload';
3
3
  /**
4
4
  * Resolves the client `I18n` for the current TanStack Start request without a
5
- * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
5
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
6
6
  * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
7
7
  * needs `config` + `i18n` to translate admin-page titles.
8
8
  */
@@ -3,7 +3,7 @@ import { getRequest } from '@tanstack/react-start/server';
3
3
  import { getRequestLanguage, parseCookies } from 'payload';
4
4
  /**
5
5
  * Resolves the client `I18n` for the current TanStack Start request without a
6
- * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
6
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
7
7
  * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
8
8
  * needs `config` + `i18n` to translate admin-page titles.
9
9
  */ export async function getRequestI18n({ config }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initReq` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
@@ -0,0 +1,9 @@
1
+ import type { ServerAdapter } from 'payload';
2
+ import type { InitAdminContextArgs } from 'payload/internal';
3
+ import './devConfigReload.server.js';
4
+ type TanStackInitAdminContextArgs = {
5
+ serverAdapter?: ServerAdapter;
6
+ } & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>;
7
+ export declare const initAdminContext: ({ serverAdapter, ...args }: TanStackInitAdminContextArgs) => Promise<import("payload").AdminContext>;
8
+ export {};
9
+ //# sourceMappingURL=initAdminContext.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initAdminContext.server.d.ts","sourceRoot":"","sources":["../../src/utilities/initAdminContext.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAO5D,OAAO,6BAA6B,CAAA;AAGpC,KAAK,4BAA4B,GAAG;IAClC,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC,CAAA;AAExE,eAAO,MAAM,gBAAgB,+BAG1B,4BAA4B,4CAK3B,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { getRequest } from '@tanstack/react-start/server';
2
+ import { initAdminContext as initPayloadAdminContext } from 'payload/internal';
3
+ // Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.
4
+ // Side-effect only, and a no-op outside of dev serve.
5
+ import './devConfigReload.server.js';
6
+ import { tanstackServerAdapter } from '../adapters/server.js';
7
+ export const initAdminContext = ({ serverAdapter = tanstackServerAdapter, ...args })=>initPayloadAdminContext({
8
+ ...args,
9
+ requestURL: getRequest().url,
10
+ serverAdapter
11
+ });
12
+
13
+ //# sourceMappingURL=initAdminContext.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/initAdminContext.server.ts"],"sourcesContent":["import type { ServerAdapter } from 'payload'\nimport type { InitAdminContextArgs } from 'payload/internal'\n\nimport { getRequest } from '@tanstack/react-start/server'\nimport { initAdminContext as initPayloadAdminContext } from 'payload/internal'\n\n// Registers the dev reload strategy before `initPayloadAdminContext` can build an instance.\n// Side-effect only, and a no-op outside of dev serve.\nimport './devConfigReload.server.js'\nimport { tanstackServerAdapter } from '../adapters/server.js'\n\ntype TanStackInitAdminContextArgs = {\n serverAdapter?: ServerAdapter\n} & Omit<InitAdminContextArgs, 'cache' | 'requestURL' | 'serverAdapter'>\n\nexport const initAdminContext = ({\n serverAdapter = tanstackServerAdapter,\n ...args\n}: TanStackInitAdminContextArgs) =>\n initPayloadAdminContext({\n ...args,\n requestURL: getRequest().url,\n serverAdapter,\n })\n"],"names":["getRequest","initAdminContext","initPayloadAdminContext","tanstackServerAdapter","serverAdapter","args","requestURL","url"],"mappings":"AAGA,SAASA,UAAU,QAAQ,+BAA8B;AACzD,SAASC,oBAAoBC,uBAAuB,QAAQ,mBAAkB;AAE9E,4FAA4F;AAC5F,sDAAsD;AACtD,OAAO,8BAA6B;AACpC,SAASC,qBAAqB,QAAQ,wBAAuB;AAM7D,OAAO,MAAMF,mBAAmB,CAAC,EAC/BG,gBAAgBD,qBAAqB,EACrC,GAAGE,MAC0B,GAC7BH,wBAAwB;QACtB,GAAGG,IAAI;QACPC,YAAYN,aAAaO,GAAG;QAC5BH;IACF,GAAE"}
@@ -1,29 +1,8 @@
1
1
  import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload';
2
- /**
3
- * Builds the client-side `ServerFunctionClient` wired into
4
- * `RootProvider.serverFunction`, given the app's `createServerFn`-based
5
- * dispatcher (`runServerFn`).
6
- *
7
- * Strips functions / symbols / RegExps / React elements from the args before
8
- * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
9
- * those, but TanStack Start's seroval-based wire format errors instead. We
10
- * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
11
- * `ServerFunctionsProvider`) that may pass the live form state — which can
12
- * carry stray functions — keep working without each call site sanitising.
13
- *
14
- * Delegates to `runServerFn`, so the response (including any RSC handles for
15
- * server-rendered custom components) is decoded by TanStack Start back into
16
- * renderable React nodes on the client.
17
- */
2
+ /** Builds the admin dispatcher with native Flight response decoding. */
18
3
  export declare function createServerFunctionClient({ runServerFn, }: {
19
4
  runServerFn: (input: {
20
5
  data: ServerFunctionClientArgs;
21
- }) => Promise<unknown>;
6
+ }) => Promise<Response>;
22
7
  }): ServerFunctionClient;
23
- /**
24
- * Recursively removes values TanStack Start's seroval wire format cannot
25
- * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
26
- * normalizes `Date` subclasses to plain `Date`.
27
- */
28
- export declare function stripUnserializable(value: unknown, cache?: WeakMap<object, unknown>, ancestors?: WeakSet<object>): unknown;
29
8
  //# sourceMappingURL=serverFunctionClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7E,GAAG,oBAAoB,CAKvB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAiB,EAC/C,SAAS,GAAE,OAAO,CAAC,MAAM,CAAiB,GACzC,OAAO,CA4FT"}
1
+ {"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE7E,wEAAwE;AACxE,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC9E,GAAG,oBAAoB,CAoBvB"}
@@ -1,109 +1,20 @@
1
- /**
2
- * Builds the client-side `ServerFunctionClient` wired into
3
- * `RootProvider.serverFunction`, given the app's `createServerFn`-based
4
- * dispatcher (`runServerFn`).
5
- *
6
- * Strips functions / symbols / RegExps / React elements from the args before
7
- * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
8
- * those, but TanStack Start's seroval-based wire format errors instead. We
9
- * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
10
- * `ServerFunctionsProvider`) that may pass the live form state — which can
11
- * carry stray functions — keep working without each call site sanitising.
12
- *
13
- * Delegates to `runServerFn`, so the response (including any RSC handles for
14
- * server-rendered custom components) is decoded by TanStack Start back into
15
- * renderable React nodes on the client.
16
- */ export function createServerFunctionClient({ runServerFn }) {
1
+ /** Builds the admin dispatcher with native Flight response decoding. */ export function createServerFunctionClient({ runServerFn }) {
17
2
  return async (args)=>{
18
- const safeArgs = stripUnserializable(args);
19
- return await runServerFn({
20
- data: safeArgs
3
+ const response = await runServerFn({
4
+ data: args
21
5
  });
22
- };
23
- }
24
- /**
25
- * Recursively removes values TanStack Start's seroval wire format cannot
26
- * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
27
- * normalizes `Date` subclasses to plain `Date`.
28
- */ export function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
29
- if (value === null || value === undefined) {
30
- return value;
31
- }
32
- const t = typeof value;
33
- if (t === 'function' || t === 'symbol') {
34
- return undefined;
35
- }
36
- if (t !== 'object') {
37
- return value;
38
- }
39
- const obj = value;
40
- if (typeof obj.$$typeof === 'symbol') {
41
- return undefined;
42
- }
43
- if (ancestors.has(obj)) {
44
- return undefined;
45
- }
46
- if (cache.has(obj)) {
47
- return cache.get(obj);
48
- }
49
- if (obj instanceof Date) {
50
- // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,
51
- // used by the schedule-publish drawer) are `instanceof Date` but have a
52
- // different `constructor`, which TanStack Start's seroval serializer
53
- // rejects with "The value [object Date] ... cannot be parsed/serialized".
54
- return new Date(obj.getTime());
55
- }
56
- if (obj instanceof RegExp) {
57
- return undefined;
58
- }
59
- ancestors.add(obj);
60
- if (obj instanceof Map) {
61
- const cleaned = new Map();
62
- cache.set(obj, cleaned);
63
- for (const [k, v] of obj){
64
- const cv = stripUnserializable(v, cache, ancestors);
65
- if (cv !== undefined) {
66
- cleaned.set(k, cv);
67
- }
6
+ if (!response.ok) {
7
+ throw new Error(`Payload server function failed with status ${response.status}`);
68
8
  }
69
- ancestors.delete(obj);
70
- return cleaned;
71
- }
72
- if (obj instanceof Set) {
73
- const cleaned = new Set();
74
- cache.set(obj, cleaned);
75
- for (const v of obj){
76
- const cv = stripUnserializable(v, cache, ancestors);
77
- if (cv !== undefined) {
78
- cleaned.add(cv);
79
- }
9
+ if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {
10
+ throw new Error('Expected a React Flight response from the Payload server function');
80
11
  }
81
- ancestors.delete(obj);
82
- return cleaned;
83
- }
84
- if (Array.isArray(obj)) {
85
- const arr = [];
86
- cache.set(obj, arr);
87
- for (const item of obj){
88
- arr.push(stripUnserializable(item, cache, ancestors));
12
+ if (!response.body) {
13
+ throw new Error('The Payload server function returned an empty Flight response');
89
14
  }
90
- ancestors.delete(obj);
91
- return arr;
92
- }
93
- if (ArrayBuffer.isView(obj)) {
94
- ancestors.delete(obj);
95
- return obj;
96
- }
97
- const result = {};
98
- cache.set(obj, result);
99
- for (const key of Object.keys(obj)){
100
- const v = stripUnserializable(obj[key], cache, ancestors);
101
- if (v !== undefined) {
102
- result[key] = v;
103
- }
104
- }
105
- ancestors.delete(obj);
106
- return result;
15
+ const { createFromReadableStream } = await import('@tanstack/react-start/rsc');
16
+ return await createFromReadableStream(response.body);
17
+ };
107
18
  }
108
19
 
109
20
  //# sourceMappingURL=serverFunctionClient.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\n/**\n * Builds the client-side `ServerFunctionClient` wired into\n * `RootProvider.serverFunction`, given the app's `createServerFn`-based\n * dispatcher (`runServerFn`).\n *\n * Strips functions / symbols / RegExps / React elements from the args before\n * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped\n * those, but TanStack Start's seroval-based wire format errors instead. We\n * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in\n * `ServerFunctionsProvider`) that may pass the live form state — which can\n * carry stray functions — keep working without each call site sanitising.\n *\n * Delegates to `runServerFn`, so the response (including any RSC handles for\n * server-rendered custom components) is decoded by TanStack Start back into\n * renderable React nodes on the client.\n */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<unknown>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const safeArgs = stripUnserializable(args) as ServerFunctionClientArgs\n return await runServerFn({ data: safeArgs })\n }) as ServerFunctionClient\n}\n\n/**\n * Recursively removes values TanStack Start's seroval wire format cannot\n * serialize (functions, symbols, RegExps, React elements, cyclic refs) and\n * normalizes `Date` subclasses to plain `Date`.\n */\nexport function stripUnserializable(\n value: unknown,\n cache: WeakMap<object, unknown> = new WeakMap(),\n ancestors: WeakSet<object> = new WeakSet(),\n): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return undefined\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,\n // used by the schedule-publish drawer) are `instanceof Date` but have a\n // different `constructor`, which TanStack Start's seroval serializer\n // rejects with \"The value [object Date] ... cannot be parsed/serialized\".\n return new Date(obj.getTime())\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(stripUnserializable(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = stripUnserializable(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["createServerFunctionClient","runServerFn","args","safeArgs","stripUnserializable","data","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","getTime","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASA,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAWC,oBAAoBF;QACrC,OAAO,MAAMD,YAAY;YAAEI,MAAMF;QAAS;IAC5C;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASC,oBACdE,KAAc,EACdC,QAAkC,IAAIC,SAAS,EAC/CC,YAA6B,IAAIC,SAAS;IAE1C,IAAIJ,UAAU,QAAQA,UAAUK,WAAW;QACzC,OAAOL;IACT;IAEA,MAAMM,IAAI,OAAON;IACjB,IAAIM,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAON;IACT;IAEA,MAAMO,MAAMP;IAEZ,IAAI,OAAOO,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAOH;IACT;IAEA,IAAIF,UAAUM,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIJ,MAAMQ,GAAG,CAACF,MAAM;QAClB,OAAON,MAAMS,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,2EAA2E;QAC3E,wEAAwE;QACxE,qEAAqE;QACrE,0EAA0E;QAC1E,OAAO,IAAIA,KAAKJ,IAAIK,OAAO;IAC7B;IAEA,IAAIL,eAAeM,QAAQ;QACzB,OAAOR;IACT;IAEAF,UAAUW,GAAG,CAACP;IAEd,IAAIA,eAAeQ,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBd,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIZ,IAAK;YACxB,MAAMa,KAAKtB,oBAAoBqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIT,eAAee,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBrB,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAMG,KAAKZ,IAAK;YACnB,MAAMa,KAAKtB,oBAAoBqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQF,GAAG,CAACM;YACd;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIO,MAAMC,OAAO,CAACjB,MAAM;QACtB,MAAMkB,MAAiB,EAAE;QACzBxB,MAAMgB,GAAG,CAACV,KAAKkB;QACf,KAAK,MAAMC,QAAQnB,IAAK;YACtBkB,IAAIE,IAAI,CAAC7B,oBAAoB4B,MAAMzB,OAAOE;QAC5C;QACAA,UAAUkB,MAAM,CAACd;QACjB,OAAOkB;IACT;IAEA,IAAIG,YAAYC,MAAM,CAACtB,MAAM;QAC3BJ,UAAUkB,MAAM,CAACd;QACjB,OAAOA;IACT;IAEA,MAAMuB,SAAkC,CAAC;IACzC7B,MAAMgB,GAAG,CAACV,KAAKuB;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC1B,KAAM;QAClC,MAAMY,IAAIrB,oBAAoBS,GAAG,CAACwB,IAAI,EAAE9B,OAAOE;QAC/C,IAAIgB,MAAMd,WAAW;YACnByB,MAAM,CAACC,IAAI,GAAGZ;QAChB;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\n/** Builds the admin dispatcher with native Flight response decoding. */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<Response>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const response = await runServerFn({ data: args })\n\n if (!response.ok) {\n throw new Error(`Payload server function failed with status ${response.status}`)\n }\n\n if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {\n throw new Error('Expected a React Flight response from the Payload server function')\n }\n\n if (!response.body) {\n throw new Error('The Payload server function returned an empty Flight response')\n }\n\n const { createFromReadableStream } = await import('@tanstack/react-start/rsc')\n\n return await createFromReadableStream(response.body)\n }) as ServerFunctionClient\n}\n"],"names":["createServerFunctionClient","runServerFn","args","response","data","ok","Error","status","headers","get","split","trim","body","createFromReadableStream"],"mappings":"AAEA,sEAAsE,GACtE,OAAO,SAASA,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAW,MAAMF,YAAY;YAAEG,MAAMF;QAAK;QAEhD,IAAI,CAACC,SAASE,EAAE,EAAE;YAChB,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEH,SAASI,MAAM,EAAE;QACjF;QAEA,IAAIJ,SAASK,OAAO,CAACC,GAAG,CAAC,iBAAiBC,MAAM,IAAI,CAAC,EAAE,EAAEC,WAAW,oBAAoB;YACtF,MAAM,IAAIL,MAAM;QAClB;QAEA,IAAI,CAACH,SAASS,IAAI,EAAE;YAClB,MAAM,IAAIN,MAAM;QAClB;QAEA,MAAM,EAAEO,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC;QAElD,OAAO,MAAMA,yBAAyBV,SAASS,IAAI;IACrD;AACF"}
@@ -1,35 +1,33 @@
1
- /**
2
- * SSR/RSC externalization config used by `withPayload`. Kept separate from the
3
- * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
4
- */
5
1
  /**
6
2
  * Packages externalized during dev serve (`ssr.external`). Node's loader resolves
7
3
  * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
8
4
  * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment
9
5
  * throws when transformed rather than required).
10
6
  *
11
- * Note `pluralize` is deliberately excluded from {@link buildExternalPackages}:
12
- * for the production build it must bundle (see there).
7
+ * Safe here whoever declared the entry: Node resolves from the importing package,
8
+ * so pnpm's isolated layout never applies. The build is stricter — see
9
+ * {@link buildBundledPackages}.
13
10
  */
14
11
  export declare const ssrExternalPackages: string[];
15
12
  /**
16
- * External packages for the production `vite build` only (not dev serve).
17
- *
18
- * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
19
- * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
20
- * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
21
- * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
22
- * `dist/`, since pnpm does not hoist it.
13
+ * Entries of {@link ssrExternalPackages} that must bundle in the production build.
23
14
  *
24
- * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
25
- * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
26
- * transform can resolve — an externalized copy would hit Node's raw resolver and
27
- * fail on the `.js`→`.ts` mismatch.
15
+ * Externalizing only works for specifiers resolvable from the project root. These
16
+ * are leaf deps of Payload packages, so under pnpm they live in `.pnpm/…` and a bare
17
+ * specifier in a root-resolved chunk is invisible — `ERR_MODULE_NOT_FOUND` at
18
+ * runtime, or a build-time resolve failure under Nitro's re-bundle pass.
28
19
  *
29
- * `pluralize` is excluded: it is reached from client-safe code (`payload`'s
30
- * `formatLabels`, shipped in the `/shared` export), so externalizing it would
31
- * leave a bare specifier in a bundled client chunk that pnpm can't resolve from
32
- * `dist/` at runtime. It must bundle for the build.
20
+ * `pluralize` also needs forcing back via `noExternal` (see `withPayload`); the
21
+ * storage leaves don't, since their adapters are already `noExternal`.
22
+ */
23
+ export declare const buildBundledPackages: string[];
24
+ /** Server-only package boundaries loaded directly by Node in development and production. */
25
+ export declare const serverExternalPackages: string[];
26
+ /** Additional installed packages that can bypass Vite's development server transforms. */
27
+ export declare const devExternalPackages: string[];
28
+ /**
29
+ * Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
30
+ * Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
33
31
  */
34
32
  export declare const buildExternalPackages: string[];
35
33
  export declare const payloadNoExternalPatterns: Array<RegExp | string>;
@@ -1 +1 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAUzC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/external.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAwBvC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAOxC,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAS1C,CAAA;AAED,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAOvC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
@@ -1,26 +1,19 @@
1
+ import { devServerExternalPackages as devServerExternalPayloadPackages, serverExternalPackages as serverExternalPayloadPackages } from 'payload/build-config';
1
2
  /**
2
- * SSR/RSC externalization config used by `withPayload`. Kept separate from the
3
- * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
4
- */ /**
5
3
  * Packages externalized during dev serve (`ssr.external`). Node's loader resolves
6
4
  * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
7
5
  * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment
8
6
  * throws when transformed rather than required).
9
7
  *
10
- * Note `pluralize` is deliberately excluded from {@link buildExternalPackages}:
11
- * for the production build it must bundle (see there).
8
+ * Safe here whoever declared the entry: Node resolves from the importing package,
9
+ * so pnpm's isolated layout never applies. The build is stricter — see
10
+ * {@link buildBundledPackages}.
12
11
  */ export const ssrExternalPackages = [
13
- 'ajv',
12
+ 'zod',
14
13
  'fast-uri',
15
- 'drizzle-kit',
16
- 'drizzle-kit/api',
14
+ ...serverExternalPayloadPackages,
17
15
  'drizzle-orm',
18
- 'sharp',
19
- 'require-in-the-middle',
20
- 'json-schema-to-typescript',
21
- 'pino',
22
16
  'pino-pretty',
23
- 'graphql',
24
17
  'nodemailer',
25
18
  'aws4',
26
19
  'pluralize',
@@ -36,30 +29,29 @@
36
29
  'pg-cloudflare',
37
30
  // SQLite (`@payloadcms/db-sqlite`)
38
31
  'better-sqlite3',
39
- 'libsql',
40
32
  // Mongo (`@payloadcms/db-mongodb`)
41
33
  'mongodb',
42
34
  'mongoose'
43
35
  ];
44
36
  /**
45
- * External packages for the production `vite build` only (not dev serve).
37
+ * Entries of {@link ssrExternalPackages} that must bundle in the production build.
46
38
  *
47
- * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
48
- * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
49
- * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
50
- * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
51
- * `dist/`, since pnpm does not hoist it.
39
+ * Externalizing only works for specifiers resolvable from the project root. These
40
+ * are leaf deps of Payload packages, so under pnpm they live in `.pnpm/…` and a bare
41
+ * specifier in a root-resolved chunk is invisible — `ERR_MODULE_NOT_FOUND` at
42
+ * runtime, or a build-time resolve failure under Nitro's re-bundle pass.
52
43
  *
53
- * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
54
- * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
55
- * transform can resolve — an externalized copy would hit Node's raw resolver and
56
- * fail on the `.js`→`.ts` mismatch.
57
- *
58
- * `pluralize` is excluded: it is reached from client-safe code (`payload`'s
59
- * `formatLabels`, shipped in the `/shared` export), so externalizing it would
60
- * leave a bare specifier in a bundled client chunk that pnpm can't resolve from
61
- * `dist/` at runtime. It must bundle for the build.
62
- */ export const buildExternalPackages = [
44
+ * `pluralize` also needs forcing back via `noExternal` (see `withPayload`); the
45
+ * storage leaves don't, since their adapters are already `noExternal`.
46
+ */ export const buildBundledPackages = [
47
+ 'pluralize',
48
+ // Leaf deps of the `@payloadcms/storage-*` adapters.
49
+ '@aws-sdk/client-s3',
50
+ '@aws-sdk/s3-request-presigner',
51
+ '@azure/storage-blob',
52
+ '@google-cloud/storage'
53
+ ];
54
+ /** Server-only package boundaries loaded directly by Node in development and production. */ export const serverExternalPackages = [
63
55
  'payload',
64
56
  'payload/node',
65
57
  '@payloadcms/drizzle',
@@ -67,8 +59,22 @@
67
59
  '@payloadcms/db-postgres',
68
60
  '@payloadcms/db-vercel-postgres',
69
61
  '@payloadcms/db-sqlite',
70
- '@payloadcms/db-d1-sqlite',
71
- ...ssrExternalPackages.filter((pkg)=>pkg !== 'pluralize')
62
+ '@payloadcms/db-d1-sqlite'
63
+ ];
64
+ /** Additional installed packages that can bypass Vite's development server transforms. */ export const devExternalPackages = [
65
+ ...new Set([
66
+ // Vite otherwise transforms date-fns' full module graph during SSR.
67
+ 'date-fns',
68
+ ...devServerExternalPayloadPackages,
69
+ ...serverExternalPackages
70
+ ])
71
+ ];
72
+ /**
73
+ * Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
74
+ * Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
75
+ */ export const buildExternalPackages = [
76
+ ...serverExternalPackages,
77
+ ...ssrExternalPackages.filter((pkg)=>!buildBundledPackages.includes(pkg))
72
78
  ];
73
79
  export const payloadNoExternalPatterns = [
74
80
  '@payloadcms/ui',