@payloadcms/tanstack-start 4.0.0-internal.c7d5de4 → 4.0.0-internal.cea8867
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/exports/server.d.ts +1 -2
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +1 -2
- package/dist/exports/server.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/routes/apiRoute.d.ts +0 -5
- package/dist/routes/apiRoute.d.ts.map +1 -1
- package/dist/routes/apiRoute.js +1 -6
- package/dist/routes/apiRoute.js.map +1 -1
- package/dist/utilities/{handleAPIRoute.server.d.ts → handleAPIRoute.d.ts} +1 -1
- package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
- package/dist/utilities/{handleAPIRoute.server.js → handleAPIRoute.js} +1 -1
- package/dist/utilities/handleAPIRoute.js.map +1 -0
- package/dist/utilities/loadAdminPage.d.ts.map +1 -1
- package/dist/utilities/loadAdminPage.js +2 -11
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/meta.d.ts +0 -1
- package/dist/utilities/meta.d.ts.map +1 -1
- package/dist/utilities/meta.js +1 -2
- package/dist/utilities/meta.js.map +1 -1
- package/dist/vite/config/external.d.ts +0 -15
- package/dist/vite/config/external.d.ts.map +1 -1
- package/dist/vite/config/external.js +0 -24
- package/dist/vite/config/external.js.map +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +3 -3
- package/dist/vite/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.server.js.map +0 -1
- package/dist/utilities/routerSearch.d.ts +0 -40
- package/dist/utilities/routerSearch.d.ts.map +0 -1
- package/dist/utilities/routerSearch.js +0 -45
- package/dist/utilities/routerSearch.js.map +0 -1
package/dist/exports/server.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export { login } from '../auth/login.js';
|
|
2
2
|
export { logout } from '../auth/logout.js';
|
|
3
3
|
export { refresh } from '../auth/refresh.js';
|
|
4
|
-
export { payloadApiHandlers } from '../routes/apiRoute.js';
|
|
5
4
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
6
5
|
export { getRequestLocale } from '../utilities/getRequestLocale.js';
|
|
7
6
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
|
-
export { handleAPIRoute } from '../utilities/handleAPIRoute.
|
|
7
|
+
export { handleAPIRoute } from '../utilities/handleAPIRoute.js';
|
|
9
8
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
9
|
export { getImportMapOutputPath } from '../utilities/importMap.server.js';
|
|
11
10
|
export { initReq } from '../utilities/initReq.server.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EACL,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EACL,6BAA6B,EAC7B,KAAK,aAAa,EAClB,qBAAqB,GACtB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}
|
package/dist/exports/server.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export { login } from '../auth/login.js';
|
|
2
2
|
export { logout } from '../auth/logout.js';
|
|
3
3
|
export { refresh } from '../auth/refresh.js';
|
|
4
|
-
export { payloadApiHandlers } from '../routes/apiRoute.js';
|
|
5
4
|
export { getRequestI18n } from '../utilities/getRequestI18n.server.js';
|
|
6
5
|
export { getRequestLocale } from '../utilities/getRequestLocale.js';
|
|
7
6
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
|
-
export { handleAPIRoute } from '../utilities/handleAPIRoute.
|
|
7
|
+
export { handleAPIRoute } from '../utilities/handleAPIRoute.js';
|
|
9
8
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
9
|
export { getImportMapOutputPath } from '../utilities/importMap.server.js';
|
|
11
10
|
export { initReq } from '../utilities/initReq.server.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { login } from '../auth/login.js'\nexport { logout } from '../auth/logout.js'\nexport { refresh } from '../auth/refresh.js'\nexport { getRequestI18n } from '../utilities/getRequestI18n.server.js'\nexport { getRequestLocale } from '../utilities/getRequestLocale.js'\nexport { handleGraphQL } from '../utilities/graphqlHandler.server.js'\nexport { handleAPIRoute } from '../utilities/handleAPIRoute.js'\nexport { handleServerFunctions } from '../utilities/handleServerFunctions.js'\nexport { getImportMapOutputPath } from '../utilities/importMap.server.js'\nexport { initReq } from '../utilities/initReq.server.js'\nexport {\n loadAdminPage,\n type LoadAdminPageArgs,\n type LoadAdminPageResult,\n} from '../utilities/loadAdminPage.js'\nexport { type AdminPageMetadata, getAdminMeta } from '../utilities/meta.js'\nexport { serializeForRsc } from '../utilities/serializeForRsc.js'\nexport {\n createPageRenderServerAdapter,\n type PageNavIntent,\n tanstackServerAdapter,\n} from '../utilities/serverAdapter.server.js'\nexport { toSerializable } from '../utilities/toSerializable.js'\nexport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\n"],"names":["login","logout","refresh","getRequestI18n","getRequestLocale","handleGraphQL","handleAPIRoute","handleServerFunctions","getImportMapOutputPath","initReq","loadAdminPage","getAdminMeta","serializeForRsc","createPageRenderServerAdapter","tanstackServerAdapter","toSerializable","getRequestTheme"],"mappings":"AAAA,SAASA,KAAK,QAAQ,mBAAkB;AACxC,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,OAAO,QAAQ,qBAAoB;AAC5C,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,aAAa,QAAQ,wCAAuC;AACrE,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,qBAAqB,QAAQ,wCAAuC;AAC7E,SAASC,sBAAsB,QAAQ,mCAAkC;AACzE,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,aAAa,QAGR,gCAA+B;AACtC,SAAiCC,YAAY,QAAQ,uBAAsB;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SACEC,6BAA6B,EAE7BC,qBAAqB,QAChB,uCAAsC;AAC7C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,eAAe,QAAQ,2CAA0C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { TanStackComponentRenderer } from './elements/RenderComponent/index.js';
|
|
2
2
|
export { TanStackRouterAdapter } from './elements/RouterAdapter/index.js';
|
|
3
|
+
export { payloadApiHandlers } from './routes/apiRoute.js';
|
|
3
4
|
export { viteDevReloadStrategy } from './utilities/devReloadStrategy.js';
|
|
4
5
|
export { type AdminPageMetadata, getAdminMeta } from './utilities/meta.js';
|
|
5
|
-
export { payloadParseSearch, payloadStringifySearch } from './utilities/routerSearch.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,KAAK,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TanStackComponentRenderer } from './elements/RenderComponent/index.js';
|
|
2
2
|
export { TanStackRouterAdapter } from './elements/RouterAdapter/index.js';
|
|
3
|
+
export { payloadApiHandlers } from './routes/apiRoute.js';
|
|
3
4
|
export { viteDevReloadStrategy } from './utilities/devReloadStrategy.js';
|
|
4
5
|
export { getAdminMeta } from './utilities/meta.js';
|
|
5
|
-
export { payloadParseSearch, payloadStringifySearch } from './utilities/routerSearch.js';
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { TanStackComponentRenderer } from './elements/RenderComponent/index.js'\nexport { TanStackRouterAdapter } from './elements/RouterAdapter/index.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { TanStackComponentRenderer } from './elements/RenderComponent/index.js'\nexport { TanStackRouterAdapter } from './elements/RouterAdapter/index.js'\nexport { payloadApiHandlers } from './routes/apiRoute.js'\nexport { viteDevReloadStrategy } from './utilities/devReloadStrategy.js'\nexport { type AdminPageMetadata, getAdminMeta } from './utilities/meta.js'\n"],"names":["TanStackComponentRenderer","TanStackRouterAdapter","payloadApiHandlers","viteDevReloadStrategy","getAdminMeta"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,sCAAqC;AAC/E,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,qBAAqB,QAAQ,mCAAkC;AACxE,SAAiCC,YAAY,QAAQ,sBAAqB"}
|
|
@@ -7,15 +7,10 @@ type ApiRouteHandler = (ctx: {
|
|
|
7
7
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
8
8
|
* import) since the package cannot resolve the consumer's config.
|
|
9
9
|
*
|
|
10
|
-
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
11
|
-
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
12
|
-
*
|
|
13
10
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
14
11
|
* client compiler can statically see — and prune — the server-only route:
|
|
15
12
|
*
|
|
16
13
|
* ```ts
|
|
17
|
-
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
18
|
-
*
|
|
19
14
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
20
15
|
* server: {
|
|
21
16
|
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE
|
|
1
|
+
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
|
package/dist/routes/apiRoute.js
CHANGED
|
@@ -3,15 +3,10 @@
|
|
|
3
3
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
4
|
* import) since the package cannot resolve the consumer's config.
|
|
5
5
|
*
|
|
6
|
-
* Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
|
|
7
|
-
* the server-only `handleAPIRoute` graph never reaches the client bundle.
|
|
8
|
-
*
|
|
9
6
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
10
7
|
* client compiler can statically see — and prune — the server-only route:
|
|
11
8
|
*
|
|
12
9
|
* ```ts
|
|
13
|
-
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
|
|
14
|
-
*
|
|
15
10
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
16
11
|
* server: {
|
|
17
12
|
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
@@ -24,7 +19,7 @@
|
|
|
24
19
|
* key, leaking the config graph into the client bundle.
|
|
25
20
|
*/ export function payloadApiHandlers({ getConfig }) {
|
|
26
21
|
const handler = async ({ request })=>{
|
|
27
|
-
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.
|
|
22
|
+
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
|
|
28
23
|
return handleAPIRoute({
|
|
29
24
|
config: await getConfig(),
|
|
30
25
|
request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n *
|
|
1
|
+
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;CAmBC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAPIRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleAPIRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GACpE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;CAC5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoJlD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getViewportContent } from '@payloadcms/ui/shared';
|
|
2
1
|
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
3
2
|
import { getRequestI18n } from './getRequestI18n.server.js';
|
|
4
3
|
import { initReq } from './initReq.server.js';
|
|
@@ -100,21 +99,16 @@ const resolveTitle = (title)=>{
|
|
|
100
99
|
// by RSC streaming deep inside view components). Read after the render.
|
|
101
100
|
const nav = {};
|
|
102
101
|
const pageServerAdapter = createPageRenderServerAdapter(nav);
|
|
103
|
-
let userAgent;
|
|
104
102
|
// `renderRoot` calls `initReq` itself with its own overrides (query
|
|
105
103
|
// re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
|
|
106
104
|
// page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
|
|
107
105
|
// is recorded + thrown rather than escaping as raw TanStack nav.
|
|
108
|
-
const boundInitReq =
|
|
109
|
-
const result = await initReq({
|
|
106
|
+
const boundInitReq = (args)=>initReq({
|
|
110
107
|
configPromise: args.configPromise,
|
|
111
108
|
importMap: args.importMap,
|
|
112
109
|
overrides: args.overrides,
|
|
113
110
|
serverAdapter: pageServerAdapter
|
|
114
111
|
});
|
|
115
|
-
userAgent = result.headers.get('user-agent') ?? undefined;
|
|
116
|
-
return result;
|
|
117
|
-
};
|
|
118
112
|
const notFound = ()=>{
|
|
119
113
|
nav.type = 'notFound';
|
|
120
114
|
throw new Error('not-found');
|
|
@@ -215,10 +209,7 @@ const resolveTitle = (title)=>{
|
|
|
215
209
|
}
|
|
216
210
|
});
|
|
217
211
|
return {
|
|
218
|
-
metadata:
|
|
219
|
-
...toAdminPageMetadata(meta),
|
|
220
|
-
viewport: getViewportContent(userAgent)
|
|
221
|
-
},
|
|
212
|
+
metadata: toAdminPageMetadata(meta),
|
|
222
213
|
routeKey: splat ?? '',
|
|
223
214
|
rscPayload
|
|
224
215
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/shared'\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: React.ReactNode }\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: React.ReactNode\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\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. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. 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 `initReq` 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 boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = async (args) => {\n const result = await initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.headers.get('user-agent') ?? undefined\n return result\n }\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\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 initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\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 initReq: boundInitReq,\n 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,\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","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","userAgent","boundInitReq","args","result","configPromise","overrides","serverAdapter","headers","get","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","viewport","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AA6BzE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IACA,IAAI,OAAOD,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,IAAI,cAAcA,OAAO;QACvB,OAAOA,MAAME,QAAQ;IACvB;IACA,OAAOF,MAAMG,OAAO;AACtB;AAEA;;;;;;CAMC,GACD,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,KAAKD,KAAKE,SAAS;IASzB,MAAMC,YAAYF,IAAIG;IACtB,MAAMC,cAAcF,YAAaG,MAAMC,OAAO,CAACJ,aAAaA,YAAY;QAACA;KAAU,GAAI,EAAE;IACzF,MAAMC,SAASC,YACZG,GAAG,CAAC,CAACC,QACJ,OAAOA,UAAU,WACb;YAAEC,KAAKD;QAAM,IACbA,OAAOC,MACL;YAAEC,KAAKF,MAAME,GAAG;YAAEC,QAAQH,MAAMG,MAAM;YAAEF,KAAKG,OAAOJ,MAAMC,GAAG;YAAGI,OAAOL,MAAMK,KAAK;QAAC,IACnFlB,WAEPmB,MAAM,CAACC;IAEV,MAAMC,WAAWjB,KAAKkB,KAAK;IAC3B,MAAMC,WAAWb,MAAMC,OAAO,CAACU,YAC3BA,WACAA,YAAY,OAAOA,aAAa,YAAYX,MAAMC,OAAO,CAACU,SAASG,IAAI,IACrEH,SAASG,IAAI,GACb,EAAE;IACR,MAAMF,QAAQC,SACXX,GAAG,CAAC,CAACY,OACJ,OAAOA,SAAS,WACZ;YAAEC,KAAK;YAAQX,KAAKU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ACxE,sEAAsE;QACtE,2DAA2D;QAC3D,MAAMoB,OAAO,MAAMtF,eAAe;YAAEyC;QAAO;QAC3C,MAAMhC,OAAO,MAAMsC,qBAAqB;YACtC6B,YAAY9B;YACZL;YACA6C;YACAf,QAAQ;gBAAErB;YAAS;QACrB;QAEA,OAAO;YACLqC,UAAU;gBACR,GAAG/E,oBAAoBC,KAAK;gBAC5B+E,UAAU1F,mBAAmBwD;YAC/B;YACAoB,UAAU9B,SAAS;YACnB4B;QACF;IACF,EAAE,OAAOiB,KAAK;QACZ,MAAMC,UAAUD,eAAezB,QAAQyB,IAAIC,OAAO,GAAGpE,OAAOmE;QAC5D,IAAIrC,IAAIrB,IAAI,KAAK,cAAc2D,YAAY,aAAa;YACtD,OAAO,MAAMxB;QACf;QACA,IAAId,IAAIrB,IAAI,KAAK,cAAc2D,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEN,WAAWjC,IAAIjC,GAAG,IAAIuE,QAAQE,KAAK,CAAC,YAAYxD,MAAM;YAAE;QACnE;QACA,MAAMqD;IACR;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: React.ReactNode }\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: React.ReactNode\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\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. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. 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\n // `renderRoot` calls `initReq` 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 boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\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 initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\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 initReq: boundInitReq,\n 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,\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: toAdminPageMetadata(meta),\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":["renderServerComponent","getRequestI18n","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","boundInitReq","args","configPromise","overrides","serverAdapter","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AA6BzE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IACA,IAAI,OAAOD,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,IAAI,cAAcA,OAAO;QACvB,OAAOA,MAAME,QAAQ;IACvB;IACA,OAAOF,MAAMG,OAAO;AACtB;AAEA;;;;;;CAMC,GACD,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,KAAKD,K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.ts","sourceRoot":"","sources":["../../src/utilities/meta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/utilities/meta.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GACV;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,aAAa,EAAE,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,iBAAiB,GAAG;IAC1D,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,IAAI,EAAE,SAAS,EAAE,CAAA;CAClB,CA0EA"}
|
package/dist/utilities/meta.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getViewportContent } from '@payloadcms/ui/shared';
|
|
2
1
|
/**
|
|
3
2
|
* Builds TanStack Router `head()` `meta` + `links` entries for an admin page
|
|
4
3
|
* from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders
|
|
@@ -17,7 +16,7 @@ import { getViewportContent } from '@payloadcms/ui/shared';
|
|
|
17
16
|
},
|
|
18
17
|
{
|
|
19
18
|
name: 'viewport',
|
|
20
|
-
content:
|
|
19
|
+
content: 'width=device-width, initial-scale=1'
|
|
21
20
|
}
|
|
22
21
|
];
|
|
23
22
|
const links = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["type MetaEntry =\n | { charSet: string }\n | { content: string; name: string }\n | { content: string; property: string }\n | { title: string }\n\ntype LinkEntry = {\n href: string\n media?: string\n rel: string\n sizes?: string\n type?: string\n}\n\ntype AdminPageIcon = {\n media?: string\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\n\ntype AdminPageOGImage = {\n alt?: string\n height?: number\n url: string\n width?: number\n}\n\n/**\n * Resolved admin-page metadata produced by the admin-page server function.\n *\n * The server function resolves the framework-agnostic `MetaConfig` (via the\n * shared `generatePageMetadata` in `@payloadcms/ui`) down to plain serializable\n * values, so the route loader can ship it across the wire and feed it to\n * `getAdminMeta` in `head()`.\n */\nexport type AdminPageMetadata = {\n description?: string\n icons?: AdminPageIcon[]\n keywords?: string\n openGraph?: {\n description?: string\n images?: AdminPageOGImage[]\n siteName?: string\n title?: string\n }\n robots?: string\n title?: string\n}\n\n/**\n * Builds TanStack Router `head()` `meta` + `links` entries for an admin page\n * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders\n * natively from the same `MetaConfig` (title, description, robots, keywords,\n * OpenGraph, Twitter — derived from OpenGraph — and icon links).\n *\n * ```ts\n * export const Route = createFileRoute('/admin/$')({\n * head: ({ loaderData }) => getAdminMeta(loaderData?.metadata),\n * })\n * ```\n */\nexport function getAdminMeta(metadata?: AdminPageMetadata): {\n links: LinkEntry[]\n meta: MetaEntry[]\n} {\n const meta: MetaEntry[] = [\n { charSet: 'utf-8' },\n { name: 'viewport', content: 'width=device-width, initial-scale=1' },\n ]\n const links: LinkEntry[] = []\n\n if (!metadata) {\n return { links, meta }\n }\n\n if (metadata.title) {\n meta.push({ title: metadata.title })\n }\n if (metadata.description) {\n meta.push({ name: 'description', content: metadata.description })\n }\n if (metadata.keywords) {\n meta.push({ name: 'keywords', content: metadata.keywords })\n }\n if (metadata.robots) {\n meta.push({ name: 'robots', content: metadata.robots })\n }\n\n const og = metadata.openGraph\n if (og) {\n if (og.title) {\n meta.push({ content: og.title, property: 'og:title' })\n }\n if (og.description) {\n meta.push({ content: og.description, property: 'og:description' })\n }\n if (og.siteName) {\n meta.push({ content: og.siteName, property: 'og:site_name' })\n }\n\n for (const image of og.images ?? []) {\n meta.push({ content: image.url, property: 'og:image' })\n if (image.width) {\n meta.push({ content: String(image.width), property: 'og:image:width' })\n }\n if (image.height) {\n meta.push({ content: String(image.height), property: 'og:image:height' })\n }\n if (image.alt) {\n meta.push({ content: image.alt, property: 'og:image:alt' })\n }\n }\n\n // Twitter card is inherited from OpenGraph (matches Next.js metadata resolution).\n const firstImage = og.images?.[0]\n if (firstImage) {\n meta.push({ name: 'twitter:card', content: 'summary_large_image' })\n meta.push({ name: 'twitter:image', content: firstImage.url })\n }\n if (og.title) {\n meta.push({ name: 'twitter:title', content: og.title })\n }\n if (og.description) {\n meta.push({ name: 'twitter:description', content: og.description })\n }\n }\n\n for (const icon of metadata.icons ?? []) {\n links.push({\n href: icon.url,\n rel: icon.rel ?? 'icon',\n ...(icon.media ? { media: icon.media } : {}),\n ...(icon.sizes ? { sizes: icon.sizes } : {}),\n ...(icon.type ? { type: icon.type } : {}),\n })\n }\n\n return { links, meta }\n}\n"],"names":["getAdminMeta","metadata","meta","charSet","name","content","links","title","push","description","keywords","robots","og","openGraph","property","siteName","image","images","url","width","String","height","alt","firstImage","icon","icons","href","rel","media","sizes","type"],"mappings":"AAmDA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAAS;QAAsC;KACpE;IACD,MAAMC,QAAqB,EAAE;IAE7B,IAAI,CAACL,UAAU;QACb,OAAO;YAAEK;YAAOJ;QAAK;IACvB;IAEA,IAAID,SAASM,KAAK,EAAE;QAClBL,KAAKM,IAAI,CAAC;YAAED,OAAON,SAASM,KAAK;QAAC;IACpC;IACA,IAAIN,SAASQ,WAAW,EAAE;QACxBP,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAeC,SAASJ,SAASQ,WAAW;QAAC;IACjE;IACA,IAAIR,SAASS,QAAQ,EAAE;QACrBR,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAYC,SAASJ,SAASS,QAAQ;QAAC;IAC3D;IACA,IAAIT,SAASU,MAAM,EAAE;QACnBT,KAAKM,IAAI,CAAC;YAAEJ,MAAM;YAAUC,SAASJ,SAASU,MAAM;QAAC;IACvD;IAEA,MAAMC,KAAKX,SAASY,SAAS;IAC7B,IAAID,IAAI;QACN,IAAIA,GAAGL,KAAK,EAAE;YACZL,KAAKM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GAAGH,WAAW;YAAC;QACnE;IACF;IAEA,KAAK,MAAMe,QAAQvB,SAASwB,KAAK,IAAI,EAAE,CAAE;QACvCnB,MAAME,IAAI,CAAC;YACTkB,MAAMF,KAAKN,GAAG;YACdS,KAAKH,KAAKG,GAAG,IAAI;YACjB,GAAIH,KAAKI,KAAK,GAAG;gBAAEA,OAAOJ,KAAKI,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIJ,KAAKK,KAAK,GAAG;gBAAEA,OAAOL,KAAKK,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIL,KAAKM,IAAI,GAAG;gBAAEA,MAAMN,KAAKM,IAAI;YAAC,IAAI,CAAC,CAAC;QAC1C;IACF;IAEA,OAAO;QAAExB;QAAOJ;IAAK;AACvB"}
|
|
@@ -7,20 +7,5 @@
|
|
|
7
7
|
* These are the Vite equivalent of Next.js's `serverExternalPackages`.
|
|
8
8
|
*/
|
|
9
9
|
export declare const ssrExternalPackages: string[];
|
|
10
|
-
/**
|
|
11
|
-
* External packages for the production `vite build` only (not dev serve).
|
|
12
|
-
*
|
|
13
|
-
* Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
|
|
14
|
-
* resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
|
|
15
|
-
* its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
|
|
16
|
-
* pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
|
|
17
|
-
* `dist/`, since pnpm does not hoist it.
|
|
18
|
-
*
|
|
19
|
-
* Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
|
|
20
|
-
* TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
|
|
21
|
-
* transform can resolve — an externalized copy would hit Node's raw resolver and
|
|
22
|
-
* fail on the `.js`→`.ts` mismatch.
|
|
23
|
-
*/
|
|
24
|
-
export declare const buildExternalPackages: string[];
|
|
25
10
|
export declare const payloadNoExternalPatterns: Array<RegExp | string>;
|
|
26
11
|
//# sourceMappingURL=external.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/vite/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/vite/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
|
|
@@ -36,30 +36,6 @@
|
|
|
36
36
|
'mongodb',
|
|
37
37
|
'mongoose'
|
|
38
38
|
];
|
|
39
|
-
/**
|
|
40
|
-
* External packages for the production `vite build` only (not dev serve).
|
|
41
|
-
*
|
|
42
|
-
* Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
|
|
43
|
-
* resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
|
|
44
|
-
* its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
|
|
45
|
-
* pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
|
|
46
|
-
* `dist/`, since pnpm does not hoist it.
|
|
47
|
-
*
|
|
48
|
-
* Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
|
|
49
|
-
* TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
|
|
50
|
-
* transform can resolve — an externalized copy would hit Node's raw resolver and
|
|
51
|
-
* fail on the `.js`→`.ts` mismatch.
|
|
52
|
-
*/ export const buildExternalPackages = [
|
|
53
|
-
'payload',
|
|
54
|
-
'payload/node',
|
|
55
|
-
'@payloadcms/drizzle',
|
|
56
|
-
'@payloadcms/db-mongodb',
|
|
57
|
-
'@payloadcms/db-postgres',
|
|
58
|
-
'@payloadcms/db-vercel-postgres',
|
|
59
|
-
'@payloadcms/db-sqlite',
|
|
60
|
-
'@payloadcms/db-d1-sqlite',
|
|
61
|
-
...ssrExternalPackages
|
|
62
|
-
];
|
|
63
39
|
export const payloadNoExternalPatterns = [
|
|
64
40
|
'@payloadcms/ui',
|
|
65
41
|
'@payloadcms/translations',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Server-only packages (Node-only or only ever used by the server bundle).\n * These are the Vite equivalent of Next.js's `serverExternalPackages`.\n */\nexport const ssrExternalPackages: string[] = [\n 'ajv',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Server-only packages (Node-only or only ever used by the server bundle).\n * These are the Vite equivalent of Next.js's `serverExternalPackages`.\n */\nexport const ssrExternalPackages: string[] = [\n 'ajv',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;CAGC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
package/dist/vite/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA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,qFAAqF;IACrF,aAAa,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,UAAU,CAAA;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,kBAAkB,EACrC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CAqGpB;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAElF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,+BAAoC,GACzC,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAwClD"}
|
package/dist/vite/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import viteReact from '@vitejs/plugin-react';
|
|
|
5
5
|
import rsc from '@vitejs/plugin-rsc';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { createLogger, mergeConfig } from 'vite';
|
|
8
|
-
import {
|
|
8
|
+
import { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
|
|
9
9
|
import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js';
|
|
10
10
|
import { payloadScssImporters } from './config/scss.js';
|
|
11
11
|
import { defaultImportProtectionIgnoreImporters, onImportProtectionViolation, serverOnlyClientSpecifiers } from './importProtection.js';
|
|
@@ -101,7 +101,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
101
101
|
rsc: {
|
|
102
102
|
build: {
|
|
103
103
|
rollupOptions: {
|
|
104
|
-
external:
|
|
104
|
+
external: ssrExternalPackages
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
resolve: {
|
|
@@ -111,7 +111,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
111
111
|
ssr: {
|
|
112
112
|
build: {
|
|
113
113
|
rollupOptions: {
|
|
114
|
-
external:
|
|
114
|
+
external: ssrExternalPackages
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
resolve: {
|
package/dist/vite/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport {\n buildExternalPackages,\n payloadNoExternalPatterns,\n ssrExternalPackages,\n} from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n */\nconst suppressibleWarningPatterns = ['points to missing source files', 'Sourcemap for']\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","buildExternalPackages","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SACEC,qBAAqB,EACrBC,yBAAyB,EACzBC,mBAAmB,QACd,uBAAsB;AAC7B,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE;;;;CAIC,GACD,MAAMC,8BAA8B;IAAC;IAAkC;CAAgB;AAEvF;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYnB;IAC3B,MAAMqB,iBAAiB,CAACC,MACtB,OAAOA,QAAQ,YAAYL,4BAA4BM,IAAI,CAAC,CAACC,UAAYF,IAAIG,QAAQ,CAACD;IAExF,MAAME,WAAWN,OAAOO,IAAI,CAACC,IAAI,CAACR;IAClC,MAAMS,eAAeT,OAAOU,QAAQ,CAACF,IAAI,CAACR;IAC1CA,OAAOO,IAAI,GAAG,C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zE;YAA2B;YACnE0E,iBAAiB;mBAAI5E;mBAA2C8B;aAA0B;YAC1F0B,SAAS;gBAAC;aAAO;YACjBqB,YAAY;YACZC,aAAa7E;YACb,4EAA4E;YAC5E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,oEAAoE;YACpE8E,QAAQ;gBAAEL,cAAc;oBAAC;uBAAyB1C;iBAAyB;YAAC;QAC9E;QACAgD,QAAQ;YACNC,sBAAsB;gBACpB,0EAA0E;gBAC1E,2EAA2E;gBAC3E,0EAA0E;gBAC1E,gEAAgE;gBAChEC,eAAe,CAAC,EAAEC,OAAO,EAAuB,GAC9CA,YAAYpD,gBAAgBoD,QAAQC,UAAU,CAAC,GAAGrD,aAAa,CAAC,CAAC,IAAI,EAAE,GAAGsD;YAC9E;YACA,0EAA0E;YAC1E,+CAA+C;YAC/CC,wBAAwB;YACxBpD;QACF;QACA5C,KAAK;YAAEoC,SAAS;QAAK;QACrBU;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n */\nconst suppressibleWarningPatterns = ['points to missing source files', 'Sourcemap for']\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SAASC,yBAAyB,EAAEC,mBAAmB,QAAQ,uBAAsB;AACrF,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE;;;;CAIC,GACD,MAAMC,8BAA8B;IAAC;IAAkC;CAAgB;AAEvF;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYlB;IAC3B,MAAMoB,iBAAiB,CAACC,MACtB,OAAOA,QAAQ,YAAYL,4BAA4BM,IAAI,CAAC,CAACC,UAAYF,IAAIG,QAAQ,CAACD;IAExF,MAAME,WAAWN,OAAOO,IAAI,CAACC,IAAI,CAACR;IAClC,MAAMS,eAAeT,OAAOU,QAAQ,CAACF,IAAI,CAACR;IAC1CA,OAAOO,IAAI,GAAG,CAACL,KAAKS;QAClB,IAAI,CAACV,eAAeC,MAAM;YACxBI,SAASJ,KAAKS;QAChB;IACF;IACAX,OAAOU,QAAQ,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;YACZC,aAAa7E;YACb,4EAA4E;YAC5E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,oEAAoE;YACpE8E,QAAQ;gBAAEL,cAAc;oBAAC;uBAAyB1C;iBAAyB;YAAC;QAC9E;QACAgD,QAAQ;YACNC,sBAAsB;gBACpB,0EAA0E;gBAC1E,2EAA2E;gBAC3E,0EAA0E;gBAC1E,gEAAgE;gBAChEC,eAAe,CAAC,EAAEC,OAAO,EAAuB,GAC9CA,YAAYpD,gBAAgBoD,QAAQC,UAAU,CAAC,GAAGrD,aAAa,CAAC,CAAC,IAAI,EAAE,GAAGsD;YAC9E;YACA,0EAA0E;YAC1E,+CAA+C;YAC/CC,wBAAwB;YACxBpD;QACF;QACA3C,KAAK;YAAEmC,SAAS;QAAK;QACrBU;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/tanstack-start",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.cea8867",
|
|
4
4
|
"description": "TanStack Start framework adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"qs-esm": "^7.0.2",
|
|
61
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
62
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
61
|
+
"@payloadcms/translations": "4.0.0-internal.cea8867",
|
|
62
|
+
"@payloadcms/ui": "4.0.0-internal.cea8867"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"react": "^19.0.0",
|
|
72
72
|
"react-dom": "^19.0.0",
|
|
73
73
|
"vite": ">=8.0.0",
|
|
74
|
-
"payload": "4.0.0-internal.
|
|
74
|
+
"payload": "4.0.0-internal.cea8867"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react": "^19.0.0",
|
|
82
82
|
"react-dom": "^19.0.0",
|
|
83
83
|
"vite": ">=8.0.0",
|
|
84
|
-
"payload": "4.0.0-internal.
|
|
84
|
+
"payload": "4.0.0-internal.cea8867"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"@vitejs/plugin-react": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleAPIRoute.server.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/handleAPIRoute.server.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as qs from 'qs-esm';
|
|
2
|
-
/**
|
|
3
|
-
* `parseSearch` for TanStack Router's `createRouter`, required for Payload's
|
|
4
|
-
* admin UI. Pair with {@link payloadStringifySearch}.
|
|
5
|
-
*
|
|
6
|
-
* Payload serializes query state (notably the list-view `where` filter) with
|
|
7
|
-
* `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
|
|
8
|
-
* Router's default serializer treats each bracketed string as a flat key and
|
|
9
|
-
* JSON-encodes values, so it never round-trips Payload's nested query: every
|
|
10
|
-
* navigation re-encodes the already-encoded value, exponentially nesting it
|
|
11
|
-
* (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
|
|
12
|
-
* stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
|
|
13
|
-
* the URL idempotent and the nested `where` intact across navigations.
|
|
14
|
-
*
|
|
15
|
-
* This is a router-global serializer: it applies to every route, not just
|
|
16
|
-
* `/admin`. On your own routes, search values arrive as strings (qs does no
|
|
17
|
-
* JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
|
|
18
|
-
* you need numbers or booleans.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { createRouter } from '@tanstack/react-router'
|
|
23
|
-
* import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'
|
|
24
|
-
*
|
|
25
|
-
* export function getRouter() {
|
|
26
|
-
* return createRouter({
|
|
27
|
-
* parseSearch: payloadParseSearch,
|
|
28
|
-
* routeTree,
|
|
29
|
-
* stringifySearch: payloadStringifySearch,
|
|
30
|
-
* })
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare const payloadParseSearch: (searchStr: string) => qs.ParsedQs;
|
|
35
|
-
/**
|
|
36
|
-
* `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
|
|
37
|
-
* admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
|
|
38
|
-
*/
|
|
39
|
-
export declare const payloadStringifySearch: (search: Record<string, unknown>) => string;
|
|
40
|
-
//# sourceMappingURL=routerSearch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routerSearch.d.ts","sourceRoot":"","sources":["../../src/utilities/routerSearch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,kBAAkB,cAAe,MAAM,gBACS,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAGrE,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as qs from 'qs-esm';
|
|
2
|
-
/**
|
|
3
|
-
* `parseSearch` for TanStack Router's `createRouter`, required for Payload's
|
|
4
|
-
* admin UI. Pair with {@link payloadStringifySearch}.
|
|
5
|
-
*
|
|
6
|
-
* Payload serializes query state (notably the list-view `where` filter) with
|
|
7
|
-
* `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack
|
|
8
|
-
* Router's default serializer treats each bracketed string as a flat key and
|
|
9
|
-
* JSON-encodes values, so it never round-trips Payload's nested query: every
|
|
10
|
-
* navigation re-encodes the already-encoded value, exponentially nesting it
|
|
11
|
-
* (`[true,"[true,\"[true…"]`) until the filter is unusable. Parsing and
|
|
12
|
-
* stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps
|
|
13
|
-
* the URL idempotent and the nested `where` intact across navigations.
|
|
14
|
-
*
|
|
15
|
-
* This is a router-global serializer: it applies to every route, not just
|
|
16
|
-
* `/admin`. On your own routes, search values arrive as strings (qs does no
|
|
17
|
-
* JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where
|
|
18
|
-
* you need numbers or booleans.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { createRouter } from '@tanstack/react-router'
|
|
23
|
-
* import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'
|
|
24
|
-
*
|
|
25
|
-
* export function getRouter() {
|
|
26
|
-
* return createRouter({
|
|
27
|
-
* parseSearch: payloadParseSearch,
|
|
28
|
-
* routeTree,
|
|
29
|
-
* stringifySearch: payloadStringifySearch,
|
|
30
|
-
* })
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/ export const payloadParseSearch = (searchStr)=>qs.parse(searchStr, {
|
|
34
|
-
depth: 10,
|
|
35
|
-
ignoreQueryPrefix: true
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* `stringifySearch` for TanStack Router's `createRouter`, required for Payload's
|
|
39
|
-
* admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.
|
|
40
|
-
*/ export const payloadStringifySearch = (search)=>{
|
|
41
|
-
const searchStr = qs.stringify(search);
|
|
42
|
-
return searchStr ? `?${searchStr}` : '';
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=routerSearch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/routerSearch.ts"],"sourcesContent":["import * as qs from 'qs-esm'\n\n/**\n * `parseSearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadStringifySearch}.\n *\n * Payload serializes query state (notably the list-view `where` filter) with\n * `qs` bracket notation — e.g. `?where[or][0][and][0][x][equals]=y`. TanStack\n * Router's default serializer treats each bracketed string as a flat key and\n * JSON-encodes values, so it never round-trips Payload's nested query: every\n * navigation re-encodes the already-encoded value, exponentially nesting it\n * (`[true,\"[true,\\\"[true…\"]`) until the filter is unusable. Parsing and\n * stringifying with `qs` (same options as `payload`/`@payloadcms/ui`) keeps\n * the URL idempotent and the nested `where` intact across navigations.\n *\n * This is a router-global serializer: it applies to every route, not just\n * `/admin`. On your own routes, search values arrive as strings (qs does no\n * JSON type-coercion), so coerce in `validateSearch` (e.g. `Number(...)`) where\n * you need numbers or booleans.\n *\n * @example\n * ```ts\n * import { createRouter } from '@tanstack/react-router'\n * import { payloadParseSearch, payloadStringifySearch } from '@payloadcms/tanstack-start'\n *\n * export function getRouter() {\n * return createRouter({\n * parseSearch: payloadParseSearch,\n * routeTree,\n * stringifySearch: payloadStringifySearch,\n * })\n * }\n * ```\n */\nexport const payloadParseSearch = (searchStr: string) =>\n qs.parse(searchStr, { depth: 10, ignoreQueryPrefix: true })\n\n/**\n * `stringifySearch` for TanStack Router's `createRouter`, required for Payload's\n * admin UI. Pair with {@link payloadParseSearch}; see it for the full rationale.\n */\nexport const payloadStringifySearch = (search: Record<string, unknown>) => {\n const searchStr = qs.stringify(search)\n return searchStr ? `?${searchStr}` : ''\n}\n"],"names":["qs","payloadParseSearch","searchStr","parse","depth","ignoreQueryPrefix","payloadStringifySearch","search","stringify"],"mappings":"AAAA,YAAYA,QAAQ,SAAQ;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,MAAMC,qBAAqB,CAACC,YACjCF,GAAGG,KAAK,CAACD,WAAW;QAAEE,OAAO;QAAIC,mBAAmB;IAAK,GAAE;AAE7D;;;CAGC,GACD,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAML,YAAYF,GAAGQ,SAAS,CAACD;IAC/B,OAAOL,YAAY,CAAC,CAAC,EAAEA,WAAW,GAAG;AACvC,EAAC"}
|