@payloadcms/tanstack-start 4.0.0-canary.8
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/LICENSE.md +22 -0
- package/dist/auth/login.d.ts +17 -0
- package/dist/auth/login.d.ts.map +1 -0
- package/dist/auth/login.js +50 -0
- package/dist/auth/login.js.map +1 -0
- package/dist/auth/logout.d.ts +9 -0
- package/dist/auth/logout.d.ts.map +1 -0
- package/dist/auth/logout.js +51 -0
- package/dist/auth/logout.js.map +1 -0
- package/dist/auth/refresh.d.ts +8 -0
- package/dist/auth/refresh.d.ts.map +1 -0
- package/dist/auth/refresh.js +53 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/elements/DocumentHeaderClient/index.d.ts +16 -0
- package/dist/elements/DocumentHeaderClient/index.d.ts.map +1 -0
- package/dist/elements/DocumentHeaderClient/index.js +116 -0
- package/dist/elements/DocumentHeaderClient/index.js.map +1 -0
- package/dist/elements/RenderComponent/index.d.ts +10 -0
- package/dist/elements/RenderComponent/index.d.ts.map +1 -0
- package/dist/elements/RenderComponent/index.js +12 -0
- package/dist/elements/RenderComponent/index.js.map +1 -0
- package/dist/elements/RouterAdapter/index.d.ts +3 -0
- package/dist/elements/RouterAdapter/index.d.ts.map +1 -0
- package/dist/elements/RouterAdapter/index.js +141 -0
- package/dist/elements/RouterAdapter/index.js.map +1 -0
- package/dist/exports/client.d.ts +8 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +10 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/layouts.d.ts +6 -0
- package/dist/exports/layouts.d.ts.map +1 -0
- package/dist/exports/layouts.js +5 -0
- package/dist/exports/layouts.js.map +1 -0
- package/dist/exports/rsc.browser.d.ts +12 -0
- package/dist/exports/rsc.browser.d.ts.map +1 -0
- package/dist/exports/rsc.browser.js +12 -0
- package/dist/exports/rsc.browser.js.map +1 -0
- package/dist/exports/rsc.d.ts +5 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +6 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/server.d.ts +17 -0
- package/dist/exports/server.d.ts.map +1 -0
- package/dist/exports/server.js +18 -0
- package/dist/exports/server.js.map +1 -0
- package/dist/exports/vite.d.ts +3 -0
- package/dist/exports/vite.d.ts.map +1 -0
- package/dist/exports/vite.js +3 -0
- package/dist/exports/vite.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/Root/getLayoutData.d.ts +12 -0
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -0
- package/dist/layouts/Root/getLayoutData.js +91 -0
- package/dist/layouts/Root/getLayoutData.js.map +1 -0
- package/dist/layouts/Root/index.d.ts +32 -0
- package/dist/layouts/Root/index.d.ts.map +1 -0
- package/dist/layouts/Root/index.js +51 -0
- package/dist/layouts/Root/index.js.map +1 -0
- package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
- package/dist/layouts/Root/withPayloadRoot.js +92 -0
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
- package/dist/node/cssLoader.d.mts +3 -0
- package/dist/node/cssLoader.d.mts.map +1 -0
- package/dist/node/cssLoader.js +70 -0
- package/dist/node/cssLoader.js.map +1 -0
- package/dist/node/cssLoader.mjs +75 -0
- package/dist/node/registerCssLoader.d.mts +2 -0
- package/dist/node/registerCssLoader.d.mts.map +1 -0
- package/dist/node/registerCssLoader.js +10 -0
- package/dist/node/registerCssLoader.js.map +1 -0
- package/dist/node/registerCssLoader.mjs +10 -0
- package/dist/routes/adminRoutes.d.ts +111 -0
- package/dist/routes/adminRoutes.d.ts.map +1 -0
- package/dist/routes/adminRoutes.js +108 -0
- package/dist/routes/adminRoutes.js.map +1 -0
- package/dist/routes/apiRoute.d.ts +29 -0
- package/dist/routes/apiRoute.d.ts.map +1 -0
- package/dist/routes/apiRoute.js +38 -0
- package/dist/routes/apiRoute.js.map +1 -0
- package/dist/routes/layoutRoute.d.ts +26 -0
- package/dist/routes/layoutRoute.d.ts.map +1 -0
- package/dist/routes/layoutRoute.js +57 -0
- package/dist/routes/layoutRoute.js.map +1 -0
- package/dist/rsc/CollectionCards.d.ts +4 -0
- package/dist/rsc/CollectionCards.d.ts.map +1 -0
- package/dist/rsc/CollectionCards.js +12 -0
- package/dist/rsc/CollectionCards.js.map +1 -0
- package/dist/rsc/HierarchyTypeFieldServer.d.ts +9 -0
- package/dist/rsc/HierarchyTypeFieldServer.d.ts.map +1 -0
- package/dist/rsc/HierarchyTypeFieldServer.js +35 -0
- package/dist/rsc/HierarchyTypeFieldServer.js.map +1 -0
- package/dist/rsc/renderOnDemand.d.ts +15 -0
- package/dist/rsc/renderOnDemand.d.ts.map +1 -0
- package/dist/rsc/renderOnDemand.js +25 -0
- package/dist/rsc/renderOnDemand.js.map +1 -0
- package/dist/rsc/renderPayloadRSC.d.ts +6 -0
- package/dist/rsc/renderPayloadRSC.d.ts.map +1 -0
- package/dist/rsc/renderPayloadRSC.js +6 -0
- package/dist/rsc/renderPayloadRSC.js.map +1 -0
- package/dist/utilities/devReloadStrategy.d.ts +10 -0
- package/dist/utilities/devReloadStrategy.d.ts.map +1 -0
- package/dist/utilities/devReloadStrategy.js +27 -0
- package/dist/utilities/devReloadStrategy.js.map +1 -0
- package/dist/utilities/getExistingAuthToken.d.ts +7 -0
- package/dist/utilities/getExistingAuthToken.d.ts.map +1 -0
- package/dist/utilities/getExistingAuthToken.js +18 -0
- package/dist/utilities/getExistingAuthToken.js.map +1 -0
- package/dist/utilities/getPreferences.d.ts +10 -0
- package/dist/utilities/getPreferences.d.ts.map +1 -0
- package/dist/utilities/getPreferences.js +33 -0
- package/dist/utilities/getPreferences.js.map +1 -0
- package/dist/utilities/getRequestI18n.server.d.ts +12 -0
- package/dist/utilities/getRequestI18n.server.d.ts.map +1 -0
- package/dist/utilities/getRequestI18n.server.js +25 -0
- package/dist/utilities/getRequestI18n.server.js.map +1 -0
- package/dist/utilities/getRequestLocale.d.ts +7 -0
- package/dist/utilities/getRequestLocale.d.ts.map +1 -0
- package/dist/utilities/getRequestLocale.js +20 -0
- package/dist/utilities/getRequestLocale.js.map +1 -0
- package/dist/utilities/getRequestTheme.d.ts +10 -0
- package/dist/utilities/getRequestTheme.d.ts.map +1 -0
- package/dist/utilities/getRequestTheme.js +25 -0
- package/dist/utilities/getRequestTheme.js.map +1 -0
- package/dist/utilities/graphqlHandler.server.d.ts +12 -0
- package/dist/utilities/graphqlHandler.server.d.ts.map +1 -0
- package/dist/utilities/graphqlHandler.server.js +129 -0
- package/dist/utilities/graphqlHandler.server.js.map +1 -0
- package/dist/utilities/handleAPIRoute.d.ts +11 -0
- package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
- package/dist/utilities/handleAPIRoute.js +17 -0
- package/dist/utilities/handleAPIRoute.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts +20 -0
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -0
- package/dist/utilities/handleServerFunctions.js +60 -0
- package/dist/utilities/handleServerFunctions.js.map +1 -0
- package/dist/utilities/importMap.server.d.ts +8 -0
- package/dist/utilities/importMap.server.d.ts.map +1 -0
- package/dist/utilities/importMap.server.js +11 -0
- package/dist/utilities/importMap.server.js.map +1 -0
- package/dist/utilities/initReq.server.d.ts +19 -0
- package/dist/utilities/initReq.server.d.ts.map +1 -0
- package/dist/utilities/initReq.server.js +87 -0
- package/dist/utilities/initReq.server.js.map +1 -0
- package/dist/utilities/loadAdminPage.d.ts +54 -0
- package/dist/utilities/loadAdminPage.d.ts.map +1 -0
- package/dist/utilities/loadAdminPage.js +230 -0
- package/dist/utilities/loadAdminPage.js.map +1 -0
- package/dist/utilities/loadLayoutData.d.ts +15 -0
- package/dist/utilities/loadLayoutData.d.ts.map +1 -0
- package/dist/utilities/loadLayoutData.js +23 -0
- package/dist/utilities/loadLayoutData.js.map +1 -0
- package/dist/utilities/meta.d.ts +70 -0
- package/dist/utilities/meta.d.ts.map +1 -0
- package/dist/utilities/meta.js +142 -0
- package/dist/utilities/meta.js.map +1 -0
- package/dist/utilities/serializeForRsc.d.ts +26 -0
- package/dist/utilities/serializeForRsc.d.ts.map +1 -0
- package/dist/utilities/serializeForRsc.js +122 -0
- package/dist/utilities/serializeForRsc.js.map +1 -0
- package/dist/utilities/serverAdapter.server.d.ts +36 -0
- package/dist/utilities/serverAdapter.server.d.ts.map +1 -0
- package/dist/utilities/serverAdapter.server.js +130 -0
- package/dist/utilities/serverAdapter.server.js.map +1 -0
- package/dist/utilities/serverFunctionClient.d.ts +29 -0
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
- package/dist/utilities/serverFunctionClient.js +109 -0
- package/dist/utilities/serverFunctionClient.js.map +1 -0
- package/dist/utilities/serverFunctionHandlers.d.ts +18 -0
- package/dist/utilities/serverFunctionHandlers.d.ts.map +1 -0
- package/dist/utilities/serverFunctionHandlers.js +17 -0
- package/dist/utilities/serverFunctionHandlers.js.map +1 -0
- package/dist/utilities/setPayloadAuthCookie.d.ts +9 -0
- package/dist/utilities/setPayloadAuthCookie.d.ts.map +1 -0
- package/dist/utilities/setPayloadAuthCookie.js +31 -0
- package/dist/utilities/setPayloadAuthCookie.js.map +1 -0
- package/dist/utilities/toSerializable.d.ts +2 -0
- package/dist/utilities/toSerializable.d.ts.map +1 -0
- package/dist/utilities/toSerializable.js +111 -0
- package/dist/utilities/toSerializable.js.map +1 -0
- package/dist/vite/constants.d.ts +42 -0
- package/dist/vite/constants.d.ts.map +1 -0
- package/dist/vite/constants.js +177 -0
- package/dist/vite/constants.js.map +1 -0
- package/dist/vite/importProtection.d.ts +14 -0
- package/dist/vite/importProtection.d.ts.map +1 -0
- package/dist/vite/importProtection.js +54 -0
- package/dist/vite/importProtection.js.map +1 -0
- package/dist/vite/plugin.d.ts +38 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +177 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.d.ts +14 -0
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.js +98 -0
- package/dist/vite/plugins/clientModuleResolution.js.map +1 -0
- package/dist/vite/plugins/devTransforms.d.ts +19 -0
- package/dist/vite/plugins/devTransforms.d.ts.map +1 -0
- package/dist/vite/plugins/devTransforms.js +67 -0
- package/dist/vite/plugins/devTransforms.js.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.d.ts +27 -0
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.js +90 -0
- package/dist/vite/plugins/reactDomServerInRsc.js.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.d.ts +21 -0
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.js +140 -0
- package/dist/vite/plugins/stripDistStyleImports.js.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.d.ts +15 -0
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.js +106 -0
- package/dist/vite/plugins/wrapCjsForClient.js.map +1 -0
- package/package.json +106 -0
|
@@ -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 @@
|
|
|
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"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAACF,MAAM;QAClB,OAAON,MAAMS,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,sEAAsE;IACtE,2DAA2D;IAC3D,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAF,UAAUU,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBb,MAAMe,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAKpB,oBAAoBmB,GAAGjB,OAAOE;YACzC,IAAIgB,OAAOd,WAAW;gBACpBU,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAhB,UAAUiB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIR,eAAec,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBpB,MAAMe,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAMG,KAAKX,IAAK;YACnB,MAAMY,KAAKpB,oBAAoBmB,GAAGjB,OAAOE;YACzC,IAAIgB,OAAOd,WAAW;gBACpBU,QAAQF,GAAG,CAACM;YACd;QACF;QACAhB,UAAUiB,MAAM,CAACb;QACjB,OAAOQ;IACT;IAEA,IAAIO,MAAMC,OAAO,CAAChB,MAAM;QACtB,MAAMiB,MAAiB,EAAE;QACzBvB,MAAMe,GAAG,CAACT,KAAKiB;QACf,KAAK,MAAMC,QAAQlB,IAAK;YACtBiB,IAAIE,IAAI,CAAC3B,oBAAoB0B,MAAMxB,OAAOE;QAC5C;QACAA,UAAUiB,MAAM,CAACb;QACjB,OAAOiB;IACT;IAEA,IAAIG,YAAYC,MAAM,CAACrB,MAAM;QAC3BJ,UAAUiB,MAAM,CAACb;QACjB,OAAOA;IACT;IAEA,MAAMsB,SAAkC,CAAC;IACzC5B,MAAMe,GAAG,CAACT,KAAKsB;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACzB,KAAM;QAClC,MAAMW,IAAInB,oBAAoBQ,GAAG,CAACuB,IAAI,EAAE7B,OAAOE;QAC/C,IAAIe,MAAMb,WAAW;YACnBwB,MAAM,CAACC,IAAI,GAAGZ;QAChB;IACF;IACAf,UAAUiB,MAAM,CAACb;IACjB,OAAOsB;AACT;AAEA,OAAO,SAASI,eAAkBjC,KAAQ;IACxC,OAAOD,oBAAoBC;AAC7B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite-level configuration constants used by `payloadPlugin`. Kept separate so
|
|
3
|
+
* `plugin.ts` stays focused on wiring.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Server-only packages (Node-only or only ever used by the server bundle).
|
|
7
|
+
* These are the Vite equivalent of Next.js's `serverExternalPackages`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ssrExternalPackages: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Payload packages whose source must be processed by Vite even on the server
|
|
12
|
+
* (because they are workspace `.ts` files in dev). Server-only adapters
|
|
13
|
+
* (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are
|
|
14
|
+
* intentionally not included — those should stay external on the SSR side.
|
|
15
|
+
*/
|
|
16
|
+
export declare const payloadNoExternalPatterns: Array<RegExp | string>;
|
|
17
|
+
/**
|
|
18
|
+
* The subset of `payloadNoExternalPatterns` that needs to participate in the
|
|
19
|
+
* RSC environment. Plugins and storage adapters must be included: they register
|
|
20
|
+
* custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`
|
|
21
|
+
* `TenantSelectionProvider`) that render in the RSC graph via
|
|
22
|
+
* `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`
|
|
23
|
+
* never transforms its `'use client'` modules into client references, so the
|
|
24
|
+
* component executes server-side and crashes on the first hook
|
|
25
|
+
* (`Cannot read properties of null (reading 'useState')`).
|
|
26
|
+
*/
|
|
27
|
+
export declare const payloadRscNoExternalPatterns: Array<RegExp | string>;
|
|
28
|
+
/**
|
|
29
|
+
* Packages we know contain Node-only code or top-level side effects requiring
|
|
30
|
+
* Node APIs. Excluding them from the client optimizer prevents Vite from
|
|
31
|
+
* walking into their main entries and trying to bundle server-only imports
|
|
32
|
+
* for the browser.
|
|
33
|
+
*/
|
|
34
|
+
export declare const optimizeDepsExcludeDefaults: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
|
|
37
|
+
* pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
|
|
38
|
+
* these up because their parent packages are in `optimizeDeps.exclude`, so we
|
|
39
|
+
* list them explicitly using the `parent > child` syntax.
|
|
40
|
+
*/
|
|
41
|
+
export declare const optimizeDepsIncludeDefaults: string[];
|
|
42
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0BvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO/D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA8E/C,CAAA"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite-level configuration constants used by `payloadPlugin`. Kept separate so
|
|
3
|
+
* `plugin.ts` stays focused on wiring.
|
|
4
|
+
*/ /**
|
|
5
|
+
* Server-only packages (Node-only or only ever used by the server bundle).
|
|
6
|
+
* These are the Vite equivalent of Next.js's `serverExternalPackages`.
|
|
7
|
+
*/ export const ssrExternalPackages = [
|
|
8
|
+
'ajv',
|
|
9
|
+
'fast-uri',
|
|
10
|
+
'drizzle-kit',
|
|
11
|
+
'drizzle-kit/api',
|
|
12
|
+
'drizzle-orm',
|
|
13
|
+
'sharp',
|
|
14
|
+
'libsql',
|
|
15
|
+
'require-in-the-middle',
|
|
16
|
+
'json-schema-to-typescript',
|
|
17
|
+
'pino',
|
|
18
|
+
'pino-pretty',
|
|
19
|
+
'graphql',
|
|
20
|
+
'mongodb',
|
|
21
|
+
'mongoose',
|
|
22
|
+
'better-sqlite3',
|
|
23
|
+
'pg',
|
|
24
|
+
'pg-native',
|
|
25
|
+
'nodemailer',
|
|
26
|
+
'aws4',
|
|
27
|
+
'pluralize',
|
|
28
|
+
'console-table-printer',
|
|
29
|
+
'@azure/storage-blob',
|
|
30
|
+
'@aws-sdk/client-s3',
|
|
31
|
+
'@aws-sdk/s3-request-presigner',
|
|
32
|
+
'@google-cloud/storage'
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* Payload packages whose source must be processed by Vite even on the server
|
|
36
|
+
* (because they are workspace `.ts` files in dev). Server-only adapters
|
|
37
|
+
* (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are
|
|
38
|
+
* intentionally not included — those should stay external on the SSR side.
|
|
39
|
+
*/ export const payloadNoExternalPatterns = [
|
|
40
|
+
'@payloadcms/ui',
|
|
41
|
+
'@payloadcms/translations',
|
|
42
|
+
'@payloadcms/tanstack-start',
|
|
43
|
+
/^@payloadcms\/richtext-lexical/,
|
|
44
|
+
/^@payloadcms\/plugin-/,
|
|
45
|
+
/^@payloadcms\/storage-/
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* The subset of `payloadNoExternalPatterns` that needs to participate in the
|
|
49
|
+
* RSC environment. Plugins and storage adapters must be included: they register
|
|
50
|
+
* custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`
|
|
51
|
+
* `TenantSelectionProvider`) that render in the RSC graph via
|
|
52
|
+
* `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`
|
|
53
|
+
* never transforms its `'use client'` modules into client references, so the
|
|
54
|
+
* component executes server-side and crashes on the first hook
|
|
55
|
+
* (`Cannot read properties of null (reading 'useState')`).
|
|
56
|
+
*/ export const payloadRscNoExternalPatterns = [
|
|
57
|
+
'@payloadcms/ui',
|
|
58
|
+
'@payloadcms/translations',
|
|
59
|
+
'@payloadcms/tanstack-start',
|
|
60
|
+
/^@payloadcms\/richtext-lexical/,
|
|
61
|
+
/^@payloadcms\/plugin-/,
|
|
62
|
+
/^@payloadcms\/storage-/
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* Packages we know contain Node-only code or top-level side effects requiring
|
|
66
|
+
* Node APIs. Excluding them from the client optimizer prevents Vite from
|
|
67
|
+
* walking into their main entries and trying to bundle server-only imports
|
|
68
|
+
* for the browser.
|
|
69
|
+
*/ export const optimizeDepsExcludeDefaults = [
|
|
70
|
+
'sharp',
|
|
71
|
+
'@payloadcms/ui',
|
|
72
|
+
'@payloadcms/tanstack-start',
|
|
73
|
+
'payload',
|
|
74
|
+
'pino',
|
|
75
|
+
'pino-pretty',
|
|
76
|
+
'busboy',
|
|
77
|
+
'get-tsconfig',
|
|
78
|
+
'ws',
|
|
79
|
+
'croner',
|
|
80
|
+
'prompts',
|
|
81
|
+
'file-type',
|
|
82
|
+
// Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite
|
|
83
|
+
// sometimes walks these from the main package entry while scanning
|
|
84
|
+
// workspace deps, and the browser sub-bundles do not expose the
|
|
85
|
+
// server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev
|
|
86
|
+
// server with a `MISSING_EXPORT` error before any test runs.
|
|
87
|
+
'@azure/storage-blob',
|
|
88
|
+
'@aws-sdk/client-s3',
|
|
89
|
+
'@aws-sdk/s3-request-presigner',
|
|
90
|
+
'@google-cloud/storage'
|
|
91
|
+
];
|
|
92
|
+
/**
|
|
93
|
+
* Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
|
|
94
|
+
* pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
|
|
95
|
+
* these up because their parent packages are in `optimizeDeps.exclude`, so we
|
|
96
|
+
* list them explicitly using the `parent > child` syntax.
|
|
97
|
+
*/ export const optimizeDepsIncludeDefaults = [
|
|
98
|
+
'@payloadcms/ui > sonner',
|
|
99
|
+
'@payloadcms/ui > @faceless-ui/modal',
|
|
100
|
+
'@payloadcms/ui > @faceless-ui/window-info',
|
|
101
|
+
'@payloadcms/ui > @faceless-ui/scroll-info',
|
|
102
|
+
'@payloadcms/ui > @dnd-kit/core',
|
|
103
|
+
'@payloadcms/ui > @dnd-kit/sortable',
|
|
104
|
+
'@payloadcms/ui > @dnd-kit/utilities',
|
|
105
|
+
'@payloadcms/ui > react-datepicker',
|
|
106
|
+
'@payloadcms/ui > react-select',
|
|
107
|
+
'@payloadcms/ui > react-select/creatable',
|
|
108
|
+
'@payloadcms/ui > react-image-crop',
|
|
109
|
+
'@payloadcms/ui > @monaco-editor/react',
|
|
110
|
+
'@payloadcms/ui > date-fns',
|
|
111
|
+
'@payloadcms/ui > date-fns/transpose',
|
|
112
|
+
'@payloadcms/ui > @date-fns/tz/date/mini',
|
|
113
|
+
'@payloadcms/ui > uuid',
|
|
114
|
+
'@payloadcms/ui > use-context-selector',
|
|
115
|
+
'@payloadcms/ui > bson-objectid',
|
|
116
|
+
'@payloadcms/ui > dequal',
|
|
117
|
+
'@payloadcms/ui > object-to-formdata',
|
|
118
|
+
'@payloadcms/ui > md5',
|
|
119
|
+
'payload > deepmerge',
|
|
120
|
+
'payload > pluralize',
|
|
121
|
+
// `scheduler` is a transitive dep of `react-dom`, not a direct dependency of
|
|
122
|
+
// the app, so a bare `'scheduler'` specifier fails to resolve from an isolated
|
|
123
|
+
// install (`test/node_modules` built with `pnpm i --ignore-workspace`), where
|
|
124
|
+
// it isn't hoisted to the top level. Path it through `react-dom` so the
|
|
125
|
+
// optimizer resolves the exact copy the runtime loads.
|
|
126
|
+
'react-dom > scheduler',
|
|
127
|
+
// `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the
|
|
128
|
+
// React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.
|
|
129
|
+
// Because its parent is excluded, the optimizer never crawls in to discover
|
|
130
|
+
// this entry, so Vite serves `react/compiler-runtime` raw. That file is
|
|
131
|
+
// CommonJS (`module.exports = require(...)`), so the named `c` export can't be
|
|
132
|
+
// statically extracted and every client component throws "does not provide an
|
|
133
|
+
// export named 'c'". Pre-bundling it lets esbuild synthesize the named export.
|
|
134
|
+
'react/compiler-runtime',
|
|
135
|
+
// Transitive deps that Vite otherwise discovers *after* the initial crawl
|
|
136
|
+
// (react-select pulls in @floating-ui at runtime; react-is is reached via
|
|
137
|
+
// react-transition-group/prop-types; the default date-fns locale is loaded
|
|
138
|
+
// through a dynamic `date-fns/locale/${key}` import). A late discovery forces
|
|
139
|
+
// a full dep re-optimization mid-session, which 404s every in-flight
|
|
140
|
+
// `.vite/deps/*` chunk ("Pre-transform error: file does not exist in the
|
|
141
|
+
// optimize deps directory") and breaks the admin UI in CI cold starts.
|
|
142
|
+
// Pre-bundling them keeps the first optimization pass complete.
|
|
143
|
+
'@payloadcms/ui > react-select > @floating-ui/dom',
|
|
144
|
+
'@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',
|
|
145
|
+
'@payloadcms/ui > react-select > prop-types > react-is',
|
|
146
|
+
'@payloadcms/ui > date-fns/locale/en-US',
|
|
147
|
+
// Further late discoveries observed re-optimizing mid-run in CI cold starts
|
|
148
|
+
// (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / ajv /
|
|
149
|
+
// dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
|
|
150
|
+
// render; form-state diffing reaches `dequal/lite` (a distinct entry point
|
|
151
|
+
// from the already-listed `dequal`); client-side field validation reaches
|
|
152
|
+
// `ajv` *through `payload`* — it is `ssrExternal` server-side but still
|
|
153
|
+
// bundled into the client, and must be pathed via `payload` so the optimizer
|
|
154
|
+
// pre-bundles the exact copy the runtime loads.
|
|
155
|
+
'@payloadcms/ui > @dnd-kit/modifiers',
|
|
156
|
+
'@payloadcms/ui > dequal/lite',
|
|
157
|
+
'payload > ajv',
|
|
158
|
+
// The storage client-upload suites (esp. vercel-blob) crawl part of the
|
|
159
|
+
// `payload` server runtime into the client bundle and discover these late,
|
|
160
|
+
// triggering several "optimized dependencies changed. reloading" waves that
|
|
161
|
+
// reload the page mid-test (the bulk-upload drawer's Create New button /
|
|
162
|
+
// dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the
|
|
163
|
+
// whole observed set so the first pass is complete.
|
|
164
|
+
'payload > undici',
|
|
165
|
+
'payload > jose',
|
|
166
|
+
'payload > dataloader',
|
|
167
|
+
'payload > path-to-regexp',
|
|
168
|
+
'payload > console-table-printer',
|
|
169
|
+
'payload > ci-info',
|
|
170
|
+
'payload > image-size',
|
|
171
|
+
'payload > image-size/fromFile',
|
|
172
|
+
'payload > ipaddr.js',
|
|
173
|
+
'payload > range-parser',
|
|
174
|
+
'payload > sanitize-filename'
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/constants.ts"],"sourcesContent":["/**\n * Vite-level configuration constants used by `payloadPlugin`. Kept separate so\n * `plugin.ts` stays focused on wiring.\n */\n\n/**\n * Server-only packages (Node-only or only ever used by the server bundle).\n * These are the Vite equivalent of Next.js's `serverExternalPackages`.\n */\nexport const ssrExternalPackages: string[] = [\n 'ajv',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'mongodb',\n 'mongoose',\n 'better-sqlite3',\n 'pg',\n 'pg-native',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Payload packages whose source must be processed by Vite even on the server\n * (because they are workspace `.ts` files in dev). Server-only adapters\n * (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are\n * intentionally not included — those should stay external on the SSR side.\n */\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n\n/**\n * The subset of `payloadNoExternalPatterns` that needs to participate in the\n * RSC environment. Plugins and storage adapters must be included: they register\n * custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`\n * `TenantSelectionProvider`) that render in the RSC graph via\n * `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`\n * never transforms its `'use client'` modules into client references, so the\n * component executes server-side and crashes on the first hook\n * (`Cannot read properties of null (reading 'useState')`).\n */\nexport const payloadRscNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of\n // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated\n // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where\n // it isn't hoisted to the top level. Path it through `react-dom` so the\n // optimizer resolves the exact copy the runtime loads.\n 'react-dom > scheduler',\n // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the\n // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.\n // Because its parent is excluded, the optimizer never crawls in to discover\n // this entry, so Vite serves `react/compiler-runtime` raw. That file is\n // CommonJS (`module.exports = require(...)`), so the named `c` export can't be\n // statically extracted and every client component throws \"does not provide an\n // export named 'c'\". Pre-bundling it lets esbuild synthesize the named export.\n 'react/compiler-runtime',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / ajv /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `ajv` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > ajv',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-size',\n 'payload > image-size/fromFile',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n]\n"],"names":["ssrExternalPackages","payloadNoExternalPatterns","payloadRscNoExternalPatterns","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"mappings":"AAAA;;;CAGC,GAED;;;CAGC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;CASC,GACD,OAAO,MAAMC,+BAAuD;IAClE;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD;IACA,8EAA8E;IAC9E,0EAA0E;IAC1E,4EAA4E;IAC5E,wEAAwE;IACxE,+EAA+E;IAC/E,8EAA8E;IAC9E,+EAA+E;IAC/E;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifiers that must never appear in the client module graph. These are the
|
|
3
|
+
* server-only Payload entry points plus Node.js built-ins and a handful of
|
|
4
|
+
* Node-only npm packages that Payload pulls in transitively.
|
|
5
|
+
*/
|
|
6
|
+
export declare const serverOnlyClientSpecifiers: Array<RegExp | string>;
|
|
7
|
+
/**
|
|
8
|
+
* Allowlist callback for the `tanstackStart` plugin's import-protection. These
|
|
9
|
+
* are the legitimate cross-environment imports in our monorepo that we want
|
|
10
|
+
* to permit even when they appear to cross a server/client boundary.
|
|
11
|
+
*/
|
|
12
|
+
export declare function onImportProtectionViolation(violation: unknown): boolean | void;
|
|
13
|
+
export declare const defaultImportProtectionIgnoreImporters: RegExp[];
|
|
14
|
+
//# sourceMappingURL=importProtection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importProtection.d.ts","sourceRoot":"","sources":["../../src/vite/importProtection.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAoB7D,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAoC9E;AAED,eAAO,MAAM,sCAAsC,EAAE,MAAM,EAAsC,CAAA"}
|