@bgub/fig-tanstack-start 0.1.0-alpha.1 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## @bgub/fig-tanstack-start@0.1.0-alpha.3
2
+
3
+ ### Let Fig's Vite integration own runtime configuration
4
+
5
+ The new `fig()` Vite integration defines Fig's development gate and installs
6
+ Fast Refresh. TanStack Start composes it automatically, so applications no
7
+ longer need to configure Fig's compile-time mode or SSR package bundling
8
+ themselves.
9
+
10
+ `@bgub/fig-vite` now uses the application's Fig DOM renderer as a peer instead
11
+ of installing a private renderer copy.
12
+
13
+ The development gate follows Vite's command rather than its mode: serving
14
+ enables development behavior, while builds—including `--mode development`—strip
15
+ it from production output.
16
+
17
+ Published npm packages now expose development artifacts through a Fig-owned
18
+ condition, allowing the Vite integration to enable diagnostics and Fast Refresh
19
+ for ordinary installs while explicit static overrides remain authoritative and
20
+ default production imports retain their previous dead-code elimination. A
21
+ static `false` override also disables Fast Refresh instrumentation.
22
+
1
23
  ## @bgub/fig-tanstack-start@0.1.0-alpha.1
2
24
 
3
25
  ### Refresh resolves the app's renderer runtime
@@ -1,6 +1,6 @@
1
1
  import { n as payloadStylesheetsSymbolKey } from "../payload-assets-eHfSAMbN.js";
2
2
  import { START_ENVIRONMENT_NAMES, tanStackStartVite } from "@tanstack/start-plugin-core/vite";
3
- import { figRefresh } from "@bgub/fig-vite";
3
+ import { fig } from "@bgub/fig-vite";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { Buffer as Buffer$1 } from "node:buffer";
6
6
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
@@ -848,7 +848,7 @@ function tanstackStart(options) {
848
848
  ssrIsProvider: true,
849
849
  ssrResolverStrategy: { type: "default" }
850
850
  }, options),
851
- figRefresh()
851
+ ...fig()
852
852
  ];
853
853
  }
