@payloadcms/tanstack-start 4.0.0-internal.203916b → 4.0.0-internal.21664f3

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 (64) hide show
  1. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  2. package/dist/elements/RouterAdapter/index.js +18 -2
  3. package/dist/elements/RouterAdapter/index.js.map +1 -1
  4. package/dist/exports/client.d.ts +1 -1
  5. package/dist/exports/client.d.ts.map +1 -1
  6. package/dist/exports/client.js +1 -1
  7. package/dist/exports/client.js.map +1 -1
  8. package/dist/exports/server.d.ts +1 -1
  9. package/dist/exports/server.d.ts.map +1 -1
  10. package/dist/exports/server.js +1 -1
  11. package/dist/exports/server.js.map +1 -1
  12. package/dist/exports/vite.d.ts +2 -12
  13. package/dist/exports/vite.d.ts.map +1 -1
  14. package/dist/exports/vite.js +1 -8
  15. package/dist/exports/vite.js.map +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  21. package/dist/layouts/Root/getLayoutData.js +1 -1
  22. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  23. package/dist/layouts/Root/index.js +4 -2
  24. package/dist/layouts/Root/index.js.map +1 -1
  25. package/dist/layouts/Root/withPayloadRoot.d.ts +7 -31
  26. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
  27. package/dist/layouts/Root/withPayloadRoot.js +33 -34
  28. package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
  29. package/dist/node/cssLoader.d.mts +24 -2
  30. package/dist/node/cssLoader.d.mts.map +1 -1
  31. package/dist/routes/adminRoutes.d.ts.map +1 -1
  32. package/dist/routes/layoutRoute.d.ts.map +1 -1
  33. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  34. package/dist/utilities/loadAdminPage.d.ts.map +1 -1
  35. package/dist/utilities/loadAdminPage.js +11 -2
  36. package/dist/utilities/loadAdminPage.js.map +1 -1
  37. package/dist/utilities/meta.d.ts +1 -0
  38. package/dist/utilities/meta.d.ts.map +1 -1
  39. package/dist/utilities/meta.js +2 -1
  40. package/dist/utilities/meta.js.map +1 -1
  41. package/dist/utilities/routerSearch.d.ts +40 -0
  42. package/dist/utilities/routerSearch.d.ts.map +1 -0
  43. package/dist/utilities/routerSearch.js +45 -0
  44. package/dist/utilities/routerSearch.js.map +1 -0
  45. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  46. package/dist/vite/config/external.d.ts.map +1 -1
  47. package/dist/vite/config/external.js +0 -2
  48. package/dist/vite/config/external.js.map +1 -1
  49. package/dist/vite/index.d.ts +81 -37
  50. package/dist/vite/index.d.ts.map +1 -1
  51. package/dist/vite/index.js +127 -107
  52. package/dist/vite/index.js.map +1 -1
  53. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -1
  54. package/dist/vite/workarounds/devTransforms.js +5 -0
  55. package/dist/vite/workarounds/devTransforms.js.map +1 -1
  56. package/dist/vite/workarounds/stubPrettierInClient.d.ts +5 -13
  57. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -1
  58. package/dist/vite/workarounds/stubPrettierInClient.js +8 -15
  59. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -1
  60. package/package.json +14 -7
  61. package/dist/utilities/getRequestTheme.d.ts +0 -10
  62. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  63. package/dist/utilities/getRequestTheme.js +0 -25
  64. package/dist/utilities/getRequestTheme.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ // Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy
2
+ // alongside the host's would load two instances and crash.
1
3
  import { tanstackStart } from '@tanstack/react-start/plugin/vite';
2
4
  import viteReact from '@vitejs/plugin-react';
3
5
  import rsc from '@vitejs/plugin-rsc';
@@ -41,27 +43,46 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
41
43
  };
42
44
  return logger;
43
45
  }
