@payloadcms/tanstack-start 4.0.0-internal.7b031c8 → 4.0.0-internal.8709764
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/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/elements/RouterAdapter/index.d.ts.map +1 -1
- package/dist/elements/RouterAdapter/index.js +17 -3
- package/dist/elements/RouterAdapter/index.js.map +1 -1
- package/dist/exports/client.d.ts +0 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +0 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +1 -3
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +0 -1
- package/dist/exports/layouts.js.map +1 -1
- 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 +0 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +0 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts +24 -2
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +6 -0
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/routes/adminRoutes.d.ts +6 -4
- package/dist/routes/adminRoutes.d.ts.map +1 -1
- package/dist/routes/adminRoutes.js +48 -42
- package/dist/routes/adminRoutes.js.map +1 -1
- package/dist/routes/layoutRoute.d.ts.map +1 -1
- package/dist/routes/layoutRoute.js +1 -0
- package/dist/routes/layoutRoute.js.map +1 -1
- package/dist/utilities/getRequestLocale.d.ts.map +1 -1
- package/dist/utilities/getRequestLocale.js +1 -2
- package/dist/utilities/getRequestLocale.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts +1 -19
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +8 -56
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/loadAdminPage.d.ts.map +1 -1
- package/dist/utilities/loadAdminPage.js +3 -11
- package/dist/utilities/loadAdminPage.js.map +1 -1
- 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/workarounds/stripDistStyleImports.js +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
- package/package.json +5 -5
- 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/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/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/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/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/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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs';
|
|
2
2
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
3
3
|
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
4
|
+
import { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed';
|
|
4
5
|
import { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
5
6
|
import { Outlet } from '@tanstack/react-router';
|
|
6
7
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
@@ -19,6 +20,10 @@ import { initReq } from '../../utilities/initReq.server.js';
|
|
|
19
20
|
cookies,
|
|
20
21
|
headers
|
|
21
22
|
});
|
|
23
|
+
const isEmbedded = getRequestEmbed({
|
|
24
|
+
config,
|
|
25
|
+
cookies
|
|
26
|
+
});
|
|
22
27
|
const languageOptions = Object.entries(config.i18n.supportedLanguages || {}).reduce((acc, [language, languageConfig])=>{
|
|
23
28
|
if (Object.keys(config.i18n.supportedLanguages).includes(language)) {
|
|
24
29
|
acc.push({
|
|
@@ -76,6 +81,7 @@ import { initReq } from '../../utilities/initReq.server.js';
|
|
|
76
81
|
clientConfig,
|
|
77
82
|
dateFNSKey: req.i18n.dateFNSKey,
|
|
78
83
|
fallbackLang: config.i18n.fallbackLanguage,
|
|
84
|
+
isEmbedded,
|
|
79
85
|
isNavOpen: navPrefs?.open ?? true,
|
|
80
86
|
languageCode,
|
|
81
87
|
languageOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap
|
|
1
|
+
{"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type { Theme } from '@payloadcms/ui'\nimport type {\n ClientConfig,\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n SanitizedPermissions,\n ServerProps,\n User,\n} from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed'\nimport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\nimport { Outlet } from '@tanstack/react-router'\nimport { applyLocaleFiltering } from 'payload/shared'\nimport { createElement } from 'react'\n\nimport { initReq } from '../../utilities/initReq.server.js'\n\nexport type RootLayoutData = {\n clientConfig: ClientConfig\n dateFNSKey: I18nClient['dateFNSKey']\n fallbackLang: string\n isEmbedded: boolean\n isNavOpen: boolean\n languageCode: string\n languageOptions: LanguageOptions\n locale?: string\n permissions: SanitizedPermissions\n /**\n * Custom admin provider tree (`config.admin.components.providers`) nested\n * around the router `<Outlet />`. Built unrendered by `getLayoutData`; the\n * layout server function renders it to an RSC payload before it reaches the\n * client. `undefined` when no custom providers are configured.\n */\n providers?: React.ReactNode\n theme: Theme\n translations: I18nClient['translations']\n user: null | User\n}\n\nexport type GetLayoutDataArgs = {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}\n\n/**\n * Fetches all data needed by the root admin layout.\n * Call this in your TanStack Start root route loader.\n */\nexport async function getLayoutData({\n configPromise,\n importMap,\n}: GetLayoutDataArgs): Promise<RootLayoutData> {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap })\n\n const theme = getRequestTheme({ config, cookies, headers })\n const isEmbedded = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language as AcceptedLanguages,\n })\n }\n return acc\n }, [] as LanguageOptions)\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user ?? true,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Build the custom admin provider tree (`config.admin.components.providers`)\n // nested around the router `<Outlet />`, mirroring the Next adapter's\n // `NestProviders`. Returned as an unrendered element; the caller's server\n // function renders it to an RSC payload (so server-component providers run\n // server-side and client providers wrap the live Outlet). `undefined` when\n // no custom providers are configured — the caller falls back to `<Outlet />`.\n const providerPaths = config.admin?.components?.providers\n let providers: React.ReactNode = undefined\n if (Array.isArray(providerPaths) && providerPaths.length > 0) {\n const serverProps: ServerProps = {\n i18n: req.i18n,\n params: {},\n payload: req.payload,\n permissions,\n searchParams: {},\n server: req.server!,\n user: req.user ?? undefined,\n }\n // Mirror the Next adapter's `NestProviders`: render each configured provider\n // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`\n // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and\n // server components receive `serverProps` while client components get only\n // `clientProps`. Nested around the router `<Outlet />` instead of `children`.\n providers = providerPaths.reduceRight<React.ReactNode>(\n (children, provider) =>\n RenderServerComponent({\n clientProps: { children },\n Component: provider,\n importMap,\n serverProps,\n }),\n createElement(Outlet),\n )\n }\n\n return {\n clientConfig,\n dateFNSKey: req.i18n.dateFNSKey,\n fallbackLang: config.i18n.fallbackLanguage,\n isEmbedded,\n isNavOpen: navPrefs?.open ?? true,\n languageCode,\n languageOptions,\n locale: req.locale ?? undefined,\n permissions,\n providers,\n theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","getRequestEmbed","getRequestTheme","Outlet","applyLocaleFiltering","createElement","initReq","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","theme","isEmbedded","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAYA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,aAAa,QAAQ,QAAO;AAErC,SAASC,OAAO,QAAQ,oCAAmC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IAAIC,OAAO;YACpBF;YACAoC,cAAc,CAAC;YACfC,QAAQpC,IAAIoC,MAAM;YAClBZ,MAAMxB,IAAIwB,IAAI,IAAIK;QACpB;QACA,6EAA6E;QAC7E,6EAA6E;QAC7E,8EAA8E;QAC9E,2EAA2E;QAC3E,8EAA8E;QAC9ED,YAAYH,cAAcY,WAAW,CACnC,CAACC,UAAUC,WACTtD,sBAAsB;gBACpBuD,aAAa;oBAAEF;gBAAS;gBACxBG,WAAWF;gBACX5C;gBACAsC;YACF,IACF1C,cAAcF;IAElB;IAEA,OAAO;QACLkC;QACAmB,YAAY1C,IAAIQ,IAAI,CAACkC,UAAU;QAC/BC,cAAczC,OAAOM,IAAI,CAACoC,gBAAgB;QAC1CxC;QACAyC,WAAWvB,UAAUwB,QAAQ;QAC7BhD;QACAO;QACA0C,QAAQ/C,IAAI+C,MAAM,IAAIlB;QACtB9B;QACA6B;QACAzB;QACAe,cAAclB,IAAIQ,IAAI,CAACU,YAAY;QACnCM,MAAMxB,IAAIwB,IAAI;IAChB;AACF"}
|
|
@@ -49,6 +49,7 @@ export declare function payloadAdminSplatRoute({ load }: {
|
|
|
49
49
|
title: string;
|
|
50
50
|
})[];
|
|
51
51
|
};
|
|
52
|
+
notFoundComponent: typeof AdminNotFound;
|
|
52
53
|
loader: {
|
|
53
54
|
handler: ({ location, params }: {
|
|
54
55
|
location: any;
|
|
@@ -61,12 +62,11 @@ export declare function payloadAdminSplatRoute({ load }: {
|
|
|
61
62
|
}) => {
|
|
62
63
|
searchKey: string;
|
|
63
64
|
};
|
|
64
|
-
notFoundComponent: typeof AdminNotFound;
|
|
65
65
|
validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* Route options for the admin index route (`/_payload/admin/`).
|
|
69
|
-
*
|
|
68
|
+
* Route options for the admin index route (`/_payload/admin/`). Not-found
|
|
69
|
+
* results omit the RSC payload and fall back to `NotFoundClient`.
|
|
70
70
|
*/
|
|
71
71
|
export declare function payloadAdminIndexRoute({ load }: {
|
|
72
72
|
load: AdminLoad;
|
|
@@ -94,9 +94,11 @@ export declare function payloadAdminIndexRoute({ load }: {
|
|
|
94
94
|
title: string;
|
|
95
95
|
})[];
|
|
96
96
|
};
|
|
97
|
+
notFoundComponent: typeof AdminNotFound;
|
|
97
98
|
loader: {
|
|
98
|
-
handler: ({ location }: {
|
|
99
|
+
handler: ({ location, params }: {
|
|
99
100
|
location: any;
|
|
101
|
+
params: any;
|
|
100
102
|
}) => Promise<any>;
|
|
101
103
|
staleReloadMode: string;
|
|
102
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAA;AAI7E;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE;IAC7B,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACpE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAclB,iBAAS,SAAS,gCAuBjB;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,+BAMrF;AAiDD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;;2BArC3C;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;QAUzC,OAAO,yBAA+B;YAAE,QAAQ,EAAE,GAAG,CAAC;YAAC,MAAM,EAAE,GAAG,CAAA;SAAE;QAYpE,eAAe;;6BAGQ;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;QAC1D,SAAS;;6BAEc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAejD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;;2BAjD3C;QAAE,UAAU,CAAC,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;QAUzC,OAAO,yBAA+B;YAAE,QAAQ,EAAE,GAAG,CAAC;YAAC,MAAM,EAAE,GAAG,CAAA;SAAE;QAYpE,eAAe;;6BAGQ;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;QAC1D,SAAS;;6BAEc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EA2BjD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { NotFoundClient } from '@payloadcms/ui';
|
|
3
|
+
import { NotFoundClient, useRouteTransition } from '@payloadcms/ui';
|
|
4
4
|
import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
|
|
5
|
-
import { Fragment } from 'react';
|
|
5
|
+
import { Fragment, useDeferredValue, useEffect } from 'react';
|
|
6
6
|
import { getAdminMeta } from '../utilities/meta.js';
|
|
7
7
|
const searchToRecord = (searchStr)=>Object.fromEntries(new URLSearchParams(searchStr));
|
|
8
8
|
const runLoader = async (load, splat, searchStr)=>{
|
|
@@ -21,17 +21,30 @@ const runLoader = async (load, splat, searchStr)=>{
|
|
|
21
21
|
return data;
|
|
22
22
|
};
|
|
23
23
|
function AdminPage() {
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
// transition and would remount with the previous payload) so navigating to a
|
|
27
|
-
// different admin page remounts the view, mirroring Next route-segment
|
|
28
|
-
// semantics. Search params are excluded so search-only changes reconcile in place.
|
|
24
|
+
// Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.
|
|
25
|
+
// The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.
|
|
29
26
|
const data = useLoaderData({
|
|
30
27
|
strict: false
|
|
31
28
|
});
|
|
29
|
+
// Route state comes from an external store, so a new RSC payload that suspends
|
|
30
|
+
// on code-split client references can reveal the router's null fallback.
|
|
31
|
+
// Keep the current payload painted until the next one is renderable.
|
|
32
|
+
const rscPayload = useDeferredValue(data?.rscPayload);
|
|
33
|
+
const { holdRouteTransition } = useRouteTransition();
|
|
34
|
+
const isRscPayloadDeferred = rscPayload !== data?.rscPayload;
|
|
35
|
+
useEffect(()=>{
|
|
36
|
+
if (!isRscPayloadDeferred) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const releaseRouteTransition = holdRouteTransition();
|
|
40
|
+
return ()=>releaseRouteTransition();
|
|
41
|
+
}, [
|
|
42
|
+
holdRouteTransition,
|
|
43
|
+
isRscPayloadDeferred
|
|
44
|
+
]);
|
|
32
45
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
33
|
-
children:
|
|
34
|
-
}
|
|
46
|
+
children: rscPayload
|
|
47
|
+
});
|
|
35
48
|
}
|
|
36
49
|
function AdminNotFound(props) {
|
|
37
50
|
const rscPayload = props?.data?.rscPayload;
|
|
@@ -42,15 +55,12 @@ function AdminNotFound(props) {
|
|
|
42
55
|
children: rscPayload
|
|
43
56
|
}, props?.data?.routeKey);
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
* Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
|
|
47
|
-
* server-built NotFound page (shipped via the `notFound()` error's
|
|
48
|
-
* `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
|
|
49
|
-
* client view.
|
|
50
|
-
*/ export function payloadAdminSplatRoute({ load }) {
|
|
51
|
-
return {
|
|
58
|
+
const adminRouteOptions = ({ forwardNotFoundPayload, load, resolveSplat })=>({
|
|
52
59
|
component: AdminPage,
|
|
53
60
|
head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
|
|
61
|
+
// Both admin routes must use the same boundary type so index ↔ splat
|
|
62
|
+
// navigation preserves the existing admin subtree.
|
|
63
|
+
notFoundComponent: AdminNotFound,
|
|
54
64
|
// `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
|
|
55
65
|
// sibling route option — router-core only reads it off a non-function loader)
|
|
56
66
|
// makes stale-match revalidation await the fresh loader before committing,
|
|
@@ -58,15 +68,15 @@ function AdminNotFound(props) {
|
|
|
58
68
|
// (e.g. a just-created doc missing) until the reload lands.
|
|
59
69
|
loader: {
|
|
60
70
|
handler: async ({ location, params })=>{
|
|
61
|
-
const data = await runLoader(load, params
|
|
71
|
+
const data = await runLoader(load, resolveSplat(params), location.searchStr);
|
|
62
72
|
if (data?._notFound) {
|
|
63
73
|
// eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
|
|
64
|
-
throw notFound({
|
|
74
|
+
throw notFound(forwardNotFoundPayload ? {
|
|
65
75
|
data: {
|
|
66
76
|
routeKey: data.routeKey,
|
|
67
77
|
rscPayload: data.rscPayload
|
|
68
78
|
}
|
|
69
|
-
});
|
|
79
|
+
} : undefined);
|
|
70
80
|
}
|
|
71
81
|
return data;
|
|
72
82
|
},
|
|
@@ -76,33 +86,29 @@ function AdminNotFound(props) {
|
|
|
76
86
|
loaderDeps: ({ search })=>({
|
|
77
87
|
searchKey: JSON.stringify(search)
|
|
78
88
|
}),
|
|
79
|
-
notFoundComponent: AdminNotFound,
|
|
80
89
|
validateSearch: (search)=>search
|
|
81
|
-
};
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
|
|
93
|
+
* server-built NotFound page (shipped via the `notFound()` error's
|
|
94
|
+
* `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
|
|
95
|
+
* client view.
|
|
96
|
+
*/ export function payloadAdminSplatRoute({ load }) {
|
|
97
|
+
return adminRouteOptions({
|
|
98
|
+
forwardNotFoundPayload: true,
|
|
99
|
+
load,
|
|
100
|
+
resolveSplat: (params)=>params._splat ?? ''
|
|
101
|
+
});
|
|
82
102
|
}
|
|
83
103
|
/**
|
|
84
|
-
* Route options for the admin index route (`/_payload/admin/`).
|
|
85
|
-
*
|
|
104
|
+
* Route options for the admin index route (`/_payload/admin/`). Not-found
|
|
105
|
+
* results omit the RSC payload and fall back to `NotFoundClient`.
|
|
86
106
|
*/ export function payloadAdminIndexRoute({ load }) {
|
|
87
|
-
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const data = await runLoader(load, '', location.searchStr);
|
|
93
|
-
if (data?._notFound) {
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
|
|
95
|
-
throw notFound();
|
|
96
|
-
}
|
|
97
|
-
return data;
|
|
98
|
-
},
|
|
99
|
-
staleReloadMode: 'blocking'
|
|
100
|
-
},
|
|
101
|
-
loaderDeps: ({ search })=>({
|
|
102
|
-
searchKey: JSON.stringify(search)
|
|
103
|
-
}),
|
|
104
|
-
validateSearch: (search)=>search
|
|
105
|
-
};
|
|
107
|
+
return adminRouteOptions({
|
|
108
|
+
forwardNotFoundPayload: false,
|
|
109
|
+
load,
|
|
110
|
+
resolveSplat: ()=>''
|
|
111
|
+
});
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
//# sourceMappingURL=adminRoutes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\nfunction AdminPage() {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode, useDeferredValue, useEffect } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\nfunction AdminPage() {\n // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.\n // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.\n const data = useLoaderData({ strict: false })\n\n // Route state comes from an external store, so a new RSC payload that suspends\n // on code-split client references can reveal the router's null fallback.\n // Keep the current payload painted until the next one is renderable.\n const rscPayload = useDeferredValue(data?.rscPayload)\n const { holdRouteTransition } = useRouteTransition()\n const isRscPayloadDeferred = rscPayload !== data?.rscPayload\n\n useEffect(() => {\n if (!isRscPayloadDeferred) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRscPayloadDeferred])\n\n return <Fragment>{rscPayload}</Fragment>\n}\n\nfunction AdminNotFound(props: { data?: { routeKey?: string; rscPayload?: ReactNode } }) {\n const rscPayload = props?.data?.rscPayload\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={props?.data?.routeKey}>{rscPayload}</Fragment>\n}\n\nconst adminRouteOptions = ({\n forwardNotFoundPayload,\n load,\n resolveSplat,\n}: {\n /**\n * Ships the server-rendered NotFound tree through `notFound()`'s `data` so a\n * `notFoundComponent` can render it with the full admin chrome. Routes without\n * one throw bare.\n */\n forwardNotFoundPayload: boolean\n load: AdminLoad\n /** The route's splat, i.e. the path after `/admin/`. */\n resolveSplat: (params: any) => string\n}) => ({\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // Both admin routes must use the same boundary type so index ↔ splat\n // navigation preserves the existing admin subtree.\n notFoundComponent: AdminNotFound,\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, resolveSplat(params), location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound(\n forwardNotFoundPayload\n ? { data: { routeKey: data.routeKey, rscPayload: data.rscPayload } }\n : undefined,\n )\n }\n return data\n },\n staleReloadMode: 'blocking',\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n})\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: true,\n load,\n resolveSplat: (params) => params._splat ?? '',\n })\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Not-found\n * results omit the RSC payload and fall back to `NotFoundClient`.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return adminRouteOptions({\n forwardNotFoundPayload: false,\n load,\n resolveSplat: () => '',\n })\n}\n"],"names":["NotFoundClient","useRouteTransition","notFound","redirect","useLoaderData","Fragment","useDeferredValue","useEffect","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","holdRouteTransition","isRscPayloadDeferred","releaseRouteTransition","AdminNotFound","props","routeKey","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","notFoundComponent","loader","handler","location","params","_notFound","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","payloadAdminIndexRoute"],"mappings":"AAAA;;AAEA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,iBAAgB;AACnE,SAASC,QAAQ,EAAEC,QAAQ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MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,cAAc,GACf,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc,EAAE,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACtE;
|
|
1
|
+
{"version":3,"file":"layoutRoute.d.ts","sourceRoot":"","sources":["../../src/routes/layoutRoute.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK1D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,cAAc,GACf,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc,EAAE,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACtE;IAsCG,SAAS;IACT,MAAM;QAAI,OAAO;QAAgB,eAAe;;EAEnD"}
|
|
@@ -19,6 +19,7 @@ import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
|
19
19
|
/*#__PURE__*/ _jsxs(RootProvider, {
|
|
20
20
|
config: data.clientConfig,
|
|
21
21
|
dateFNSKey: data.dateFNSKey,
|
|
22
|
+
embed: data.isEmbedded,
|
|
22
23
|
fallbackLang: data.fallbackLang,
|
|
23
24
|
highContrastMode: false,
|
|
24
25
|
isNavOpen: data.isNavOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { Outlet, useLoaderData } from '@tanstack/react-router'\n\nimport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadLayoutData`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type LayoutLoad = () => Promise<Record<string, unknown>>\n\n/**\n * Route options for the Payload admin layout (`/_payload`). Maps the layout\n * loader data onto `RootProvider` and renders the admin chrome (progress bar,\n * custom-provider tree or router `<Outlet />`, portal mount). The app supplies\n * `load` (the layout-data server fn) and `serverFunction` (the server-function\n * client wired into `RootProvider`); everything else is adapter-owned.\n */\nexport function payloadLayoutRoute({\n load,\n serverFunction,\n}: {\n load: LayoutLoad\n serverFunction: ComponentProps<typeof RootProvider>['serverFunction']\n}) {\n function PayloadLayout() {\n const data = useLoaderData({ strict: false })\n\n return (\n <>\n <RootProvider\n config={data.clientConfig}\n dateFNSKey={data.dateFNSKey}\n fallbackLang={data.fallbackLang}\n highContrastMode={false}\n isNavOpen={data.isNavOpen}\n languageCode={data.languageCode}\n languageOptions={data.languageOptions}\n locale={data.locale}\n permissions={data.user ? data.permissions : null}\n RouterAdapter={TanStackRouterAdapter}\n serverFunction={serverFunction}\n theme={data.theme}\n translations={data.translations}\n user={data.user}\n >\n <ProgressBar />\n {/* `data.providers` is the custom-provider tree (config.admin.components.providers)\n already wrapping the router <Outlet />; falls back to a bare <Outlet /> when\n no custom providers are configured. */}\n {data.providers ?? <Outlet />}\n </RootProvider>\n <div id=\"portal\" />\n </>\n )\n }\n\n // `staleReloadMode` lives on the loader *object* — router-core only reads it\n // off a non-function loader — so stale-match revalidation blocks on the fresh\n // loader instead of flashing stale layout data via the default background SWR.\n return {\n component: PayloadLayout,\n loader: { handler: () => load(), staleReloadMode: 'blocking' },\n }\n}\n"],"names":["ProgressBar","RootProvider","Outlet","useLoaderData","TanStackRouterAdapter","payloadLayoutRoute","load","serverFunction","PayloadLayout","data","strict","config","clientConfig","dateFNSKey","fallbackLang","highContrastMode","isNavOpen","languageCode","languageOptions","locale","permissions","user","RouterAdapter","theme","translations","providers","div","id","component","loader","handler","staleReloadMode"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,YAAY,QAAQ,iBAAgB;AAC1D,SAASC,MAAM,EAAEC,aAAa,QAAQ,yBAAwB;AAE9D,SAASC,qBAAqB,QAAQ,qCAAoC;AAS1E;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,cAAc,EAIf;IACC,SAASC;QACP,MAAMC,OAAON,cAAc;YAAEO,QAAQ;QAAM;QAE3C,qBACE;;8BACE,MAACT;oBACCU,QAAQF,KAAKG,YAAY;oBACzBC,YAAYJ,KAAKI,UAAU;oBAC3BC,
|
|
1
|
+
{"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { Outlet, useLoaderData } from '@tanstack/react-router'\n\nimport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadLayoutData`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type LayoutLoad = () => Promise<Record<string, unknown>>\n\n/**\n * Route options for the Payload admin layout (`/_payload`). Maps the layout\n * loader data onto `RootProvider` and renders the admin chrome (progress bar,\n * custom-provider tree or router `<Outlet />`, portal mount). The app supplies\n * `load` (the layout-data server fn) and `serverFunction` (the server-function\n * client wired into `RootProvider`); everything else is adapter-owned.\n */\nexport function payloadLayoutRoute({\n load,\n serverFunction,\n}: {\n load: LayoutLoad\n serverFunction: ComponentProps<typeof RootProvider>['serverFunction']\n}) {\n function PayloadLayout() {\n const data = useLoaderData({ strict: false })\n\n return (\n <>\n <RootProvider\n config={data.clientConfig}\n dateFNSKey={data.dateFNSKey}\n embed={data.isEmbedded}\n fallbackLang={data.fallbackLang}\n highContrastMode={false}\n isNavOpen={data.isNavOpen}\n languageCode={data.languageCode}\n languageOptions={data.languageOptions}\n locale={data.locale}\n permissions={data.user ? data.permissions : null}\n RouterAdapter={TanStackRouterAdapter}\n serverFunction={serverFunction}\n theme={data.theme}\n translations={data.translations}\n user={data.user}\n >\n <ProgressBar />\n {/* `data.providers` is the custom-provider tree (config.admin.components.providers)\n already wrapping the router <Outlet />; falls back to a bare <Outlet /> when\n no custom providers are configured. */}\n {data.providers ?? <Outlet />}\n </RootProvider>\n <div id=\"portal\" />\n </>\n )\n }\n\n // `staleReloadMode` lives on the loader *object* — router-core only reads it\n // off a non-function loader — so stale-match revalidation blocks on the fresh\n // loader instead of flashing stale layout data via the default background SWR.\n return {\n component: PayloadLayout,\n loader: { handler: () => load(), staleReloadMode: 'blocking' },\n }\n}\n"],"names":["ProgressBar","RootProvider","Outlet","useLoaderData","TanStackRouterAdapter","payloadLayoutRoute","load","serverFunction","PayloadLayout","data","strict","config","clientConfig","dateFNSKey","embed","isEmbedded","fallbackLang","highContrastMode","isNavOpen","languageCode","languageOptions","locale","permissions","user","RouterAdapter","theme","translations","providers","div","id","component","loader","handler","staleReloadMode"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,YAAY,QAAQ,iBAAgB;AAC1D,SAASC,MAAM,EAAEC,aAAa,QAAQ,yBAAwB;AAE9D,SAASC,qBAAqB,QAAQ,qCAAoC;AAS1E;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,cAAc,EAIf;IACC,SAASC;QACP,MAAMC,OAAON,cAAc;YAAEO,QAAQ;QAAM;QAE3C,qBACE;;8BACE,MAACT;oBACCU,QAAQF,KAAKG,YAAY;oBACzBC,YAAYJ,KAAKI,UAAU;oBAC3BC,OAAOL,KAAKM,UAAU;oBACtBC,cAAcP,KAAKO,YAAY;oBAC/BC,kBAAkB;oBAClBC,WAAWT,KAAKS,SAAS;oBACzBC,cAAcV,KAAKU,YAAY;oBAC/BC,iBAAiBX,KAAKW,eAAe;oBACrCC,QAAQZ,KAAKY,MAAM;oBACnBC,aAAab,KAAKc,IAAI,GAAGd,KAAKa,WAAW,GAAG;oBAC5CE,eAAepB;oBACfG,gBAAgBA;oBAChBkB,OAAOhB,KAAKgB,KAAK;oBACjBC,cAAcjB,KAAKiB,YAAY;oBAC/BH,MAAMd,KAAKc,IAAI;;sCAEf,KAACvB;wBAIAS,KAAKkB,SAAS,kBAAI,KAACzB;;;8BAEtB,KAAC0B;oBAAIC,IAAG;;;;IAGd;IAEA,6EAA6E;IAC7E,8EAA8E;IAC9E,+EAA+E;IAC/E,OAAO;QACLC,WAAWtB;QACXuB,QAAQ;YAAEC,SAAS,IAAM1B;YAAQ2B,iBAAiB;QAAW;IAC/D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestLocale.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getRequestLocale.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKrD,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkCjG"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { upsertPreferences } from '@payloadcms/ui/rsc';
|
|
1
|
+
import { getPreferences, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
2
2
|
import { findLocaleFromCode } from '@payloadcms/ui/shared';
|
|
3
|
-
import { getPreferences } from './getPreferences.js';
|
|
4
3
|
export async function getRequestLocale({ req }) {
|
|
5
4
|
if (req.payload.config.localization) {
|
|
6
5
|
const localeFromParams = req.query.locale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { getPreferences, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\ntype GetRequestLocaleArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocaleArgs): Promise<Locale | undefined> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (req.user && localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n const userLocale =\n req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )\n\n return (\n userLocale ??\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n ) ??\n undefined\n )\n }\n\n return undefined\n}\n"],"names":["getPreferences","upsertPreferences","findLocaleFromCode","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","user","key","value","userLocale","id","collection","defaultLocale","undefined"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,qBAAoB;AACtE,SAASC,kBAAkB,QAAQ,wBAAuB;AAM1D,OAAO,eAAeC,iBAAiB,EAAEC,GAAG,EAAwB;IAClE,IAAIA,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;QACnC,MAAMC,mBAAmBJ,IAAIK,KAAK,CAACC,MAAM;QAEzC,IAAIN,IAAIO,IAAI,IAAIH,kBAAkB;YAChC,MAAMP,kBAAkC;gBAAEW,KAAK;gBAAUR;gBAAKS,OAAOL;YAAiB;QACxF;QAEA,MAAMM,aACJV,IAAIO,IAAI,IACRT,mBACEE,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,oBAEI,CAAA,MAAMR,eACJ,UACAI,IAAIC,OAAO,EACXD,IAAIO,IAAI,CAACI,EAAE,EACXX,IAAIO,IAAI,CAACK,UAAU,CACrB,GACCH;QAGT,OACEC,cACAZ,mBACEE,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,IAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACU,aAAa,IAAI,SAEnDC;IAEJ;IAEA,OAAOA;AACT"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Server function dispatcher for TanStack Start.
|
|
4
|
-
*
|
|
5
|
-
* Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
|
|
6
|
-
* exact same set of handlers — both adapters share `sharedServerFunctions`
|
|
7
|
-
* plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
|
|
8
|
-
*
|
|
9
|
-
* Pipes the result through `serializeForRsc`, which converts any React
|
|
10
|
-
* elements left in the response (e.g. `state[path].customComponents.Field`
|
|
11
|
-
* produced by `buildFormState`, the `List` / `Document` nodes returned by
|
|
12
|
-
* `render-list` / `render-document`) into RSC "renderable handles" via
|
|
13
|
-
* `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
|
|
14
|
-
* `$RSC` serialization adapter then ships those handles to the client as
|
|
15
|
-
* Flight payloads — so this dispatcher must be invoked from a context that
|
|
16
|
-
* uses TanStack's wire format (e.g. `createServerFn`), not raw
|
|
17
|
-
* `JSON.stringify`.
|
|
18
|
-
*/
|
|
19
|
-
export declare const handleServerFunctions: ServerFunctionHandler;
|
|
1
|
+
export declare const handleServerFunctions: import("payload").ServerFunctionHandler;
|
|
20
2
|
//# sourceMappingURL=handleServerFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,yCAGhC,CAAA"}
|
|
@@ -1,60 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _internal_renderFieldHandler } from '@payloadcms/ui/rsc';
|
|
3
|
-
import { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry';
|
|
4
|
-
import { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn';
|
|
5
|
-
import { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn';
|
|
6
|
-
import { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots';
|
|
7
|
-
import { RenderRSCComponent } from '../rsc/renderPayloadRSC.js';
|
|
1
|
+
import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions';
|
|
8
2
|
import { initReq } from './initReq.server.js';
|
|
9
3
|
import { serializeForRsc } from './serializeForRsc.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'render-widget': renderWidgetHandler,
|
|
18
|
-
'switch-language': switchLanguageHandler
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Server function dispatcher for TanStack Start.
|
|
22
|
-
*
|
|
23
|
-
* Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
|
|
24
|
-
* exact same set of handlers — both adapters share `sharedServerFunctions`
|
|
25
|
-
* plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
|
|
26
|
-
*
|
|
27
|
-
* Pipes the result through `serializeForRsc`, which converts any React
|
|
28
|
-
* elements left in the response (e.g. `state[path].customComponents.Field`
|
|
29
|
-
* produced by `buildFormState`, the `List` / `Document` nodes returned by
|
|
30
|
-
* `render-list` / `render-document`) into RSC "renderable handles" via
|
|
31
|
-
* `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
|
|
32
|
-
* `$RSC` serialization adapter then ships those handles to the client as
|
|
33
|
-
* Flight payloads — so this dispatcher must be invoked from a context that
|
|
34
|
-
* uses TanStack's wire format (e.g. `createServerFn`), not raw
|
|
35
|
-
* `JSON.stringify`.
|
|
36
|
-
*/ export const handleServerFunctions = async (args)=>{
|
|
37
|
-
const { name: fnKey, args: fnArgs, config: configPromise, importMap, serverFunctions: extraServerFunctions } = args;
|
|
38
|
-
const { cookies, locale, permissions, req } = await initReq({
|
|
39
|
-
configPromise,
|
|
40
|
-
importMap
|
|
41
|
-
});
|
|
42
|
-
const augmentedArgs = {
|
|
43
|
-
...fnArgs,
|
|
44
|
-
cookies,
|
|
45
|
-
importMap,
|
|
46
|
-
locale,
|
|
47
|
-
mode: 'rsc',
|
|
48
|
-
permissions,
|
|
49
|
-
renderComponent: RenderRSCComponent,
|
|
50
|
-
req
|
|
51
|
-
};
|
|
52
|
-
const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
|
|
53
|
-
if (!fn) {
|
|
54
|
-
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
55
|
-
}
|
|
56
|
-
const result = await fn(augmentedArgs);
|
|
57
|
-
return await serializeForRsc(result);
|
|
58
|
-
};
|
|
4
|
+
export const handleServerFunctions = createServerFunctionHandler({
|
|
5
|
+
initReq: ({ configPromise, importMap })=>initReq({
|
|
6
|
+
configPromise,
|
|
7
|
+
importMap
|
|
8
|
+
}),
|
|
9
|
+
transformResult: serializeForRsc
|
|
10
|
+
});
|
|
59
11
|
|
|
60
12
|
//# sourceMappingURL=handleServerFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions'\n\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\n\nexport const handleServerFunctions = createServerFunctionHandler({\n initReq: ({ configPromise, importMap }) => initReq({ configPromise, importMap }),\n transformResult: serializeForRsc,\n})\n"],"names":["createServerFunctionHandler","initReq","serializeForRsc","handleServerFunctions","configPromise","importMap","transformResult"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iDAAgD;AAE5F,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,OAAO,MAAMC,wBAAwBH,4BAA4B;IAC/DC,SAAS,CAAC,EAAEG,aAAa,EAAEC,SAAS,EAAE,GAAKJ,QAAQ;YAAEG;YAAeC;QAAU;IAC9EC,iBAAiBJ;AACnB,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAKrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IA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5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAkJlD"}
|
|
@@ -115,15 +115,6 @@ const resolveTitle = (title)=>{
|
|
|
115
115
|
userAgent = result.headers.get('user-agent') ?? undefined;
|
|
116
116
|
return result;
|
|
117
117
|
};
|
|
118
|
-
const notFound = ()=>{
|
|
119
|
-
nav.type = 'notFound';
|
|
120
|
-
throw new Error('not-found');
|
|
121
|
-
};
|
|
122
|
-
const redirect = (url)=>{
|
|
123
|
-
nav.type = 'redirect';
|
|
124
|
-
nav.url = url;
|
|
125
|
-
throw new Error(`redirect:${url}`);
|
|
126
|
-
};
|
|
127
118
|
// Build the 404 result the route loader re-throws as TanStack `notFound()`.
|
|
128
119
|
//
|
|
129
120
|
// Throwing `notFound()` is the only way to set the SSR document status to 404
|
|
@@ -165,13 +156,14 @@ const resolveTitle = (title)=>{
|
|
|
165
156
|
config: Promise.resolve(config),
|
|
166
157
|
importMap,
|
|
167
158
|
initReq: boundInitReq,
|
|
168
|
-
|
|
159
|
+
key: splat ?? '',
|
|
160
|
+
notFound: pageServerAdapter.notFound,
|
|
169
161
|
// `segments` is intentionally `undefined` for the admin root (`/admin`),
|
|
170
162
|
// matching Next's optional catch-all; `renderRoot` handles it at runtime.
|
|
171
163
|
params: Promise.resolve({
|
|
172
164
|
segments
|
|
173
165
|
}),
|
|
174
|
-
redirect,
|
|
166
|
+
redirect: pageServerAdapter.redirect,
|
|
175
167
|
searchParams: Promise.resolve(searchParams)
|
|
176
168
|
});
|
|
177
169
|
const rscPayload = await renderServerComponent(node);
|