@payloadcms/tanstack-start 4.0.0-internal.314c594 → 4.0.0-internal.31ba7ee
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/elements/RouterAdapter/index.d.ts.map +1 -1
- package/dist/elements/RouterAdapter/index.js +2 -1
- package/dist/elements/RouterAdapter/index.js.map +1 -1
- package/dist/exports/server.d.ts +0 -2
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +0 -2
- package/dist/exports/server.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts +3 -0
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +7 -6
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +3 -4
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +22 -11
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
- package/dist/routes/adminRoutes.d.ts.map +1 -1
- package/dist/routes/adminRoutes.js +2 -1
- package/dist/routes/adminRoutes.js.map +1 -1
- package/dist/routes/layoutRoute.d.ts +1 -1
- package/dist/routes/layoutRoute.d.ts.map +1 -1
- package/dist/routes/layoutRoute.js +2 -1
- package/dist/routes/layoutRoute.js.map +1 -1
- package/dist/utilities/devConfigReload.server.js +28 -3
- package/dist/utilities/devConfigReload.server.js.map +1 -1
- package/dist/utilities/getRequestI18n.server.d.ts +1 -1
- package/dist/utilities/getRequestI18n.server.js +1 -1
- package/dist/utilities/getRequestI18n.server.js.map +1 -1
- package/dist/utilities/graphqlHandler.server.js +2 -2
- package/dist/utilities/graphqlHandler.server.js.map +1 -1
- package/dist/utilities/handleServerFunctions.js +2 -5
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initAdminContext.server.d.ts +9 -0
- package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
- package/dist/utilities/initAdminContext.server.js +13 -0
- package/dist/utilities/initAdminContext.server.js.map +1 -0
- package/dist/utilities/loadAdminPage.d.ts +2 -2
- package/dist/utilities/loadAdminPage.d.ts.map +1 -1
- package/dist/utilities/loadAdminPage.js +8 -12
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/serializeForRsc.d.ts.map +1 -1
- package/dist/utilities/serializeForRsc.js +6 -1
- package/dist/utilities/serializeForRsc.js.map +1 -1
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +6 -1
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/utilities/toSerializable.d.ts.map +1 -1
- package/dist/utilities/toSerializable.js +6 -1
- package/dist/utilities/toSerializable.js.map +1 -1
- package/dist/withPayload/config/external.js +1 -1
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
- package/dist/withPayload/config/optimizeDeps.js +20 -4
- package/dist/withPayload/config/optimizeDeps.js.map +1 -1
- package/dist/withPayload/index.d.ts +6 -0
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +8 -2
- package/dist/withPayload/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -19
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/initReq.server.d.ts +0 -20
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -90
- package/dist/utilities/initReq.server.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterAdapter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterAdapter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AA8DvE,eAAO,MAAM,qBAAqB,EAAE,sBAqHnC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { RouterAdapterContext
|
|
3
|
+
import { RouterAdapterContext } from '@payloadcms/ui/providers/RouterAdapter';
|
|
4
|
+
import { useRouteTransition } from '@payloadcms/ui/providers/RouteTransition';
|
|
4
5
|
import { Link as TanStackLink, useLocation, useParams, useRouter, useRouterState } from '@tanstack/react-router';
|
|
5
6
|
import * as qs from 'qs-esm';
|
|
6
7
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/RouterAdapter/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps, RouterAdapterComponent } from 'payload'\n\nimport { RouterAdapterContext
|
|
1
|
+
{"version":3,"sources":["../../../src/elements/RouterAdapter/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RouterAdapterContextValue } from '@payloadcms/ui/providers/RouterAdapter'\nimport type { LinkAdapterProps, RouterAdapterComponent } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui/providers/RouterAdapter'\nimport { useRouteTransition } from '@payloadcms/ui/providers/RouteTransition'\nimport {\n Link as TanStackLink,\n useLocation,\n useParams,\n useRouter,\n useRouterState,\n} from '@tanstack/react-router'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo } from 'react'\n\nconst normalizeNavigationTarget = ({\n path,\n pathname,\n search,\n}: {\n path: string\n pathname: string\n search: string\n}) => {\n if (path.startsWith('http')) {\n const url = new URL(path)\n return `${url.pathname}${url.search}${url.hash}`\n }\n\n if (path.startsWith('?')) {\n return `${pathname}${path}`\n }\n\n if (path.startsWith('#')) {\n return `${pathname}${search}${path}`\n }\n\n return path\n}\n\nconst TanStackLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <TanStackLink\n preload={prefetch === false ? false : 'intent'}\n ref={ref}\n replace={replace}\n resetScroll={scroll}\n to={href}\n {...rest}\n >\n {children}\n </TanStackLink>\n )\n}\n\nexport const TanStackRouterAdapter: RouterAdapterComponent = ({ children }) => {\n const router = useRouter()\n const location = useLocation()\n const params = useParams({ strict: false })\n const isRouterLoading = useRouterState({ select: (state) => state.isLoading })\n const { holdRouteTransition } = useRouteTransition()\n\n useEffect(() => {\n if (!isRouterLoading) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRouterLoading])\n\n const adaptedParams = useMemo(() => {\n const adapted: Record<string, string | string[]> = { ...params }\n\n if ('_splat' in params && typeof params._splat === 'string') {\n adapted.segments = params._splat.split('/').filter(Boolean)\n }\n\n return adapted\n }, [params])\n\n // Split a target into `to` (pathname) + a parsed `search` object, so the\n // router serializes the query via its `stringifySearch` (qs, bracket-encoded)\n // rather than embedding the raw string in `to`. Navigating with a string `to`\n // leaves the search *unencoded* in `window.location.search`\n // (e.g. `where[or][0]…`), which then never matches Payload's `qs.stringify`\n // output (`where%5Bor%5D…`) — breaking the list-view `syncPropsToURL` guard,\n // which compares the two and would otherwise clobber optimistic query state\n // (e.g. an in-progress filter condition) on every navigation.\n const toNavOptions = useCallback((path: string) => {\n const relativePath = normalizeNavigationTarget({\n path,\n pathname: window.location.pathname,\n search: window.location.search,\n })\n\n const queryIndex = relativePath.indexOf('?')\n\n if (queryIndex === -1) {\n return { to: relativePath }\n }\n\n const searchObject = qs.parse(relativePath.slice(queryIndex + 1), {\n depth: 10,\n ignoreQueryPrefix: true,\n })\n\n // Function form replaces the search entirely (no merge with current search).\n return { search: () => searchObject, to: relativePath.slice(0, queryIndex) }\n }, [])\n\n const back = useCallback(() => router.history.back(), [router])\n\n const push = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n\n const refresh = useCallback(() => {\n void router.invalidate()\n }, [router])\n\n const replace = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), replace: true, resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n\n // Mirror Next.js' router behavior to allow syncing client state to the URL without triggering a second server load.\n // TanStack's browser history monkeypatches `window.history.replaceState` and notifies `router.load` on every call.\n // Use `_ignoreSubscribers` to suppresses that notification — the same flag TanStack uses internally when flushing history.\n const replaceState = useCallback(\n (url: string) => {\n const { history } = router\n history._ignoreSubscribers = true\n\n try {\n window.history.replaceState(null, '', url)\n } finally {\n history._ignoreSubscribers = false\n }\n },\n [router],\n )\n\n const adaptedRouter = useMemo(\n () => ({ back, push, refresh, replace, replaceState }),\n [back, push, refresh, replace, replaceState],\n )\n\n // `location.searchStr` is the serialized query string; `location.search` is\n // the parsed object (a nested structure once the router uses `qs` for search\n // serialization), which `URLSearchParams` cannot consume. Build from the\n // string so Payload's `parseSearchParams` re-parses the bracket notation.\n const searchParams = useMemo(() => new URLSearchParams(location.searchStr), [location.searchStr])\n\n const value: RouterAdapterContextValue = useMemo(\n () => ({\n Link: TanStackLinkAdapter,\n params: adaptedParams,\n pathname: location.pathname,\n router: adaptedRouter,\n searchParams,\n }),\n [adaptedParams, location.pathname, adaptedRouter, searchParams],\n )\n\n return <RouterAdapterContext value={value}>{children}</RouterAdapterContext>\n}\n"],"names":["RouterAdapterContext","useRouteTransition","Link","TanStackLink","useLocation","useParams","useRouter","useRouterState","qs","React","useCallback","useEffect","useMemo","normalizeNavigationTarget","path","pathname","search","startsWith","url","URL","hash","TanStackLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","preload","resetScroll","to","TanStackRouterAdapter","router","location","params","strict","isRouterLoading","select","state","isLoading","holdRouteTransition","releaseRouteTransition","adaptedParams","adapted","_splat","segments","split","filter","Boolean","toNavOptions","relativePath","window","queryIndex","indexOf","searchObject","parse","slice","depth","ignoreQueryPrefix","back","history","push","options","navigate","refresh","invalidate","replaceState","_ignoreSubscribers","adaptedRouter","searchParams","URLSearchParams","searchStr","value"],"mappings":"AAAA;;AAKA,SAASA,oBAAoB,QAAQ,yCAAwC;AAC7E,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SACEC,QAAQC,YAAY,EACpBC,WAAW,EACXC,SAAS,EACTC,SAAS,EACTC,cAAc,QACT,yBAAwB;AAC/B,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,QAAO;AAE9D,MAAMC,4BAA4B,CAAC,EACjCC,IAAI,EACJC,QAAQ,EACRC,MAAM,EAKP;IACC,IAAIF,KAAKG,UAAU,CAAC,SAAS;QAC3B,MAAMC,MAAM,IAAIC,IAAIL;QACpB,OAAO,GAAGI,IAAIH,QAAQ,GAAGG,IAAIF,MAAM,GAAGE,IAAIE,IAAI,EAAE;IAClD;IAEA,IAAIN,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWD,MAAM;IAC7B;IAEA,IAAIA,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWC,SAASF,MAAM;IACtC;IAEA,OAAOA;AACT;AAEA,MAAMO,sBAAkD,CAAC,EACvDC,QAAQ,EACRC,IAAI,EACJC,QAAQ,EACRC,GAAG,EACHC,OAAO,EACPC,MAAM,EACN,GAAGC,MACJ;IACC,qBACE,KAACzB;QACC0B,SAASL,aAAa,QAAQ,QAAQ;QACtCC,KAAKA;QACLC,SAASA;QACTI,aAAaH;QACbI,IAAIR;QACH,GAAGK,IAAI;kBAEPN;;AAGP;AAEA,OAAO,MAAMU,wBAAgD,CAAC,EAAEV,QAAQ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YACRC;QACF,CAAA,GACA;QAAC3B;QAAeT,SAASnB,QAAQ;QAAEsD;QAAeC;KAAa;IAGjE,qBAAO,KAACtE;QAAqByE,OAAOA;kBAAQnD;;AAC9C,EAAC"}
|
package/dist/exports/server.d.ts
CHANGED
|
@@ -3,11 +3,9 @@ export { logout } from '../auth/logout.js';
|
|
|
3
3
|
export { refresh } from '../auth/refresh.js';
|
|
4
4
|
export { payloadApiHandlers } from '../routes/apiRoute.js';
|
|
5
5
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
6
|
-
export { getRequestLocale } from '../utilities/getRequestLocale.js';
|
|
7
6
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
7
|
export { handleAPIRoute } from '../utilities/handleAPIRoute.server.js';
|
|
9
8
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
|
-
export { initReq } from '../utilities/initReq.server.js';
|
|
11
9
|
export { loadAdminPage, type LoadAdminPageArgs, type LoadAdminPageResult, } from '../utilities/loadAdminPage.js';
|
|
12
10
|
export { type AdminPageMetadata, getAdminMeta } from '../utilities/meta.js';
|
|
13
11
|
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,KAAK,aAAa,EAClB,qBAAqB,GACtB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,KAAK,kBAAkB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}
|
package/dist/exports/server.js
CHANGED
|
@@ -3,11 +3,9 @@ export { logout } from '../auth/logout.js';
|
|
|
3
3
|
export { refresh } from '../auth/refresh.js';
|
|
4
4
|
export { payloadApiHandlers } from '../routes/apiRoute.js';
|
|
5
5
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
6
|
-
export { getRequestLocale } from '../utilities/getRequestLocale.js';
|
|
7
6
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
7
|
export { handleAPIRoute } from '../utilities/handleAPIRoute.server.js';
|
|
9
8
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
|
-
export { initReq } from '../utilities/initReq.server.js';
|
|
11
9
|
export { loadAdminPage } from '../utilities/loadAdminPage.js';
|
|
12
10
|
export { getAdminMeta } from '../utilities/meta.js';
|
|
13
11
|
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { payloadApiHandlers } from '../routes/apiRoute.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { payloadApiHandlers } from '../routes/apiRoute.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport { handleGraphQL } from '../utilities/graphqlHandler.server.js'\nexport { handleAPIRoute } from '../utilities/handleAPIRoute.server.js'\nexport { handleServerFunctions } from '../utilities/handleServerFunctions.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../utilities/loadAdminPage.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../utilities/meta.js'\nexport { serializeForRsc } from '../utilities/serializeForRsc.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../utilities/serverAdapter.server.js'\nexport { type SerializableRecord, toSerializable } from '../utilities/toSerializable.js'\nexport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\n"],"names":["login","logout","refresh","payloadApiHandlers","getRequestI18n","handleGraphQL","handleAPIRoute","handleServerFunctions","loadAdminPage","getAdminMeta","serializeForRsc","createPageRenderServerAdapter","tanstackServerAdapter","toSerializable","getRequestTheme"],"mappings":"AAAA,SAASA,KAAK,QAAQ,mBAAkB;AACxC,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,OAAO,QAAQ,qBAAoB;AAC5C,SAASC,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,aAAa,QAAQ,wCAAuC;AACrE,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,qBAAqB,QAAQ,wCAAuC;AAC7E,SACEC,aAAa,QAGR,gCAA+B;AACtC,SAAiCC,YAAY,QAAQ,uBAAsB;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SACEC,6BAA6B,EAE7BC,qBAAqB,QAChB,uCAAsC;AAC7C,SAAkCC,cAAc,QAAQ,iCAAgC;AACxF,SAASC,eAAe,QAAQ,2CAA0C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
2
|
import type { Theme } from '@payloadcms/ui';
|
|
3
|
+
import type { RequestThemeSource } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
3
4
|
import type { ClientConfig, ImportMap, LanguageOptions, SanitizedConfig, SanitizedPermissions, User } from 'payload';
|
|
4
5
|
export type RootLayoutData = {
|
|
5
6
|
clientConfig: ClientConfig;
|
|
@@ -19,6 +20,8 @@ export type RootLayoutData = {
|
|
|
19
20
|
*/
|
|
20
21
|
providers?: React.ReactNode;
|
|
21
22
|
theme: Theme;
|
|
23
|
+
/** The request input used to resolve `theme`. */
|
|
24
|
+
themeSource: RequestThemeSource;
|
|
22
25
|
translations: I18nClient['translations'];
|
|
23
26
|
user: null | User;
|
|
24
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLayoutData.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/getLayoutData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBA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,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,eAAe,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,oBAAoB,CAAA;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,iDAAiD;IACjD,WAAW,EAAE,kBAAkB,CAAA;IAC/B,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IACxC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,EAClC,aAAa,EACb,SAAS,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CA+F7C"}
|
|
@@ -6,16 +6,16 @@ import { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
|
6
6
|
import { Outlet } from '@tanstack/react-router';
|
|
7
7
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
8
8
|
import { createElement } from 'react';
|
|
9
|
-
import {
|
|
9
|
+
import { initAdminContext } from '../../utilities/initAdminContext.server.js';
|
|
10
10
|
/**
|
|
11
11
|
* Fetches all data needed by the root admin layout.
|
|
12
12
|
* Call this in your TanStack Start root route loader.
|
|
13
13
|
*/ export async function getLayoutData({ configPromise, importMap }) {
|
|
14
|
-
const { cookies, headers, languageCode, permissions, req, req: { payload: { config } } } = await
|
|
14
|
+
const { cookies, headers, languageCode, permissions, req, req: { payload: { config } }, user } = await initAdminContext({
|
|
15
15
|
configPromise,
|
|
16
16
|
importMap
|
|
17
17
|
});
|
|
18
|
-
const theme = getRequestTheme({
|
|
18
|
+
const { theme, themeSource } = getRequestTheme({
|
|
19
19
|
config,
|
|
20
20
|
cookies,
|
|
21
21
|
headers
|
|
@@ -38,7 +38,7 @@ import { initReq } from '../../utilities/initReq.server.js';
|
|
|
38
38
|
config,
|
|
39
39
|
i18n: req.i18n,
|
|
40
40
|
importMap,
|
|
41
|
-
user:
|
|
41
|
+
user: user ?? true
|
|
42
42
|
});
|
|
43
43
|
await applyLocaleFiltering({
|
|
44
44
|
clientConfig,
|
|
@@ -61,7 +61,7 @@ import { initReq } from '../../utilities/initReq.server.js';
|
|
|
61
61
|
permissions,
|
|
62
62
|
searchParams: {},
|
|
63
63
|
server: req.server,
|
|
64
|
-
user:
|
|
64
|
+
user: user ?? undefined
|
|
65
65
|
};
|
|
66
66
|
// Mirror the Next adapter's `NestProviders`: render each configured provider
|
|
67
67
|
// via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`
|
|
@@ -89,8 +89,9 @@ import { initReq } from '../../utilities/initReq.server.js';
|
|
|
89
89
|
permissions,
|
|
90
90
|
providers,
|
|
91
91
|
theme,
|
|
92
|
+
themeSource,
|
|
92
93
|
translations: req.i18n.translations,
|
|
93
|
-
user:
|
|
94
|
+
user: user ?? null
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
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 { RequestThemeSource } from '@payloadcms/ui/utilities/getRequestTheme'\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 { initAdminContext } from '../../utilities/initAdminContext.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 /** The request input used to resolve `theme`. */\n themeSource: RequestThemeSource\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 user,\n } = await initAdminContext({ configPromise, importMap })\n\n const { theme, themeSource } = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\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: 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: 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 themeSource,\n translations: req.i18n.translations,\n user: user ?? null,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","getRequestEmbed","getRequestTheme","Outlet","applyLocaleFiltering","createElement","initAdminContext","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","user","theme","themeSource","isEmbedded","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAaA,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,gBAAgB,QAAQ,6CAA4C;AA+B7E;;;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,EACDC,IAAI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C9ED,YAAYH,cAAcY,WAAW,CACnC,CAACC,UAAUC,WACTvD,sBAAsB;gBACpBwD,aAAa;oBAAEF;gBAAS;gBACxBG,WAAWF;gBACX7C;gBACAuC;YACF,IACF3C,cAAcF;IAElB;IAEA,OAAO;QACLoC;QACAkB,YAAY3C,IAAIU,IAAI,CAACiC,UAAU;QAC/BC,cAAc1C,OAAOQ,IAAI,CAACmC,gBAAgB;QAC1CvC;QACAwC,WAAWtB,UAAUuB,QAAQ;QAC7BjD;QACAS;QACAyC,QAAQhD,IAAIgD,MAAM,IAAIlB;QACtB/B;QACA8B;QACAzB;QACAC;QACAe,cAAcpB,IAAIU,IAAI,CAACU,YAAY;QACnCjB,MAAMA,QAAQ;IAChB;AACF"}
|
|
@@ -6,10 +6,9 @@ export type PayloadAdminShellProps = {
|
|
|
6
6
|
* The `<html>` document shell for Payload admin routes — the TanStack Start
|
|
7
7
|
* equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
|
|
8
8
|
* `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
|
|
9
|
-
* (`getLayoutData`, exposed on the `/_payload` route loader)
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
|
|
9
|
+
* (`getLayoutData`, exposed on the `/_payload` route loader). A blocking script
|
|
10
|
+
* resolves the server's default theme from the browser preference before first paint,
|
|
11
|
+
* while the server-provided language and text direction remain authoritative.
|
|
13
12
|
*/
|
|
14
13
|
export declare function PayloadAdminShell({ children }: PayloadAdminShellProps): React.JSX.Element;
|
|
15
14
|
export type WithPayloadRootOptions = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,qBAkDrE;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,EAC7D,OAAO,GAAE,sBAA2B,kBAIW;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ResolveThemeOnClient } from '@payloadcms/ui/layouts/Root/ResolveThemeOnClient';
|
|
3
4
|
import { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir';
|
|
4
5
|
import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
|
|
5
6
|
import React from 'react';
|
|
@@ -7,22 +8,25 @@ import React from 'react';
|
|
|
7
8
|
* The `<html>` document shell for Payload admin routes — the TanStack Start
|
|
8
9
|
* equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
|
|
9
10
|
* `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
|
|
10
|
-
* (`getLayoutData`, exposed on the `/_payload` route loader)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
|
|
11
|
+
* (`getLayoutData`, exposed on the `/_payload` route loader). A blocking script
|
|
12
|
+
* resolves the server's default theme from the browser preference before first paint,
|
|
13
|
+
* while the server-provided language and text direction remain authoritative.
|
|
14
14
|
*/ export function PayloadAdminShell({ children }) {
|
|
15
|
-
const htmlProps = useRouterState({
|
|
15
|
+
const { htmlProps, serverTheme, themeSource } = useRouterState({
|
|
16
16
|
select: (state)=>{
|
|
17
17
|
for (const match of state.matches){
|
|
18
18
|
const data = match.loaderData;
|
|
19
19
|
if (data?.theme && data?.languageCode) {
|
|
20
20
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
htmlProps: {
|
|
22
|
+
'data-theme': data.theme,
|
|
23
|
+
dir: getLanguageDir({
|
|
24
|
+
languageCode: data.languageCode
|
|
25
|
+
}),
|
|
26
|
+
lang: data.languageCode
|
|
27
|
+
},
|
|
28
|
+
serverTheme: data.theme,
|
|
29
|
+
themeSource: data.themeSource ?? 'default'
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
}
|
|
@@ -30,7 +34,11 @@ import React from 'react';
|
|
|
30
34
|
// to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the
|
|
31
35
|
// document sidebar divider) still match, matching Next's `ltr` default.
|
|
32
36
|
return {
|
|
33
|
-
|
|
37
|
+
htmlProps: {
|
|
38
|
+
dir: 'ltr'
|
|
39
|
+
},
|
|
40
|
+
serverTheme: 'light',
|
|
41
|
+
themeSource: 'default'
|
|
34
42
|
};
|
|
35
43
|
}
|
|
36
44
|
});
|
|
@@ -41,6 +49,9 @@ import React from 'react';
|
|
|
41
49
|
children: [
|
|
42
50
|
/*#__PURE__*/ _jsxs("head", {
|
|
43
51
|
children: [
|
|
52
|
+
themeSource === 'default' && /*#__PURE__*/ _jsx(ResolveThemeOnClient, {
|
|
53
|
+
serverTheme: serverTheme
|
|
54
|
+
}),
|
|
44
55
|
/*#__PURE__*/ _jsx("style", {
|
|
45
56
|
children: `@layer payload-default, payload;`
|
|
46
57
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport type { Theme } from '@payloadcms/ui'\n\nimport { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\ntype AdminHTMLProps = {\n 'data-theme'?: Theme\n dir: 'ltr' | 'rtl'\n lang?: string\n}\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets\n * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data\n * (`getLayoutData`, exposed on the `/_payload` route loader)
|
|
1
|
+
{"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport type { Theme } from '@payloadcms/ui'\nimport type { RequestThemeSource } from '@payloadcms/ui/utilities/getRequestTheme'\n\nimport { ResolveThemeOnClient } from '@payloadcms/ui/layouts/Root/ResolveThemeOnClient'\nimport { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\ntype AdminHTMLProps = {\n 'data-theme'?: Theme\n dir: 'ltr' | 'rtl'\n lang?: string\n}\n\ntype AdminShellState = {\n htmlProps: AdminHTMLProps\n serverTheme: Theme\n themeSource: RequestThemeSource\n}\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets\n * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data\n * (`getLayoutData`, exposed on the `/_payload` route loader). A blocking script\n * resolves the server's default theme from the browser preference before first paint,\n * while the server-provided language and text direction remain authoritative.\n */\nexport function PayloadAdminShell({ children }: PayloadAdminShellProps) {\n const { htmlProps, serverTheme, themeSource } = useRouterState({\n select: (state): AdminShellState => {\n for (const match of state.matches) {\n const data = match.loaderData as\n | {\n languageCode?: string\n theme?: Theme\n themeSource?: RequestThemeSource\n }\n | undefined\n\n if (data?.theme && data?.languageCode) {\n return {\n htmlProps: {\n 'data-theme': data.theme,\n dir: getLanguageDir({ languageCode: data.languageCode }),\n lang: data.languageCode,\n },\n serverTheme: data.theme,\n themeSource: data.themeSource ?? 'default',\n }\n }\n }\n\n // No layout data yet (fresh session before the loader resolves): default\n // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the\n // document sidebar divider) still match, matching Next's `ltr` default.\n return {\n htmlProps: { dir: 'ltr' },\n serverTheme: 'light',\n themeSource: 'default',\n }\n },\n })\n\n return (\n // eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available\n <html {...htmlProps} suppressHydrationWarning>\n <head>\n {themeSource === 'default' && <ResolveThemeOnClient serverTheme={serverTheme} />}\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin' } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["ResolveThemeOnClient","getLanguageDir","HeadContent","Scripts","useRouterState","React","PayloadAdminShell","children","htmlProps","serverTheme","themeSource","select","state","match","matches","data","loaderData","theme","languageCode","dir","lang","html","suppressHydrationWarning","head","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","s","pathname","location","startsWith"],"mappings":"AAAA;;AAIA,SAASA,oBAAoB,QAAQ,mDAAkD;AACvF,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAkBzB;;;;;;;CAOC,GACD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,EAA0B;IACpE,MAAM,EAAEC,SAAS,EAAEC,WAAW,EAAEC,WAAW,EAAE,GAAGN,eAAe;QAC7DO,QAAQ,CAACC;YACP,KAAK,MAAMC,SAASD,MAAME,OAAO,CAAE;gBACjC,MAAMC,OAAOF,MAAMG,UAAU;gBAQ7B,IAAID,MAAME,SAASF,MAAMG,cAAc;oBACrC,OAAO;wBACLV,WAAW;4BACT,cAAcO,KAAKE,KAAK;4BACxBE,KAAKlB,eAAe;gCAAEiB,cAAcH,KAAKG,YAAY;4BAAC;4BACtDE,MAAML,KAAKG,YAAY;wBACzB;wBACAT,aAAaM,KAAKE,KAAK;wBACvBP,aAAaK,KAAKL,WAAW,IAAI;oBACnC;gBACF;YACF;YAEA,yEAAyE;YACzE,oEAAoE;YACpE,wEAAwE;YACxE,OAAO;gBACLF,WAAW;oBAAEW,KAAK;gBAAM;gBACxBV,aAAa;gBACbC,aAAa;YACf;QACF;IACF;IAEA,OACE,mHAAmH;kBACnH,MAACW;QAAM,GAAGb,SAAS;QAAEc,wBAAwB;;0BAC3C,MAACC;;oBACEb,gBAAgB,2BAAa,KAACV;wBAAqBS,aAAaA;;kCACjE,KAACe;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACtB;;;0BAEH,MAACuB;;oBACElB;kCACD,KAACJ;;;;;AAIT;AAWA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASuB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAE,GAAGD;IAElC,OAAO,SAASE,iBAAiB,EAAEvB,QAAQ,EAAiC;QAC1E,MAAMwB,eAAe3B,eAAe;YAClCO,QAAQ,CAACqB;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaJ,cAAcI,SAASE,UAAU,CAAC,GAAGN,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAACzB;0BAAmBC;;QAC7B;QAEA,qBAAO,KAACoB;sBAAWpB;;IACrB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAShE;;;;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;AAID,iBAAS,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,kBAAkB,+BAOlD;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,EAAE,UAAU;;6BAGJ;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,EAAE,UAAU;;6BAGJ;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;QAC1D,SAAS;;6BAEc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EA2BjD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useRouteTransition } from '@payloadcms/ui/providers/RouteTransition';
|
|
4
|
+
import { NotFoundClient } from '@payloadcms/ui/views/NotFound/client';
|
|
4
5
|
import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
|
|
5
6
|
import { Fragment, useDeferredValue, useEffect } from 'react';
|
|
6
7
|
import { getAdminMeta } from '../utilities/meta.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { useRouteTransition } from '@payloadcms/ui/providers/RouteTransition'\nimport { NotFoundClient } from '@payloadcms/ui/views/NotFound/client'\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\ntype AdminNotFoundData = { routeKey?: string; rscPayload?: ReactNode }\n\nfunction AdminNotFound({ data }: NotFoundRouteProps) {\n // TanStack exposes not-found data as unknown; this route only receives the shape thrown below.\n const { routeKey, rscPayload } = (data ?? {}) as AdminNotFoundData\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={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' as const,\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":["useRouteTransition","NotFoundClient","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","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;;AAIA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,yBAAwB;AAC1E,SAASC,QAAQ,EAAkBC,gBAAgB,EAAEC,SAAS,QAAQ,QAAO;AAE7E,SAASC,YAAY,QAAQ,uBAAsB;AAWnD,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAOC,MAAiBC,OAAeN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AAUC,MAAMiB,aAAaS,SAASD,SAAS9B,SAAS;gBAC3E,IAAIO,MAAMyB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMxC,SACJ6B,yBACI;wBAAEd,MAAM;4BAAEY,UAAUZ,KAAKY,QAAQ;4BAAEL,YAAYP,KAAKO,UAAU;wBAAC;oBAAE,IACjEmB;gBAER;gBACA,OAAO1B;YACT;YACA2B,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAE1B,MAAM,EAAuC,GAAM,CAAA;gBAChE2B,WAAWC,KAAKC,SAAS,CAAC7B;YAC5B,CAAA;QACA8B,gBAAgB,CAAC9B,SAAoCA;IACvD,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAAS+B,uBAAuB,EAAEnC,IAAI,EAAuB;IAClE,OAAOe,kBAAkB;QACvBC,wBAAwB;QACxBhB;QACAiB,cAAc,CAACS,SAAWA,OAAOvB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAASiC,uBAAuB,EAAEpC,IAAI,EAAuB;IAClE,OAAOe,kBAAkB;QACvBC,wBAAwB;QACxBhB;QACAiB,cAAc,IAAM;IACtB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
-
import { RootProvider } from '@payloadcms/ui';
|
|
2
|
+
import { RootProvider } from '@payloadcms/ui/providers/Root';
|
|
3
3
|
import type { LoadLayoutDataResult } from '../utilities/loadLayoutData.js';
|
|
4
4
|
/**
|
|
5
5
|
* Loader supplied by the app — a TanStack Start `createServerFn` that delegates
|
|
@@ -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,
|
|
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,+BAA+B,CAAA;AAI5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAI1E;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE5D;;;;;;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,EAAE,UAAU;;EAE/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { RootProvider } from '@payloadcms/ui/providers/Root';
|
|
4
|
+
import { ProgressBar } from '@payloadcms/ui/providers/RouteTransition/ProgressBar';
|
|
4
5
|
import { Outlet, useLoaderData } from '@tanstack/react-router';
|
|
5
6
|
import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
6
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport { RootProvider } from '@payloadcms/ui/providers/Root'\nimport { ProgressBar } from '@payloadcms/ui/providers/RouteTransition/ProgressBar'\nimport { Outlet, useLoaderData } from '@tanstack/react-router'\n\nimport type { LoadLayoutDataResult } from '../utilities/loadLayoutData.js'\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<LoadLayoutDataResult>\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' as const },\n }\n}\n"],"names":["RootProvider","ProgressBar","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,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,WAAW,QAAQ,uDAAsD;AAClF,SAASC,MAAM,EAAEC,aAAa,QAAQ,yBAAwB;AAI9D,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,MAACV;oBACCW,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,KAACtB;wBAIAQ,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;QAAoB;IACxE;AACF"}
|
|
@@ -4,7 +4,7 @@ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
|
4
4
|
* Subscribes the Payload instance to the config-changed event that the
|
|
5
5
|
* `payload:dev-config-reload` Vite plugin broadcasts.
|
|
6
6
|
*
|
|
7
|
-
* Imported for its side effect by `
|
|
7
|
+
* Imported for its side effect by `initAdminContext.server.ts`, the adapter's only
|
|
8
8
|
* `getPayload` call site, so the strategy is registered before an instance can
|
|
9
9
|
* be built. Registration is module-scoped on both ends: this runs inside the
|
|
10
10
|
* app's server graph and so resolves the same copy of `payload` that
|
|
@@ -19,20 +19,45 @@ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
|
19
19
|
* production build.
|
|
20
20
|
*/ const hot = import.meta.hot;
|
|
21
21
|
if (hot) {
|
|
22
|
+
registerDevReloadStrategy(createConfigChangedStrategy({
|
|
23
|
+
hot
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds a dev reload strategy that forwards the config-changed event to every
|
|
28
|
+
* connected instance.
|
|
29
|
+
*
|
|
30
|
+
* After a program reload, the first request to re-import this module replaces
|
|
31
|
+
* the old listener with a new one, but the cached Payload instance only connects
|
|
32
|
+
* to it on its next `getPayload` call - and a request such as a frontend page
|
|
33
|
+
* render may never make one. An event that lands in that gap has no one to
|
|
34
|
+
* notify, so it is held and replayed to the next connection instead of being
|
|
35
|
+
* dropped - which would otherwise leave the instance serving the old config
|
|
36
|
+
* indefinitely.
|
|
37
|
+
*/ function createConfigChangedStrategy({ hot }) {
|
|
22
38
|
const listeners = new Set();
|
|
39
|
+
let hasPendingReload = false;
|
|
23
40
|
hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
|
|
41
|
+
if (listeners.size === 0) {
|
|
42
|
+
hasPendingReload = true;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
24
45
|
for (const onReload of listeners){
|
|
25
46
|
onReload();
|
|
26
47
|
}
|
|
27
48
|
});
|
|
28
|
-
|
|
49
|
+
return {
|
|
29
50
|
connect: (onReload)=>{
|
|
30
51
|
listeners.add(onReload);
|
|
52
|
+
if (hasPendingReload) {
|
|
53
|
+
hasPendingReload = false;
|
|
54
|
+
onReload();
|
|
55
|
+
}
|
|
31
56
|
return ()=>{
|
|
32
57
|
listeners.delete(onReload);
|
|
33
58
|
};
|
|
34
59
|
}
|
|
35
|
-
}
|
|
60
|
+
};
|
|
36
61
|
}
|
|
37
62
|
|
|
38
63
|
//# sourceMappingURL=devConfigReload.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported for its side effect by `initAdminContext.server.ts`, the adapter's only\n * `getPayload` call site, so the strategy is registered before an instance can\n * be built. Registration is module-scoped on both ends: this runs inside the\n * app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n registerDevReloadStrategy(createConfigChangedStrategy({ hot }))\n}\n\n/**\n * Builds a dev reload strategy that forwards the config-changed event to every\n * connected instance.\n *\n * After a program reload, the first request to re-import this module replaces\n * the old listener with a new one, but the cached Payload instance only connects\n * to it on its next `getPayload` call - and a request such as a frontend page\n * render may never make one. An event that lands in that gap has no one to\n * notify, so it is held and replayed to the next connection instead of being\n * dropped - which would otherwise leave the instance serving the old config\n * indefinitely.\n */\nfunction createConfigChangedStrategy({ hot }: { hot: ViteHotContext }): {\n connect: (onReload: () => void) => () => void\n} {\n const listeners = new Set<() => void>()\n let hasPendingReload = false\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n if (listeners.size === 0) {\n hasPendingReload = true\n return\n }\n\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n return {\n connect: (onReload) => {\n listeners.add(onReload)\n\n if (hasPendingReload) {\n hasPendingReload = false\n onReload()\n }\n\n return () => {\n listeners.delete(onReload)\n }\n },\n }\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","createConfigChangedStrategy","listeners","Set","hasPendingReload","on","size","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;;;CAiBC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACPF,0BAA0BG,4BAA4B;QAAED;IAAI;AAC9D;AAEA;;;;;;;;;;;CAWC,GACD,SAASC,4BAA4B,EAAED,GAAG,EAA2B;IAGnE,MAAME,YAAY,IAAIC;IACtB,IAAIC,mBAAmB;IAEvBJ,IAAIK,EAAE,CAACN,8BAA8B;QACnC,IAAIG,UAAUI,IAAI,KAAK,GAAG;YACxBF,mBAAmB;YACnB;QACF;QAEA,KAAK,MAAMG,YAAYL,UAAW;YAChCK;QACF;IACF;IAEA,OAAO;QACLC,SAAS,CAACD;YACRL,UAAUO,GAAG,CAACF;YAEd,IAAIH,kBAAkB;gBACpBA,mBAAmB;gBACnBG;YACF;YAEA,OAAO;gBACLL,UAAUQ,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
|
|
|
2
2
|
import type { SanitizedConfig } from 'payload';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the client `I18n` for the current TanStack Start request without a
|
|
5
|
-
* full `
|
|
5
|
+
* full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
|
|
6
6
|
* `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
|
|
7
7
|
* needs `config` + `i18n` to translate admin-page titles.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,7 @@ import { getRequest } from '@tanstack/react-start/server';
|
|
|
3
3
|
import { getRequestLanguage, parseCookies } from 'payload';
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the client `I18n` for the current TanStack Start request without a
|
|
6
|
-
* full `
|
|
6
|
+
* full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's
|
|
7
7
|
* `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only
|
|
8
8
|
* needs `config` + `i18n` to translate admin-page titles.
|
|
9
9
|
*/ export async function getRequestI18n({ config }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getRequestI18n.server.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { getRequest } from '@tanstack/react-start/server'\nimport { getRequestLanguage, parseCookies } from 'payload'\n\n/**\n * Resolves the client `I18n` for the current TanStack Start request without a\n * full `initAdminContext` (no `getPayload`/auth/access). Mirrors the Next.js adapter's\n * `getNextRequestI18n` and feeds the shared `generatePageMetadata`, which only\n * needs `config` + `i18n` to translate admin-page titles.\n */\nexport async function getRequestI18n({ config }: { config: SanitizedConfig }): Promise<I18nClient> {\n const webRequest = getRequest()\n const headers = new Headers(webRequest.headers)\n const cookies = parseCookies(headers)\n\n const languageCode = getRequestLanguage({ config, cookies, headers })\n\n return initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n}\n"],"names":["initI18n","getRequest","getRequestLanguage","parseCookies","getRequestI18n","config","webRequest","headers","Headers","cookies","languageCode","i18n","context","language"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,UAAS;AAE1D;;;;;CAKC,GACD,OAAO,eAAeC,eAAe,EAAEC,MAAM,EAA+B;IAC1E,MAAMC,aAAaL;IACnB,MAAMM,UAAU,IAAIC,QAAQF,WAAWC,OAAO;IAC9C,MAAME,UAAUN,aAAaI;IAE7B,MAAMG,eAAeR,mBAAmB;QAAEG;QAAQI;QAASF;IAAQ;IAEnE,OAAOP,SAAS;QACdK,QAAQA,OAAOM,IAAI;QACnBC,SAAS;QACTC,UAAUH;IACZ;AACF"}
|