@payloadcms/tanstack-start 4.0.0-internal.183b315 → 4.0.0-internal.688c4d0

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.
Files changed (33) hide show
  1. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  2. package/dist/elements/RouterAdapter/index.js +38 -15
  3. package/dist/elements/RouterAdapter/index.js.map +1 -1
  4. package/dist/exports/client.d.ts +1 -0
  5. package/dist/exports/client.d.ts.map +1 -1
  6. package/dist/exports/client.js +1 -0
  7. package/dist/exports/client.js.map +1 -1
  8. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  9. package/dist/layouts/Root/getLayoutData.js +36 -0
  10. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  11. package/dist/layouts/Root/index.d.ts +7 -0
  12. package/dist/layouts/Root/index.d.ts.map +1 -1
  13. package/dist/layouts/Root/index.js.map +1 -1
  14. package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
  15. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  16. package/dist/layouts/Root/withPayloadRoot.js +92 -0
  17. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  18. package/dist/utilities/serializeForRsc.d.ts.map +1 -1
  19. package/dist/utilities/serializeForRsc.js +17 -0
  20. package/dist/utilities/serializeForRsc.js.map +1 -1
  21. package/dist/vite/constants.d.ts.map +1 -1
  22. package/dist/vite/constants.js +29 -1
  23. package/dist/vite/constants.js.map +1 -1
  24. package/dist/vite/plugin.js +2 -1
  25. package/dist/vite/plugin.js.map +1 -1
  26. package/dist/vite/plugins/devTransforms.d.ts +11 -0
  27. package/dist/vite/plugins/devTransforms.d.ts.map +1 -1
  28. package/dist/vite/plugins/devTransforms.js +13 -2
  29. package/dist/vite/plugins/devTransforms.js.map +1 -1
  30. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -1
  31. package/dist/vite/plugins/stripDistStyleImports.js +20 -2
  32. package/dist/vite/plugins/stripDistStyleImports.js.map +1 -1
  33. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterAdapter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAsDvE,eAAO,MAAM,qBAAqB,EAAE,sBA+DnC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterAdapter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAuDvE,eAAO,MAAM,qBAAqB,EAAE,sBA+EnC,CAAA"}
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { RouterAdapterContext } from '@payloadcms/ui';
4
4
  import { Link as TanStackLink, useLocation, useParams, useRouter } from '@tanstack/react-router';
5
+ import * as qs from 'qs-esm';
5
6
  import React, { useCallback, useMemo } from 'react';