46
+ /** Applies dependency-warning suppression to a config in place when enabled. */ function applyDependencyWarningSuppression(config, enabled) {
47
+ if (enabled) {
48
+ config.customLogger = withQuietedDependencyWarnings(config.customLogger);
49
+ }
50
+ return config;
51
+ }
44
52
  /**
45
- * Vite config helper for Payload + TanStack Start. The Vite-side counterpart to
46
- * `withPayload` for Next.js: it owns the whole Vite setup needed to run the
47
- * Payload admin — the RSC, React, and TanStack Start plugins plus a small set of
48
- * Payload-specific workarounds — so a consumer's `vite.config.ts` collapses to:
53
+ * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'
54
+ * `withPayload`.
49
55
  *
50
- * ```ts
51
- * import { withPayload } from '@payloadcms/tanstack-start/vite'
56
+ * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:
52
57
  *
53
- * export default withPayload({ payloadConfigPath: './src/payload.config.ts' })
58
+ * ```ts
59
+ * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })
54
60
  * ```
55
61
  *
56
- * The React (`@vitejs/plugin-react`), RSC (`@vitejs/plugin-rsc`), and TanStack
57
- * Start plugins are instantiated internally with the settings the admin
58
- * requires consumers no longer pass them in. Each remaining Payload
59
- * workaround lives in its own file under `./workarounds/` so it can be deleted
60
- * individually once the corresponding upstream fix lands.
61
- */ export function withPayload(options) {
62
- const { additionalIgnoreImporters = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
63
- return (_env)=>{
62
+ * Guest mode — pass a `build` callback to instantiate them yourself (one copy of
63
+ * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;
64
+ * `withPayload` deep-merges them onto Payload's base config:
65
+ *
66
+ * ```ts
67
+ * export default withPayload(
68
+ * ({ pluginOptions }) => ({
69
+ * plugins: [
70
+ * rsc(pluginOptions.rsc),
71
+ * tanstackStart(pluginOptions.tanstackStart),
72
+ * viteReact(pluginOptions.react),
73
+ * ],
74
+ * // ...other config options
75
+ * }),
76
+ * { payloadConfigPath: './src/payload.config.ts' },
77
+ * )
78
+ * ```
79
+ */ export function withPayload(build, options) {
80
+ const { additionalIgnoreImporters = [], adminRouteId, clientDenialExcludeFiles = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
81
+ return (env)=>{
64
82
  const base = {
83
+ build: {
84
+ cssMinify: 'esbuild'
85
+ },
65
86
  css: {
66
87
  preprocessorOptions: {
67
88
  scss: {
@@ -102,100 +123,16 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
102
123
  exclude: optimizeDepsExcludeDefaults,
103
124
  include: optimizeDepsIncludeDefaults
104
125
  },
126
+ // Payload's internal workaround plugins only. The RSC, TanStack Start, and
127
+ // React plugins are appended below (default form) or by the consumer's
128
+ // `build` callback (guest form).
105
129
  plugins: [
106
130
  clientModuleResolution(),
107
131
  wrapCjsForClient(),
108
132
  ssrStripDistStyleImports(),
109
133
  reactDomServerInRsc(),
110
134
  stubPrettierInClient(),
111
- payloadDevTransforms(),
112
- rsc({
113
- serverHandler: false
114
- }),
115
- tanstackStart({
116
- importProtection: {
117
- client: {
118
- excludeFiles: [],
119
- specifiers: serverOnlyClientSpecifiers
120
- },
121
- ignoreImporters: [
122
- ...defaultImportProtectionIgnoreImporters,
123
- ...additionalIgnoreImporters
124
- ],
125
- include: [
126
- '**/*'
127
- ],
128
- mockAccess: 'warn',
129
- onViolation: onImportProtectionViolation,
130
- // Disable TanStack Start's default `**/*.client.*` file-based denial in
131
- // the SSR environment. Payload uses the `.client.tsx` filename suffix
132
- // for React Client Components (with a `'use client'` directive) that
133
- // MUST be server-rendered to HTML during SSR. The default rule would
134
- // otherwise replace those files with an `import-protection mock` Proxy
135
- // during SSR, which crashes React (TypeError: Cannot convert object to
136
- // primitive value) the moment React tries to format a warning that
137
- // mentions one of these components.
138
- server: {
139
- files: []
140
- }
141
- },
142
- // Disable TanStack Router's automatic per-route code-splitting.
143
- //
144
- // With splitting enabled each route's `component` is fetched lazily
145
- // via `?tsr-split=component` after the initial SSR HTML is streamed.
146
- // Until that lazy chunk lands the rendered admin tree has no client
147
- // React attached, so any button clicks (e.g. the
148
- // `#toggle-list-filters` chevron in `<ListControls />`) hit a static
149
- // DOM, the click is dropped, and once the chunk finally loads the
150
- // component re-mounts with its initial `useState` instead of the
151
- // toggled value. That single behaviour was the root cause of the
152
- // "page renders but nothing is interactive" tanstack-start E2E
153
- // failures (`#list-controls-where`, `[data-lexical-editor]`, etc.) -
154
- // playwright traces show "Download the React DevTools" landing
155
- // *after* the playwright click, confirming late hydration.
156
- //
157
- // We pass BOTH knobs because `tanstackStart`'s schema silently
158
- // strips the user-supplied `autoCodeSplitting` (its `tsrConfig`
159
- // does `configSchema.omit({ autoCodeSplitting: true, target: true
160
- // })`) and then leaves the value `undefined` — which is fine for
161
- // the conditional inside `unpluginRouterComposedFactory`, but the
162
- // TanStack Start vite plugin *unconditionally* installs the router
163
- // code-splitter via `tanStackRouterCodeSplitter(...)` regardless.
164
- // The only knob that survives all of that and is honoured by the
165
- // splitter is `router.codeSplittingOptions.defaultBehavior` — set
166
- // to an empty array, the splitter still walks each `createFileRoute`
167
- // file but produces no virtual `?tsr-split=...` modules, so every
168
- // route component ships in the initial bundle and hydration starts
169
- // immediately on first paint. We keep `autoCodeSplitting: false` as
170
- // a belt-and-braces signal in case the start plugin ever stops
171
- // dropping it.
172
- //
173
- // Eager-loading routes ships a slightly larger initial bundle but
174
- // makes the admin actually interactive on first paint.
175
- router: {
176
- autoCodeSplitting: false,
177
- codeSplittingOptions: {
178
- defaultBehavior: []
179
- },
180
- // Exclude generated importMap files and colocated server-function
181
- // modules (`*.functions.ts`). Admin form saves are dispatched via
182
- // `runPayloadServerFn` (a TanStack Start `createServerFn`) rather than
183
- // a hand-rolled route, so there is no longer an `api.server-function.ts`
184
- // to special-case here. The `*.functions.ts` shims live next to the
185
- // routes that use them (e.g. `app/_payload/*.functions.ts`); they
186
- // define `createServerFn`s, not routes, so they must not be scanned.
187
- routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
188
- routesDirectory
189
- },
190
- rsc: {
191
- enabled: true
192
- },
193
- srcDirectory
194
- }),
195
- viteReact({
196
- exclude: [],
197
- include: /\.[jt]sx?$/
198
- })
135
+ payloadDevTransforms()
199
136
  ],
200
137
  resolve: {
201
138
  alias: [
@@ -227,11 +164,94 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
227
164
  noExternal: payloadNoExternalPatterns
228
165
  }
229
166
  };
230
- const merged = vite ? mergeConfig(base, vite) : base;
231
- if (silenceDependencyWarnings) {
232
- merged.customLogger = withQuietedDependencyWarnings(merged.customLogger);
167
+ const pluginOptions = {
168
+ react: payloadReactOptions(),
169
+ rsc: payloadRscOptions(),
170
+ tanstackStart: payloadTanstackStartOptions({
171
+ additionalIgnoreImporters,
172
+ adminRouteId,
173
+ clientDenialExcludeFiles,
174
+ routesDirectory,
175
+ srcDirectory
176
+ })
177
+ };
178
+ if (build) {
179
+ return applyDependencyWarningSuppression(mergeConfig(base, build({
180
+ env,
181
+ pluginOptions
182
+ })), silenceDependencyWarnings);
233
183
  }
234
- return merged;
184
+ base.plugins = [
185
+ ...base.plugins,
186
+ rsc(pluginOptions.rsc),
187
+ tanstackStart(pluginOptions.tanstackStart),
188
+ viteReact(pluginOptions.react)
189
+ ];
190
+ const merged = vite ? mergeConfig(base, vite) : base;
191
+ return applyDependencyWarningSuppression(merged, silenceDependencyWarnings);
192
+ };
193
+ }
194
+ /** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */ export function payloadRscOptions() {
195
+ return {
196
+ serverHandler: false
197
+ };
198
+ }
199
+ /** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */ export function payloadReactOptions() {
200
+ return {
201
+ exclude: [],
202
+ include: /\.[jt]sx?$/
203
+ };
204
+ }
205
+ /**
206
+ * The `tanstackStart` options Payload's admin requires (import-protection and
207
+ * code-splitting). TanStack Start is one-per-app, so a host that already runs it
208
+ * should merge these into its single `tanstackStart` call.
209
+ */ export function payloadTanstackStartOptions(args = {}) {
210
+ const { additionalIgnoreImporters = [], adminRouteId = '/_payload', clientDenialExcludeFiles = [], routesDirectory = 'app', srcDirectory = 'src' } = args;
211
+ return {
212
+ importProtection: {
213
+ client: {
214
+ excludeFiles: [],
215
+ specifiers: serverOnlyClientSpecifiers
216
+ },
217
+ ignoreImporters: [
218
+ ...defaultImportProtectionIgnoreImporters,
219
+ ...additionalIgnoreImporters
220
+ ],
221
+ include: [
222
+ '**/*'
223
+ ],
224
+ mockAccess: 'warn',
225
+ onViolation: onImportProtectionViolation,
226
+ // Payload's `.client.*` components are React Client Components that must be
227
+ // server-rendered during SSR; TanStack's default `**/*.client.*` server
228
+ // denial would mock and crash them. All such files live in `@payloadcms/*`
229
+ // packages, so keep the denial (host `.client.*` files still get it) and
230
+ // just exempt Payload's — `node_modules` covers published installs.
231
+ server: {
232
+ excludeFiles: [
233
+ '**/node_modules/**',
234
+ ...clientDenialExcludeFiles
235
+ ]
236
+ }
237
+ },
238
+ router: {
239
+ codeSplittingOptions: {
240
+ // Eager-load only Payload's admin routes so they hydrate on first paint —
241
+ // a split admin renders but isn't interactive until its lazy `?tsr-split=`
242
+ // chunk lands. Returning `[]` disables splitting for a route; `undefined`
243
+ // lets host routes keep TanStack's default per-route splitting.
244
+ splitBehavior: ({ routeId })=>routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined
245
+ },
246
+ // Ignore generated importMap files and colocated `*.functions.ts` modules
247
+ // (they define `createServerFn`s, not routes).
248
+ routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
249
+ routesDirectory
250
+ },
251
+ rsc: {
252
+ enabled: true
253
+ },
254
+ srcDirectory
235
255
  };
236
256
  }
237
257
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { Logger, UserConfig, UserConfigFnObject } from 'vite'\n\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n */\nconst suppressibleWarningPatterns = ['points to missing source files', 'Sourcemap for']\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\nexport type WithPayloadOptions = {\n /**\n * Additional import-protection `ignoreImporters` patterns. This is a\n * Payload-specific knob on the TanStack Start plugin, so it cannot be\n * expressed through `vite` — pass it here.\n */\n additionalIgnoreImporters?: RegExp[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /**\n * Silence Vite warnings about third-party dependency sourcemaps pointing to\n * missing source files — noise Payload consumers can't act on. Defaults to\n * `true`; set `false` to see them. Composes with a `vite.customLogger`.\n */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /**\n * Extra Vite config merged on top of the Payload defaults via Vite's own\n * `mergeConfig`. Objects are deep-merged and arrays are appended, so this is\n * the single hook for everything a consumer used to reach through separate\n * options: extra `plugins`, `resolve.alias` entries, `optimizeDeps.include`,\n * `ssr.external`, `server`, `build`, and so on.\n *\n * @example\n * withPayload({\n * payloadConfigPath: './src/payload.config.ts',\n * vite: { server: { port: 4000 } },\n * })\n */\n vite?: UserConfig\n}\n\n/**\n * Vite config helper for Payload + TanStack Start. The Vite-side counterpart to\n * `withPayload` for Next.js: it owns the whole Vite setup needed to run the\n * Payload admin — the RSC, React, and TanStack Start plugins plus a small set of\n * Payload-specific workarounds — so a consumer's `vite.config.ts` collapses to:\n *\n * ```ts\n * import { withPayload } from '@payloadcms/tanstack-start/vite'\n *\n * export default withPayload({ payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * The React (`@vitejs/plugin-react`), RSC (`@vitejs/plugin-rsc`), and TanStack\n * Start plugins are instantiated internally with the settings the admin\n * requires — consumers no longer pass them in. Each remaining Payload\n * workaround lives in its own file under `./workarounds/` so it can be deleted\n * individually once the corresponding upstream fix lands.\n */\nexport function withPayload(options: WithPayloadOptions): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (_env) => {\n const base: UserConfig = {\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n rsc({ serverHandler: false }),\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 generated importMap files and colocated server-function\n // modules (`*.functions.ts`). Admin form saves are dispatched via\n // `runPayloadServerFn` (a TanStack Start `createServerFn`) rather than\n // a hand-rolled route, so there is no longer an `api.server-function.ts`\n // to special-case here. The `*.functions.ts` shims live next to the\n // routes that use them (e.g. `app/_payload/*.functions.ts`); they\n // define `createServerFn`s, not routes, so they must not be scanned.\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }),\n viteReact({ exclude: [], include: /\\.[jt]sx?$/ }),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n if (silenceDependencyWarnings) {\n merged.customLogger = withQuietedDependencyWarnings(merged.customLogger)\n }\n\n return merged\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","withPayload","additionalIgnoreImporters","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","_env","base","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","build","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","serverHandler","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","files","router","autoCodeSplitting","codeSplittingOptions","defaultBehavior","routeFileIgnorePattern","enabled","alias","find","replacement","dedupe","extensions","tsconfigPaths","merged","customLogger"],"mappings":"AAEA,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SAASC,yBAAyB,EAAEC,mBAAmB,QAAQ,uBAAsB;AACrF,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAA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,mBAAmB;wBACnBC,sBAAsB;4BAAEC,iBAAiB,EAAE;wBAAC;wBAC5C,kEAAkE;wBAClE,kEAAkE;wBAClE,uEAAuE;wBACvE,yEAAyE;wBACzE,oEAAoE;wBACpE,kEAAkE;wBAClE,qEAAqE;wBACrEC,wBAAwB;wBACxBtC;oBACF;oBACApC,KAAK;wBAAE2E,SAAS;oBAAK;oBACrBrC;gBACF;gBACAvC,UAAU;oBAAE0D,SAAS,EAAE;oBAAEC,SAAS;gBAAa;aAChD;YACDL,SAAS;gBACPuB,OAAO;oBAAC;wBAAEC,MAAM;wBAAmBC,aAAa7E,KAAKoD,OAAO,CAAClB;oBAAmB;iBAAE;gBAClF4C,QAAQ;oBACN;oBACA;oBACA;oBACA;oBACA;iBACD;gBACDC,YAAY;oBAAC;oBAAQ;oBAAO;oBAAQ;oBAAO;oBAAQ;oBAAQ;iBAAQ;gBACnEC,eAAe;YACjB;YACA1B,KAAK;gBACHH,UAAU/C;gBACViD,YAAYlD;YACd;QACF;QAEA,MAAM8E,SAAS3C,OAAOpC,YAAYsC,MAAMF,QAAQE;QAEhD,IAAIJ,2BAA2B;YAC7B6C,OAAOC,YAAY,GAAGhE,8BAA8B+D,OAAOC,YAAY;QACzE;QAEA,OAAOD;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n */\nconst suppressibleWarningPatterns = ['points to missing source files', 'Sourcemap for']\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SAASC,yBAAyB,EAAEC,mBAAmB,QAAQ,uBAAsB;AACrF,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE;;;;CAIC,GACD,MAAMC,8BAA8B;IAAC;IAAkC;CAAgB;AAEvF;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYlB;IAC3B,MAAMoB,iBAAiB,CAACC,MACtB,OAAOA,QAAQ,YAAYL,4BAA4BM,IAAI,CAAC,CAACC,UAAYF,IAAIG,QAAQ,CAACD;IAExF,MAAME,WAAWN,OAAOO,IAAI,CAACC,IAAI,CAACR;IA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C;IAEJ,OAAO;QACLC,kBAAkB;YAChBC,QAAQ;gBAAEC,cAAc,EAAE;gBAAEC,YAAYzE;YAA2B;YACnE0E,iBAAiB;mBAAI5E;mBAA2C8B;aAA0B;YAC1F0B,SAAS;gBAAC;aAAO;YACjBqB,YAAY;YACZC,aAAa7E;YACb,4EAA4E;YAC5E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,oEAAoE;YACpE8E,QAAQ;gBAAEL,cAAc;oBAAC;uBAAyB1C;iBAAyB;YAAC;QAC9E;QACAgD,QAAQ;YACNC,sBAAsB;gBACpB,0EAA0E;gBAC1E,2EAA2E;gBAC3E,0EAA0E;gBAC1E,gEAAgE;gBAChEC,eAAe,CAAC,EAAEC,OAAO,EAAuB,GAC9CA,YAAYpD,gBAAgBoD,QAAQC,UAAU,CAAC,GAAGrD,aAAa,CAAC,CAAC,IAAI,EAAE,GAAGsD;YAC9E;YACA,0EAA0E;YAC1E,+CAA+C;YAC/CC,wBAAwB;YACxBpD;QACF;QACA3C,KAAK;YAAEmC,SAAS;QAAK;QACrBU;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CA2DnD"}
1
+ {"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAgEnD"}
@@ -38,6 +38,11 @@ window.__vite_plugin_react_preamble_installed__ = true
38
38
  return chunk;
39
39
  }
40
40
  const str = typeof chunk === 'string' ? chunk : Buffer.isBuffer(chunk) ? chunk.toString() : chunk instanceof Uint8Array ? Buffer.from(chunk).toString() : null;
41
+ // Skip if a host already injected the preamble — a second copy breaks HMR.
42
+ if (str && str.includes('__vite_plugin_react_preamble_installed__')) {
43
+ injected = true;
44
+ return chunk;
45
+ }
41
46
  if (str && str.includes('</head>')) {
42
47
  injected = true;
43
48
  return str.replace('</head>', `${devScripts}</head>`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/workarounds/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
+ {"version":3,"sources":["../../../src/vite/workarounds/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 // Skip if a host already injected the preamble — a second copy breaks HMR.\n if (str && str.includes('__vite_plugin_react_preamble_installed__')) {\n injected = true\n return chunk\n }\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","ss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AI,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"}
@@ -2,20 +2,12 @@ import type { PluginOption } from 'vite';
2
2
  /**
3
3
  * Stubs `prettier` in the CLIENT bundle only.
4
4
  *
5
- * `payload`'s barrel transitively pulls `configToJSONSchema` →
6
- * `json-schema-to-typescript` → `prettier` (CommonJS) into the client module
7
- * graph through re-export side effects. That path is type-generation only
8
- * (`payload generate:types`) and never runs in the browser, but the bundler
9
- * still drags `prettier`'s `index.cjs` in — where it fails to parse as ESM and
10
- * breaks the client build.
5
+ * `payload`'s barrel transitively pulls `json-schema-to-typescript` → `prettier`
6
+ * (CommonJS) into the client graph. That path is type-gen only and never runs in
7
+ * the browser, but the bundler still drags in `prettier`'s `index.cjs`, which
8
+ * fails to parse as ESM and breaks the client build. SSR/RSC keep real prettier.
11
9
  *
12
- * We redirect `prettier` to a no-op `format` stub in the client environment
13
- * only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`
14
- * stays external and resolves it from `node_modules`), and the `prettier` CLI /
15
- * `payload generate:types` are unaffected.
16
- *
17
- * Delete this once `payload`'s barrel no longer reaches the type-gen path from
18
- * the client-reachable export graph.
10
+ * Delete once `payload`'s barrel no longer reaches type-gen from the client graph.
19
11
  */
20
12
  export declare function stubPrettierInClient(): PluginOption;
21
13
  //# sourceMappingURL=stubPrettierInClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stubPrettierInClient.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAoBnD"}
1
+ {"version":3,"file":"stubPrettierInClient.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAqBnD"}
@@ -1,20 +1,12 @@
1
1
  /**
2
2
  * Stubs `prettier` in the CLIENT bundle only.
3
3
  *
4
- * `payload`'s barrel transitively pulls `configToJSONSchema` →
5
- * `json-schema-to-typescript` → `prettier` (CommonJS) into the client module
6
- * graph through re-export side effects. That path is type-generation only
7
- * (`payload generate:types`) and never runs in the browser, but the bundler
8
- * still drags `prettier`'s `index.cjs` in — where it fails to parse as ESM and
9
- * breaks the client build.
4
+ * `payload`'s barrel transitively pulls `json-schema-to-typescript` → `prettier`
5
+ * (CommonJS) into the client graph. That path is type-gen only and never runs in
6
+ * the browser, but the bundler still drags in `prettier`'s `index.cjs`, which
7
+ * fails to parse as ESM and breaks the client build. SSR/RSC keep real prettier.
10
8
  *
11
- * We redirect `prettier` to a no-op `format` stub in the client environment
12
- * only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`
13
- * stays external and resolves it from `node_modules`), and the `prettier` CLI /
14
- * `payload generate:types` are unaffected.
15
- *
16
- * Delete this once `payload`'s barrel no longer reaches the type-gen path from
17
- * the client-reachable export graph.
9
+ * Delete once `payload`'s barrel no longer reaches type-gen from the client graph.
18
10
  */ export function stubPrettierInClient() {
19
11
  const RESOLVED_ID = '\0payload:prettier-client-stub';
20
12
  return {
@@ -25,11 +17,12 @@
25
17
  return 'export const format = (source) => source;\nexport default { format };';
26
18
  }
27
19
  },
28
- resolveId (id, _importer, options) {
20
+ resolveId (id, importer, options) {
29
21
  if (options?.ssr) {
30
22
  return;
31
23
  }
32
- if (id === 'prettier') {
24
+ // Only stub the type-gen import; leave a host's own client `prettier` alone.
25
+ if (id === 'prettier' && importer?.includes('json-schema-to-typescript')) {
33
26
  return RESOLVED_ID;
34
27
  }
35
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Stubs `prettier` in the CLIENT bundle only.\n *\n * `payload`'s barrel transitively pulls `configToJSONSchema` →\n * `json-schema-to-typescript` → `prettier` (CommonJS) into the client module\n * graph through re-export side effects. That path is type-generation only\n * (`payload generate:types`) and never runs in the browser, but the bundler\n * still drags `prettier`'s `index.cjs` in where it fails to parse as ESM and\n * breaks the client build.\n *\n * We redirect `prettier` to a no-op `format` stub in the client environment\n * only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`\n * stays external and resolves it from `node_modules`), and the `prettier` CLI /\n * `payload generate:types` are unaffected.\n *\n * Delete this once `payload`'s barrel no longer reaches the type-gen path from\n * the client-reachable export graph.\n */\nexport function stubPrettierInClient(): PluginOption {\n const RESOLVED_ID = '\\0payload:prettier-client-stub'\n\n return {\n name: 'payload:stub-prettier-in-client',\n enforce: 'pre',\n load(id) {\n if (id === RESOLVED_ID) {\n return 'export const format = (source) => source;\\nexport default { format };'\n }\n },\n resolveId(id, _importer, options) {\n if (options?.ssr) {\n return\n }\n if (id === 'prettier') {\n return RESOLVED_ID\n }\n },\n }\n}\n"],"names":["stubPrettierInClient","RESOLVED_ID","name","enforce","load","id","resolveId","_importer","options","ssr"],"mappings":"AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASA;IACd,MAAMC,cAAc;IAEpB,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAOJ,aAAa;gBACtB,OAAO;YACT;QACF;QACAK,WAAUD,EAAE,EAAEE,SAAS,EAAEC,OAAO;YAC9B,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,IAAIJ,OAAO,YAAY;gBACrB,OAAOJ;YACT;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Stubs `prettier` in the CLIENT bundle only.\n *\n * `payload`'s barrel transitively pulls `json-schema-to-typescript` → `prettier`\n * (CommonJS) into the client graph. That path is type-gen only and never runs in\n * the browser, but the bundler still drags in `prettier`'s `index.cjs`, which\n * fails to parse as ESM and breaks the client build. SSR/RSC keep real prettier.\n *\n * Delete once `payload`'s barrel no longer reaches type-gen from the client graph.\n */\nexport function stubPrettierInClient(): PluginOption {\n const RESOLVED_ID = '\\0payload:prettier-client-stub'\n\n return {\n name: 'payload:stub-prettier-in-client',\n enforce: 'pre',\n load(id) {\n if (id === RESOLVED_ID) {\n return 'export const format = (source) => source;\\nexport default { format };'\n }\n },\n resolveId(id, importer, options) {\n if (options?.ssr) {\n return\n }\n // Only stub the type-gen import; leave a host's own client `prettier` alone.\n if (id === 'prettier' && importer?.includes('json-schema-to-typescript')) {\n return RESOLVED_ID\n }\n },\n }\n}\n"],"names":["stubPrettierInClient","RESOLVED_ID","name","enforce","load","id","resolveId","importer","options","ssr","includes"],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,SAASA;IACd,MAAMC,cAAc;IAEpB,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAOJ,aAAa;gBACtB,OAAO;YACT;QACF;QACAK,WAAUD,EAAE,EAAEE,QAAQ,EAAEC,OAAO;YAC7B,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,6EAA6E;YAC7E,IAAIJ,OAAO,cAAcE,UAAUG,SAAS,8BAA8B;gBACxE,OAAOT;YACT;QACF;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-internal.203916b",
3
+ "version": "4.0.0-internal.21664f3",
4
4
  "description": "TanStack Start framework adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -57,32 +57,39 @@
57
57
  "dist"
58
58
  ],
59
59
  "dependencies": {
60
- "@vitejs/plugin-react": "^6.0.0",
61
- "@vitejs/plugin-rsc": "^0.5.21",
62
60
  "qs-esm": "^7.0.2",
63
- "@payloadcms/translations": "4.0.0-internal.203916b",
64
- "@payloadcms/ui": "4.0.0-internal.203916b"
61
+ "@payloadcms/translations": "4.0.0-internal.21664f3",
62
+ "@payloadcms/ui": "4.0.0-internal.21664f3"
65
63
  },
66
64
  "devDependencies": {
67
65
  "@tanstack/react-router": "^1.120.0",
68
66
  "@tanstack/react-start": "^1.168.26",
69
67
  "@types/react": "^19.0.0",
70
68
  "@types/react-dom": "^19.0.0",
69
+ "@vitejs/plugin-react": "^6.0.0",
71
70
  "@vitejs/plugin-rsc": "^0.5.21",
72
71
  "react": "^19.0.0",
73
72
  "react-dom": "^19.0.0",
74
73
  "vite": ">=8.0.0",
75
- "payload": "4.0.0-internal.203916b"
74
+ "payload": "4.0.0-internal.21664f3"
76
75
  },
77
76
  "peerDependencies": {
78
77
  "@tanstack/react-router": "^1.120.0",
79
78
  "@tanstack/react-start": "^1.168.26",
79
+ "@vitejs/plugin-react": "^6.0.0",
80
+ "@vitejs/plugin-rsc": "^0.5.21",
80
81
  "react": "^19.0.0",
81
82
  "react-dom": "^19.0.0",
82
83
  "vite": ">=8.0.0",
83
- "payload": "4.0.0-internal.203916b"
84
+ "payload": "4.0.0-internal.21664f3"
84
85
  },
85
86
  "peerDependenciesMeta": {
87
+ "@vitejs/plugin-react": {
88
+ "optional": true
89
+ },
90
+ "@vitejs/plugin-rsc": {
91
+ "optional": true
92
+ },
86
93
  "vite": {
87
94
  "optional": true
88
95
  }
@@ -1,10 +0,0 @@
1
- import type { Theme } from '@payloadcms/ui';
2
- import type { SanitizedConfig } from 'payload';
3
- type GetRequestThemeArgs = {
4
- config: SanitizedConfig;
5
- cookies: Map<string, string>;
6
- headers: Headers;
7
- };
8
- export declare function getRequestTheme({ config, cookies, headers }: GetRequestThemeArgs): Theme;
9
- export {};
10
- //# sourceMappingURL=getRequestTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRequestTheme.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAUD,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAkBxF"}
@@ -1,25 +0,0 @@
1
- // Defined locally rather than imported from `@payloadcms/ui` (a `'use client'`
2
- // barrel) because its value exports resolve to non-serializable client
3
- // references in this adapter's RSC server context. `Theme` is a type-only
4
- // import and is safely erased at runtime.
5
- const defaultTheme = 'light';
6
- const acceptedThemes = [
7
- 'dark',
8
- 'light'
9
- ];
10
- export function getRequestTheme({ config, cookies, headers }) {
11
- if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {
12
- return config.admin.theme;
13
- }
14
- const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`);
15
- if (themeCookie && acceptedThemes.includes(themeCookie)) {
16
- return themeCookie;
17
- }
18
- const themeFromHeader = headers.get('Sec-CH-Prefers-Color-Scheme');
19
- if (themeFromHeader && acceptedThemes.includes(themeFromHeader)) {
20
- return themeFromHeader;
21
- }
22
- return defaultTheme;
23
- }
24
-
25
- //# sourceMappingURL=getRequestTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/getRequestTheme.ts"],"sourcesContent":["import type { Theme } from '@payloadcms/ui'\nimport type { SanitizedConfig } from 'payload'\n\ntype GetRequestThemeArgs = {\n config: SanitizedConfig\n cookies: Map<string, string>\n headers: Headers\n}\n\n// Defined locally rather than imported from `@payloadcms/ui` (a `'use client'`\n// barrel) because its value exports resolve to non-serializable client\n// references in this adapter's RSC server context. `Theme` is a type-only\n// import and is safely erased at runtime.\nconst defaultTheme: Theme = 'light'\n\nconst acceptedThemes: Theme[] = ['dark', 'light']\n\nexport function getRequestTheme({ config, cookies, headers }: GetRequestThemeArgs): Theme {\n if (config.admin.theme !== 'all' && acceptedThemes.includes(config.admin.theme)) {\n return config.admin.theme\n }\n\n const themeCookie = cookies.get(`${config.cookiePrefix || 'payload'}-theme`)\n\n if (themeCookie && acceptedThemes.includes(themeCookie as Theme)) {\n return themeCookie as Theme\n }\n\n const themeFromHeader = headers.get('Sec-CH-Prefers-Color-Scheme') as Theme\n\n if (themeFromHeader && acceptedThemes.includes(themeFromHeader)) {\n return themeFromHeader\n }\n\n return defaultTheme\n}\n"],"names":["defaultTheme","acceptedThemes","getRequestTheme","config","cookies","headers","admin","theme","includes","themeCookie","get","cookiePrefix","themeFromHeader"],"mappings":"AASA,+EAA+E;AAC/E,uEAAuE;AACvE,0EAA0E;AAC1E,0CAA0C;AAC1C,MAAMA,eAAsB;AAE5B,MAAMC,iBAA0B;IAAC;IAAQ;CAAQ;AAEjD,OAAO,SAASC,gBAAgB,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAuB;IAC/E,IAAIF,OAAOG,KAAK,CAACC,KAAK,KAAK,SAASN,eAAeO,QAAQ,CAACL,OAAOG,KAAK,CAACC,KAAK,GAAG;QAC/E,OAAOJ,OAAOG,KAAK,CAACC,KAAK;IAC3B;IAEA,MAAME,cAAcL,QAAQM,GAAG,CAAC,GAAGP,OAAOQ,YAAY,IAAI,UAAU,MAAM,CAAC;IAE3E,IAAIF,eAAeR,eAAeO,QAAQ,CAACC,cAAuB;QAChE,OAAOA;IACT;IAEA,MAAMG,kBAAkBP,QAAQK,GAAG,CAAC;IAEpC,IAAIE,mBAAmBX,eAAeO,QAAQ,CAACI,kBAAkB;QAC/D,OAAOA;IACT;IAEA,OAAOZ;AACT"}