854
854
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":["Buffer"],"sources":["../../src/plugin/module-ids.ts","../../src/plugin/compatibility-profile.ts","../../src/plugin/compatibility-vite.ts","../../src/plugin/compiler-options.ts","../../src/plugin/isomorphic-manifest.ts","../../src/plugin/isomorphic-compiler.ts","../../src/plugin/payload-stylesheet-compiler.ts","../../src/plugin/payload-compiler.ts","../../src/plugin/server-payload-compiler.ts","../../src/plugin/public-assets.ts","../../src/plugin/payload-vite.ts","../../src/plugin/vite.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport { isAbsolute, relative, sep } from \"node:path\";\n\nexport const payloadManifestDefinitionQuery = \"fig-payload-manifest\";\nexport const payloadModuleQuery = \"fig-payload-module\";\nexport const payloadReferenceQuery = \"fig-payload-reference\";\n\nexport function cleanModuleId(id: string): string {\n const query = id.indexOf(\"?\");\n return query === -1 ? id : id.slice(0, query);\n}\n\nexport function moduleQueryValue(id: string, name: string): string | undefined {\n const query = id.indexOf(\"?\");\n if (query === -1) return undefined;\n const hash = id.indexOf(\"#\", query);\n const value = new URLSearchParams(\n id.slice(query + 1, hash === -1 ? undefined : hash),\n ).get(name);\n return value ?? undefined;\n}\n\nexport function hasModuleQuery(id: string, name: string): boolean {\n return moduleQueryValue(id, name) !== undefined;\n}\n\nexport function withModuleQuery(\n source: string,\n name: string,\n value: string,\n): string {\n const hash = source.indexOf(\"#\");\n const suffix = hash === -1 ? \"\" : source.slice(hash);\n const path = hash === -1 ? source : source.slice(0, hash);\n const separator = path.includes(\"?\") ? \"&\" : \"?\";\n return `${path}${separator}${name}=${encodeURIComponent(value)}${suffix}`;\n}\n\nexport function encodeOpaqueId(id: string): string {\n return Buffer.from(id).toString(\"base64url\");\n}\n\nexport function decodeOpaqueId(id: string): string {\n return Buffer.from(id, \"base64url\").toString();\n}\n\nexport function toViteModulePath(root: string, moduleId: string): string {\n const clean = cleanModuleId(moduleId);\n const path = isAbsolute(clean) ? relative(root, clean) : clean;\n const normalized = normalizePath(path);\n return isAbsolute(path) || normalized.startsWith(\"../\")\n ? toViteFsPath(clean)\n : `/${normalized.replace(/^\\/+/, \"\")}`;\n}\n\nexport function toViteFsPath(path: string): string {\n return `/@fs/${normalizePath(path).replace(/^\\/+/, \"\")}`;\n}\n\nfunction normalizePath(path: string): string {\n return path.split(sep).join(\"/\").replaceAll(\"\\\\\", \"/\");\n}\n","export const tanStackCompatibilityProfile = {\n id: \"tanstack-start-core-1.171\",\n framework: \"solid\",\n packages: {\n figRouter: \"@bgub/fig-tanstack-router\",\n figStart: \"@bgub/fig-tanstack-start\",\n frameworkRouter: \"@tanstack/solid-router\",\n frameworkStart: \"@tanstack/solid-start\",\n startClient: \"@tanstack/start-client-core\",\n startServer: \"@tanstack/start-server-core\",\n },\n versions: {\n routerCore: \"1.171.15\",\n startClientCore: \"1.170.14\",\n startPluginCore: \"1.171.22\",\n startServerCore: \"1.169.17\",\n },\n} as const;\n\nexport function createCompilerRpcModules(\n resolveDependency: (id: string) => string,\n) {\n const { frameworkStart, startClient, startServer } =\n tanStackCompatibilityProfile.packages;\n return [\n {\n source: `${frameworkStart}/client-rpc`,\n id: \"\\0fig-tanstack-start:client-rpc\",\n code: `export { createClientRpc } from \"${startClient}/client-rpc\";`,\n },\n {\n source: `${frameworkStart}/server-rpc`,\n id: \"\\0fig-tanstack-start:server-rpc\",\n code: `export { createServerRpc } from ${JSON.stringify(\n resolveDependency(`${startServer}/createServerRpc`),\n )};`,\n },\n {\n source: `${frameworkStart}/ssr-rpc`,\n id: \"\\0fig-tanstack-start:ssr-rpc\",\n code: `export { createSsrRpc } from ${JSON.stringify(\n resolveDependency(`${startServer}/createSsrRpc`),\n )};`,\n },\n ];\n}\n\nexport function createDefaultServerEntry(): string {\n const { figStart } = tanStackCompatibilityProfile.packages;\n return [\n `import { createFigStartHandler } from ${JSON.stringify(`${figStart}/server`)};`,\n \"const fetch = createFigStartHandler();\",\n \"export default { fetch };\",\n ].join(\"\\n\");\n}\n\nexport function rewriteFrameworkImports(code: string): string {\n const { figStart, frameworkStart } = tanStackCompatibilityProfile.packages;\n return code.replace(\n new RegExp(\n `\\\\b(from|import)\\\\s*(\\\\(\\\\s*)?([\"'])${escapeRegExp(figStart)}\\\\3`,\n \"g\",\n ),\n (_match, keyword: string, parenthesis: string | undefined, quote: string) =>\n `${keyword}${parenthesis === undefined ? \" \" : parenthesis}${quote}${frameworkStart}${quote}`,\n );\n}\n\nexport function incompatibleRuntimeModules(\n moduleIds: Iterable<string>,\n): string[] {\n const { frameworkRouter, frameworkStart } =\n tanStackCompatibilityProfile.packages;\n const forbiddenPackages = [frameworkRouter, frameworkStart];\n return [...moduleIds].filter((id) => {\n const normalized = id.replaceAll(\"\\\\\", \"/\");\n return forbiddenPackages.some((packageName) =>\n normalized.includes(`/node_modules/${packageName}/`),\n );\n });\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { fileURLToPath } from \"node:url\";\nimport { START_ENVIRONMENT_NAMES } from \"@tanstack/start-plugin-core/vite\";\nimport type { PluginOption } from \"vite\";\nimport { toViteFsPath } from \"./module-ids.ts\";\nimport {\n createCompilerRpcModules,\n createDefaultServerEntry,\n incompatibleRuntimeModules,\n rewriteFrameworkImports,\n tanStackCompatibilityProfile,\n} from \"./compatibility-profile.ts\";\n\nconst {\n figRouter: figRouterPackage,\n figStart: figTanStackStartPackage,\n frameworkRouter: tanstackRouterPackage,\n frameworkStart: tanstackStartPackage,\n startClient: tanstackStartClientPackage,\n} = tanStackCompatibilityProfile.packages;\n\nconst resolveDependency = (id: string) =>\n fileURLToPath(import.meta.resolve(id));\nconst tanstackStartClientModules = [\n tanstackStartClientPackage,\n `${tanstackStartClientPackage}/client`,\n `${tanstackStartClientPackage}/client-rpc`,\n] as const;\nconst tanstackStartClientAliases = tanstackStartClientModules.map((id) => ({\n find: new RegExp(`^${id}$`),\n replacement: resolveDependency(id),\n}));\nconst optimizedClientModules = [\"@tanstack/router-core/ssr/client\"] as const;\nconst applicationEntryIds = new Set([\n \"#tanstack-router-entry\",\n \"#tanstack-start-entry\",\n]);\nconst storageContextPath = fileURLToPath(\n new URL(\"../storage-context.js\", import.meta.url),\n);\n\nexport const defaultEntryPaths = {\n client: fileURLToPath(new URL(\"../default-entry/client.js\", import.meta.url)),\n server: fileURLToPath(new URL(\"../default-entry/server.js\", import.meta.url)),\n start: fileURLToPath(new URL(\"../default-entry/start.js\", import.meta.url)),\n} as const;\n\nconst compilerRpcModules = createCompilerRpcModules(resolveDependency);\n\nexport function startCompatibilityPlugin(): PluginOption {\n const applicationEntryUrls = new Map<string, string>();\n const optimizerApplicationEntries = {\n name: \"fig-tanstack-start:optimizer-application-entries\",\n resolveId(source: string) {\n const id = applicationEntryUrls.get(source);\n return id === undefined ? null : { external: true, id };\n },\n };\n\n return {\n name: \"fig-tanstack-start:compatibility\",\n enforce: \"pre\",\n config() {\n return {\n resolve: {\n alias: [\n ...tanstackStartClientAliases,\n {\n find: /^@tanstack\\/start-storage-context$/,\n replacement: storageContextPath,\n },\n {\n find: new RegExp(`^${tanstackRouterPackage}$`),\n replacement: figRouterPackage,\n },\n {\n find: new RegExp(`^${tanstackStartPackage}$`),\n replacement: figTanStackStartPackage,\n },\n ],\n dedupe: [figTanStackStartPackage, figRouterPackage],\n },\n };\n },\n configEnvironment(environmentName, environment) {\n if (environmentName !== START_ENVIRONMENT_NAMES.client) return undefined;\n const optimizerPlugins =\n environment.optimizeDeps?.rolldownOptions?.plugins;\n return {\n optimizeDeps: {\n include: [\n ...(environment.optimizeDeps?.include ?? []),\n ...optimizedClientModules,\n ],\n exclude: [\n ...(environment.optimizeDeps?.exclude ?? []),\n // Start's compiler must rewrite createIsomorphicFn branches per\n // environment; prebundling these first freezes server code into\n // the client graph and makes client-side server functions crash.\n ...tanstackStartClientModules,\n figTanStackStartPackage,\n figRouterPackage,\n ],\n rolldownOptions: {\n ...environment.optimizeDeps?.rolldownOptions,\n plugins: [\n ...(optimizerPlugins === undefined ? [] : [optimizerPlugins]),\n optimizerApplicationEntries,\n ],\n },\n },\n };\n },\n configResolved(config) {\n for (const alias of config.resolve.alias) {\n if (\n typeof alias.find === \"string\" &&\n applicationEntryIds.has(alias.find)\n ) {\n applicationEntryUrls.set(alias.find, toViteFsPath(alias.replacement));\n }\n }\n },\n generateBundle(_options, bundle) {\n if (this.environment.name !== START_ENVIRONMENT_NAMES.client) return;\n const emittedModuleIds = Object.values(bundle).flatMap((output) =>\n output.type === \"chunk\"\n ? Object.entries(output.modules).flatMap(([id, module]) =>\n module.renderedLength === 0 ? [] : [id],\n )\n : [],\n );\n const incompatible = incompatibleRuntimeModules(emittedModuleIds);\n if (incompatible.length === 0) return;\n throw new Error(\n `${tanStackCompatibilityProfile.id} resolved compatibility-only Solid modules into the client runtime:\\n${incompatible.join(\"\\n\")}`,\n );\n },\n resolveId(source) {\n return compilerRpcModules.find((module) => module.source === source)?.id;\n },\n load(id) {\n const rpcModule = compilerRpcModules.find((module) => module.id === id);\n if (rpcModule !== undefined) return rpcModule.code;\n if (id === defaultEntryPaths.server) return createDefaultServerEntry();\n return undefined;\n },\n transform(code) {\n const rewritten = rewriteFrameworkImports(code);\n return rewritten === code ? null : { code: rewritten, map: null };\n },\n };\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath } from \"@babel/core\";\nimport presetTypescript from \"@babel/preset-typescript\";\n\nexport const payloadPackageId = \"@bgub/fig-tanstack-start/payload\";\nexport const serverPackageId = \"@bgub/fig-tanstack-start/server\";\n\n// One home for what counts as a source module: the manifest glob and the\n// compiler analysis gates must accept the same files.\nexport const sourceModuleExtensions = [\n \"js\",\n \"jsx\",\n \"ts\",\n \"tsx\",\n \"cjs\",\n \"mjs\",\n \"cts\",\n \"mts\",\n] as const;\n\nconst sourceModulePattern = new RegExp(\n `\\\\.(?:${sourceModuleExtensions.join(\"|\")})$`,\n);\n\nexport function babelOptions(\n filename: string,\n): NonNullable<Parameters<typeof babel.transformAsync>[1]> {\n return {\n babelrc: false,\n configFile: false,\n filename,\n presets: [\n [\n presetTypescript,\n { ignoreExtensions: true, onlyRemoveTypeImports: true },\n ],\n ],\n parserOpts: { plugins: filename.endsWith(\"x\") ? [\"jsx\"] : [] },\n };\n}\n\nexport function isSourceModule(id: string): boolean {\n return sourceModulePattern.test(id);\n}\n\nexport function isComponentName(name: string): boolean {\n const first = name.codePointAt(0);\n return first !== undefined && first >= 65 && first <= 90;\n}\n\nexport function isImportedBinding(\n path: NodePath,\n localName: string,\n importedName: string,\n source: string,\n): boolean {\n const binding = path.scope.getBinding(localName);\n if (!binding?.path.isImportSpecifier()) return false;\n const imported = binding.path.node.imported;\n const actualName =\n imported.type === \"Identifier\" ? imported.name : imported.value;\n return (\n actualName === importedName &&\n binding.path.parentPath.isImportDeclaration() &&\n binding.path.parentPath.node.source.value === source\n );\n}\n","import { sourceModuleExtensions } from \"./compiler-options.ts\";\nimport type { CompiledIsomorphicImport } from \"./isomorphic-compiler.ts\";\nimport {\n decodeOpaqueId,\n encodeOpaqueId,\n moduleQueryValue,\n payloadManifestDefinitionQuery,\n payloadReferenceQuery,\n toViteModulePath,\n withModuleQuery,\n} from \"./module-ids.ts\";\n\nexport const payloadManifestId = \"virtual:fig-tanstack-start/payload-manifest\";\nexport const resolvedPayloadManifestId = `\\0${payloadManifestId}`;\n\nexport interface ManifestReference extends CompiledIsomorphicImport {\n developmentStylesheetHrefs: string[];\n resolvedModuleId: string;\n}\n\nexport function isomorphicReferenceId(\n root: string,\n moduleId: string,\n exportName: string,\n): string {\n return `${toViteModulePath(root, moduleId)}#${exportName}`;\n}\n\nexport function payloadManifestDefinitionCode(\n references: readonly ManifestReference[],\n): string {\n const entries = references.map((reference) => {\n const moduleId = withModuleQuery(\n reference.resolvedModuleId,\n payloadReferenceQuery,\n encodeOpaqueId(reference.referenceId),\n );\n return `${JSON.stringify(reference.referenceId)}: {\n load: () => import(${JSON.stringify(moduleId)}).then((module) => module[${JSON.stringify(reference.importedName)}]),\n stylesheets: ${JSON.stringify(reference.developmentStylesheetHrefs)},\n }`;\n });\n return `export const references = {${entries.join(\",\\n\")}};`;\n}\n\nexport function payloadManifestRuntimeCode(\n clientStylesheets: ReadonlyMap<string, readonly string[]>,\n): string {\n const assets = JSON.stringify(Object.fromEntries(clientStylesheets));\n return `import { stylesheet } from \"@bgub/fig\";\nimport { createPayloadClientReferenceResolver } from \"@bgub/fig/payload\";\n\nconst definitions = import.meta.glob([\n \"/**/*.{${sourceModuleExtensions.join(\",\")}}\",\n \"!/**/*.d.ts\",\n \"!/**/*.test.*\",\n \"!/**/*.spec.*\",\n \"!/**/__tests__/**\",\n \"!/**/dist/**\",\n \"!/**/node_modules/**\",\n], {\n eager: true,\n import: \"references\",\n query: \"?${payloadManifestDefinitionQuery}\",\n});\nconst references = Object.assign({}, ...Object.values(definitions));\nconst clientStylesheets = ${assets};\n\nexport const resolveIsomorphicReference = createPayloadClientReferenceResolver(\n (reference) => references[reference.id]?.load(),\n);\n\nexport function compiledIsomorphicReferenceAssets({ id }) {\n const hrefs = clientStylesheets[id] ?? references[id]?.stylesheets ?? [];\n return hrefs.map((href) => stylesheet(href, { precedence: \"isomorphic\" }));\n}`;\n}\n\nexport function payloadReferenceIds(moduleIds: readonly string[]): string[] {\n const ids = new Set<string>();\n for (const moduleId of moduleIds) {\n const id = moduleQueryValue(moduleId, payloadReferenceQuery);\n if (id !== undefined) ids.add(decodeOpaqueId(id));\n }\n return [...ids];\n}\n","import type { NodePath, PluginObject } from \"@babel/core\";\nimport type * as babel from \"@babel/core\";\nimport { isImportedBinding, payloadPackageId } from \"./compiler-options.ts\";\n\nexport interface IsomorphicImport {\n importedName: string;\n localName: string;\n source: string;\n}\n\nexport interface CompiledIsomorphicImport extends IsomorphicImport {\n referenceId: string;\n}\n\nexport function isomorphicBoundaryAnalysisPlugin(\n imports: IsomorphicImport[],\n): () => PluginObject {\n return () => ({\n name: \"fig-tanstack-start-isomorphic-boundary-analysis\",\n visitor: {\n Program(path) {\n const seen = new Set<string>();\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (\n elementPath.node.name.type !== \"JSXIdentifier\" ||\n !isIsomorphicBoundary(elementPath, elementPath.node.name.name)\n ) {\n return;\n }\n const component = isomorphicComponentAttribute(elementPath);\n const imported = importedComponent(\n elementPath,\n component.node.name,\n );\n const key = `${imported.source}\\0${imported.importedName}\\0${component.node.name}`;\n if (seen.has(key)) return;\n seen.add(key);\n imports.push({ ...imported, localName: component.node.name });\n },\n });\n },\n },\n });\n}\n\n// Returns the local identifier for the runtime's createIsomorphicReference\n// when at least one boundary was rewritten, undefined otherwise.\nexport function rewriteIsomorphicBoundaries(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n references: readonly CompiledIsomorphicImport[],\n): babel.types.Identifier | undefined {\n if (references.length === 0) return undefined;\n const byLocalName = new Map(\n references.map((reference) => [reference.localName, reference]),\n );\n const createReference = path.scope.generateUidIdentifier(\n \"createIsomorphicReference\",\n );\n let count = 0;\n\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (\n elementPath.node.name.type !== \"JSXIdentifier\" ||\n !isIsomorphicBoundary(elementPath, elementPath.node.name.name)\n ) {\n return;\n }\n const component = isomorphicComponentAttribute(elementPath);\n const reference = byLocalName.get(component.node.name);\n if (reference === undefined) return;\n component.replaceWith(\n t.callExpression(t.cloneNode(createReference), [\n t.stringLiteral(reference.referenceId),\n ]),\n );\n count += 1;\n },\n });\n if (count === 0) return undefined;\n\n path.scope.crawl();\n for (const localName of byLocalName.keys()) {\n const binding = path.scope.getBinding(localName);\n if (\n binding?.referenced ||\n (!binding?.path.isImportSpecifier() &&\n !binding?.path.isImportDefaultSpecifier())\n ) {\n continue;\n }\n const declaration = binding.path.parentPath;\n binding.path.remove();\n if (\n declaration.isImportDeclaration() &&\n declaration.node.specifiers.length === 0\n ) {\n declaration.remove();\n }\n }\n return createReference;\n}\n\nfunction isIsomorphicBoundary(path: NodePath, localName: string): boolean {\n return isImportedBinding(path, localName, \"Isomorphic\", payloadPackageId);\n}\n\nfunction isomorphicComponentAttribute(\n path: NodePath<babel.types.JSXOpeningElement>,\n): NodePath<babel.types.Identifier> {\n const attribute = path\n .get(\"attributes\")\n .find(\n (candidate) =>\n candidate.isJSXAttribute() &&\n candidate.node.name.type === \"JSXIdentifier\" &&\n candidate.node.name.name === \"component\",\n );\n if (attribute === undefined || !attribute.isJSXAttribute()) {\n throw path.buildCodeFrameError(\n \"Isomorphic requires a component prop containing a statically imported component.\",\n );\n }\n const value = attribute.get(\"value\");\n if (!value.isJSXExpressionContainer()) {\n throw attribute.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n const expression = value.get(\"expression\");\n if (Array.isArray(expression) || !expression.isIdentifier()) {\n throw value.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n return expression;\n}\n\nfunction importedComponent(\n path: NodePath,\n localName: string,\n): Omit<IsomorphicImport, \"localName\"> {\n const binding = path.scope.getBinding(localName);\n if (\n binding === undefined ||\n (!binding.path.isImportSpecifier() &&\n !binding.path.isImportDefaultSpecifier()) ||\n !binding.path.parentPath.isImportDeclaration()\n ) {\n throw path.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n const importedName = binding.path.isImportDefaultSpecifier()\n ? \"default\"\n : binding.path.node.imported.type === \"Identifier\"\n ? binding.path.node.imported.name\n : binding.path.node.imported.value;\n return {\n importedName,\n source: binding.path.parentPath.node.source.value,\n };\n}\n","import type { NodePath, PluginObject } from \"@babel/core\";\nimport type * as babel from \"@babel/core\";\nimport { isComponentName } from \"./compiler-options.ts\";\nimport { cleanModuleId, hasModuleQuery } from \"./module-ids.ts\";\n\nexport function stylesheetImportAnalysisPlugin(\n stylesheets: string[],\n): () => PluginObject {\n return () => ({\n name: \"fig-tanstack-start-stylesheet-import-analysis\",\n visitor: {\n ImportDeclaration(path) {\n const source = path.node.source.value;\n if (isStylesheetSpecifier(source)) stylesheets.push(source);\n },\n },\n });\n}\n\nexport function rewriteStylesheetImports(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n): babel.types.Identifier[] {\n const hrefs: babel.types.Identifier[] = [];\n for (const statement of path.get(\"body\")) {\n if (!statement.isImportDeclaration()) continue;\n const source = statement.node.source.value;\n if (!isStylesheetSpecifier(source)) continue;\n\n const existingUrl = hasUrlQuery(source);\n const defaultSpecifier = statement.node.specifiers.find(\n (specifier): specifier is babel.types.ImportDefaultSpecifier =>\n t.isImportDefaultSpecifier(specifier),\n );\n if (existingUrl && defaultSpecifier !== undefined) {\n hrefs.push(defaultSpecifier.local);\n continue;\n }\n\n const local = path.scope.generateUidIdentifier(\"figPayloadStylesheet\");\n if (statement.node.specifiers.length === 0) {\n statement.node.source = t.stringLiteral(withUrlQuery(source));\n statement.node.specifiers.push(t.importDefaultSpecifier(local));\n } else {\n statement.insertAfter(\n t.importDeclaration(\n [t.importDefaultSpecifier(local)],\n t.stringLiteral(withUrlQuery(source)),\n ),\n );\n }\n hrefs.push(local);\n }\n return hrefs;\n}\n\nexport function collectComponentNames(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n): string[] {\n const names = new Set<string>();\n for (const statement of path.get(\"body\")) {\n const declaration =\n statement.isExportNamedDeclaration() ||\n statement.isExportDefaultDeclaration()\n ? statement.get(\"declaration\")\n : statement;\n if (Array.isArray(declaration)) continue;\n\n if (declaration.isFunctionDeclaration()) {\n const name = declaration.node.id?.name;\n if (name !== undefined && isComponentName(name)) names.add(name);\n continue;\n }\n if (!declaration.isVariableDeclaration()) continue;\n\n for (const declarator of declaration.node.declarations) {\n if (\n t.isIdentifier(declarator.id) &&\n isComponentName(declarator.id.name) &&\n (t.isArrowFunctionExpression(declarator.init) ||\n t.isFunctionExpression(declarator.init))\n ) {\n names.add(declarator.id.name);\n }\n }\n }\n return [...names];\n}\n\nexport function isStylesheetSpecifier(source: string): boolean {\n const path = cleanModuleId(source);\n return /\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)$/.test(path);\n}\n\nfunction hasUrlQuery(source: string): boolean {\n return hasModuleQuery(source, \"url\");\n}\n\n// Vite's url plugin only matches the bare `?url` flag, so this cannot use\n// withModuleQuery's `name=value` form.\nfunction withUrlQuery(source: string): string {\n if (hasUrlQuery(source)) return source;\n return `${source}${source.includes(\"?\") ? \"&\" : \"?\"}url`;\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath, PluginObject } from \"@babel/core\";\nimport { payloadStylesheetsSymbolKey } from \"../payload-assets.ts\";\nimport {\n babelOptions,\n isComponentName,\n isImportedBinding,\n isSourceModule,\n serverPackageId,\n} from \"./compiler-options.ts\";\nimport {\n type CompiledIsomorphicImport,\n type IsomorphicImport,\n isomorphicBoundaryAnalysisPlugin,\n rewriteIsomorphicBoundaries,\n} from \"./isomorphic-compiler.ts\";\nimport {\n cleanModuleId,\n hasModuleQuery,\n payloadModuleQuery,\n withModuleQuery,\n} from \"./module-ids.ts\";\nimport {\n collectComponentNames,\n isStylesheetSpecifier,\n rewriteStylesheetImports,\n stylesheetImportAnalysisPlugin,\n} from \"./payload-stylesheet-compiler.ts\";\n\nexport const payloadRuntimeId = \"virtual:fig-tanstack-start/payload-runtime\";\nexport const resolvedPayloadRuntimeId = `\\0${payloadRuntimeId}`;\n\nconst figRuntimePackageIds: readonly string[] = [\n \"@bgub/fig\",\n \"@bgub/fig-devtools\",\n \"@bgub/fig-dom\",\n \"@bgub/fig-reconciler\",\n \"@bgub/fig-refresh\",\n \"@bgub/fig-server\",\n \"@bgub/fig-tanstack-router\",\n \"@bgub/fig-tanstack-start\",\n \"@bgub/fig-vite\",\n];\n\nexport async function analyzeStylesheetImports(\n code: string,\n id: string,\n): Promise<string[]> {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean)) return [];\n const stylesheets: string[] = [];\n await babel.transformAsync(code, {\n ...babelOptions(clean),\n plugins: [stylesheetImportAnalysisPlugin(stylesheets)],\n });\n return stylesheets;\n}\n\nexport async function analyzeIsomorphicBoundaries(\n code: string,\n id: string,\n): Promise<IsomorphicImport[]> {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean) || !code.includes(\"Isomorphic\")) return [];\n\n const imports: IsomorphicImport[] = [];\n await babel.transformAsync(code, {\n ...babelOptions(clean),\n plugins: [isomorphicBoundaryAnalysisPlugin(imports)],\n });\n return imports;\n}\n\n// Cheap pre-parse gate shared with the Vite transform hook, so callers can\n// skip boundary analysis for modules this transform cannot apply to.\nexport function mayBePayloadModule(code: string, id: string): boolean {\n return (\n isSourceModule(cleanModuleId(id)) &&\n (hasModuleQuery(id, payloadModuleQuery) ||\n code.includes(\"renderPayloadResponse\"))\n );\n}\n\nexport async function transformPayloadModule(\n code: string,\n id: string,\n isomorphicImports: readonly CompiledIsomorphicImport[] = [],\n) {\n if (!mayBePayloadModule(code, id)) return null;\n\n const state = { changed: false };\n const result = await babel.transformAsync(code, {\n ...babelOptions(cleanModuleId(id)),\n sourceMaps: true,\n plugins: [\n payloadBabelPlugin(\n isomorphicImports,\n hasModuleQuery(id, payloadModuleQuery),\n state,\n ),\n ],\n });\n\n if (!state.changed || result?.code == null) return null;\n return {\n code: result.code,\n map: result.map == null ? null : JSON.stringify(result.map),\n };\n}\n\nexport function payloadRuntimeCode(): string {\n return `import { clientReference } from \"@bgub/fig\";\nconst stylesheetKey = Symbol.for(${JSON.stringify(payloadStylesheetsSymbolKey)});\nexport function createIsomorphicReference(id) {\n return clientReference({ id });\n}\nexport function registerPayloadStylesheets(components, hrefs) {\n for (const component of components) {\n if (typeof component === \"function\") {\n Object.defineProperty(component, stylesheetKey, { configurable: true, value: hrefs });\n }\n }\n}`;\n}\n\nfunction payloadBabelPlugin(\n isomorphicImports: readonly CompiledIsomorphicImport[],\n compiledPayloadModule: boolean,\n state: { changed: boolean },\n): (api: typeof babel) => PluginObject {\n return (api: typeof babel) => {\n const t = api.types;\n\n return {\n name: \"fig-tanstack-start-payload\",\n visitor: {\n Program: {\n exit(path: NodePath<babel.types.Program>) {\n if (!compiledPayloadModule && !callsRenderPayloadResponse(path)) {\n return;\n }\n const components = collectComponentNames(path, t);\n const hrefs =\n components.length === 0 ? [] : rewriteStylesheetImports(path, t);\n const createReference = rewriteIsomorphicBoundaries(\n path,\n t,\n isomorphicImports,\n );\n\n if (rewritePayloadComponentImports(path) > 0) state.changed = true;\n\n const runtimeSpecifiers: babel.types.ImportSpecifier[] = [];\n if (createReference !== undefined) {\n runtimeSpecifiers.push(\n t.importSpecifier(\n createReference,\n t.identifier(\"createIsomorphicReference\"),\n ),\n );\n }\n let registerStylesheets: babel.types.Identifier | undefined;\n if (hrefs.length > 0) {\n registerStylesheets = path.scope.generateUidIdentifier(\n \"registerPayloadStylesheets\",\n );\n runtimeSpecifiers.push(\n t.importSpecifier(\n registerStylesheets,\n t.identifier(\"registerPayloadStylesheets\"),\n ),\n );\n }\n if (runtimeSpecifiers.length === 0) return;\n state.changed = true;\n\n path.node.body.unshift(\n t.importDeclaration(\n runtimeSpecifiers,\n t.stringLiteral(payloadRuntimeId),\n ),\n );\n if (registerStylesheets !== undefined) {\n path.node.body.push(\n t.expressionStatement(\n t.callExpression(registerStylesheets, [\n t.arrayExpression(\n components.map((name) => t.identifier(name)),\n ),\n t.arrayExpression(hrefs),\n ]),\n ),\n );\n }\n },\n },\n },\n };\n };\n}\n\nfunction callsRenderPayloadResponse(\n path: NodePath<babel.types.Program>,\n): boolean {\n let found = false;\n path.traverse({\n CallExpression(callPath) {\n if (\n callPath.node.callee.type === \"Identifier\" &&\n isImportedBinding(\n callPath,\n callPath.node.callee.name,\n \"renderPayloadResponse\",\n serverPackageId,\n )\n ) {\n found = true;\n callPath.stop();\n }\n },\n });\n return found;\n}\n\n// Returns the number of import declarations marked with the payload query.\nfunction rewritePayloadComponentImports(\n path: NodePath<babel.types.Program>,\n): number {\n const componentBindings = new Set<string>();\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (elementPath.node.name.type === \"JSXNamespacedName\") return;\n const name = rootJsxIdentifier(elementPath.node.name);\n if (name !== undefined) componentBindings.add(name);\n },\n CallExpression(callPath) {\n if (\n callPath.node.callee.type !== \"Identifier\" ||\n !isImportedBinding(\n callPath,\n callPath.node.callee.name,\n \"createElement\",\n \"@bgub/fig\",\n )\n ) {\n return;\n }\n const [type] = callPath.node.arguments;\n if (type?.type === \"Identifier\" && isComponentName(type.name)) {\n componentBindings.add(type.name);\n }\n },\n });\n\n let count = 0;\n for (const statement of path.get(\"body\")) {\n if (!statement.isImportDeclaration()) continue;\n const source = statement.node.source.value;\n if (\n statement.node.importKind === \"type\" ||\n isStylesheetSpecifier(source) ||\n isFigRuntimeSpecifier(source) ||\n hasModuleQuery(source, payloadModuleQuery) ||\n !statement.node.specifiers.some(\n (specifier) =>\n !(\"importKind\" in specifier && specifier.importKind === \"type\") &&\n componentBindings.has(specifier.local.name),\n )\n ) {\n continue;\n }\n statement.node.source.value = withModuleQuery(\n source,\n payloadModuleQuery,\n \"1\",\n );\n count += 1;\n }\n return count;\n}\n\nfunction isFigRuntimeSpecifier(source: string): boolean {\n return figRuntimePackageIds.some(\n (packageId) => source === packageId || source.startsWith(`${packageId}/`),\n );\n}\n\nfunction rootJsxIdentifier(\n name: babel.types.JSXIdentifier | babel.types.JSXMemberExpression,\n): string | undefined {\n let current: typeof name = name;\n while (current.type === \"JSXMemberExpression\") current = current.object;\n return current.type === \"JSXIdentifier\" && isComponentName(current.name)\n ? current.name\n : undefined;\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath, PluginObject } from \"@babel/core\";\nimport { tanStackCompatibilityProfile } from \"./compatibility-profile.ts\";\nimport {\n babelOptions,\n isImportedBinding,\n isSourceModule,\n payloadPackageId,\n serverPackageId,\n} from \"./compiler-options.ts\";\nimport { cleanModuleId } from \"./module-ids.ts\";\n\nconst compiledServerPayloadMarkerKey =\n \"fig.tanstack-start.compiled-server-payload\";\n\nexport async function transformServerPayloadDefinitions(\n code: string,\n id: string,\n) {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean) || !code.includes(\"serverPayload\")) return null;\n\n const state = { transformed: false };\n const result = await babel.transformAsync(code, {\n ...babelOptions(clean),\n sourceMaps: true,\n plugins: [serverPayloadBabelPlugin(state)],\n });\n\n if (!state.transformed || result?.code == null) return null;\n return {\n code: result.code,\n map: result.map == null ? null : JSON.stringify(result.map),\n };\n}\n\nfunction serverPayloadBabelPlugin(state: {\n transformed: boolean;\n}): (api: typeof babel) => PluginObject {\n return (api: typeof babel) => {\n const t = api.types;\n let createElement: babel.types.Identifier;\n let createServerFn: babel.types.Identifier;\n let renderPayloadResponse: babel.types.Identifier;\n\n return {\n name: \"fig-tanstack-start-server-payload\",\n visitor: {\n Program: {\n enter(path: NodePath<babel.types.Program>) {\n createElement = path.scope.generateUidIdentifier(\"createElement\");\n createServerFn = path.scope.generateUidIdentifier(\"createServerFn\");\n renderPayloadResponse = path.scope.generateUidIdentifier(\n \"renderPayloadResponse\",\n );\n },\n exit(path: NodePath<babel.types.Program>) {\n if (!state.transformed) return;\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n createElement,\n t.identifier(\"createElement\"),\n ),\n ],\n t.stringLiteral(\"@bgub/fig\"),\n ),\n );\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n renderPayloadResponse,\n t.identifier(\"renderPayloadResponse\"),\n ),\n ],\n t.stringLiteral(serverPackageId),\n ),\n );\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n createServerFn,\n t.identifier(\"createServerFn\"),\n ),\n ],\n t.stringLiteral(\n tanStackCompatibilityProfile.packages.frameworkStart,\n ),\n ),\n );\n },\n },\n CallExpression(path: NodePath<babel.types.CallExpression>) {\n if (\n path.node.callee.type !== \"Identifier\" ||\n !isImportedBinding(\n path,\n path.node.callee.name,\n \"serverPayload\",\n payloadPackageId,\n )\n ) {\n return;\n }\n\n transformServerPayloadCall(\n path,\n t,\n createElement,\n createServerFn,\n renderPayloadResponse,\n );\n state.transformed = true;\n },\n },\n };\n };\n}\n\nfunction transformServerPayloadCall(\n path: NodePath<babel.types.CallExpression>,\n t: typeof babel.types,\n createElement: babel.types.Identifier,\n createServerFn: babel.types.Identifier,\n renderPayloadResponse: babel.types.Identifier,\n): void {\n const [render, ...extra] = path.node.arguments;\n if (\n render === undefined ||\n render.type === \"SpreadElement\" ||\n render.type === \"ArgumentPlaceholder\" ||\n extra.length > 0\n ) {\n throw path.buildCodeFrameError(\n \"serverPayload requires exactly one server component or render callback.\",\n );\n }\n if (!isRenderExpression(render)) {\n throw path.buildCodeFrameError(\n \"serverPayload requires a component reference or inline render callback.\",\n );\n }\n const statement = path.getStatementParent();\n if (\n path.getFunctionParent() !== null ||\n statement === null ||\n !statement.parentPath.isProgram()\n ) {\n throw path.buildCodeFrameError(\n \"serverPayload must be declared in a top-level statement.\",\n );\n }\n\n const declarator = path.findParent((candidate) =>\n candidate.isVariableDeclarator(),\n );\n const requestName =\n declarator?.isVariableDeclarator() &&\n declarator.node.id.type === \"Identifier\"\n ? `${declarator.node.id.name}Request`\n : \"payloadRequest\";\n const request = statement.scope.generateUidIdentifier(requestName);\n const data = statement.scope.generateUidIdentifier(\"data\");\n const input = statement.scope.generateUidIdentifier(\"input\");\n const signal = statement.scope.generateUidIdentifier(\"signal\");\n\n const serverFn = t.callExpression(\n t.memberExpression(\n t.callExpression(createServerFn, []),\n t.identifier(\"handler\"),\n ),\n [\n t.arrowFunctionExpression(\n [\n t.objectPattern([\n t.objectProperty(t.identifier(\"data\"), data, false, false),\n ]),\n ],\n t.callExpression(renderPayloadResponse, [\n t.callExpression(createElement, [render, data]),\n ]),\n ),\n ],\n );\n\n statement.insertBefore(\n t.variableDeclaration(\"const\", [t.variableDeclarator(request, serverFn)]),\n );\n const proxy = t.arrowFunctionExpression(\n [\n input,\n t.objectPattern([\n t.objectProperty(t.identifier(\"signal\"), signal, false, false),\n ]),\n ],\n t.callExpression(request, [\n t.objectExpression([\n t.objectProperty(t.identifier(\"data\"), input, false, false),\n t.objectProperty(t.identifier(\"signal\"), signal, false, false),\n ]),\n ]),\n );\n path.node.arguments = [\n t.callExpression(\n t.memberExpression(t.identifier(\"Object\"), t.identifier(\"assign\")),\n [\n proxy,\n t.objectExpression([\n t.objectProperty(\n t.callExpression(\n t.memberExpression(t.identifier(\"Symbol\"), t.identifier(\"for\")),\n [t.stringLiteral(compiledServerPayloadMarkerKey)],\n ),\n t.booleanLiteral(true),\n true,\n ),\n ]),\n ],\n ),\n ];\n}\n\nfunction isRenderExpression(\n value: babel.types.Expression,\n): value is\n | babel.types.ArrowFunctionExpression\n | babel.types.FunctionExpression\n | babel.types.Identifier\n | babel.types.MemberExpression {\n return (\n value.type === \"ArrowFunctionExpression\" ||\n (value.type === \"FunctionExpression\" && !value.generator) ||\n value.type === \"Identifier\" ||\n value.type === \"MemberExpression\"\n );\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport async function writePublicAsset(\n path: string,\n source: string | Uint8Array,\n): Promise<void> {\n const bytes = Buffer.from(source);\n let existing: Buffer | undefined;\n try {\n existing = await readFile(path);\n } catch (error) {\n if (!isMissingFile(error)) throw error;\n }\n\n if (existing !== undefined) {\n if (existing.equals(bytes)) return;\n throw new Error(\n `TanStack Start server asset ${JSON.stringify(path)} conflicts with a different client asset at the same public path. Use content-hashed or separately namespaced asset file names.`,\n );\n }\n\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, bytes);\n}\n\nfunction isMissingFile(error: unknown): error is NodeJS.ErrnoException {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n","import { readFile } from \"node:fs/promises\";\nimport { isAbsolute, resolve } from \"node:path\";\nimport { START_ENVIRONMENT_NAMES } from \"@tanstack/start-plugin-core/vite\";\nimport type { EnvironmentModuleNode, PluginOption } from \"vite\";\nimport { rewriteFrameworkImports } from \"./compatibility-profile.ts\";\nimport {\n isomorphicReferenceId,\n type ManifestReference,\n payloadManifestDefinitionCode,\n payloadManifestId,\n payloadManifestRuntimeCode,\n payloadReferenceIds,\n resolvedPayloadManifestId,\n} from \"./isomorphic-manifest.ts\";\nimport {\n cleanModuleId,\n decodeOpaqueId,\n encodeOpaqueId,\n hasModuleQuery,\n payloadManifestDefinitionQuery,\n payloadModuleQuery,\n toViteModulePath,\n withModuleQuery,\n} from \"./module-ids.ts\";\nimport type { IsomorphicImport } from \"./isomorphic-compiler.ts\";\nimport {\n analyzeIsomorphicBoundaries,\n analyzeStylesheetImports,\n mayBePayloadModule,\n payloadRuntimeCode,\n payloadRuntimeId,\n resolvedPayloadRuntimeId,\n transformPayloadModule,\n} from \"./payload-compiler.ts\";\nimport { transformServerPayloadDefinitions } from \"./server-payload-compiler.ts\";\nimport { writePublicAsset } from \"./public-assets.ts\";\n\nconst payloadManifestDefinitionPrefix =\n \"\\0fig-tanstack-start:payload-manifest-definition:\";\n\nexport function serverPayloadPlugin(): PluginOption {\n return {\n name: \"fig-tanstack-start:server-payload\",\n enforce: \"pre\",\n transform: transformServerPayloadDefinitions,\n };\n}\n\nexport function payloadPlugin(): PluginOption {\n let root = process.cwd();\n let base = \"/\";\n let clientOutDir: string | undefined;\n let serverAssetsPrefix = \"assets/\";\n // Start runs the client build before the server build with this plugin\n // instance. Retain Vite's final client CSS names for the server manifest.\n const clientStylesheets = new Map<string, string[]>();\n // Loaded manifest definitions read their source — and each referenced\n // component's stylesheet imports — through the filesystem, so the module\n // graph cannot see when those analyzed inputs change; hotUpdate compares\n // these fingerprints to reload only affected definitions.\n const definitionInputs = new Map<string, DefinitionInputs>();\n\n return {\n name: \"fig-tanstack-start:payload\",\n enforce: \"pre\",\n configEnvironment(environmentName) {\n if (environmentName === START_ENVIRONMENT_NAMES.server) {\n return { build: { emitAssets: true } };\n }\n return undefined;\n },\n configResolved(config) {\n root = config.root;\n base = config.base;\n const outDir =\n config.environments[START_ENVIRONMENT_NAMES.client]?.build.outDir;\n if (outDir !== undefined) clientOutDir = resolve(config.root, outDir);\n const assetsDir =\n config.environments[START_ENVIRONMENT_NAMES.server]?.build.assetsDir;\n if (assetsDir !== undefined) {\n const normalized = assetsDir.replace(/\\/+$/, \"\");\n serverAssetsPrefix = normalized === \"\" ? \"\" : `${normalized}/`;\n }\n },\n async writeBundle(_options, bundle) {\n if (\n this.environment.name !== START_ENVIRONMENT_NAMES.server ||\n clientOutDir === undefined\n ) {\n return;\n }\n\n const publicOutDir = clientOutDir;\n await Promise.all(\n Object.values(bundle).map(async (output) => {\n if (\n output.type !== \"asset\" ||\n !output.fileName.startsWith(serverAssetsPrefix) ||\n output.fileName.endsWith(\".map\")\n ) {\n return;\n }\n const path = resolve(publicOutDir, output.fileName);\n await writePublicAsset(path, output.source);\n }),\n );\n },\n generateBundle(_options, bundle) {\n if (this.environment.name !== START_ENVIRONMENT_NAMES.client) return;\n collectClientStylesheets(bundle, clientStylesheets, base);\n },\n async resolveId(source, importer) {\n if (source === payloadRuntimeId) return resolvedPayloadRuntimeId;\n if (source === payloadManifestId) return resolvedPayloadManifestId;\n if (hasModuleQuery(source, payloadModuleQuery)) {\n const resolved = await this.resolve(cleanModuleId(source), importer, {\n skipSelf: true,\n });\n return resolved === null\n ? null\n : withModuleQuery(\n cleanModuleId(resolved.id),\n payloadModuleQuery,\n \"1\",\n );\n }\n if (!hasModuleQuery(source, payloadManifestDefinitionQuery)) {\n return undefined;\n }\n\n const resolved = await this.resolve(cleanModuleId(source), importer, {\n skipSelf: true,\n });\n if (resolved === null) return null;\n // Start protects .server modules from the client graph. The manifest\n // needs only their compiled definitions, so expose those definitions\n // through a private virtual id before import protection runs.\n return definitionModuleId(cleanModuleId(resolved.id));\n },\n async load(id) {\n if (id === resolvedPayloadRuntimeId) return payloadRuntimeCode();\n if (id === resolvedPayloadManifestId) {\n return payloadManifestRuntimeCode(clientStylesheets);\n }\n if (!id.startsWith(payloadManifestDefinitionPrefix)) return undefined;\n\n const sourceId = decodeOpaqueId(\n id.slice(payloadManifestDefinitionPrefix.length),\n );\n const code = rewriteFrameworkImports(await readFile(sourceId, \"utf8\"));\n const stylesheetSources = new Map<string, string>();\n const references = await collectPayloadReferences(\n sourceId,\n code,\n (source, importer) =>\n this.resolve(source, importer, { skipSelf: true }),\n root,\n stylesheetSources,\n );\n if (references.length > 0) {\n this.addWatchFile(sourceId);\n definitionInputs.set(sourceId, {\n boundaries: boundaryFingerprint(references),\n stylesheetSources,\n });\n } else {\n // A missing entry means the empty fingerprint, so the map only holds\n // the few definitions that actually have boundaries.\n definitionInputs.delete(sourceId);\n }\n return payloadManifestDefinitionCode(references);\n },\n async hotUpdate({ file, modules, read }) {\n const { moduleGraph } = this.environment;\n const invalidated = new Set<EnvironmentModuleNode>();\n let content: string | undefined;\n const readContent = async () => (content ??= await read());\n\n const definition = moduleGraph.getModuleById(definitionModuleId(file));\n if (definition !== undefined) {\n let changed: boolean;\n try {\n const boundaries = boundaryFingerprint(\n await analyzeIsomorphicBoundaries(\n rewriteFrameworkImports(await readContent()),\n file,\n ),\n );\n changed =\n (definitionInputs.get(file)?.boundaries ??\n emptyBoundaryFingerprint) !== boundaries;\n } catch {\n // Mid-edit analysis failures surface through the module's own\n // transform; reload the definition so the manifest cannot go stale.\n changed = true;\n }\n if (changed) invalidated.add(definition);\n }\n\n // The changed file may be a component module whose stylesheet imports\n // are embedded in other definitions as development hrefs.\n const dependents = [...definitionInputs].filter(([, inputs]) =>\n inputs.stylesheetSources.has(file),\n );\n if (dependents.length > 0) {\n let sources: string | undefined;\n try {\n sources = stylesheetSourceFingerprint(\n await analyzeStylesheetImports(await readContent(), file),\n );\n } catch {\n sources = undefined;\n }\n for (const [sourceId, inputs] of dependents) {\n if (inputs.stylesheetSources.get(file) === sources) continue;\n const dependent = moduleGraph.getModuleById(\n definitionModuleId(sourceId),\n );\n if (dependent !== undefined) invalidated.add(dependent);\n }\n }\n\n if (invalidated.size === 0) return undefined;\n return [...modules, ...invalidated];\n },\n async transform(code, id) {\n if (\n this.environment.name !== START_ENVIRONMENT_NAMES.server ||\n !mayBePayloadModule(code, id)\n ) {\n return null;\n }\n const references = await collectPayloadReferences(\n id,\n code,\n (source, importer) =>\n this.resolve(source, importer, { skipSelf: true }),\n root,\n );\n return transformPayloadModule(code, id, references);\n },\n };\n}\n\ninterface DefinitionInputs {\n boundaries: string;\n // Referenced component module id → fingerprint of its stylesheet imports.\n stylesheetSources: Map<string, string>;\n}\n\nfunction definitionModuleId(sourceId: string): string {\n return `${payloadManifestDefinitionPrefix}${encodeOpaqueId(sourceId)}`;\n}\n\nfunction boundaryFingerprint(imports: readonly IsomorphicImport[]): string {\n return JSON.stringify(\n imports.map(({ importedName, localName, source }) => [\n source,\n importedName,\n localName,\n ]),\n );\n}\n\nconst emptyBoundaryFingerprint = boundaryFingerprint([]);\n\n// hotUpdate has no resolver, so fingerprints use the raw import specifiers\n// rather than resolved stylesheet ids.\nfunction stylesheetSourceFingerprint(sources: readonly string[]): string {\n return JSON.stringify(sources);\n}\n\ntype ResolveModule = (\n source: string,\n importer: string,\n) => Promise<{ id: string } | null>;\n\nasync function collectPayloadReferences(\n id: string,\n code: string,\n resolveModule: ResolveModule,\n root: string,\n stylesheetSources?: Map<string, string>,\n): Promise<ManifestReference[]> {\n const importerId = cleanModuleId(id);\n const imports = await analyzeIsomorphicBoundaries(code, id);\n return Promise.all(\n imports.map(async (imported): Promise<ManifestReference> => {\n const resolved = await resolveModule(imported.source, importerId);\n if (resolved === null) {\n throw new Error(\n `Cannot resolve Isomorphic component import ${JSON.stringify(imported.source)} from ${importerId}.`,\n );\n }\n const moduleId = cleanModuleId(resolved.id);\n const referenceId = isomorphicReferenceId(\n root,\n moduleId,\n imported.importedName,\n );\n let hrefs: string[] = [];\n if (stylesheetSources !== undefined) {\n const stylesheets = await moduleStylesheets(\n moduleId,\n root,\n resolveModule,\n );\n hrefs = stylesheets.hrefs;\n stylesheetSources.set(\n moduleId,\n stylesheetSourceFingerprint(stylesheets.sources),\n );\n }\n return {\n ...imported,\n referenceId,\n resolvedModuleId: moduleId,\n developmentStylesheetHrefs: hrefs,\n };\n }),\n );\n}\n\nasync function moduleStylesheets(\n moduleId: string,\n root: string,\n resolveModule: ResolveModule,\n): Promise<{ hrefs: string[]; sources: string[] }> {\n if (!isAbsolute(moduleId)) return { hrefs: [], sources: [] };\n let code: string;\n try {\n code = await readFile(moduleId, \"utf8\");\n } catch {\n return { hrefs: [], sources: [] };\n }\n const sources = await analyzeStylesheetImports(code, moduleId);\n const hrefs = (\n await Promise.all(\n sources.map(async (source) => {\n const resolved = await resolveModule(source, moduleId);\n return resolved === null\n ? undefined\n : toViteModulePath(root, cleanModuleId(resolved.id));\n }),\n )\n ).filter((href): href is string => href !== undefined);\n return { hrefs, sources };\n}\n\nfunction collectClientStylesheets(\n bundle: OutputBundle,\n clientStylesheets: Map<string, string[]>,\n base: string,\n): void {\n clientStylesheets.clear();\n for (const output of Object.values(bundle)) {\n if (output.type !== \"chunk\") continue;\n const referenceIds = payloadReferenceIds(Object.keys(output.modules));\n for (const referenceId of referenceIds) {\n const stylesheets = new Set(clientStylesheets.get(referenceId));\n for (const file of output.viteMetadata?.importedCss ?? []) {\n stylesheets.add(`${base.replace(/\\/$/, \"\")}/${file}`);\n }\n clientStylesheets.set(referenceId, [...stylesheets]);\n }\n }\n}\n\ntype OutputBundle = Record<string, OutputChunk | OutputAsset>;\n\ninterface OutputAsset {\n type: \"asset\";\n}\n\ninterface OutputChunk {\n modules: Record<string, unknown>;\n type: \"chunk\";\n viteMetadata?: { importedCss?: Set<string> };\n}\n","import {\n START_ENVIRONMENT_NAMES,\n tanStackStartVite,\n type TanStackStartViteInputConfig,\n} from \"@tanstack/start-plugin-core/vite\";\nimport { figRefresh } from \"@bgub/fig-vite\";\nimport type { PluginOption } from \"vite\";\nimport {\n defaultEntryPaths,\n startCompatibilityPlugin,\n} from \"./compatibility-vite.ts\";\nimport { payloadPlugin, serverPayloadPlugin } from \"./payload-vite.ts\";\nimport { tanStackCompatibilityProfile } from \"./compatibility-profile.ts\";\n\nexport function tanstackStart(\n options?: TanStackStartViteInputConfig,\n): PluginOption[] {\n return [\n startCompatibilityPlugin(),\n serverPayloadPlugin(),\n payloadPlugin(),\n tanStackStartVite(\n {\n defaultEntryPaths,\n framework: tanStackCompatibilityProfile.framework,\n providerEnvironmentName: START_ENVIRONMENT_NAMES.server,\n ssrIsProvider: true,\n ssrResolverStrategy: { type: \"default\" },\n },\n options,\n ),\n // Route splitting must run first: it moves component declarations into\n // virtual modules. Refresh then registers the declarations where they\n // actually remain instead of leaving references in the route shell.\n figRefresh(),\n ];\n}\n"],"mappings":";;;;;;;;;;AAGA,MAAa,iCAAiC;AAC9C,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AAErC,SAAgB,cAAc,IAAoB;CAChD,MAAM,QAAQ,GAAG,QAAQ,GAAG;CAC5B,OAAO,UAAU,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;AAC9C;AAEA,SAAgB,iBAAiB,IAAY,MAAkC;CAC7E,MAAM,QAAQ,GAAG,QAAQ,GAAG;CAC5B,IAAI,UAAU,IAAI,OAAO,KAAA;CACzB,MAAM,OAAO,GAAG,QAAQ,KAAK,KAAK;CAIlC,OAHc,IAAI,gBAChB,GAAG,MAAM,QAAQ,GAAG,SAAS,KAAK,KAAA,IAAY,IAAI,CACpD,CAAC,CAAC,IAAI,IACK,KAAK,KAAA;AAClB;AAEA,SAAgB,eAAe,IAAY,MAAuB;CAChE,OAAO,iBAAiB,IAAI,IAAI,MAAM,KAAA;AACxC;AAEA,SAAgB,gBACd,QACA,MACA,OACQ;CACR,MAAM,OAAO,OAAO,QAAQ,GAAG;CAC/B,MAAM,SAAS,SAAS,KAAK,KAAK,OAAO,MAAM,IAAI;CACnD,MAAM,OAAO,SAAS,KAAK,SAAS,OAAO,MAAM,GAAG,IAAI;CAExD,OAAO,GAAG,OADQ,KAAK,SAAS,GAAG,IAAI,MAAM,MAChB,KAAK,GAAG,mBAAmB,KAAK,IAAI;AACnE;AAEA,SAAgB,eAAe,IAAoB;CACjD,OAAOA,SAAO,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW;AA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"sources":["../../src/plugin/module-ids.ts","../../src/plugin/compatibility-profile.ts","../../src/plugin/compatibility-vite.ts","../../src/plugin/compiler-options.ts","../../src/plugin/isomorphic-manifest.ts","../../src/plugin/isomorphic-compiler.ts","../../src/plugin/payload-stylesheet-compiler.ts","../../src/plugin/payload-compiler.ts","../../src/plugin/server-payload-compiler.ts","../../src/plugin/public-assets.ts","../../src/plugin/payload-vite.ts","../../src/plugin/vite.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport { isAbsolute, relative, sep } from \"node:path\";\n\nexport const payloadManifestDefinitionQuery = \"fig-payload-manifest\";\nexport const payloadModuleQuery = \"fig-payload-module\";\nexport const payloadReferenceQuery = \"fig-payload-reference\";\n\nexport function cleanModuleId(id: string): string {\n const query = id.indexOf(\"?\");\n return query === -1 ? id : id.slice(0, query);\n}\n\nexport function moduleQueryValue(id: string, name: string): string | undefined {\n const query = id.indexOf(\"?\");\n if (query === -1) return undefined;\n const hash = id.indexOf(\"#\", query);\n const value = new URLSearchParams(\n id.slice(query + 1, hash === -1 ? undefined : hash),\n ).get(name);\n return value ?? undefined;\n}\n\nexport function hasModuleQuery(id: string, name: string): boolean {\n return moduleQueryValue(id, name) !== undefined;\n}\n\nexport function withModuleQuery(\n source: string,\n name: string,\n value: string,\n): string {\n const hash = source.indexOf(\"#\");\n const suffix = hash === -1 ? \"\" : source.slice(hash);\n const path = hash === -1 ? source : source.slice(0, hash);\n const separator = path.includes(\"?\") ? \"&\" : \"?\";\n return `${path}${separator}${name}=${encodeURIComponent(value)}${suffix}`;\n}\n\nexport function encodeOpaqueId(id: string): string {\n return Buffer.from(id).toString(\"base64url\");\n}\n\nexport function decodeOpaqueId(id: string): string {\n return Buffer.from(id, \"base64url\").toString();\n}\n\nexport function toViteModulePath(root: string, moduleId: string): string {\n const clean = cleanModuleId(moduleId);\n const path = isAbsolute(clean) ? relative(root, clean) : clean;\n const normalized = normalizePath(path);\n return isAbsolute(path) || normalized.startsWith(\"../\")\n ? toViteFsPath(clean)\n : `/${normalized.replace(/^\\/+/, \"\")}`;\n}\n\nexport function toViteFsPath(path: string): string {\n return `/@fs/${normalizePath(path).replace(/^\\/+/, \"\")}`;\n}\n\nfunction normalizePath(path: string): string {\n return path.split(sep).join(\"/\").replaceAll(\"\\\\\", \"/\");\n}\n","export const tanStackCompatibilityProfile = {\n id: \"tanstack-start-core-1.171\",\n framework: \"solid\",\n packages: {\n figRouter: \"@bgub/fig-tanstack-router\",\n figStart: \"@bgub/fig-tanstack-start\",\n frameworkRouter: \"@tanstack/solid-router\",\n frameworkStart: \"@tanstack/solid-start\",\n startClient: \"@tanstack/start-client-core\",\n startServer: \"@tanstack/start-server-core\",\n },\n versions: {\n routerCore: \"1.171.15\",\n startClientCore: \"1.170.14\",\n startPluginCore: \"1.171.22\",\n startServerCore: \"1.169.17\",\n },\n} as const;\n\nexport function createCompilerRpcModules(\n resolveDependency: (id: string) => string,\n) {\n const { frameworkStart, startClient, startServer } =\n tanStackCompatibilityProfile.packages;\n return [\n {\n source: `${frameworkStart}/client-rpc`,\n id: \"\\0fig-tanstack-start:client-rpc\",\n code: `export { createClientRpc } from \"${startClient}/client-rpc\";`,\n },\n {\n source: `${frameworkStart}/server-rpc`,\n id: \"\\0fig-tanstack-start:server-rpc\",\n code: `export { createServerRpc } from ${JSON.stringify(\n resolveDependency(`${startServer}/createServerRpc`),\n )};`,\n },\n {\n source: `${frameworkStart}/ssr-rpc`,\n id: \"\\0fig-tanstack-start:ssr-rpc\",\n code: `export { createSsrRpc } from ${JSON.stringify(\n resolveDependency(`${startServer}/createSsrRpc`),\n )};`,\n },\n ];\n}\n\nexport function createDefaultServerEntry(): string {\n const { figStart } = tanStackCompatibilityProfile.packages;\n return [\n `import { createFigStartHandler } from ${JSON.stringify(`${figStart}/server`)};`,\n \"const fetch = createFigStartHandler();\",\n \"export default { fetch };\",\n ].join(\"\\n\");\n}\n\nexport function rewriteFrameworkImports(code: string): string {\n const { figStart, frameworkStart } = tanStackCompatibilityProfile.packages;\n return code.replace(\n new RegExp(\n `\\\\b(from|import)\\\\s*(\\\\(\\\\s*)?([\"'])${escapeRegExp(figStart)}\\\\3`,\n \"g\",\n ),\n (_match, keyword: string, parenthesis: string | undefined, quote: string) =>\n `${keyword}${parenthesis === undefined ? \" \" : parenthesis}${quote}${frameworkStart}${quote}`,\n );\n}\n\nexport function incompatibleRuntimeModules(\n moduleIds: Iterable<string>,\n): string[] {\n const { frameworkRouter, frameworkStart } =\n tanStackCompatibilityProfile.packages;\n const forbiddenPackages = [frameworkRouter, frameworkStart];\n return [...moduleIds].filter((id) => {\n const normalized = id.replaceAll(\"\\\\\", \"/\");\n return forbiddenPackages.some((packageName) =>\n normalized.includes(`/node_modules/${packageName}/`),\n );\n });\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { fileURLToPath } from \"node:url\";\nimport { START_ENVIRONMENT_NAMES } from \"@tanstack/start-plugin-core/vite\";\nimport type { PluginOption } from \"vite\";\nimport { toViteFsPath } from \"./module-ids.ts\";\nimport {\n createCompilerRpcModules,\n createDefaultServerEntry,\n incompatibleRuntimeModules,\n rewriteFrameworkImports,\n tanStackCompatibilityProfile,\n} from \"./compatibility-profile.ts\";\n\nconst {\n figRouter: figRouterPackage,\n figStart: figTanStackStartPackage,\n frameworkRouter: tanstackRouterPackage,\n frameworkStart: tanstackStartPackage,\n startClient: tanstackStartClientPackage,\n} = tanStackCompatibilityProfile.packages;\n\nconst resolveDependency = (id: string) =>\n fileURLToPath(import.meta.resolve(id));\nconst tanstackStartClientModules = [\n tanstackStartClientPackage,\n `${tanstackStartClientPackage}/client`,\n `${tanstackStartClientPackage}/client-rpc`,\n] as const;\nconst tanstackStartClientAliases = tanstackStartClientModules.map((id) => ({\n find: new RegExp(`^${id}$`),\n replacement: resolveDependency(id),\n}));\nconst optimizedClientModules = [\"@tanstack/router-core/ssr/client\"] as const;\nconst applicationEntryIds = new Set([\n \"#tanstack-router-entry\",\n \"#tanstack-start-entry\",\n]);\nconst storageContextPath = fileURLToPath(\n new URL(\"../storage-context.js\", import.meta.url),\n);\n\nexport const defaultEntryPaths = {\n client: fileURLToPath(new URL(\"../default-entry/client.js\", import.meta.url)),\n server: fileURLToPath(new URL(\"../default-entry/server.js\", import.meta.url)),\n start: fileURLToPath(new URL(\"../default-entry/start.js\", import.meta.url)),\n} as const;\n\nconst compilerRpcModules = createCompilerRpcModules(resolveDependency);\n\nexport function startCompatibilityPlugin(): PluginOption {\n const applicationEntryUrls = new Map<string, string>();\n const optimizerApplicationEntries = {\n name: \"fig-tanstack-start:optimizer-application-entries\",\n resolveId(source: string) {\n const id = applicationEntryUrls.get(source);\n return id === undefined ? null : { external: true, id };\n },\n };\n\n return {\n name: \"fig-tanstack-start:compatibility\",\n enforce: \"pre\",\n config() {\n return {\n resolve: {\n alias: [\n ...tanstackStartClientAliases,\n {\n find: /^@tanstack\\/start-storage-context$/,\n replacement: storageContextPath,\n },\n {\n find: new RegExp(`^${tanstackRouterPackage}$`),\n replacement: figRouterPackage,\n },\n {\n find: new RegExp(`^${tanstackStartPackage}$`),\n replacement: figTanStackStartPackage,\n },\n ],\n dedupe: [figTanStackStartPackage, figRouterPackage],\n },\n };\n },\n configEnvironment(environmentName, environment) {\n if (environmentName !== START_ENVIRONMENT_NAMES.client) return undefined;\n const optimizerPlugins =\n environment.optimizeDeps?.rolldownOptions?.plugins;\n return {\n optimizeDeps: {\n include: [\n ...(environment.optimizeDeps?.include ?? []),\n ...optimizedClientModules,\n ],\n exclude: [\n ...(environment.optimizeDeps?.exclude ?? []),\n // Start's compiler must rewrite createIsomorphicFn branches per\n // environment; prebundling these first freezes server code into\n // the client graph and makes client-side server functions crash.\n ...tanstackStartClientModules,\n figTanStackStartPackage,\n figRouterPackage,\n ],\n rolldownOptions: {\n ...environment.optimizeDeps?.rolldownOptions,\n plugins: [\n ...(optimizerPlugins === undefined ? [] : [optimizerPlugins]),\n optimizerApplicationEntries,\n ],\n },\n },\n };\n },\n configResolved(config) {\n for (const alias of config.resolve.alias) {\n if (\n typeof alias.find === \"string\" &&\n applicationEntryIds.has(alias.find)\n ) {\n applicationEntryUrls.set(alias.find, toViteFsPath(alias.replacement));\n }\n }\n },\n generateBundle(_options, bundle) {\n if (this.environment.name !== START_ENVIRONMENT_NAMES.client) return;\n const emittedModuleIds = Object.values(bundle).flatMap((output) =>\n output.type === \"chunk\"\n ? Object.entries(output.modules).flatMap(([id, module]) =>\n module.renderedLength === 0 ? [] : [id],\n )\n : [],\n );\n const incompatible = incompatibleRuntimeModules(emittedModuleIds);\n if (incompatible.length === 0) return;\n throw new Error(\n `${tanStackCompatibilityProfile.id} resolved compatibility-only Solid modules into the client runtime:\\n${incompatible.join(\"\\n\")}`,\n );\n },\n resolveId(source) {\n return compilerRpcModules.find((module) => module.source === source)?.id;\n },\n load(id) {\n const rpcModule = compilerRpcModules.find((module) => module.id === id);\n if (rpcModule !== undefined) return rpcModule.code;\n if (id === defaultEntryPaths.server) return createDefaultServerEntry();\n return undefined;\n },\n transform(code) {\n const rewritten = rewriteFrameworkImports(code);\n return rewritten === code ? null : { code: rewritten, map: null };\n },\n };\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath } from \"@babel/core\";\nimport presetTypescript from \"@babel/preset-typescript\";\n\nexport const payloadPackageId = \"@bgub/fig-tanstack-start/payload\";\nexport const serverPackageId = \"@bgub/fig-tanstack-start/server\";\n\n// One home for what counts as a source module: the manifest glob and the\n// compiler analysis gates must accept the same files.\nexport const sourceModuleExtensions = [\n \"js\",\n \"jsx\",\n \"ts\",\n \"tsx\",\n \"cjs\",\n \"mjs\",\n \"cts\",\n \"mts\",\n] as const;\n\nconst sourceModulePattern = new RegExp(\n `\\\\.(?:${sourceModuleExtensions.join(\"|\")})$`,\n);\n\nexport function babelOptions(\n filename: string,\n): NonNullable<Parameters<typeof babel.transformAsync>[1]> {\n return {\n babelrc: false,\n configFile: false,\n filename,\n presets: [\n [\n presetTypescript,\n { ignoreExtensions: true, onlyRemoveTypeImports: true },\n ],\n ],\n parserOpts: { plugins: filename.endsWith(\"x\") ? [\"jsx\"] : [] },\n };\n}\n\nexport function isSourceModule(id: string): boolean {\n return sourceModulePattern.test(id);\n}\n\nexport function isComponentName(name: string): boolean {\n const first = name.codePointAt(0);\n return first !== undefined && first >= 65 && first <= 90;\n}\n\nexport function isImportedBinding(\n path: NodePath,\n localName: string,\n importedName: string,\n source: string,\n): boolean {\n const binding = path.scope.getBinding(localName);\n if (!binding?.path.isImportSpecifier()) return false;\n const imported = binding.path.node.imported;\n const actualName =\n imported.type === \"Identifier\" ? imported.name : imported.value;\n return (\n actualName === importedName &&\n binding.path.parentPath.isImportDeclaration() &&\n binding.path.parentPath.node.source.value === source\n );\n}\n","import { sourceModuleExtensions } from \"./compiler-options.ts\";\nimport type { CompiledIsomorphicImport } from \"./isomorphic-compiler.ts\";\nimport {\n decodeOpaqueId,\n encodeOpaqueId,\n moduleQueryValue,\n payloadManifestDefinitionQuery,\n payloadReferenceQuery,\n toViteModulePath,\n withModuleQuery,\n} from \"./module-ids.ts\";\n\nexport const payloadManifestId = \"virtual:fig-tanstack-start/payload-manifest\";\nexport const resolvedPayloadManifestId = `\\0${payloadManifestId}`;\n\nexport interface ManifestReference extends CompiledIsomorphicImport {\n developmentStylesheetHrefs: string[];\n resolvedModuleId: string;\n}\n\nexport function isomorphicReferenceId(\n root: string,\n moduleId: string,\n exportName: string,\n): string {\n return `${toViteModulePath(root, moduleId)}#${exportName}`;\n}\n\nexport function payloadManifestDefinitionCode(\n references: readonly ManifestReference[],\n): string {\n const entries = references.map((reference) => {\n const moduleId = withModuleQuery(\n reference.resolvedModuleId,\n payloadReferenceQuery,\n encodeOpaqueId(reference.referenceId),\n );\n return `${JSON.stringify(reference.referenceId)}: {\n load: () => import(${JSON.stringify(moduleId)}).then((module) => module[${JSON.stringify(reference.importedName)}]),\n stylesheets: ${JSON.stringify(reference.developmentStylesheetHrefs)},\n }`;\n });\n return `export const references = {${entries.join(\",\\n\")}};`;\n}\n\nexport function payloadManifestRuntimeCode(\n clientStylesheets: ReadonlyMap<string, readonly string[]>,\n): string {\n const assets = JSON.stringify(Object.fromEntries(clientStylesheets));\n return `import { stylesheet } from \"@bgub/fig\";\nimport { createPayloadClientReferenceResolver } from \"@bgub/fig/payload\";\n\nconst definitions = import.meta.glob([\n \"/**/*.{${sourceModuleExtensions.join(\",\")}}\",\n \"!/**/*.d.ts\",\n \"!/**/*.test.*\",\n \"!/**/*.spec.*\",\n \"!/**/__tests__/**\",\n \"!/**/dist/**\",\n \"!/**/node_modules/**\",\n], {\n eager: true,\n import: \"references\",\n query: \"?${payloadManifestDefinitionQuery}\",\n});\nconst references = Object.assign({}, ...Object.values(definitions));\nconst clientStylesheets = ${assets};\n\nexport const resolveIsomorphicReference = createPayloadClientReferenceResolver(\n (reference) => references[reference.id]?.load(),\n);\n\nexport function compiledIsomorphicReferenceAssets({ id }) {\n const hrefs = clientStylesheets[id] ?? references[id]?.stylesheets ?? [];\n return hrefs.map((href) => stylesheet(href, { precedence: \"isomorphic\" }));\n}`;\n}\n\nexport function payloadReferenceIds(moduleIds: readonly string[]): string[] {\n const ids = new Set<string>();\n for (const moduleId of moduleIds) {\n const id = moduleQueryValue(moduleId, payloadReferenceQuery);\n if (id !== undefined) ids.add(decodeOpaqueId(id));\n }\n return [...ids];\n}\n","import type { NodePath, PluginObject } from \"@babel/core\";\nimport type * as babel from \"@babel/core\";\nimport { isImportedBinding, payloadPackageId } from \"./compiler-options.ts\";\n\nexport interface IsomorphicImport {\n importedName: string;\n localName: string;\n source: string;\n}\n\nexport interface CompiledIsomorphicImport extends IsomorphicImport {\n referenceId: string;\n}\n\nexport function isomorphicBoundaryAnalysisPlugin(\n imports: IsomorphicImport[],\n): () => PluginObject {\n return () => ({\n name: \"fig-tanstack-start-isomorphic-boundary-analysis\",\n visitor: {\n Program(path) {\n const seen = new Set<string>();\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (\n elementPath.node.name.type !== \"JSXIdentifier\" ||\n !isIsomorphicBoundary(elementPath, elementPath.node.name.name)\n ) {\n return;\n }\n const component = isomorphicComponentAttribute(elementPath);\n const imported = importedComponent(\n elementPath,\n component.node.name,\n );\n const key = `${imported.source}\\0${imported.importedName}\\0${component.node.name}`;\n if (seen.has(key)) return;\n seen.add(key);\n imports.push({ ...imported, localName: component.node.name });\n },\n });\n },\n },\n });\n}\n\n// Returns the local identifier for the runtime's createIsomorphicReference\n// when at least one boundary was rewritten, undefined otherwise.\nexport function rewriteIsomorphicBoundaries(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n references: readonly CompiledIsomorphicImport[],\n): babel.types.Identifier | undefined {\n if (references.length === 0) return undefined;\n const byLocalName = new Map(\n references.map((reference) => [reference.localName, reference]),\n );\n const createReference = path.scope.generateUidIdentifier(\n \"createIsomorphicReference\",\n );\n let count = 0;\n\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (\n elementPath.node.name.type !== \"JSXIdentifier\" ||\n !isIsomorphicBoundary(elementPath, elementPath.node.name.name)\n ) {\n return;\n }\n const component = isomorphicComponentAttribute(elementPath);\n const reference = byLocalName.get(component.node.name);\n if (reference === undefined) return;\n component.replaceWith(\n t.callExpression(t.cloneNode(createReference), [\n t.stringLiteral(reference.referenceId),\n ]),\n );\n count += 1;\n },\n });\n if (count === 0) return undefined;\n\n path.scope.crawl();\n for (const localName of byLocalName.keys()) {\n const binding = path.scope.getBinding(localName);\n if (\n binding?.referenced ||\n (!binding?.path.isImportSpecifier() &&\n !binding?.path.isImportDefaultSpecifier())\n ) {\n continue;\n }\n const declaration = binding.path.parentPath;\n binding.path.remove();\n if (\n declaration.isImportDeclaration() &&\n declaration.node.specifiers.length === 0\n ) {\n declaration.remove();\n }\n }\n return createReference;\n}\n\nfunction isIsomorphicBoundary(path: NodePath, localName: string): boolean {\n return isImportedBinding(path, localName, \"Isomorphic\", payloadPackageId);\n}\n\nfunction isomorphicComponentAttribute(\n path: NodePath<babel.types.JSXOpeningElement>,\n): NodePath<babel.types.Identifier> {\n const attribute = path\n .get(\"attributes\")\n .find(\n (candidate) =>\n candidate.isJSXAttribute() &&\n candidate.node.name.type === \"JSXIdentifier\" &&\n candidate.node.name.name === \"component\",\n );\n if (attribute === undefined || !attribute.isJSXAttribute()) {\n throw path.buildCodeFrameError(\n \"Isomorphic requires a component prop containing a statically imported component.\",\n );\n }\n const value = attribute.get(\"value\");\n if (!value.isJSXExpressionContainer()) {\n throw attribute.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n const expression = value.get(\"expression\");\n if (Array.isArray(expression) || !expression.isIdentifier()) {\n throw value.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n return expression;\n}\n\nfunction importedComponent(\n path: NodePath,\n localName: string,\n): Omit<IsomorphicImport, \"localName\"> {\n const binding = path.scope.getBinding(localName);\n if (\n binding === undefined ||\n (!binding.path.isImportSpecifier() &&\n !binding.path.isImportDefaultSpecifier()) ||\n !binding.path.parentPath.isImportDeclaration()\n ) {\n throw path.buildCodeFrameError(\n \"Isomorphic component must be a statically imported component identifier.\",\n );\n }\n const importedName = binding.path.isImportDefaultSpecifier()\n ? \"default\"\n : binding.path.node.imported.type === \"Identifier\"\n ? binding.path.node.imported.name\n : binding.path.node.imported.value;\n return {\n importedName,\n source: binding.path.parentPath.node.source.value,\n };\n}\n","import type { NodePath, PluginObject } from \"@babel/core\";\nimport type * as babel from \"@babel/core\";\nimport { isComponentName } from \"./compiler-options.ts\";\nimport { cleanModuleId, hasModuleQuery } from \"./module-ids.ts\";\n\nexport function stylesheetImportAnalysisPlugin(\n stylesheets: string[],\n): () => PluginObject {\n return () => ({\n name: \"fig-tanstack-start-stylesheet-import-analysis\",\n visitor: {\n ImportDeclaration(path) {\n const source = path.node.source.value;\n if (isStylesheetSpecifier(source)) stylesheets.push(source);\n },\n },\n });\n}\n\nexport function rewriteStylesheetImports(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n): babel.types.Identifier[] {\n const hrefs: babel.types.Identifier[] = [];\n for (const statement of path.get(\"body\")) {\n if (!statement.isImportDeclaration()) continue;\n const source = statement.node.source.value;\n if (!isStylesheetSpecifier(source)) continue;\n\n const existingUrl = hasUrlQuery(source);\n const defaultSpecifier = statement.node.specifiers.find(\n (specifier): specifier is babel.types.ImportDefaultSpecifier =>\n t.isImportDefaultSpecifier(specifier),\n );\n if (existingUrl && defaultSpecifier !== undefined) {\n hrefs.push(defaultSpecifier.local);\n continue;\n }\n\n const local = path.scope.generateUidIdentifier(\"figPayloadStylesheet\");\n if (statement.node.specifiers.length === 0) {\n statement.node.source = t.stringLiteral(withUrlQuery(source));\n statement.node.specifiers.push(t.importDefaultSpecifier(local));\n } else {\n statement.insertAfter(\n t.importDeclaration(\n [t.importDefaultSpecifier(local)],\n t.stringLiteral(withUrlQuery(source)),\n ),\n );\n }\n hrefs.push(local);\n }\n return hrefs;\n}\n\nexport function collectComponentNames(\n path: NodePath<babel.types.Program>,\n t: typeof babel.types,\n): string[] {\n const names = new Set<string>();\n for (const statement of path.get(\"body\")) {\n const declaration =\n statement.isExportNamedDeclaration() ||\n statement.isExportDefaultDeclaration()\n ? statement.get(\"declaration\")\n : statement;\n if (Array.isArray(declaration)) continue;\n\n if (declaration.isFunctionDeclaration()) {\n const name = declaration.node.id?.name;\n if (name !== undefined && isComponentName(name)) names.add(name);\n continue;\n }\n if (!declaration.isVariableDeclaration()) continue;\n\n for (const declarator of declaration.node.declarations) {\n if (\n t.isIdentifier(declarator.id) &&\n isComponentName(declarator.id.name) &&\n (t.isArrowFunctionExpression(declarator.init) ||\n t.isFunctionExpression(declarator.init))\n ) {\n names.add(declarator.id.name);\n }\n }\n }\n return [...names];\n}\n\nexport function isStylesheetSpecifier(source: string): boolean {\n const path = cleanModuleId(source);\n return /\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)$/.test(path);\n}\n\nfunction hasUrlQuery(source: string): boolean {\n return hasModuleQuery(source, \"url\");\n}\n\n// Vite's url plugin only matches the bare `?url` flag, so this cannot use\n// withModuleQuery's `name=value` form.\nfunction withUrlQuery(source: string): string {\n if (hasUrlQuery(source)) return source;\n return `${source}${source.includes(\"?\") ? \"&\" : \"?\"}url`;\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath, PluginObject } from \"@babel/core\";\nimport { payloadStylesheetsSymbolKey } from \"../payload-assets.ts\";\nimport {\n babelOptions,\n isComponentName,\n isImportedBinding,\n isSourceModule,\n serverPackageId,\n} from \"./compiler-options.ts\";\nimport {\n type CompiledIsomorphicImport,\n type IsomorphicImport,\n isomorphicBoundaryAnalysisPlugin,\n rewriteIsomorphicBoundaries,\n} from \"./isomorphic-compiler.ts\";\nimport {\n cleanModuleId,\n hasModuleQuery,\n payloadModuleQuery,\n withModuleQuery,\n} from \"./module-ids.ts\";\nimport {\n collectComponentNames,\n isStylesheetSpecifier,\n rewriteStylesheetImports,\n stylesheetImportAnalysisPlugin,\n} from \"./payload-stylesheet-compiler.ts\";\n\nexport const payloadRuntimeId = \"virtual:fig-tanstack-start/payload-runtime\";\nexport const resolvedPayloadRuntimeId = `\\0${payloadRuntimeId}`;\n\nconst figRuntimePackageIds: readonly string[] = [\n \"@bgub/fig\",\n \"@bgub/fig-devtools\",\n \"@bgub/fig-dom\",\n \"@bgub/fig-reconciler\",\n \"@bgub/fig-refresh\",\n \"@bgub/fig-server\",\n \"@bgub/fig-tanstack-router\",\n \"@bgub/fig-tanstack-start\",\n \"@bgub/fig-vite\",\n];\n\nexport async function analyzeStylesheetImports(\n code: string,\n id: string,\n): Promise<string[]> {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean)) return [];\n const stylesheets: string[] = [];\n await babel.transformAsync(code, {\n ...babelOptions(clean),\n plugins: [stylesheetImportAnalysisPlugin(stylesheets)],\n });\n return stylesheets;\n}\n\nexport async function analyzeIsomorphicBoundaries(\n code: string,\n id: string,\n): Promise<IsomorphicImport[]> {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean) || !code.includes(\"Isomorphic\")) return [];\n\n const imports: IsomorphicImport[] = [];\n await babel.transformAsync(code, {\n ...babelOptions(clean),\n plugins: [isomorphicBoundaryAnalysisPlugin(imports)],\n });\n return imports;\n}\n\n// Cheap pre-parse gate shared with the Vite transform hook, so callers can\n// skip boundary analysis for modules this transform cannot apply to.\nexport function mayBePayloadModule(code: string, id: string): boolean {\n return (\n isSourceModule(cleanModuleId(id)) &&\n (hasModuleQuery(id, payloadModuleQuery) ||\n code.includes(\"renderPayloadResponse\"))\n );\n}\n\nexport async function transformPayloadModule(\n code: string,\n id: string,\n isomorphicImports: readonly CompiledIsomorphicImport[] = [],\n) {\n if (!mayBePayloadModule(code, id)) return null;\n\n const state = { changed: false };\n const result = await babel.transformAsync(code, {\n ...babelOptions(cleanModuleId(id)),\n sourceMaps: true,\n plugins: [\n payloadBabelPlugin(\n isomorphicImports,\n hasModuleQuery(id, payloadModuleQuery),\n state,\n ),\n ],\n });\n\n if (!state.changed || result?.code == null) return null;\n return {\n code: result.code,\n map: result.map == null ? null : JSON.stringify(result.map),\n };\n}\n\nexport function payloadRuntimeCode(): string {\n return `import { clientReference } from \"@bgub/fig\";\nconst stylesheetKey = Symbol.for(${JSON.stringify(payloadStylesheetsSymbolKey)});\nexport function createIsomorphicReference(id) {\n return clientReference({ id });\n}\nexport function registerPayloadStylesheets(components, hrefs) {\n for (const component of components) {\n if (typeof component === \"function\") {\n Object.defineProperty(component, stylesheetKey, { configurable: true, value: hrefs });\n }\n }\n}`;\n}\n\nfunction payloadBabelPlugin(\n isomorphicImports: readonly CompiledIsomorphicImport[],\n compiledPayloadModule: boolean,\n state: { changed: boolean },\n): (api: typeof babel) => PluginObject {\n return (api: typeof babel) => {\n const t = api.types;\n\n return {\n name: \"fig-tanstack-start-payload\",\n visitor: {\n Program: {\n exit(path: NodePath<babel.types.Program>) {\n if (!compiledPayloadModule && !callsRenderPayloadResponse(path)) {\n return;\n }\n const components = collectComponentNames(path, t);\n const hrefs =\n components.length === 0 ? [] : rewriteStylesheetImports(path, t);\n const createReference = rewriteIsomorphicBoundaries(\n path,\n t,\n isomorphicImports,\n );\n\n if (rewritePayloadComponentImports(path) > 0) state.changed = true;\n\n const runtimeSpecifiers: babel.types.ImportSpecifier[] = [];\n if (createReference !== undefined) {\n runtimeSpecifiers.push(\n t.importSpecifier(\n createReference,\n t.identifier(\"createIsomorphicReference\"),\n ),\n );\n }\n let registerStylesheets: babel.types.Identifier | undefined;\n if (hrefs.length > 0) {\n registerStylesheets = path.scope.generateUidIdentifier(\n \"registerPayloadStylesheets\",\n );\n runtimeSpecifiers.push(\n t.importSpecifier(\n registerStylesheets,\n t.identifier(\"registerPayloadStylesheets\"),\n ),\n );\n }\n if (runtimeSpecifiers.length === 0) return;\n state.changed = true;\n\n path.node.body.unshift(\n t.importDeclaration(\n runtimeSpecifiers,\n t.stringLiteral(payloadRuntimeId),\n ),\n );\n if (registerStylesheets !== undefined) {\n path.node.body.push(\n t.expressionStatement(\n t.callExpression(registerStylesheets, [\n t.arrayExpression(\n components.map((name) => t.identifier(name)),\n ),\n t.arrayExpression(hrefs),\n ]),\n ),\n );\n }\n },\n },\n },\n };\n };\n}\n\nfunction callsRenderPayloadResponse(\n path: NodePath<babel.types.Program>,\n): boolean {\n let found = false;\n path.traverse({\n CallExpression(callPath) {\n if (\n callPath.node.callee.type === \"Identifier\" &&\n isImportedBinding(\n callPath,\n callPath.node.callee.name,\n \"renderPayloadResponse\",\n serverPackageId,\n )\n ) {\n found = true;\n callPath.stop();\n }\n },\n });\n return found;\n}\n\n// Returns the number of import declarations marked with the payload query.\nfunction rewritePayloadComponentImports(\n path: NodePath<babel.types.Program>,\n): number {\n const componentBindings = new Set<string>();\n path.traverse({\n JSXOpeningElement(elementPath) {\n if (elementPath.node.name.type === \"JSXNamespacedName\") return;\n const name = rootJsxIdentifier(elementPath.node.name);\n if (name !== undefined) componentBindings.add(name);\n },\n CallExpression(callPath) {\n if (\n callPath.node.callee.type !== \"Identifier\" ||\n !isImportedBinding(\n callPath,\n callPath.node.callee.name,\n \"createElement\",\n \"@bgub/fig\",\n )\n ) {\n return;\n }\n const [type] = callPath.node.arguments;\n if (type?.type === \"Identifier\" && isComponentName(type.name)) {\n componentBindings.add(type.name);\n }\n },\n });\n\n let count = 0;\n for (const statement of path.get(\"body\")) {\n if (!statement.isImportDeclaration()) continue;\n const source = statement.node.source.value;\n if (\n statement.node.importKind === \"type\" ||\n isStylesheetSpecifier(source) ||\n isFigRuntimeSpecifier(source) ||\n hasModuleQuery(source, payloadModuleQuery) ||\n !statement.node.specifiers.some(\n (specifier) =>\n !(\"importKind\" in specifier && specifier.importKind === \"type\") &&\n componentBindings.has(specifier.local.name),\n )\n ) {\n continue;\n }\n statement.node.source.value = withModuleQuery(\n source,\n payloadModuleQuery,\n \"1\",\n );\n count += 1;\n }\n return count;\n}\n\nfunction isFigRuntimeSpecifier(source: string): boolean {\n return figRuntimePackageIds.some(\n (packageId) => source === packageId || source.startsWith(`${packageId}/`),\n );\n}\n\nfunction rootJsxIdentifier(\n name: babel.types.JSXIdentifier | babel.types.JSXMemberExpression,\n): string | undefined {\n let current: typeof name = name;\n while (current.type === \"JSXMemberExpression\") current = current.object;\n return current.type === \"JSXIdentifier\" && isComponentName(current.name)\n ? current.name\n : undefined;\n}\n","import * as babel from \"@babel/core\";\nimport type { NodePath, PluginObject } from \"@babel/core\";\nimport { tanStackCompatibilityProfile } from \"./compatibility-profile.ts\";\nimport {\n babelOptions,\n isImportedBinding,\n isSourceModule,\n payloadPackageId,\n serverPackageId,\n} from \"./compiler-options.ts\";\nimport { cleanModuleId } from \"./module-ids.ts\";\n\nconst compiledServerPayloadMarkerKey =\n \"fig.tanstack-start.compiled-server-payload\";\n\nexport async function transformServerPayloadDefinitions(\n code: string,\n id: string,\n) {\n const clean = cleanModuleId(id);\n if (!isSourceModule(clean) || !code.includes(\"serverPayload\")) return null;\n\n const state = { transformed: false };\n const result = await babel.transformAsync(code, {\n ...babelOptions(clean),\n sourceMaps: true,\n plugins: [serverPayloadBabelPlugin(state)],\n });\n\n if (!state.transformed || result?.code == null) return null;\n return {\n code: result.code,\n map: result.map == null ? null : JSON.stringify(result.map),\n };\n}\n\nfunction serverPayloadBabelPlugin(state: {\n transformed: boolean;\n}): (api: typeof babel) => PluginObject {\n return (api: typeof babel) => {\n const t = api.types;\n let createElement: babel.types.Identifier;\n let createServerFn: babel.types.Identifier;\n let renderPayloadResponse: babel.types.Identifier;\n\n return {\n name: \"fig-tanstack-start-server-payload\",\n visitor: {\n Program: {\n enter(path: NodePath<babel.types.Program>) {\n createElement = path.scope.generateUidIdentifier(\"createElement\");\n createServerFn = path.scope.generateUidIdentifier(\"createServerFn\");\n renderPayloadResponse = path.scope.generateUidIdentifier(\n \"renderPayloadResponse\",\n );\n },\n exit(path: NodePath<babel.types.Program>) {\n if (!state.transformed) return;\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n createElement,\n t.identifier(\"createElement\"),\n ),\n ],\n t.stringLiteral(\"@bgub/fig\"),\n ),\n );\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n renderPayloadResponse,\n t.identifier(\"renderPayloadResponse\"),\n ),\n ],\n t.stringLiteral(serverPackageId),\n ),\n );\n path.node.body.unshift(\n t.importDeclaration(\n [\n t.importSpecifier(\n createServerFn,\n t.identifier(\"createServerFn\"),\n ),\n ],\n t.stringLiteral(\n tanStackCompatibilityProfile.packages.frameworkStart,\n ),\n ),\n );\n },\n },\n CallExpression(path: NodePath<babel.types.CallExpression>) {\n if (\n path.node.callee.type !== \"Identifier\" ||\n !isImportedBinding(\n path,\n path.node.callee.name,\n \"serverPayload\",\n payloadPackageId,\n )\n ) {\n return;\n }\n\n transformServerPayloadCall(\n path,\n t,\n createElement,\n createServerFn,\n renderPayloadResponse,\n );\n state.transformed = true;\n },\n },\n };\n };\n}\n\nfunction transformServerPayloadCall(\n path: NodePath<babel.types.CallExpression>,\n t: typeof babel.types,\n createElement: babel.types.Identifier,\n createServerFn: babel.types.Identifier,\n renderPayloadResponse: babel.types.Identifier,\n): void {\n const [render, ...extra] = path.node.arguments;\n if (\n render === undefined ||\n render.type === \"SpreadElement\" ||\n render.type === \"ArgumentPlaceholder\" ||\n extra.length > 0\n ) {\n throw path.buildCodeFrameError(\n \"serverPayload requires exactly one server component or render callback.\",\n );\n }\n if (!isRenderExpression(render)) {\n throw path.buildCodeFrameError(\n \"serverPayload requires a component reference or inline render callback.\",\n );\n }\n const statement = path.getStatementParent();\n if (\n path.getFunctionParent() !== null ||\n statement === null ||\n !statement.parentPath.isProgram()\n ) {\n throw path.buildCodeFrameError(\n \"serverPayload must be declared in a top-level statement.\",\n );\n }\n\n const declarator = path.findParent((candidate) =>\n candidate.isVariableDeclarator(),\n );\n const requestName =\n declarator?.isVariableDeclarator() &&\n declarator.node.id.type === \"Identifier\"\n ? `${declarator.node.id.name}Request`\n : \"payloadRequest\";\n const request = statement.scope.generateUidIdentifier(requestName);\n const data = statement.scope.generateUidIdentifier(\"data\");\n const input = statement.scope.generateUidIdentifier(\"input\");\n const signal = statement.scope.generateUidIdentifier(\"signal\");\n\n const serverFn = t.callExpression(\n t.memberExpression(\n t.callExpression(createServerFn, []),\n t.identifier(\"handler\"),\n ),\n [\n t.arrowFunctionExpression(\n [\n t.objectPattern([\n t.objectProperty(t.identifier(\"data\"), data, false, false),\n ]),\n ],\n t.callExpression(renderPayloadResponse, [\n t.callExpression(createElement, [render, data]),\n ]),\n ),\n ],\n );\n\n statement.insertBefore(\n t.variableDeclaration(\"const\", [t.variableDeclarator(request, serverFn)]),\n );\n const proxy = t.arrowFunctionExpression(\n [\n input,\n t.objectPattern([\n t.objectProperty(t.identifier(\"signal\"), signal, false, false),\n ]),\n ],\n t.callExpression(request, [\n t.objectExpression([\n t.objectProperty(t.identifier(\"data\"), input, false, false),\n t.objectProperty(t.identifier(\"signal\"), signal, false, false),\n ]),\n ]),\n );\n path.node.arguments = [\n t.callExpression(\n t.memberExpression(t.identifier(\"Object\"), t.identifier(\"assign\")),\n [\n proxy,\n t.objectExpression([\n t.objectProperty(\n t.callExpression(\n t.memberExpression(t.identifier(\"Symbol\"), t.identifier(\"for\")),\n [t.stringLiteral(compiledServerPayloadMarkerKey)],\n ),\n t.booleanLiteral(true),\n true,\n ),\n ]),\n ],\n ),\n ];\n}\n\nfunction isRenderExpression(\n value: babel.types.Expression,\n): value is\n | babel.types.ArrowFunctionExpression\n | babel.types.FunctionExpression\n | babel.types.Identifier\n | babel.types.MemberExpression {\n return (\n value.type === \"ArrowFunctionExpression\" ||\n (value.type === \"FunctionExpression\" && !value.generator) ||\n value.type === \"Identifier\" ||\n value.type === \"MemberExpression\"\n );\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nexport async function writePublicAsset(\n path: string,\n source: string | Uint8Array,\n): Promise<void> {\n const bytes = Buffer.from(source);\n let existing: Buffer | undefined;\n try {\n existing = await readFile(path);\n } catch (error) {\n if (!isMissingFile(error)) throw error;\n }\n\n if (existing !== undefined) {\n if (existing.equals(bytes)) return;\n throw new Error(\n `TanStack Start server asset ${JSON.stringify(path)} conflicts with a different client asset at the same public path. Use content-hashed or separately namespaced asset file names.`,\n );\n }\n\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, bytes);\n}\n\nfunction isMissingFile(error: unknown): error is NodeJS.ErrnoException {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n","import { readFile } from \"node:fs/promises\";\nimport { isAbsolute, resolve } from \"node:path\";\nimport { START_ENVIRONMENT_NAMES } from \"@tanstack/start-plugin-core/vite\";\nimport type { EnvironmentModuleNode, PluginOption } from \"vite\";\nimport { rewriteFrameworkImports } from \"./compatibility-profile.ts\";\nimport {\n isomorphicReferenceId,\n type ManifestReference,\n payloadManifestDefinitionCode,\n payloadManifestId,\n payloadManifestRuntimeCode,\n payloadReferenceIds,\n resolvedPayloadManifestId,\n} from \"./isomorphic-manifest.ts\";\nimport {\n cleanModuleId,\n decodeOpaqueId,\n encodeOpaqueId,\n hasModuleQuery,\n payloadManifestDefinitionQuery,\n payloadModuleQuery,\n toViteModulePath,\n withModuleQuery,\n} from \"./module-ids.ts\";\nimport type { IsomorphicImport } from \"./isomorphic-compiler.ts\";\nimport {\n analyzeIsomorphicBoundaries,\n analyzeStylesheetImports,\n mayBePayloadModule,\n payloadRuntimeCode,\n payloadRuntimeId,\n resolvedPayloadRuntimeId,\n transformPayloadModule,\n} from \"./payload-compiler.ts\";\nimport { transformServerPayloadDefinitions } from \"./server-payload-compiler.ts\";\nimport { writePublicAsset } from \"./public-assets.ts\";\n\nconst payloadManifestDefinitionPrefix =\n \"\\0fig-tanstack-start:payload-manifest-definition:\";\n\nexport function serverPayloadPlugin(): PluginOption {\n return {\n name: \"fig-tanstack-start:server-payload\",\n enforce: \"pre\",\n transform: transformServerPayloadDefinitions,\n };\n}\n\nexport function payloadPlugin(): PluginOption {\n let root = process.cwd();\n let base = \"/\";\n let clientOutDir: string | undefined;\n let serverAssetsPrefix = \"assets/\";\n // Start runs the client build before the server build with this plugin\n // instance. Retain Vite's final client CSS names for the server manifest.\n const clientStylesheets = new Map<string, string[]>();\n // Loaded manifest definitions read their source — and each referenced\n // component's stylesheet imports — through the filesystem, so the module\n // graph cannot see when those analyzed inputs change; hotUpdate compares\n // these fingerprints to reload only affected definitions.\n const definitionInputs = new Map<string, DefinitionInputs>();\n\n return {\n name: \"fig-tanstack-start:payload\",\n enforce: \"pre\",\n configEnvironment(environmentName) {\n if (environmentName === START_ENVIRONMENT_NAMES.server) {\n return { build: { emitAssets: true } };\n }\n return undefined;\n },\n configResolved(config) {\n root = config.root;\n base = config.base;\n const outDir =\n config.environments[START_ENVIRONMENT_NAMES.client]?.build.outDir;\n if (outDir !== undefined) clientOutDir = resolve(config.root, outDir);\n const assetsDir =\n config.environments[START_ENVIRONMENT_NAMES.server]?.build.assetsDir;\n if (assetsDir !== undefined) {\n const normalized = assetsDir.replace(/\\/+$/, \"\");\n serverAssetsPrefix = normalized === \"\" ? \"\" : `${normalized}/`;\n }\n },\n async writeBundle(_options, bundle) {\n if (\n this.environment.name !== START_ENVIRONMENT_NAMES.server ||\n clientOutDir === undefined\n ) {\n return;\n }\n\n const publicOutDir = clientOutDir;\n await Promise.all(\n Object.values(bundle).map(async (output) => {\n if (\n output.type !== \"asset\" ||\n !output.fileName.startsWith(serverAssetsPrefix) ||\n output.fileName.endsWith(\".map\")\n ) {\n return;\n }\n const path = resolve(publicOutDir, output.fileName);\n await writePublicAsset(path, output.source);\n }),\n );\n },\n generateBundle(_options, bundle) {\n if (this.environment.name !== START_ENVIRONMENT_NAMES.client) return;\n collectClientStylesheets(bundle, clientStylesheets, base);\n },\n async resolveId(source, importer) {\n if (source === payloadRuntimeId) return resolvedPayloadRuntimeId;\n if (source === payloadManifestId) return resolvedPayloadManifestId;\n if (hasModuleQuery(source, payloadModuleQuery)) {\n const resolved = await this.resolve(cleanModuleId(source), importer, {\n skipSelf: true,\n });\n return resolved === null\n ? null\n : withModuleQuery(\n cleanModuleId(resolved.id),\n payloadModuleQuery,\n \"1\",\n );\n }\n if (!hasModuleQuery(source, payloadManifestDefinitionQuery)) {\n return undefined;\n }\n\n const resolved = await this.resolve(cleanModuleId(source), importer, {\n skipSelf: true,\n });\n if (resolved === null) return null;\n // Start protects .server modules from the client graph. The manifest\n // needs only their compiled definitions, so expose those definitions\n // through a private virtual id before import protection runs.\n return definitionModuleId(cleanModuleId(resolved.id));\n },\n async load(id) {\n if (id === resolvedPayloadRuntimeId) return payloadRuntimeCode();\n if (id === resolvedPayloadManifestId) {\n return payloadManifestRuntimeCode(clientStylesheets);\n }\n if (!id.startsWith(payloadManifestDefinitionPrefix)) return undefined;\n\n const sourceId = decodeOpaqueId(\n id.slice(payloadManifestDefinitionPrefix.length),\n );\n const code = rewriteFrameworkImports(await readFile(sourceId, \"utf8\"));\n const stylesheetSources = new Map<string, string>();\n const references = await collectPayloadReferences(\n sourceId,\n code,\n (source, importer) =>\n this.resolve(source, importer, { skipSelf: true }),\n root,\n stylesheetSources,\n );\n if (references.length > 0) {\n this.addWatchFile(sourceId);\n definitionInputs.set(sourceId, {\n boundaries: boundaryFingerprint(references),\n stylesheetSources,\n });\n } else {\n // A missing entry means the empty fingerprint, so the map only holds\n // the few definitions that actually have boundaries.\n definitionInputs.delete(sourceId);\n }\n return payloadManifestDefinitionCode(references);\n },\n async hotUpdate({ file, modules, read }) {\n const { moduleGraph } = this.environment;\n const invalidated = new Set<EnvironmentModuleNode>();\n let content: string | undefined;\n const readContent = async () => (content ??= await read());\n\n const definition = moduleGraph.getModuleById(definitionModuleId(file));\n if (definition !== undefined) {\n let changed: boolean;\n try {\n const boundaries = boundaryFingerprint(\n await analyzeIsomorphicBoundaries(\n rewriteFrameworkImports(await readContent()),\n file,\n ),\n );\n changed =\n (definitionInputs.get(file)?.boundaries ??\n emptyBoundaryFingerprint) !== boundaries;\n } catch {\n // Mid-edit analysis failures surface through the module's own\n // transform; reload the definition so the manifest cannot go stale.\n changed = true;\n }\n if (changed) invalidated.add(definition);\n }\n\n // The changed file may be a component module whose stylesheet imports\n // are embedded in other definitions as development hrefs.\n const dependents = [...definitionInputs].filter(([, inputs]) =>\n inputs.stylesheetSources.has(file),\n );\n if (dependents.length > 0) {\n let sources: string | undefined;\n try {\n sources = stylesheetSourceFingerprint(\n await analyzeStylesheetImports(await readContent(), file),\n );\n } catch {\n sources = undefined;\n }\n for (const [sourceId, inputs] of dependents) {\n if (inputs.stylesheetSources.get(file) === sources) continue;\n const dependent = moduleGraph.getModuleById(\n definitionModuleId(sourceId),\n );\n if (dependent !== undefined) invalidated.add(dependent);\n }\n }\n\n if (invalidated.size === 0) return undefined;\n return [...modules, ...invalidated];\n },\n async transform(code, id) {\n if (\n this.environment.name !== START_ENVIRONMENT_NAMES.server ||\n !mayBePayloadModule(code, id)\n ) {\n return null;\n }\n const references = await collectPayloadReferences(\n id,\n code,\n (source, importer) =>\n this.resolve(source, importer, { skipSelf: true }),\n root,\n );\n return transformPayloadModule(code, id, references);\n },\n };\n}\n\ninterface DefinitionInputs {\n boundaries: string;\n // Referenced component module id → fingerprint of its stylesheet imports.\n stylesheetSources: Map<string, string>;\n}\n\nfunction definitionModuleId(sourceId: string): string {\n return `${payloadManifestDefinitionPrefix}${encodeOpaqueId(sourceId)}`;\n}\n\nfunction boundaryFingerprint(imports: readonly IsomorphicImport[]): string {\n return JSON.stringify(\n imports.map(({ importedName, localName, source }) => [\n source,\n importedName,\n localName,\n ]),\n );\n}\n\nconst emptyBoundaryFingerprint = boundaryFingerprint([]);\n\n// hotUpdate has no resolver, so fingerprints use the raw import specifiers\n// rather than resolved stylesheet ids.\nfunction stylesheetSourceFingerprint(sources: readonly string[]): string {\n return JSON.stringify(sources);\n}\n\ntype ResolveModule = (\n source: string,\n importer: string,\n) => Promise<{ id: string } | null>;\n\nasync function collectPayloadReferences(\n id: string,\n code: string,\n resolveModule: ResolveModule,\n root: string,\n stylesheetSources?: Map<string, string>,\n): Promise<ManifestReference[]> {\n const importerId = cleanModuleId(id);\n const imports = await analyzeIsomorphicBoundaries(code, id);\n return Promise.all(\n imports.map(async (imported): Promise<ManifestReference> => {\n const resolved = await resolveModule(imported.source, importerId);\n if (resolved === null) {\n throw new Error(\n `Cannot resolve Isomorphic component import ${JSON.stringify(imported.source)} from ${importerId}.`,\n );\n }\n const moduleId = cleanModuleId(resolved.id);\n const referenceId = isomorphicReferenceId(\n root,\n moduleId,\n imported.importedName,\n );\n let hrefs: string[] = [];\n if (stylesheetSources !== undefined) {\n const stylesheets = await moduleStylesheets(\n moduleId,\n root,\n resolveModule,\n );\n hrefs = stylesheets.hrefs;\n stylesheetSources.set(\n moduleId,\n stylesheetSourceFingerprint(stylesheets.sources),\n );\n }\n return {\n ...imported,\n referenceId,\n resolvedModuleId: moduleId,\n developmentStylesheetHrefs: hrefs,\n };\n }),\n );\n}\n\nasync function moduleStylesheets(\n moduleId: string,\n root: string,\n resolveModule: ResolveModule,\n): Promise<{ hrefs: string[]; sources: string[] }> {\n if (!isAbsolute(moduleId)) return { hrefs: [], sources: [] };\n let code: string;\n try {\n code = await readFile(moduleId, \"utf8\");\n } catch {\n return { hrefs: [], sources: [] };\n }\n const sources = await analyzeStylesheetImports(code, moduleId);\n const hrefs = (\n await Promise.all(\n sources.map(async (source) => {\n const resolved = await resolveModule(source, moduleId);\n return resolved === null\n ? undefined\n : toViteModulePath(root, cleanModuleId(resolved.id));\n }),\n )\n ).filter((href): href is string => href !== undefined);\n return { hrefs, sources };\n}\n\nfunction collectClientStylesheets(\n bundle: OutputBundle,\n clientStylesheets: Map<string, string[]>,\n base: string,\n): void {\n clientStylesheets.clear();\n for (const output of Object.values(bundle)) {\n if (output.type !== \"chunk\") continue;\n const referenceIds = payloadReferenceIds(Object.keys(output.modules));\n for (const referenceId of referenceIds) {\n const stylesheets = new Set(clientStylesheets.get(referenceId));\n for (const file of output.viteMetadata?.importedCss ?? []) {\n stylesheets.add(`${base.replace(/\\/$/, \"\")}/${file}`);\n }\n clientStylesheets.set(referenceId, [...stylesheets]);\n }\n }\n}\n\ntype OutputBundle = Record<string, OutputChunk | OutputAsset>;\n\ninterface OutputAsset {\n type: \"asset\";\n}\n\ninterface OutputChunk {\n modules: Record<string, unknown>;\n type: \"chunk\";\n viteMetadata?: { importedCss?: Set<string> };\n}\n","import {\n START_ENVIRONMENT_NAMES,\n tanStackStartVite,\n type TanStackStartViteInputConfig,\n} from \"@tanstack/start-plugin-core/vite\";\nimport { fig } from \"@bgub/fig-vite\";\nimport type { PluginOption } from \"vite\";\nimport {\n defaultEntryPaths,\n startCompatibilityPlugin,\n} from \"./compatibility-vite.ts\";\nimport { payloadPlugin, serverPayloadPlugin } from \"./payload-vite.ts\";\nimport { tanStackCompatibilityProfile } from \"./compatibility-profile.ts\";\n\nexport function tanstackStart(\n options?: TanStackStartViteInputConfig,\n): PluginOption[] {\n return [\n startCompatibilityPlugin(),\n serverPayloadPlugin(),\n payloadPlugin(),\n tanStackStartVite(\n {\n defaultEntryPaths,\n framework: tanStackCompatibilityProfile.framework,\n providerEnvironmentName: START_ENVIRONMENT_NAMES.server,\n ssrIsProvider: true,\n ssrResolverStrategy: { type: \"default\" },\n },\n options,\n ),\n // Route splitting must run first: it moves component declarations into\n // virtual modules. Refresh then registers the declarations where they\n // actually remain instead of leaving references in the route shell.\n ...fig(),\n ];\n}\n"],"mappings":";;;;;;;;;;AAGA,MAAa,iCAAiC;AAC9C,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AAErC,SAAgB,cAAc,IAAoB;CAChD,MAAM,QAAQ,GAAG,QAAQ,GAAG;CAC5B,OAAO,UAAU,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;AAC9C;AAEA,SAAgB,iBAAiB,IAAY,MAAkC;CAC7E,MAAM,QAAQ,GAAG,QAAQ,GAAG;CAC5B,IAAI,UAAU,IAAI,OAAO,KAAA;CACzB,MAAM,OAAO,GAAG,QAAQ,KAAK,KAAK;CAIlC,OAHc,IAAI,gBAChB,GAAG,MAAM,QAAQ,GAAG,SAAS,KAAK,KAAA,IAAY,IAAI,CACpD,CAAC,CAAC,IAAI,IACK,KAAK,KAAA;AAClB;AAEA,SAAgB,eAAe,IAAY,MAAuB;CAChE,OAAO,iBAAiB,IAAI,IAAI,MAAM,KAAA;AACxC;AAEA,SAAgB,gBACd,QACA,MACA,OACQ;CACR,MAAM,OAAO,OAAO,QAAQ,GAAG;CAC/B,MAAM,SAAS,SAAS,KAAK,KAAK,OAAO,MAAM,IAAI;CACnD,MAAM,OAAO,SAAS,KAAK,SAAS,OAAO,MAAM,GAAG,IAAI;CAExD,OAAO,GAAG,OADQ,KAAK,SAAS,GAAG,IAAI,MAAM,MAChB,KAAK,GAAG,mBAAmB,KAAK,IAAI;AACnE;AAEA,SAAgB,eAAe,IAAoB;CACjD,OAAOA,SAAO,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;AAEA,SAAgB,eAAe,IAAoB;CACjD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stack-start",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "TanStack Start adapter for Fig",
5
5
  "keywords": [
6
6
  "fig",
@@ -66,21 +66,21 @@
66
66
  "@tanstack/start-client-core": "1.170.14",
67
67
  "@tanstack/start-plugin-core": "1.171.22",
68
68
  "@tanstack/start-server-core": "1.169.17",
69
- "@bgub/fig-vite": "0.1.0-alpha.1"
69
+ "@bgub/fig-vite": "0.1.0-alpha.3"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "vite": ">=7.0.0",
73
- "@bgub/fig": "0.1.0-alpha.1",
74
- "@bgub/fig-dom": "0.1.0-alpha.1",
75
- "@bgub/fig-tanstack-router": "0.1.0-alpha.1",
76
- "@bgub/fig-server": "0.1.0-alpha.1"
73
+ "@bgub/fig": "0.1.0-alpha.3",
74
+ "@bgub/fig-server": "0.1.0-alpha.3",
75
+ "@bgub/fig-tanstack-router": "0.1.0-alpha.3",
76
+ "@bgub/fig-dom": "0.1.0-alpha.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "vite": "8.1.4",
80
- "@bgub/fig-dom": "0.1.0-alpha.1",
81
- "@bgub/fig-server": "0.1.0-alpha.1",
82
- "@bgub/fig": "0.1.0-alpha.1",
83
- "@bgub/fig-tanstack-router": "0.1.0-alpha.1"
80
+ "@bgub/fig": "0.1.0-alpha.3",
81
+ "@bgub/fig-dom": "0.1.0-alpha.3",
82
+ "@bgub/fig-server": "0.1.0-alpha.3",
83
+ "@bgub/fig-tanstack-router": "0.1.0-alpha.3"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=22.12.0"