@payloadcms/tanstack-start 4.0.0-internal.7b031c8 → 4.0.0-internal.7b53b6d
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.
- package/dist/adapters/handleServerFunctions.d.ts +3 -0
- package/dist/adapters/handleServerFunctions.d.ts.map +1 -0
- package/dist/adapters/handleServerFunctions.js +17 -0
- package/dist/adapters/handleServerFunctions.js.map +1 -0
- package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
- package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
- package/dist/adapters/layout/RootProviders/index.js +21 -0
- package/dist/adapters/layout/RootProviders/index.js.map +1 -0
- package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout/index.d.ts} +32 -4
- package/dist/adapters/layout/index.d.ts.map +1 -0
- package/dist/adapters/layout/index.js +107 -0
- package/dist/adapters/layout/index.js.map +1 -0
- package/dist/adapters/layout/lazy.d.ts +7 -0
- package/dist/adapters/layout/lazy.d.ts.map +1 -0
- package/dist/adapters/layout/lazy.js +17 -0
- package/dist/adapters/layout/lazy.js.map +1 -0
- package/dist/adapters/layout/outlet.d.ts +4 -0
- package/dist/adapters/layout/outlet.d.ts.map +1 -0
- package/dist/adapters/layout/outlet.js +9 -0
- package/dist/adapters/layout/outlet.js.map +1 -0
- package/dist/adapters/layout/server.d.ts +23 -0
- package/dist/adapters/layout/server.d.ts.map +1 -0
- package/dist/adapters/layout/server.js +65 -0
- package/dist/adapters/layout/server.js.map +1 -0
- package/dist/{utilities/meta.d.ts → adapters/metadata.d.ts} +10 -1
- package/dist/adapters/metadata.d.ts.map +1 -0
- package/dist/{utilities/meta.js → adapters/metadata.js} +60 -1
- package/dist/adapters/metadata.js.map +1 -0
- package/dist/{elements/RouterAdapter/index.d.ts → adapters/router.d.ts} +1 -1
- package/dist/adapters/router.d.ts.map +1 -0
- package/dist/{elements/RouterAdapter/index.js → adapters/router.js} +43 -17
- package/dist/adapters/router.js.map +1 -0
- package/dist/{utilities/serverAdapter.server.d.ts → adapters/server.d.ts} +1 -1
- package/dist/adapters/server.d.ts.map +1 -0
- package/dist/{utilities/serverAdapter.server.js → adapters/server.js} +3 -30
- package/dist/adapters/server.js.map +1 -0
- package/dist/{routes/adminRoutes.d.ts → adapters/views/index.d.ts} +15 -19
- package/dist/adapters/views/index.d.ts.map +1 -0
- package/dist/adapters/views/index.js +101 -0
- package/dist/adapters/views/index.js.map +1 -0
- package/dist/adapters/views/lazy.d.ts +4 -0
- package/dist/adapters/views/lazy.d.ts.map +1 -0
- package/dist/adapters/views/lazy.js +44 -0
- package/dist/adapters/views/lazy.js.map +1 -0
- package/dist/{utilities/loadAdminPage.d.ts → adapters/views/server.d.ts} +12 -6
- package/dist/adapters/views/server.d.ts.map +1 -0
- package/dist/{utilities/loadAdminPage.js → adapters/views/server.js} +28 -89
- package/dist/adapters/views/server.js.map +1 -0
- package/dist/auth/login.d.ts +3 -16
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js +6 -46
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -5
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js +6 -47
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -4
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +6 -49
- package/dist/auth/refresh.js.map +1 -1
- package/dist/exports/client/layout.d.ts +2 -0
- package/dist/exports/client/layout.d.ts.map +1 -0
- package/dist/exports/client/layout.js +4 -0
- package/dist/exports/client/layout.js.map +1 -0
- package/dist/exports/client.d.ts +3 -7
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +3 -7
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +2 -5
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -3
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/routes.d.ts +2 -0
- package/dist/exports/routes.d.ts.map +1 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/routes.js.map +1 -0
- package/dist/exports/rsc.browser.d.ts +4 -1
- package/dist/exports/rsc.browser.d.ts.map +1 -1
- package/dist/exports/rsc.browser.js +4 -1
- package/dist/exports/rsc.browser.js.map +1 -1
- package/dist/exports/rsc.d.ts +0 -1
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +0 -1
- package/dist/exports/rsc.js.map +1 -1
- package/dist/exports/server.d.ts +6 -12
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +6 -12
- package/dist/exports/server.js.map +1 -1
- package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -3
- package/dist/routes/graphql/handler.server.d.ts.map +1 -0
- package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +9 -6
- package/dist/routes/graphql/handler.server.js.map +1 -0
- package/dist/routes/rest/handler.server.d.ts +11 -0
- package/dist/routes/rest/handler.server.d.ts.map +1 -0
- package/dist/routes/rest/handler.server.js +14 -0
- package/dist/routes/rest/handler.server.js.map +1 -0
- package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +5 -4
- package/dist/routes/rest/index.d.ts.map +1 -0
- package/dist/routes/{apiRoute.js → rest/index.js} +6 -5
- package/dist/routes/rest/index.js.map +1 -0
- package/dist/rsc/CollectionCards.js +1 -1
- package/dist/rsc/CollectionCards.js.map +1 -1
- package/dist/utilities/devConfigReload.server.d.ts +2 -0
- package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
- package/dist/utilities/devConfigReload.server.js +61 -0
- package/dist/utilities/devConfigReload.server.js.map +1 -0
- package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
- package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
- package/dist/utilities/devConfigReloadEvent.js +9 -0
- package/dist/utilities/devConfigReloadEvent.js.map +1 -0
- package/dist/utilities/getRequestI18n.server.d.ts +1 -1
- package/dist/utilities/getRequestI18n.server.js +1 -1
- package/dist/utilities/getRequestI18n.server.js.map +1 -1
- package/dist/utilities/initAdminContext.server.d.ts +9 -0
- package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
- package/dist/utilities/initAdminContext.server.js +13 -0
- package/dist/utilities/initAdminContext.server.js.map +1 -0
- package/dist/utilities/serverFunctionClient.d.ts +2 -23
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +12 -101
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +19 -21
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +38 -32
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
- package/dist/withPayload/config/optimizeDeps.js +44 -7
- package/dist/withPayload/config/optimizeDeps.js.map +1 -1
- package/dist/withPayload/devConfigReload.d.ts +14 -0
- package/dist/withPayload/devConfigReload.d.ts.map +1 -0
- package/dist/withPayload/devConfigReload.js +84 -0
- package/dist/withPayload/devConfigReload.js.map +1 -0
- package/dist/withPayload/importProtection.d.ts.map +1 -1
- package/dist/withPayload/importProtection.js +2 -2
- package/dist/withPayload/importProtection.js.map +1 -1
- package/dist/withPayload/index.d.ts +24 -11
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +50 -19
- package/dist/withPayload/index.js.map +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js +2 -2
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
- package/package.json +35 -29
- package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
- package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeaderClient/index.js +0 -116
- package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
- package/dist/elements/RenderComponent/index.d.ts +0 -10
- package/dist/elements/RenderComponent/index.d.ts.map +0 -1
- package/dist/elements/RenderComponent/index.js +0 -12
- package/dist/elements/RenderComponent/index.js.map +0 -1
- package/dist/elements/RouterAdapter/index.d.ts.map +0 -1
- package/dist/elements/RouterAdapter/index.js.map +0 -1
- package/dist/layouts/Root/getLayoutData.d.ts +0 -12
- package/dist/layouts/Root/getLayoutData.d.ts.map +0 -1
- package/dist/layouts/Root/getLayoutData.js +0 -91
- package/dist/layouts/Root/getLayoutData.js.map +0 -1
- package/dist/layouts/Root/index.d.ts +0 -32
- package/dist/layouts/Root/index.d.ts.map +0 -1
- package/dist/layouts/Root/index.js +0 -53
- package/dist/layouts/Root/index.js.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.js +0 -91
- package/dist/layouts/Root/withPayloadRoot.js.map +0 -1
- package/dist/node/cssLoader.d.mts +0 -25
- package/dist/node/cssLoader.d.mts.map +0 -1
- package/dist/node/cssLoader.js +0 -70
- package/dist/node/cssLoader.js.map +0 -1
- package/dist/node/cssLoader.mjs +0 -75
- package/dist/node/registerCssLoader.d.mts +0 -2
- package/dist/node/registerCssLoader.d.mts.map +0 -1
- package/dist/node/registerCssLoader.js +0 -10
- package/dist/node/registerCssLoader.js.map +0 -1
- package/dist/node/registerCssLoader.mjs +0 -10
- package/dist/routes/adminRoutes.d.ts.map +0 -1
- package/dist/routes/adminRoutes.js +0 -108
- package/dist/routes/adminRoutes.js.map +0 -1
- package/dist/routes/apiRoute.d.ts.map +0 -1
- package/dist/routes/apiRoute.js.map +0 -1
- package/dist/routes/layoutRoute.d.ts +0 -26
- package/dist/routes/layoutRoute.d.ts.map +0 -1
- package/dist/routes/layoutRoute.js +0 -57
- package/dist/routes/layoutRoute.js.map +0 -1
- package/dist/rsc/renderPayloadRSC.d.ts +0 -6
- package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
- package/dist/rsc/renderPayloadRSC.js +0 -6
- package/dist/rsc/renderPayloadRSC.js.map +0 -1
- package/dist/utilities/devReloadStrategy.d.ts +0 -10
- package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
- package/dist/utilities/devReloadStrategy.js +0 -27
- package/dist/utilities/devReloadStrategy.js.map +0 -1
- package/dist/utilities/getExistingAuthToken.d.ts +0 -7
- package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
- package/dist/utilities/getExistingAuthToken.js +0 -18
- package/dist/utilities/getExistingAuthToken.js.map +0 -1
- package/dist/utilities/getPreferences.d.ts +0 -10
- package/dist/utilities/getPreferences.d.ts.map +0 -1
- package/dist/utilities/getPreferences.js +0 -33
- package/dist/utilities/getPreferences.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -20
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/graphqlHandler.server.d.ts.map +0 -1
- package/dist/utilities/graphqlHandler.server.js.map +0 -1
- package/dist/utilities/handleAPIRoute.server.d.ts +0 -11
- package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.server.js +0 -17
- package/dist/utilities/handleAPIRoute.server.js.map +0 -1
- package/dist/utilities/handleServerFunctions.d.ts +0 -20
- package/dist/utilities/handleServerFunctions.d.ts.map +0 -1
- package/dist/utilities/handleServerFunctions.js +0 -60
- package/dist/utilities/handleServerFunctions.js.map +0 -1
- package/dist/utilities/importMap.server.d.ts +0 -8
- package/dist/utilities/importMap.server.d.ts.map +0 -1
- package/dist/utilities/importMap.server.js +0 -11
- package/dist/utilities/importMap.server.js.map +0 -1
- package/dist/utilities/initReq.server.d.ts +0 -19
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -87
- package/dist/utilities/initReq.server.js.map +0 -1
- package/dist/utilities/loadAdminPage.d.ts.map +0 -1
- package/dist/utilities/loadAdminPage.js.map +0 -1
- package/dist/utilities/loadLayoutData.d.ts +0 -15
- package/dist/utilities/loadLayoutData.d.ts.map +0 -1
- package/dist/utilities/loadLayoutData.js +0 -23
- package/dist/utilities/loadLayoutData.js.map +0 -1
- package/dist/utilities/meta.d.ts.map +0 -1
- package/dist/utilities/meta.js.map +0 -1
- package/dist/utilities/serializeForRsc.d.ts +0 -26
- package/dist/utilities/serializeForRsc.d.ts.map +0 -1
- package/dist/utilities/serializeForRsc.js +0 -122
- package/dist/utilities/serializeForRsc.js.map +0 -1
- package/dist/utilities/serverAdapter.server.d.ts.map +0 -1
- package/dist/utilities/serverAdapter.server.js.map +0 -1
- package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
- package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
- package/dist/utilities/serverFunctionHandlers.js +0 -17
- package/dist/utilities/serverFunctionHandlers.js.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
- package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.js +0 -31
- package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
- package/dist/utilities/toSerializable.d.ts +0 -2
- package/dist/utilities/toSerializable.d.ts.map +0 -1
- package/dist/utilities/toSerializable.js +0 -111
- package/dist/utilities/toSerializable.js.map +0 -1
|
@@ -1,122 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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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,MAAMa,GAAG,CAACT,KAAKuB;QACf,KAAK,MAAMJ,QAAQnB,IAAK;YACtBuB,IAAIC,IAAI,CAAC,MAAM/B,KAAK0B,MAAMvB,OAAOC;QACnC;QACAA,UAAUgB,MAAM,CAACb;QACjB,OAAOuB;IACT;IAEA,IAAIE,YAAYC,MAAM,CAAC1B,MAAM;QAC3BH,UAAUgB,MAAM,CAACb;QACjB,OAAOA;IACT;IAEA,MAAM2B,SAAkC,CAAC;IACzC/B,MAAMa,GAAG,CAACT,KAAK2B;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC9B,KAAM;QAClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAAC4B,IAAI,EAAEhC,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnB6B,MAAM,CAACC,IAAI,GAAGjB;QAChB;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,QA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GAAG;YACXD,IAAIE,GAAG,GAAGzB;YACV,MAAM,IAAImB,MAAM,CAAC,SAAS,EAAEnB,MAAM;QACpC;IACF,CAAA,EAAE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively strip values that seroval cannot serialize (React elements,
|
|
3
|
-
* functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.
|
|
4
|
-
*
|
|
5
|
-
* TanStack Start uses seroval to transfer server function return values to
|
|
6
|
-
* the client. Payload's `getClientConfig` / `getLayoutData` may include
|
|
7
|
-
* callback functions or RegExp instances that seroval chokes on. Running
|
|
8
|
-
* the data through this function before returning from a `createServerFn`
|
|
9
|
-
* handler keeps the transfer safe.
|
|
10
|
-
*
|
|
11
|
-
* For server functions whose payloads contain React elements (e.g. the
|
|
12
|
-
* shared `form-state` / `render-list` / `render-document` handlers), use
|
|
13
|
-
* `serializeForRsc` instead — it converts elements into RSC handles rather
|
|
14
|
-
* than stripping them.
|
|
15
|
-
*
|
|
16
|
-
* Uses a WeakMap cache so that shared object references (e.g. the same array
|
|
17
|
-
* referenced by both `doc.hasMany` and `formState.hasMany.value`) are
|
|
18
|
-
* returned correctly instead of being dropped as "already seen".
|
|
19
|
-
*
|
|
20
|
-
* A separate `ancestors` WeakSet tracks objects currently being recursed into.
|
|
21
|
-
* If an object is encountered while it is still on the recursion stack, the
|
|
22
|
-
* reference is circular and is replaced with `undefined` to keep the output
|
|
23
|
-
* JSON-safe. Once recursion completes the object is removed from `ancestors`,
|
|
24
|
-
* so sibling/cousin references to the same (fully-processed) object still
|
|
25
|
-
* resolve to the cached clone.
|
|
26
|
-
*/ function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
|
|
27
|
-
if (value === null || value === undefined) {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
const t = typeof value;
|
|
31
|
-
if (t === 'function' || t === 'symbol') {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
if (t !== 'object') {
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
const obj = value;
|
|
38
|
-
if (typeof obj.$$typeof === 'symbol') {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
if (ancestors.has(obj)) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
if (cache.has(obj)) {
|
|
45
|
-
return cache.get(obj);
|
|
46
|
-
}
|
|
47
|
-
if (obj instanceof Date) {
|
|
48
|
-
return obj;
|
|
49
|
-
}
|
|
50
|
-
// RegExp: seroval's SSR bootstrap emits regex literals with broken escape
|
|
51
|
-
// sequences (e.g. `/!\\[.../` instead of `/!\[.../`), crashing the client
|
|
52
|
-
// script that populates `window.$_TSR` and preventing hydration. Rich-text
|
|
53
|
-
// feature transformer regexes aren't needed on the client (they drive
|
|
54
|
-
// server-side markdown import/export), so strip them here.
|
|
55
|
-
if (obj instanceof RegExp) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
ancestors.add(obj);
|
|
59
|
-
if (obj instanceof Map) {
|
|
60
|
-
const cleaned = new Map();
|
|
61
|
-
cache.set(obj, cleaned);
|
|
62
|
-
for (const [k, v] of obj){
|
|
63
|
-
const cv = stripUnserializable(v, cache, ancestors);
|
|
64
|
-
if (cv !== undefined) {
|
|
65
|
-
cleaned.set(k, cv);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
ancestors.delete(obj);
|
|
69
|
-
return cleaned;
|
|
70
|
-
}
|
|
71
|
-
if (obj instanceof Set) {
|
|
72
|
-
const cleaned = new Set();
|
|
73
|
-
cache.set(obj, cleaned);
|
|
74
|
-
for (const v of obj){
|
|
75
|
-
const cv = stripUnserializable(v, cache, ancestors);
|
|
76
|
-
if (cv !== undefined) {
|
|
77
|
-
cleaned.add(cv);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
ancestors.delete(obj);
|
|
81
|
-
return cleaned;
|
|
82
|
-
}
|
|
83
|
-
if (Array.isArray(obj)) {
|
|
84
|
-
const arr = [];
|
|
85
|
-
cache.set(obj, arr);
|
|
86
|
-
for (const item of obj){
|
|
87
|
-
arr.push(stripUnserializable(item, cache, ancestors));
|
|
88
|
-
}
|
|
89
|
-
ancestors.delete(obj);
|
|
90
|
-
return arr;
|
|
91
|
-
}
|
|
92
|
-
if (ArrayBuffer.isView(obj)) {
|
|
93
|
-
ancestors.delete(obj);
|
|
94
|
-
return obj;
|
|
95
|
-
}
|
|
96
|
-
const result = {};
|
|
97
|
-
cache.set(obj, result);
|
|
98
|
-
for (const key of Object.keys(obj)){
|
|
99
|
-
const v = stripUnserializable(obj[key], cache, ancestors);
|
|
100
|
-
if (v !== undefined) {
|
|
101
|
-
result[key] = v;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
ancestors.delete(obj);
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
export function toSerializable(value) {
|
|
108
|
-
return stripUnserializable(value);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//# sourceMappingURL=toSerializable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/toSerializable.ts"],"sourcesContent":["/**\n * Recursively strip values that seroval cannot serialize (React elements,\n * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.\n *\n * TanStack Start uses seroval to transfer server function return values to\n * the client. Payload's `getClientConfig` / `getLayoutData` may include\n * callback functions or RegExp instances that seroval chokes on. Running\n * the data through this function before returning from a `createServerFn`\n * handler keeps the transfer safe.\n *\n * For server functions whose payloads contain React elements (e.g. the\n * shared `form-state` / `render-list` / `render-document` handlers), use\n * `serializeForRsc` instead — it converts elements into RSC handles rather\n * than stripping them.\n *\n * Uses a WeakMap cache so that shared object references (e.g. the same array\n * referenced by both `doc.hasMany` and `formState.hasMany.value`) are\n * returned correctly instead of being dropped as \"already seen\".\n *\n * A separate `ancestors` WeakSet tracks objects currently being recursed into.\n * If an object is encountered while it is still on the recursion stack, the\n * reference is circular and is replaced with `undefined` to keep the output\n * JSON-safe. Once recursion completes the object is removed from `ancestors`,\n * so sibling/cousin references to the same (fully-processed) object still\n * resolve to the cached clone.\n */\nfunction stripUnserializable(\n value: unknown,\n cache = new WeakMap<object, unknown>(),\n ancestors = new WeakSet<object>(),\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 return obj\n }\n\n // RegExp: seroval's SSR bootstrap emits regex literals with broken escape\n // sequences (e.g. `/!\\\\[.../` instead of `/!\\[.../`), crashing the client\n // script that populates `window.$_TSR` and preventing hydration. Rich-text\n // feature transformer regexes aren't needed on the client (they drive\n // server-side markdown import/export), so strip them here.\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\nexport function toSerializable<T>(value: T): T {\n return stripUnserializable(value) as T\n}\n"],"names":["stripUnserializable","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys","toSerializable"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,SAASA,oBACPC,KAAc,EACdC,QAAQ,IAAIC,SAA0B,EACtCC,YAAY,IAAIC,SAAiB;IAEjC,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,C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