@payloadcms/tanstack-start 4.0.0-beta.2 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/handleServerFunctions.d.ts +2 -1
- package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
- package/dist/adapters/handleServerFunctions.js +12 -4
- package/dist/adapters/handleServerFunctions.js.map +1 -1
- package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
- package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
- package/dist/adapters/layout/RootProviders/index.js +21 -0
- package/dist/adapters/layout/RootProviders/index.js.map +1 -0
- package/dist/adapters/layout/index.d.ts +7 -4
- package/dist/adapters/layout/index.d.ts.map +1 -1
- package/dist/adapters/layout/index.js +3 -1
- package/dist/adapters/layout/index.js.map +1 -1
- package/dist/adapters/layout/lazy.d.ts +1 -5
- package/dist/adapters/layout/lazy.d.ts.map +1 -1
- package/dist/adapters/layout/lazy.js +9 -15
- package/dist/adapters/layout/lazy.js.map +1 -1
- package/dist/adapters/layout/outlet.d.ts +4 -0
- package/dist/adapters/layout/outlet.d.ts.map +1 -0
- package/dist/adapters/layout/outlet.js +9 -0
- package/dist/adapters/layout/outlet.js.map +1 -0
- package/dist/adapters/layout/server.d.ts +7 -13
- package/dist/adapters/layout/server.d.ts.map +1 -1
- package/dist/adapters/layout/server.js +18 -16
- package/dist/adapters/layout/server.js.map +1 -1
- package/dist/adapters/router.d.ts.map +1 -1
- package/dist/adapters/router.js +17 -13
- package/dist/adapters/router.js.map +1 -1
- package/dist/adapters/views/index.d.ts +5 -2
- package/dist/adapters/views/index.d.ts.map +1 -1
- package/dist/adapters/views/index.js +29 -8
- package/dist/adapters/views/index.js.map +1 -1
- package/dist/adapters/views/lazy.d.ts.map +1 -1
- package/dist/adapters/views/lazy.js +5 -4
- package/dist/adapters/views/lazy.js.map +1 -1
- package/dist/adapters/views/server.d.ts +5 -2
- package/dist/adapters/views/server.d.ts.map +1 -1
- package/dist/adapters/views/server.js +12 -3
- package/dist/adapters/views/server.js.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/exports/client/layout.d.ts +2 -0
- package/dist/exports/client/layout.d.ts.map +1 -0
- package/dist/exports/client/layout.js +4 -0
- package/dist/exports/client/layout.js.map +1 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/routes.d.ts +2 -0
- package/dist/exports/routes.d.ts.map +1 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/routes.js.map +1 -0
- package/dist/exports/server.d.ts +0 -3
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +0 -3
- package/dist/exports/server.js.map +1 -1
- package/dist/routes/rest/handler.server.d.ts +1 -0
- package/dist/routes/rest/handler.server.d.ts.map +1 -1
- package/dist/routes/rest/handler.server.js +1 -0
- package/dist/routes/rest/handler.server.js.map +1 -1
- package/dist/routes/rest/index.d.ts +4 -3
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +4 -3
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/utilities/devConfigReload.server.js +2 -4
- package/dist/utilities/devConfigReload.server.js.map +1 -1
- package/dist/utilities/serverFunctionClient.d.ts +2 -23
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +12 -106
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +6 -16
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +18 -26
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/importProtection.js +1 -1
- package/dist/withPayload/importProtection.js.map +1 -1
- package/dist/withPayload/index.d.ts +3 -1
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +14 -6
- package/dist/withPayload/index.js.map +1 -1
- package/package.json +25 -22
- package/dist/utilities/serializeForRsc.d.ts +0 -26
- package/dist/utilities/serializeForRsc.d.ts.map +0 -1
- package/dist/utilities/serializeForRsc.js +0 -127
- package/dist/utilities/serializeForRsc.js.map +0 -1
- package/dist/utilities/toSerializable.d.ts +0 -11
- package/dist/utilities/toSerializable.d.ts.map +0 -1
- package/dist/utilities/toSerializable.js +0 -127
- package/dist/utilities/toSerializable.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/views/index.tsx"],"sourcesContent":["'use client'\n\nimport { lazyRouteComponent, notFound, redirect } from '@tanstack/react-router'\n\nimport { getAdminMeta } from '../metadata.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))
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/views/index.tsx"],"sourcesContent":["'use client'\n\nimport { lazyRouteComponent, notFound, redirect } from '@tanstack/react-router'\n\nimport { getAdminMeta } from '../metadata.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 signal?: AbortSignal\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr))\n\nconst runLoader = async ({\n load,\n searchStr,\n signal,\n splat,\n}: {\n load: AdminLoad\n searchStr: string\n signal: AbortSignal\n splat: string\n}) => {\n const loadController = new AbortController()\n const abortLoad = () => loadController.abort(signal.reason)\n\n signal.addEventListener('abort', abortLoad, { once: true })\n\n if (signal.aborted) {\n abortLoad()\n }\n\n let data: Awaited<ReturnType<AdminLoad>>\n\n try {\n data = await load({\n data: { _splat: splat, search: searchToRecord(searchStr) },\n signal: loadController.signal,\n })\n } finally {\n // The returned RSC payload can still be streaming after the loader resolves.\n // Later navigations must not abort a payload that React is already rendering.\n signal.removeEventListener('abort', abortLoad)\n }\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\n// The admin UI loads with the admin routes only, so front-end routes never download it. The\n// router preloads lazy route components before rendering, so admin pages don't flash.\nconst AdminPage = lazyRouteComponent(() => import('./lazy.js'), 'AdminPage')\nconst AdminNotFound = lazyRouteComponent(() => import('./lazy.js'), 'AdminNotFound')\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 ({\n abortController,\n location,\n params,\n }: {\n abortController: AbortController\n location: any\n params: any\n }) => {\n const data = await runLoader({\n load,\n searchStr: location.searchStr,\n signal: abortController.signal,\n splat: resolveSplat(params),\n })\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":["lazyRouteComponent","notFound","redirect","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","signal","splat","loadController","AbortController","abortLoad","abort","reason","addEventListener","once","aborted","data","_splat","search","removeEventListener","_redirect","to","AdminPage","AdminNotFound","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","notFoundComponent","loader","handler","abortController","location","params","_notFound","routeKey","rscPayload","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","payloadAdminIndexRoute"],"mappings":"AAAA;AAEA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,yBAAwB;AAE/E,SAASC,YAAY,QAAQ,iBAAgB;AAY7C,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAO,EACvBC,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;gBACtB;gBACA,IAAIpB,MAAMqB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMzC,SACJ6B,yBACI;wBAAET,MAAM;4BAAEsB,UAAUtB,KAAKsB,QAAQ;4BAAEC,YAAYvB,KAAKuB,UAAU;wBAAC;oBAAE,IACjEC;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,EAAE1C,IAAI,EAAuB;IAClE,OAAOmB,kBAAkB;QACvBC,wBAAwB;QACxBpB;QACAqB,cAAc,CAACU,SAAWA,OAAOnB,MAAM,IAAI;IAC7C;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS+B,uBAAuB,EAAE3C,IAAI,EAAuB;IAClE,OAAOmB,kBAAkB;QACvBC,wBAAwB;QACxBpB;QACAqB,cAAc,IAAM;IACtB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/adapters/views/lazy.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAMhE,wBAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/adapters/views/lazy.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAMhE,wBAAgB,SAAS,gCAwBxB;AAID,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,kBAAkB,+BAOzD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { NotFoundClient, useRouteTransition } from '@payloadcms/ui';
|
|
4
4
|
import { useLoaderData } from '@tanstack/react-router';
|
|
5
|
-
import { Fragment, useDeferredValue,
|
|
5
|
+
import { Fragment, useDeferredValue, useLayoutEffect } from 'react';
|
|
6
6
|
export function AdminPage() {
|
|
7
7
|
// Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.
|
|
8
8
|
// The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.
|
|
@@ -15,7 +15,8 @@ export function AdminPage() {
|
|
|
15
15
|
const rscPayload = useDeferredValue(data?.rscPayload);
|
|
16
16
|
const { holdRouteTransition } = useRouteTransition();
|
|
17
17
|
const isRscPayloadDeferred = rscPayload !== data?.rscPayload;
|
|
18
|
-
|
|
18
|
+
// Register before the router acknowledges this commit so navigation can await the deferred view.
|
|
19
|
+
useLayoutEffect(()=>{
|
|
19
20
|
if (!isRscPayloadDeferred) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
@@ -26,7 +27,7 @@ export function AdminPage() {
|
|
|
26
27
|
isRscPayloadDeferred
|
|
27
28
|
]);
|
|
28
29
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
29
|
-
children: rscPayload
|
|
30
|
+
children: rscPayload?.page
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
export function AdminNotFound({ data }) {
|
|
@@ -36,7 +37,7 @@ export function AdminNotFound({ data }) {
|
|
|
36
37
|
return /*#__PURE__*/ _jsx(NotFoundClient, {});
|
|
37
38
|
}
|
|
38
39
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
39
|
-
children: rscPayload
|
|
40
|
+
children: rscPayload.page
|
|
40
41
|
}, routeKey);
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/views/lazy.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { useLoaderData } from '@tanstack/react-router'\nimport { Fragment,
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/views/lazy.tsx"],"sourcesContent":["'use client'\n\nimport type { NotFoundRouteProps } from '@tanstack/react-router'\n\nimport { NotFoundClient, useRouteTransition } from '@payloadcms/ui'\nimport { useLoaderData } from '@tanstack/react-router'\nimport { Fragment, useDeferredValue, useLayoutEffect } from 'react'\n\nexport function 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 // Register before the router acknowledges this commit so navigation can await the deferred view.\n useLayoutEffect(() => {\n if (!isRscPayloadDeferred) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRscPayloadDeferred])\n\n return <Fragment>{rscPayload?.page}</Fragment>\n}\n\ntype AdminNotFoundData = { routeKey?: string; rscPayload?: { page: React.ReactNode } }\n\nexport function 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.page}</Fragment>\n}\n"],"names":["NotFoundClient","useRouteTransition","useLoaderData","Fragment","useDeferredValue","useLayoutEffect","AdminPage","data","strict","rscPayload","holdRouteTransition","isRscPayloadDeferred","releaseRouteTransition","page","AdminNotFound","routeKey"],"mappings":"AAAA;;AAIA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,iBAAgB;AACnE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,QAAQ,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,QAAO;AAEnE,OAAO,SAASC;IACd,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAMC,OAAOL,cAAc;QAAEM,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAaL,iBAAiBG,MAAME;IAC1C,MAAM,EAAEC,mBAAmB,EAAE,GAAGT;IAChC,MAAMU,uBAAuBF,eAAeF,MAAME;IAElD,iGAAiG;IACjGJ,gBAAgB;QACd,IAAI,CAACM,sBAAsB;YACzB;QACF;QAEA,MAAMC,yBAAyBF;QAE/B,OAAO,IAAME;IACf,GAAG;QAACF;QAAqBC;KAAqB;IAE9C,qBAAO,KAACR;kBAAUM,YAAYI;;AAChC;AAIA,OAAO,SAASC,cAAc,EAAEP,IAAI,EAAsB;IACxD,+FAA+F;IAC/F,MAAM,EAAEQ,QAAQ,EAAEN,UAAU,EAAE,GAAIF,QAAQ,CAAC;IAC3C,IAAI,CAACE,YAAY;QACf,qBAAO,KAACT;IACV;IACA,qBAAO,KAACG;kBAAyBM,WAAWI,IAAI;OAA1BE;AACxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RenderableServerComponentBuilder } from '@tanstack/react-start/rsc';
|
|
2
2
|
import type { ImportMap, SanitizedConfig } from 'payload';
|
|
3
3
|
import type { AdminPageMetadata } from '../metadata.js';
|
|
4
4
|
export type LoadAdminPageArgs = {
|
|
@@ -7,7 +7,10 @@ export type LoadAdminPageArgs = {
|
|
|
7
7
|
search?: Record<string, string | string[]>;
|
|
8
8
|
splat?: string;
|
|
9
9
|
};
|
|
10
|
-
type RSCPayload =
|
|
10
|
+
type RSCPayload = RenderableServerComponentBuilder<{
|
|
11
|
+
page: React.ReactElement;
|
|
12
|
+
routeKey: string;
|
|
13
|
+
}>;
|
|
11
14
|
export type LoadAdminPageResult = {
|
|
12
15
|
_notFound: true;
|
|
13
16
|
routeKey?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/views/server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/views/server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAOvD,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,KAAK,UAAU,GAAG,gCAAgC,CAAC;IACjD,IAAI,EAAE,KAAK,CAAC,YAAY,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAAE,GAC/D;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyJlD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getViewportContent } from '@payloadcms/ui/shared';
|
|
2
2
|
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
3
|
+
import { getRequest } from '@tanstack/react-start/server';
|
|
3
4
|
import { getRequestI18n } from '../../utilities/getRequestI18n.server.js';
|
|
4
5
|
import { initAdminContext } from '../../utilities/initAdminContext.server.js';
|
|
5
6
|
import { toAdminPageMetadata } from '../metadata.js';
|
|
@@ -81,7 +82,10 @@ import { createPageRenderServerAdapter } from '../server.js';
|
|
|
81
82
|
}),
|
|
82
83
|
searchParams: Promise.resolve(searchParams)
|
|
83
84
|
});
|
|
84
|
-
const rscPayload = await renderServerComponent(
|
|
85
|
+
const rscPayload = await renderServerComponent({
|
|
86
|
+
page: notFoundNode,
|
|
87
|
+
routeKey: splat ?? ''
|
|
88
|
+
});
|
|
85
89
|
return {
|
|
86
90
|
_notFound: true,
|
|
87
91
|
routeKey: splat ?? '',
|
|
@@ -104,7 +108,10 @@ import { createPageRenderServerAdapter } from '../server.js';
|
|
|
104
108
|
redirect: pageServerAdapter.redirect,
|
|
105
109
|
searchParams: Promise.resolve(searchParams)
|
|
106
110
|
});
|
|
107
|
-
const rscPayload = await renderServerComponent(
|
|
111
|
+
const rscPayload = await renderServerComponent({
|
|
112
|
+
page: node,
|
|
113
|
+
routeKey: splat ?? ''
|
|
114
|
+
});
|
|
108
115
|
// The server-function (client-nav RPC) path returns the flight stream unread —
|
|
109
116
|
// unlike the router/SSR path, which awaits a decode that drives the render to
|
|
110
117
|
// completion. So streamed side effects (e.g. DocumentView's autosave-create
|
|
@@ -114,7 +121,9 @@ import { createPageRenderServerAdapter } from '../server.js';
|
|
|
114
121
|
if (!nav.type) {
|
|
115
122
|
const wrapper = rscPayload[Symbol.for('tanstack.rsc.stream')];
|
|
116
123
|
if (typeof wrapper?.createReplayStream === 'function') {
|
|
117
|
-
const buffer = await new Response(wrapper.createReplayStream()
|
|
124
|
+
const buffer = await new Response(wrapper.createReplayStream().pipeThrough(new TransformStream(), {
|
|
125
|
+
signal: getRequest().signal
|
|
126
|
+
})).arrayBuffer();
|
|
118
127
|
wrapper.createReplayStream = ()=>new Response(buffer).body;
|
|
119
128
|
}
|
|
120
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/views/server.tsx"],"sourcesContent":["import type { RenderableServerComponent } from '@tanstack/react-start/rsc'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from '../metadata.js'\n\nimport { getRequestI18n } from '../../utilities/getRequestI18n.server.js'\nimport { initAdminContext } from '../../utilities/initAdminContext.server.js'\nimport { toAdminPageMetadata } from '../metadata.js'\nimport { createPageRenderServerAdapter } from '../server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\ntype RSCPayload = RenderableServerComponent<React.ReactElement>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RSCPayload }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: RSCPayload\n }\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initAdminContext` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitAdminContext: Parameters<typeof renderRoot>[0]['initAdminContext'] = async (\n args,\n ) => {\n const result = await initAdminContext({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.req.headers.get('user-agent') ?? undefined\n return result\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initAdminContext,\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initAdminContext: boundInitAdminContext,\n key: splat ?? '',\n notFound: pageServerAdapter.notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect: pageServerAdapter.redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequestI18n","initAdminContext","toAdminPageMetadata","createPageRenderServerAdapter","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","filter","Boolean","segments","length","undefined","searchParams","nav","pageServerAdapter","userAgent","boundInitAdminContext","args","result","configPromise","overrides","serverAdapter","req","headers","get","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","key","notFound","redirect","type","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","url","_redirect","i18n","meta","metadata","viewport","err","message","Error","String","startsWith","slice"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,2CAA0C;AACzE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,6BAA6B,QAAQ,eAAc;AA+B5D;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,eAAeC,cAAc,EAClCC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,KAAK,EACa;IAClB,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;IACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC3C,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;IAE9C,MAAMC,gBAAgBJ,QAAQA,MAAMK,KAAK,CAAC,KAAKC,MAAM,CAACC,WAAW,EAAE;IACnE,6EAA6E;IAC7E,uEAAuE;IACvE,uEAAuE;IACvE,8EAA8E;IAC9E,6EAA6E;IAC7E,4CAA4C;IAC5C,MAAMC,WAAWJ,cAAcK,MAAM,GAAG,IAAIL,gBAAgBM;IAC5D,MAAMC,eAAeZ,UAAU,CAAC;IAEhC,8EAA8E;IAC9E,wEAAwE;IACxE,MAAMa,MAAwD,CAAC;IAC/D,MAAMC,oBAAoBlB,8B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AC,cAAc;YAC9D,OAAO;gBAAET,WAAWpC,IAAImC,GAAG,IAAIO,QAAQI,KAAK,CAAC,YAAYjD,MAAM;YAAE;QACnE;QACA,MAAM4C;IACR;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/views/server.tsx"],"sourcesContent":["import type { RenderableServerComponentBuilder } from '@tanstack/react-start/rsc'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { getRequest } from '@tanstack/react-start/server'\n\nimport type { AdminPageMetadata } from '../metadata.js'\n\nimport { getRequestI18n } from '../../utilities/getRequestI18n.server.js'\nimport { initAdminContext } from '../../utilities/initAdminContext.server.js'\nimport { toAdminPageMetadata } from '../metadata.js'\nimport { createPageRenderServerAdapter } from '../server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\ntype RSCPayload = RenderableServerComponentBuilder<{\n page: React.ReactElement\n routeKey: string\n}>\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: RSCPayload }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: RSCPayload\n }\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Gets the Payload admin context via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initAdminContext`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n let userAgent: string | undefined\n\n // `renderRoot` calls `initAdminContext` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitAdminContext: Parameters<typeof renderRoot>[0]['initAdminContext'] = async (\n args,\n ) => {\n const result = await initAdminContext({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.req.headers.get('user-agent') ?? undefined\n return result\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initAdminContext,\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent({\n page: notFoundNode as React.ReactElement,\n routeKey: splat ?? '',\n })\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initAdminContext: boundInitAdminContext,\n key: splat ?? '',\n notFound: pageServerAdapter.notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect: pageServerAdapter.redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent({\n page: node as React.ReactElement,\n routeKey: splat ?? '',\n })\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(\n wrapper.createReplayStream().pipeThrough(new TransformStream(), {\n signal: getRequest().signal,\n }),\n ).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["getViewportContent","renderServerComponent","getRequest","getRequestI18n","initAdminContext","toAdminPageMetadata","createPageRenderServerAdapter","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","filter","Boolean","segments","length","undefined","searchParams","nav","pageServerAdapter","userAgent","boundInitAdminContext","args","result","configPromise","overrides","serverAdapter","req","headers","get","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","page","routeKey","_notFound","node","adminViews","key","notFound","redirect","type","wrapper","Symbol","for","createReplayStream","buffer","Response","pipeThrough","TransformStream","signal","arrayBuffer","body","url","_redirect","i18n","meta","metadata","viewport","err","message","Error","String","startsWith","slice"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,UAAU,QAAQ,+BAA8B;AAIzD,SAASC,cAAc,QAAQ,2CAA0C;AACzE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,6BAA6B,QAAQ,eAAc;AAkC5D;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,eAAeC,cAAc,EAClCC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,KAAK,EACa;IAClB,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;IACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;IAC3C,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;IAE9C,MAAMC,gBAAgBJ,QAAQA,MAAMK,KAAK,CAAC,KAAKC,MAAM,CAACC,WAAW,EAAE;IACnE,6EAA6E;IAC7E,uEAAuE;IACvE,uEAAuE;IACvE,8EAA8E;IAC9E,6EAA6E;IAC7E,4CAA4C;IAC5C,MAAMC,WAAWJ,cAAcK,MAAM,GAAG,IAAIL,gBAAgBM;IAC5D,MAAMC,eAAeZ,UAAU,CAAC;IAEhC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ACF;IACF,EAAE,OAAO2B,KAAK;QACZ,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAGE,OAAOH;QAC5D,IAAI7C,IAAI2B,IAAI,KAAK,cAAcmB,YAAY,aAAa;YACtD,OAAO,MAAMlC;QACf;QACA,IAAIZ,IAAI2B,IAAI,KAAK,cAAcmB,QAAQG,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAET,WAAWxC,IAAIuC,GAAG,IAAIO,QAAQI,KAAK,CAAC,YAAYrD,MAAM;YAAE;QACnE;QACA,MAAMgD;IACR;AACF"}
|
package/dist/auth/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/login.ts"],"sourcesContent":["import type { AuthCollectionSlug, LoginResult } from 'payload'\n\nimport { type LoginArgs, type LoginArgsWithoutServerAdapter, login as loginFn } from 'payload/auth'\n\nimport { tanstackServerAdapter } from '../adapters/server.js'\n\nexport async function login<TSlug extends AuthCollectionSlug>(\n args: LoginArgsWithoutServerAdapter<TSlug>,\n): Promise<LoginResult<TSlug>> {\n return loginFn({ ...args, serverAdapter: tanstackServerAdapter }
|
|
1
|
+
{"version":3,"sources":["../../src/auth/login.ts"],"sourcesContent":["import type { AuthCollectionSlug, LoginResult } from 'payload'\n\nimport { type LoginArgs, type LoginArgsWithoutServerAdapter, login as loginFn } from 'payload/auth'\n\nimport { tanstackServerAdapter } from '../adapters/server.js'\n\nexport async function login<TSlug extends AuthCollectionSlug>(\n args: LoginArgsWithoutServerAdapter<TSlug>,\n): Promise<LoginResult<TSlug>> {\n return loginFn({ ...args, serverAdapter: tanstackServerAdapter })\n}\n"],"names":["login","loginFn","tanstackServerAdapter","args","serverAdapter"],"mappings":"AAEA,SAA6DA,SAASC,OAAO,QAAQ,eAAc;AAEnG,SAASC,qBAAqB,QAAQ,wBAAuB;AAE7D,OAAO,eAAeF,MACpBG,IAA0C;IAE1C,OAAOF,QAAQ;QAAE,GAAGE,IAAI;QAAEC,eAAeF;IAAsB;AACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/exports/client/layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exports/client/layout.ts"],"sourcesContent":["'use client'\n\nexport { PayloadRootProviders } from '../../adapters/layout/RootProviders/index.js'\n"],"names":["PayloadRootProviders"],"mappings":"AAAA;AAEA,SAASA,oBAAoB,QAAQ,+CAA8C"}
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { type LayoutLoad, PayloadAdminShell, type PayloadAdminShellProps, payloadLayoutRoute, withPayloadRoot, type WithPayloadRootOptions, } from '../adapters/layout/index.js';
|
|
2
2
|
export { type AdminLoad, payloadAdminIndexRoute, payloadAdminSplatRoute, } from '../adapters/views/index.js';
|
|
3
|
-
export { createServerFunctionClient
|
|
3
|
+
export { createServerFunctionClient } from '../utilities/serverFunctionClient.js';
|
|
4
4
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAA"}
|
package/dist/exports/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
export { PayloadAdminShell, payloadLayoutRoute, withPayloadRoot } from '../adapters/layout/index.js';
|
|
3
3
|
export { payloadAdminIndexRoute, payloadAdminSplatRoute } from '../adapters/views/index.js';
|
|
4
|
-
export { createServerFunctionClient
|
|
4
|
+
export { createServerFunctionClient } from '../utilities/serverFunctionClient.js';
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport {\n type LayoutLoad,\n PayloadAdminShell,\n type PayloadAdminShellProps,\n payloadLayoutRoute,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../adapters/layout/index.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../adapters/views/index.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport {\n type LayoutLoad,\n PayloadAdminShell,\n type PayloadAdminShellProps,\n payloadLayoutRoute,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../adapters/layout/index.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../adapters/views/index.js'\nexport { createServerFunctionClient } from '../utilities/serverFunctionClient.js'\n"],"names":["PayloadAdminShell","payloadLayoutRoute","withPayloadRoot","payloadAdminIndexRoute","payloadAdminSplatRoute","createServerFunctionClient"],"mappings":"AAAA;AAEA,SAEEA,iBAAiB,EAEjBC,kBAAkB,EAClBC,eAAe,QAEV,8BAA6B;AACpC,SAEEC,sBAAsB,EACtBC,sBAAsB,QACjB,6BAA4B;AACnC,SAASC,0BAA0B,QAAQ,uCAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/exports/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/routes.ts"],"sourcesContent":["export { payloadApiHandlers } from '../routes/rest/index.js'\n"],"names":["payloadApiHandlers"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,0BAAyB"}
|
package/dist/exports/server.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export { logout } from '../auth/logout.js';
|
|
|
7
7
|
export { refresh } from '../auth/refresh.js';
|
|
8
8
|
export { handleGraphQL } from '../routes/graphql/handler.server.js';
|
|
9
9
|
export { handleAPIRoute } from '../routes/rest/handler.server.js';
|
|
10
|
-
export { payloadApiHandlers } from '../routes/rest/index.js';
|
|
11
10
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
12
|
-
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
13
|
-
export { type SerializableRecord, toSerializable } from '../utilities/toSerializable.js';
|
|
14
11
|
export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
15
12
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EACL,6BAA6B,EAC7B,KAAK,aAAa,EAClB,qBAAqB,GACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAA;AACpC,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,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EACL,6BAA6B,EAC7B,KAAK,aAAa,EAClB,qBAAqB,GACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAA;AACpC,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,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}
|
package/dist/exports/server.js
CHANGED
|
@@ -7,10 +7,7 @@ export { logout } from '../auth/logout.js';
|
|
|
7
7
|
export { refresh } from '../auth/refresh.js';
|
|
8
8
|
export { handleGraphQL } from '../routes/graphql/handler.server.js';
|
|
9
9
|
export { handleAPIRoute } from '../routes/rest/handler.server.js';
|
|
10
|
-
export { payloadApiHandlers } from '../routes/rest/index.js';
|
|
11
10
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
12
|
-
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
13
|
-
export { toSerializable } from '../utilities/toSerializable.js';
|
|
14
11
|
export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
15
12
|
|
|
16
13
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { handleServerFunctions } from '../adapters/handleServerFunctions.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../adapters/metadata.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../adapters/server.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../adapters/views/server.js'\nexport { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { handleGraphQL } from '../routes/graphql/handler.server.js'\nexport { handleAPIRoute } from '../routes/rest/handler.server.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { handleServerFunctions } from '../adapters/handleServerFunctions.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../adapters/metadata.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../adapters/server.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../adapters/views/server.js'\nexport { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { handleGraphQL } from '../routes/graphql/handler.server.js'\nexport { handleAPIRoute } from '../routes/rest/handler.server.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\n"],"names":["handleServerFunctions","getAdminMeta","createPageRenderServerAdapter","tanstackServerAdapter","loadAdminPage","login","logout","refresh","handleGraphQL","handleAPIRoute","getRequestI18n","getRequestTheme"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,uCAAsC;AAC5E,SAAiCC,YAAY,QAAQ,0BAAyB;AAC9E,SACEC,6BAA6B,EAE7BC,qBAAqB,QAChB,wBAAuB;AAC9B,SACEC,aAAa,QAGR,8BAA6B;AACpC,SAASC,KAAK,QAAQ,mBAAkB;AACxC,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,OAAO,QAAQ,qBAAoB;AAC5C,SAASC,aAAa,QAAQ,sCAAqC;AACnE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,eAAe,QAAQ,2CAA0C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
import '../../utilities/devConfigReload.server.js';
|
|
2
3
|
/**
|
|
3
4
|
* Routes a TanStack Start API request to Payload's endpoint handler. The framework adapter
|
|
4
5
|
* wires this into the app's API route and supplies the resolved `config`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.server.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/handler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;GAGG;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,CAMpB"}
|
|
1
|
+
{"version":3,"file":"handler.server.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/handler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,2CAA2C,CAAA;AAElD;;;GAGG;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,CAMpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/handler.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request to Payload's endpoint handler. The framework adapter\n * wires this into the app's API route and supplies the resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n return handleEndpoints({\n config,\n path: new URL(request.url).pathname,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","path","URL","url","pathname"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;CAGC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,OAAOH,gBAAgB;QACrBE;QACAE,MAAM,IAAIC,IAAIF,QAAQG,GAAG,EAAEC,QAAQ;QACnCJ;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/handler.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\nimport '../../utilities/devConfigReload.server.js'\n\n/**\n * Routes a TanStack Start API request to Payload's endpoint handler. The framework adapter\n * wires this into the app's API route and supplies the resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n return handleEndpoints({\n config,\n path: new URL(request.url).pathname,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","path","URL","url","pathname"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC,OAAO,4CAA2C;AAElD;;;CAGC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,OAAOH,gBAAgB;QACrBE;QACAE,MAAM,IAAIC,IAAIF,QAAQG,GAAG,EAAEC,QAAQ;QACnCJ;IACF;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
import '../../utilities/devConfigReload.server.js';
|
|
2
3
|
type ApiRouteHandler = (ctx: {
|
|
3
4
|
request: Request;
|
|
4
5
|
}) => Promise<Response>;
|
|
@@ -7,14 +8,14 @@ type ApiRouteHandler = (ctx: {
|
|
|
7
8
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
8
9
|
* import) since the package cannot resolve the consumer's config.
|
|
9
10
|
*
|
|
10
|
-
* Imported from `@payloadcms/tanstack-start/
|
|
11
|
-
* the
|
|
11
|
+
* Imported from `@payloadcms/tanstack-start/routes` so API routes do not load
|
|
12
|
+
* the admin rendering graph from the shared server entrypoint.
|
|
12
13
|
*
|
|
13
14
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
14
15
|
* client compiler can statically see — and prune — the server-only route:
|
|
15
16
|
*
|
|
16
17
|
* ```ts
|
|
17
|
-
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/
|
|
18
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
|
|
18
19
|
*
|
|
19
20
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
20
21
|
* server: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/index.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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,2CAA2C,CAAA;AAElD,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"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import '../../utilities/devConfigReload.server.js';
|
|
1
2
|
/**
|
|
2
3
|
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
3
4
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
5
|
* import) since the package cannot resolve the consumer's config.
|
|
5
6
|
*
|
|
6
|
-
* Imported from `@payloadcms/tanstack-start/
|
|
7
|
-
* the
|
|
7
|
+
* Imported from `@payloadcms/tanstack-start/routes` so API routes do not load
|
|
8
|
+
* the admin rendering graph from the shared server entrypoint.
|
|
8
9
|
*
|
|
9
10
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
10
11
|
* client compiler can statically see — and prune — the server-only route:
|
|
11
12
|
*
|
|
12
13
|
* ```ts
|
|
13
|
-
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/
|
|
14
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
|
|
14
15
|
*
|
|
15
16
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
16
17
|
* server: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/index.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/
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/index.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport '../../utilities/devConfigReload.server.js'\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/routes` so API routes do not load\n * the admin rendering graph from the shared server entrypoint.\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/routes'\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('./handler.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":"AAEA,OAAO,4CAA2C;AAIlD;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -4,10 +4,8 @@ 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
|
|
8
|
-
*
|
|
9
|
-
* be built. Registration is module-scoped on both ends: this runs inside the
|
|
10
|
-
* app's server graph and so resolves the same copy of `payload` that
|
|
7
|
+
* Imported by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.
|
|
8
|
+
* Registration is module-scoped on both ends: this runs inside the app's server graph and so resolves the same copy of `payload` that
|
|
11
9
|
* `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
|
|
12
10
|
* its own listener against its own copy.
|
|
13
11
|
*
|
|
@@ -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
|
|
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 by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.\n * Registration is module-scoped on both ends: this runs inside the 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;;;;;;;;;;;;;;;CAeC,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"}
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Builds the client-side `ServerFunctionClient` wired into
|
|
4
|
-
* `RootProvider.serverFunction`, given the app's `createServerFn`-based
|
|
5
|
-
* dispatcher (`runServerFn`).
|
|
6
|
-
*
|
|
7
|
-
* Strips functions / symbols / RegExps / React elements from the args before
|
|
8
|
-
* dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
|
|
9
|
-
* those, but TanStack Start's seroval-based wire format errors instead. We
|
|
10
|
-
* mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
|
|
11
|
-
* `ServerFunctionsProvider`) that may pass the live form state — which can
|
|
12
|
-
* carry stray functions — keep working without each call site sanitising.
|
|
13
|
-
*
|
|
14
|
-
* Delegates to `runServerFn`, so the response (including any RSC handles for
|
|
15
|
-
* server-rendered custom components) is decoded by TanStack Start back into
|
|
16
|
-
* renderable React nodes on the client.
|
|
17
|
-
*/
|
|
2
|
+
/** Builds the admin dispatcher with native Flight response decoding. */
|
|
18
3
|
export declare function createServerFunctionClient({ runServerFn, }: {
|
|
19
4
|
runServerFn: (input: {
|
|
20
5
|
data: ServerFunctionClientArgs;
|
|
21
|
-
}) => Promise<
|
|
6
|
+
}) => Promise<Response>;
|
|
22
7
|
}): ServerFunctionClient;
|
|
23
|
-
/**
|
|
24
|
-
* Recursively removes values TanStack Start's seroval wire format cannot
|
|
25
|
-
* serialize (functions, symbols, RegExps, React elements, cyclic refs) and
|
|
26
|
-
* normalizes `Date` subclasses to plain `Date`.
|
|
27
|
-
*/
|
|
28
|
-
export declare function stripUnserializable(value: unknown, cache?: WeakMap<object, unknown>, ancestors?: WeakSet<object>): unknown;
|
|
29
8
|
//# sourceMappingURL=serverFunctionClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE7E,wEAAwE;AACxE,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC9E,GAAG,oBAAoB,CAoBvB"}
|