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

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 (171) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  3. package/dist/elements/RouterAdapter/index.js +55 -16
  4. package/dist/elements/RouterAdapter/index.js.map +1 -1
  5. package/dist/exports/client.d.ts +4 -0
  6. package/dist/exports/client.d.ts.map +1 -1
  7. package/dist/exports/client.js +4 -0
  8. package/dist/exports/client.js.map +1 -1
  9. package/dist/exports/layouts.d.ts +1 -0
  10. package/dist/exports/layouts.d.ts.map +1 -1
  11. package/dist/exports/layouts.js +1 -0
  12. package/dist/exports/layouts.js.map +1 -1
  13. package/dist/exports/server.d.ts +4 -2
  14. package/dist/exports/server.d.ts.map +1 -1
  15. package/dist/exports/server.js +4 -2
  16. package/dist/exports/server.js.map +1 -1
  17. package/dist/exports/shared.d.ts +2 -0
  18. package/dist/exports/shared.d.ts.map +1 -0
  19. package/dist/exports/shared.js +3 -0
  20. package/dist/exports/shared.js.map +1 -0
  21. package/dist/index.d.ts +1 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  26. package/dist/layouts/Root/getLayoutData.js +37 -1
  27. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  28. package/dist/layouts/Root/index.d.ts +9 -2
  29. package/dist/layouts/Root/index.d.ts.map +1 -1
  30. package/dist/layouts/Root/index.js +4 -2
  31. package/dist/layouts/Root/index.js.map +1 -1
  32. package/dist/layouts/Root/withPayloadRoot.d.ts +41 -0
  33. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  34. package/dist/layouts/Root/withPayloadRoot.js +91 -0
  35. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  36. package/dist/node/cssLoader.d.mts +24 -2
  37. package/dist/node/cssLoader.d.mts.map +1 -1
  38. package/dist/routes/adminRoutes.d.ts +111 -0
  39. package/dist/routes/adminRoutes.d.ts.map +1 -0
  40. package/dist/routes/adminRoutes.js +108 -0
  41. package/dist/routes/adminRoutes.js.map +1 -0
  42. package/dist/routes/apiRoute.d.ts +34 -0
  43. package/dist/routes/apiRoute.d.ts.map +1 -0
  44. package/dist/routes/apiRoute.js +43 -0
  45. package/dist/routes/apiRoute.js.map +1 -0
  46. package/dist/routes/layoutRoute.d.ts +26 -0
  47. package/dist/routes/layoutRoute.d.ts.map +1 -0
  48. package/dist/routes/layoutRoute.js +57 -0
  49. package/dist/routes/layoutRoute.js.map +1 -0
  50. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  51. package/dist/utilities/handleAPIRoute.server.d.ts +11 -0
  52. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  53. package/dist/utilities/handleAPIRoute.server.js +17 -0
  54. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  55. package/dist/utilities/handleServerFunctions.d.ts +1 -19
  56. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  57. package/dist/utilities/handleServerFunctions.js +8 -56
  58. package/dist/utilities/handleServerFunctions.js.map +1 -1
  59. package/dist/utilities/importMap.server.d.ts +4 -5
  60. package/dist/utilities/importMap.server.d.ts.map +1 -1
  61. package/dist/utilities/importMap.server.js +5 -6
  62. package/dist/utilities/importMap.server.js.map +1 -1
  63. package/dist/utilities/loadAdminPage.d.ts +54 -0
  64. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  65. package/dist/utilities/loadAdminPage.js +239 -0
  66. package/dist/utilities/loadAdminPage.js.map +1 -0
  67. package/dist/utilities/loadLayoutData.d.ts +15 -0
  68. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  69. package/dist/utilities/loadLayoutData.js +23 -0
  70. package/dist/utilities/loadLayoutData.js.map +1 -0
  71. package/dist/utilities/meta.d.ts +1 -0
  72. package/dist/utilities/meta.d.ts.map +1 -1
  73. package/dist/utilities/meta.js +2 -1
  74. package/dist/utilities/meta.js.map +1 -1
  75. package/dist/utilities/routerSearch.d.ts +40 -0
  76. package/dist/utilities/routerSearch.d.ts.map +1 -0
  77. package/dist/utilities/routerSearch.js +45 -0
  78. package/dist/utilities/routerSearch.js.map +1 -0
  79. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  80. package/dist/utilities/serializeForRsc.js +17 -0
  81. package/dist/utilities/serializeForRsc.js.map +1 -1
  82. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  83. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  84. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  85. package/dist/utilities/serverFunctionClient.js +109 -0
  86. package/dist/utilities/serverFunctionClient.js.map +1 -0
  87. package/dist/withPayload/config/external.d.ts +36 -0
  88. package/dist/withPayload/config/external.d.ts.map +1 -0
  89. package/dist/withPayload/config/external.js +82 -0
  90. package/dist/withPayload/config/external.js.map +1 -0
  91. package/dist/withPayload/config/optimizeDeps.d.ts +25 -0
  92. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
  93. package/dist/withPayload/config/optimizeDeps.js +123 -0
  94. package/dist/withPayload/config/optimizeDeps.js.map +1 -0
  95. package/dist/withPayload/config/scss.d.ts +14 -0
  96. package/dist/withPayload/config/scss.d.ts.map +1 -0
  97. package/dist/withPayload/config/scss.js +28 -0
  98. package/dist/withPayload/config/scss.js.map +1 -0
  99. package/dist/withPayload/importProtection.d.ts.map +1 -0
  100. package/dist/withPayload/importProtection.js.map +1 -0
  101. package/dist/withPayload/index.d.ts +99 -0
  102. package/dist/withPayload/index.d.ts.map +1 -0
  103. package/dist/withPayload/index.js +277 -0
  104. package/dist/withPayload/index.js.map +1 -0
  105. package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
  106. package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
  107. package/dist/withPayload/workarounds/devTransforms.d.ts +19 -0
  108. package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
  109. package/dist/{vite/plugins → withPayload/workarounds}/devTransforms.js +18 -2
  110. package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
  111. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  112. package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
  113. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
  114. package/dist/withPayload/workarounds/stripDistStyleImports.js +140 -0
  115. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
  116. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts +13 -0
  117. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
  118. package/dist/withPayload/workarounds/stubPrettierInClient.js +32 -0
  119. package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
  120. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
  121. package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
  122. package/package.json +17 -12
  123. package/dist/@types/assets.d.js +0 -2
  124. package/dist/@types/assets.d.js.map +0 -1
  125. package/dist/auth/switchLanguage.d.ts +0 -6
  126. package/dist/auth/switchLanguage.d.ts.map +0 -1
  127. package/dist/auth/switchLanguage.js +0 -11
  128. package/dist/auth/switchLanguage.js.map +0 -1
  129. package/dist/exports/vite.d.ts +0 -3
  130. package/dist/exports/vite.d.ts.map +0 -1
  131. package/dist/exports/vite.js +0 -3
  132. package/dist/exports/vite.js.map +0 -1
  133. package/dist/utilities/getRequestTheme.d.ts +0 -10
  134. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  135. package/dist/utilities/getRequestTheme.js +0 -25
  136. package/dist/utilities/getRequestTheme.js.map +0 -1
  137. package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
  138. package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
  139. package/dist/utilities/serverFunctionHandlers.js +0 -17
  140. package/dist/utilities/serverFunctionHandlers.js.map +0 -1
  141. package/dist/vite/constants.d.ts +0 -37
  142. package/dist/vite/constants.d.ts.map +0 -1
  143. package/dist/vite/constants.js +0 -129
  144. package/dist/vite/constants.js.map +0 -1
  145. package/dist/vite/importProtection.d.ts.map +0 -1
  146. package/dist/vite/importProtection.js.map +0 -1
  147. package/dist/vite/plugin.d.ts +0 -38
  148. package/dist/vite/plugin.d.ts.map +0 -1
  149. package/dist/vite/plugin.js +0 -182
  150. package/dist/vite/plugin.js.map +0 -1
  151. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  152. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  153. package/dist/vite/plugins/devTransforms.d.ts +0 -8
  154. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  155. package/dist/vite/plugins/devTransforms.js.map +0 -1
  156. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  157. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  158. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  159. package/dist/vite/plugins/stripDistStyleImports.js +0 -89
  160. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  161. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  162. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  163. /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
  164. /package/dist/{vite → withPayload}/importProtection.js +0 -0
  165. /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.d.ts +0 -0
  166. /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.js +0 -0
  167. /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.d.ts +0 -0
  168. /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.js +0 -0
  169. /package/dist/{vite/plugins → withPayload/workarounds}/stripDistStyleImports.d.ts +0 -0
  170. /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.d.ts +0 -0
  171. /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.js +0 -0
