@payloadcms/tanstack-start 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ec73d44

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 (91) hide show
  1. package/dist/adapters/handleServerFunctions.d.ts +2 -1
  2. package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
  3. package/dist/adapters/handleServerFunctions.js +12 -4
  4. package/dist/adapters/handleServerFunctions.js.map +1 -1
  5. package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
  6. package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
  7. package/dist/adapters/layout/RootProviders/index.js +21 -0
  8. package/dist/adapters/layout/RootProviders/index.js.map +1 -0
  9. package/dist/adapters/layout/index.d.ts +7 -4
  10. package/dist/adapters/layout/index.d.ts.map +1 -1
  11. package/dist/adapters/layout/index.js +3 -1
  12. package/dist/adapters/layout/index.js.map +1 -1
  13. package/dist/adapters/layout/lazy.d.ts +1 -5
  14. package/dist/adapters/layout/lazy.d.ts.map +1 -1
  15. package/dist/adapters/layout/lazy.js +9 -15
  16. package/dist/adapters/layout/lazy.js.map +1 -1
  17. package/dist/adapters/layout/outlet.d.ts +4 -0
  18. package/dist/adapters/layout/outlet.d.ts.map +1 -0
  19. package/dist/adapters/layout/outlet.js +9 -0
  20. package/dist/adapters/layout/outlet.js.map +1 -0
  21. package/dist/adapters/layout/server.d.ts +7 -13
  22. package/dist/adapters/layout/server.d.ts.map +1 -1
  23. package/dist/adapters/layout/server.js +18 -16
  24. package/dist/adapters/layout/server.js.map +1 -1
  25. package/dist/adapters/router.d.ts.map +1 -1
  26. package/dist/adapters/router.js +17 -13
  27. package/dist/adapters/router.js.map +1 -1
  28. package/dist/adapters/server.d.ts.map +1 -1
  29. package/dist/adapters/server.js +2 -29
  30. package/dist/adapters/server.js.map +1 -1
  31. package/dist/adapters/views/index.d.ts +5 -2
  32. package/dist/adapters/views/index.d.ts.map +1 -1
  33. package/dist/adapters/views/index.js +29 -8
  34. package/dist/adapters/views/index.js.map +1 -1
  35. package/dist/adapters/views/lazy.d.ts.map +1 -1
  36. package/dist/adapters/views/lazy.js +5 -4
  37. package/dist/adapters/views/lazy.js.map +1 -1
  38. package/dist/adapters/views/server.d.ts +5 -2
  39. package/dist/adapters/views/server.d.ts.map +1 -1
  40. package/dist/adapters/views/server.js +12 -3
  41. package/dist/adapters/views/server.js.map +1 -1
  42. package/dist/auth/login.js.map +1 -1
  43. package/dist/exports/client/layout.d.ts +2 -0
  44. package/dist/exports/client/layout.d.ts.map +1 -0
  45. package/dist/exports/client/layout.js +4 -0
  46. package/dist/exports/client/layout.js.map +1 -0
  47. package/dist/exports/client.d.ts +1 -1
  48. package/dist/exports/client.d.ts.map +1 -1
  49. package/dist/exports/client.js +1 -1
  50. package/dist/exports/client.js.map +1 -1
  51. package/dist/exports/routes.d.ts +2 -0
  52. package/dist/exports/routes.d.ts.map +1 -0
  53. package/dist/exports/routes.js +3 -0
  54. package/dist/exports/routes.js.map +1 -0
  55. package/dist/exports/server.d.ts +0 -3
  56. package/dist/exports/server.d.ts.map +1 -1
  57. package/dist/exports/server.js +0 -3
  58. package/dist/exports/server.js.map +1 -1
  59. package/dist/routes/rest/handler.server.d.ts +3 -3
  60. package/dist/routes/rest/handler.server.d.ts.map +1 -1
  61. package/dist/routes/rest/handler.server.js +4 -7
  62. package/dist/routes/rest/handler.server.js.map +1 -1
  63. package/dist/routes/rest/index.d.ts +4 -3
  64. package/dist/routes/rest/index.d.ts.map +1 -1
  65. package/dist/routes/rest/index.js +4 -3
  66. package/dist/routes/rest/index.js.map +1 -1
  67. package/dist/utilities/devConfigReload.server.js +2 -4
  68. package/dist/utilities/devConfigReload.server.js.map +1 -1
  69. package/dist/utilities/serverFunctionClient.d.ts +2 -23
  70. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  71. package/dist/utilities/serverFunctionClient.js +12 -106
  72. package/dist/utilities/serverFunctionClient.js.map +1 -1
  73. package/dist/withPayload/config/external.d.ts +6 -16
  74. package/dist/withPayload/config/external.d.ts.map +1 -1
  75. package/dist/withPayload/config/external.js +18 -26
  76. package/dist/withPayload/config/external.js.map +1 -1
  77. package/dist/withPayload/importProtection.js +1 -1
  78. package/dist/withPayload/importProtection.js.map +1 -1
  79. package/dist/withPayload/index.d.ts +3 -1
  80. package/dist/withPayload/index.d.ts.map +1 -1
  81. package/dist/withPayload/index.js +14 -6
  82. package/dist/withPayload/index.js.map +1 -1
  83. package/package.json +31 -28
  84. package/dist/utilities/serializeForRsc.d.ts +0 -26
  85. package/dist/utilities/serializeForRsc.d.ts.map +0 -1
  86. package/dist/utilities/serializeForRsc.js +0 -127
  87. package/dist/utilities/serializeForRsc.js.map +0 -1
  88. package/dist/utilities/toSerializable.d.ts +0 -11
  89. package/dist/utilities/toSerializable.d.ts.map +0 -1
  90. package/dist/utilities/toSerializable.js +0 -127
  91. package/dist/utilities/toSerializable.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/withPayload/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport {\n buildExternalPackages,\n payloadNoExternalPatterns,\n ssrExternalPackages,\n} from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport { payloadDevConfigReload } from './devConfigReload.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 *\n * `Failed to load source map` covers deps that ship a `sourceMappingURL` comment\n * without the `.map` file it points at (e.g. `undici`'s `lib/llhttp/*.js`, pulled\n * in via `@vercel/blob`). Vite appends the underlying `ENOENT` stack to that one,\n * so each occurrence is a ~10-line block that buries real log output.\n */\nconst suppressibleWarningPatterns = [\n 'points to missing source files',\n 'Sourcemap for',\n 'Failed to load source map',\n 'references a map file outside its package',\n]\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 /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /**\n * Packages added to `ssr.external` on dev serve only (the build bundles them).\n * List CommonJS deps that 500 with `__cjs_module_runner_transform` — the RSC\n * plugin's CJS-to-ESM rewrite breaks on their circular `require`s.\n */\n devServerExternalPackages?: 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 `nitro()` options Payload's server build requires. Typed structurally — `nitro` is the host's dependency, not Payload's. */\nexport type PayloadNitroOptions = {\n traceDeps: string[]\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n nitro: PayloadNitroOptions\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 * nitro(pluginOptions.nitro), // only if the app deploys through Nitro\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 clientDenialExcludeFiles = [],\n devServerExternalPackages = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n // `pluralize` ships a UMD wrapper that throws when run through Vite's dev SSR\n // transform, so dev serve keeps it external and lets Node require it.\n // The production build must bundle it instead: it is reached from the\n // force-bundled `@payloadcms/ui` / `@payloadcms/translations`, and Vite would\n // otherwise externalize it into a client chunk as a bare specifier that pnpm\n // can't resolve from `dist/` at runtime. Dropping it from the externals list\n // isn't enough — Vite externalizes deps of `noExternal` packages by default,\n // so it must be forced back in via `noExternal`.\n const isBuild = env.command === 'build'\n const noExternalPatterns = isBuild\n ? [...payloadNoExternalPatterns, 'pluralize']\n : payloadNoExternalPatterns\n // Dev serve externalizes the server-only Node packages (including `pluralize`,\n // whose UMD wrapper breaks under Vite's SSR transform). The prod build instead\n // externalizes the package boundaries (`buildExternalPackages`) and drops\n // `pluralize` so it bundles — leaving it in `ssr.external` here would win over\n // `noExternal` and re-emit the bare specifier.\n // Dev serve also honors `devServerExternalPackages`, the app's own CJS\n // dependencies that break under the RSC plugin's CJS-to-ESM rewrite; the build\n // needs none of it, since Rollup bundles CJS correctly.\n const ssrExternal = isBuild\n ? buildExternalPackages\n : [...ssrExternalPackages, ...devServerExternalPackages]\n\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\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 payloadDevConfigReload({ payloadConfigPath }),\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: ssrExternal,\n noExternal: noExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n nitro: payloadNitroOptions(),\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\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/**\n * `nitro/vite` options for Payload's server build. `tslib*` full-traces `tslib`\n * so an externalized dep's `tslib/modules/index.js` import (its `import.node`\n * export condition) ships — otherwise the build is green and the server 500s\n * with `ERR_MODULE_NOT_FOUND` on the first request.\n */\nexport function payloadNitroOptions(): PayloadNitroOptions {\n return { traceDeps: ['tslib*'] }\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 * 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 * route discovery). 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 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 // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:d\\\\.ts|js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","buildExternalPackages","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","payloadDevConfigReload","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","clientDenialExcludeFiles","devServerExternalPackages","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","isBuild","command","noExternalPatterns","ssrExternal","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","nitro","payloadNitroOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","traceDeps","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;A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GACjF,OAAO,SAASL;IACd,OAAO;QAAEb,SAAS,EAAE;QAAEC,SAAS;IAAa;AAC9C;AAiBA;;;;CAIC,GACD,OAAO,SAASc,4BACdI,OAAwC,CAAC,CAAC;IAE1C,MAAM,EACJhD,4BAA4B,EAAE,EAC9BC,2BAA2B,EAAE,EAC7BG,kBAAkB,KAAK,EACvBE,eAAe,KAAK,EACrB,GAAG0C;IAEJ,OAAO;QACLC,kBAAkB;YAChBC,QAAQ;gBAAEC,cAAc,EAAE;gBAAEC,YAAYhF;YAA2B;YACnEiF,iBAAiB;mBAAInF;mBAA2C8B;aAA0B;YAC1F8B,SAAS;gBAAC;aAAO;YACjBwB,YAAY;YACZC,aAAapF;YACb,4EAA4E;YAC5E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,oEAAoE;YACpEqF,QAAQ;gBAAEL,cAAc;oBAAC;uBAAyBlD;iBAAyB;YAAC;QAC9E;QACAwD,QAAQ;YACN,0EAA0E;YAC1E,+CAA+C;YAC/CC,wBAAwB;YACxBtD;QACF;QACA7C,KAAK;YAAEqC,SAAS;QAAK;QACrBU;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/withPayload/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport {\n buildExternalPackages,\n devExternalPackages,\n payloadNoExternalPatterns,\n ssrExternalPackages,\n} from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport { payloadDevConfigReload } from './devConfigReload.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 *\n * `Failed to load source map` covers deps that ship a `sourceMappingURL` comment\n * without the `.map` file it points at (e.g. `undici`'s `lib/llhttp/*.js`, pulled\n * in via `@vercel/blob`). Vite appends the underlying `ENOENT` stack to that one,\n * so each occurrence is a ~10-line block that buries real log output.\n */\nconst suppressibleWarningPatterns = [\n 'points to missing source files',\n 'Sourcemap for',\n 'Failed to load source map',\n 'references a map file outside its package',\n]\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 /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Transform server packages in development. Enable when linking Payload source. Defaults to `false`. */\n devBundleServerPackages?: boolean\n /**\n * Packages added to `ssr.external` on dev serve only (the build bundles them).\n * List CommonJS deps that 500 with `__cjs_module_runner_transform` — the RSC\n * plugin's CJS-to-ESM rewrite breaks on their circular `require`s.\n */\n devServerExternalPackages?: 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 `nitro()` options Payload's server build requires. Typed structurally — `nitro` is the host's dependency, not Payload's. */\nexport type PayloadNitroOptions = {\n traceDeps: string[]\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n nitro: PayloadNitroOptions\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 * nitro(pluginOptions.nitro), // only if the app deploys through Nitro\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 clientDenialExcludeFiles = [],\n devBundleServerPackages = false,\n devServerExternalPackages = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n // `pluralize` ships a UMD wrapper that throws when run through Vite's dev SSR\n // transform, so dev serve keeps it external and lets Node require it.\n // The production build must bundle it instead: it is reached from the\n // force-bundled `@payloadcms/ui` / `@payloadcms/translations`, and Vite would\n // otherwise externalize it into a client chunk as a bare specifier that pnpm\n // can't resolve from `dist/` at runtime. Dropping it from the externals list\n // isn't enough — Vite externalizes deps of `noExternal` packages by default,\n // so it must be forced back in via `noExternal`.\n const isBuild = env.command === 'build'\n const noExternalPatterns = isBuild\n ? [...payloadNoExternalPatterns, 'pluralize']\n : payloadNoExternalPatterns\n // Dev serve externalizes the server-only Node packages (including `pluralize`,\n // whose UMD wrapper breaks under Vite's SSR transform). The prod build instead\n // externalizes the package boundaries (`buildExternalPackages`) and drops\n // `pluralize` so it bundles — leaving it in `ssr.external` here would win over\n // `noExternal` and re-emit the bare specifier.\n // Dev serve also honors `devServerExternalPackages`, the app's own CJS\n // dependencies that break under the RSC plugin's CJS-to-ESM rewrite; the build\n // needs none of it, since Rollup bundles CJS correctly.\n const ssrExternal = isBuild\n ? buildExternalPackages\n : [\n ...new Set([\n ...(devBundleServerPackages ? [] : devExternalPackages),\n ...devServerExternalPackages,\n ...ssrExternalPackages,\n ]),\n ]\n\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 },\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: {\n external: isBuild ? undefined : ssrExternal,\n noExternal: noExternalPatterns,\n },\n },\n ssr: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: {\n external: isBuild ? undefined : ssrExternal,\n noExternal: noExternalPatterns,\n },\n },\n },\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 payloadDevConfigReload({ payloadConfigPath }),\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 },\n ssr: {\n external: ssrExternal,\n noExternal: noExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n nitro: payloadNitroOptions(),\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\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/**\n * `nitro/vite` options for Payload's server build. `tslib*` full-traces `tslib`\n * so an externalized dep's `tslib/modules/index.js` import (its `import.node`\n * export condition) ships — otherwise the build is green and the server 500s\n * with `ERR_MODULE_NOT_FOUND` on the first request.\n */\nexport function payloadNitroOptions(): PayloadNitroOptions {\n return { traceDeps: ['tslib*'] }\n}\n\n/** Transforms application and workspace source without refreshing installed dependencies. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: /node_modules/, include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\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 * route discovery). 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 clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n exclude: ['**/node_modules/**'],\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 // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:d\\\\.ts|js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n },\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","buildExternalPackages","devExternalPackages","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","payloadDevConfigReload","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","clientDenialExcludeFiles","devBundleServerPackages","devServerExternalPackages","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","isBuild","command","noExternalPatterns","ssrExternal","Set","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","undefined","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","nitro","payloadNitroOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","traceDeps","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,yBAAyB,EACzBC,mBAAmB,QACd,uBAAsB;AAC7B,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,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;;;;;;;;;CASC,GACD,MAAMC,8BAA8B;IAClC;IACA;IACA;IACA;CACD;AAED;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYrB;IAC3B,MAAMuB,iBAAiB,CAACC,MACtB,OAAOA,QAAQ,YAAYL,4BAA4BM,IAAI,CAAC,CAAC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/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-internal.ea6e8f8",
