@payloadcms/tanstack-start 4.0.0-canary.10

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 (228) hide show
  1. package/LICENSE.md +22 -0
  2. package/dist/auth/login.d.ts +17 -0
  3. package/dist/auth/login.d.ts.map +1 -0
  4. package/dist/auth/login.js +50 -0
  5. package/dist/auth/login.js.map +1 -0
  6. package/dist/auth/logout.d.ts +9 -0
  7. package/dist/auth/logout.d.ts.map +1 -0
  8. package/dist/auth/logout.js +51 -0
  9. package/dist/auth/logout.js.map +1 -0
  10. package/dist/auth/refresh.d.ts +8 -0
  11. package/dist/auth/refresh.d.ts.map +1 -0
  12. package/dist/auth/refresh.js +53 -0
  13. package/dist/auth/refresh.js.map +1 -0
  14. package/dist/elements/DocumentHeaderClient/index.d.ts +16 -0
  15. package/dist/elements/DocumentHeaderClient/index.d.ts.map +1 -0
  16. package/dist/elements/DocumentHeaderClient/index.js +116 -0
  17. package/dist/elements/DocumentHeaderClient/index.js.map +1 -0
  18. package/dist/elements/RenderComponent/index.d.ts +10 -0
  19. package/dist/elements/RenderComponent/index.d.ts.map +1 -0
  20. package/dist/elements/RenderComponent/index.js +12 -0
  21. package/dist/elements/RenderComponent/index.js.map +1 -0
  22. package/dist/elements/RouterAdapter/index.d.ts +3 -0
  23. package/dist/elements/RouterAdapter/index.d.ts.map +1 -0
  24. package/dist/elements/RouterAdapter/index.js +157 -0
  25. package/dist/elements/RouterAdapter/index.js.map +1 -0
  26. package/dist/exports/client.d.ts +8 -0
  27. package/dist/exports/client.d.ts.map +1 -0
  28. package/dist/exports/client.js +10 -0
  29. package/dist/exports/client.js.map +1 -0
  30. package/dist/exports/layouts.d.ts +6 -0
  31. package/dist/exports/layouts.d.ts.map +1 -0
  32. package/dist/exports/layouts.js +5 -0
  33. package/dist/exports/layouts.js.map +1 -0
  34. package/dist/exports/rsc.browser.d.ts +12 -0
  35. package/dist/exports/rsc.browser.d.ts.map +1 -0
  36. package/dist/exports/rsc.browser.js +12 -0
  37. package/dist/exports/rsc.browser.js.map +1 -0
  38. package/dist/exports/rsc.d.ts +5 -0
  39. package/dist/exports/rsc.d.ts.map +1 -0
  40. package/dist/exports/rsc.js +6 -0
  41. package/dist/exports/rsc.js.map +1 -0
  42. package/dist/exports/server.d.ts +17 -0
  43. package/dist/exports/server.d.ts.map +1 -0
  44. package/dist/exports/server.js +18 -0
  45. package/dist/exports/server.js.map +1 -0
  46. package/dist/exports/vite.d.ts +3 -0
  47. package/dist/exports/vite.d.ts.map +1 -0
  48. package/dist/exports/vite.js +3 -0
  49. package/dist/exports/vite.js.map +1 -0
  50. package/dist/index.d.ts +6 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +7 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/layouts/Root/getLayoutData.d.ts +12 -0
  55. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -0
  56. package/dist/layouts/Root/getLayoutData.js +91 -0
  57. package/dist/layouts/Root/getLayoutData.js.map +1 -0
  58. package/dist/layouts/Root/index.d.ts +32 -0
  59. package/dist/layouts/Root/index.d.ts.map +1 -0
  60. package/dist/layouts/Root/index.js +51 -0
  61. package/dist/layouts/Root/index.js.map +1 -0
  62. package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
  63. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  64. package/dist/layouts/Root/withPayloadRoot.js +92 -0
  65. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  66. package/dist/node/cssLoader.d.mts +25 -0
  67. package/dist/node/cssLoader.d.mts.map +1 -0
  68. package/dist/node/cssLoader.js +70 -0
  69. package/dist/node/cssLoader.js.map +1 -0
  70. package/dist/node/cssLoader.mjs +75 -0
  71. package/dist/node/registerCssLoader.d.mts +2 -0
  72. package/dist/node/registerCssLoader.d.mts.map +1 -0
  73. package/dist/node/registerCssLoader.js +10 -0
  74. package/dist/node/registerCssLoader.js.map +1 -0
  75. package/dist/node/registerCssLoader.mjs +10 -0
  76. package/dist/routes/adminRoutes.d.ts +111 -0
  77. package/dist/routes/adminRoutes.d.ts.map +1 -0
  78. package/dist/routes/adminRoutes.js +108 -0
  79. package/dist/routes/adminRoutes.js.map +1 -0
  80. package/dist/routes/apiRoute.d.ts +29 -0
  81. package/dist/routes/apiRoute.d.ts.map +1 -0
  82. package/dist/routes/apiRoute.js +38 -0
  83. package/dist/routes/apiRoute.js.map +1 -0
  84. package/dist/routes/layoutRoute.d.ts +26 -0
  85. package/dist/routes/layoutRoute.d.ts.map +1 -0
  86. package/dist/routes/layoutRoute.js +57 -0
  87. package/dist/routes/layoutRoute.js.map +1 -0
  88. package/dist/rsc/CollectionCards.d.ts +4 -0
  89. package/dist/rsc/CollectionCards.d.ts.map +1 -0
  90. package/dist/rsc/CollectionCards.js +12 -0
  91. package/dist/rsc/CollectionCards.js.map +1 -0
  92. package/dist/rsc/HierarchyTypeFieldServer.d.ts +9 -0
  93. package/dist/rsc/HierarchyTypeFieldServer.d.ts.map +1 -0
  94. package/dist/rsc/HierarchyTypeFieldServer.js +35 -0
  95. package/dist/rsc/HierarchyTypeFieldServer.js.map +1 -0
  96. package/dist/rsc/renderOnDemand.d.ts +15 -0
  97. package/dist/rsc/renderOnDemand.d.ts.map +1 -0
  98. package/dist/rsc/renderOnDemand.js +25 -0
  99. package/dist/rsc/renderOnDemand.js.map +1 -0
  100. package/dist/rsc/renderPayloadRSC.d.ts +6 -0
  101. package/dist/rsc/renderPayloadRSC.d.ts.map +1 -0
  102. package/dist/rsc/renderPayloadRSC.js +6 -0
  103. package/dist/rsc/renderPayloadRSC.js.map +1 -0
  104. package/dist/utilities/devReloadStrategy.d.ts +10 -0
  105. package/dist/utilities/devReloadStrategy.d.ts.map +1 -0
  106. package/dist/utilities/devReloadStrategy.js +27 -0
  107. package/dist/utilities/devReloadStrategy.js.map +1 -0
  108. package/dist/utilities/getExistingAuthToken.d.ts +7 -0
  109. package/dist/utilities/getExistingAuthToken.d.ts.map +1 -0
  110. package/dist/utilities/getExistingAuthToken.js +18 -0
  111. package/dist/utilities/getExistingAuthToken.js.map +1 -0
  112. package/dist/utilities/getPreferences.d.ts +10 -0
  113. package/dist/utilities/getPreferences.d.ts.map +1 -0
  114. package/dist/utilities/getPreferences.js +33 -0
  115. package/dist/utilities/getPreferences.js.map +1 -0
  116. package/dist/utilities/getRequestI18n.server.d.ts +12 -0
  117. package/dist/utilities/getRequestI18n.server.d.ts.map +1 -0
  118. package/dist/utilities/getRequestI18n.server.js +25 -0
  119. package/dist/utilities/getRequestI18n.server.js.map +1 -0
  120. package/dist/utilities/getRequestLocale.d.ts +7 -0
  121. package/dist/utilities/getRequestLocale.d.ts.map +1 -0
  122. package/dist/utilities/getRequestLocale.js +20 -0
  123. package/dist/utilities/getRequestLocale.js.map +1 -0
  124. package/dist/utilities/getRequestTheme.d.ts +10 -0
  125. package/dist/utilities/getRequestTheme.d.ts.map +1 -0
  126. package/dist/utilities/getRequestTheme.js +25 -0
  127. package/dist/utilities/getRequestTheme.js.map +1 -0
  128. package/dist/utilities/graphqlHandler.server.d.ts +12 -0
  129. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -0
  130. package/dist/utilities/graphqlHandler.server.js +129 -0
  131. package/dist/utilities/graphqlHandler.server.js.map +1 -0
  132. package/dist/utilities/handleAPIRoute.d.ts +11 -0
  133. package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
  134. package/dist/utilities/handleAPIRoute.js +17 -0
  135. package/dist/utilities/handleAPIRoute.js.map +1 -0
  136. package/dist/utilities/handleServerFunctions.d.ts +20 -0
  137. package/dist/utilities/handleServerFunctions.d.ts.map +1 -0
  138. package/dist/utilities/handleServerFunctions.js +60 -0
  139. package/dist/utilities/handleServerFunctions.js.map +1 -0
  140. package/dist/utilities/importMap.server.d.ts +8 -0
  141. package/dist/utilities/importMap.server.d.ts.map +1 -0
  142. package/dist/utilities/importMap.server.js +11 -0
  143. package/dist/utilities/importMap.server.js.map +1 -0
  144. package/dist/utilities/initReq.server.d.ts +19 -0
  145. package/dist/utilities/initReq.server.d.ts.map +1 -0
  146. package/dist/utilities/initReq.server.js +87 -0
  147. package/dist/utilities/initReq.server.js.map +1 -0
  148. package/dist/utilities/loadAdminPage.d.ts +54 -0
  149. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  150. package/dist/utilities/loadAdminPage.js +239 -0
  151. package/dist/utilities/loadAdminPage.js.map +1 -0
  152. package/dist/utilities/loadLayoutData.d.ts +15 -0
  153. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  154. package/dist/utilities/loadLayoutData.js +23 -0
  155. package/dist/utilities/loadLayoutData.js.map +1 -0
  156. package/dist/utilities/meta.d.ts +71 -0
  157. package/dist/utilities/meta.d.ts.map +1 -0
  158. package/dist/utilities/meta.js +143 -0
  159. package/dist/utilities/meta.js.map +1 -0
  160. package/dist/utilities/serializeForRsc.d.ts +26 -0
  161. package/dist/utilities/serializeForRsc.d.ts.map +1 -0
  162. package/dist/utilities/serializeForRsc.js +122 -0
  163. package/dist/utilities/serializeForRsc.js.map +1 -0
  164. package/dist/utilities/serverAdapter.server.d.ts +36 -0
  165. package/dist/utilities/serverAdapter.server.d.ts.map +1 -0
  166. package/dist/utilities/serverAdapter.server.js +130 -0
  167. package/dist/utilities/serverAdapter.server.js.map +1 -0
  168. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  169. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  170. package/dist/utilities/serverFunctionClient.js +109 -0
  171. package/dist/utilities/serverFunctionClient.js.map +1 -0
  172. package/dist/utilities/serverFunctionHandlers.d.ts +18 -0
  173. package/dist/utilities/serverFunctionHandlers.d.ts.map +1 -0
  174. package/dist/utilities/serverFunctionHandlers.js +17 -0
  175. package/dist/utilities/serverFunctionHandlers.js.map +1 -0
  176. package/dist/utilities/setPayloadAuthCookie.d.ts +9 -0
  177. package/dist/utilities/setPayloadAuthCookie.d.ts.map +1 -0
  178. package/dist/utilities/setPayloadAuthCookie.js +31 -0
  179. package/dist/utilities/setPayloadAuthCookie.js.map +1 -0
  180. package/dist/utilities/toSerializable.d.ts +2 -0
  181. package/dist/utilities/toSerializable.d.ts.map +1 -0
  182. package/dist/utilities/toSerializable.js +111 -0
  183. package/dist/utilities/toSerializable.js.map +1 -0
  184. package/dist/vite/config/external.d.ts +11 -0
  185. package/dist/vite/config/external.d.ts.map +1 -0
  186. package/dist/vite/config/external.js +48 -0
  187. package/dist/vite/config/external.js.map +1 -0
  188. package/dist/vite/config/optimizeDeps.d.ts +25 -0
  189. package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
  190. package/dist/vite/config/optimizeDeps.js +123 -0
  191. package/dist/vite/config/optimizeDeps.js.map +1 -0
  192. package/dist/vite/config/scss.d.ts +14 -0
  193. package/dist/vite/config/scss.d.ts.map +1 -0
  194. package/dist/vite/config/scss.js +28 -0
  195. package/dist/vite/config/scss.js.map +1 -0
  196. package/dist/vite/importProtection.d.ts +14 -0
  197. package/dist/vite/importProtection.d.ts.map +1 -0
  198. package/dist/vite/importProtection.js +54 -0
  199. package/dist/vite/importProtection.js.map +1 -0
  200. package/dist/vite/index.d.ts +99 -0
  201. package/dist/vite/index.d.ts.map +1 -0
  202. package/dist/vite/index.js +258 -0
  203. package/dist/vite/index.js.map +1 -0
  204. package/dist/vite/workarounds/clientModuleResolution.d.ts +14 -0
  205. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
  206. package/dist/vite/workarounds/clientModuleResolution.js +98 -0
  207. package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
  208. package/dist/vite/workarounds/devTransforms.d.ts +19 -0
  209. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
  210. package/dist/vite/workarounds/devTransforms.js +72 -0
  211. package/dist/vite/workarounds/devTransforms.js.map +1 -0
  212. package/dist/vite/workarounds/reactDomServerInRsc.d.ts +27 -0
  213. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  214. package/dist/vite/workarounds/reactDomServerInRsc.js +90 -0
  215. package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
  216. package/dist/vite/workarounds/stripDistStyleImports.d.ts +21 -0
  217. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
  218. package/dist/vite/workarounds/stripDistStyleImports.js +140 -0
  219. package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
  220. package/dist/vite/workarounds/stubPrettierInClient.d.ts +13 -0
  221. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
  222. package/dist/vite/workarounds/stubPrettierInClient.js +32 -0
  223. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
  224. package/dist/vite/workarounds/wrapCjsForClient.d.ts +15 -0
  225. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
  226. package/dist/vite/workarounds/wrapCjsForClient.js +106 -0
  227. package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
  228. package/package.json +111 -0