@@ -0,0 +1,40 @@
1
+ import * as qs from 'qs-esm';
2
+ /**
3
+ * `parseSearch` for TanStack Router's `createRouter`, required for Payload's
4
+ * admin UI. Pair with {@link payloadStringifySearch}.
5
+ *
6
+ * Payload serializes query state (notably the list-view `where` filter) with
7
+ * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
8
+ * Router's default serializer treats each bracketed string as a flat key and
9
+ * JSON-encodes values, so it never round-trips Payload's nested query: every
10
+ * navigation re-encodes the already-encoded value, exponentially nesting it
11
+ * (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
12
+ * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
13
+ * the URL idempotent and the nested `where` intact across navigations.
14
+ *
15
+ * This is a router-global serializer: it applies to every route, not just
16
+ * `/admin`. On your own routes, search values arrive as strings (qs does no
17
+ * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
18
+ * you need numbers or booleans.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createRouter } from '@tanstack/react-router'
23
+ * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start/shared'
24
+ *
25
+ * export function getRouter() {
26
+ * return createRouter({
27
+ * parseSearch: payloadParseSearch,
28
+ * routeTree,
29
+ * stringifySearch: payloadStringifySearch,
30
+ * })
31
+ * }
32
+ * ```
33
+ */
34
+ export declare const payloadParseSearch: (searchStr: string) => qs.ParsedQs;
35
+ /**
36
+ * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
37
+ * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
38
+ */
39
+ export declare const payloadStringifySearch: (search: Record<string, unknown>) => string;
40
+ //# sourceMappingURL=routerSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerSearch.d.ts","sourceRoot":"","sources":["../../src/utilities/routerSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,kBAAkB,cAAe,MAAM,gBACS,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAGrE,CAAA"}
@@ -0,0 +1,45 @@
1
+ import * as qs from 'qs-esm';
2
+ /**
3
+ * `parseSearch` for TanStack Router's `createRouter`, required for Payload's
4
+ * admin UI. Pair with {@link payloadStringifySearch}.
5
+ *
6
+ * Payload serializes query state (notably the list-view `where` filter) with
7
+ * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
8
+ * Router's default serializer treats each bracketed string as a flat key and
9
+ * JSON-encodes values, so it never round-trips Payload's nested query: every
10
+ * navigation re-encodes the already-encoded value, exponentially nesting it
11
+ * (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
12
+ * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
13
+ * the URL idempotent and the nested `where` intact across navigations.
14
+ *
15
+ * This is a router-global serializer: it applies to every route, not just
16
+ * `/admin`. On your own routes, search values arrive as strings (qs does no
17
+ * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
18
+ * you need numbers or booleans.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createRouter } from '@tanstack/react-router'
23
+ * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start/shared'
24
+ *
25
+ * export function getRouter() {
26
+ * return createRouter({
27
+ * parseSearch: payloadParseSearch,
28
+ * routeTree,
29
+ * stringifySearch: payloadStringifySearch,
30
+ * })
31
+ * }
32
+ * ```
33
+ */ export const payloadParseSearch = (searchStr)=>qs.parse(searchStr, {
34
+ depth: 10,
35
+ ignoreQueryPrefix: true
36
+ });
37
+ /**
38
+ * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
39
+ * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
40
+ */ export const payloadStringifySearch = (search)=>{
41
+ const searchStr = qs.stringify(search);
42
+ return searchStr ? `?${searchStr}` : '';
43
+ };
44
+
45
+ //# sourceMappingURL=routerSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/routerSearch.ts"],"sourcesContent":["import * as qs from 'qs-esm'\n\n/**\n * `parseSearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadStringifySearch}.\n *\n * Payload serializes query state (notably the list-view `where` filter) with\n * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack\n * Router's default serializer treats each bracketed string as a flat key and\n * JSON-encodes values, so it never round-trips Payload's nested query: every\n * navigation re-encodes the already-encoded value, exponentially nesting it\n * (`[true,\"[true,\\\"[true…\"]`) until the filter is unusable. Parsing and\n * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps\n * the URL idempotent and the nested `where` intact across navigations.\n *\n * This is a router-global serializer: it applies to every route, not just\n * `/admin`. On your own routes, search values arrive as strings (qs does no\n * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where\n * you need numbers or booleans.\n *\n * @example\n * ```ts\n * import { createRouter } from '@tanstack/react-router'\n * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start/shared'\n *\n * export function getRouter() {\n * return createRouter({\n * parseSearch: payloadParseSearch,\n * routeTree,\n * stringifySearch: payloadStringifySearch,\n * })\n * }\n * ```\n */\nexport const payloadParseSearch = (searchStr: string) =>\n qs.parse(searchStr, { depth: 10, ignoreQueryPrefix: true })\n\n/**\n * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.\n */\nexport const payloadStringifySearch = (search: Record<string, unknown>) => {\n const searchStr = qs.stringify(search)\n return searchStr ? `?${searchStr}` : ''\n}\n"],"names":["qs","payloadParseSearch","searchStr","parse","depth","ignoreQueryPrefix","payloadStringifySearch","search","stringify"],"mappings":"AAAA,YAAYA,QAAQ,SAAQ;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,MAAMC,qBAAqB,CAACC,YACjCF,GAAGG,KAAK,CAACD,WAAW;QAAEE,OAAO;QAAIC,mBAAmB;IAAK,GAAE;AAE7D;;;CAGC,GACD,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAML,YAAYF,GAAGQ,SAAS,CAACD;IAC/B,OAAOL,YAAY,CAAC,CAAC,EAAEA,WAAW,GAAG;AACvC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
1
+ {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -1,4 +1,5 @@
1
1
  import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { createElement, Fragment } from 'react';
2
3
  /**
3
4
  * Recursively walk a server-function return value and prepare it for transit
4
5
  * to the client as an RSC payload.
@@ -78,6 +79,22 @@ async function walk(value, cache, ancestors) {
78
79
  return cleaned;
79
80
  }
80
81
  if (Array.isArray(obj)) {
82
+ // An array consisting entirely of React elements (e.g. a field's
83
+ // `beforeInput` / `afterInput` component list, produced by
84
+ // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
85
+ // Converting each element individually below turns every item into its own
86
+ // `renderServerComponent` handle, which drops the element's React `key` —
87
+ // the client then renders `{[handle, handle]}` as unkeyed array children
88
+ // and React warns "Each child in a list should have a unique key prop".
89
+ // Payload always renders these component arrays wholesale (`{BeforeInput}`),
90
+ // so collapsing them into one Fragment-rendered handle is render-equivalent
91
+ // and keeps the per-element keys intact inside the single Flight payload.
92
+ const items = obj.filter((item)=>item !== null && item !== undefined);
93
+ const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
94
+ if (isReactElementArray) {
95
+ ancestors.delete(obj);
96
+ return await renderServerComponent(createElement(Fragment, null, ...obj));
97
+ }
81
98
  const arr = [];
82
99
  cache.set(obj, arr);
83
100
  for (const item of obj){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<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 await renderServerComponent(value as React.ReactElement)\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 return obj\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 = await walk(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 = await walk(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(await walk(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 = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAEjE;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMX,sBAAsBE;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAD,UAAUS,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBX,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAf,UAAUgB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIR,eAAec,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBlB,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAMG,KAAKX,IAAK;YACnB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQF,GAAG,CAACM;YACd;QACF;QACAf,UAAUgB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIO,MAAMC,OAAO,CAAChB,MAAM;QACtB,MAAMiB,MAAiB,EAAE;QACzBrB,MAAMa,GAAG,CAACT,KAAKiB;QACf,KAAK,MAAMC,QAAQlB,IAAK;YACtBiB,IAAIE,IAAI,CAAC,MAAM1B,KAAKyB,MAAMtB,OAAOC;QACnC;QACAA,UAAUgB,MAAM,CAACb;QACjB,OAAOiB;IACT;IAEA,IAAIG,YAAYC,MAAM,CAACrB,MAAM;QAC3BH,UAAUgB,MAAM,CAACb;QACjB,OAAOA;IACT;IAEA,MAAMsB,SAAkC,CAAC;IACzC1B,MAAMa,GAAG,CAACT,KAAKsB;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACzB,KAAM;QAClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAACuB,IAAI,EAAE3B,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnBwB,MAAM,CAACC,IAAI,GAAGZ;QAChB;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAOsB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { createElement, Fragment } from 'react'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<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 await renderServerComponent(value as React.ReactElement)\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 return obj\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 = await walk(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 = await walk(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 // An array consisting entirely of React elements (e.g. a field's\n // `beforeInput` / `afterInput` component list, produced by\n // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.\n // Converting each element individually below turns every item into its own\n // `renderServerComponent` handle, which drops the element's React `key` —\n // the client then renders `{[handle, handle]}` as unkeyed array children\n // and React warns \"Each child in a list should have a unique key prop\".\n // Payload always renders these component arrays wholesale (`{BeforeInput}`),\n // so collapsing them into one Fragment-rendered handle is render-equivalent\n // and keeps the per-element keys intact inside the single Flight payload.\n const items = obj.filter((item) => item !== null && item !== undefined)\n const isReactElementArray =\n items.length > 0 &&\n items.every(\n (item) => typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(createElement(Fragment, null, ...(obj as React.ReactNode[])))\n }\n\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(await walk(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 = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","createElement","Fragment","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","items","filter","item","isReactElementArray","length","every","arr","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,aAAa,EAAEC,QAAQ,QAAQ,QAAO;AAE/C;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMb,sBAAsBI;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAD,UAAUS,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBX,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAf,UAAUgB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIR,eAAec,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBlB,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAMG,KAAKX,IAAK;YACnB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQF,GAAG,CAACM;YACd;QACF;QACAf,UAAUgB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIO,MAAMC,OAAO,CAAChB,MAAM;QACtB,iEAAiE;QACjE,2DAA2D;QAC3D,oEAAoE;QACpE,2EAA2E;QAC3E,0EAA0E;QAC1E,yEAAyE;QACzE,wEAAwE;QACxE,6EAA6E;QAC7E,4EAA4E;QAC5E,0EAA0E;QAC1E,MAAMiB,QAAQjB,IAAIkB,MAAM,CAAC,CAACC,OAASA,SAAS,QAAQA,SAASrB;QAC7D,MAAMsB,sBACJH,MAAMI,MAAM,GAAG,KACfJ,MAAMK,KAAK,CACT,CAACH,OAAS,OAAOA,SAAS,YAAY,OAAO,AAACA,KAAgClB,QAAQ,KAAK;QAE/F,IAAImB,qBAAqB;YACvBvB,UAAUgB,MAAM,CAACb;YACjB,OAAO,MAAMZ,sBAAsBC,cAAcC,UAAU,SAAUU;QACvE;QAEA,MAAMuB,MAAiB,EAAE;QACzB3B,MAAMa,GAAG,CAACT,KAAKuB;QACf,KAAK,MAAMJ,QAAQnB,IAAK;YACtBuB,IAAIC,IAAI,CAAC,MAAM/B,KAAK0B,MAAMvB,OAAOC;QACnC;QACAA,UAAUgB,MAAM,CAACb;QACjB,OAAOuB;IACT;IAEA,IAAIE,YAAYC,MAAM,CAAC1B,MAAM;QAC3BH,UAAUgB,MAAM,CAACb;QACjB,OAAOA;IACT;IAEA,MAAM2B,SAAkC,CAAC;IACzC/B,MAAMa,GAAG,CAACT,KAAK2B;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC9B,KAAM;QAClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAAC4B,IAAI,EAAEhC,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnB6B,MAAM,CAACC,IAAI,GAAGjB;QAChB;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"serverAdapter.server.d.ts","sourceRoot":"","sources":["../../src/utilities/serverAdapter.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,SAAS,CAAA;AAsDxE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aA8CnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GAAI,KAAK,aAAa,KAAG,aAgBjE,CAAA"}
1
+ {"version":3,"file":"serverAdapter.server.d.ts","sourceRoot":"","sources":["../../src/utilities/serverAdapter.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,SAAS,CAAA;AAsDxE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aA8CnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,QAAS,aAAa,KAAG,aAgBjE,CAAA"}
@@ -0,0 +1,29 @@
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
+ */
18
+ export declare function createServerFunctionClient({ runServerFn, }: {
19
+ runServerFn: (input: {
20
+ data: ServerFunctionClientArgs;
21
+ }) => Promise<unknown>;
22
+ }): 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
+ //# sourceMappingURL=serverFunctionClient.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,109 @@
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 }) {
17
+ return async (args)=>{
18
+ const safeArgs = stripUnserializable(args);
19
+ return await runServerFn({
20
+ data: safeArgs
21
+ });
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
+ }
68
+ }
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
+ }
80
+ }
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));
89
+ }
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;
107
+ }
108
+
109
+ //# sourceMappingURL=serverFunctionClient.js.map
@@ -0,0 +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"}
@@ -0,0 +1,36 @@
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
+ /**
6
+ * Packages externalized during dev serve (`ssr.external`). Node's loader resolves
7
+ * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
8
+ * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment
9
+ * throws when transformed rather than required).
10
+ *
11
+ * Note `pluralize` is deliberately excluded from {@link buildExternalPackages}:
12
+ * for the production build it must bundle (see there).
13
+ */
14
+ export declare const ssrExternalPackages: string[];
15
+ /**
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.
23
+ *
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.
28
+ *
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.
33
+ */
34
+ export declare const buildExternalPackages: string[];
35
+ export declare const payloadNoExternalPatterns: Array<RegExp | string>;
36
+ //# sourceMappingURL=external.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,82 @@
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
+ * Packages externalized during dev serve (`ssr.external`). Node's loader resolves
6
+ * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
7
+ * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment
8
+ * throws when transformed rather than required).
9
+ *
10
+ * Note `pluralize` is deliberately excluded from {@link buildExternalPackages}:
11
+ * for the production build it must bundle (see there).
12
+ */ export const ssrExternalPackages = [
13
+ 'ajv',
14
+ 'fast-uri',
15
+ 'drizzle-kit',
16
+ 'drizzle-kit/api',
17
+ 'drizzle-orm',
18
+ 'sharp',
19
+ 'require-in-the-middle',
20
+ 'json-schema-to-typescript',
21
+ 'pino',
22
+ 'pino-pretty',
23
+ 'graphql',
24
+ 'nodemailer',
25
+ 'aws4',
26
+ 'pluralize',
27
+ 'console-table-printer',
28
+ '@azure/storage-blob',
29
+ '@aws-sdk/client-s3',
30
+ '@aws-sdk/s3-request-presigner',
31
+ '@google-cloud/storage',
32
+ // Database drivers + their lazily-required companions, one group per adapter.
33
+ // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)
34
+ 'pg',
35
+ 'pg-native',
36
+ 'pg-cloudflare',
37
+ // SQLite (`@payloadcms/db-sqlite`)
38
+ 'better-sqlite3',
39
+ 'libsql',
40
+ // Mongo (`@payloadcms/db-mongodb`)
41
+ 'mongodb',
42
+ 'mongoose'
43
+ ];
44
+ /**
45
+ * External packages for the production `vite build` only (not dev serve).
46
+ *
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.
52
+ *
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 = [
63
+ 'payload',
64
+ 'payload/node',
65
+ '@payloadcms/drizzle',
66
+ '@payloadcms/db-mongodb',
67
+ '@payloadcms/db-postgres',
68
+ '@payloadcms/db-vercel-postgres',
69
+ '@payloadcms/db-sqlite',
70
+ '@payloadcms/db-d1-sqlite',
71
+ ...ssrExternalPackages.filter((pkg)=>pkg !== 'pluralize')
72
+ ];
73
+ export const payloadNoExternalPatterns = [
74
+ '@payloadcms/ui',
75
+ '@payloadcms/translations',
76
+ '@payloadcms/tanstack-start',
77
+ /^@payloadcms\/richtext-lexical/,
78
+ /^@payloadcms\/plugin-/,
79
+ /^@payloadcms\/storage-/
80
+ ];
81
+
82
+ //# sourceMappingURL=external.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Packages externalized during dev serve (`ssr.external`). Node's loader resolves\n * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break\n * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment\n * throws when transformed rather than required).\n *\n * Note `pluralize` is deliberately excluded from {@link buildExternalPackages}:\n * for the production build it must bundle (see there).\n */\nexport const ssrExternalPackages: string[] = [\n 'ajv',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\n/**\n * External packages for the production `vite build` only (not dev serve).\n *\n * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each\n * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from\n * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under\n * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from\n * `dist/`, since pnpm does not hoist it.\n *\n * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to\n * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's\n * transform can resolve — an externalized copy would hit Node's raw resolver and\n * fail on the `.js`→`.ts` mismatch.\n *\n * `pluralize` is excluded: it is reached from client-safe code (`payload`'s\n * `formatLabels`, shipped in the `/shared` export), so externalizing it would\n * leave a bare specifier in a bundled client chunk that pnpm can't resolve from\n * `dist/` at runtime. It must bundle for the build.\n */\nexport const buildExternalPackages: string[] = [\n 'payload',\n 'payload/node',\n '@payloadcms/drizzle',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-d1-sqlite',\n ...ssrExternalPackages.filter((pkg) => pkg !== 'pluralize'),\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","buildExternalPackages","filter","pkg","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;;;;;;CAQC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,wBAAkC;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;OACGD,oBAAoBE,MAAM,CAAC,CAACC,MAAQA,QAAQ;CAChD,CAAA;AAED,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Client dep-optimizer config used by `withPayload`. Kept separate from the
3
+ * SSR/RSC externalization config (`./external.ts`) so each concern stays small.
4
+ */
5
+ /**
6
+ * Packages we know contain Node-only code or top-level side effects requiring
7
+ * Node APIs. Excluding them from the client optimizer prevents Vite from
8
+ * walking into their main entries and trying to bundle server-only imports
9
+ * for the browser.
10
+ */
11
+ export declare const optimizeDepsExcludeDefaults: string[];
12
+ /**
13
+ * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
14
+ * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
15
+ * these up because their parent packages are in `optimizeDeps.exclude`, so we
16
+ * list them explicitly using the `parent > child` syntax.
17
+ *
18
+ * Each entry below fixes a specific late-discovery re-optimization: without it,
19
+ * Vite discovers the dep *after* its initial crawl, forcing a full dep
20
+ * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
21
+ * remounts the admin (dropping client state). This is why the list can't simply
22
+ * be deleted — it is the "complete first pass" for the admin's dep graph.
23
+ */
24
+ export declare const optimizeDepsIncludeDefaults: string[];
25
+ //# sourceMappingURL=optimizeDeps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA8E/C,CAAA"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Client dep-optimizer config used by `withPayload`. Kept separate from the
3
+ * SSR/RSC externalization config (`./external.ts`) so each concern stays small.
4
+ */ /**
5
+ * Packages we know contain Node-only code or top-level side effects requiring
6
+ * Node APIs. Excluding them from the client optimizer prevents Vite from
7
+ * walking into their main entries and trying to bundle server-only imports
8
+ * for the browser.
9
+ */ export const optimizeDepsExcludeDefaults = [
10
+ 'sharp',
11
+ '@payloadcms/ui',
12
+ '@payloadcms/tanstack-start',
13
+ 'payload',
14
+ 'pino',
15
+ 'pino-pretty',
16
+ 'busboy',
17
+ 'get-tsconfig',
18
+ 'ws',
19
+ 'croner',
20
+ 'prompts',
21
+ 'file-type',
22
+ // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite
23
+ // sometimes walks these from the main package entry while scanning
24
+ // workspace deps, and the browser sub-bundles do not expose the
25
+ // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev
26
+ // server with a `MISSING_EXPORT` error before any test runs.
27
+ '@azure/storage-blob',
28
+ '@aws-sdk/client-s3',
29
+ '@aws-sdk/s3-request-presigner',
30
+ '@google-cloud/storage'
31
+ ];
32
+ /**
33
+ * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
34
+ * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
35
+ * these up because their parent packages are in `optimizeDeps.exclude`, so we
36
+ * list them explicitly using the `parent > child` syntax.
37
+ *
38
+ * Each entry below fixes a specific late-discovery re-optimization: without it,
39
+ * Vite discovers the dep *after* its initial crawl, forcing a full dep
40
+ * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
41
+ * remounts the admin (dropping client state). This is why the list can't simply
42
+ * be deleted — it is the "complete first pass" for the admin's dep graph.
43
+ */ export const optimizeDepsIncludeDefaults = [
44
+ '@payloadcms/ui > sonner',
45
+ '@payloadcms/ui > @faceless-ui/modal',
46
+ '@payloadcms/ui > @faceless-ui/window-info',
47
+ '@payloadcms/ui > @faceless-ui/scroll-info',
48
+ '@payloadcms/ui > @dnd-kit/core',
49
+ '@payloadcms/ui > @dnd-kit/sortable',
50
+ '@payloadcms/ui > @dnd-kit/utilities',
51
+ '@payloadcms/ui > react-datepicker',
52
+ '@payloadcms/ui > react-select',
53
+ '@payloadcms/ui > react-select/creatable',
54
+ '@payloadcms/ui > react-image-crop',
55
+ '@payloadcms/ui > @monaco-editor/react',
56
+ '@payloadcms/ui > date-fns',
57
+ '@payloadcms/ui > date-fns/transpose',
58
+ '@payloadcms/ui > @date-fns/tz/date/mini',
59
+ '@payloadcms/ui > uuid',
60
+ '@payloadcms/ui > use-context-selector',
61
+ '@payloadcms/ui > bson-objectid',
62
+ '@payloadcms/ui > dequal',
63
+ '@payloadcms/ui > object-to-formdata',
64
+ '@payloadcms/ui > md5',
65
+ 'payload > deepmerge',
66
+ 'payload > pluralize',
67
+ // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of
68
+ // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated
69
+ // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where
70
+ // it isn't hoisted to the top level. Path it through `react-dom` so the
71
+ // optimizer resolves the exact copy the runtime loads.
72
+ 'react-dom > scheduler',
73
+ // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the
74
+ // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.
75
+ // Because its parent is excluded, the optimizer never crawls in to discover
76
+ // this entry, so Vite serves `react/compiler-runtime` raw. That file is
77
+ // CommonJS (`module.exports = require(...)`), so the named `c` export can't be
78
+ // statically extracted and every client component throws "does not provide an
79
+ // export named 'c'". Pre-bundling it lets esbuild synthesize the named export.
80
+ 'react/compiler-runtime',
81
+ // Transitive deps that Vite otherwise discovers *after* the initial crawl
82
+ // (react-select pulls in @floating-ui at runtime; react-is is reached via
83
+ // react-transition-group/prop-types; the default date-fns locale is loaded
84
+ // through a dynamic `date-fns/locale/${key}` import). A late discovery forces
85
+ // a full dep re-optimization mid-session, which 404s every in-flight
86
+ // `.vite/deps/*` chunk ("Pre-transform error: file does not exist in the
87
+ // optimize deps directory") and breaks the admin UI in CI cold starts.
88
+ // Pre-bundling them keeps the first optimization pass complete.
89
+ '@payloadcms/ui > react-select > @floating-ui/dom',
90
+ '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',
91
+ '@payloadcms/ui > react-select > prop-types > react-is',
92
+ '@payloadcms/ui > date-fns/locale/en-US',
93
+ // Further late discoveries observed re-optimizing mid-run in CI cold starts
94
+ // (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / ajv /
95
+ // dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
96
+ // render; form-state diffing reaches `dequal/lite` (a distinct entry point
97
+ // from the already-listed `dequal`); client-side field validation reaches
98
+ // `ajv` *through `payload`* — it is `ssrExternal` server-side but still
99
+ // bundled into the client, and must be pathed via `payload` so the optimizer
100
+ // pre-bundles the exact copy the runtime loads.
101
+ '@payloadcms/ui > @dnd-kit/modifiers',
102
+ '@payloadcms/ui > dequal/lite',
103
+ 'payload > ajv',
104
+ // The storage client-upload suites (esp. vercel-blob) crawl part of the
105
+ // `payload` server runtime into the client bundle and discover these late,
106
+ // triggering several "optimized dependencies changed. reloading" waves that
107
+ // reload the page mid-test (the bulk-upload drawer's Create New button /
108
+ // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the
109
+ // whole observed set so the first pass is complete.
110
+ 'payload > undici',
111
+ 'payload > jose',
112
+ 'payload > dataloader',
113
+ 'payload > path-to-regexp',
114
+ 'payload > console-table-printer',
115
+ 'payload > ci-info',
116
+ 'payload > image-size',
117
+ 'payload > image-size/fromFile',
118
+ 'payload > ipaddr.js',
119
+ 'payload > range-parser',
120
+ 'payload > sanitize-filename'
121
+ ];
122
+
123
+ //# sourceMappingURL=optimizeDeps.js.map