3
+ "version": "4.0.0-internal.ec73d44",
4
4
  "description": "TanStack Start framework adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/payloadcms/payload.git",
9
- "directory": "packages/tanstack-start"
10
- },
11
6
  "license": "MIT",
12
7
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
8
  "maintainers": [
@@ -17,7 +12,17 @@
17
12
  "url": "https://payloadcms.com"
18
13
  }
19
14
  ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/payloadcms/payload.git",
18
+ "directory": "packages/tanstack-start"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
20
23
  "type": "module",
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
21
26
  "exports": {
22
27
  ".": {
23
28
  "import": "./dist/index.js",
@@ -34,6 +39,11 @@
34
39
  "types": "./dist/exports/server.d.ts",
35
40
  "default": "./dist/exports/server.js"
36
41
  },
42
+ "./routes": {
43
+ "import": "./dist/exports/routes.js",
44
+ "types": "./dist/exports/routes.d.ts",
45
+ "default": "./dist/exports/routes.js"
46
+ },
37
47
  "./shared": {
38
48
  "import": "./dist/exports/shared.js",
39
49
  "types": "./dist/exports/shared.d.ts",
@@ -51,40 +61,35 @@
51
61
  "default": "./dist/exports/rsc.js"
52
62
  }
53
63
  },
54
- "main": "./dist/index.js",
55
- "types": "./dist/index.d.ts",
56
- "files": [
57
- "dist"
58
- ],
59
64
  "dependencies": {
65
+ "@payloadcms/graphql": "4.0.0-internal.ec73d44",
66
+ "@payloadcms/translations": "4.0.0-internal.ec73d44",
67
+ "@payloadcms/ui": "4.0.0-internal.ec73d44",
60
68
  "graphql-http": "1.22.4",
61
- "qs-esm": "^7.0.2",
62
- "@payloadcms/graphql": "4.0.0-internal.ea6e8f8",
63
- "@payloadcms/ui": "4.0.0-internal.ea6e8f8",
64
- "@payloadcms/translations": "4.0.0-internal.ea6e8f8"
69
+ "qs-esm": "^7.0.2"
65
70
  },
