@payloadcms/tanstack-start 4.0.0-internal.2fddfc0 → 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/LICENSE.md +1 -1
- package/dist/auth/login.d.ts +3 -16
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js +6 -46
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -5
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js +6 -47
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -4
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +6 -49
- package/dist/auth/refresh.js.map +1 -1
- package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
- package/dist/elements/RouterAdapter/index.js +36 -5
- package/dist/elements/RouterAdapter/index.js.map +1 -1
- package/dist/exports/client.d.ts +2 -3
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +2 -3
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +2 -4
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +0 -1
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/rsc.browser.d.ts +4 -1
- package/dist/exports/rsc.browser.d.ts.map +1 -1
- package/dist/exports/rsc.browser.js +4 -1
- package/dist/exports/rsc.browser.js.map +1 -1
- package/dist/exports/rsc.d.ts +0 -1
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +0 -1
- package/dist/exports/rsc.js.map +1 -1
- package/dist/exports/server.d.ts +4 -6
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +3 -5
- package/dist/exports/server.js.map +1 -1
- package/dist/exports/shared.d.ts +2 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +3 -0
- package/dist/exports/shared.js.map +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts +27 -2
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +14 -7
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +6 -31
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +43 -33
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
- package/dist/node/cssLoader.d.mts +24 -2
- package/dist/node/cssLoader.d.mts.map +1 -1
- package/dist/routes/adminRoutes.d.ts +20 -17
- package/dist/routes/adminRoutes.d.ts.map +1 -1
- package/dist/routes/adminRoutes.js +71 -52
- package/dist/routes/adminRoutes.js.map +1 -1
- package/dist/routes/apiRoute.d.ts +29 -28
- package/dist/routes/apiRoute.d.ts.map +1 -1
- package/dist/routes/apiRoute.js +31 -15
- package/dist/routes/apiRoute.js.map +1 -1
- package/dist/routes/layoutRoute.d.ts +7 -3
- package/dist/routes/layoutRoute.d.ts.map +1 -1
- package/dist/routes/layoutRoute.js +10 -2
- package/dist/routes/layoutRoute.js.map +1 -1
- package/dist/utilities/devConfigReload.server.d.ts +2 -0
- package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
- package/dist/utilities/devConfigReload.server.js +63 -0
- package/dist/utilities/devConfigReload.server.js.map +1 -0
- package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
- package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
- package/dist/utilities/devConfigReloadEvent.js +9 -0
- package/dist/utilities/devConfigReloadEvent.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/utilities/graphqlHandler.server.js +2 -2
- package/dist/utilities/graphqlHandler.server.js.map +1 -1
- package/dist/utilities/{handleAPIRoute.d.ts → handleAPIRoute.server.d.ts} +1 -1
- package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
- package/dist/utilities/{handleAPIRoute.js → handleAPIRoute.server.js} +1 -1
- package/dist/utilities/handleAPIRoute.server.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts +1 -19
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +6 -57
- 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 +7 -4
- package/dist/utilities/loadAdminPage.d.ts.map +1 -1
- package/dist/utilities/loadAdminPage.js +32 -22
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/loadLayoutData.d.ts +3 -1
- package/dist/utilities/loadLayoutData.d.ts.map +1 -1
- package/dist/utilities/loadLayoutData.js +2 -3
- package/dist/utilities/loadLayoutData.js.map +1 -1
- package/dist/utilities/meta.d.ts +1 -0
- package/dist/utilities/meta.d.ts.map +1 -1
- package/dist/utilities/meta.js +2 -1
- package/dist/utilities/meta.js.map +1 -1
- package/dist/utilities/routerSearch.d.ts +40 -0
- package/dist/utilities/routerSearch.d.ts.map +1 -0
- package/dist/utilities/routerSearch.js +45 -0
- package/dist/utilities/routerSearch.js.map +1 -0
- package/dist/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/serverAdapter.server.d.ts.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 +9 -0
- package/dist/utilities/toSerializable.d.ts.map +1 -1
- package/dist/utilities/toSerializable.js +19 -3
- package/dist/utilities/toSerializable.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +44 -0
- package/dist/withPayload/config/external.d.ts.map +1 -0
- package/dist/withPayload/config/external.js +96 -0
- package/dist/withPayload/config/external.js.map +1 -0
- package/dist/withPayload/config/optimizeDeps.d.ts +25 -0
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
- package/dist/{vite/constants.js → withPayload/config/optimizeDeps.js} +36 -70
- package/dist/withPayload/config/optimizeDeps.js.map +1 -0
- package/dist/withPayload/config/scss.d.ts +14 -0
- package/dist/withPayload/config/scss.d.ts.map +1 -0
- package/dist/withPayload/config/scss.js +28 -0
- package/dist/withPayload/config/scss.js.map +1 -0
- package/dist/withPayload/devConfigReload.d.ts +14 -0
- package/dist/withPayload/devConfigReload.d.ts.map +1 -0
- package/dist/withPayload/devConfigReload.js +84 -0
- package/dist/withPayload/devConfigReload.js.map +1 -0
- package/dist/withPayload/importProtection.d.ts.map +1 -0
- package/dist/{vite → withPayload}/importProtection.js +2 -2
- package/dist/withPayload/importProtection.js.map +1 -0
- package/dist/withPayload/index.d.ts +118 -0
- package/dist/withPayload/index.d.ts.map +1 -0
- package/dist/withPayload/index.js +308 -0
- package/dist/withPayload/index.js.map +1 -0
- package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
- package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
- package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
- package/dist/{vite/plugins → withPayload/workarounds}/devTransforms.js +5 -0
- package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
- package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
- package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
- package/dist/{vite/plugins → withPayload/workarounds}/stripDistStyleImports.js +37 -4
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.d.ts +13 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.js +32 -0
- package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
- package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
- package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
- package/package.json +22 -16
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
- package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeaderClient/index.js +0 -116
- package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
- package/dist/elements/RenderComponent/index.d.ts +0 -10
- package/dist/elements/RenderComponent/index.d.ts.map +0 -1
- package/dist/elements/RenderComponent/index.js +0 -12
- package/dist/elements/RenderComponent/index.js.map +0 -1
- package/dist/exports/vite.d.ts +0 -3
- package/dist/exports/vite.d.ts.map +0 -1
- package/dist/exports/vite.js +0 -3
- package/dist/exports/vite.js.map +0 -1
- package/dist/layouts/Root/index.d.ts +0 -32
- package/dist/layouts/Root/index.d.ts.map +0 -1
- package/dist/layouts/Root/index.js +0 -51
- package/dist/layouts/Root/index.js.map +0 -1
- package/dist/rsc/renderPayloadRSC.d.ts +0 -6
- package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
- package/dist/rsc/renderPayloadRSC.js +0 -6
- package/dist/rsc/renderPayloadRSC.js.map +0 -1
- package/dist/utilities/devReloadStrategy.d.ts +0 -10
- package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
- package/dist/utilities/devReloadStrategy.js +0 -27
- package/dist/utilities/devReloadStrategy.js.map +0 -1
- package/dist/utilities/getExistingAuthToken.d.ts +0 -7
- package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
- package/dist/utilities/getExistingAuthToken.js +0 -18
- package/dist/utilities/getExistingAuthToken.js.map +0 -1
- package/dist/utilities/getPreferences.d.ts +0 -10
- package/dist/utilities/getPreferences.d.ts.map +0 -1
- package/dist/utilities/getPreferences.js +0 -33
- package/dist/utilities/getPreferences.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -20
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/getRequestTheme.d.ts +0 -10
- package/dist/utilities/getRequestTheme.d.ts.map +0 -1
- package/dist/utilities/getRequestTheme.js +0 -25
- package/dist/utilities/getRequestTheme.js.map +0 -1
- package/dist/utilities/handleAPIRoute.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.js.map +0 -1
- package/dist/utilities/importMap.server.d.ts +0 -9
- package/dist/utilities/importMap.server.d.ts.map +0 -1
- package/dist/utilities/importMap.server.js +0 -12
- package/dist/utilities/importMap.server.js.map +0 -1
- package/dist/utilities/initReq.server.d.ts +0 -19
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -87
- package/dist/utilities/initReq.server.js.map +0 -1
- package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
- package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
- package/dist/utilities/serverFunctionHandlers.js +0 -17
- package/dist/utilities/serverFunctionHandlers.js.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
- package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.js +0 -31
- package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
- package/dist/vite/constants.d.ts +0 -42
- package/dist/vite/constants.d.ts.map +0 -1
- package/dist/vite/constants.js.map +0 -1
- package/dist/vite/importProtection.d.ts.map +0 -1
- package/dist/vite/importProtection.js.map +0 -1
- package/dist/vite/plugin.d.ts +0 -38
- package/dist/vite/plugin.d.ts.map +0 -1
- package/dist/vite/plugin.js +0 -179
- package/dist/vite/plugin.js.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
- package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
- package/dist/vite/plugins/devTransforms.js.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
- /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/clientModuleResolution.js +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/devTransforms.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/reactDomServerInRsc.js +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/stripDistStyleImports.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.d.ts +0 -0
- /package/dist/{vite/plugins → withPayload/workarounds}/wrapCjsForClient.js +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
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
|
-
import { Fragment } from 'react';
|
|
6
|
+
import { Fragment, useDeferredValue, useEffect } from 'react';
|
|
6
7
|
import { getAdminMeta } from '../utilities/meta.js';
|
|
7
8
|
const searchToRecord = (searchStr)=>Object.fromEntries(new URLSearchParams(searchStr));
|
|
8
9
|
const runLoader = async (load, splat, searchStr)=>{
|
|
@@ -21,77 +22,95 @@ const runLoader = async (load, splat, searchStr)=>{
|
|
|
21
22
|
return data;
|
|
22
23
|
};
|
|
23
24
|
function AdminPage() {
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
// transition and would remount with the previous payload) so navigating to a
|
|
27
|
-
// different admin page remounts the view, mirroring Next route-segment
|
|
28
|
-
// semantics. Search params are excluded so search-only changes reconcile in place.
|
|
25
|
+
// Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.
|
|
26
|
+
// The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.
|
|
29
27
|
const data = useLoaderData({
|
|
30
28
|
strict: false
|
|
31
29
|
});
|
|
30
|
+
// Route state comes from an external store, so a new RSC payload that suspends
|
|
31
|
+
// on code-split client references can reveal the router's null fallback.
|
|
32
|
+
// Keep the current payload painted until the next one is renderable.
|
|
33
|
+
const rscPayload = useDeferredValue(data?.rscPayload);
|
|
34
|
+
const { holdRouteTransition } = useRouteTransition();
|
|
35
|
+
const isRscPayloadDeferred = rscPayload !== data?.rscPayload;
|
|
36
|
+
useEffect(()=>{
|
|
37
|
+
if (!isRscPayloadDeferred) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const releaseRouteTransition = holdRouteTransition();
|
|
41
|
+
return ()=>releaseRouteTransition();
|
|
42
|
+
}, [
|
|
43
|
+
holdRouteTransition,
|
|
44
|
+
isRscPayloadDeferred
|
|
45
|
+
]);
|
|
32
46
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
33
|
-
children:
|
|
34
|
-
}
|
|
47
|
+
children: rscPayload
|
|
48
|
+
});
|
|
35
49
|
}
|
|
36
|
-
function AdminNotFound(
|
|
37
|
-
|
|
50
|
+
function AdminNotFound({ data }) {
|
|
51
|
+
// TanStack exposes not-found data as unknown; this route only receives the shape thrown below.
|
|
52
|
+
const { routeKey, rscPayload } = data ?? {};
|
|
38
53
|
if (!rscPayload) {
|
|
39
54
|
return /*#__PURE__*/ _jsx(NotFoundClient, {});
|
|
40
55
|
}
|
|
41
56
|
return /*#__PURE__*/ _jsx(Fragment, {
|
|
42
57
|
children: rscPayload
|
|
43
|
-
},
|
|
58
|
+
}, routeKey);
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
* Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
|
|
47
|
-
* server-built NotFound page (shipped via the `notFound()` error's
|
|
48
|
-
* `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
|
|
49
|
-
* client view.
|
|
50
|
-
*/ export function payloadAdminSplatRoute({ load }) {
|
|
51
|
-
return {
|
|
60
|
+
const adminRouteOptions = ({ forwardNotFoundPayload, load, resolveSplat })=>({
|
|
52
61
|
component: AdminPage,
|
|
53
62
|
head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
// Both admin routes must use the same boundary type so index ↔ splat
|
|
64
|
+
// navigation preserves the existing admin subtree.
|
|
65
|
+
notFoundComponent: AdminNotFound,
|
|
66
|
+
// `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
|
|
67
|
+
// sibling route option — router-core only reads it off a non-function loader)
|
|
68
|
+
// makes stale-match revalidation await the fresh loader before committing,
|
|
69
|
+
// instead of the default background SWR that flashes the pre-navigation list
|
|
70
|
+
// (e.g. a just-created doc missing) until the reload lands.
|
|
71
|
+
loader: {
|
|
72
|
+
handler: async ({ location, params })=>{
|
|
73
|
+
const data = await runLoader(load, resolveSplat(params), location.searchStr);
|
|
74
|
+
if (data?._notFound) {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
|
|
76
|
+
throw notFound(forwardNotFoundPayload ? {
|
|
77
|
+
data: {
|
|
78
|
+
routeKey: data.routeKey,
|
|
79
|
+
rscPayload: data.rscPayload
|
|
80
|
+
}
|
|
81
|
+
} : undefined);
|
|
82
|
+
}
|
|
83
|
+
return data;
|
|
84
|
+
},
|
|
85
|
+
staleReloadMode: 'blocking'
|
|
67
86
|
},
|
|
87
|
+
// Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.
|
|
68
88
|
loaderDeps: ({ search })=>({
|
|
69
89
|
searchKey: JSON.stringify(search)
|
|
70
90
|
}),
|
|
71
|
-
notFoundComponent: AdminNotFound,
|
|
72
91
|
validateSearch: (search)=>search
|
|
73
|
-
};
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
|
|
95
|
+
* server-built NotFound page (shipped via the `notFound()` error's
|
|
96
|
+
* `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
|
|
97
|
+
* client view.
|
|
98
|
+
*/ export function payloadAdminSplatRoute({ load }) {
|
|
99
|
+
return adminRouteOptions({
|
|
100
|
+
forwardNotFoundPayload: true,
|
|
101
|
+
load,
|
|
102
|
+
resolveSplat: (params)=>params._splat ?? ''
|
|
103
|
+
});
|
|
74
104
|
}
|
|
75
105
|
/**
|
|
76
|
-
* Route options for the admin index route (`/_payload/admin/`).
|
|
77
|
-
*
|
|
106
|
+
* Route options for the admin index route (`/_payload/admin/`). Not-found
|
|
107
|
+
* results omit the RSC payload and fall back to `NotFoundClient`.
|
|
78
108
|
*/ export function payloadAdminIndexRoute({ load }) {
|
|
79
|
-
return {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (data?._notFound) {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
|
|
86
|
-
throw notFound();
|
|
87
|
-
}
|
|
88
|
-
return data;
|
|
89
|
-
},
|
|
90
|
-
loaderDeps: ({ search })=>({
|
|
91
|
-
searchKey: JSON.stringify(search)
|
|
92
|
-
}),
|
|
93
|
-
validateSearch: (search)=>search
|
|
94
|
-
};
|
|
109
|
+
return adminRouteOptions({
|
|
110
|
+
forwardNotFoundPayload: false,
|
|
111
|
+
load,
|
|
112
|
+
resolveSplat: ()=>''
|
|
113
|
+
});
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
//# sourceMappingURL=adminRoutes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\nfunction AdminPage() {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport 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;IACvD,MAAMO,OAAO,MAAMF,KAAK;QAAEE,MAAM;YAAEC,QAAQF;YAAOG,QAAQV,eAAeC;QAAW;IAAE;IACrF,IAAIO,MAAMG,WAAW;QACnB,qHAAqH;QACrH,MAAMjB,SAAS;YAAEkB,IAAIJ,KAAKG,SAAS;QAAC;IACtC;IACA,OAAOH;AACT;AAEA,SAASK;IACP,+HAA+H;IAC/H,2HAA2H;IAC3H,MAAML,OAAOb,cAAc;QAAEmB,QAAQ;IAAM;IAE3C,+EAA+E;IAC/E,yEAAyE;IACzE,qEAAqE;IACrE,MAAMC,aAAalB,iBAAiBW,MAAMO;IAC1C,MAAM,EAAEC,mBAAmB,EAAE,GAAGzB;IAChC,MAAM0B,uBAAuBF,eAAeP,MAAMO;IAElDjB,UAAU;QACR,IAAI,CAACmB,sBAAsB;YACzB;QACF;QAEA,MAAMC,yBAAyBF;QAE/B,OAAO,IAAME;IACf,GAAG;QAACF;QAAqBC;KAAqB;IAE9C,qBAAO,KAACrB;kBAAUmB;;AACpB;AAIA,SAASI,cAAc,EAAEX,IAAI,EAAsB;IACjD,+FAA+F;IAC/F,MAAM,EAAEY,QAAQ,EAAEL,UAAU,EAAE,GAAIP,QAAQ,CAAC;IAC3C,IAAI,CAACO,YAAY;QACf,qBAAO,KAACvB;IACV;IACA,qBAAO,KAACI;kBAAyBmB;OAAXK;AACxB;AAEA,MAAMC,oBAAoB,CAAC,EACzBC,sBAAsB,EACtBhB,IAAI,EACJiB,YAAY,EAWb,GAAM,CAAA;QACLC,WAAWX;QACXY,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAK3B,aAAa2B,YAAYC;QACzE,qEAAqE;QACrE,mDAAmD;QACnDC,mBAAmBT;QACnB,0EAA0E;QAC1E,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,4DAA4D;QAC5DU,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;gBAClE,MAAMxB,OAAO,MAAMH,UAAUC,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,33 +1,34 @@
|
|
|
1
1
|
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
type ApiRouteHandler = (ctx: {
|
|
3
|
+
request: Request;
|
|
4
|
+
}) => Promise<Response>;
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
* app supplies `getConfig` (an `@payload-config`
|
|
5
|
-
* resolve the consumer's config.
|
|
6
|
+
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
7
|
+
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
8
|
+
* import) since the package cannot resolve the consumer's config.
|
|
9
|
+
*
|
|
10
|
+
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
11
|
+
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
12
|
+
*
|
|
13
|
+
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
14
|
+
* client compiler can statically see — and prune — the server-only route:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
18
|
+
*
|
|
19
|
+
* export const Route = createFileRoute('/_payload/api/$')({
|
|
20
|
+
* server: {
|
|
21
|
+
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
22
|
+
* },
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The compiler only strips a literal `server:` key from a route-options object
|
|
27
|
+
* expression; wrapping the whole options object in a factory call hides the
|
|
28
|
+
* key, leaking the config graph into the client bundle.
|
|
6
29
|
*/
|
|
7
|
-
export declare function
|
|
30
|
+
export declare function payloadApiHandlers({ getConfig, }: {
|
|
8
31
|
getConfig: () => Promise<SanitizedConfig>;
|
|
9
|
-
}):
|
|
10
|
-
|
|
11
|
-
handlers: {
|
|
12
|
-
DELETE: ({ request }: {
|
|
13
|
-
request: Request;
|
|
14
|
-
}) => Promise<Response>;
|
|
15
|
-
GET: ({ request }: {
|
|
16
|
-
request: Request;
|
|
17
|
-
}) => Promise<Response>;
|
|
18
|
-
OPTIONS: ({ request }: {
|
|
19
|
-
request: Request;
|
|
20
|
-
}) => Promise<Response>;
|
|
21
|
-
PATCH: ({ request }: {
|
|
22
|
-
request: Request;
|
|
23
|
-
}) => Promise<Response>;
|
|
24
|
-
POST: ({ request }: {
|
|
25
|
-
request: Request;
|
|
26
|
-
}) => Promise<Response>;
|
|
27
|
-
PUT: ({ request }: {
|
|
28
|
-
request: Request;
|
|
29
|
-
}) => Promise<Response>;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
32
|
+
}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler>;
|
|
33
|
+
export {};
|
|
33
34
|
//# sourceMappingURL=apiRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C
|
|
1
|
+
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
|
package/dist/routes/apiRoute.js
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* app supplies `getConfig` (an `@payload-config`
|
|
4
|
-
* resolve the consumer's config.
|
|
5
|
-
|
|
2
|
+
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
3
|
+
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
|
+
* import) since the package cannot resolve the consumer's config.
|
|
5
|
+
*
|
|
6
|
+
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
7
|
+
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
8
|
+
*
|
|
9
|
+
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
10
|
+
* client compiler can statically see — and prune — the server-only route:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
14
|
+
*
|
|
15
|
+
* export const Route = createFileRoute('/_payload/api/$')({
|
|
16
|
+
* server: {
|
|
17
|
+
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
18
|
+
* },
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The compiler only strips a literal `server:` key from a route-options object
|
|
23
|
+
* expression; wrapping the whole options object in a factory call hides the
|
|
24
|
+
* key, leaking the config graph into the client bundle.
|
|
25
|
+
*/ export function payloadApiHandlers({ getConfig }) {
|
|
6
26
|
const handler = async ({ request })=>{
|
|
7
|
-
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
|
|
27
|
+
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js');
|
|
8
28
|
return handleAPIRoute({
|
|
9
29
|
config: await getConfig(),
|
|
10
30
|
request
|
|
11
31
|
});
|
|
12
32
|
};
|
|
13
33
|
return {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
POST: handler,
|
|
21
|
-
PUT: handler
|
|
22
|
-
}
|
|
23
|
-
}
|
|
34
|
+
DELETE: handler,
|
|
35
|
+
GET: handler,
|
|
36
|
+
OPTIONS: handler,
|
|
37
|
+
PATCH: handler,
|
|
38
|
+
POST: handler,
|
|
39
|
+
PUT: handler
|
|
24
40
|
};
|
|
25
41
|
}
|
|
26
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so\n * the server-only `handleAPIRoute` graph never reaches the client bundle.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
-
import { RootProvider } from '@payloadcms/ui';
|
|
2
|
+
import { RootProvider } from '@payloadcms/ui/providers/Root';
|
|
3
|
+
import type { LoadLayoutDataResult } from '../utilities/loadLayoutData.js';
|
|
3
4
|
/**
|
|
4
5
|
* Loader supplied by the app — a TanStack Start `createServerFn` that delegates
|
|
5
6
|
* to `loadLayoutData`. Typed loosely because the server-fn's call signature is
|
|
6
7
|
* generated by the Start compiler.
|
|
7
8
|
*/
|
|
8
|
-
export type LayoutLoad = () => Promise<
|
|
9
|
+
export type LayoutLoad = () => Promise<LoadLayoutDataResult>;
|
|
9
10
|
/**
|
|
10
11
|
* Route options for the Payload admin layout (`/_payload`). Maps the layout
|
|
11
12
|
* loader data onto `RootProvider` and renders the admin chrome (progress bar,
|
|
@@ -18,6 +19,9 @@ export declare function payloadLayoutRoute({ load, serverFunction, }: {
|
|
|
18
19
|
serverFunction: ComponentProps<typeof RootProvider>['serverFunction'];
|
|
19
20
|
}): {
|
|
20
21
|
component: () => import("react").JSX.Element;
|
|
21
|
-
loader:
|
|
22
|
+
loader: {
|
|
23
|
+
handler: () => Promise<import("../utilities/toSerializable.js").SerializableRecord>;
|
|
24
|
+
staleReloadMode: 'blocking';
|
|
25
|
+
};
|
|
22
26
|
};
|
|
23
27
|
//# sourceMappingURL=layoutRoute.d.ts.map
|
|
@@ -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
|
/**
|
|
@@ -19,6 +20,7 @@ import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
|
19
20
|
/*#__PURE__*/ _jsxs(RootProvider, {
|
|
20
21
|
config: data.clientConfig,
|
|
21
22
|
dateFNSKey: data.dateFNSKey,
|
|
23
|
+
embed: data.isEmbedded,
|
|
22
24
|
fallbackLang: data.fallbackLang,
|
|
23
25
|
highContrastMode: false,
|
|
24
26
|
isNavOpen: data.isNavOpen,
|
|
@@ -42,9 +44,15 @@ import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
|
42
44
|
]
|
|
43
45
|
});
|
|
44
46
|
}
|
|
47
|
+
// `staleReloadMode` lives on the loader *object* — router-core only reads it
|
|
48
|
+
// off a non-function loader — so stale-match revalidation blocks on the fresh
|
|
49
|
+
// loader instead of flashing stale layout data via the default background SWR.
|
|
45
50
|
return {
|
|
46
51
|
component: PayloadLayout,
|
|
47
|
-
loader:
|
|
52
|
+
loader: {
|
|
53
|
+
handler: ()=>load(),
|
|
54
|
+
staleReloadMode: 'blocking'
|
|
55
|
+
}
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devConfigReload.server.d.ts","sourceRoot":"","sources":["../../src/utilities/devConfigReload.server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { registerDevReloadStrategy } from 'payload';
|
|
2
|
+
import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribes the Payload instance to the config-changed event that the
|
|
5
|
+
* `payload:dev-config-reload` Vite plugin broadcasts.
|
|
6
|
+
*
|
|
7
|
+
* Imported for its side effect by `initAdminContext.server.ts`, the adapter's only
|
|
8
|
+
* `getPayload` call site, so the strategy is registered before an instance can
|
|
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
|
|
11
|
+
* `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
|
|
12
|
+
* its own listener against its own copy.
|
|
13
|
+
*
|
|
14
|
+
* Vite re-evaluates this module on a program reload, which drops the listeners
|
|
15
|
+
* the previous instance had collected. `getPayload` reconnects on its next call
|
|
16
|
+
* because the registered strategy is a new object - see `connectDevReload`.
|
|
17
|
+
*
|
|
18
|
+
* `import.meta.hot` is only defined during dev serve, so this is inert in a
|
|
19
|
+
* production build.
|
|
20
|
+
*/ const hot = import.meta.hot;
|
|
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 }) {
|
|
38
|
+
const listeners = new Set();
|
|
39
|
+
let hasPendingReload = false;
|
|
40
|
+
hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, ()=>{
|
|
41
|
+
if (listeners.size === 0) {
|
|
42
|
+
hasPendingReload = true;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const onReload of listeners){
|
|
46
|
+
onReload();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
connect: (onReload)=>{
|
|
51
|
+
listeners.add(onReload);
|
|
52
|
+
if (hasPendingReload) {
|
|
53
|
+
hasPendingReload = false;
|
|
54
|
+
onReload();
|
|
55
|
+
}
|
|
56
|
+
return ()=>{
|
|
57
|
+
listeners.delete(onReload);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=devConfigReload.server.js.map
|
|
@@ -0,0 +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 `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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
|
|
3
|
+
* the Payload config (or anything it imports) changes on disk.
|
|
4
|
+
*
|
|
5
|
+
* Kept in its own module so the Vite plugin can name the event without pulling
|
|
6
|
+
* in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PAYLOAD_CONFIG_CHANGED_EVENT = "payload:config-changed";
|
|
9
|
+
//# sourceMappingURL=devConfigReloadEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devConfigReloadEvent.d.ts","sourceRoot":"","sources":["../../src/utilities/devConfigReloadEvent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when
|
|
3
|
+
* the Payload config (or anything it imports) changes on disk.
|
|
4
|
+
*
|
|
5
|
+
* Kept in its own module so the Vite plugin can name the event without pulling
|
|
6
|
+
* in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.
|
|
7
|
+
*/ export const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=devConfigReloadEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/devConfigReloadEvent.ts"],"sourcesContent":["/**\n * Custom Vite HMR event the `payload:dev-config-reload` plugin broadcasts when\n * the Payload config (or anything it imports) changes on disk.\n *\n * Kept in its own module so the Vite plugin can name the event without pulling\n * in the server runtime — and therefore the whole CMS — when `vite.config.ts` loads.\n */\nexport const PAYLOAD_CONFIG_CHANGED_EVENT = 'payload:config-changed'\n"],"names":["PAYLOAD_CONFIG_CHANGED_EVENT"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,+BAA+B,yBAAwB"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlHandler.server.d.ts","sourceRoot":"","sources":["../../src/utilities/graphqlHandler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,SAAS,CAAA;AAyFvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"graphqlHandler.server.d.ts","sourceRoot":"","sources":["../../src/utilities/graphqlHandler.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,SAAS,CAAA;AAyFvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,yBAGvB;IACD,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CAAC,QAAQ,CA2DnB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addDataAndFileToRequest, addLocalesToRequestFromData,
|
|
1
|
+
import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
|
|
2
2
|
const handleError = async ({ err, payload, req })=>{
|
|
3
3
|
const status = err.originalError?.status || 500;
|
|
4
4
|
let errorMessage = err.message;
|
|
@@ -72,7 +72,7 @@ const getGraphql = async (config)=>{
|
|
|
72
72
|
* Requires `@payloadcms/graphql` and `graphql-http` to be installed in the consuming app.
|
|
73
73
|
*/ export const handleGraphQL = async ({ config, request })=>{
|
|
74
74
|
const originalRequest = request.clone();
|
|
75
|
-
const req = await
|
|
75
|
+
const req = await createPayloadRequestFromWebRequest({
|
|
76
76
|
canSetHeaders: true,
|
|
77
77
|
config,
|
|
78
78
|
request
|