6
7
  const normalizeNavigationTarget = ({ path, pathname, search })=>{
7
8
  if (path.startsWith('http')) {
@@ -44,21 +45,47 @@ export const TanStackRouterAdapter = ({ children })=>{
44
45
  }, [
45
46
  params
46
47
  ]);
47
- const back = useCallback(()=>router.history.back(), [
48
- router
49
- ]);
50
- const push = useCallback((path, options)=>{
48
+ // Split a target into `to` (pathname) + a parsed `search` object, so the
49
+ // router serializes the query via its `stringifySearch` (qs, bracket-encoded)
50
+ // rather than embedding the raw string in `to`. Navigating with a string `to`
51
+ // leaves the search *unencoded* in `window.location.search`
52
+ // (e.g. `where[or][0]…`), which then never matches Payload's `qs.stringify`
53
+ // output (`where%5Bor%5D…`) — breaking the list-view `syncPropsToURL` guard,
54
+ // which compares the two and would otherwise clobber optimistic query state
55
+ // (e.g. an in-progress filter condition) on every navigation.
56
+ const toNavOptions = useCallback((path)=>{
51
57
  const relativePath = normalizeNavigationTarget({
52
58
  path,
53
59
  pathname: window.location.pathname,
54
60
  search: window.location.search
55
61
  });
62
+ const queryIndex = relativePath.indexOf('?');
63
+ if (queryIndex === -1) {
64
+ return {
65
+ to: relativePath
66
+ };
67
+ }
68
+ const searchObject = qs.parse(relativePath.slice(queryIndex + 1), {
69
+ depth: 10,
70
+ ignoreQueryPrefix: true
71
+ });
72
+ // Function form replaces the search entirely (no merge with current search).
73
+ return {
74
+ search: ()=>searchObject,
75
+ to: relativePath.slice(0, queryIndex)
76
+ };
77
+ }, []);
78
+ const back = useCallback(()=>router.history.back(), [
79
+ router
80
+ ]);
81
+ const push = useCallback((path, options)=>{
56
82
  void router.navigate({
57
- resetScroll: options?.scroll,
58
- to: relativePath
83
+ ...toNavOptions(path),
84
+ resetScroll: options?.scroll
59
85
  });
60
86
  }, [
61
- router
87
+ router,
88
+ toNavOptions
62
89
  ]);
63
90
  const refresh = useCallback(()=>{
64
91
  void router.invalidate();
@@ -66,18 +93,14 @@ export const TanStackRouterAdapter = ({ children })=>{
66
93
  router
67
94
  ]);
68
95
  const replace = useCallback((path, options)=>{
69
- const relativePath = normalizeNavigationTarget({
70
- path,
71
- pathname: window.location.pathname,
72
- search: window.location.search
73
- });
74
96
  void router.navigate({
97
+ ...toNavOptions(path),
75
98
  replace: true,
76
- resetScroll: options?.scroll,
77
- to: relativePath
99
+ resetScroll: options?.scroll
78
100
  });
79
101
  }, [
80
- router
102
+ router,
103
+ toNavOptions
81
104
  ]);
82
105
  const adaptedRouter = useMemo(()=>({
83
106
  back,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/elements/RouterAdapter/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps, RouterAdapterComponent } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui'\nimport { Link as TanStackLink, useLocation, useParams, useRouter } from '@tanstack/react-router'\nimport React, { useCallback, useMemo } from 'react'\n\nconst normalizeNavigationTarget = ({\n path,\n pathname,\n search,\n}: {\n path: string\n pathname: string\n search: string\n}) => {\n if (path.startsWith('http')) {\n const url = new URL(path)\n return `${url.pathname}${url.search}${url.hash}`\n }\n\n if (path.startsWith('?')) {\n return `${pathname}${path}`\n }\n\n if (path.startsWith('#')) {\n return `${pathname}${search}${path}`\n }\n\n return path\n}\n\nconst TanStackLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <TanStackLink\n preload={prefetch === false ? false : 'intent'}\n ref={ref}\n replace={replace}\n resetScroll={scroll}\n to={href}\n {...rest}\n >\n {children}\n </TanStackLink>\n )\n}\n\nexport const TanStackRouterAdapter: RouterAdapterComponent = ({ children }) => {\n const router = useRouter()\n const location = useLocation()\n const params = useParams({ strict: false })\n\n const adaptedParams = useMemo(() => {\n const adapted: Record<string, string | string[]> = { ...params }\n if ('_splat' in params && typeof params._splat === 'string') {\n adapted.segments = params._splat.split('/').filter(Boolean)\n }\n return adapted\n }, [params])\n\n const back = useCallback(() => router.history.back(), [router])\n const push = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n const relativePath = normalizeNavigationTarget({\n path,\n pathname: window.location.pathname,\n search: window.location.search,\n })\n void router.navigate({ resetScroll: options?.scroll, to: relativePath })\n },\n [router],\n )\n const refresh = useCallback(() => {\n void router.invalidate()\n }, [router])\n const replace = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n const relativePath = normalizeNavigationTarget({\n path,\n pathname: window.location.pathname,\n search: window.location.search,\n })\n void router.navigate({ replace: true, resetScroll: options?.scroll, to: relativePath })\n },\n [router],\n )\n\n const adaptedRouter = useMemo(\n () => ({ back, push, refresh, replace }),\n [back, push, refresh, replace],\n )\n\n // `location.searchStr` is the serialized query string; `location.search` is\n // the parsed object (a nested structure once the router uses `qs` for search\n // serialization), which `URLSearchParams` cannot consume. Build from the\n // string so Payload's `parseSearchParams` re-parses the bracket notation.\n const searchParams = useMemo(() => new URLSearchParams(location.searchStr), [location.searchStr])\n\n const value: RouterAdapterContextValue = useMemo(\n () => ({\n Link: TanStackLinkAdapter,\n params: adaptedParams,\n pathname: location.pathname,\n router: adaptedRouter,\n searchParams,\n }),\n [adaptedParams, location.pathname, adaptedRouter, searchParams],\n )\n\n return <RouterAdapterContext value={value}>{children}</RouterAdapterContext>\n}\n"],"names":["RouterAdapterContext","Link","TanStackLink","useLocation","useParams","useRouter","React","useCallback","useMemo","normalizeNavigationTarget","path","pathname","search","startsWith","url","URL","hash","TanStackLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","preload","resetScroll","to","TanStackRouterAdapter","router","location","params","strict","adaptedParams","adapted","_splat","segments","split","filter","Boolean","back","history","push","options","relativePath","window","navigate","refresh","invalidate","adaptedRouter","searchParams","URLSearchParams","searchStr","value"],"mappings":"AAAA;;AAKA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,QAAQC,YAAY,EAAEC,WAAW,EAAEC,SAAS,EAAEC,SAAS,QAAQ,yBAAwB;AAChG,OAAOC,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAO;AAEnD,MAAMC,4BAA4B,CAAC,EACjCC,IAAI,EACJC,QAAQ,EACRC,MAAM,EAKP;IACC,IAAIF,KAAKG,UAAU,CAAC,SAAS;QAC3B,MAAMC,MAAM,IAAIC,IAAIL;QACpB,OAAO,GAAGI,IAAIH,QAAQ,GAAGG,IAAIF,MAAM,GAAGE,IAAIE,IAAI,EAAE;IAClD;IAEA,IAAIN,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWD,MAAM;IAC7B;IAEA,IAAIA,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWC,SAASF,MAAM;IACtC;IAEA,OAAOA;AACT;AAEA,MAAMO,sBAAkD,CAAC,EACvDC,QAAQ,EACRC,IAAI,EACJC,QAAQ,EACRC,GAAG,EACHC,OAAO,EACPC,MAAM,EACN,GAAGC,MACJ;IACC,qBACE,KAACtB;QACCuB,SAASL,aAA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GV,MAAMoB,gBAAgBzC,QACpB,IAAO,CAAA;YAAEgC;YAAME;YAAMK;YAASzB;QAAQ,CAAA,GACtC;QAACkB;QAAME;QAAMK;QAASzB;KAAQ;IAGhC,4EAA4E;IAC5E,6EAA6E;IAC7E,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM4B,eAAe1C,QAAQ,IAAM,IAAI2C,gBAAgBrB,SAASsB,SAAS,GAAG;QAACtB,SAASsB,SAAS;KAAC;IAEhG,MAAMC,QAAmC7C,QACvC,IAAO,CAAA;YACLP,MAAMgB;YACNc,QAAQE;YACRtB,UAAUmB,SAASnB,QAAQ;YAC3BkB,QAAQoB;YACRC;QACF,CAAA,GACA;QAACjB;QAAeH,SAASnB,QAAQ;QAAEsC;QAAeC;KAAa;IAGjE,qBAAO,KAAClD;QAAqBqD,OAAOA;kBAAQnC;;AAC9C,EAAC"}
1
+ {"version":3,"sources":["../../../src/elements/RouterAdapter/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps, RouterAdapterComponent } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui'\nimport { Link as TanStackLink, useLocation, useParams, useRouter } from '@tanstack/react-router'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo } from 'react'\n\nconst normalizeNavigationTarget = ({\n path,\n pathname,\n search,\n}: {\n path: string\n pathname: string\n search: string\n}) => {\n if (path.startsWith('http')) {\n const url = new URL(path)\n return `${url.pathname}${url.search}${url.hash}`\n }\n\n if (path.startsWith('?')) {\n return `${pathname}${path}`\n }\n\n if (path.startsWith('#')) {\n return `${pathname}${search}${path}`\n }\n\n return path\n}\n\nconst TanStackLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <TanStackLink\n preload={prefetch === false ? false : 'intent'}\n ref={ref}\n replace={replace}\n resetScroll={scroll}\n to={href}\n {...rest}\n >\n {children}\n </TanStackLink>\n )\n}\n\nexport const TanStackRouterAdapter: RouterAdapterComponent = ({ children }) => {\n const router = useRouter()\n const location = useLocation()\n const params = useParams({ strict: false })\n\n const adaptedParams = useMemo(() => {\n const adapted: Record<string, string | string[]> = { ...params }\n if ('_splat' in params && typeof params._splat === 'string') {\n adapted.segments = params._splat.split('/').filter(Boolean)\n }\n return adapted\n }, [params])\n\n // Split a target into `to` (pathname) + a parsed `search` object, so the\n // router serializes the query via its `stringifySearch` (qs, bracket-encoded)\n // rather than embedding the raw string in `to`. Navigating with a string `to`\n // leaves the search *unencoded* in `window.location.search`\n // (e.g. `where[or][0]…`), which then never matches Payload's `qs.stringify`\n // output (`where%5Bor%5D…`) — breaking the list-view `syncPropsToURL` guard,\n // which compares the two and would otherwise clobber optimistic query state\n // (e.g. an in-progress filter condition) on every navigation.\n const toNavOptions = useCallback((path: string) => {\n const relativePath = normalizeNavigationTarget({\n path,\n pathname: window.location.pathname,\n search: window.location.search,\n })\n const queryIndex = relativePath.indexOf('?')\n if (queryIndex === -1) {\n return { to: relativePath }\n }\n const searchObject = qs.parse(relativePath.slice(queryIndex + 1), {\n depth: 10,\n ignoreQueryPrefix: true,\n })\n // Function form replaces the search entirely (no merge with current search).\n return { search: () => searchObject, to: relativePath.slice(0, queryIndex) }\n }, [])\n\n const back = useCallback(() => router.history.back(), [router])\n const push = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n const refresh = useCallback(() => {\n void router.invalidate()\n }, [router])\n const replace = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), replace: true, resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n\n const adaptedRouter = useMemo(\n () => ({ back, push, refresh, replace }),\n [back, push, refresh, replace],\n )\n\n // `location.searchStr` is the serialized query string; `location.search` is\n // the parsed object (a nested structure once the router uses `qs` for search\n // serialization), which `URLSearchParams` cannot consume. Build from the\n // string so Payload's `parseSearchParams` re-parses the bracket notation.\n const searchParams = useMemo(() => new URLSearchParams(location.searchStr), [location.searchStr])\n\n const value: RouterAdapterContextValue = useMemo(\n () => ({\n Link: TanStackLinkAdapter,\n params: adaptedParams,\n pathname: location.pathname,\n router: adaptedRouter,\n searchParams,\n }),\n [adaptedParams, location.pathname, adaptedRouter, searchParams],\n )\n\n return <RouterAdapterContext value={value}>{children}</RouterAdapterContext>\n}\n"],"names":["RouterAdapterContext","Link","TanStackLink","useLocation","useParams","useRouter","qs","React","useCallback","useMemo","normalizeNavigationTarget","path","pathname","search","startsWith","url","URL","hash","TanStackLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","preload","resetScroll","to","TanStackRouterAdapter","router","location","params","strict","adaptedParams","adapted","_splat","segments","split","filter","Boolean","toNavOptions","relativePath","window","queryIndex","indexOf","searchObject","parse","slice","depth","ignoreQueryPrefix","back","history","push","options","navigate","refresh","invalidate","adaptedRouter","searchParams","URLSearchParams","searchStr","value"],"mappings":"AAAA;;AAKA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,QAAQC,YAAY,EAAEC,WAAW,EAAEC,SAAS,EAAEC,SAAS,QAAQ,yBAAwB;AAChG,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAO;AAEnD,MAAMC,4BAA4B,CAAC,EACjCC,IAAI,EACJC,QAAQ,EACRC,MAAM,EAKP;IACC,IAAIF,KAAKG,UAAU,CAAC,SAAS;QAC3B,MAAMC,MAAM,IAAIC,IAAIL;QACpB,OAAO,GAAGI,IAAIH,QAAQ,GAAGG,IAAIF,MAAM,GAAGE,IAAIE,IAAI,EAAE;IAClD;IAEA,IAAIN,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWD,MAAM;IAC7B;IAEA,IAAIA,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWC,SA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StackRouterAdapter } from '../elements/RouterAdapter/index.js';
3
+ export { buildThemeInitScript, PayloadAdminShell, type PayloadAdminShellProps, THEME_INIT_SCRIPT, withPayloadRoot, type WithPayloadRootOptions, } from '../layouts/Root/withPayloadRoot.js';
3
4
  export { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js';
4
5
  //# sourceMappingURL=client.d.ts.map
@@ -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,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,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,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA"}
@@ -1,6 +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 { buildThemeInitScript, PayloadAdminShell, THEME_INIT_SCRIPT, withPayloadRoot } from '../layouts/Root/withPayloadRoot.js';
4
5
  export { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js';
5
6
 
6
7
  //# sourceMappingURL=client.js.map
@@ -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 { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js'\n"],"names":["TanStackComponentRenderer","TanStackRouterAdapter","viteDevReloadStrategy"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,uCAAsC;AAChF,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,qBAAqB,QAAQ,oCAAmC"}
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 { viteDevReloadStrategy } from '../utilities/devReloadStrategy.js'\n"],"names":["TanStackComponentRenderer","TanStackRouterAdapter","buildThemeInitScript","PayloadAdminShell","THEME_INIT_SCRIPT","withPayloadRoot","viteDevReloadStrategy"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,uCAAsC;AAChF,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SACEC,oBAAoB,EACpBC,iBAAiB,EAEjBC,iBAAiB,EACjBC,eAAe,QAEV,qCAAoC;AAC3C,SAASC,qBAAqB,QAAQ,oCAAmC"}
@@ -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;AAM1E,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,CAkD7C"}
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,6 +1,9 @@
1
1
  import { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs';
2
+ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
2
3
  import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
4
+ import { Outlet } from '@tanstack/react-router';
3
5
  import { applyLocaleFiltering } from 'payload/shared';
6
+ import { createElement } from 'react';
4
7
  import { getRequestTheme } from '../../utilities/getRequestTheme.js';
5
8
  import { initReq } from '../../utilities/initReq.server.js';
6
9
  /**
@@ -37,6 +40,38 @@ import { initReq } from '../../utilities/initReq.server.js';
37
40
  config,
38
41
  req
39
42
  });
43
+ // Build the custom admin provider tree (`config.admin.components.providers`)
44
+ // nested around the router `<Outlet />`, mirroring the Next adapter's
45
+ // `NestProviders`. Returned as an unrendered element; the caller's server
46
+ // function renders it to an RSC payload (so server-component providers run
47
+ // server-side and client providers wrap the live Outlet). `undefined` when
48
+ // no custom providers are configured — the caller falls back to `<Outlet />`.
49
+ const providerPaths = config.admin?.components?.providers;
50
+ let providers = undefined;
51
+ if (Array.isArray(providerPaths) && providerPaths.length > 0) {
52
+ const serverProps = {
53
+ i18n: req.i18n,
54
+ params: {},
55
+ payload: req.payload,
56
+ permissions,
57
+ searchParams: {},
58
+ server: req.server,
59
+ user: req.user ?? undefined
60
+ };
61
+ // Mirror the Next adapter's `NestProviders`: render each configured provider
62
+ // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`
63
+ // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and
64
+ // server components receive `serverProps` while client components get only
65
+ // `clientProps`. Nested around the router `<Outlet />` instead of `children`.
66
+ providers = providerPaths.reduceRight((children, provider)=>RenderServerComponent({
67
+ clientProps: {
68
+ children
69
+ },
70
+ Component: provider,
71
+ importMap,
72
+ serverProps
73
+ }), createElement(Outlet));
74
+ }
40
75
  return {
41
76
  clientConfig,
42
77
  dateFNSKey: req.i18n.dateFNSKey,
@@ -46,6 +81,7 @@ import { initReq } from '../../utilities/initReq.server.js';
46
81
  languageOptions,
47
82
  locale: req.locale ?? undefined,
48
83
  permissions,
84
+ providers,
49
85
  theme,
50
86
  translations: req.i18n.translations,
51
87
  user: req.user
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig } from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { applyLocaleFiltering } from 'payload/shared'\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 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 theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","getClientConfig","applyLocaleFiltering","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","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","undefined"],"mappings":"AAGA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,oBAAoB,QAAQ,iBAAgB;AAIrD,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;QACA,OAAOD;IACT,GAAG,EAAE;IAEL,MAAMW,WAAW,MAAMjC,YAAYY;IAEnC,MAAMsB,eAAejC,gBAAgB;QACnCa;QACAK,MAAMP,IAAIO,IAAI;QACdZ;QACA4B,MAAMvB,IAAIuB,IAAI,IAAI;IACpB;IAEA,MAAMjC,qBAAqB;QAAEgC;QAAcpB;QAAQF;IAAI;IAEvD,OAAO;QACLsB;QACAE,YAAYxB,IAAIO,IAAI,CAACiB,UAAU;QAC/BC,cAAcvB,OAAOK,IAAI,CAACmB,gBAAgB;QAC1CC,WAAWN,UAAUO,QAAQ;QAC7B9B;QACAM;QACAyB,QAAQ7B,IAAI6B,MAAM,IAAIC;QACtB/B;QACAI;QACAc,cAAcjB,IAAIO,IAAI,CAACU,YAAY;QACnCM,MAAMvB,IAAIuB,IAAI;IAChB;AACF"}
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,EAC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A8E;QAC9E,2EAA2E;QAC3E,8EAA8E;QAC9ED,YAAYH,cAAcY,WAAW,CACnC,CAACC,UAAUC,WACTpD,sBAAsB;gBACpBqD,aAAa;oBAAEF;gBAAS;gBACxBG,WAAWF;gBACX3C;gBACAqC;YACF,IACF1C,cAAcF;IAElB;IAEA,OAAO;QACLkC;QACAmB,YAAYzC,IAAIO,IAAI,CAACkC,UAAU;QAC/BC,cAAcxC,OAAOK,IAAI,CAACoC,gBAAgB;QAC1CC,WAAWvB,UAAUwB,QAAQ;QAC7B/C;QACAM;QACA0C,QAAQ9C,IAAI8C,MAAM,IAAIlB;QACtB7B;QACA4B;QACAxB;QACAc,cAAcjB,IAAIO,IAAI,CAACU,YAAY;QACnCM,MAAMvB,IAAIuB,IAAI;IAChB;AACF"}
@@ -12,6 +12,13 @@ export type RootLayoutData = {
12
12
  languageOptions: LanguageOptions;
13
13
  locale?: string;
14
14
  permissions: SanitizedPermissions;
15
+ /**
16
+ * Custom admin provider tree (`config.admin.components.providers`) nested
17
+ * around the router `<Outlet />`. Built unrendered by `getLayoutData`; the
18
+ * layout server function renders it to an RSC payload before it reaches the
19
+ * client. `undefined` when no custom providers are configured.
20
+ */
21
+ providers?: React.ReactNode;
15
22
  theme: Theme;
16
23
  translations: I18nClient['translations'];
17
24
  user: null | TypedUser;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EACV,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,8BAA8B,CAAA;AAIrC,MAAM,MAAM,cAAc,GAAG;IAC3B,YA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AAA;IACpB,eAAe,EAAE,eAAe,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,oBAAoB,CAAA;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IACxC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;IAC7B,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAA;CAC9C,CAAA;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,eAAe,qBAgC7E"}
@@ -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 TypedUser,\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 theme: Theme\n translations: I18nClient['translations']\n user: null | TypedUser\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;AAsB7E,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
+ {"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 TypedUser,\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 | TypedUser\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"}
@@ -0,0 +1,65 @@
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;
18
+ export type PayloadAdminShellProps = {
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;
25
+ };
26
+ /**
27
+ * The `<html>` document shell for Payload admin routes — the TanStack Start
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`.
32
+ */
33
+ export declare function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps): React.JSX.Element;
34
+ export type WithPayloadRootOptions = {
35
+ /**
36
+ * Path prefix that mounts the Payload admin panel (`config.routes.admin`).
37
+ * Routes under it render the Payload admin document shell; everything else
38
+ * renders your own shell. Defaults to `'/admin'`.
39
+ */
40
+ adminRoute?: string;
41
+ /**
42
+ * The `config.cookiePrefix` used by the no-flash theme bootstrap script.
43
+ * Defaults to `'payload'`.
44
+ */
45
+ cookiePrefix?: string;
46
+ };
47
+ /**
48
+ * Wraps your application's root document shell so Payload owns its own
49
+ * `<html>` chrome on admin routes while your shell renders everywhere else.
50
+ *
51
+ * Attach the result to the root route's `shellComponent`; it is the single
52
+ * integration touch point — no root loader and no manual data threading:
53
+ *
54
+ * ```tsx
55
+ * export const Route = createRootRoute({
56
+ * shellComponent: withPayloadRoot(MarketingHtml),
57
+ * })
58
+ * ```
59
+ */
60
+ export declare function withPayloadRoot(RootShell: React.ComponentType<{
61
+ children: React.ReactNode;
62
+ }>, options?: WithPayloadRootOptions): ({ children }: {
63
+ children: React.ReactNode;
64
+ }) => React.JSX.Element;
65
+ //# sourceMappingURL=withPayloadRoot.d.ts.map
@@ -0,0 +1 @@
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,IAIH,cAAc;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { rtlLanguages } from '@payloadcms/translations';
4
+ import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
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();
23
+ /**
24
+ * The `<html>` document shell for Payload admin routes — the TanStack Start
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
34
+ /*#__PURE__*/ _jsxs("html", {
35
+ suppressHydrationWarning: true,
36
+ children: [
37
+ /*#__PURE__*/ _jsxs("head", {
38
+ children: [
39
+ /*#__PURE__*/ _jsx("script", {
40
+ dangerouslySetInnerHTML: {
41
+ __html: themeInitScript
42
+ }
43
+ }),
44
+ /*#__PURE__*/ _jsx("style", {
45
+ children: `@layer payload-default, payload;`
46
+ }),
47
+ /*#__PURE__*/ _jsx(HeadContent, {})
48
+ ]
49
+ }),
50
+ /*#__PURE__*/ _jsxs("body", {
51
+ children: [
52
+ children,
53
+ /*#__PURE__*/ _jsx(Scripts, {})
54
+ ]
55
+ })
56
+ ]
57
+ }));
58
+ }
59
+ /**
60
+ * Wraps your application's root document shell so Payload owns its own
61
+ * `<html>` chrome on admin routes while your shell renders everywhere else.
62
+ *
63
+ * Attach the result to the root route's `shellComponent`; it is the single
64
+ * integration touch point — no root loader and no manual data threading:
65
+ *
66
+ * ```tsx
67
+ * export const Route = createRootRoute({
68
+ * shellComponent: withPayloadRoot(MarketingHtml),
69
+ * })
70
+ * ```
71
+ */ export function withPayloadRoot(RootShell, options = {}) {
72
+ const { adminRoute = '/admin', cookiePrefix } = options;
73
+ return function PayloadRootShell({ children }) {
74
+ const isAdminRoute = useRouterState({
75
+ select: (s)=>{
76
+ const { pathname } = s.location;
77
+ return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`);
78
+ }
79
+ });
80
+ if (isAdminRoute) {
81
+ return /*#__PURE__*/ _jsx(PayloadAdminShell, {
82
+ cookiePrefix: cookiePrefix,
83
+ children: children
84
+ });
85
+ }
86
+ return /*#__PURE__*/ _jsx(RootShell, {
87
+ children: children
88
+ });
89
+ };
90
+ }
91
+
92
+ //# sourceMappingURL=withPayloadRoot.js.map
@@ -0,0 +1 @@
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(MarketingHtml),\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,2BAA0B;AACvD,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAEzB;;;;;;;;CAQC,GACD,OAAO,SAASC,qBAAqBC,eAAuB,SAAS;IACnE,MAAMC,MA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AAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
1
+ {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -1,4 +1,5 @@
1
1
  import { renderServerComponent } from '@tanstack/react-start/rsc';
2
+ import { createElement, Fragment } from 'react';
2
3
  /**
3
4
  * Recursively walk a server-function return value and prepare it for transit
4
5
  * to the client as an RSC payload.
@@ -78,6 +79,22 @@ async function walk(value, cache, ancestors) {
78
79
  return cleaned;
79
80
  }
80
81
  if (Array.isArray(obj)) {
82
+ // An array consisting entirely of React elements (e.g. a field's
83
+ // `beforeInput` / `afterInput` component list, produced by
84
+ // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
85
+ // Converting each element individually below turns every item into its own
86
+ // `renderServerComponent` handle, which drops the element's React `key` —
87
+ // the client then renders `{[handle, handle]}` as unkeyed array children
88
+ // and React warns "Each child in a list should have a unique key prop".
89
+ // Payload always renders these component arrays wholesale (`{BeforeInput}`),
90
+ // so collapsing them into one Fragment-rendered handle is render-equivalent
91
+ // and keeps the per-element keys intact inside the single Flight payload.
92
+ const items = obj.filter((item)=>item !== null && item !== undefined);
93
+ const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
94
+ if (isReactElementArray) {
95
+ ancestors.delete(obj);
96
+ return await renderServerComponent(createElement(Fragment, null, ...obj));
97
+ }
81
98
  const arr = [];
82
99
  cache.set(obj, arr);
83
100
  for (const item of obj){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<unknown> {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return await renderServerComponent(value as React.ReactElement)\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n return obj\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(await walk(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAEjE;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMX,sBAAsBE;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;I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,MAAMb,WAAW;YACnBwB,MAAM,CAACC,IAAI,GAAGZ;QAChB;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAOsB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { createElement, Fragment } from 'react'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<unknown> {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return await renderServerComponent(value as React.ReactElement)\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n return obj\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n // An array consisting entirely of React elements (e.g. a field's\n // `beforeInput` / `afterInput` component list, produced by\n // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.\n // Converting each element individually below turns every item into its own\n // `renderServerComponent` handle, which drops the element's React `key` —\n // the client then renders `{[handle, handle]}` as unkeyed array children\n // and React warns \"Each child in a list should have a unique key prop\".\n // Payload always renders these component arrays wholesale (`{BeforeInput}`),\n // so collapsing them into one Fragment-rendered handle is render-equivalent\n // and keeps the per-element keys intact inside the single Flight payload.\n const items = obj.filter((item) => item !== null && item !== undefined)\n const isReactElementArray =\n items.length > 0 &&\n items.every(\n (item) => typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(createElement(Fragment, null, ...(obj as React.ReactNode[])))\n }\n\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(await walk(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n result[key] = v\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","createElement","Fragment","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","items","filter","item","isReactElementArray","length","every","arr","push","ArrayBuffer","isView","result","key","Object","keys"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,aAAa,EAAEC,QAAQ,QAAQ,QAAO;AAE/C;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMb,sBAAsBI;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAD,UAAUS,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBX,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAf,UAAUgB,M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AClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAAC4B,IAAI,EAAEhC,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnB6B,MAAM,CAACC,IAAI,GAAGjB;QAChB;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0BvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAK/D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAqC/C,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/vite/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA0BvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAK/D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAiE/C,CAAA"}
@@ -123,7 +123,35 @@
123
123
  '@payloadcms/ui > react-select > @floating-ui/dom',
124
124
  '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',
125
125
  '@payloadcms/ui > react-select > prop-types > react-is',
126
- '@payloadcms/ui > date-fns/locale/en-US'
126
+ '@payloadcms/ui > date-fns/locale/en-US',
127
+ // Further late discoveries observed re-optimizing mid-run in CI cold starts
128
+ // (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / ajv /
129
+ // dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
130
+ // render; form-state diffing reaches `dequal/lite` (a distinct entry point
131
+ // from the already-listed `dequal`); client-side field validation reaches
132
+ // `ajv` *through `payload`* — it is `ssrExternal` server-side but still
133
+ // bundled into the client, and must be pathed via `payload` so the optimizer
134
+ // pre-bundles the exact copy the runtime loads.
135
+ '@payloadcms/ui > @dnd-kit/modifiers',
136
+ '@payloadcms/ui > dequal/lite',
137
+ 'payload > ajv',
138
+ // The storage client-upload suites (esp. vercel-blob) crawl part of the
139
+ // `payload` server runtime into the client bundle and discover these late,
140
+ // triggering several "optimized dependencies changed. reloading" waves that
141
+ // reload the page mid-test (the bulk-upload drawer's Create New button /
142
+ // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the
143
+ // whole observed set so the first pass is complete.
144
+ 'payload > undici',
145
+ 'payload > jose',
146
+ 'payload > dataloader',
147
+ 'payload > path-to-regexp',
148
+ 'payload > console-table-printer',
149
+ 'payload > ci-info',
150
+ 'payload > image-size',
151
+ 'payload > image-size/fromFile',
152
+ 'payload > ipaddr.js',
153
+ 'payload > range-parser',
154
+ 'payload > sanitize-filename'
127
155
  ];
128
156
 
129
157
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vite/constants.ts"],"sourcesContent":["/**\n * Vite-level configuration constants used by `payloadPlugin`. Kept separate so\n * `plugin.ts` stays focused on wiring.\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 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'mongodb',\n 'mongoose',\n 'better-sqlite3',\n 'pg',\n 'pg-native',\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]\n\n/**\n * Payload packages whose source must be processed by Vite even on the server\n * (because they are workspace `.ts` files in dev). Server-only adapters\n * (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are\n * intentionally not included — those should stay external on the SSR side.\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\n/**\n * The subset of `payloadNoExternalPatterns` that needs to participate in the\n * RSC environment. The RSC graph is narrower — plugins and storage adapters\n * don't run in RSC, only the admin UI surface does.\n */\nexport const payloadRscNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n]\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n 'scheduler',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n]\n"],"names":["ssrExternalPackages","payloadNoExternalPatterns","payloadRscNoExternalPatterns","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"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;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMC,+BAAuD;IAClE;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;CACD,CAAA"}
1
+ {"version":3,"sources":["../../src/vite/constants.ts"],"sourcesContent":["/**\n * Vite-level configuration constants used by `payloadPlugin`. Kept separate so\n * `plugin.ts` stays focused on wiring.\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 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'mongodb',\n 'mongoose',\n 'better-sqlite3',\n 'pg',\n 'pg-native',\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]\n\n/**\n * Payload packages whose source must be processed by Vite even on the server\n * (because they are workspace `.ts` files in dev). Server-only adapters\n * (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are\n * intentionally not included — those should stay external on the SSR side.\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\n/**\n * The subset of `payloadNoExternalPatterns` that needs to participate in the\n * RSC environment. The RSC graph is narrower — plugins and storage adapters\n * don't run in RSC, only the admin UI surface does.\n */\nexport const payloadRscNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n]\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n 'scheduler',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / ajv /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `ajv` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > ajv',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-size',\n 'payload > image-size/fromFile',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n]\n"],"names":["ssrExternalPackages","payloadNoExternalPatterns","payloadRscNoExternalPatterns","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"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;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMC,+BAAuD;IAClE;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -149,7 +149,8 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
149
149
  'react',
150
150
  'react-dom',
151
151
  'scheduler',
152
- '@payloadcms/ui'
152
+ '@payloadcms/ui',
153
+ '@payloadcms/richtext-lexical'
153
154
  ],
154
155
  extensions: [
155
156
  '.mjs',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vite/plugin.ts"],"sourcesContent":["import type { PluginOption, UserConfigFnObject } from 'vite'\n\nimport path from 'node:path'\n\nimport {\n optimizeDepsExcludeDefaults,\n optimizeDepsIncludeDefaults,\n payloadNoExternalPatterns,\n payloadRscNoExternalPatterns,\n ssrExternalPackages,\n} from './constants.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './plugins/clientModuleResolution.js'\nimport { payloadDevTransforms } from './plugins/devTransforms.js'\nimport { reactDomServerInRsc } from './plugins/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './plugins/stripDistStyleImports.js'\nimport { wrapCjsForClient } from './plugins/wrapCjsForClient.js'\n\nexport interface PayloadPluginOptions {\n /** Additional resolve aliases */\n additionalAliases?: Array<{ find: RegExp | string; replacement: string }>\n /** Additional import protection ignoreImporters patterns */\n additionalIgnoreImporters?: RegExp[]\n /** Extra optimizeDeps.include entries */\n additionalOptimizeDepsInclude?: string[]\n /** Extra ssr.external entries */\n additionalSsrExternal?: string[]\n /** Path to the user's payload.config.ts (required) */\n payloadConfigPath: string\n /** Extra Vite plugins to include */\n plugins?: PluginOption[]\n /** @vitejs/plugin-react instance — must be passed by consumer to ensure correct resolution */\n reactPlugin: PluginOption\n /** TanStack router routes directory relative to srcDirectory. Defaults to 'app' */\n routesDirectory?: string\n /** @vitejs/plugin-rsc instance — required for RSC support, must be passed by consumer */\n rscPlugin: PluginOption\n /** TanStack source directory. Defaults to 'src' */\n srcDirectory?: string\n /** tanstackStart from '@tanstack/react-start/plugin/vite' — must be passed by consumer to ensure correct resolution */\n tanstackStart: typeof import('@tanstack/react-start/plugin/vite').tanstackStart\n}\n\n/**\n * Vite plugin for Payload + TanStack Start. The Vite-side counterpart to\n * `withPayload` for Next.js: it configures the Vite environment so the Payload\n * admin can run, then composes the TanStack Start plugin with two small\n * Payload-specific workarounds (dev HMR injection, SSR style stripping). Each\n * remaining workaround lives in its own file under `./plugins/` so it can be\n * deleted individually once the corresponding upstream fix lands.\n */\nexport function payloadPlugin(options: PayloadPluginOptions): UserConfigFnObject {\n const {\n additionalAliases = [],\n additionalIgnoreImporters = [],\n additionalOptimizeDepsInclude = [],\n additionalSsrExternal = [],\n payloadConfigPath,\n plugins: extraPlugins = [],\n reactPlugin,\n routesDirectory = 'app',\n rscPlugin,\n srcDirectory = 'src',\n tanstackStart,\n } = options\n\n process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED = 'true'\n\n return (_env) => ({\n css: {\n preprocessorOptions: {\n scss: {\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n 'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true'),\n },\n environments: {\n rsc: { resolve: { noExternal: payloadRscNoExternalPatterns } },\n ssr: { resolve: { noExternal: payloadNoExternalPatterns } },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: [...optimizeDepsIncludeDefaults, ...additionalOptimizeDepsInclude],\n },\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n payloadDevTransforms(),\n rscPlugin,\n tanstackStart({\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [\n ...defaultImportProtectionIgnoreImporters,\n ...additionalIgnoreImporters,\n ],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Disable TanStack Start's default `**/*.client.*` file-based denial in\n // the SSR environment. Payload uses the `.client.tsx` filename suffix\n // for React Client Components (with a `'use client'` directive) that\n // MUST be server-rendered to HTML during SSR. The default rule would\n // otherwise replace those files with an `import-protection mock` Proxy\n // during SSR, which crashes React (TypeError: Cannot convert object to\n // primitive value) the moment React tries to format a warning that\n // mentions one of these components.\n server: { files: [] },\n },\n // Disable TanStack Router's automatic per-route code-splitting.\n //\n // With splitting enabled each route's `component` is fetched lazily\n // via `?tsr-split=component` after the initial SSR HTML is streamed.\n // Until that lazy chunk lands the rendered admin tree has no client\n // React attached, so any button clicks (e.g. the\n // `#toggle-list-filters` chevron in `<ListControls />`) hit a static\n // DOM, the click is dropped, and once the chunk finally loads the\n // component re-mounts with its initial `useState` instead of the\n // toggled value. That single behaviour was the root cause of the\n // \"page renders but nothing is interactive\" tanstack-start E2E\n // failures (`#list-controls-where`, `[data-lexical-editor]`, etc.) -\n // playwright traces show \"Download the React DevTools\" landing\n // *after* the playwright click, confirming late hydration.\n //\n // We pass BOTH knobs because `tanstackStart`'s schema silently\n // strips the user-supplied `autoCodeSplitting` (its `tsrConfig`\n // does `configSchema.omit({ autoCodeSplitting: true, target: true\n // })`) and then leaves the value `undefined` — which is fine for\n // the conditional inside `unpluginRouterComposedFactory`, but the\n // TanStack Start vite plugin *unconditionally* installs the router\n // code-splitter via `tanStackRouterCodeSplitter(...)` regardless.\n // The only knob that survives all of that and is honoured by the\n // splitter is `router.codeSplittingOptions.defaultBehavior` — set\n // to an empty array, the splitter still walks each `createFileRoute`\n // file but produces no virtual `?tsr-split=...` modules, so every\n // route component ships in the initial bundle and hydration starts\n // immediately on first paint. We keep `autoCodeSplitting: false` as\n // a belt-and-braces signal in case the start plugin ever stops\n // dropping it.\n //\n // Eager-loading routes ships a slightly larger initial bundle but\n // makes the admin actually interactive on first paint.\n router: {\n autoCodeSplitting: false,\n codeSplittingOptions: { defaultBehavior: [] },\n // Exclude only generated importMap files. Admin form saves are\n // dispatched via `runPayloadServerFn` (a TanStack Start\n // `createServerFn`) rather than a hand-rolled route, so there is\n // no longer an `api.server-function.ts` to special-case here.\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }),\n reactPlugin,\n ...extraPlugins,\n ],\n resolve: {\n alias: [\n { find: '@payload-config', replacement: path.resolve(payloadConfigPath) },\n ...additionalAliases,\n ],\n dedupe: ['react', 'react-dom', 'scheduler', '@payloadcms/ui'],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n server: {\n warmup: { clientFiles: ['./src/importMap.js'] },\n },\n ssr: {\n external: [...ssrExternalPackages, ...additionalSsrExternal],\n noExternal: payloadNoExternalPatterns,\n },\n })\n}\n"],"names":["path","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadNoExternalPatterns","payloadRscNoExternalPatterns","ssrExternalPackages","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","wrapCjsForClient","payloadPlugin","options","additionalAliases","additionalIgnoreImporters","additionalOptimizeDepsInclude","additionalSsrExternal","payloadConfigPath","plugins","extraPlugins","reactPlugin","routesDirectory","rscPlugin","srcDirectory","tanstackStart","process","env","PAYLOAD_FRAMEWORK_RSC_ENABLED","_env","css","preprocessorOptions","scss","silenceDeprecations","define","global","JSON","stringify","environments","rsc","resolve","noExternal","ssr","optimizeDeps","exclude","include","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","files","router","autoCodeSplitting","codeSplittingOptions","defaultBehavior","routeFileIgnorePattern","enabled","alias","find","replacement","dedupe","extensions","tsconfigPaths","warmup","clientFiles","external"],"mappings":"AAEA,OAAOA,UAAU,YAAW;AAE5B,SACEC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,yBAAyB,EACzBC,4BAA4B,EAC5BC,mBAAmB,QACd,iBAAgB;AACvB,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,QAAQ,gCAA+B;AA2BhE;;;;;;;CAOC,GACD,OAAO,SAASC,cAAcC,OAA6B;IACzD,MAAM,EACJC,oBAAoB,EAAE,EACtBC,4BAA4B,EAAE,EAC9BC,gCAAgC,EAAE,EAClCC,wB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+D;oBAC/D,2DAA2D;oBAC3D,EAAE;oBACF,+DAA+D;oBAC/D,gEAAgE;oBAChE,kEAAkE;oBAClE,iEAAiE;oBACjE,kEAAkE;oBAClE,mEAAmE;oBACnE,kEAAkE;oBAClE,iEAAiE;oBACjE,kEAAkE;oBAClE,qEAAqE;oBACrE,kEAAkE;oBAClE,mEAAmE;oBACnE,oEAAoE;oBACpE,+DAA+D;oBAC/D,eAAe;oBACf,EAAE;oBACF,kEAAkE;oBAClE,uDAAuD;oBACvDC,QAAQ;wBACNC,mBAAmB;wBACnBC,sBAAsB;4BAAEC,iBAAiB,EAAE;wBAAC;wBAC5C,+DAA+D;wBAC/D,wDAAwD;wBACxD,iEAAiE;wBACjE,8DAA8D;wBAC9DC,wBAAwB;wBACxBrC;oBACF;oBACAiB,KAAK;wBAAEqB,SAAS;oBAAK;oBACrBpC;gBACF;gBACAH;mBACGD;aACJ;YACDoB,SAAS;gBACPqB,OAAO;oBACL;wBAAEC,MAAM;wBAAmBC,aAAajE,KAAK0C,OAAO,CAACtB;oBAAmB;uBACrEJ;iBACJ;gBACDkD,QAAQ;oBAAC;oBAAS;oBAAa;oBAAa;iBAAiB;gBAC7DC,YAAY;oBAAC;oBAAQ;oBAAO;oBAAQ;oBAAO;oBAAQ;oBAAQ;iBAAQ;gBACnEC,eAAe;YACjB;YACAb,QAAQ;gBACNc,QAAQ;oBAAEC,aAAa;wBAAC;qBAAqB;gBAAC;YAChD;YACA1B,KAAK;gBACH2B,UAAU;uBAAIlE;uBAAwBc;iBAAsB;gBAC5DwB,YAAYxC;YACd;QACF,CAAA;AACF"}
1
+ {"version":3,"sources":["../../src/vite/plugin.ts"],"sourcesContent":["import type { PluginOption, UserConfigFnObject } from 'vite'\n\nimport path from 'node:path'\n\nimport {\n optimizeDepsExcludeDefaults,\n optimizeDepsIncludeDefaults,\n payloadNoExternalPatterns,\n payloadRscNoExternalPatterns,\n ssrExternalPackages,\n} from './constants.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './plugins/clientModuleResolution.js'\nimport { payloadDevTransforms } from './plugins/devTransforms.js'\nimport { reactDomServerInRsc } from './plugins/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './plugins/stripDistStyleImports.js'\nimport { wrapCjsForClient } from './plugins/wrapCjsForClient.js'\n\nexport interface PayloadPluginOptions {\n /** Additional resolve aliases */\n additionalAliases?: Array<{ find: RegExp | string; replacement: string }>\n /** Additional import protection ignoreImporters patterns */\n additionalIgnoreImporters?: RegExp[]\n /** Extra optimizeDeps.include entries */\n additionalOptimizeDepsInclude?: string[]\n /** Extra ssr.external entries */\n additionalSsrExternal?: string[]\n /** Path to the user's payload.config.ts (required) */\n payloadConfigPath: string\n /** Extra Vite plugins to include */\n plugins?: PluginOption[]\n /** @vitejs/plugin-react instance — must be passed by consumer to ensure correct resolution */\n reactPlugin: PluginOption\n /** TanStack router routes directory relative to srcDirectory. Defaults to 'app' */\n routesDirectory?: string\n /** @vitejs/plugin-rsc instance — required for RSC support, must be passed by consumer */\n rscPlugin: PluginOption\n /** TanStack source directory. Defaults to 'src' */\n srcDirectory?: string\n /** tanstackStart from '@tanstack/react-start/plugin/vite' — must be passed by consumer to ensure correct resolution */\n tanstackStart: typeof import('@tanstack/react-start/plugin/vite').tanstackStart\n}\n\n/**\n * Vite plugin for Payload + TanStack Start. The Vite-side counterpart to\n * `withPayload` for Next.js: it configures the Vite environment so the Payload\n * admin can run, then composes the TanStack Start plugin with two small\n * Payload-specific workarounds (dev HMR injection, SSR style stripping). Each\n * remaining workaround lives in its own file under `./plugins/` so it can be\n * deleted individually once the corresponding upstream fix lands.\n */\nexport function payloadPlugin(options: PayloadPluginOptions): UserConfigFnObject {\n const {\n additionalAliases = [],\n additionalIgnoreImporters = [],\n additionalOptimizeDepsInclude = [],\n additionalSsrExternal = [],\n payloadConfigPath,\n plugins: extraPlugins = [],\n reactPlugin,\n routesDirectory = 'app',\n rscPlugin,\n srcDirectory = 'src',\n tanstackStart,\n } = options\n\n process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED = 'true'\n\n return (_env) => ({\n css: {\n preprocessorOptions: {\n scss: {\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n 'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true'),\n },\n environments: {\n rsc: { resolve: { noExternal: payloadRscNoExternalPatterns } },\n ssr: { resolve: { noExternal: payloadNoExternalPatterns } },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: [...optimizeDepsIncludeDefaults, ...additionalOptimizeDepsInclude],\n },\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n payloadDevTransforms(),\n rscPlugin,\n tanstackStart({\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [\n ...defaultImportProtectionIgnoreImporters,\n ...additionalIgnoreImporters,\n ],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Disable TanStack Start's default `**/*.client.*` file-based denial in\n // the SSR environment. Payload uses the `.client.tsx` filename suffix\n // for React Client Components (with a `'use client'` directive) that\n // MUST be server-rendered to HTML during SSR. The default rule would\n // otherwise replace those files with an `import-protection mock` Proxy\n // during SSR, which crashes React (TypeError: Cannot convert object to\n // primitive value) the moment React tries to format a warning that\n // mentions one of these components.\n server: { files: [] },\n },\n // Disable TanStack Router's automatic per-route code-splitting.\n //\n // With splitting enabled each route's `component` is fetched lazily\n // via `?tsr-split=component` after the initial SSR HTML is streamed.\n // Until that lazy chunk lands the rendered admin tree has no client\n // React attached, so any button clicks (e.g. the\n // `#toggle-list-filters` chevron in `<ListControls />`) hit a static\n // DOM, the click is dropped, and once the chunk finally loads the\n // component re-mounts with its initial `useState` instead of the\n // toggled value. That single behaviour was the root cause of the\n // \"page renders but nothing is interactive\" tanstack-start E2E\n // failures (`#list-controls-where`, `[data-lexical-editor]`, etc.) -\n // playwright traces show \"Download the React DevTools\" landing\n // *after* the playwright click, confirming late hydration.\n //\n // We pass BOTH knobs because `tanstackStart`'s schema silently\n // strips the user-supplied `autoCodeSplitting` (its `tsrConfig`\n // does `configSchema.omit({ autoCodeSplitting: true, target: true\n // })`) and then leaves the value `undefined` — which is fine for\n // the conditional inside `unpluginRouterComposedFactory`, but the\n // TanStack Start vite plugin *unconditionally* installs the router\n // code-splitter via `tanStackRouterCodeSplitter(...)` regardless.\n // The only knob that survives all of that and is honoured by the\n // splitter is `router.codeSplittingOptions.defaultBehavior` — set\n // to an empty array, the splitter still walks each `createFileRoute`\n // file but produces no virtual `?tsr-split=...` modules, so every\n // route component ships in the initial bundle and hydration starts\n // immediately on first paint. We keep `autoCodeSplitting: false` as\n // a belt-and-braces signal in case the start plugin ever stops\n // dropping it.\n //\n // Eager-loading routes ships a slightly larger initial bundle but\n // makes the admin actually interactive on first paint.\n router: {\n autoCodeSplitting: false,\n codeSplittingOptions: { defaultBehavior: [] },\n // Exclude only generated importMap files. Admin form saves are\n // dispatched via `runPayloadServerFn` (a TanStack Start\n // `createServerFn`) rather than a hand-rolled route, so there is\n // no longer an `api.server-function.ts` to special-case here.\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }),\n reactPlugin,\n ...extraPlugins,\n ],\n resolve: {\n alias: [\n { find: '@payload-config', replacement: path.resolve(payloadConfigPath) },\n ...additionalAliases,\n ],\n dedupe: ['react', 'react-dom', 'scheduler', '@payloadcms/ui', '@payloadcms/richtext-lexical'],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n server: {\n warmup: { clientFiles: ['./src/importMap.js'] },\n },\n ssr: {\n external: [...ssrExternalPackages, ...additionalSsrExternal],\n noExternal: payloadNoExternalPatterns,\n },\n })\n}\n"],"names":["path","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadNoExternalPatterns","payloadRscNoExternalPatterns","ssrExternalPackages","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","wrapCjsForClient","payloadPlugin","options","additionalAliases","additionalIgnoreImporters","additionalOptimizeDepsInclude","additionalSsrExternal","payloadConfigPath","plugins","extraPlugins","reactPlugin","routesDirectory","rscPlugin","srcDirectory","tanstackStart","process","env","PAYLOAD_FRAMEWORK_RSC_ENABLED","_env","css","preprocessorOptions","scss","silenceDeprecations","define","global","JSON","stringify","environments","rsc","resolve","noExternal","ssr","optimizeDeps","exclude","include","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","files","router","autoCodeSplitting","codeSplittingOptions","defaultBehavior","routeFileIgnorePattern","enabled","alias","find","replacement","dedupe","extensions","tsconfigPaths","warmup","clientFiles","external"],"mappings":"AAEA,OAAOA,UAAU,YAAW;AAE5B,SACEC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,yBAAyB,EACzBC,4BAA4B,EAC5BC,mBAAmB,QACd,iBAAgB;AACvB,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,QAAQ,gCAA+B;AA2BhE;;;;;;;CAOC,GACD,OAAO,SAASC,cAAcC,OAA6B;IACzD,MAAM,EACJC,oBAAoB,EAAE,EACtBC,4BAA4B,EAAE,EAC9BC,gCAAgC,EAAE,EAClCC,wBAAwB,EAAE,EAC1BC,iBAAiB,EACjBC,SAASC,eAAe,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;oBAC/D,gEAAgE;oBAChE,kEAAkE;oBAClE,iEAAiE;oBACjE,kEAAkE;oBAClE,mEAAmE;oBACnE,kEAAkE;oBAClE,iEAAiE;oBACjE,kEAAkE;oBAClE,qEAAqE;oBACrE,kEAAkE;oBAClE,mEAAmE;oBACnE,oEAAoE;oBACpE,+DAA+D;oBAC/D,eAAe;oBACf,EAAE;oBACF,kEAAkE;oBAClE,uDAAuD;oBACvDC,QAAQ;wBACNC,mBAAmB;wBACnBC,sBAAsB;4BAAEC,iBAAiB,EAAE;wBAAC;wBAC5C,+DAA+D;wBAC/D,wDAAwD;wBACxD,iEAAiE;wBACjE,8DAA8D;wBAC9DC,wBAAwB;wBACxBrC;oBACF;oBACAiB,KAAK;wBAAEqB,SAAS;oBAAK;oBACrBpC;gBACF;gBACAH;mBACGD;aACJ;YACDoB,SAAS;gBACPqB,OAAO;oBACL;wBAAEC,MAAM;wBAAmBC,aAAajE,KAAK0C,OAAO,CAACtB;oBAAmB;uBACrEJ;iBACJ;gBACDkD,QAAQ;oBAAC;oBAAS;oBAAa;oBAAa;oBAAkB;iBAA+B;gBAC7FC,YAAY;oBAAC;oBAAQ;oBAAO;oBAAQ;oBAAO;oBAAQ;oBAAQ;iBAAQ;gBACnEC,eAAe;YACjB;YACAb,QAAQ;gBACNc,QAAQ;oBAAEC,aAAa;wBAAC;qBAAqB;gBAAC;YAChD;YACA1B,KAAK;gBACH2B,UAAU;uBAAIlE;uBAAwBc;iBAAsB;gBAC5DwB,YAAYxC;YACd;QACF,CAAA;AACF"}
@@ -3,6 +3,17 @@ import type { PluginOption } from 'vite';
3
3
  * Dev-time transforms:
4
4
  * - Replaces `process.cwd()` with `"/"` in client code (non-SSR, non-prebundled)
5
5
  * - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)
6
+ *
7
+ * The preamble is injected just before `</head>`, *after* everything React
8
+ * renders into the head. React 19 treats `<meta>`/`<link>`/`<style>`/`<title>`
9
+ * as hoistable resources it matches by key (position-tolerant), but a
10
+ * non-hoistable inline `<script type="module">` placed *before* React's first
11
+ * rendered head node makes hydration position-match that script against a
12
+ * `<style>`/`<meta>` and throw — discarding the whole tree client-side, which
13
+ * aborts in-flight server-function fetches and intermittently breaks drawers,
14
+ * forms, and navigation. Appending after React's head content keeps the
15
+ * preamble out of that positional comparison while still running before the
16
+ * body's app-entry module.
6
17
  */
7
18
  export declare function payloadDevTransforms(): PluginOption;
8
19
  //# sourceMappingURL=devTransforms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CA2DnD"}
1
+ {"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CA2DnD"}
@@ -2,6 +2,17 @@
2
2
  * Dev-time transforms:
3
3
  * - Replaces `process.cwd()` with `"/"` in client code (non-SSR, non-prebundled)
4
4
  * - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)
5
+ *
6
+ * The preamble is injected just before `</head>`, *after* everything React
7
+ * renders into the head. React 19 treats `<meta>`/`<link>`/`<style>`/`<title>`
8
+ * as hoistable resources it matches by key (position-tolerant), but a
9
+ * non-hoistable inline `<script type="module">` placed *before* React's first
10
+ * rendered head node makes hydration position-match that script against a
11
+ * `<style>`/`<meta>` and throw — discarding the whole tree client-side, which
12
+ * aborts in-flight server-function fetches and intermittently breaks drawers,
13
+ * forms, and navigation. Appending after React's head content keeps the
14
+ * preamble out of that positional comparison while still running before the
15
+ * body's app-entry module.
5
16
  */ export function payloadDevTransforms() {
6
17
  const devScripts = `<script type="module" src="/@vite/client"></script>
7
18
  <script type="module">
@@ -27,9 +38,9 @@ window.__vite_plugin_react_preamble_installed__ = true
27
38
  return chunk;
28
39
  }
29
40
  const str = typeof chunk === 'string' ? chunk : Buffer.isBuffer(chunk) ? chunk.toString() : chunk instanceof Uint8Array ? Buffer.from(chunk).toString() : null;
30
- if (str && str.includes('<head>')) {
41
+ if (str && str.includes('</head>')) {
31
42
  injected = true;
32
- return str.replace('<head>', `<head>${devScripts}`);
43
+ return str.replace('</head>', `${devScripts}</head>`);
33
44
  }
34
45
  return chunk;
35
46
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/plugins/devTransforms.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Dev-time transforms:\n * - Replaces `process.cwd()` with `\"/\"` in client code (non-SSR, non-prebundled)\n * - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)\n */\nexport function payloadDevTransforms(): PluginOption {\n const devScripts = `<script type=\"module\" src=\"/@vite/client\"></script>\n<script type=\"module\">\nimport RefreshRuntime from \"/@react-refresh\"\nRefreshRuntime.injectIntoGlobalHook(window)\nwindow.$RefreshReg$ = () => {}\nwindow.$RefreshSig$ = () => (type) => type\nwindow.__vite_plugin_react_preamble_installed__ = true\n</script>`\n\n return {\n name: 'payload:dev-transforms',\n configureServer(server) {\n server.middlewares.use((_req, res, next) => {\n let injected = false\n const origWrite = res.write\n const origEnd = res.end\n\n function tryInject(chunk: any): any {\n if (injected || chunk == null) {\n return chunk\n }\n const ct = res.getHeader('content-type')\n if (typeof ct !== 'string' || !ct.includes('text/html')) {\n return chunk\n }\n const str =\n typeof chunk === 'string'\n ? chunk\n : Buffer.isBuffer(chunk)\n ? chunk.toString()\n : chunk instanceof Uint8Array\n ? Buffer.from(chunk).toString()\n : null\n if (str && str.includes('<head>')) {\n injected = true\n return str.replace('<head>', `<head>${devScripts}`)\n }\n return chunk\n }\n\n res.write = function (this: any, chunk: any, encodingOrCb?: any, cb?: any) {\n return origWrite.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.write\n res.end = function (this: any, chunk?: any, encodingOrCb?: any, cb?: any) {\n return origEnd.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.end\n next()\n })\n },\n transform(code, id, options) {\n if (options?.ssr) {\n return\n }\n if (code.includes('process.cwd') && !id.includes('node_modules/.vite')) {\n return code.replace(/process\\.cwd\\(\\)/g, '\"/\"')\n }\n },\n }\n}\n"],"names":["payloadDevTransforms","devScripts","name","configureServer","server","middlewares","use","_req","res","next","injected","origWrite","write","origEnd","end","tryInject","chunk","ct","getHeader","includes","str","Buffer","isBuffer","toString","Uint8Array","from","replace","encodingOrCb","cb","call","transform","code","id","options","ssr"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA;IACd,MAAMC,aAAa,CAAC;;;;;;;SAOb,CAAC;IAER,OAAO;QACLC,MAAM;QACNC,iBAAgBC,MAAM;YACpBA,OAAOC,WAAW,CAACC,GAAG,CAAC,CAACC,MAAMC,KAAKC;gBACjC,IAAIC,WAAW;gBACf,MAAMC,YAAYH,IAAII,KAAK;gBAC3B,MAAMC,UAAUL,IAAIM,GAAG;gBAEvB,SAASC,UAAUC,KAAU;oBAC3B,IAAIN,YAAYM,SAAS,MAAM;wBAC7B,OAAOA;oBACT;oBACA,MAAMC,KAAKT,IAAIU,SAAS,CAAC;oBACzB,IAAI,OAAOD,OAAO,YAAY,CAACA,GAAGE,QAAQ,CAAC,cAAc;wBACvD,OAAOH;oBACT;oBACA,MAAMI,MACJ,OAAOJ,UAAU,WACbA,QACAK,OAAOC,QAAQ,CAACN,SACdA,MAAMO,QAAQ,KACdP,iBAAiBQ,aACfH,OAAOI,IAAI,CAACT,OAAOO,QAAQ,KAC3B;oBACV,IAAIH,OAAOA,IAAID,QAAQ,CAAC,WAAW;wBACjCT,WAAW;wBACX,OAAOU,IAAIM,OAAO,CAAC,UAAU,CAAC,MAAM,EAAEzB,YAAY;oBACpD;oBACA,OAAOe;gBACT;gBAEAR,IAAII,KAAK,GAAG,SAAqBI,KAAU,EAAEW,YAAkB,EAAEC,EAAQ;oBACvE,OAAOjB,UAAUkB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC9D;gBACApB,IAAIM,GAAG,GAAG,SAAqBE,KAAW,EAAEW,YAAkB,EAAEC,EAAQ;oBACtE,OAAOf,QAAQgB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC5D;gBACAnB;YACF;QACF;QACAqB,WAAUC,IAAI,EAAEC,EAAE,EAAEC,OAAO;YACzB,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,IAAIH,KAAKZ,QAAQ,CAAC,kBAAkB,CAACa,GAAGb,QAAQ,CAAC,uBAAuB;gBACtE,OAAOY,KAAKL,OAAO,CAAC,qBAAqB;YAC3C;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/vite/plugins/devTransforms.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Dev-time transforms:\n * - Replaces `process.cwd()` with `\"/\"` in client code (non-SSR, non-prebundled)\n * - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)\n *\n * The preamble is injected just before `</head>`, *after* everything React\n * renders into the head. React 19 treats `<meta>`/`<link>`/`<style>`/`<title>`\n * as hoistable resources it matches by key (position-tolerant), but a\n * non-hoistable inline `<script type=\"module\">` placed *before* React's first\n * rendered head node makes hydration position-match that script against a\n * `<style>`/`<meta>` and throw — discarding the whole tree client-side, which\n * aborts in-flight server-function fetches and intermittently breaks drawers,\n * forms, and navigation. Appending after React's head content keeps the\n * preamble out of that positional comparison while still running before the\n * body's app-entry module.\n */\nexport function payloadDevTransforms(): PluginOption {\n const devScripts = `<script type=\"module\" src=\"/@vite/client\"></script>\n<script type=\"module\">\nimport RefreshRuntime from \"/@react-refresh\"\nRefreshRuntime.injectIntoGlobalHook(window)\nwindow.$RefreshReg$ = () => {}\nwindow.$RefreshSig$ = () => (type) => type\nwindow.__vite_plugin_react_preamble_installed__ = true\n</script>`\n\n return {\n name: 'payload:dev-transforms',\n configureServer(server) {\n server.middlewares.use((_req, res, next) => {\n let injected = false\n const origWrite = res.write\n const origEnd = res.end\n\n function tryInject(chunk: any): any {\n if (injected || chunk == null) {\n return chunk\n }\n const ct = res.getHeader('content-type')\n if (typeof ct !== 'string' || !ct.includes('text/html')) {\n return chunk\n }\n const str =\n typeof chunk === 'string'\n ? chunk\n : Buffer.isBuffer(chunk)\n ? chunk.toString()\n : chunk instanceof Uint8Array\n ? Buffer.from(chunk).toString()\n : null\n if (str && str.includes('</head>')) {\n injected = true\n return str.replace('</head>', `${devScripts}</head>`)\n }\n return chunk\n }\n\n res.write = function (this: any, chunk: any, encodingOrCb?: any, cb?: any) {\n return origWrite.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.write\n res.end = function (this: any, chunk?: any, encodingOrCb?: any, cb?: any) {\n return origEnd.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.end\n next()\n })\n },\n transform(code, id, options) {\n if (options?.ssr) {\n return\n }\n if (code.includes('process.cwd') && !id.includes('node_modules/.vite')) {\n return code.replace(/process\\.cwd\\(\\)/g, '\"/\"')\n }\n },\n }\n}\n"],"names":["payloadDevTransforms","devScripts","name","configureServer","server","middlewares","use","_req","res","next","injected","origWrite","write","origEnd","end","tryInject","chunk","ct","getHeader","includes","str","Buffer","isBuffer","toString","Uint8Array","from","replace","encodingOrCb","cb","call","transform","code","id","options","ssr"],"mappings":"AAEA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASA;IACd,MAAMC,aAAa,CAAC;;;;;;;SAOb,CAAC;IAER,OAAO;QACLC,MAAM;QACNC,iBAAgBC,MAAM;YACpBA,OAAOC,WAAW,CAACC,GAAG,CAAC,CAACC,MAAMC,KAAKC;gBACjC,IAAIC,WAAW;gBACf,MAAMC,YAAYH,IAAII,KAAK;gBAC3B,MAAMC,UAAUL,IAAIM,GAAG;gBAEvB,SAASC,UAAUC,KAAU;oBAC3B,IAAIN,YAAYM,SAAS,MAAM;wBAC7B,OAAOA;oBACT;oBACA,MAAMC,KAAKT,IAAIU,SAAS,CAAC;oBACzB,IAAI,OAAOD,OAAO,YAAY,CAACA,GAAGE,QAAQ,CAAC,cAAc;wBACvD,OAAOH;oBACT;oBACA,MAAMI,MACJ,OAAOJ,UAAU,WACbA,QACAK,OAAOC,QAAQ,CAACN,SACdA,MAAMO,QAAQ,KACdP,iBAAiBQ,aACfH,OAAOI,IAAI,CAACT,OAAOO,QAAQ,KAC3B;oBACV,IAAIH,OAAOA,IAAID,QAAQ,CAAC,YAAY;wBAClCT,WAAW;wBACX,OAAOU,IAAIM,OAAO,CAAC,WAAW,GAAGzB,WAAW,OAAO,CAAC;oBACtD;oBACA,OAAOe;gBACT;gBAEAR,IAAII,KAAK,GAAG,SAAqBI,KAAU,EAAEW,YAAkB,EAAEC,EAAQ;oBACvE,OAAOjB,UAAUkB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC9D;gBACApB,IAAIM,GAAG,GAAG,SAAqBE,KAAW,EAAEW,YAAkB,EAAEC,EAAQ;oBACtE,OAAOf,QAAQgB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC5D;gBACAnB;YACF;QACF;QACAqB,WAAUC,IAAI,EAAEC,EAAE,EAAEC,OAAO;YACzB,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,IAAIH,KAAKZ,QAAQ,CAAC,kBAAkB,CAACa,GAAGb,QAAQ,CAAC,uBAAuB;gBACtE,OAAOY,KAAKL,OAAO,CAAC,qBAAqB;YAC3C;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"stripDistStyleImports.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/stripDistStyleImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAuBxC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,IAAI,YAAY,CAmDvD"}
1
+ {"version":3,"file":"stripDistStyleImports.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/stripDistStyleImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAuBxC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,IAAI,YAAY,CAoEvD"}
@@ -41,10 +41,22 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
41
41
  }
42
42
  },
43
43
  resolveId (id, importer, options) {
44
- const isServerEnv = options?.ssr || this.environment && this.environment.name !== 'client';
44
+ const envName = this.environment?.name;
45
+ const isServerEnv = options?.ssr || envName && envName !== 'client';
45
46
  if (!isServerEnv) {
46
47
  return;
47
48
  }
49
+ // Do NOT strip in the RSC environment. Server components (e.g. the admin
50
+ // `Nav`, a non-'use client' component that `import './index.css'`) render
51
+ // in the RSC graph, and `@vitejs/plugin-rsc` must SEE their `.css` imports
52
+ // there to collect them as client stylesheets. Stripping them here means
53
+ // their CSS is never emitted and the admin renders unstyled (broken nav
54
+ // scroll/layout, etc.). The Node-side `.css` no-op is handled by
55
+ // `cssLoader.mjs` (dev) and by Vite's CSS extraction (build), so the
56
+ // crash this plugin guards against does not require touching the RSC env.
57
+ if (envName === 'rsc') {
58
+ return;
59
+ }
48
60
  if (!STYLE_EXTENSION_RE.test(id)) {
49
61
  return;
50
62
  }
@@ -56,10 +68,16 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
56
68
  }
57
69
  },
58
70
  transform (code, id) {
59
- const isServerEnv = this.environment && this.environment.name !== 'client';
71
+ const envName = this.environment?.name;
72
+ const isServerEnv = envName && envName !== 'client';
60
73
  if (!isServerEnv) {
61
74
  return;
62
75
  }
76
+ // Skip the RSC env so plugin-rsc can collect server-component CSS — see
77
+ // the matching note in `resolveId` above.
78
+ if (envName === 'rsc') {
79
+ return;
80
+ }
63
81
  // Only touch Payload dependency files: published `node_modules/.../dist/`
64
82
  // builds, or workspace `…/packages/<pkg>/src/…` sources in the core-dev /
65
83
  // test setup. Don't strip from the consumer's own app source — devs may
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/plugins/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * Stops Vite (and the underlying Node ESM loader) from trying to load\n * SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built\n * `dist/` directory or when the specifier is a bare package name.\n *\n * We do this two ways, because either layer can fail:\n *\n * 1. `resolveId` redirects style specifiers to a virtual empty module —\n * handles cases where Vite asks us to resolve them.\n * 2. `transform` strips top-level `import './x.css'` statements out of any\n * JS/TS file living under `node_modules/.../dist/` for non-client envs.\n * This is the bulletproof path for prod-packed `@payloadcms/ui` (and\n * similar) dependencies that get pre-bundled by Vite's SSR/RSC dep\n * optimizer (esbuild). Esbuild preserves `.css` import statements as-is,\n * and Node's native ESM loader then crashes with\n * `Unknown file extension \".css\"`. Removing them at the source avoids\n * that entirely.\n */\nexport function ssrStripDistStyleImports(): PluginOption {\n return {\n name: 'payload:ssr-strip-dist-style-imports',\n enforce: 'pre',\n load(id) {\n if (id === '\\0ssr-empty-style') {\n return ''\n }\n },\n resolveId(id, importer, options) {\n const isServerEnv =\n options?.ssr || ((this as any).environment && (this as any).environment.name !== 'client')\n if (!isServerEnv) {\n return\n }\n if (!STYLE_EXTENSION_RE.test(id)) {\n return\n }\n if (importer && (/\\/dist\\//.test(importer) || PAYLOAD_PKG_SRC_RE.test(importer))) {\n return '\\0ssr-empty-style'\n }\n if (/^@?[a-z]/.test(id) && !id.startsWith('.') && !id.startsWith('/')) {\n return '\\0ssr-empty-style'\n }\n },\n transform(code, id) {\n const isServerEnv = (this as any).environment && (this as any).environment.name !== 'client'\n if (!isServerEnv) {\n return\n }\n // Only touch Payload dependency files: published `node_modules/.../dist/`\n // builds, or workspace `…/packages/<pkg>/src/…` sources in the core-dev /\n // test setup. Don't strip from the consumer's own app source — devs may\n // legitimately want SSR-rendered <link>s from their own CSS imports.\n const isPayloadDistFile = /\\/node_modules\\//.test(id) && /\\/dist\\//.test(id)\n const isPayloadSrcFile = PAYLOAD_PKG_SRC_RE.test(id)\n if (!isPayloadDistFile && !isPayloadSrcFile) {\n return\n }\n if (!/\\.[mc]?[jt]sx?$/.test(id)) {\n return\n }\n if (!STATIC_STYLE_IMPORT_RE.test(code)) {\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n return\n }\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n const stripped = code.replace(STATIC_STYLE_IMPORT_RE, '')\n return { code: stripped, map: null }\n },\n }\n}\n"],"names":["STYLE_EXTENSION_RE","STATIC_STYLE_IMPORT_RE","PAYLOAD_PKG_SRC_RE","ssrStripDistStyleImports","name","enforce","load","id","resolveId","importer","options","isServerEnv","ssr","environment","test","startsWith","transform","code","isPayloadDistFile","isPayloadSrcFile","lastIndex","stripped","replace","map"],"mappings":"AAEA,MAAMA,qBAAqB;AAE3B;;;;;;;;CAQC,GACD,MAAMC,yBAAyB;AAE/B;;;;;CAKC,GACD,MAAMC,qBAAqB;AAE3B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AAwB;YACtD,OAAO;gBAAEgB,MAAMI;gBAAUE,KAAK;YAAK;QACrC;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/vite/plugins/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * Stops Vite (and the underlying Node ESM loader) from trying to load\n * SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built\n * `dist/` directory or when the specifier is a bare package name.\n *\n * We do this two ways, because either layer can fail:\n *\n * 1. `resolveId` redirects style specifiers to a virtual empty module —\n * handles cases where Vite asks us to resolve them.\n * 2. `transform` strips top-level `import './x.css'` statements out of any\n * JS/TS file living under `node_modules/.../dist/` for non-client envs.\n * This is the bulletproof path for prod-packed `@payloadcms/ui` (and\n * similar) dependencies that get pre-bundled by Vite's SSR/RSC dep\n * optimizer (esbuild). Esbuild preserves `.css` import statements as-is,\n * and Node's native ESM loader then crashes with\n * `Unknown file extension \".css\"`. Removing them at the source avoids\n * that entirely.\n */\nexport function ssrStripDistStyleImports(): PluginOption {\n return {\n name: 'payload:ssr-strip-dist-style-imports',\n enforce: 'pre',\n load(id) {\n if (id === '\\0ssr-empty-style') {\n return ''\n }\n },\n resolveId(id, importer, options) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = options?.ssr || (envName && envName !== 'client')\n if (!isServerEnv) {\n return\n }\n // Do NOT strip in the RSC environment. Server components (e.g. the admin\n // `Nav`, a non-'use client' component that `import './index.css'`) render\n // in the RSC graph, and `@vitejs/plugin-rsc` must SEE their `.css` imports\n // there to collect them as client stylesheets. Stripping them here means\n // their CSS is never emitted and the admin renders unstyled (broken nav\n // scroll/layout, etc.). The Node-side `.css` no-op is handled by\n // `cssLoader.mjs` (dev) and by Vite's CSS extraction (build), so the\n // crash this plugin guards against does not require touching the RSC env.\n if (envName === 'rsc') {\n return\n }\n if (!STYLE_EXTENSION_RE.test(id)) {\n return\n }\n if (importer && (/\\/dist\\//.test(importer) || PAYLOAD_PKG_SRC_RE.test(importer))) {\n return '\\0ssr-empty-style'\n }\n if (/^@?[a-z]/.test(id) && !id.startsWith('.') && !id.startsWith('/')) {\n return '\\0ssr-empty-style'\n }\n },\n transform(code, id) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = envName && envName !== 'client'\n if (!isServerEnv) {\n return\n }\n // Skip the RSC env so plugin-rsc can collect server-component CSS — see\n // the matching note in `resolveId` above.\n if (envName === 'rsc') {\n return\n }\n // Only touch Payload dependency files: published `node_modules/.../dist/`\n // builds, or workspace `…/packages/<pkg>/src/…` sources in the core-dev /\n // test setup. Don't strip from the consumer's own app source — devs may\n // legitimately want SSR-rendered <link>s from their own CSS imports.\n const isPayloadDistFile = /\\/node_modules\\//.test(id) && /\\/dist\\//.test(id)\n const isPayloadSrcFile = PAYLOAD_PKG_SRC_RE.test(id)\n if (!isPayloadDistFile && !isPayloadSrcFile) {\n return\n }\n if (!/\\.[mc]?[jt]sx?$/.test(id)) {\n return\n }\n if (!STATIC_STYLE_IMPORT_RE.test(code)) {\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n return\n }\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n const stripped = code.replace(STATIC_STYLE_IMPORT_RE, '')\n return { code: stripped, map: null }\n },\n }\n}\n"],"names":["STYLE_EXTENSION_RE","STATIC_STYLE_IMPORT_RE","PAYLOAD_PKG_SRC_RE","ssrStripDistStyleImports","name","enforce","load","id","resolveId","importer","options","envName","environment","isServerEnv","ssr","test","startsWith","transform","code","isPayloadDistFile","isPayloadSrcFile","lastIndex","stripped","replace","map"],"mappings":"AAEA,MAAMA,qBAAqB;AAE3B;;;;;;;;CAQC,GACD,MAAMC,yBAAyB;AAE/B;;;;;CAKC,GACD,MAAMC,qBAAqB;AAE3B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAO,qBAAqB;gBAC9B,OAAO;YACT;QACF;QACAC,WAAUD,EAAE,EAAEE,QAAQ,EAAEC,OAAO;YAC7B,MAAMC,UAAU,AAAC,IAAI,CAASC,WAAW,EAAER;YAC3C,MAAMS,cAAcH,SAASI,OAAQH,WAAWA,YAAY;YAC5D,IAAI,CAACE,aAAa;gBAChB;YACF;YACA,yEAAyE;YACzE,0EAA0E;YAC1E,2EAA2E;YAC3E,yEAAyE;YACzE,wEAAwE;YACxE,iEAAiE;YACjE,qEAAqE;YACrE,0EAA0E;YAC1E,IAAIF,YAAY,OAAO;gBACrB;YACF;YACA,IAAI,CAACX,mBAAmBe,IAAI,CAACR,KAAK;gBAChC;YACF;YACA,IAAIE,YAAa,CAAA,WAAWM,IAAI,CAACN,aAAaP,mBAAmBa,IAAI,CAACN,SAAQ,GAAI;gBAChF,OAAO;YACT;YACA,IAAI,WAAWM,IAAI,CAACR,OAAO,CAACA,GAAGS,UAAU,CAAC,QAAQ,CAACT,GAAGS,UAAU,CAAC,MAAM;gBACrE,OAAO;YACT;QACF;QACAC,WAAUC,IAAI,EAAEX,EAAE;YAChB,MAAMI,UAAU,AAAC,IAAI,CAASC,WAAW,EAAER;YAC3C,MAAMS,cAAcF,WAAWA,YAAY;YAC3C,IAAI,CAACE,aAAa;gBAChB;YACF;YACA,wEAAwE;YACxE,0CAA0C;YAC1C,IAAIF,YAAY,OAAO;gBACrB;YACF;YACA,0EAA0E;YAC1E,0EAA0E;YAC1E,wEAAwE;YACxE,qEAAqE;YACrE,MAAMQ,oBAAoB,mBAAmBJ,IAAI,CAACR,OAAO,WAAWQ,IAAI,CAACR;YACzE,MAAMa,mBAAmBlB,mBAAmBa,IAAI,CAACR;YACjD,IAAI,CAACY,qBAAqB,CAACC,kBAAkB;gBAC3C;YACF;YACA,IAAI,CAAC,kBAAkBL,IAAI,CAACR,KAAK;gBAC/B;YACF;YACA,IAAI,CAACN,uBAAuBc,IAAI,CAACG,OAAO;gBACtCjB,uBAAuBoB,SAAS,GAAG;gBACnC;YACF;YACApB,uBAAuBoB,SAAS,GAAG;YACnC,MAAMC,WAAWJ,KAAKK,OAAO,CAACtB,wBAAwB;YACtD,OAAO;gBAAEiB,MAAMI;gBAAUE,KAAK;YAAK;QACrC;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-internal.183b315",
3
+ "version": "4.0.0-internal.688c4d0",
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.183b315",
62
- "@payloadcms/ui": "4.0.0-internal.183b315"
61
+ "@payloadcms/translations": "4.0.0-internal.688c4d0",
62
+ "@payloadcms/ui": "4.0.0-internal.688c4d0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@tanstack/react-router": "^1.120.0",
@@ -70,7 +70,7 @@
70
70
  "react": "^19.0.0",
71
71
  "react-dom": "^19.0.0",
72
72
  "vite": ">=8.0.0",
73
- "payload": "4.0.0-beta.0"
73
+ "payload": "4.0.0-internal.688c4d0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@tanstack/react-router": "^1.120.0",
@@ -79,7 +79,7 @@
79
79
  "react": "^19.0.0",
80
80
  "react-dom": "^19.0.0",
81
81
  "vite": ">=8.0.0",
82
- "payload": "4.0.0-beta.0"
82
+ "payload": "4.0.0-internal.688c4d0"
83
83
  },
84
84
  "peerDependenciesMeta": {
85
85
  "@vitejs/plugin-react": {