66
71
  "devDependencies": {
67
- "@tanstack/react-router": "^1.120.0",
68
- "@tanstack/react-start": "^1.168.60",
72
+ "@tanstack/react-router": "^1.170.44",
73
+ "@tanstack/react-start": "^1.169.1",
69
74
  "@types/react": "^19.0.0",
70
75
  "@types/react-dom": "^19.0.0",
71
76
  "@vitejs/plugin-react": "^6.0.0",
72
77
  "@vitejs/plugin-rsc": "^0.5.21",
73
- "react": "19.3.0",
74
- "react-dom": "19.3.0",
75
- "vite": ">=8.0.0",
76
- "payload": "4.0.0-internal.ea6e8f8"
78
+ "payload": "4.0.0-internal.ec73d44",
79
+ "react": "19.3.1",
80
+ "react-dom": "19.3.1",
81
+ "vite": ">=8.0.0"
77
82
  },
78
83
  "peerDependencies": {
79
- "@tanstack/react-router": "^1.120.0",
80
- "@tanstack/react-start": "^1.168.60",
84
+ "@tanstack/react-router": "^1.170.44",
85
+ "@tanstack/react-start": "^1.169.1",
81
86
  "@vitejs/plugin-react": "^6.0.0",
82
87
  "@vitejs/plugin-rsc": "^0.5.21",
83
88
  "graphql": "^16.8.1",
89
+ "payload": "4.0.0-internal.ec73d44",
84
90
  "react": "^19.0.0",
85
91
  "react-dom": "^19.0.0",
86
- "vite": ">=8.0.0",
87
- "payload": "4.0.0-internal.ea6e8f8"
92
+ "vite": ">=8.0.0"
88
93
  },
