@payloadcms/tanstack-start 4.0.0-beta.0

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 (186) hide show
  1. package/LICENSE.md +22 -0
  2. package/dist/adapters/handleServerFunctions.d.ts +2 -0
  3. package/dist/adapters/handleServerFunctions.d.ts.map +1 -0
  4. package/dist/adapters/handleServerFunctions.js +9 -0
  5. package/dist/adapters/handleServerFunctions.js.map +1 -0
  6. package/dist/adapters/layout/index.d.ts +66 -0
  7. package/dist/adapters/layout/index.d.ts.map +1 -0
  8. package/dist/adapters/layout/index.js +105 -0
  9. package/dist/adapters/layout/index.js.map +1 -0
  10. package/dist/adapters/layout/lazy.d.ts +11 -0
  11. package/dist/adapters/layout/lazy.d.ts.map +1 -0
  12. package/dist/adapters/layout/lazy.js +23 -0
  13. package/dist/adapters/layout/lazy.js.map +1 -0
  14. package/dist/adapters/layout/server.d.ts +29 -0
  15. package/dist/adapters/layout/server.d.ts.map +1 -0
  16. package/dist/adapters/layout/server.js +63 -0
  17. package/dist/adapters/layout/server.js.map +1 -0
  18. package/dist/adapters/metadata.d.ts +80 -0
  19. package/dist/adapters/metadata.d.ts.map +1 -0
  20. package/dist/adapters/metadata.js +202 -0
  21. package/dist/adapters/metadata.js.map +1 -0
  22. package/dist/adapters/router.d.ts +3 -0
  23. package/dist/adapters/router.d.ts.map +1 -0
  24. package/dist/adapters/router.js +179 -0
  25. package/dist/adapters/router.js.map +1 -0
  26. package/dist/adapters/server.d.ts +36 -0
  27. package/dist/adapters/server.d.ts.map +1 -0
  28. package/dist/adapters/server.js +130 -0
  29. package/dist/adapters/server.js.map +1 -0
  30. package/dist/adapters/views/index.d.ts +104 -0
  31. package/dist/adapters/views/index.d.ts.map +1 -0
  32. package/dist/adapters/views/index.js +80 -0
  33. package/dist/adapters/views/index.js.map +1 -0
  34. package/dist/adapters/views/lazy.d.ts +4 -0
  35. package/dist/adapters/views/lazy.d.ts.map +1 -0
  36. package/dist/adapters/views/lazy.js +43 -0
  37. package/dist/adapters/views/lazy.js.map +1 -0
  38. package/dist/adapters/views/server.d.ts +57 -0
  39. package/dist/adapters/views/server.d.ts.map +1 -0
  40. package/dist/adapters/views/server.js +169 -0
  41. package/dist/adapters/views/server.js.map +1 -0
  42. package/dist/auth/login.d.ts +4 -0
  43. package/dist/auth/login.d.ts.map +1 -0
  44. package/dist/auth/login.js +10 -0
  45. package/dist/auth/login.js.map +1 -0
  46. package/dist/auth/logout.d.ts +6 -0
  47. package/dist/auth/logout.d.ts.map +1 -0
  48. package/dist/auth/logout.js +10 -0
  49. package/dist/auth/logout.js.map +1 -0
  50. package/dist/auth/refresh.d.ts +6 -0
  51. package/dist/auth/refresh.d.ts.map +1 -0
  52. package/dist/auth/refresh.js +10 -0
  53. package/dist/auth/refresh.js.map +1 -0
  54. package/dist/exports/client.d.ts +4 -0
  55. package/dist/exports/client.d.ts.map +1 -0
  56. package/dist/exports/client.js +6 -0
  57. package/dist/exports/client.js.map +1 -0
  58. package/dist/exports/layouts.d.ts +3 -0
  59. package/dist/exports/layouts.d.ts.map +1 -0
  60. package/dist/exports/layouts.js +3 -0
  61. package/dist/exports/layouts.js.map +1 -0
  62. package/dist/exports/rsc.browser.d.ts +15 -0
  63. package/dist/exports/rsc.browser.d.ts.map +1 -0
  64. package/dist/exports/rsc.browser.js +15 -0
  65. package/dist/exports/rsc.browser.js.map +1 -0
  66. package/dist/exports/rsc.d.ts +4 -0
  67. package/dist/exports/rsc.d.ts.map +1 -0
  68. package/dist/exports/rsc.js +5 -0
  69. package/dist/exports/rsc.js.map +1 -0
  70. package/dist/exports/server.d.ts +15 -0
  71. package/dist/exports/server.d.ts.map +1 -0
  72. package/dist/exports/server.js +16 -0
  73. package/dist/exports/server.js.map +1 -0
  74. package/dist/exports/shared.d.ts +2 -0
  75. package/dist/exports/shared.d.ts.map +1 -0
  76. package/dist/exports/shared.js +3 -0
  77. package/dist/exports/shared.js.map +1 -0
  78. package/dist/index.d.ts +2 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +3 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/routes/graphql/handler.server.d.ts +10 -0
  83. package/dist/routes/graphql/handler.server.d.ts.map +1 -0
  84. package/dist/routes/graphql/handler.server.js +132 -0
  85. package/dist/routes/graphql/handler.server.js.map +1 -0
  86. package/dist/routes/rest/handler.server.d.ts +11 -0
  87. package/dist/routes/rest/handler.server.d.ts.map +1 -0
  88. package/dist/routes/rest/handler.server.js +17 -0
  89. package/dist/routes/rest/handler.server.js.map +1 -0
  90. package/dist/routes/rest/index.d.ts +34 -0
  91. package/dist/routes/rest/index.d.ts.map +1 -0
  92. package/dist/routes/rest/index.js +43 -0
  93. package/dist/routes/rest/index.js.map +1 -0
  94. package/dist/rsc/CollectionCards.d.ts +4 -0
  95. package/dist/rsc/CollectionCards.d.ts.map +1 -0
  96. package/dist/rsc/CollectionCards.js +12 -0
  97. package/dist/rsc/CollectionCards.js.map +1 -0
  98. package/dist/rsc/HierarchyTypeFieldServer.d.ts +9 -0
  99. package/dist/rsc/HierarchyTypeFieldServer.d.ts.map +1 -0
  100. package/dist/rsc/HierarchyTypeFieldServer.js +35 -0
  101. package/dist/rsc/HierarchyTypeFieldServer.js.map +1 -0
  102. package/dist/rsc/renderOnDemand.d.ts +15 -0
  103. package/dist/rsc/renderOnDemand.d.ts.map +1 -0
  104. package/dist/rsc/renderOnDemand.js +25 -0
  105. package/dist/rsc/renderOnDemand.js.map +1 -0
  106. package/dist/utilities/devConfigReload.server.d.ts +2 -0
  107. package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
  108. package/dist/utilities/devConfigReload.server.js +63 -0
  109. package/dist/utilities/devConfigReload.server.js.map +1 -0
  110. package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
  111. package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
  112. package/dist/utilities/devConfigReloadEvent.js +9 -0
  113. package/dist/utilities/devConfigReloadEvent.js.map +1 -0
  114. package/dist/utilities/getRequestI18n.server.d.ts +12 -0
  115. package/dist/utilities/getRequestI18n.server.d.ts.map +1 -0
  116. package/dist/utilities/getRequestI18n.server.js +25 -0
  117. package/dist/utilities/getRequestI18n.server.js.map +1 -0
  118. package/dist/utilities/initAdminContext.server.d.ts +9 -0
  119. package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
  120. package/dist/utilities/initAdminContext.server.js +13 -0
  121. package/dist/utilities/initAdminContext.server.js.map +1 -0
  122. package/dist/utilities/routerSearch.d.ts +40 -0
  123. package/dist/utilities/routerSearch.d.ts.map +1 -0
  124. package/dist/utilities/routerSearch.js +45 -0
  125. package/dist/utilities/routerSearch.js.map +1 -0
  126. package/dist/utilities/serializeForRsc.d.ts +26 -0
  127. package/dist/utilities/serializeForRsc.d.ts.map +1 -0
  128. package/dist/utilities/serializeForRsc.js +127 -0
  129. package/dist/utilities/serializeForRsc.js.map +1 -0
  130. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  131. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  132. package/dist/utilities/serverFunctionClient.js +114 -0
  133. package/dist/utilities/serverFunctionClient.js.map +1 -0
  134. package/dist/utilities/toSerializable.d.ts +11 -0
  135. package/dist/utilities/toSerializable.d.ts.map +1 -0
  136. package/dist/utilities/toSerializable.js +127 -0
  137. package/dist/utilities/toSerializable.js.map +1 -0
  138. package/dist/withPayload/config/external.d.ts +44 -0
  139. package/dist/withPayload/config/external.d.ts.map +1 -0
  140. package/dist/withPayload/config/external.js +96 -0
  141. package/dist/withPayload/config/external.js.map +1 -0
  142. package/dist/withPayload/config/optimizeDeps.d.ts +25 -0
  143. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
  144. package/dist/withPayload/config/optimizeDeps.js +160 -0
  145. package/dist/withPayload/config/optimizeDeps.js.map +1 -0
  146. package/dist/withPayload/config/scss.d.ts +14 -0
  147. package/dist/withPayload/config/scss.d.ts.map +1 -0
  148. package/dist/withPayload/config/scss.js +28 -0
  149. package/dist/withPayload/config/scss.js.map +1 -0
  150. package/dist/withPayload/devConfigReload.d.ts +14 -0
  151. package/dist/withPayload/devConfigReload.d.ts.map +1 -0
  152. package/dist/withPayload/devConfigReload.js +84 -0
  153. package/dist/withPayload/devConfigReload.js.map +1 -0
  154. package/dist/withPayload/importProtection.d.ts +14 -0
  155. package/dist/withPayload/importProtection.d.ts.map +1 -0
  156. package/dist/withPayload/importProtection.js +54 -0
  157. package/dist/withPayload/importProtection.js.map +1 -0
  158. package/dist/withPayload/index.d.ts +110 -0
  159. package/dist/withPayload/index.d.ts.map +1 -0
  160. package/dist/withPayload/index.js +300 -0
  161. package/dist/withPayload/index.js.map +1 -0
  162. package/dist/withPayload/workarounds/clientModuleResolution.d.ts +14 -0
  163. package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
  164. package/dist/withPayload/workarounds/clientModuleResolution.js +98 -0
  165. package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
  166. package/dist/withPayload/workarounds/devTransforms.d.ts +19 -0
  167. package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
  168. package/dist/withPayload/workarounds/devTransforms.js +72 -0
  169. package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
  170. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts +27 -0
  171. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  172. package/dist/withPayload/workarounds/reactDomServerInRsc.js +90 -0
  173. package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
  174. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts +21 -0
  175. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
  176. package/dist/withPayload/workarounds/stripDistStyleImports.js +140 -0
  177. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
  178. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts +13 -0
  179. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
  180. package/dist/withPayload/workarounds/stubPrettierInClient.js +32 -0
  181. package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
  182. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts +15 -0
  183. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
  184. package/dist/withPayload/workarounds/wrapCjsForClient.js +106 -0
  185. package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
  186. package/package.json +114 -0
