@payloadcms/tanstack-start 4.0.0-internal.cea8867 → 4.0.0-internal.d1cc1d3
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/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 +2 -2
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +2 -2
- package/dist/exports/server.js.map +1 -1
- package/dist/exports/shared.d.ts +2 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +3 -0
- package/dist/exports/shared.js.map +1 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.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 +35 -41
- package/dist/routes/adminRoutes.js.map +1 -1
- package/dist/routes/apiRoute.d.ts +5 -0
- package/dist/routes/apiRoute.d.ts.map +1 -1
- package/dist/routes/apiRoute.js +6 -1
- package/dist/routes/apiRoute.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/{handleAPIRoute.d.ts → handleAPIRoute.server.d.ts} +1 -1
- package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
- package/dist/utilities/{handleAPIRoute.js → handleAPIRoute.server.js} +1 -1
- package/dist/utilities/handleAPIRoute.server.js.map +1 -0
- 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 +13 -12
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/meta.d.ts +1 -0
- package/dist/utilities/meta.d.ts.map +1 -1
- package/dist/utilities/meta.js +2 -1
- package/dist/utilities/meta.js.map +1 -1
- package/dist/utilities/routerSearch.d.ts +40 -0
- package/dist/utilities/routerSearch.d.ts.map +1 -0
- package/dist/utilities/routerSearch.js +45 -0
- package/dist/utilities/routerSearch.js.map +1 -0
- package/dist/withPayload/config/external.d.ts +36 -0
- package/dist/withPayload/config/external.d.ts.map +1 -0
- package/dist/withPayload/config/external.js +82 -0
- package/dist/withPayload/config/external.js.map +1 -0
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
- package/dist/withPayload/config/optimizeDeps.js.map +1 -0
- package/dist/withPayload/config/scss.d.ts.map +1 -0
- package/dist/withPayload/config/scss.js.map +1 -0
- package/dist/withPayload/importProtection.d.ts.map +1 -0
- package/dist/{vite → withPayload}/importProtection.js +2 -2
- package/dist/withPayload/importProtection.js.map +1 -0
- package/dist/withPayload/index.d.ts.map +1 -0
- package/dist/{vite → withPayload}/index.js +26 -7
- package/dist/withPayload/index.js.map +1 -0
- package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
- package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
- package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
- package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
- package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
- package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
- package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.js +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
- package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
- package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
- package/package.json +10 -10
- 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/exports/vite.d.ts +0 -3
- package/dist/exports/vite.d.ts.map +0 -1
- package/dist/exports/vite.js +0 -3
- package/dist/exports/vite.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/handleAPIRoute.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.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
- package/dist/vite/config/external.d.ts +0 -11
- package/dist/vite/config/external.d.ts.map +0 -1
- package/dist/vite/config/external.js +0 -48
- package/dist/vite/config/external.js.map +0 -1
- package/dist/vite/config/optimizeDeps.d.ts.map +0 -1
- package/dist/vite/config/optimizeDeps.js.map +0 -1
- package/dist/vite/config/scss.d.ts.map +0 -1
- package/dist/vite/config/scss.js.map +0 -1
- package/dist/vite/importProtection.d.ts.map +0 -1
- package/dist/vite/importProtection.js.map +0 -1
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/workarounds/clientModuleResolution.d.ts.map +0 -1
- package/dist/vite/workarounds/clientModuleResolution.js.map +0 -1
- package/dist/vite/workarounds/devTransforms.d.ts.map +0 -1
- package/dist/vite/workarounds/devTransforms.js.map +0 -1
- package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +0 -1
- package/dist/vite/workarounds/reactDomServerInRsc.js.map +0 -1
- package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +0 -1
- package/dist/vite/workarounds/stripDistStyleImports.js.map +0 -1
- package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +0 -1
- package/dist/vite/workarounds/stubPrettierInClient.js.map +0 -1
- package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +0 -1
- package/dist/vite/workarounds/wrapCjsForClient.js.map +0 -1
- /package/dist/{vite → withPayload}/config/optimizeDeps.d.ts +0 -0
- /package/dist/{vite → withPayload}/config/optimizeDeps.js +0 -0
- /package/dist/{vite → withPayload}/config/scss.d.ts +0 -0
- /package/dist/{vite → withPayload}/config/scss.js +0 -0
- /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
- /package/dist/{vite → withPayload}/index.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.js +0 -0
- /package/dist/{vite → withPayload}/workarounds/devTransforms.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/devTransforms.js +0 -0
- /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.js +0 -0
- /package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.js +0 -0
- /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.d.ts +0 -0
- /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.js +0 -0
|
@@ -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;AA6B3D;;;CAGC,GACD,OAAO,eAAeC,cAAc,EAClCC,aAAa,EACbC,SAAS,EACS;IAClB,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,GAAG,MAAMV,QAAQ;QAAEE;QAAeC;IAAU;IAE7C,MAAMQ,QAAQf,gBAAgB;QAAEc;QAAQN;QAASC;IAAQ;IACzD,MAAMO,aAAajB,gBAAgB;QAAEe;QAAQN;IAAQ;IAErD,MAAMS,kBAAmCC,OAAOC,OAAO,CACrDL,OAAOM,IAAI,CAACC,kBAAkB,IAAI,CAAC,GACnCC,MAAM,CAAC,CAACC,KAAK,CAACC,UAAUC,eAAe;QACvC,IAAIP,OAAOQ,IAAI,CAACZ,OAAOM,IAAI,CAACC,kBAAkB,EAAEM,QAAQ,CAACH,WAAW;YAClED,IAAIK,IAAI,CAAC;gBACPC,OAAOJ,eAAeK,YAAY,CAACC,OAAO,CAACC,YAAY;gBACvDC,OAAOT;YACT;QACF;QACA,OAAOD;IACT,GAAG,EAAE;IAEL,MAAMW,WAAW,MAAMtC,YAAYgB;IAEnC,MAAMuB,eAAerC,gBAAgB;QACnCgB;QACAM,MAAMR,IAAIQ,IAAI;QACdb;QACA6B,MAAMxB,IAAIwB,IAAI,IAAI;IACpB;IAEA,MAAMlC,qBAAqB;QAAEiC;QAAcrB;QAAQF;IAAI;IAEvD,6EAA6E;IAC7E,sEAAsE;IACtE,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,8EAA8E;IAC9E,MAAMyB,gBAAgBvB,OAAOwB,KAAK,EAAEC,YAAYC;IAChD,IAAIA,YAA6BC;IACjC,IAAIC,MAAMC,OAAO,CAACN,kBAAkBA,cAAcO,MAAM,GAAG,GAAG;QAC5D,MAAMC,cAA2B;YAC/BzB,MAAMR,IAAIQ,IAAI;YACd0B,QAAQ,CAAC;YACTjC,SAASD,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,EAAoB,MAAM,OAAO,CAAA;AAIlE;;;;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,gCAWjB;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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { NotFoundClient } from '@payloadcms/ui';
|
|
4
4
|
import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
|
|
5
|
-
import { Fragment } from 'react';
|
|
5
|
+
import { Fragment, useDeferredValue } 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,18 @@ 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);
|
|
32
33
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
33
|
-
children:
|
|
34
|
-
}
|
|
34
|
+
children: rscPayload
|
|
35
|
+
});
|
|
35
36
|
}
|
|
36
37
|
function AdminNotFound(props) {
|
|
37
38
|
const rscPayload = props?.data?.rscPayload;
|
|
@@ -42,15 +43,12 @@ function AdminNotFound(props) {
|
|
|
42
43
|
children: rscPayload
|
|
43
44
|
}, props?.data?.routeKey);
|
|
44
45
|
}
|
|
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 {
|
|
46
|
+
const adminRouteOptions = ({ forwardNotFoundPayload, load, resolveSplat })=>({
|
|
52
47
|
component: AdminPage,
|
|
53
48
|
head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
|
|
49
|
+
// Both admin routes must use the same boundary type so index ↔ splat
|
|
50
|
+
// navigation preserves the existing admin subtree.
|
|
51
|
+
notFoundComponent: AdminNotFound,
|
|
54
52
|
// `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
|
|
55
53
|
// sibling route option — router-core only reads it off a non-function loader)
|
|
56
54
|
// makes stale-match revalidation await the fresh loader before committing,
|
|
@@ -58,15 +56,15 @@ function AdminNotFound(props) {
|
|
|
58
56
|
// (e.g. a just-created doc missing) until the reload lands.
|
|
59
57
|
loader: {
|
|
60
58
|
handler: async ({ location, params })=>{
|
|
61
|
-
const data = await runLoader(load, params
|
|
59
|
+
const data = await runLoader(load, resolveSplat(params), location.searchStr);
|
|
62
60
|
if (data?._notFound) {
|
|
63
61
|
// eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
|
|
64
|
-
throw notFound({
|
|
62
|
+
throw notFound(forwardNotFoundPayload ? {
|
|
65
63
|
data: {
|
|
66
64
|
routeKey: data.routeKey,
|
|
67
65
|
rscPayload: data.rscPayload
|
|
68
66
|
}
|
|
69
|
-
});
|
|
67
|
+
} : undefined);
|
|
70
68
|
}
|
|
71
69
|
return data;
|
|
72
70
|
},
|
|
@@ -76,33 +74,29 @@ function AdminNotFound(props) {
|
|
|
76
74
|
loaderDeps: ({ search })=>({
|
|
77
75
|
searchKey: JSON.stringify(search)
|
|
78
76
|
}),
|
|
79
|
-
notFoundComponent: AdminNotFound,
|
|
80
77
|
validateSearch: (search)=>search
|
|
81
|
-
};
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
|
|
81
|
+
* server-built NotFound page (shipped via the `notFound()` error's
|
|
82
|
+
* `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
|
|
83
|
+
* client view.
|
|
84
|
+
*/ export function payloadAdminSplatRoute({ load }) {
|
|
85
|
+
return adminRouteOptions({
|
|
86
|
+
forwardNotFoundPayload: true,
|
|
87
|
+
load,
|
|
88
|
+
resolveSplat: (params)=>params._splat ?? ''
|
|
89
|
+
});
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
|
-
* Route options for the admin index route (`/_payload/admin/`).
|
|
85
|
-
*
|
|
92
|
+
* Route options for the admin index route (`/_payload/admin/`). Not-found
|
|
93
|
+
* results omit the RSC payload and fall back to `NotFoundClient`.
|
|
86
94
|
*/ 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
|
-
};
|
|
95
|
+
return adminRouteOptions({
|
|
96
|
+
forwardNotFoundPayload: false,
|
|
97
|
+
load,
|
|
98
|
+
resolveSplat: ()=>''
|
|
99
|
+
});
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
//# 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 } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode, useDeferredValue } 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\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","notFound","redirect","useLoaderData","Fragment","useDeferredValue","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","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,QAAQ,iBAAgB;AAC/C,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,yBAAwB;AAC1E,SAASC,QAAQ,EAAkBC,gBAAgB,QAAQ,QAAO;AAElE,SAASC,YAAY,QAAQ,uBAAsB;AAWnD,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAOC,MAAiBC,OAAeN;IACvD,MAAMO,OAAO,MAAMF,KAAK;QAAEE,MAAM;YAAEC,QAAQF;YAAOG,QAAQV,eAAeC;QAAW;IAAE;IACrF,IAAIO,MAAMG,WAAW;QACnB,qHAAqH;QACrH,MAAMhB,SAAS;YAAEiB,IAAIJ,KAAKG,SAAS;QAAC;IACtC;IACA,OAAOH;AACT;AAEA,SAASK;IACP,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAML,OAAOZ,cAAc;QAAEkB,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAajB,iBAAiBU,MAAMO;IAE1C,qBAAO,KAAClB;kBAAUkB;;AACpB;AAEA,SAASC,cAAcC,KAA+D;IACpF,MAAMF,aAAaE,OAAOT,MAAMO;IAChC,IAAI,CAACA,YAAY;QACf,qBAAO,KAACtB;IACV;IACA,qBAAO,KAACI;kBAAsCkB;OAAxBE,OAAOT,MAAMU;AACrC;AAEA,MAAMC,oBAAoB,CAAC,EACzBC,sBAAsB,EACtBd,IAAI,EACJe,YAAY,EAWb,GAAM,CAAA;QACLC,WAAWT;QACXU,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKzB,aAAayB,YAAYC;QACzE,qEAAqE;QACrE,mDAAmD;QACnDC,mBAAmBV;QACnB,0EAA0E;QAC1E,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,4DAA4D;QAC5DW,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;gBAClE,MAAMtB,OAAO,MAAMH,UAAUC,MAAMe,aAAaS,SAASD,SAAS5B,SAAS;gBAC3E,IAAIO,MAAMuB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMrC,SACJ0B,yBACI;wBAAEZ,MAAM;4BAAEU,UAAUV,KAAKU,QAAQ;4BAAEH,YAAYP,KAAKO,UAAU;wBAAC;oBAAE,IACjEiB;gBAER;gBACA,OAAOxB;YACT;YACAyB,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAExB,MAAM,EAAuC,GAAM,CAAA;gBAChEyB,WAAWC,KAAKC,SAAS,CAAC3B;YAC5B,CAAA;QACA4B,gBAAgB,CAAC5B,SAAoCA;IACvD,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAAS6B,uBAAuB,EAAEjC,IAAI,EAAuB;IAClE,OAAOa,kBAAkB;QACvBC,wBAAwB;QACxBd;QACAe,cAAc,CAACS,SAAWA,OAAOrB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS+B,uBAAuB,EAAElC,IAAI,EAAuB;IAClE,OAAOa,kBAAkB;QACvBC,wBAAwB;QACxBd;QACAe,cAAc,IAAM;IACtB;AACF"}
|
|
@@ -7,10 +7,15 @@ type ApiRouteHandler = (ctx: {
|
|
|
7
7
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
8
8
|
* import) since the package cannot resolve the consumer's config.
|
|
9
9
|
*
|
|
10
|
+
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
11
|
+
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
12
|
+
*
|
|
10
13
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
11
14
|
* client compiler can statically see — and prune — the server-only route:
|
|
12
15
|
*
|
|
13
16
|
* ```ts
|
|
17
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
18
|
+
*
|
|
14
19
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
15
20
|
* server: {
|
|
16
21
|
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE
|
|
1
|
+
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
|
package/dist/routes/apiRoute.js
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
4
|
* import) since the package cannot resolve the consumer's config.
|
|
5
5
|
*
|
|
6
|
+
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
7
|
+
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
8
|
+
*
|
|
6
9
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
7
10
|
* client compiler can statically see — and prune — the server-only route:
|
|
8
11
|
*
|
|
9
12
|
* ```ts
|
|
13
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
14
|
+
*
|
|
10
15
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
11
16
|
* server: {
|
|
12
17
|
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
@@ -19,7 +24,7 @@
|
|
|
19
24
|
* key, leaking the config graph into the client bundle.
|
|
20
25
|
*/ export function payloadApiHandlers({ getConfig }) {
|
|
21
26
|
const handler = async ({ request })=>{
|
|
22
|
-
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
|
|
27
|
+
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js');
|
|
23
28
|
return handleAPIRoute({
|
|
24
29
|
config: await getConfig(),
|
|
25
30
|
request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA
|
|
1
|
+
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so\n * the server-only `handleAPIRoute` graph never reaches the client bundle.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAPIRoute.server.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleAPIRoute.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
|
|
@@ -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;
|
|
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,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GACpE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;CAC5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAkJlD"}
|