@@ -0,0 +1,122 @@
1
+ import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { createElement, Fragment } from 'react';
3
+ /**
4
+ * Recursively walk a server-function return value and prepare it for transit
5
+ * to the client as an RSC payload.
6
+ *
7
+ * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
8
+ * refs) with two key differences:
9
+ *
10
+ * 1. React elements are NOT stripped. They are passed through
11
+ * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
12
+ * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
13
+ * streams the underlying Flight payload to the client, where it is
14
+ * decoded back into a renderable React node. This matches the way
15
+ * Next.js's RSC payload format ships React elements over server actions
16
+ * and lets server-rendered custom field components (e.g. those returned
17
+ * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
18
+ * round trip.
19
+ *
20
+ * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
21
+ * transport cannot handle them, and Payload doesn't intentionally include
22
+ * them in server-function return values.
23
+ *
24
+ * Use this in `createServerFn` handlers that return Payload form/view state
25
+ * containing React elements (e.g. `state[path].customComponents.Field`).
26
+ */ export async function serializeForRsc(value) {
27
+ return await walk(value, new WeakMap(), new WeakSet());
28
+ }
29
+ async function walk(value, cache, ancestors) {
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 await renderServerComponent(value);
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
+ return obj;
52
+ }
53
+ if (obj instanceof RegExp) {
54
+ return undefined;
55
+ }
56
+ ancestors.add(obj);
57
+ if (obj instanceof Map) {
58
+ const cleaned = new Map();
59
+ cache.set(obj, cleaned);
60
+ for (const [k, v] of obj){
61
+ const cv = await walk(v, cache, ancestors);
62
+ if (cv !== undefined) {
63
+ cleaned.set(k, cv);
64
+ }
65
+ }
66
+ ancestors.delete(obj);
67
+ return cleaned;
68
+ }
69
+ if (obj instanceof Set) {
70
+ const cleaned = new Set();
71
+ cache.set(obj, cleaned);
72
+ for (const v of obj){
73
+ const cv = await walk(v, cache, ancestors);
74
+ if (cv !== undefined) {
75
+ cleaned.add(cv);
76
+ }
77
+ }
78
+ ancestors.delete(obj);
79
+ return cleaned;
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
+ }
98
+ const arr = [];
99
+ cache.set(obj, arr);
100
+ for (const item of obj){
101
+ arr.push(await walk(item, cache, ancestors));
102
+ }
103
+ ancestors.delete(obj);
104
+ return arr;
105
+ }
106
+ if (ArrayBuffer.isView(obj)) {
107
+ ancestors.delete(obj);
108
+ return obj;
109
+ }
110
+ const result = {};
111
+ cache.set(obj, result);
112
+ for (const key of Object.keys(obj)){
113
+ const v = await walk(obj[key], cache, ancestors);
114
+ if (v !== undefined) {
115
+ result[key] = v;
116
+ }
117
+ }
118
+ ancestors.delete(obj);
119
+ return result;
120
+ }
121
+
122
+ //# 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 { 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"}
@@ -0,0 +1,36 @@
1
+ import type { ServerAdapter } from 'payload';
2
+ /**
3
+ * Server-side adapter for TanStack Start.
4
+ * Uses `@tanstack/react-start/server` utilities for request/response handling.
5
+ */
6
+ export declare const tanstackServerAdapter: ServerAdapter;
7
+ /**
8
+ * Navigation requested during an admin page render, recorded by
9
+ * `createPageRenderServerAdapter`. The admin-page server function reads this
10
+ * after `renderServerComponent` resolves.
11
+ */
12
+ export type PageNavIntent = {
13
+ type?: 'notFound' | 'redirect';
14
+ url?: string;
15
+ };
16
+ /**
17
+ * Builds the `ServerAdapter` for the admin page render (`renderRoot`). Like
18
+ * `tanstackServerAdapter` for cookies/headers, but navigation **records the
19
+ * intent on `nav` and throws** the framework-agnostic string error-contract
20
+ * (`Error('not-found')` / `Error('redirect:<url>')`) instead of TanStack's
21
+ * native `notFound`/`redirect`.
22
+ *
23
+ * `renderRoot` navigates via `req.server.*` in two places:
24
+ * - during orchestration (e.g. the unauthenticated login redirect) — the throw
25
+ * propagates out of `renderRoot` and is caught by the loader's try/catch;
26
+ * - deep inside streamed view components (e.g. `DocumentView` access checks,
27
+ * `LoginView` already-authenticated) — here the throw happens during
28
+ * `renderServerComponent` and is swallowed into the RSC stream, so it never
29
+ * rejects the render promise.
30
+ *
31
+ * Recording the intent on `nav` lets the loader honor the second case by
32
+ * inspecting `nav` after the render resolves, then re-throwing native TanStack
33
+ * nav at the loader boundary.
34
+ */
35
+ export declare const createPageRenderServerAdapter: (nav: PageNavIntent) => ServerAdapter;
36
+ //# sourceMappingURL=serverAdapter.server.d.ts.map
@@ -0,0 +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,QAAS,aAAa,KAAG,aAgBjE,CAAA"}
@@ -0,0 +1,130 @@
1
+ import { notFound, redirect } from '@tanstack/react-router';
2
+ import { getRequest, setResponseHeader } from '@tanstack/react-start/server';
3
+ import { parseCookies } from 'payload';
4
+ function buildCookieStore(headers) {
5
+ const cookies = parseCookies(headers);
6
+ return {
7
+ get: (name)=>{
8
+ const value = cookies.get(name);
9
+ return value !== undefined ? {
10
+ name,
11
+ value
12
+ } : undefined;
13
+ },
14
+ getAll: ()=>{
15
+ return Array.from(cookies.entries()).map(([name, value])=>({
16
+ name,
17
+ value
18
+ }));
19
+ }
20
+ };
21
+ }
22
+ function serializeCookie(name, value, options) {
23
+ let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
24
+ if (options?.path) {
25
+ cookie += `; Path=${options.path}`;
26
+ }
27
+ if (options?.domain) {
28
+ cookie += `; Domain=${options.domain}`;
29
+ }
30
+ if (options?.maxAge !== undefined) {
31
+ cookie += `; Max-Age=${options.maxAge}`;
32
+ }
33
+ if (options?.expires) {
34
+ cookie += `; Expires=${options.expires.toUTCString()}`;
35
+ }
36
+ if (options?.httpOnly) {
37
+ cookie += '; HttpOnly';
38
+ }
39
+ if (options?.secure) {
40
+ cookie += '; Secure';
41
+ }
42
+ if (options?.sameSite) {
43
+ cookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`;
44
+ }
45
+ return cookie;
46
+ }
47
+ /**
48
+ * Server-side adapter for TanStack Start.
49
+ * Uses `@tanstack/react-start/server` utilities for request/response handling.
50
+ */ export const tanstackServerAdapter = {
51
+ getCookies: ()=>{
52
+ const request = getRequest();
53
+ const headers = new Headers(request.headers);
54
+ return buildCookieStore(headers);
55
+ },
56
+ getHeaders: ()=>{
57
+ const request = getRequest();
58
+ return new Headers(request.headers);
59
+ },
60
+ notFound: ()=>{
61
+ // TanStack Router requires throwing the notFound() result directly
62
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
63
+ throw notFound();
64
+ },
65
+ redirect: (path)=>{
66
+ // TanStack Router requires throwing the redirect() result directly
67
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
68
+ throw redirect({
69
+ to: path
70
+ });
71
+ },
72
+ permanentRedirect: (path)=>{
73
+ // TanStack Router does not have a separate permanent redirect primitive;
74
+ // fall back to a regular redirect so existing behavior is preserved.
75
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
76
+ throw redirect({
77
+ to: path
78
+ });
79
+ },
80
+ forbidden: ()=>{
81
+ // TanStack Router does not have a dedicated forbidden() helper; surface
82
+ // a generic error so the request boundary still terminates the request.
83
+ throw new Error('Forbidden');
84
+ },
85
+ unauthorized: ()=>{
86
+ // TanStack Router does not have a dedicated unauthorized() helper; surface
87
+ // a generic error so the request boundary still terminates the request.
88
+ throw new Error('Unauthorized');
89
+ },
90
+ setCookie: (name, value, options)=>{
91
+ setResponseHeader('Set-Cookie', serializeCookie(name, value, options));
92
+ }
93
+ };
94
+ /**
95
+ * Builds the `ServerAdapter` for the admin page render (`renderRoot`). Like
96
+ * `tanstackServerAdapter` for cookies/headers, but navigation **records the
97
+ * intent on `nav` and throws** the framework-agnostic string error-contract
98
+ * (`Error('not-found')` / `Error('redirect:<url>')`) instead of TanStack's
99
+ * native `notFound`/`redirect`.
100
+ *
101
+ * `renderRoot` navigates via `req.server.*` in two places:
102
+ * - during orchestration (e.g. the unauthenticated login redirect) — the throw
103
+ * propagates out of `renderRoot` and is caught by the loader's try/catch;
104
+ * - deep inside streamed view components (e.g. `DocumentView` access checks,
105
+ * `LoginView` already-authenticated) — here the throw happens during
106
+ * `renderServerComponent` and is swallowed into the RSC stream, so it never
107
+ * rejects the render promise.
108
+ *
109
+ * Recording the intent on `nav` lets the loader honor the second case by
110
+ * inspecting `nav` after the render resolves, then re-throwing native TanStack
111
+ * nav at the loader boundary.
112
+ */ export const createPageRenderServerAdapter = (nav)=>({
113
+ ...tanstackServerAdapter,
114
+ notFound: ()=>{
115
+ nav.type = 'notFound';
116
+ throw new Error('not-found');
117
+ },
118
+ permanentRedirect: (path)=>{
119
+ nav.type = 'redirect';
120
+ nav.url = path;
121
+ throw new Error(`redirect:${path}`);
122
+ },
123
+ redirect: (path)=>{
124
+ nav.type = 'redirect';
125
+ nav.url = path;
126
+ throw new Error(`redirect:${path}`);
127
+ }
128
+ });
129
+
130
+ //# sourceMappingURL=serverAdapter.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/serverAdapter.server.ts"],"sourcesContent":["import type { CookieOptions, CookieStore, ServerAdapter } from 'payload'\n\nimport { notFound, redirect } from '@tanstack/react-router'\nimport { getRequest, setResponseHeader } from '@tanstack/react-start/server'\nimport { parseCookies } from 'payload'\n\nfunction buildCookieStore(headers: Headers): CookieStore {\n const cookies = parseCookies(headers)\n\n return {\n get: (name: string) => {\n const value = cookies.get(name)\n return value !== undefined ? { name, value } : undefined\n },\n getAll: () => {\n return Array.from(cookies.entries()).map(([name, value]) => ({ name, value }))\n },\n }\n}\n\nfunction serializeCookie(name: string, value: string, options?: CookieOptions): string {\n let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`\n\n if (options?.path) {\n cookie += `; Path=${options.path}`\n }\n\n if (options?.domain) {\n cookie += `; Domain=${options.domain}`\n }\n\n if (options?.maxAge !== undefined) {\n cookie += `; Max-Age=${options.maxAge}`\n }\n\n if (options?.expires) {\n cookie += `; Expires=${options.expires.toUTCString()}`\n }\n\n if (options?.httpOnly) {\n cookie += '; HttpOnly'\n }\n\n if (options?.secure) {\n cookie += '; Secure'\n }\n\n if (options?.sameSite) {\n cookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`\n }\n\n return cookie\n}\n\n/**\n * Server-side adapter for TanStack Start.\n * Uses `@tanstack/react-start/server` utilities for request/response handling.\n */\nexport const tanstackServerAdapter: ServerAdapter = {\n getCookies: () => {\n const request = getRequest()\n const headers = new Headers(request.headers)\n return buildCookieStore(headers)\n },\n\n getHeaders: () => {\n const request = getRequest()\n return new Headers(request.headers)\n },\n\n notFound: () => {\n // TanStack Router requires throwing the notFound() result directly\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw notFound()\n },\n\n redirect: (path: string) => {\n // TanStack Router requires throwing the redirect() result directly\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw redirect({ to: path })\n },\n\n permanentRedirect: (path: string) => {\n // TanStack Router does not have a separate permanent redirect primitive;\n // fall back to a regular redirect so existing behavior is preserved.\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw redirect({ to: path })\n },\n\n forbidden: () => {\n // TanStack Router does not have a dedicated forbidden() helper; surface\n // a generic error so the request boundary still terminates the request.\n throw new Error('Forbidden')\n },\n\n unauthorized: () => {\n // TanStack Router does not have a dedicated unauthorized() helper; surface\n // a generic error so the request boundary still terminates the request.\n throw new Error('Unauthorized')\n },\n\n setCookie: (name: string, value: string, options?: CookieOptions) => {\n setResponseHeader('Set-Cookie', serializeCookie(name, value, options))\n },\n}\n\n/**\n * Navigation requested during an admin page render, recorded by\n * `createPageRenderServerAdapter`. The admin-page server function reads this\n * after `renderServerComponent` resolves.\n */\nexport type PageNavIntent = {\n type?: 'notFound' | 'redirect'\n url?: string\n}\n\n/**\n * Builds the `ServerAdapter` for the admin page render (`renderRoot`). Like\n * `tanstackServerAdapter` for cookies/headers, but navigation **records the\n * intent on `nav` and throws** the framework-agnostic string error-contract\n * (`Error('not-found')` / `Error('redirect:<url>')`) instead of TanStack's\n * native `notFound`/`redirect`.\n *\n * `renderRoot` navigates via `req.server.*` in two places:\n * - during orchestration (e.g. the unauthenticated login redirect) — the throw\n * propagates out of `renderRoot` and is caught by the loader's try/catch;\n * - deep inside streamed view components (e.g. `DocumentView` access checks,\n * `LoginView` already-authenticated) — here the throw happens during\n * `renderServerComponent` and is swallowed into the RSC stream, so it never\n * rejects the render promise.\n *\n * Recording the intent on `nav` lets the loader honor the second case by\n * inspecting `nav` after the render resolves, then re-throwing native TanStack\n * nav at the loader boundary.\n */\nexport const createPageRenderServerAdapter = (nav: PageNavIntent): ServerAdapter => ({\n ...tanstackServerAdapter,\n notFound: () => {\n nav.type = 'notFound'\n throw new Error('not-found')\n },\n permanentRedirect: (path: string) => {\n nav.type = 'redirect'\n nav.url = path\n throw new Error(`redirect:${path}`)\n },\n redirect: (path: string) => {\n nav.type = 'redirect'\n nav.url = path\n throw new Error(`redirect:${path}`)\n },\n})\n"],"names":["notFound","redirect","getRequest","setResponseHeader","parseCookies","buildCookieStore","headers","cookies","get","name","value","undefined","getAll","Array","from","entries","map","serializeCookie","options","cookie","encodeURIComponent","path","domain","maxAge","expires","toUTCString","httpOnly","secure","sameSite","charAt","toUpperCase","slice","tanstackServerAdapter","getCookies","request","Headers","getHeaders","to","permanentRedirect","forbidden","Error","unauthorized","setCookie","createPageRenderServerAdapter","nav","type","url"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,yBAAwB;AAC3D,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,+BAA8B;AAC5E,SAASC,YAAY,QAAQ,UAAS;AAEtC,SAASC,iBAAiBC,OAAgB;IACxC,MAAMC,UAAUH,aAAaE;IAE7B,OAAO;QACLE,KAAK,CAACC;YACJ,MAAMC,QAAQH,QAAQC,GAAG,CAACC;YAC1B,OAAOC,UAAUC,YAAY;gBAAEF;gBAAMC;YAAM,IAAIC;QACjD;QACAC,QAAQ;YACN,OAAOC,MAAMC,IAAI,CAACP,QAAQQ,OAAO,IAAIC,GAAG,CAAC,CAAC,CAACP,MAAMC,MAAM,GAAM,CAAA;oBAAED;oBAAMC;gBAAM,CAAA;QAC7E;IACF;AACF;AAEA,SAASO,gBAAgBR,IAAY,EAAEC,KAAa,EAAEQ,OAAuB;IAC3E,IAAIC,SAAS,GAAGC,mBAAmBX,MAAM,CAAC,EAAEW,mBAAmBV,QAAQ;IAEvE,IAAIQ,SAASG,MAAM;QACjBF,UAAU,CAAC,OAAO,EAAED,QAAQG,IAAI,EAAE;IACpC;IAEA,IAAIH,SAASI,QAAQ;QACnBH,UAAU,CAAC,SAAS,EAAED,QAAQI,MAAM,EAAE;IACxC;IAEA,IAAIJ,SAASK,WAAWZ,WAAW;QACjCQ,UAAU,CAAC,UAAU,EAAED,QAAQK,MAAM,EAAE;IACzC;IAEA,IAAIL,SAASM,SAAS;QACpBL,UAAU,CAAC,UAAU,EAAED,QAAQM,OAAO,CAACC,WAAW,IAAI;IACxD;IAEA,IAAIP,SAASQ,UAAU;QACrBP,UAAU;IACZ;IAEA,IAAID,SAASS,QAAQ;QACnBR,UAAU;IACZ;IAEA,IAAID,SAASU,UAAU;QACrBT,UAAU,CAAC,WAAW,EAAED,QAAQU,QAAQ,CAACC,MAAM,CAAC,GAAGC,WAAW,KAAKZ,QAAQU,QAAQ,CAACG,KAAK,CAAC,IAAI;IAChG;IAEA,OAAOZ;AACT;AAEA;;;CAGC,GACD,OAAO,MAAMa,wBAAuC;IAClDC,YAAY;QACV,MAAMC,UAAUhC;QAChB,MAAMI,UAAU,IAAI6B,QAAQD,QAAQ5B,OAAO;QAC3C,OAAOD,iBAAiBC;IAC1B;IAEA8B,YAAY;QACV,MAAMF,UAAUhC;QAChB,OAAO,IAAIiC,QAAQD,QAAQ5B,OAAO;IACpC;IAEAN,UAAU;QACR,mEAAmE;QACnE,+DAA+D;QAC/D,MAAMA;IACR;IAEAC,UAAU,CAACoB;QACT,mEAAmE;QACnE,+DAA+D;QAC/D,MAAMpB,SAAS;YAAEoC,IAAIhB;QAAK;IAC5B;IAEAiB,mBAAmB,CAACjB;QAClB,yEAAyE;QACzE,qEAAqE;QACrE,+DAA+D;QAC/D,MAAMpB,SAAS;YAAEoC,IAAIhB;QAAK;IAC5B;IAEAkB,WAAW;QACT,wEAAwE;QACxE,wEAAwE;QACxE,MAAM,IAAIC,MAAM;IAClB;IAEAC,cAAc;QACZ,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,IAAID,MAAM;IAClB;IAEAE,WAAW,CAACjC,MAAcC,OAAeQ;QACvCf,kBAAkB,cAAcc,gBAAgBR,MAAMC,OAAOQ;IAC/D;AACF,EAAC;AAYD;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMyB,gCAAgC,CAACC,MAAuC,CAAA;QACnF,GAAGZ,qBAAqB;QACxBhC,UAAU;YACR4C,IAAIC,IAAI,GAAG;YACX,MAAM,IAAIL,MAAM;QAClB;QACAF,mBAAmB,CAACjB;YAClBuB,IAAIC,IAAI,GAAG;YACXD,IAAIE,GAAG,GAAGzB;YACV,MAAM,IAAImB,MAAM,CAAC,SAAS,EAAEnB,MAAM;QACpC;QACApB,UAAU,CAACoB;YACTuB,IAAIC,IAAI,GAAG;YACXD,IAAIE,GAAG,GAAGzB;YACV,MAAM,IAAImB,MAAM,CAAC,SAAS,EAAEnB,MAAM;QACpC;IACF,CAAA,EAAE"}
@@ -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,18 @@
1
+ import type { ServerFunction } from 'payload';
2
+ /**
3
+ * Framework-agnostic server-function handlers the TanStack Start dispatcher
4
+ * registers to reach parity with the Next.js adapter
5
+ * (`packages/next/src/utilities/handleServerFunctions.ts`).
6
+ */
7
+ type SwitchLanguageArgs = {
8
+ lang: string;
9
+ };
10
+ /**
11
+ * Dispatched from `TranslationProvider` when the user switches the admin
12
+ * language. Writes the `<cookiePrefix>-lng` cookie via the request's
13
+ * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by
14
+ * the provider's `router.refresh()` — reads the new language.
15
+ */
16
+ export declare const switchLanguageHandler: ServerFunction<SwitchLanguageArgs, Promise<void>>;
17
+ export {};
18
+ //# sourceMappingURL=serverFunctionHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverFunctionHandlers.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;GAIG;AAEH,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAcnF,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dispatched from `TranslationProvider` when the user switches the admin
3
+ * language. Writes the `<cookiePrefix>-lng` cookie via the request's
4
+ * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by
5
+ * the provider's `router.refresh()` — reads the new language.
6
+ */ export const switchLanguageHandler = async ({ lang, req })=>{
7
+ if (!req.server) {
8
+ throw new Error('switch-language requires a ServerAdapter on the request');
9
+ }
10
+ const cookieName = `${req.payload.config.cookiePrefix || 'payload'}-lng`;
11
+ await req.server.setCookie(cookieName, lang, {
12
+ maxAge: 60 * 60 * 24 * 365,
13
+ path: '/'
14
+ });
15
+ };
16
+
17
+ //# sourceMappingURL=serverFunctionHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/serverFunctionHandlers.ts"],"sourcesContent":["import type { ServerFunction } from 'payload'\n\n/**\n * Framework-agnostic server-function handlers the TanStack Start dispatcher\n * registers to reach parity with the Next.js adapter\n * (`packages/next/src/utilities/handleServerFunctions.ts`).\n */\n\ntype SwitchLanguageArgs = {\n lang: string\n}\n\n/**\n * Dispatched from `TranslationProvider` when the user switches the admin\n * language. Writes the `<cookiePrefix>-lng` cookie via the request's\n * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by\n * the provider's `router.refresh()` — reads the new language.\n */\nexport const switchLanguageHandler: ServerFunction<SwitchLanguageArgs, Promise<void>> = async ({\n lang,\n req,\n}) => {\n if (!req.server) {\n throw new Error('switch-language requires a ServerAdapter on the request')\n }\n\n const cookieName = `${req.payload.config.cookiePrefix || 'payload'}-lng`\n\n await req.server.setCookie(cookieName, lang, {\n maxAge: 60 * 60 * 24 * 365,\n path: '/',\n })\n}\n"],"names":["switchLanguageHandler","lang","req","server","Error","cookieName","payload","config","cookiePrefix","setCookie","maxAge","path"],"mappings":"AAYA;;;;;CAKC,GACD,OAAO,MAAMA,wBAA2E,OAAO,EAC7FC,IAAI,EACJC,GAAG,EACJ;IACC,IAAI,CAACA,IAAIC,MAAM,EAAE;QACf,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,aAAa,GAAGH,IAAII,OAAO,CAACC,MAAM,CAACC,YAAY,IAAI,UAAU,IAAI,CAAC;IAExE,MAAMN,IAAIC,MAAM,CAACM,SAAS,CAACJ,YAAYJ,MAAM;QAC3CS,QAAQ,KAAK,KAAK,KAAK;QACvBC,MAAM;IACR;AACF,EAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Auth } from 'payload';
2
+ type SetPayloadAuthCookieArgs = {
3
+ authConfig: Auth;
4
+ cookiePrefix: string;
5
+ token: string;
6
+ };
7
+ export declare function setPayloadAuthCookie({ authConfig, cookiePrefix, token, }: SetPayloadAuthCookieArgs): void;
8
+ export {};
9
+ //# sourceMappingURL=setPayloadAuthCookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setPayloadAuthCookie.d.ts","sourceRoot":"","sources":["../../src/utilities/setPayloadAuthCookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAKnC,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,IAAI,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,YAAY,EACZ,KAAK,GACN,EAAE,wBAAwB,GAAG,IAAI,CAoCjC"}
@@ -0,0 +1,31 @@
1
+ import { setResponseHeader } from '@tanstack/react-start/server';
2
+ import { generatePayloadCookie } from 'payload';
3
+ export function setPayloadAuthCookie({ authConfig, cookiePrefix, token }) {
4
+ const cookieExpiration = authConfig.tokenExpiration ? new Date(Date.now() + authConfig.tokenExpiration) : undefined;
5
+ const payloadCookie = generatePayloadCookie({
6
+ collectionAuthConfig: authConfig,
7
+ cookiePrefix,
8
+ expires: cookieExpiration,
9
+ returnCookieAsObject: true,
10
+ token
11
+ });
12
+ if (payloadCookie.value) {
13
+ const sameSite = typeof authConfig.cookies.sameSite === 'string' ? authConfig.cookies.sameSite : 'Lax';
14
+ let cookie = `${encodeURIComponent(payloadCookie.name)}=${encodeURIComponent(payloadCookie.value)}`;
15
+ cookie += '; HttpOnly';
16
+ cookie += `; SameSite=${sameSite}`;
17
+ cookie += '; Path=/';
18
+ if (authConfig.cookies.secure) {
19
+ cookie += '; Secure';
20
+ }
21
+ if (authConfig.cookies.domain) {
22
+ cookie += `; Domain=${authConfig.cookies.domain}`;
23
+ }
24
+ if (payloadCookie.expires) {
25
+ cookie += `; Expires=${new Date(payloadCookie.expires).toUTCString()}`;
26
+ }
27
+ setResponseHeader('Set-Cookie', cookie);
28
+ }
29
+ }
30
+
31
+ //# sourceMappingURL=setPayloadAuthCookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/setPayloadAuthCookie.ts"],"sourcesContent":["import type { Auth } from 'payload'\n\nimport { setResponseHeader } from '@tanstack/react-start/server'\nimport { generatePayloadCookie } from 'payload'\n\ntype SetPayloadAuthCookieArgs = {\n authConfig: Auth\n cookiePrefix: string\n token: string\n}\n\nexport function setPayloadAuthCookie({\n authConfig,\n cookiePrefix,\n token,\n}: SetPayloadAuthCookieArgs): void {\n const cookieExpiration = authConfig.tokenExpiration\n ? new Date(Date.now() + authConfig.tokenExpiration)\n : undefined\n\n const payloadCookie = generatePayloadCookie({\n collectionAuthConfig: authConfig,\n cookiePrefix,\n expires: cookieExpiration,\n returnCookieAsObject: true,\n token,\n })\n\n if (payloadCookie.value) {\n const sameSite =\n typeof authConfig.cookies.sameSite === 'string' ? authConfig.cookies.sameSite : 'Lax'\n\n let cookie = `${encodeURIComponent(payloadCookie.name)}=${encodeURIComponent(payloadCookie.value)}`\n cookie += '; HttpOnly'\n cookie += `; SameSite=${sameSite}`\n cookie += '; Path=/'\n\n if (authConfig.cookies.secure) {\n cookie += '; Secure'\n }\n\n if (authConfig.cookies.domain) {\n cookie += `; Domain=${authConfig.cookies.domain}`\n }\n\n if (payloadCookie.expires) {\n cookie += `; Expires=${new Date(payloadCookie.expires).toUTCString()}`\n }\n\n setResponseHeader('Set-Cookie', cookie)\n }\n}\n"],"names":["setResponseHeader","generatePayloadCookie","setPayloadAuthCookie","authConfig","cookiePrefix","token","cookieExpiration","tokenExpiration","Date","now","undefined","payloadCookie","collectionAuthConfig","expires","returnCookieAsObject","value","sameSite","cookies","cookie","encodeURIComponent","name","secure","domain","toUTCString"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,qBAAqB,QAAQ,UAAS;AAQ/C,OAAO,SAASC,qBAAqB,EACnCC,UAAU,EACVC,YAAY,EACZC,KAAK,EACoB;IACzB,MAAMC,mBAAmBH,WAAWI,eAAe,GAC/C,IAAIC,KAAKA,KAAKC,GAAG,KAAKN,WAAWI,eAAe,IAChDG;IAEJ,MAAMC,gBAAgBV,sBAAsB;QAC1CW,sBAAsBT;QACtBC;QACAS,SAASP;QACTQ,sBAAsB;QACtBT;IACF;IAEA,IAAIM,cAAcI,KAAK,EAAE;QACvB,MAAMC,WACJ,OAAOb,WAAWc,OAAO,CAACD,QAAQ,KAAK,WAAWb,WAAWc,OAAO,CAACD,QAAQ,GAAG;QAElF,IAAIE,SAAS,GAAGC,mBAAmBR,cAAcS,IAAI,EAAE,CAAC,EAAED,mBAAmBR,cAAcI,KAAK,GAAG;QACnGG,UAAU;QACVA,UAAU,CAAC,WAAW,EAAEF,UAAU;QAClCE,UAAU;QAEV,IAAIf,WAAWc,OAAO,CAACI,MAAM,EAAE;YAC7BH,UAAU;QACZ;QAEA,IAAIf,WAAWc,OAAO,CAACK,MAAM,EAAE;YAC7BJ,UAAU,CAAC,SAAS,EAAEf,WAAWc,OAAO,CAACK,MAAM,EAAE;QACnD;QAEA,IAAIX,cAAcE,OAAO,EAAE;YACzBK,UAAU,CAAC,UAAU,EAAE,IAAIV,KAAKG,cAAcE,OAAO,EAAEU,WAAW,IAAI;QACxE;QAEAvB,kBAAkB,cAAckB;IAClC;AACF"}
@@ -0,0 +1,2 @@
1
+ export declare function toSerializable<T>(value: T): T;
2
+ //# sourceMappingURL=toSerializable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toSerializable.d.ts","sourceRoot":"","sources":["../../src/utilities/toSerializable.ts"],"names":[],"mappings":"AA6HA,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE7C"}