@@ -0,0 +1,63 @@
1
+ import { registerDevReloadStrategy } from 'payload';
2
+ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
3
+ /**
4
+ * Subscribes the Payload instance to the config-changed event that the
5
+ * `payload:dev-config-reload` Vite plugin broadcasts.
6
+ *
7
+ * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only
8
+ * `getPayload` call site, so the strategy is registered before an instance can
9
+ * be built. Registration is module-scoped on both ends: this runs inside the
10
+ * app's server graph and so resolves the same copy of `payload` that
11
+ * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
12
+ * its own listener against its own copy.
13
+ *
14
+ * Vite re-evaluates this module on a program reload, which drops the listeners
15
+ * the previous instance had collected. `getPayload` reconnects on its next call
16
+ * because the registered strategy is a new object - see `connectDevReload`.
17
+ *
18
+ * `import.meta.hot` is only defined during dev serve, so this is inert in a
19
+ * production build.
20
+ */ const hot = import.meta.hot;
21
+ if (hot) {
22
+ registerDevReloadStrategy(createConfigChangedStrategy({
23
+ hot
24
+ }));
25
+ }
26
+ /**
27
+ * Builds a dev reload strategy that forwards the config-changed event to every
28
+ * connected instance.
29
+ *
30
+ * After a program reload, the first request to re-import this module replaces
31
+ * the old listener with a new one, but the cached Payload instance only connects
32
+ * to it on its next `getPayload` call - and a request such as a frontend page
33
+ * render may never make one. An event that lands in that gap has no one to
34
+ * notify, so it is held and replayed to the next connection instead of being
35
+ * dropped - which would otherwise leave the instance serving the old config
36
+ * indefinitely.
37
+ */ function createConfigChangedStrategy({ hot }) {
38
+ const listeners = new Set();
39
+ let hasPendingReload = false;
40
+ hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
41
+ if (listeners.size === 0) {
42
+ hasPendingReload = true;
43
+ return;
44
+ }
45
+ for (const onReload of listeners){
46
+ onReload();
47
+ }
48
+ });
49
+ return {
50
+ connect: (onReload)=>{
51
+ listeners.add(onReload);
52
+ if (hasPendingReload) {
53
+ hasPendingReload = false;
54
+ onReload();
55
+ }
56
+ return ()=>{
57
+ listeners.delete(onReload);
58
+ };
59
+ }
60
+ };
61
+ }
62
+
63
+ //# sourceMappingURL=devConfigReload.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only\n * `getPayload` call site, so the strategy is registered before an instance can\n * be built. Registration is module-scoped on both ends: this runs inside the\n * app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n 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;;;;;;;;;;;;;;;;;CAiBC,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"}
@@ -0,0 +1,12 @@
1
+ import type { I18nClient } from '@payloadcms/translations';
2
+ import type { SanitizedConfig } from 'payload';
3
+ /**
4
+ * Resolves the client `I18n` for the current TanStack Start request without a
5
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
6
+ * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
7
+ * needs `config` + `i18n` to translate admin-page titles.
8
+ */
9
+ export declare function getRequestI18n({ config }: {
10
+ config: SanitizedConfig;
11
+ }): Promise<I18nClient>;
12
+ //# sourceMappingURL=getRequestI18n.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequestI18n.server.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestI18n.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM9C;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAYjG"}
@@ -0,0 +1,25 @@
1
+ import { initI18n } from '@payloadcms/translations';
2
+ import { getRequest } from '@tanstack/react-start/server';
3
+ import { getRequestLanguage, parseCookies } from 'payload';
4
+ /**
5
+ * Resolves the client `I18n` for the current TanStack Start request without a
6
+ * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
7
+ * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
8
+ * needs `config` + `i18n` to translate admin-page titles.
9
+ */ export async function getRequestI18n({ config }) {
10
+ const webRequest = getRequest();
11
+ const headers = new Headers(webRequest.headers);
12
+ const cookies = parseCookies(headers);
13
+ const languageCode = getRequestLanguage({
14
+ config,
15
+ cookies,
16
+ headers
17
+ });
18
+ return initI18n({
19
+ config: config.i18n,
20
+ context: 'client',
21
+ language: languageCode
22
+ });
23
+ }
24
+
25
+ //# sourceMappingURL=getRequestI18n.server.js.map
@@ -0,0 +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 `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"}
@@ -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"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Recursively walk a server-function return value and prepare it for transit
3
+ * to the client as an RSC payload.
4
+ *
5
+ * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
6
+ * refs) with two key differences:
7
+ *
8
+ * 1. React elements are NOT stripped. They are passed through
9
+ * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
10
+ * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
11
+ * streams the underlying Flight payload to the client, where it is
12
+ * decoded back into a renderable React node. This matches the way
13
+ * Next.js's RSC payload format ships React elements over server actions
14
+ * and lets server-rendered custom field components (e.g. those returned
15
+ * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
16
+ * round trip.
17
+ *
18
+ * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
19
+ * transport cannot handle them, and Payload doesn't intentionally include
20
+ * them in server-function return values.
21
+ *
22
+ * Use this in `createServerFn` handlers that return Payload form/view state
23
+ * containing React elements (e.g. `state[path].customComponents.Field`).
24
+ */
25
+ export declare function serializeForRsc<T>(value: T): Promise<T>;
26
+ //# sourceMappingURL=serializeForRsc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -0,0 +1,127 @@
1
+ import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { setOwnProperty } from 'payload/shared';
3
+ import { createElement, Fragment } from 'react';
4
+ /**
5
+ * Recursively walk a server-function return value and prepare it for transit
6
+ * to the client as an RSC payload.
7
+ *
8
+ * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
9
+ * refs) with two key differences:
10
+ *
11
+ * 1. React elements are NOT stripped. They are passed through
12
+ * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
13
+ * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
14
+ * streams the underlying Flight payload to the client, where it is
15
+ * decoded back into a renderable React node. This matches the way
16
+ * Next.js's RSC payload format ships React elements over server actions
17
+ * and lets server-rendered custom field components (e.g. those returned
18
+ * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
19
+ * round trip.
20
+ *
21
+ * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
22
+ * transport cannot handle them, and Payload doesn't intentionally include
23
+ * them in server-function return values.
24
+ *
25
+ * Use this in `createServerFn` handlers that return Payload form/view state
26
+ * containing React elements (e.g. `state[path].customComponents.Field`).
27
+ */ export async function serializeForRsc(value) {
28
+ return await walk(value, new WeakMap(), new WeakSet());
29
+ }
30
+ async function walk(value, cache, ancestors) {
31
+ if (value === null || value === undefined) {
32
+ return value;
33
+ }
34
+ const t = typeof value;
35
+ if (t === 'function' || t === 'symbol') {
36
+ return undefined;
37
+ }
38
+ if (t !== 'object') {
39
+ return value;
40
+ }
41
+ const obj = value;
42
+ if (typeof obj.$$typeof === 'symbol') {
43
+ return await renderServerComponent(value);
44
+ }
45
+ if (ancestors.has(obj)) {
46
+ return undefined;
47
+ }
48
+ if (cache.has(obj)) {
49
+ return cache.get(obj);
50
+ }
51
+ if (obj instanceof Date) {
52
+ return obj;
53
+ }
54
+ if (obj instanceof RegExp) {
55
+ return undefined;
56
+ }
57
+ ancestors.add(obj);
58
+ if (obj instanceof Map) {
59
+ const cleaned = new Map();
60
+ cache.set(obj, cleaned);
61
+ for (const [k, v] of obj){
62
+ const cv = await walk(v, cache, ancestors);
63
+ if (cv !== undefined) {
64
+ cleaned.set(k, cv);
65
+ }
66
+ }
67
+ ancestors.delete(obj);
68
+ return cleaned;
69
+ }
70
+ if (obj instanceof Set) {
71
+ const cleaned = new Set();
72
+ cache.set(obj, cleaned);
73
+ for (const v of obj){
74
+ const cv = await walk(v, cache, ancestors);
75
+ if (cv !== undefined) {
76
+ cleaned.add(cv);
77
+ }
78
+ }
79
+ ancestors.delete(obj);
80
+ return cleaned;
81
+ }
82
+ if (Array.isArray(obj)) {
83
+ // An array consisting entirely of React elements (e.g. a field's
84
+ // `beforeInput` / `afterInput` component list, produced by
85
+ // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
86
+ // Converting each element individually below turns every item into its own
87
+ // `renderServerComponent` handle, which drops the element's React `key` —
88
+ // the client then renders `{[handle, handle]}` as unkeyed array children
89
+ // and React warns "Each child in a list should have a unique key prop".
90
+ // Payload always renders these component arrays wholesale (`{BeforeInput}`),
91
+ // so collapsing them into one Fragment-rendered handle is render-equivalent
92
+ // and keeps the per-element keys intact inside the single Flight payload.
93
+ const items = obj.filter((item)=>item !== null && item !== undefined);
94
+ const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
95
+ if (isReactElementArray) {
96
+ ancestors.delete(obj);
97
+ return await renderServerComponent(createElement(Fragment, null, ...obj));
98
+ }
99
+ const arr = [];
100
+ cache.set(obj, arr);
101
+ for (const item of obj){
102
+ arr.push(await walk(item, cache, ancestors));
103
+ }
104
+ ancestors.delete(obj);
105
+ return arr;
106
+ }
107
+ if (ArrayBuffer.isView(obj)) {
108
+ ancestors.delete(obj);
109
+ return obj;
110
+ }
111
+ const result = {};
112
+ cache.set(obj, result);
113
+ for (const key of Object.keys(obj)){
114
+ const v = await walk(obj[key], cache, ancestors);
115
+ if (v !== undefined) {
116
+ setOwnProperty({
117
+ key,
118
+ target: result,
119
+ value: v
120
+ });
121
+ }
122
+ }
123
+ ancestors.delete(obj);
124
+ return result;
125
+ }
126
+
127
+ //# sourceMappingURL=serializeForRsc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { setOwnProperty } from 'payload/shared'\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) =>\n typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(\n createElement(Fragment, null, ...(obj as React.ReactNode[])),\n )\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 setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","setOwnProperty","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","target"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,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,MAAMd,sBAAsBK;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,OACC,OAAOA,SAAS,YAAY,OAAO,AAACA,KAAgClB,QAAQ,KAAK;QAEvF,IAAImB,qBAAqB;YACvBvB,UAAUgB,MAAM,CAACb;YACjB,OAAO,MAAMb,sBACXE,cAAcC,UAAU,SAAUU;QAEtC;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;YACnBV,eAAe;gBAAEwC;gBAAKG,QAAQJ;gBAAQnC,OAAOmB;YAAE;QACjD;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
@@ -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;AAI7E;;;;;;;;;;;;;;;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,114 @@
1
+ import { setOwnProperty } from 'payload/shared';
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
+ */ export function createServerFunctionClient({ runServerFn }) {
18
+ return async (args)=>{
19
+ const safeArgs = stripUnserializable(args);
20
+ return await runServerFn({
21
+ data: safeArgs
22
+ });
23
+ };
24
+ }
25
+ /**
26
+ * Recursively removes values TanStack Start's seroval wire format cannot
27
+ * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
28
+ * normalizes `Date` subclasses to plain `Date`.
29
+ */ export function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
30
+ if (value === null || value === undefined) {
31
+ return value;
32
+ }
33
+ const t = typeof value;
34
+ if (t === 'function' || t === 'symbol') {
35
+ return undefined;
36
+ }
37
+ if (t !== 'object') {
38
+ return value;
39
+ }
40
+ const obj = value;
41
+ if (typeof obj.$$typeof === 'symbol') {
42
+ return undefined;
43
+ }
44
+ if (ancestors.has(obj)) {
45
+ return undefined;
46
+ }
47
+ if (cache.has(obj)) {
48
+ return cache.get(obj);
49
+ }
50
+ if (obj instanceof Date) {
51
+ // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,
52
+ // used by the schedule-publish drawer) are `instanceof Date` but have a
53
+ // different `constructor`, which TanStack Start's seroval serializer
54
+ // rejects with "The value [object Date] ... cannot be parsed/serialized".
55
+ return new Date(obj.getTime());
56
+ }
57
+ if (obj instanceof RegExp) {
58
+ return undefined;
59
+ }
60
+ ancestors.add(obj);
61
+ if (obj instanceof Map) {
62
+ const cleaned = new Map();
63
+ cache.set(obj, cleaned);
64
+ for (const [k, v] of obj){
65
+ const cv = stripUnserializable(v, cache, ancestors);
66
+ if (cv !== undefined) {
67
+ cleaned.set(k, cv);
68
+ }
69
+ }
70
+ ancestors.delete(obj);
71
+ return cleaned;
72
+ }
73
+ if (obj instanceof Set) {
74
+ const cleaned = new Set();
75
+ cache.set(obj, cleaned);
76
+ for (const v of obj){
77
+ const cv = stripUnserializable(v, cache, ancestors);
78
+ if (cv !== undefined) {
79
+ cleaned.add(cv);
80
+ }
81
+ }
82
+ ancestors.delete(obj);
83
+ return cleaned;
84
+ }
85
+ if (Array.isArray(obj)) {
86
+ const arr = [];
87
+ cache.set(obj, arr);
88
+ for (const item of obj){
89
+ arr.push(stripUnserializable(item, cache, ancestors));
90
+ }
91
+ ancestors.delete(obj);
92
+ return arr;
93
+ }
94
+ if (ArrayBuffer.isView(obj)) {
95
+ ancestors.delete(obj);
96
+ return obj;
97
+ }
98
+ const result = {};
99
+ cache.set(obj, result);
100
+ for (const key of Object.keys(obj)){
101
+ const v = stripUnserializable(obj[key], cache, ancestors);
102
+ if (v !== undefined) {
103
+ setOwnProperty({
104
+ key,
105
+ target: result,
106
+ value: v
107
+ });
108
+ }
109
+ }
110
+ ancestors.delete(obj);
111
+ return result;
112
+ }
113
+
114
+ //# sourceMappingURL=serverFunctionClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\nimport { setOwnProperty } from 'payload/shared'\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 setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["setOwnProperty","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","target"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAE/C;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,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;YACnBZ,eAAe;gBAAEsC;gBAAKG,QAAQJ;gBAAQ9B,OAAOmB;YAAE;QACjD;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
@@ -0,0 +1,11 @@
1
+ import type { Serializable, SerializableExtensions } from '@tanstack/react-router';
2
+ /** A record sanitized for TanStack's server-function transport. */
3
+ export type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable'];
4
+ /**
5
+ * Removes values unsupported by TanStack's serializer. Trusted serializable
6
+ * additions are merged afterward so opaque handles such as RSC payloads are
7
+ * preserved while the source record is sanitized.
8
+ */
9
+ export declare function toSerializable<T>(value: T): T;
10
+ export declare function toSerializable(value: Record<string, unknown>, additions: Record<string, Serializable>): SerializableRecord;
11
+ //# sourceMappingURL=toSerializable.d.ts.map