@payloadcms/tanstack-start 4.0.0-internal.c7d5de4 → 4.0.0-internal.cd69eef
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/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/server.d.ts +2 -3
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +2 -3
- 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/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +1 -1
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/index.js +2 -4
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +31 -7
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +34 -33
- package/dist/layouts/Root/withPayloadRoot.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/getRequestTheme.d.ts +10 -0
- package/dist/utilities/getRequestTheme.d.ts.map +1 -0
- package/dist/utilities/getRequestTheme.js +25 -0
- package/dist/utilities/getRequestTheme.js.map +1 -0
- 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.js +1 -1
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/meta.js +1 -1
- 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/client.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 { PayloadAdminShell, type PayloadAdminShellProps, withPayloadRoot, type WithPayloadRootOptions, } from '../layouts/Root/withPayloadRoot.js';
|
|
3
|
+
export { buildThemeInitScript, PayloadAdminShell, type PayloadAdminShellProps, THEME_INIT_SCRIPT, withPayloadRoot, type WithPayloadRootOptions, } from '../layouts/Root/withPayloadRoot.js';
|
|
4
4
|
export { type AdminLoad, payloadAdminIndexRoute, payloadAdminSplatRoute, } from '../routes/adminRoutes.js';
|
|
5
5
|
export { type LayoutLoad, payloadLayoutRoute } from '../routes/layoutRoute.js';
|
|
6
6
|
export { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,sCAAsC,CAAA"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,iBAAiB,EACjB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,sCAAsC,CAAA"}
|
package/dist/exports/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
export { TanStackComponentRenderer } from '../elements/RenderComponent/index.js';
|
|
3
3
|
export { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
4
|
-
export { PayloadAdminShell, withPayloadRoot } from '../layouts/Root/withPayloadRoot.js';
|
|
4
|
+
export { buildThemeInitScript, PayloadAdminShell, THEME_INIT_SCRIPT, withPayloadRoot } from '../layouts/Root/withPayloadRoot.js';
|
|
5
5
|
export { payloadAdminIndexRoute, payloadAdminSplatRoute } from '../routes/adminRoutes.js';
|
|
6
6
|
export { payloadLayoutRoute } from '../routes/layoutRoute.js';
|
|
7
7
|
export { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport { TanStackComponentRenderer } from '../elements/RenderComponent/index.js'\nexport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\nexport {\n PayloadAdminShell,\n type PayloadAdminShellProps,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../layouts/Root/withPayloadRoot.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../routes/adminRoutes.js'\nexport { type LayoutLoad, payloadLayoutRoute } from '../routes/layoutRoute.js'\nexport { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js'\nexport {\n createServerFunctionClient,\n stripUnserializable,\n} from '../utilities/serverFunctionClient.js'\n"],"names":["TanStackComponentRenderer","TanStackRouterAdapter","PayloadAdminShell","withPayloadRoot","payloadAdminIndexRoute","payloadAdminSplatRoute","payloadLayoutRoute","viteDevReloadStrategy","createServerFunctionClient","stripUnserializable"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,uCAAsC;AAChF,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SACEC,iBAAiB,EAEjBC,eAAe,QAEV,qCAAoC;AAC3C,SAEEC,sBAAsB,EACtBC,sBAAsB,QACjB,2BAA0B;AACjC,SAA0BC,kBAAkB,QAAQ,2BAA0B;AAC9E,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,uCAAsC"}
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\n\nexport { TanStackComponentRenderer } from '../elements/RenderComponent/index.js'\nexport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\nexport {\n buildThemeInitScript,\n PayloadAdminShell,\n type PayloadAdminShellProps,\n THEME_INIT_SCRIPT,\n withPayloadRoot,\n type WithPayloadRootOptions,\n} from '../layouts/Root/withPayloadRoot.js'\nexport {\n type AdminLoad,\n payloadAdminIndexRoute,\n payloadAdminSplatRoute,\n} from '../routes/adminRoutes.js'\nexport { type LayoutLoad, payloadLayoutRoute } from '../routes/layoutRoute.js'\nexport { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js'\nexport {\n createServerFunctionClient,\n stripUnserializable,\n} from '../utilities/serverFunctionClient.js'\n"],"names":["TanStackComponentRenderer","TanStackRouterAdapter","buildThemeInitScript","PayloadAdminShell","THEME_INIT_SCRIPT","withPayloadRoot","payloadAdminIndexRoute","payloadAdminSplatRoute","payloadLayoutRoute","viteDevReloadStrategy","createServerFunctionClient","stripUnserializable"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,uCAAsC;AAChF,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SACEC,oBAAoB,EACpBC,iBAAiB,EAEjBC,iBAAiB,EACjBC,eAAe,QAEV,qCAAoC;AAC3C,SAEEC,sBAAsB,EACtBC,sBAAsB,QACjB,2BAA0B;AACjC,SAA0BC,kBAAkB,QAAQ,2BAA0B;AAC9E,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,uCAAsC"}
|
package/dist/exports/server.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
6
|
+
export { getRequestTheme } from '../utilities/getRequestTheme.js';
|
|
7
7
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
|
-
export { handleAPIRoute } from '../utilities/handleAPIRoute.
|
|
8
|
+
export { handleAPIRoute } from '../utilities/handleAPIRoute.js';
|
|
9
9
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
10
|
export { getImportMapOutputPath } from '../utilities/importMap.server.js';
|
|
11
11
|
export { initReq } from '../utilities/initReq.server.js';
|
|
@@ -14,5 +14,4 @@ export { type AdminPageMetadata, getAdminMeta } from '../utilities/meta.js';
|
|
|
14
14
|
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
15
15
|
export { createPageRenderServerAdapter, type PageNavIntent, tanstackServerAdapter, } from '../utilities/serverAdapter.server.js';
|
|
16
16
|
export { toSerializable } from '../utilities/toSerializable.js';
|
|
17
|
-
export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
18
17
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/exports/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,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"}
|
package/dist/exports/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
6
|
+
export { getRequestTheme } from '../utilities/getRequestTheme.js';
|
|
7
7
|
export { handleGraphQL } from '../utilities/graphqlHandler.server.js';
|
|
8
|
-
export { handleAPIRoute } from '../utilities/handleAPIRoute.
|
|
8
|
+
export { handleAPIRoute } from '../utilities/handleAPIRoute.js';
|
|
9
9
|
export { handleServerFunctions } from '../utilities/handleServerFunctions.js';
|
|
10
10
|
export { getImportMapOutputPath } from '../utilities/importMap.server.js';
|
|
11
11
|
export { initReq } from '../utilities/initReq.server.js';
|
|
@@ -14,6 +14,5 @@ export { getAdminMeta } from '../utilities/meta.js';
|
|
|
14
14
|
export { serializeForRsc } from '../utilities/serializeForRsc.js';
|
|
15
15
|
export { createPageRenderServerAdapter, tanstackServerAdapter } from '../utilities/serverAdapter.server.js';
|
|
16
16
|
export { toSerializable } from '../utilities/toSerializable.js';
|
|
17
|
-
export { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=server.js.map
|
|
@@ -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 { getRequestTheme } from '../utilities/getRequestTheme.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'\n"],"names":["login","logout","refresh","getRequestI18n","getRequestLocale","getRequestTheme","handleGraphQL","handleAPIRoute","handleServerFunctions","getImportMapOutputPath","initReq","loadAdminPage","getAdminMeta","serializeForRsc","createPageRenderServerAdapter","tanstackServerAdapter","toSerializable"],"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,eAAe,QAAQ,kCAAiC;AACjE,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"}
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLayoutData.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/getLayoutData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,eAAe,EAAe,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getLayoutData.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/getLayoutData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,eAAe,EAAe,MAAM,SAAS,CAAA;AASvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,EAClC,aAAa,EACb,SAAS,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAsF7C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs';
|
|
2
2
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
3
3
|
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
4
|
-
import { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
5
4
|
import { Outlet } from '@tanstack/react-router';
|
|
6
5
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
7
6
|
import { createElement } from 'react';
|
|
7
|
+
import { getRequestTheme } from '../../utilities/getRequestTheme.js';
|
|
8
8
|
import { initReq } from '../../utilities/initReq.server.js';
|
|
9
9
|
/**
|
|
10
10
|
* Fetches all data needed by the root admin layout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig, ServerProps } from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig, ServerProps } from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { Outlet } from '@tanstack/react-router'\nimport { applyLocaleFiltering } from 'payload/shared'\nimport { createElement } from 'react'\n\nimport type { RootLayoutData } from './index.js'\n\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.server.js'\n\nexport type GetLayoutDataArgs = {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}\n\n/**\n * Fetches all data needed by the root admin layout.\n * Call this in your TanStack Start root route loader.\n */\nexport async function getLayoutData({\n configPromise,\n importMap,\n}: GetLayoutDataArgs): Promise<RootLayoutData> {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap })\n\n const theme = getRequestTheme({ config, cookies, headers })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language as AcceptedLanguages,\n })\n }\n return acc\n }, [] as LanguageOptions)\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user ?? true,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Build the custom admin provider tree (`config.admin.components.providers`)\n // nested around the router `<Outlet />`, mirroring the Next adapter's\n // `NestProviders`. Returned as an unrendered element; the caller's server\n // function renders it to an RSC payload (so server-component providers run\n // server-side and client providers wrap the live Outlet). `undefined` when\n // no custom providers are configured — the caller falls back to `<Outlet />`.\n const providerPaths = config.admin?.components?.providers\n let providers: React.ReactNode = undefined\n if (Array.isArray(providerPaths) && providerPaths.length > 0) {\n const serverProps: ServerProps = {\n i18n: req.i18n,\n params: {},\n payload: req.payload,\n permissions,\n searchParams: {},\n server: req.server!,\n user: req.user ?? undefined,\n }\n // Mirror the Next adapter's `NestProviders`: render each configured provider\n // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`\n // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and\n // server components receive `serverProps` while client components get only\n // `clientProps`. Nested around the router `<Outlet />` instead of `children`.\n providers = providerPaths.reduceRight<React.ReactNode>(\n (children, provider) =>\n RenderServerComponent({\n clientProps: { children },\n Component: provider,\n importMap,\n serverProps,\n }),\n createElement(Outlet),\n )\n }\n\n return {\n clientConfig,\n dateFNSKey: req.i18n.dateFNSKey,\n fallbackLang: config.i18n.fallbackLanguage,\n isNavOpen: navPrefs?.open ?? true,\n languageCode,\n languageOptions,\n locale: req.locale ?? undefined,\n permissions,\n providers,\n theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","Outlet","applyLocaleFiltering","createElement","getRequestTheme","initReq","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","theme","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAGA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,aAAa,QAAQ,QAAO;AAIrC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,OAAO,QAAQ,oCAAmC;AAO3D;;;CAGC,GACD,OAAO,eAAeC,cAAc,EAClCC,aAAa,EACbC,SAAS,EACS;IAClB,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,GAAG,MAAMV,QAAQ;QAAEE;QAAeC;IAAU;IAE7C,MAAMQ,QAAQZ,gBAAgB;QAAEW;QAAQN;QAASC;IAAQ;IAEzD,MAAMO,kBAAmCC,OAAOC,OAAO,CACrDJ,OAAOK,IAAI,CAACC,kBAAkB,IAAI,CAAC,GACnCC,MAAM,CAAC,CAACC,KAAK,CAACC,UAAUC,eAAe;QACvC,IAAIP,OAAOQ,IAAI,CAACX,OAAOK,IAAI,CAACC,kBAAkB,EAAEM,QAAQ,CAACH,WAAW;YAClED,IAAIK,IAAI,CAAC;gBACPC,OAAOJ,eAAeK,YAAY,CAACC,OAAO,CAACC,YAAY;gBACvDC,OAAOT;YACT;QACF;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import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { rtlLanguages } from '@payloadcms/translations';
|
|
2
3
|
import { ProgressBar, RootProvider } from '@payloadcms/ui';
|
|
3
|
-
import { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import '@payloadcms/ui/scss/app.scss';
|
|
6
6
|
import { TanStackRouterAdapter } from '../../elements/RouterAdapter/index.js';
|
|
7
7
|
export function RootLayout({ children, data, serverFunction }) {
|
|
8
|
-
const dir =
|
|
9
|
-
languageCode: data.languageCode
|
|
10
|
-
});
|
|
8
|
+
const dir = rtlLanguages.includes(data.languageCode) ? 'RTL' : 'LTR';
|
|
11
9
|
return /*#__PURE__*/ _jsxs("html", {
|
|
12
10
|
"data-theme": data.theme,
|
|
13
11
|
dir: dir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type { Theme } from '@payloadcms/ui'\nimport type {\n ClientConfig,\n LanguageOptions,\n SanitizedPermissions,\n ServerFunctionClient,\n User,\n} from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type { Theme } from '@payloadcms/ui'\nimport type {\n ClientConfig,\n LanguageOptions,\n SanitizedPermissions,\n ServerFunctionClient,\n User,\n} from 'payload'\n\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport React from 'react'\nimport '@payloadcms/ui/scss/app.scss'\n\nimport { TanStackRouterAdapter } from '../../elements/RouterAdapter/index.js'\n\nexport type RootLayoutData = {\n clientConfig: ClientConfig\n dateFNSKey: I18nClient['dateFNSKey']\n fallbackLang: string\n isNavOpen: boolean\n languageCode: string\n languageOptions: LanguageOptions\n locale?: string\n permissions: SanitizedPermissions\n /**\n * Custom admin provider tree (`config.admin.components.providers`) nested\n * around the router `<Outlet />`. Built unrendered by `getLayoutData`; the\n * layout server function renders it to an RSC payload before it reaches the\n * client. `undefined` when no custom providers are configured.\n */\n providers?: React.ReactNode\n theme: Theme\n translations: I18nClient['translations']\n user: null | User\n}\n\nexport type RootLayoutProps = {\n readonly children: React.ReactNode\n readonly data: RootLayoutData\n readonly serverFunction: ServerFunctionClient\n}\n\nexport function RootLayout({ children, data, serverFunction }: RootLayoutProps) {\n const dir = (rtlLanguages as unknown as string[]).includes(data.languageCode) ? 'RTL' : 'LTR'\n\n return (\n <html data-theme={data.theme} dir={dir} lang={data.languageCode} suppressHydrationWarning>\n <head>\n <style>{`@layer payload-default, payload;`}</style>\n </head>\n <body>\n <RootProvider\n config={data.clientConfig}\n dateFNSKey={data.dateFNSKey}\n fallbackLang={data.fallbackLang as AcceptedLanguages}\n highContrastMode={false}\n isNavOpen={data.isNavOpen}\n languageCode={data.languageCode}\n languageOptions={data.languageOptions}\n locale={data.locale}\n permissions={(data.user ? data.permissions : null) as unknown as SanitizedPermissions}\n RouterAdapter={TanStackRouterAdapter}\n serverFunction={serverFunction}\n theme={data.theme}\n translations={data.translations}\n user={data.user}\n >\n <ProgressBar />\n {children}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"names":["rtlLanguages","ProgressBar","RootProvider","React","TanStackRouterAdapter","RootLayout","children","data","serverFunction","dir","includes","languageCode","html","data-theme","theme","lang","suppressHydrationWarning","head","style","body","config","clientConfig","dateFNSKey","fallbackLang","highContrastMode","isNavOpen","languageOptions","locale","permissions","user","RouterAdapter","translations","div","id"],"mappings":";AAUA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,WAAW,EAAEC,YAAY,QAAQ,iBAAgB;AAC1D,OAAOC,WAAW,QAAO;AACzB,OAAO,+BAA8B;AAErC,SAASC,qBAAqB,QAAQ,wCAAuC;AA6B7E,OAAO,SAASC,WAAW,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,cAAc,EAAmB;IAC5E,MAAMC,MAAM,AAACT,aAAqCU,QAAQ,CAACH,KAAKI,YAAY,IAAI,QAAQ;IAExF,qBACE,MAACC;QAAKC,cAAYN,KAAKO,KAAK;QAAEL,KAAKA;QAAKM,MAAMR,KAAKI,YAAY;QAAEK,wBAAwB;;0BACvF,KAACC;0BACC,cAAA,KAACC;8BAAO,CAAC,gCAAgC,CAAC;;;0BAE5C,MAACC;;kCACC,MAACjB;wBACCkB,QAAQb,KAAKc,YAAY;wBACzBC,YAAYf,KAAKe,UAAU;wBAC3BC,cAAchB,KAAKgB,YAAY;wBAC/BC,kBAAkB;wBAClBC,WAAWlB,KAAKkB,SAAS;wBACzBd,cAAcJ,KAAKI,YAAY;wBAC/Be,iBAAiBnB,KAAKmB,eAAe;wBACrCC,QAAQpB,KAAKoB,MAAM;wBACnBC,aAAcrB,KAAKsB,IAAI,GAAGtB,KAAKqB,WAAW,GAAG;wBAC7CE,eAAe1B;wBACfI,gBAAgBA;wBAChBM,OAAOP,KAAKO,KAAK;wBACjBiB,cAAcxB,KAAKwB,YAAY;wBAC/BF,MAAMtB,KAAKsB,IAAI;;0CAEf,KAAC5B;4BACAK;;;kCAEH,KAAC0B;wBAAIC,IAAG;;;;;;AAIhB"}
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`
|
|
4
|
+
* on `<html>` synchronously, before first paint, from Payload's theme and
|
|
5
|
+
* language cookies. This is the no-flash equivalent of what `RootProvider`'s
|
|
6
|
+
* `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd
|
|
7
|
+
* document head so the admin panel never flashes light mode (or LTR for RTL
|
|
8
|
+
* locales) on the first render. Mirrors `detectTheme` in
|
|
9
|
+
* `@payloadcms/ui`'s `ThemeProvider`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildThemeInitScript(cookiePrefix?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The no-flash theme bootstrap script for the default (`payload`) cookie
|
|
14
|
+
* prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the
|
|
15
|
+
* document `<head>` to set `data-theme`/`lang`/`dir` before first paint.
|
|
16
|
+
*/
|
|
17
|
+
export declare const THEME_INIT_SCRIPT: string;
|
|
2
18
|
export type PayloadAdminShellProps = {
|
|
3
19
|
readonly children: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The `config.cookiePrefix` used to read the theme/language cookies in the
|
|
22
|
+
* no-flash bootstrap script. Defaults to `'payload'`.
|
|
23
|
+
*/
|
|
24
|
+
readonly cookiePrefix?: string;
|
|
4
25
|
};
|
|
5
26
|
/**
|
|
6
27
|
* The `<html>` document shell for Payload admin routes — the TanStack Start
|
|
7
|
-
* equivalent of `@payloadcms/next`'s root layout `<html>`.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* client bootstrap script — the same server-side path Next's `RootLayout`
|
|
12
|
-
* uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
|
|
28
|
+
* equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash
|
|
29
|
+
* theme script, the `@layer` ordering style, `@payloadcms/ui` styles,
|
|
30
|
+
* `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of
|
|
31
|
+
* the admin tree) as `children`.
|
|
13
32
|
*/
|
|
14
|
-
export declare function PayloadAdminShell({ children }: PayloadAdminShellProps): React.JSX.Element;
|
|
33
|
+
export declare function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps): React.JSX.Element;
|
|
15
34
|
export type WithPayloadRootOptions = {
|
|
16
35
|
/**
|
|
17
36
|
* Path prefix that mounts the Payload admin panel (`config.routes.admin`).
|
|
@@ -19,6 +38,11 @@ export type WithPayloadRootOptions = {
|
|
|
19
38
|
* renders your own shell. Defaults to `'/admin'`.
|
|
20
39
|
*/
|
|
21
40
|
adminRoute?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The `config.cookiePrefix` used by the no-flash theme bootstrap script.
|
|
43
|
+
* Defaults to `'payload'`.
|
|
44
|
+
*/
|
|
45
|
+
cookiePrefix?: string;
|
|
22
46
|
};
|
|
23
47
|
/**
|
|
24
48
|
* Wraps your application's root document shell so Payload owns its own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,GAAE,MAAkB,GAAG,MAAM,CAG7E;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAA+B,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,sBAAsB,qBAmBnF;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,EAC7D,OAAO,GAAE,sBAA2B,kBAIW;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { rtlLanguages } from '@payloadcms/translations';
|
|
4
4
|
import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`
|
|
8
|
+
* on `<html>` synchronously, before first paint, from Payload's theme and
|
|
9
|
+
* language cookies. This is the no-flash equivalent of what `RootProvider`'s
|
|
10
|
+
* `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd
|
|
11
|
+
* document head so the admin panel never flashes light mode (or LTR for RTL
|
|
12
|
+
* locales) on the first render. Mirrors `detectTheme` in
|
|
13
|
+
* `@payloadcms/ui`'s `ThemeProvider`.
|
|
14
|
+
*/ export function buildThemeInitScript(cookiePrefix = 'payload') {
|
|
15
|
+
const rtl = JSON.stringify(rtlLanguages);
|
|
16
|
+
return `(function(){try{var d=document.documentElement;var c=document.cookie.split('; ');function r(n){var row=c.find(function(x){return x.indexOf(n+'=')===0});return row?row.split('=')[1]:null}var t=r('${cookiePrefix}-theme');if(t!=='light'&&t!=='dark'){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}d.setAttribute('data-theme',t);var l=r('${cookiePrefix}-lng');if(l){d.setAttribute('lang',l);d.setAttribute('dir',${rtl}.indexOf(l)!==-1?'rtl':'ltr')}}catch(e){}})()`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The no-flash theme bootstrap script for the default (`payload`) cookie
|
|
20
|
+
* prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the
|
|
21
|
+
* document `<head>` to set `data-theme`/`lang`/`dir` before first paint.
|
|
22
|
+
*/ export const THEME_INIT_SCRIPT = buildThemeInitScript();
|
|
6
23
|
/**
|
|
7
24
|
* The `<html>` document shell for Payload admin routes — the TanStack Start
|
|
8
|
-
* equivalent of `@payloadcms/next`'s root layout `<html>`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (const match of state.matches){
|
|
18
|
-
const data = match.loaderData;
|
|
19
|
-
if (data?.theme && data?.languageCode) {
|
|
20
|
-
return {
|
|
21
|
-
'data-theme': data.theme,
|
|
22
|
-
dir: getLanguageDir({
|
|
23
|
-
languageCode: data.languageCode
|
|
24
|
-
}),
|
|
25
|
-
lang: data.languageCode
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// No layout data yet (fresh session before the loader resolves): default
|
|
30
|
-
// to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the
|
|
31
|
-
// document sidebar divider) still match, matching Next's `ltr` default.
|
|
32
|
-
return {
|
|
33
|
-
dir: 'ltr'
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return(// eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available
|
|
25
|
+
* equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash
|
|
26
|
+
* theme script, the `@layer` ordering style, `@payloadcms/ui` styles,
|
|
27
|
+
* `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of
|
|
28
|
+
* the admin tree) as `children`.
|
|
29
|
+
*/ export function PayloadAdminShell({ children, cookiePrefix }) {
|
|
30
|
+
const themeInitScript = cookiePrefix ? buildThemeInitScript(cookiePrefix) : THEME_INIT_SCRIPT;
|
|
31
|
+
return(// `lang`/`dir` are set on `<html>` by `themeInitScript` before first paint
|
|
32
|
+
// from the `*-lng` cookie, so a static `lang` here would be incorrect.
|
|
33
|
+
// eslint-disable-next-line jsx-a11y/html-has-lang -- set dynamically by the inline bootstrap script
|
|
38
34
|
/*#__PURE__*/ _jsxs("html", {
|
|
39
|
-
...htmlProps,
|
|
40
35
|
suppressHydrationWarning: true,
|
|
41
36
|
children: [
|
|
42
37
|
/*#__PURE__*/ _jsxs("head", {
|
|
43
38
|
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx("script", {
|
|
40
|
+
dangerouslySetInnerHTML: {
|
|
41
|
+
__html: themeInitScript
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
44
|
/*#__PURE__*/ _jsx("style", {
|
|
45
45
|
children: `@layer payload-default, payload;`
|
|
46
46
|
}),
|
|
@@ -69,7 +69,7 @@ import React from 'react';
|
|
|
69
69
|
* })
|
|
70
70
|
* ```
|
|
71
71
|
*/ export function withPayloadRoot(RootShell, options = {}) {
|
|
72
|
-
const { adminRoute = '/admin' } = options;
|
|
72
|
+
const { adminRoute = '/admin', cookiePrefix } = options;
|
|
73
73
|
return function PayloadRootShell({ children }) {
|
|
74
74
|
const isAdminRoute = useRouterState({
|
|
75
75
|
select: (s)=>{
|
|
@@ -79,6 +79,7 @@ import React from 'react';
|
|
|
79
79
|
});
|
|
80
80
|
if (isAdminRoute) {
|
|
81
81
|
return /*#__PURE__*/ _jsx(PayloadAdminShell, {
|
|
82
|
+
cookiePrefix: cookiePrefix,
|
|
82
83
|
children: children
|
|
83
84
|
});
|
|
84
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\n/**\n * Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`\n * on `<html>` synchronously, before first paint, from Payload's theme and\n * language cookies. This is the no-flash equivalent of what `RootProvider`'s\n * `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd\n * document head so the admin panel never flashes light mode (or LTR for RTL\n * locales) on the first render. Mirrors `detectTheme` in\n * `@payloadcms/ui`'s `ThemeProvider`.\n */\nexport function buildThemeInitScript(cookiePrefix: string = 'payload'): string {\n const rtl = JSON.stringify(rtlLanguages)\n return `(function(){try{var d=document.documentElement;var c=document.cookie.split('; ');function r(n){var row=c.find(function(x){return x.indexOf(n+'=')===0});return row?row.split('=')[1]:null}var t=r('${cookiePrefix}-theme');if(t!=='light'&&t!=='dark'){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}d.setAttribute('data-theme',t);var l=r('${cookiePrefix}-lng');if(l){d.setAttribute('lang',l);d.setAttribute('dir',${rtl}.indexOf(l)!==-1?'rtl':'ltr')}}catch(e){}})()`\n}\n\n/**\n * The no-flash theme bootstrap script for the default (`payload`) cookie\n * prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the\n * document `<head>` to set `data-theme`/`lang`/`dir` before first paint.\n */\nexport const THEME_INIT_SCRIPT: string = buildThemeInitScript()\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n /**\n * The `config.cookiePrefix` used to read the theme/language cookies in the\n * no-flash bootstrap script. Defaults to `'payload'`.\n */\n readonly cookiePrefix?: string\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash\n * theme script, the `@layer` ordering style, `@payloadcms/ui` styles,\n * `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of\n * the admin tree) as `children`.\n */\nexport function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps) {\n const themeInitScript = cookiePrefix ? buildThemeInitScript(cookiePrefix) : THEME_INIT_SCRIPT\n\n return (\n // `lang`/`dir` are set on `<html>` by `themeInitScript` before first paint\n // from the `*-lng` cookie, so a static `lang` here would be incorrect.\n // eslint-disable-next-line jsx-a11y/html-has-lang -- set dynamically by the inline bootstrap script\n <html suppressHydrationWarning>\n <head>\n <script dangerouslySetInnerHTML={{ __html: themeInitScript }} />\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n /**\n * The `config.cookiePrefix` used by the no-flash theme bootstrap script.\n * Defaults to `'payload'`.\n */\n cookiePrefix?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin', cookiePrefix } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell cookiePrefix={cookiePrefix}>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["rtlLanguages","HeadContent","Scripts","useRouterState","React","buildThemeInitScript","cookiePrefix","rtl","JSON","stringify","THEME_INIT_SCRIPT","PayloadAdminShell","children","themeInitScript","html","suppressHydrationWarning","head","script","dangerouslySetInnerHTML","__html","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","select","s","pathname","location","startsWith"],"mappings":"AAAA;;AACA,SAASA,YAAY,QAAQ,2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ACF"}
|
|
@@ -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,10 @@
|
|
|
1
|
+
import type { Theme } from '@payloadcms/ui';
|
|
2
|
+
import type { SanitizedConfig } from 'payload';
|
|
3
|
+
type GetRequestThemeArgs = {
|
|
4
|
+
config: SanitizedConfig;
|
|
5
|
+
cookies: Map<string, string>;
|
|
6
|
+
headers: Headers;
|
|
7
|
+
};
|
|
8
|
+
export declare function getRequestTheme({ config, cookies, headers }: GetRequestThemeArgs): Theme;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=getRequestTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRequestTheme.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAUD,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAkBxF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Defined locally rather than imported from `@payloadcms/ui` (a `'use client'`
|
|
2
|
+
// barrel) because its value exports resolve to non-serializable client
|
|
3
|
+
// references in this adapter's RSC server context. `Theme` is a type-only
|
|
4
|
+
// import and is safely erased at runtime.
|
|
5
|
+
const defaultTheme = 'light';
|
|
6
|
+
const acceptedThemes = [
|
|
7
|
+
'dark',
|
|
8
|
+
'light'
|
|
9
|
+
];
|
|
10
|
+
export function getRequestTheme({ config, cookies, headers }) {
|
|
11
|
+
if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {
|
|
12
|
+
return config.admin.theme;
|
|
13
|
+
}
|
|
14
|
+
const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`);
|
|
15
|
+
if (themeCookie && acceptedThemes.includes(themeCookie)) {
|
|
16
|
+
return themeCookie;
|
|
17
|
+
}
|
|
18
|
+
const themeFromHeader = headers.get('Sec-CH-Prefers-Color-Scheme');
|
|
19
|
+
if (themeFromHeader && acceptedThemes.includes(themeFromHeader)) {
|
|
20
|
+
return themeFromHeader;
|
|
21
|
+
}
|
|
22
|
+
return defaultTheme;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=getRequestTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getRequestTheme.ts"],"sourcesContent":["import type { Theme } from '@payloadcms/ui'\nimport type { SanitizedConfig } from 'payload'\n\ntype GetRequestThemeArgs = {\n config: SanitizedConfig\n cookies: Map<string, string>\n headers: Headers\n}\n\n// Defined locally rather than imported from `@payloadcms/ui` (a `'use client'`\n// barrel) because its value exports resolve to non-serializable client\n// references in this adapter's RSC server context. `Theme` is a type-only\n// import and is safely erased at runtime.\nconst defaultTheme: Theme = 'light'\n\nconst acceptedThemes: Theme[] = ['dark', 'light']\n\nexport function getRequestTheme({ config, cookies, headers }: GetRequestThemeArgs): Theme {\n if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {\n return config.admin.theme\n }\n\n const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`)\n\n if (themeCookie && acceptedThemes.includes(themeCookie as Theme)) {\n return themeCookie as Theme\n }\n\n const themeFromHeader = headers.get('Sec-CH-Prefers-Color-Scheme') as Theme\n\n if (themeFromHeader && acceptedThemes.includes(themeFromHeader)) {\n return themeFromHeader\n }\n\n return defaultTheme\n}\n"],"names":["defaultTheme","acceptedThemes","getRequestTheme","config","cookies","headers","admin","theme","includes","themeCookie","get","cookiePrefix","themeFromHeader"],"mappings":"AASA,+EAA+E;AAC/E,uEAAuE;AACvE,0EAA0E;AAC1E,0CAA0C;AAC1C,MAAMA,eAAsB;AAE5B,MAAMC,iBAA0B;IAAC;IAAQ;CAAQ;AAEjD,OAAO,SAASC,gBAAgB,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAuB;IAC/E,IAAIF,OAAOG,KAAK,CAACC,KAAK,KAAK,SAASN,eAAeO,QAAQ,CAACL,OAAOG,KAAK,CAACC,KAAK,GAAG;QAC/E,OAAOJ,OAAOG,KAAK,CAACC,KAAK;IAC3B;IAEA,MAAME,cAAcL,QAAQM,GAAG,CAAC,GAAGP,OAAOQ,YAAY,IAAI,UAAU,MAAM,CAAC;IAE3E,IAAIF,eAAeR,eAAeO,QAAQ,CAACC,cAAuB;QAChE,OAAOA;IACT;IAEA,MAAMG,kBAAkBP,QAAQK,GAAG,CAAC;IAEpC,IAAIE,mBAAmBX,eAAeO,QAAQ,CAACI,kBAAkB;QAC/D,OAAOA;IACT;IAEA,OAAOZ;AACT"}
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { getViewportContent } from '@payloadcms/ui/
|
|
1
|
+
import { getViewportContent } from '@payloadcms/ui/layouts';
|
|
2
2
|
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
3
3
|
import { getRequestI18n } from './getRequestI18n.server.js';
|
|
4
4
|
import { initReq } from './initReq.server.js';
|
|
@@ -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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3C,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 { getViewportContent } from '@payloadcms/ui/layouts'\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,yBAAwB;AAC3D,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,QAA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O,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"}
|
package/dist/utilities/meta.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getViewportContent } from '@payloadcms/ui/
|
|
1
|
+
import { getViewportContent } from '@payloadcms/ui/layouts';
|
|
2
2
|
/**
|
|
3
3
|
* Builds TanStack Router `head()` `meta` + `links` entries for an admin page
|
|
4
4
|
* from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["import { getViewportContent } from '@payloadcms/ui/
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["import { getViewportContent } from '@payloadcms/ui/layouts'\n\ntype 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 viewport?: 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: metadata?.viewport ?? getViewportContent() },\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":["getViewportContent","getAdminMeta","metadata","meta","charSet","name","content","viewport","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":"AAAA,SAASA,kBAAkB,QAAQ,yBAAwB;AAsD3D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAASJ,UAAUK,YAAYP;QAAqB;KACzE;IACD,MAAMQ,QAAqB,EAAE;IAE7B,IAAI,CAACN,UAAU;QACb,OAAO;YAAEM;YAAOL;QAAK;IACvB;IAEA,IAAID,SAASO,KAAK,EAAE;QAClBN,KAAKO,IAAI,CAAC;YAAED,OAAOP,SAASO,KAAK;QAAC;IACpC;IACA,IAAIP,SAASS,WAAW,EAAE;QACxBR,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAeC,SAASJ,SAASS,WAAW;QAAC;IACjE;IACA,IAAIT,SAASU,QAAQ,EAAE;QACrBT,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAYC,SAASJ,SAASU,QAAQ;QAAC;IAC3D;IACA,IAAIV,SAASW,MAAM,EAAE;QACnBV,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAUC,SAASJ,SAASW,MAAM;QAAC;IACvD;IAEA,MAAMC,KAAKZ,SAASa,SAAS;IAC7B,IAAID,IAAI;QACN,IAAIA,GAAGL,KAAK,EAAE;YACZN,KAAKO,IAAI,CAAC;gBAAEJ,SAASQ,GAAGL,KAAK;gBAAEO,UAAU;YAAW;QACtD;QACA,IAAIF,GAAGH,WAAW,EAAE;YAClBR,KAAKO,IAAI,CAAC;gBAAEJ,SAASQ,GAAGH,WAAW;gBAAE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KH,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;QAAOL;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;AACjE,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mapp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;;;;;;;;;;;;;;;;;;;;;;;;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,CAACL,KAAKS;QAClB,IAAI,CAACV,eAAeC,MAAM;YACxBI,SAASJ,KAAKS;QAChB;IACF;IACAX,OAAOU,QAAQ,GAAG,CAACR,KAAKS;QACtB,IAAI,CAACV,eAAeC,MAAM;YACxBO,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E;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,kFAAk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C9E;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.cd69eef",
|
|
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.cd69eef",
|
|
62
|
+
"@payloadcms/ui": "4.0.0-internal.cd69eef"
|
|
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.cd69eef"
|
|
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.cd69eef"
|
|
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"}
|