89
94
  "peerDependenciesMeta": {
90
95
  "@vitejs/plugin-react": {
@@ -98,7 +103,7 @@
98
103
  }
99
104
  },
100
105
  "engines": {
101
- "node": "^18.20.2 || >=20.9.0"
106
+ "node": ">=24.22.1"
102
107
  },
103
108
  "scripts": {
104
109
  "build": "pnpm build:types && pnpm test:types && pnpm build:swc",
@@ -107,8 +112,6 @@
107
112
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
108
113
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
109
114
  "clean": "rimraf {dist,*.tsbuildinfo}",
110
- "lint": "eslint .",
111
- "lint:fix": "eslint . --fix",
112
115
  "test:types": "tsc --project test/tsconfig.json"
113
116
  }
114
117
  }
@@ -1,26 +0,0 @@
1
- /**
2
- * Recursively walk a server-function return value and prepare it for transit
3
- * to the client as an RSC payload.
4
- *
5
- * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
6
- * refs) with two key differences:
7
- *
8
- * 1. React elements are NOT stripped. They are passed through
9
- * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
10
- * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
11
- * streams the underlying Flight payload to the client, where it is
12
- * decoded back into a renderable React node. This matches the way
13
- * Next.js's RSC payload format ships React elements over server actions
14
- * and lets server-rendered custom field components (e.g. those returned
15
- * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
16
- * round trip.
17
- *
18
- * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
19
- * transport cannot handle them, and Payload doesn't intentionally include
20
- * them in server-function return values.
21
- *
22
- * Use this in `createServerFn` handlers that return Payload form/view state
23
- * containing React elements (e.g. `state[path].customComponents.Field`).
24
- */
25
- export declare function serializeForRsc<T>(value: T): Promise<T>;
26
- //# sourceMappingURL=serializeForRsc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -1,127 +0,0 @@
1
- import { renderServerComponent } from '@tanstack/react-start/rsc';
2
- import { setOwnProperty } from 'payload/shared';
3
- import { createElement, Fragment } from 'react';
4
- /**
5
- * Recursively walk a server-function return value and prepare it for transit
6
- * to the client as an RSC payload.
7
- *
8
- * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
9
- * refs) with two key differences:
10
- *
11
- * 1. React elements are NOT stripped. They are passed through
12
- * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
13
- * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
14
- * streams the underlying Flight payload to the client, where it is
15
- * decoded back into a renderable React node. This matches the way
16
- * Next.js's RSC payload format ships React elements over server actions
17
- * and lets server-rendered custom field components (e.g. those returned
18
- * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
19
- * round trip.
20
- *
21
- * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
22
- * transport cannot handle them, and Payload doesn't intentionally include
23
- * them in server-function return values.
24
- *
25
- * Use this in `createServerFn` handlers that return Payload form/view state
26
- * containing React elements (e.g. `state[path].customComponents.Field`).
27
- */ export async function serializeForRsc(value) {
28
- return await walk(value, new WeakMap(), new WeakSet());
29
- }
30
- async function walk(value, cache, ancestors) {
31
- if (value === null || value === undefined) {
32
- return value;
33
- }
34
- const t = typeof value;
35
- if (t === 'function' || t === 'symbol') {
36
- return undefined;
37
- }
38
- if (t !== 'object') {
39
- return value;
40
- }
41
- const obj = value;
42
- if (typeof obj.$$typeof === 'symbol') {
43
- return await renderServerComponent(value);
44
- }
45
- if (ancestors.has(obj)) {
46
- return undefined;
47
- }
48
- if (cache.has(obj)) {
49
- return cache.get(obj);
50
- }
51
- if (obj instanceof Date) {
52
- return obj;
53
- }
54
- if (obj instanceof RegExp) {
55
- return undefined;
56
- }
57
- ancestors.add(obj);
58
- if (obj instanceof Map) {
59
- const cleaned = new Map();
60
- cache.set(obj, cleaned);
61
- for (const [k, v] of obj){
62
- const cv = await walk(v, cache, ancestors);
63
- if (cv !== undefined) {
64
- cleaned.set(k, cv);
65
- }
66
- }
67
- ancestors.delete(obj);
68
- return cleaned;
69
- }
70
- if (obj instanceof Set) {
71
- const cleaned = new Set();
72
- cache.set(obj, cleaned);
73
- for (const v of obj){
74
- const cv = await walk(v, cache, ancestors);
75
- if (cv !== undefined) {
76
- cleaned.add(cv);
77
- }
78
- }
79
- ancestors.delete(obj);
80
- return cleaned;
81
- }
82
- if (Array.isArray(obj)) {
83
- // An array consisting entirely of React elements (e.g. a field's
84
- // `beforeInput` / `afterInput` component list, produced by
85
- // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
86
- // Converting each element individually below turns every item into its own
87
- // `renderServerComponent` handle, which drops the element's React `key` —
88
- // the client then renders `{[handle, handle]}` as unkeyed array children
89
- // and React warns "Each child in a list should have a unique key prop".
90
- // Payload always renders these component arrays wholesale (`{BeforeInput}`),
91
- // so collapsing them into one Fragment-rendered handle is render-equivalent
92
- // and keeps the per-element keys intact inside the single Flight payload.
93
- const items = obj.filter((item)=>item !== null && item !== undefined);
94
- const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
95
- if (isReactElementArray) {
96
- ancestors.delete(obj);
97
- return await renderServerComponent(createElement(Fragment, null, ...obj));
98
- }
99
- const arr = [];
100
- cache.set(obj, arr);
101
- for (const item of obj){
102
- arr.push(await walk(item, cache, ancestors));
103
- }
104
- ancestors.delete(obj);
105
- return arr;
106
- }
107
- if (ArrayBuffer.isView(obj)) {
108
- ancestors.delete(obj);
109
- return obj;
110
- }
111
- const result = {};
112
- cache.set(obj, result);
113
- for (const key of Object.keys(obj)){
114
- const v = await walk(obj[key], cache, ancestors);
115
- if (v !== undefined) {
116
- setOwnProperty({
117
- key,
118
- target: result,
119
- value: v
120
- });
121
- }
122
- }
123
- ancestors.delete(obj);
124
- return result;
125
- }
126
-
127
- //# sourceMappingURL=serializeForRsc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { setOwnProperty } from 'payload/shared'\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) =>\n typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(\n createElement(Fragment, null, ...(obj as React.ReactNode[])),\n )\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 setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","setOwnProperty","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","target"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,aA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IACjB,OAAO2B;AACT"}
@@ -1,11 +0,0 @@
1
- import type { Serializable, SerializableExtensions } from '@tanstack/react-router';
2
- /** A record sanitized for TanStack's server-function transport. */
3
- export type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable'];
4
- /**
5
- * Removes values unsupported by TanStack's serializer. Trusted serializable
6
- * additions are merged afterward so opaque handles such as RSC payloads are
7
- * preserved while the source record is sanitized.
8
- */
9
- export declare function toSerializable<T>(value: T): T;
10
- export declare function toSerializable(value: Record<string, unknown>, additions: Record<string, Serializable>): SerializableRecord;
11
- //# sourceMappingURL=toSerializable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toSerializable.d.ts","sourceRoot":"","sources":["../../src/utilities/toSerializable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAIlF,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;AA+HpG;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;AAC9C,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GACtC,kBAAkB,CAAA"}
@@ -1,127 +0,0 @@
1
- import { setOwnProperty } from 'payload/shared';
2
- /**
3
- * Recursively strip values that seroval cannot serialize (React elements,
4
- * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.
5
- *
6
- * TanStack Start uses seroval to transfer server function return values to
7
- * the client. Payload's `getClientConfig` / `getLayoutData` may include
8
- * callback functions or RegExp instances that seroval chokes on. Running
9
- * the data through this function before returning from a `createServerFn`
10
- * handler keeps the transfer safe.
11
- *
12
- * For server functions whose payloads contain React elements (e.g. the
13
- * shared `form-state` / `render-list` / `render-document` handlers), use
14
- * `serializeForRsc` instead — it converts elements into RSC handles rather
15
- * than stripping them.
16
- *
17
- * Uses a WeakMap cache so that shared object references (e.g. the same array
18
- * referenced by both `doc.hasMany` and `formState.hasMany.value`) are
19
- * returned correctly instead of being dropped as "already seen".
20
- *
21
- * A separate `ancestors` WeakSet tracks objects currently being recursed into.
22
- * If an object is encountered while it is still on the recursion stack, the
23
- * reference is circular and is replaced with `undefined` to keep the output
24
- * JSON-safe. Once recursion completes the object is removed from `ancestors`,
25
- * so sibling/cousin references to the same (fully-processed) object still
26
- * resolve to the cached clone.
27
- */ function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
28
- if (value === null || value === undefined) {
29
- return value;
30
- }
31
- const t = typeof value;
32
- if (t === 'function' || t === 'symbol') {
33
- return undefined;
34
- }
35
- if (t !== 'object') {
36
- return value;
37
- }
38
- const obj = value;
39
- if (typeof obj.$$typeof === 'symbol') {
40
- return undefined;
41
- }
42
- if (ancestors.has(obj)) {
43
- return undefined;
44
- }
45
- if (cache.has(obj)) {
46
- return cache.get(obj);
47
- }
48
- if (obj instanceof Date) {
49
- return obj;
50
- }
51
- // RegExp: seroval's SSR bootstrap emits regex literals with broken escape
52
- // sequences (e.g. `/!\\[.../` instead of `/!\[.../`), crashing the client
53
- // script that populates `window.$_TSR` and preventing hydration. Rich-text
54
- // feature transformer regexes aren't needed on the client (they drive
55
- // server-side markdown import/export), so strip them here.
56
- if (obj instanceof RegExp) {
57
- return undefined;
58
- }
59
- ancestors.add(obj);
60
- if (obj instanceof Map) {
61
- const cleaned = new Map();
62
- cache.set(obj, cleaned);
63
- for (const [k, v] of obj){
64
- const cv = stripUnserializable(v, cache, ancestors);
65
- if (cv !== undefined) {
66
- cleaned.set(k, cv);
67
- }
68
- }
69
- ancestors.delete(obj);
70
- return cleaned;
71
- }
72
- if (obj instanceof Set) {
73
- const cleaned = new Set();
74
- cache.set(obj, cleaned);
75
- for (const v of obj){
76
- const cv = stripUnserializable(v, cache, ancestors);
77
- if (cv !== undefined) {
78
- cleaned.add(cv);
79
- }
80
- }
81
- ancestors.delete(obj);
82
- return cleaned;
83
- }
84
- if (Array.isArray(obj)) {
85
- const arr = [];
86
- cache.set(obj, arr);
87
- for (const item of obj){
88
- arr.push(stripUnserializable(item, cache, ancestors));
89
- }
90
- ancestors.delete(obj);
91
- return arr;
92
- }
93
- if (ArrayBuffer.isView(obj)) {
94
- ancestors.delete(obj);
95
- return obj;
96
- }
97
- const result = {};
98
- cache.set(obj, result);
99
- for (const key of Object.keys(obj)){
100
- const v = stripUnserializable(obj[key], cache, ancestors);
101
- if (v !== undefined) {
102
- setOwnProperty({
103
- key,
104
- target: result,
105
- value: v
106
- });
107
- }
108
- }
109
- ancestors.delete(obj);
110
- return result;
111
- }
112
- export function toSerializable(value, additions) {
113
- const serialized = stripUnserializable(value);
114
- if (additions) {
115
- if (typeof serialized !== 'object' || serialized === null || Array.isArray(serialized)) {
116
- throw new TypeError('Serializable additions require an object source');
117
- }
118
- const result = {
119
- ...serialized,
120
- ...additions
121
- };
122
- return result;
123
- }
124
- return serialized;
125
- }
126
-
127
- //# sourceMappingURL=toSerializable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/toSerializable.ts"],"sourcesContent":["import type { Serializable, SerializableExtensions } from '@tanstack/react-router'\n\nimport { setOwnProperty } from 'payload/shared'\n\n/** A record sanitized for TanStack's server-function transport. */\nexport type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable']\n\n/**\n * Recursively strip values that seroval cannot serialize (React elements,\n * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.\n *\n * TanStack Start uses seroval to transfer server function return values to\n * the client. Payload's `getClientConfig` / `getLayoutData` may include\n * callback functions or RegExp instances that seroval chokes on. Running\n * the data through this function before returning from a `createServerFn`\n * handler keeps the transfer safe.\n *\n * For server functions whose payloads contain React elements (e.g. the\n * shared `form-state` / `render-list` / `render-document` handlers), use\n * `serializeForRsc` instead — it converts elements into RSC handles rather\n * than stripping them.\n *\n * Uses a WeakMap cache so that shared object references (e.g. the same array\n * referenced by both `doc.hasMany` and `formState.hasMany.value`) are\n * returned correctly instead of being dropped as \"already seen\".\n *\n * A separate `ancestors` WeakSet tracks objects currently being recursed into.\n * If an object is encountered while it is still on the recursion stack, the\n * reference is circular and is replaced with `undefined` to keep the output\n * JSON-safe. Once recursion completes the object is removed from `ancestors`,\n * so sibling/cousin references to the same (fully-processed) object still\n * resolve to the cached clone.\n */\nfunction stripUnserializable(\n value: unknown,\n cache = new WeakMap<object, unknown>(),\n ancestors = new WeakSet<object>(),\n): 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 undefined\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 // RegExp: seroval's SSR bootstrap emits regex literals with broken escape\n // sequences (e.g. `/!\\\\[.../` instead of `/!\\[.../`), crashing the client\n // script that populates `window.$_TSR` and preventing hydration. Rich-text\n // feature transformer regexes aren't needed on the client (they drive\n // server-side markdown import/export), so strip them here.\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 = stripUnserializable(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 = stripUnserializable(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(stripUnserializable(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 = stripUnserializable(obj[key], cache, ancestors)\n if (v !== undefined) {\n setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n\n/**\n * Removes values unsupported by TanStack's serializer. Trusted serializable\n * additions are merged afterward so opaque handles such as RSC payloads are\n * preserved while the source record is sanitized.\n */\nexport function toSerializable<T>(value: T): T\nexport function toSerializable(\n value: Record<string, unknown>,\n additions: Record<string, Serializable>,\n): SerializableRecord\nexport function toSerializable(value: unknown, additions?: Record<string, Serializable>): unknown {\n const serialized = stripUnserializable(value)\n\n if (additions) {\n if (typeof serialized !== 'object' || serialized === null || Array.isArray(serialized)) {\n throw new TypeError('Serializable additions require an object source')\n }\n\n const result = { ...serialized, ...additions } satisfies Record<string, unknown>\n\n return result as SerializableRecord\n }\n\n return serialized\n}\n"],"names":["setOwnProperty","stripUnserializable","value","cache","WeakMap","ancestors","WeakSet","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","target","toSerializable","additions","serialized","TypeError"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAK/C;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,SAASC,oBACPC,KAAc,EACdC,QAAQ,IAAIC,SAA0B,EACtCC,YAAY,IAAIC,SAAiB;IAEjC,IAAIJ,UAAU,QAAQA,UAAUK,WAAW;QACzC,OAAOL;IACT;IAEA,MAAMM,IAAI,OAAON;IACjB,IAAIM,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IA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