auto-server-split 0.0.0-stage → 1.0.0
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 +116 -0
- package/LICENSE +21 -0
- package/README.md +279 -2
- package/dist/bundleSize-KPGJRR3B.js +8 -0
- package/dist/bundleSize-KPGJRR3B.js.map +1 -0
- package/dist/chunk-6OAWHATP.js +4847 -0
- package/dist/chunk-6OAWHATP.js.map +1 -0
- package/dist/chunk-YCSBOPV3.js +134 -0
- package/dist/chunk-YCSBOPV3.js.map +1 -0
- package/dist/chunk-YQKO5FJM.js +155 -0
- package/dist/chunk-YQKO5FJM.js.map +1 -0
- package/dist/cli.js +257 -0
- package/dist/cli.js.map +1 -0
- package/dist/eslint/index.d.ts +17 -0
- package/dist/eslint/index.js +176 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive-JF66CJGV.js +66 -0
- package/dist/interactive-JF66CJGV.js.map +1 -0
- package/package.json +112 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/analysis/skip.ts","../src/config/config.ts","../src/split.ts","../src/analysis/components.ts","../src/analysis/context.ts","../src/analysis/refs.ts","../src/analysis/importTable.ts","../src/analysis/importers.ts","../src/analysis/directives.ts","../src/analysis/islands.ts","../src/analysis/mongoose.ts","../src/analysis/serializable.ts","../src/analysis/moduleSafety.ts","../src/analysis/taint.ts","../src/frameworks/next.ts","../src/project/loadProject.ts","../src/project/moduleGraph.ts","../src/project/packages.ts","../src/transform/emit.ts","../src/transform/text.ts","../src/transform/typeRefs.ts","../src/transform/format.ts","../src/verify/selfCheck.ts"],"sourcesContent":["/**\n * Every reason the tool can decline to split a file. Codes are stable: they appear in\n * JSON output, CI logs and docs/skip-reasons.md, so never rename one.\n */\nexport const SKIP_CODES = [\n \"imported-by-client\",\n \"exports-non-components\",\n \"state-spans-component\",\n \"context-provider\",\n \"css-in-js-runtime\",\n \"non-serializable-prop\",\n \"untyped-boundary\",\n \"spread-props\",\n \"conditional-hooks-or-returns\",\n \"class-component\",\n \"dynamic-import\",\n \"render-prop\",\n \"hoc\",\n \"server-env-difference\",\n \"no-islands\",\n \"fully-interactive\",\n \"below-threshold\",\n \"measure-failed\",\n \"output-exists\",\n \"would-create-route\",\n \"unsupported-pattern\",\n \"self-check-failed\",\n \"parse-error\",\n \"internal-error\",\n] as const;\n\nexport type SkipCode = (typeof SKIP_CODES)[number];\n\nexport type SourceLocation = { line: number; column: number };\n\nexport type Skip = {\n code: SkipCode;\n message: string;\n location?: SourceLocation;\n};\n\n/** Short, human-readable titles used when grouping skips in the CLI summary. */\nexport const SKIP_TITLES: Record<SkipCode, string> = {\n \"imported-by-client\": \"imported by a client module\",\n \"exports-non-components\": \"exports something other than components and types\",\n \"state-spans-component\": \"client state spans the whole component\",\n \"context-provider\": \"creates or provides a React Context\",\n \"css-in-js-runtime\": \"uses runtime CSS-in-JS\",\n \"non-serializable-prop\": \"a value crossing the boundary is not serializable\",\n \"untyped-boundary\": \"untyped file: boundary values can't be proven serializable\",\n \"spread-props\": \"spread props can't be proven serializable\",\n \"conditional-hooks-or-returns\": \"conditional hooks or client-dependent early returns\",\n \"class-component\": \"contains a class component\",\n \"dynamic-import\": \"uses next/dynamic or React.lazy\",\n \"render-prop\": \"uses a render prop or function-as-child\",\n hoc: \"wrapped in memo/forwardRef or another higher-order component\",\n \"server-env-difference\": \"reads an env var that differs between server and client\",\n \"no-islands\": \"no client-only code found (the directive may be unnecessary)\",\n \"fully-interactive\": \"nothing would stay on the server\",\n \"below-threshold\": \"saving is below the configured threshold\",\n \"measure-failed\": \"the saving couldn't be measured, so minBytesSaved can't be checked\",\n \"output-exists\": \"the generated file already exists\",\n \"would-create-route\": \"the generated file could become a route\",\n \"unsupported-pattern\": \"uses a pattern this version does not handle\",\n \"self-check-failed\": \"the generated code failed the self-check\",\n \"parse-error\": \"the file could not be parsed\",\n \"internal-error\": \"internal error (please report)\",\n};\n\n/** Expected skips are values, never exceptions. Analysis steps return `Outcome<T>`. */\nexport type Outcome<T> = { ok: true; value: T } | { ok: false; skip: Skip };\n\nexport function ok<T>(value: T): Outcome<T> {\n return { ok: true, value };\n}\n\nexport function skip(\n code: SkipCode,\n message: string,\n location?: SourceLocation,\n): { ok: false; skip: Skip } {\n return { ok: false, skip: location ? { code, message, location } : { code, message } };\n}\n","import { existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { buildSync } from \"esbuild\";\nimport type { ResolvedConfig, UserConfig } from \"../types.js\";\n\nconst DEFAULT_CONFIG: ResolvedConfig = {\n include: [\"app/**\", \"components/**\", \"src/**\"],\n exclude: [\"**/*.test.*\", \"**/*.spec.*\", \"**/*.stories.*\"],\n clientOnlyPackages: [],\n serverSafeHooks: [],\n clientFileSuffix: \".client\",\n islandsDir: undefined,\n minBytesSaved: 2048,\n minStaticRatio: 0.3,\n prettier: \"auto\",\n mongoose: { autoSerialize: false },\n};\n\nconst CONFIG_FILES = [\n \"auto-split.config.ts\",\n \"auto-split.config.mts\",\n \"auto-split.config.mjs\",\n \"auto-split.config.js\",\n \"auto-split.config.json\",\n];\n\nexport class ConfigError extends Error {}\n\nconst KEYS: Record<keyof UserConfig, (v: unknown) => string | undefined> = {\n include: stringArray,\n exclude: stringArray,\n clientOnlyPackages: stringArray,\n serverSafeHooks: stringArray,\n clientFileSuffix: (v) =>\n typeof v === \"string\" && /^\\.[\\w.-]+$/.test(v)\n ? undefined\n : 'must be a string starting with \".\" (e.g. \".client\")',\n islandsDir: (v) =>\n typeof v === \"string\" && v.length > 0 && !path.isAbsolute(v) && !v.includes(\"..\")\n ? undefined\n : \"must be a relative directory name\",\n minBytesSaved: (v) =>\n typeof v === \"number\" && v >= 0 && Number.isFinite(v)\n ? undefined\n : \"must be a non-negative number\",\n minStaticRatio: (v) =>\n typeof v === \"number\" && v >= 0 && v <= 1 ? undefined : \"must be a number between 0 and 1\",\n prettier: (v) => (v === \"auto\" || v === false ? undefined : 'must be \"auto\" or false'),\n mongoose: (v) => {\n if (typeof v !== \"object\" || v === null || Array.isArray(v)) return \"must be an object\";\n for (const [k, val] of Object.entries(v)) {\n if (k !== \"autoSerialize\") return `has an unknown key \"${k}\" (allowed: autoSerialize)`;\n if (typeof val !== \"boolean\") return \"autoSerialize must be a boolean\";\n }\n return undefined;\n },\n};\n\nfunction stringArray(v: unknown): string | undefined {\n return Array.isArray(v) && v.every((x) => typeof x === \"string\")\n ? undefined\n : \"must be an array of strings\";\n}\n\n/** Validates a user config object; throws ConfigError with every problem listed. */\nexport function validateConfig(value: unknown, source: string): UserConfig {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigError(`${source}: the config must be an object`);\n }\n const problems: string[] = [];\n for (const [key, v] of Object.entries(value)) {\n const check = KEYS[key as keyof UserConfig];\n if (!check) {\n problems.push(`unknown key \"${key}\" (allowed: ${Object.keys(KEYS).join(\", \")})`);\n continue;\n }\n if (v === undefined) continue;\n const problem = check(v);\n if (problem) problems.push(`\"${key}\" ${problem}`);\n }\n if (problems.length > 0) throw new ConfigError(`${source}:\\n - ${problems.join(\"\\n - \")}`);\n return value as UserConfig;\n}\n\nexport function resolveConfig(...layers: (UserConfig | undefined)[]): ResolvedConfig {\n const out: ResolvedConfig = { ...DEFAULT_CONFIG, mongoose: { ...DEFAULT_CONFIG.mongoose } };\n for (const layer of layers) {\n if (!layer) continue;\n for (const [key, value] of Object.entries(layer)) {\n if (value === undefined) continue;\n if (key === \"mongoose\")\n out.mongoose = { ...out.mongoose, ...(value as UserConfig[\"mongoose\"]) };\n else (out as Record<string, unknown>)[key] = value;\n }\n }\n return out;\n}\n\nexport function findConfigFile(root: string): string | undefined {\n return CONFIG_FILES.map((f) => path.join(root, f)).find((f) => existsSync(f));\n}\n\nfunction readJsonConfig(file: string): unknown {\n try {\n return JSON.parse(readFileSync(file, \"utf8\"));\n } catch (error) {\n throw new ConfigError(`${path.basename(file)}: invalid JSON (${(error as Error).message})`);\n }\n}\n\n/** Loads auto-split.config.{ts,mts,mjs,js,json}. TypeScript configs are compiled with esbuild first. */\nexport async function loadConfigFile(file: string): Promise<UserConfig> {\n const rel = path.basename(file);\n let raw: unknown;\n if (file.endsWith(\".json\")) {\n raw = readJsonConfig(file);\n } else if (file.endsWith(\".ts\") || file.endsWith(\".mts\")) {\n const esbuild = await import(\"esbuild\");\n const result = await esbuild.build({\n entryPoints: [file],\n bundle: true,\n write: false,\n format: \"esm\",\n platform: \"node\",\n packages: \"external\",\n logLevel: \"silent\",\n plugins: [\n {\n name: \"auto-split-shim\",\n setup(build) {\n build.onResolve({ filter: /^auto-server-split$/ }, () => ({\n path: \"shim\",\n namespace: \"auto-split-shim\",\n }));\n build.onLoad({ filter: /.*/, namespace: \"auto-split-shim\" }, () => ({\n contents: \"export const defineConfig = (c) => c;\",\n loader: \"js\",\n }));\n },\n },\n ],\n });\n const code = result.outputFiles[0]?.text ?? \"\";\n const temp = path.join(\n path.dirname(file),\n `.auto-split.config.${process.pid}.${Date.now()}.mjs`,\n );\n writeFileSync(temp, code);\n try {\n raw = ((await import(pathToFileURL(temp).href)) as { default?: unknown }).default;\n } finally {\n rmSync(temp, { force: true });\n }\n } else {\n raw = ((await import(pathToFileURL(file).href)) as { default?: unknown }).default;\n }\n return validateConfig(raw, rel);\n}\n\n/**\n * Synchronous {@link loadConfigFile} for the ESLint rule, which can't await. Every format is\n * bundled to CommonJS with esbuild and evaluated in place; `auto-server-split` resolves to the same\n * `defineConfig` shim. The one thing it can't load is a config that uses top-level await.\n */\nexport function loadConfigFileSync(file: string): UserConfig {\n const rel = path.basename(file);\n if (file.endsWith(\".json\")) return validateConfig(readJsonConfig(file), rel);\n let code: string;\n try {\n code =\n buildSync({\n entryPoints: [file],\n bundle: true,\n write: false,\n format: \"cjs\",\n platform: \"node\",\n packages: \"external\",\n logLevel: \"silent\",\n // CommonJS has no import.meta; give the config the values a native import() would.\n define: {\n \"import.meta.url\": JSON.stringify(pathToFileURL(file).href),\n \"import.meta.dirname\": JSON.stringify(path.dirname(file)),\n \"import.meta.filename\": JSON.stringify(file),\n },\n }).outputFiles[0]?.text ?? \"\";\n } catch (error) {\n const first = (error as { errors?: { text: string }[] }).errors?.[0]?.text;\n throw new ConfigError(\n `${rel}: couldn't be loaded synchronously for ESLint (${first ?? String(error)})`,\n );\n }\n const requireFromConfig = createRequire(file);\n const module = { exports: {} as unknown };\n const evaluate = new Function(\"module\", \"exports\", \"require\", \"__filename\", \"__dirname\", code);\n evaluate(\n module,\n module.exports,\n (id: string) =>\n id === \"auto-server-split\" ? { defineConfig: (c: unknown) => c } : requireFromConfig(id),\n file,\n path.dirname(file),\n );\n const exported = module.exports as { __esModule?: boolean; default?: unknown };\n // An ES module's `export default`, or a CommonJS `module.exports` (what `import()` returns).\n return validateConfig(exported.__esModule ? exported.default : exported, rel);\n}\n","import { existsSync, mkdirSync, realpathSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { createTwoFilesPatch } from \"diff\";\nimport fg from \"fast-glob\";\nimport { ts } from \"ts-morph\";\nimport { analyzeFileShape } from \"./analysis/components.js\";\nimport type { AnalysisContext } from \"./analysis/context.js\";\nimport { locOf } from \"./analysis/context.js\";\nimport type { FrameworkAdapter } from \"./analysis/framework.js\";\nimport { buildImportTable } from \"./analysis/importTable.js\";\nimport { checkImporters } from \"./analysis/importers.js\";\nimport type { ComponentInfo } from \"./analysis/components.js\";\nimport type { ComponentPlan } from \"./analysis/islands.js\";\nimport { planComponent } from \"./analysis/islands.js\";\nimport { tagNameText } from \"./analysis/refs.js\";\nimport { ModuleSafety } from \"./analysis/moduleSafety.js\";\nimport type { Outcome, Skip } from \"./analysis/skip.js\";\nimport { ok, skip } from \"./analysis/skip.js\";\nimport { FileFacts, findEnvProblem } from \"./analysis/taint.js\";\nimport { findConfigFile, loadConfigFile, resolveConfig } from \"./config/config.js\";\nimport { couldBecomeRoute, nextAdapter, readPageExtensions } from \"./frameworks/next.js\";\nimport type { BundleMeasurer } from \"./measure/bundleSize.js\";\nimport type { LoadedProject } from \"./project/loadProject.js\";\nimport { IGNORE_GLOBS, loadProject } from \"./project/loadProject.js\";\nimport type { ModuleGraph } from \"./project/moduleGraph.js\";\nimport { buildModuleGraph } from \"./project/moduleGraph.js\";\nimport { PackageClassifier } from \"./project/packages.js\";\nimport { emitSplit } from \"./transform/emit.js\";\nimport { formatWithProjectPrettier } from \"./transform/format.js\";\nimport { hasMixedLineEndings, lineEndingOf, withLineEnding } from \"./transform/text.js\";\nimport type { FileResult, IslandInfo, ResolvedConfig, SplitOptions, SplitResult } from \"./types.js\";\nimport { selfCheck } from \"./verify/selfCheck.js\";\n\nconst STYLESHEET_RE = /\\.(css|scss|sass|less|styl|pcss)$/;\n\nexport type RunContext = {\n root: string;\n config: ResolvedConfig;\n framework: FrameworkAdapter;\n loaded: LoadedProject;\n graph: ModuleGraph;\n classifier: PackageClassifier;\n moduleSafety: ModuleSafety;\n serverSafeHooks: ReadonlySet<string>;\n pageExtensions: ReturnType<typeof readPageExtensions>;\n measurer: BundleMeasurer | undefined;\n};\n\ntype Saving = {\n bytesSaved?: { isolated: number; conservative: number };\n measureError?: string;\n};\n\ntype Planned = Saving & {\n outputs: Record<string, string>;\n islands: IslandInfo[];\n staticRatio: number;\n originalText: string;\n};\n\n/** Builds the shared state for one run: project, module graph, classifiers. Synchronous. */\nexport function createRunContext(\n root: string,\n config: ResolvedConfig,\n options: { lazy?: boolean; tsconfig?: string } = {},\n): RunContext {\n const framework = nextAdapter;\n const loaded = loadProject(root, {\n lazy: options.lazy ?? false,\n ...(options.tsconfig ? { tsconfig: options.tsconfig } : {}),\n });\n const classifier = new PackageClassifier(framework, config.clientOnlyPackages);\n const graph = buildModuleGraph(loaded, classifier);\n const serverSafeHooks = new Set(config.serverSafeHooks);\n const moduleSafety = new ModuleSafety(\n () => loaded.project.getProgram().compilerObject,\n graph,\n framework,\n serverSafeHooks,\n );\n return {\n root,\n config,\n framework,\n loaded,\n graph,\n classifier,\n moduleSafety,\n serverSafeHooks,\n pageExtensions: readPageExtensions(root),\n measurer: undefined,\n };\n}\n\nexport async function runSplit(options: SplitOptions = {}): Promise<\n SplitResult & {\n filesScanned: number;\n /** Re-runs one file with island renames (interactive mode). */\n rerun: (relFile: string, renames: Readonly<Record<string, string>>) => Promise<FileResult>;\n }\n> {\n // Real path: TypeScript resolves symlinks (e.g. macOS /var -> /private/var), so globbed paths must too.\n const root = realpathSync(path.resolve(options.root ?? process.cwd()));\n const configFile = options.noConfigFile\n ? undefined\n : options.configFile\n ? path.resolve(root, options.configFile)\n : findConfigFile(root);\n const fileConfig = configFile ? await loadConfigFile(configFile) : undefined;\n const config = resolveConfig(fileConfig, options.config);\n\n const run = createRunContext(root, config);\n if (options.measure !== false) {\n const { BundleMeasurer } = await import(\"./measure/bundleSize.js\");\n run.measurer = new BundleMeasurer(root, run.graph, run.loaded.configFile);\n }\n const { graph } = run;\n\n const targets = selectTargets(root, options.paths, config);\n const files: FileResult[] = [];\n for (const file of targets) {\n const node = graph.nodes.get(file);\n if (node?.directive !== \"use client\") continue;\n const result = await processFile(run, file);\n files.push(result);\n options.onFile?.(result);\n }\n\n if (options.write) {\n for (const result of files) {\n if (result.status !== \"split\") continue;\n for (const [rel, content] of Object.entries(result.outputs)) {\n const abs = path.join(root, rel);\n mkdirSync(path.dirname(abs), { recursive: true });\n writeFileSync(abs, content);\n }\n }\n }\n return {\n files,\n filesScanned: targets.length,\n rerun: (relFile, renames) => processFile(run, path.resolve(root, relFile), renames),\n };\n}\n\nfunction selectTargets(\n root: string,\n paths: string[] | undefined,\n config: ResolvedConfig,\n): string[] {\n const ignore = [...IGNORE_GLOBS, ...config.exclude];\n const sourceGlob = \"**/*.{tsx,jsx,ts,js,mts,mjs}\";\n let files: string[];\n if (paths && paths.length > 0) {\n files = [];\n for (const p of paths) {\n const abs = path.resolve(root, p);\n if (!existsSync(abs)) continue;\n if (/\\.(tsx|jsx|ts|js|mts|mjs)$/.test(abs) && !abs.endsWith(\".d.ts\")) files.push(abs);\n else\n files.push(\n ...fg.sync([sourceGlob], { cwd: abs, ignore: [...ignore, \"**/*.d.ts\"], absolute: true }),\n );\n }\n } else {\n files = fg.sync(\n config.include.map((g) => (g.endsWith(\"/**\") ? `${g}/*` : g)),\n { cwd: root, ignore: [...ignore, \"**/*.d.ts\"], absolute: true },\n );\n }\n return [...new Set(files.map((f) => path.resolve(f)))]\n .filter((f) => /\\.(tsx|jsx|ts|js|mts|mjs)$/.test(f))\n .sort();\n}\n\nfunction rel(root: string, file: string): string {\n return path.relative(root, file).split(path.sep).join(\"/\");\n}\n\nasync function processFile(\n run: RunContext,\n file: string,\n renames: Readonly<Record<string, string>> = {},\n): Promise<FileResult> {\n const relFile = rel(run.root, file);\n const base: FileResult = {\n file: relFile,\n status: \"skipped\",\n islands: [],\n staticRatio: 0,\n diff: \"\",\n outputs: {},\n };\n try {\n const planned = await planFile(run, file, renames);\n if (!planned.ok) return { ...base, skipped: planned.skip };\n const value = planned.value;\n const diff = Object.entries(value.outputs)\n .map(([relPath, content]) => {\n const isOriginal = relPath === relFile;\n return createTwoFilesPatch(\n isOriginal ? `a/${relPath}` : \"/dev/null\",\n `b/${relPath}`,\n isOriginal ? value.originalText : \"\",\n content,\n undefined,\n undefined,\n { context: 3 },\n );\n })\n .join(\"\");\n return {\n file: relFile,\n status: \"split\",\n islands: value.islands,\n staticRatio: value.staticRatio,\n ...(value.bytesSaved ? { bytesSaved: value.bytesSaved } : {}),\n ...(value.measureError ? { measureError: value.measureError } : {}),\n diff,\n outputs: value.outputs,\n };\n } catch (error) {\n const err = error as Error;\n return {\n ...base,\n skipped: { code: \"internal-error\", message: `${err.message}\\n${err.stack ?? \"\"}` },\n };\n }\n}\n\n/** Everything the synchronous part of the pipeline produces (used by the CLI/API and the ESLint rule). */\nexport type Analyzed = {\n file: string;\n islandFile: string;\n islandSpecifier: string;\n serverText: string;\n islandText: string;\n islands: IslandInfo[];\n staticRatio: number;\n importers: string[];\n serverActionProps: Set<string>;\n isJs: boolean;\n originalText: string;\n /** Name of the main component (the default export, else the first exported one). */\n componentName: string;\n};\n\n/** Analysis + rewrite, without formatting, self-check or measurement. Synchronous. */\nexport function analyzeFile(\n run: RunContext,\n file: string,\n renames: Readonly<Record<string, string>> = {},\n): Outcome<Analyzed> {\n const { loaded, graph, config, framework, root } = run;\n const node = graph.nodes.get(file);\n if (!node?.inProgram) {\n return skip(\n \"unsupported-pattern\",\n \"the file is not part of the TypeScript program (for .js/.jsx files, enable allowJs or add a jsconfig.json)\",\n );\n }\n const baseName = path.basename(file).replace(/\\.[^.]+$/, \"\");\n if (framework.mustStayClientFiles.includes(baseName)) {\n return skip(\n \"unsupported-pattern\",\n `Next.js requires ${path.basename(file)} to be a Client Component`,\n );\n }\n\n const program = loaded.project.getProgram().compilerObject;\n const sf = program.getSourceFile(file);\n if (!sf) return skip(\"parse-error\", \"the file could not be loaded\");\n const syntax = program.getSyntacticDiagnostics(sf)[0];\n if (syntax) {\n const lc = sf.getLineAndCharacterOfPosition(syntax.start ?? 0);\n return skip(\"parse-error\", ts.flattenDiagnosticMessageText(syntax.messageText, \" \"), {\n line: lc.line + 1,\n column: lc.character + 1,\n });\n }\n const checker = program.getTypeChecker();\n const isJs = /\\.(jsx?|mjs|cjs)$/.test(file);\n const ctx: AnalysisContext = {\n program,\n checker,\n sf,\n file,\n graph,\n config,\n framework,\n isJs,\n moduleSafety: run.moduleSafety,\n };\n\n // ---- output location ------------------------------------------------------------------------\n const ext = path.extname(file);\n const dir = config.islandsDir\n ? path.join(path.dirname(file), config.islandsDir)\n : path.dirname(file);\n const islandFile = path.join(dir, `${path.basename(file, ext)}${config.clientFileSuffix}${ext}`);\n if (existsSync(islandFile) || loaded.project.getSourceFile(islandFile)) {\n return skip(\n \"output-exists\",\n `${rel(root, islandFile)} already exists; existing files are never merged into`,\n );\n }\n if (!run.pageExtensions.ok) return skip(\"would-create-route\", run.pageExtensions.reason);\n if (couldBecomeRoute(root, islandFile, run.pageExtensions.extensions)) {\n return skip(\n \"would-create-route\",\n `${rel(root, islandFile)} could be picked up as a Next.js route`,\n );\n }\n\n // ---- whole-file checks ----------------------------------------------------------------------\n const imports = buildImportTable(sf, checker, graph);\n const facts = new FileFacts(\n sf,\n checker,\n imports,\n framework,\n run.moduleSafety.check,\n run.serverSafeHooks,\n );\n for (const decl of imports.sideEffectImports) {\n const spec = (decl.moduleSpecifier as ts.StringLiteral).text;\n if (!STYLESHEET_RE.test(spec)) {\n return skip(\n \"unsupported-pattern\",\n `has a side-effect import of ${spec}, which would then run on the server only`,\n locOf(ctx, decl),\n );\n }\n }\n const fileSkip = specialApiSkip(ctx, facts);\n if (fileSkip) return { ok: false, skip: fileSkip };\n const env = findEnvProblem(sf, checker, framework);\n if (env) return skip(\"server-env-difference\", env.message, locOf(ctx, env.node));\n\n const shape = analyzeFileShape(ctx, facts);\n if (!shape.ok) return shape;\n const components = shape.value.components;\n const importerCheck = checkImporters(program, graph, file, components);\n if (!importerCheck.ok) return importerCheck;\n\n // Plan every component. A non-exported helper component that is entirely interactive moves\n // wholesale into the island file; other components may then render it as a client reference,\n // so planning repeats until the set of moved components is stable.\n const wholesale = new Set<ComponentInfo>();\n let plans: ComponentPlan[] = [];\n let unchanged: ComponentInfo[] = [];\n for (let pass = 0; pass <= components.length; pass++) {\n plans = [];\n unchanged = [];\n let grew = false;\n for (const component of components) {\n if (wholesale.has(component)) continue;\n const plan = planComponent(ctx, facts, shape.value, component, {\n serverActionProps: importerCheck.value.serverActionProps,\n wholesale,\n });\n if (plan.ok) {\n plans.push(plan.value);\n continue;\n }\n const code = plan.skip.code;\n if (code === \"no-islands\") {\n unchanged.push(component);\n continue;\n }\n const movable =\n (code === \"fully-interactive\" || code === \"state-spans-component\") &&\n component.exported === \"none\" &&\n components.length > 1;\n if (movable) {\n wholesale.add(component);\n grew = true;\n continue;\n }\n const prefix = components.length > 1 ? `${component.name}: ` : \"\";\n return { ok: false, skip: { ...plan.skip, message: `${prefix}${plan.skip.message}` } };\n }\n if (!grew) break;\n }\n if (plans.length === 0 && wholesale.size === 0) {\n return skip(\n \"no-islands\",\n `${components.map((c) => c.name).join(\", \")} ${components.length === 1 ? \"uses\" : \"use\"} no client-only features; removing \"use client\" may be enough (the tool never removes it automatically)`,\n );\n }\n if (components.every((c) => wholesale.has(c) || c.exported === \"none\") && plans.length === 0) {\n return skip(\n \"fully-interactive\",\n \"every component in the file is interactive; nothing would stay on the server\",\n );\n }\n\n const jsxCounts = (c: ComponentInfo) => countJsx(c.fn);\n const jsxTotal =\n plans.reduce((n, p) => n + p.jsxTotal, 0) +\n [...wholesale].reduce((n, c) => n + jsxCounts(c), 0) +\n unchanged.reduce((n, c) => n + jsxCounts(c), 0);\n const staticJsx =\n plans.reduce((n, p) => n + p.staticRatio * p.jsxTotal, 0) +\n unchanged.reduce((n, c) => n + jsxCounts(c), 0);\n const staticRatio = jsxTotal === 0 ? 0 : staticJsx / jsxTotal;\n if (staticRatio < config.minStaticRatio) {\n return skip(\n \"below-threshold\",\n `only ${Math.round(staticRatio * 100)}% of the JSX would stay on the server (minStaticRatio is ${Math.round(config.minStaticRatio * 100)}%)`,\n );\n }\n\n // ---- emit -------------------------------------------------------------------------------------\n const islandSpecifier = relativeSpecifier(path.dirname(file), islandFile);\n const originalSpecifier = relativeSpecifier(dir, file);\n const emitted = emitSplit({\n renames,\n ctx,\n shape: shape.value,\n imports,\n plans,\n islandSpecifier,\n originalSpecifier,\n movedComponents: [...wholesale].flatMap((c) => {\n const decl = shape.value.componentDecls.get(c);\n return decl ? [decl] : [];\n }),\n rebaseSpecifier: (spec) =>\n spec.startsWith(\".\") && dir !== path.dirname(file)\n ? relativeSpecifier(dir, path.resolve(path.dirname(file), spec), true)\n : spec,\n });\n if (!emitted.ok) return emitted;\n // Generated and inserted lines use the original file's line ending. A file that already mixes\n // CRLF and LF keeps its existing lines byte for byte.\n const eol = lineEndingOf(sf.text);\n const serverText = hasMixedLineEndings(sf.text)\n ? emitted.value.serverText\n : withLineEnding(emitted.value.serverText, eol);\n const islandText = withLineEnding(emitted.value.islandText, eol);\n\n const movedInfo: IslandInfo[] = [...wholesale].map((c) => ({\n name: c.name,\n rootTag: rootTagOf(c, sf),\n props: [],\n line: sf.getLineAndCharacterOfPosition(c.statement.getStart(sf)).line + 1,\n moved: true,\n }));\n const islands: IslandInfo[] = [\n ...emitted.value.islands.map((i) => ({\n name: i.name,\n rootTag: i.rootTag,\n props: [...i.props.map((p) => p.name), ...i.slots.map((slot) => slot.name)],\n line: i.line,\n })),\n ...movedInfo,\n ].sort((a, b) => a.line - b.line);\n const main =\n components.find((c) => c.exported === \"default\") ??\n components.find((c) => c.exported !== \"none\") ??\n components[0];\n\n return ok({\n file,\n islandFile,\n islandSpecifier,\n serverText,\n islandText,\n islands,\n staticRatio,\n importers: importerCheck.value.importers,\n serverActionProps: importerCheck.value.serverActionProps,\n isJs,\n originalText: sf.text,\n componentName: main?.name ?? path.basename(file, ext),\n });\n}\n\n/** Runs the self-check on an analysed file's output. Synchronous. */\nexport function checkAnalyzed(\n run: RunContext,\n analyzed: Analyzed,\n serverText = analyzed.serverText,\n islandText = analyzed.islandText,\n): Outcome<void> {\n return selfCheck({\n loaded: run.loaded,\n graph: run.graph,\n framework: run.framework,\n classifier: run.classifier,\n moduleSafety: run.moduleSafety,\n serverSafeHooks: run.serverSafeHooks,\n file: analyzed.file,\n islandFile: analyzed.islandFile,\n islandSpecifier: analyzed.islandSpecifier,\n serverText,\n islandText,\n importers: analyzed.importers,\n serverActionProps: analyzed.serverActionProps,\n isJs: analyzed.isJs,\n });\n}\n\nasync function planFile(\n run: RunContext,\n file: string,\n renames: Readonly<Record<string, string>>,\n): Promise<Outcome<Planned>> {\n const { config, root } = run;\n const analyzed = analyzeFile(run, file, renames);\n if (!analyzed.ok) return analyzed;\n const a = analyzed.value;\n let serverText = a.serverText;\n let islandText = a.islandText;\n if (config.prettier === \"auto\") {\n serverText = await formatWithProjectPrettier(root, file, serverText);\n islandText = await formatWithProjectPrettier(root, a.islandFile, islandText);\n }\n\n const checked = checkAnalyzed(run, a, serverText, islandText);\n if (!checked.ok) return checked;\n const saving = measureAnalyzed(run, a, islandText);\n if (!saving.ok) return saving;\n\n return ok({\n outputs: { [rel(root, file)]: serverText, [rel(root, a.islandFile)]: islandText },\n islands: a.islands,\n staticRatio: a.staticRatio,\n ...saving.value,\n originalText: a.originalText,\n });\n}\n\n/**\n * Measures the saving (when the run has a measurer) and applies `minBytesSaved`. A saving that\n * can't be measured can't be shown to meet a non-zero threshold, so it skips. Synchronous.\n */\nexport function measureAnalyzed(\n run: RunContext,\n analyzed: Analyzed,\n islandText = analyzed.islandText,\n): Outcome<Saving> {\n const { measurer, config } = run;\n if (!measurer) return ok({});\n const measured = measurer.measure(\n analyzed.file,\n analyzed.originalText,\n analyzed.islandFile,\n islandText,\n );\n const threshold = formatBytes(config.minBytesSaved);\n if (\"error\" in measured) {\n if (config.minBytesSaved === 0) return ok({ measureError: measured.error });\n return skip(\n \"measure-failed\",\n `the saving couldn't be measured (${measured.error}), so minBytesSaved (${threshold}) can't be checked; set minBytesSaved to 0 or pass --no-measure to split without an estimate`,\n );\n }\n const { bytesSaved } = measured;\n if (bytesSaved.conservative < config.minBytesSaved) {\n return skip(\n \"below-threshold\",\n `saves an estimated ${formatBytes(bytesSaved.conservative)} gzip (minBytesSaved is ${threshold})`,\n );\n }\n return ok({ bytesSaved });\n}\n\nfunction specialApiSkip(ctx: AnalysisContext, facts: FileFacts): Skip | undefined {\n for (const marker of facts.scanMarkers(ctx.sf)) {\n const loc = locOf(ctx, marker.node);\n switch (marker.special) {\n case \"css-in-js\":\n return {\n code: \"css-in-js-runtime\",\n message: `uses ${marker.detail}; runtime CSS-in-JS is always skipped`,\n location: loc,\n };\n case \"context\":\n return {\n code: \"context-provider\",\n message: \"creates a React Context (createContext)\",\n location: loc,\n };\n case \"class\":\n return {\n code: \"class-component\",\n message: \"uses React.Component / PureComponent\",\n location: loc,\n };\n case \"hoc\":\n return {\n code: \"hoc\",\n message: `uses ${marker.detail}, which this version doesn't split`,\n location: loc,\n };\n case \"lazy\":\n case \"dynamic\":\n return {\n code: \"dynamic-import\",\n message: `uses ${marker.detail}, which this version doesn't split`,\n location: loc,\n };\n default:\n break;\n }\n }\n let dynamicImport: ts.Node | undefined;\n const visit = (n: ts.Node): void => {\n if (dynamicImport) return;\n if (ts.isCallExpression(n) && n.expression.kind === ts.SyntaxKind.ImportKeyword)\n dynamicImport = n;\n ts.forEachChild(n, visit);\n };\n visit(ctx.sf);\n if (dynamicImport)\n return {\n code: \"dynamic-import\",\n message: \"uses import(), which this version doesn't split\",\n location: locOf(ctx, dynamicImport),\n };\n return undefined;\n}\n\n/** The tag of the element a component returns (used to describe components moved wholesale). */\nfunction rootTagOf(component: ComponentInfo, sf: ts.SourceFile): string {\n let tag = component.name;\n const visit = (n: ts.Node): boolean => {\n if (ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n)) {\n tag = tagNameText(sf, n);\n return true;\n }\n return ts.forEachChild(n, visit) ?? false;\n };\n if (component.fn.body) visit(component.fn.body);\n return tag;\n}\n\nfunction countJsx(node: ts.Node): number {\n let n = 0;\n const visit = (child: ts.Node): void => {\n if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child)) n++;\n ts.forEachChild(child, visit);\n };\n visit(node);\n return n;\n}\n\nfunction relativeSpecifier(fromDir: string, toFile: string, keepExtension = false): string {\n let target = path.relative(fromDir, toFile).split(path.sep).join(\"/\");\n if (!keepExtension) target = target.replace(/\\.(tsx|ts|jsx|js|mts|mjs)$/, \"\");\n return target.startsWith(\".\") ? target : `./${target}`;\n}\n\nexport function formatBytes(bytes: number): string {\n return bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${bytes} B`;\n}\n","import { ts } from \"ts-morph\";\nimport type { AnalysisContext } from \"./context.js\";\nimport { locOf } from \"./context.js\";\nimport { isJsxElementLike } from \"./refs.js\";\nimport type { Outcome } from \"./skip.js\";\nimport { ok, skip } from \"./skip.js\";\nimport type { FileFacts } from \"./taint.js\";\n\nexport type ComponentFunction = ts.FunctionDeclaration | ts.ArrowFunction | ts.FunctionExpression;\n\nexport type ComponentInfo = {\n name: string;\n fn: ComponentFunction;\n /** The module-level statement that declares the component. */\n statement: ts.Statement;\n exported: \"default\" | \"named\" | \"none\";\n};\n\n/** A module-level declaration other than imports and components (helpers, constants, types). */\nexport type ModuleDecl = {\n statement: ts.Statement;\n names: string[];\n kind: \"function\" | \"const\" | \"type\" | \"class\" | \"enum\";\n exported: boolean;\n /** Set when this declaration is a component of the file (used to copy/move whole components). */\n component?: ComponentInfo;\n};\n\nexport type FileShape = {\n components: ComponentInfo[];\n moduleDecls: ModuleDecl[];\n /** A ModuleDecl view of every component, so components can be copied like helpers. */\n componentDecls: Map<ComponentInfo, ModuleDecl>;\n};\n\n/** The node a component's symbol is declared on (function declaration or variable declarator). */\nexport function componentDeclarationNode(component: ComponentInfo): ts.Node {\n return ts.isFunctionDeclaration(component.fn) ? component.fn : component.fn.parent;\n}\n\nfunction isCapitalized(name: string): boolean {\n return /^[A-Z]/.test(name);\n}\n\nfunction hasExportModifier(node: ts.Node): boolean {\n return (\n ts.canHaveModifiers(node) &&\n (ts.getModifiers(node)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false)\n );\n}\n\nfunction hasDefaultModifier(node: ts.Node): boolean {\n return (\n ts.canHaveModifiers(node) &&\n (ts.getModifiers(node)?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword) ?? false)\n );\n}\n\n/** True if the function returns JSX (directly, not from a nested function). */\nfunction returnsJsx(fn: ComponentFunction): boolean {\n if (!fn.body) return false;\n if (!ts.isBlock(fn.body)) return containsJsx(fn.body);\n let found = false;\n const visit = (n: ts.Node): void => {\n if (found) return;\n if (ts.isFunctionLike(n) && n !== fn) return;\n if (ts.isReturnStatement(n) && n.expression && containsJsx(n.expression)) found = true;\n ts.forEachChild(n, visit);\n };\n visit(fn.body);\n return found;\n}\n\nfunction containsJsx(node: ts.Node): boolean {\n if (isJsxElementLike(node)) return true;\n return ts.forEachChild(node, (c) => (containsJsx(c) ? true : undefined)) ?? false;\n}\n\nfunction hocCallName(expr: ts.Expression, sf: ts.SourceFile): string | undefined {\n if (ts.isCallExpression(expr)) return expr.expression.getText(sf);\n return undefined;\n}\n\n/**\n * Splits the module into components and other declarations, enforcing the candidate rules:\n * only components and types are exported, and nothing runs at module level that would\n * behave differently on the server.\n */\nexport function analyzeFileShape(ctx: AnalysisContext, facts: FileFacts): Outcome<FileShape> {\n const { sf } = ctx;\n const components: ComponentInfo[] = [];\n const moduleDecls: ModuleDecl[] = [];\n const exportedNames = new Map<string, ts.Node>();\n let defaultExportName: string | undefined;\n\n for (const statement of sf.statements) {\n if (ts.isImportDeclaration(statement)) continue;\n if (ts.isExpressionStatement(statement) && ts.isStringLiteral(statement.expression)) continue; // directives\n\n if (ts.isTypeAliasDeclaration(statement) || ts.isInterfaceDeclaration(statement)) {\n moduleDecls.push({\n statement,\n names: [statement.name.text],\n kind: \"type\",\n exported: hasExportModifier(statement),\n });\n continue;\n }\n\n if (ts.isFunctionDeclaration(statement)) {\n const name = statement.name?.text ?? (hasDefaultModifier(statement) ? \"default\" : \"\");\n const exported = hasExportModifier(statement);\n if ((isCapitalized(name) || name === \"default\") && returnsJsx(statement)) {\n if (\n statement.asteriskToken ||\n statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)\n ) {\n return skip(\n \"unsupported-pattern\",\n `${name} is an async or generator function`,\n locOf(ctx, statement),\n );\n }\n components.push({\n name: name === \"default\" ? \"Component\" : name,\n fn: statement,\n statement,\n exported: exported ? (hasDefaultModifier(statement) ? \"default\" : \"named\") : \"none\",\n });\n } else {\n if (exported) {\n const why = isCapitalized(name)\n ? \"doesn't return JSX, so it isn't treated as a component\"\n : \"is not a component\";\n return skip(\n \"exports-non-components\",\n `exports ${name || \"a function\"}, which ${why}`,\n locOf(ctx, statement),\n );\n }\n moduleDecls.push({\n statement,\n names: name ? [name] : [],\n kind: \"function\",\n exported: false,\n });\n }\n continue;\n }\n\n if (ts.isVariableStatement(statement)) {\n const exported = hasExportModifier(statement);\n const isConst = (statement.declarationList.flags & ts.NodeFlags.Const) !== 0;\n let isComponentStatement = false;\n for (const decl of statement.declarationList.declarations) {\n const name = ts.isIdentifier(decl.name) ? decl.name.text : undefined;\n const init = decl.initializer;\n const fn =\n init && (ts.isArrowFunction(init) || ts.isFunctionExpression(init)) ? init : undefined;\n if (name && isCapitalized(name) && fn && returnsJsx(fn)) {\n if (statement.declarationList.declarations.length > 1) {\n return skip(\n \"unsupported-pattern\",\n `${name} is declared together with other variables`,\n locOf(ctx, decl),\n );\n }\n if (fn.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) {\n return skip(\"unsupported-pattern\", `${name} is an async function`, locOf(ctx, decl));\n }\n components.push({ name, fn, statement, exported: exported ? \"named\" : \"none\" });\n isComponentStatement = true;\n continue;\n }\n if (name && init && isCapitalized(name)) {\n const hoc = hocCallName(init, sf);\n if (hoc && /(^|\\.)(memo|forwardRef)$/.test(hoc)) {\n return skip(\n \"hoc\",\n `${name} is wrapped in ${hoc}(), which this version doesn't split`,\n locOf(ctx, decl),\n );\n }\n }\n if (exported) {\n return skip(\n \"exports-non-components\",\n `exports ${name ?? \"a value\"}, which is not a component`,\n locOf(ctx, decl),\n );\n }\n }\n if (isComponentStatement) continue; // a `const X = () => <jsx />` component, not a module value\n if (!isConst) {\n return skip(\n \"unsupported-pattern\",\n \"declares module-level `let`/`var` state, which would be shared across requests on the server\",\n locOf(ctx, statement),\n );\n }\n const names = statement.declarationList.declarations.flatMap((d) =>\n ts.isIdentifier(d.name) ? [d.name.text] : [],\n );\n if (statement.declarationList.declarations.some((d) => !ts.isIdentifier(d.name))) {\n return skip(\n \"unsupported-pattern\",\n \"uses a destructuring declaration at module level\",\n locOf(ctx, statement),\n );\n }\n moduleDecls.push({ statement, names, kind: \"const\", exported: false });\n continue;\n }\n\n if (ts.isClassDeclaration(statement)) {\n const extendsComponent = statement.heritageClauses?.some((h) =>\n h.types.some((t) => /(^|\\.)(Component|PureComponent)$/.test(t.expression.getText(sf))),\n );\n if (extendsComponent)\n return skip(\n \"class-component\",\n `${statement.name?.text ?? \"a class\"} is a class component`,\n locOf(ctx, statement),\n );\n if (hasExportModifier(statement)) {\n return skip(\n \"exports-non-components\",\n `exports the class ${statement.name?.text ?? \"\"}`.trim(),\n locOf(ctx, statement),\n );\n }\n moduleDecls.push({\n statement,\n names: statement.name ? [statement.name.text] : [],\n kind: \"class\",\n exported: false,\n });\n continue;\n }\n\n if (ts.isEnumDeclaration(statement)) {\n if (hasExportModifier(statement)) {\n return skip(\n \"exports-non-components\",\n `exports the enum ${statement.name.text}`,\n locOf(ctx, statement),\n );\n }\n moduleDecls.push({ statement, names: [statement.name.text], kind: \"enum\", exported: false });\n continue;\n }\n\n if (ts.isExportAssignment(statement)) {\n const expr = statement.expression;\n if (ts.isIdentifier(expr)) {\n defaultExportName = expr.text;\n exportedNames.set(expr.text, statement);\n continue;\n }\n const hoc = hocCallName(expr, sf);\n if (hoc)\n return skip(\n \"hoc\",\n `the default export is wrapped in ${hoc}(), which this version doesn't split`,\n locOf(ctx, statement),\n );\n return skip(\n \"exports-non-components\",\n \"the default export is not a component\",\n locOf(ctx, statement),\n );\n }\n\n if (ts.isExportDeclaration(statement)) {\n if (statement.moduleSpecifier) {\n if (statement.isTypeOnly) continue;\n return skip(\n \"exports-non-components\",\n \"re-exports another module; its exports can't be verified\",\n locOf(ctx, statement),\n );\n }\n const clause = statement.exportClause;\n if (clause && ts.isNamedExports(clause)) {\n for (const element of clause.elements) {\n if (statement.isTypeOnly || element.isTypeOnly) continue;\n const local = (element.propertyName ?? element.name).text;\n exportedNames.set(local, element);\n if (element.name.text === \"default\") defaultExportName = local;\n }\n }\n continue;\n }\n\n return skip(\n \"unsupported-pattern\",\n \"has a module-level statement that runs on import\",\n locOf(ctx, statement),\n );\n }\n\n // Names exported through `export { X }` / `export default X` must be components or types.\n for (const [name, node] of exportedNames) {\n const component = components.find((c) => c.name === name);\n if (component) {\n if (component.exported === \"none\")\n component.exported = name === defaultExportName ? \"default\" : \"named\";\n continue;\n }\n const decl = moduleDecls.find((d) => d.names.includes(name));\n if (decl?.kind === \"type\") continue;\n return skip(\n \"exports-non-components\",\n `exports ${name}, which is not a component`,\n locOf(ctx, node),\n );\n }\n\n // Module-level code (outside functions) must not touch browser APIs or call hooks.\n for (const decl of moduleDecls) {\n if (decl.kind !== \"const\" && decl.kind !== \"class\") continue;\n const markers = facts.scanMarkers(\n decl.statement,\n (n) => ts.isFunctionLike(n) || ts.isClassLike(n),\n );\n const browser = markers.find(\n (m) => m.kind === \"browser-global\" || m.kind === \"hook\" || m.kind === \"nondeterministic\",\n );\n if (browser) {\n return skip(\n \"unsupported-pattern\",\n `module-level code uses ${browser.detail}; it would run on the server after the split`,\n locOf(ctx, browser.node),\n );\n }\n }\n\n if (components.length === 0) {\n return skip(\"unsupported-pattern\", \"no function component found in this file\", undefined);\n }\n const componentDecls = new Map<ComponentInfo, ModuleDecl>();\n for (const component of components) {\n componentDecls.set(component, {\n statement: component.statement,\n names: [component.name],\n kind: \"function\",\n exported: component.exported !== \"none\",\n component,\n });\n }\n return ok({ components, moduleDecls, componentDecls });\n}\n","import type { ts } from \"ts-morph\";\nimport type { ModuleGraph } from \"../project/moduleGraph.js\";\nimport type { ResolvedConfig } from \"../types.js\";\nimport type { FrameworkAdapter } from \"./framework.js\";\nimport type { ModuleSafety } from \"./moduleSafety.js\";\n\n/** Everything the pure analysis needs. Built once per file by the orchestrator; no I/O happens below this. */\nexport type AnalysisContext = {\n program: ts.Program;\n checker: ts.TypeChecker;\n sf: ts.SourceFile;\n /** Absolute path of the file being analysed. */\n file: string;\n graph: ModuleGraph;\n config: ResolvedConfig;\n framework: FrameworkAdapter;\n /** True for .js/.jsx files: types are inferred, so the boundary rules are stricter. */\n isJs: boolean;\n moduleSafety: ModuleSafety;\n};\n\nexport function lineCol(sf: ts.SourceFile, pos: number): { line: number; column: number } {\n const lc = sf.getLineAndCharacterOfPosition(pos);\n return { line: lc.line + 1, column: lc.character + 1 };\n}\n\nexport function locOf(ctx: { sf: ts.SourceFile }, node: ts.Node): { line: number; column: number } {\n return lineCol(ctx.sf, node.getStart(ctx.sf));\n}\n","import { ts } from \"ts-morph\";\n\nexport function isJsxElementLike(\n node: ts.Node,\n): node is ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment {\n return ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node);\n}\n\nexport function isIntrinsicTagName(name: ts.JsxTagNameExpression): boolean {\n if (ts.isIdentifier(name)) return /^[a-z]/.test(name.text) || name.text.includes(\"-\");\n return ts.isJsxNamespacedName(name);\n}\n\nexport function tagNameText(\n sf: ts.SourceFile,\n node: ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment,\n): string {\n if (ts.isJsxFragment(node)) return \"Fragment\";\n const tag = ts.isJsxElement(node) ? node.openingElement.tagName : node.tagName;\n return tag.getText(sf);\n}\n\n/**\n * True if `id` is used as a value reference (not a declaration name, property name, attribute\n * name, intrinsic tag, closing tag or import/export specifier). Type positions are excluded by the\n * walkers, which never descend into type nodes.\n */\nfunction isValueReference(id: ts.Identifier): boolean {\n const parent = id.parent;\n if (!parent) return false;\n if (ts.isPropertyAccessExpression(parent) && parent.name === id) return false;\n if (ts.isQualifiedName(parent) && parent.right === id) return false;\n if (\n (ts.isPropertyAssignment(parent) ||\n ts.isPropertyDeclaration(parent) ||\n ts.isMethodDeclaration(parent) ||\n ts.isGetAccessorDeclaration(parent) ||\n ts.isSetAccessorDeclaration(parent) ||\n ts.isPropertySignature(parent) ||\n ts.isMethodSignature(parent) ||\n ts.isEnumMember(parent)) &&\n parent.name === id\n ) {\n return false;\n }\n if (ts.isBindingElement(parent) && (parent.propertyName === id || parent.name === id))\n return false;\n if (\n (ts.isVariableDeclaration(parent) ||\n ts.isParameter(parent) ||\n ts.isFunctionDeclaration(parent) ||\n ts.isFunctionExpression(parent) ||\n ts.isClassDeclaration(parent) ||\n ts.isClassExpression(parent) ||\n ts.isEnumDeclaration(parent) ||\n ts.isTypeAliasDeclaration(parent) ||\n ts.isInterfaceDeclaration(parent) ||\n ts.isTypeParameterDeclaration(parent)) &&\n parent.name === id\n ) {\n return false;\n }\n if (ts.isJsxAttribute(parent) && parent.name === id) return false;\n if (ts.isJsxClosingElement(parent)) return false;\n if (\n (ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) &&\n parent.tagName === id\n ) {\n return !isIntrinsicTagName(id);\n }\n if (\n ts.isImportSpecifier(parent) ||\n ts.isImportClause(parent) ||\n ts.isNamespaceImport(parent) ||\n ts.isExportSpecifier(parent) ||\n ts.isImportEqualsDeclaration(parent)\n ) {\n return false;\n }\n if (\n (ts.isLabeledStatement(parent) ||\n ts.isBreakStatement(parent) ||\n ts.isContinueStatement(parent)) &&\n parent.label === id\n ) {\n return false;\n }\n if (ts.isMetaProperty(parent) || ts.isJsxNamespacedName(parent)) return false;\n return true;\n}\n\n/** Skips type-only syntax (type annotations, type arguments, `satisfies`/`as` types...). */\nfunction isTypeSyntax(node: ts.Node): boolean {\n return ts.isTypeNode(node) && !ts.isExpressionWithTypeArguments(node);\n}\n\n/**\n * Calls `cb` for every value-reference identifier under `node`. `stop` can prune subtrees\n * (used to treat nested JSX elements as separate units).\n */\nexport function forEachValueRef(\n node: ts.Node,\n cb: (id: ts.Identifier) => void,\n stop?: (n: ts.Node) => boolean,\n): void {\n const visit = (n: ts.Node): void => {\n if (n !== node && stop?.(n)) return;\n if (isTypeSyntax(n)) return;\n if (ts.isTypeAliasDeclaration(n) || ts.isInterfaceDeclaration(n)) return;\n if (ts.isIdentifier(n)) {\n if (isValueReference(n)) cb(n);\n return;\n }\n if (ts.isJsxElement(n)) {\n // Closing tags repeat the opening tag; visit opening + children only.\n visit(n.openingElement);\n n.children.forEach(visit);\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n}\n\n/** Every identifier under `node`, including those in type positions (used for import pruning). */\nexport function forEachIdentifier(node: ts.Node, cb: (id: ts.Identifier) => void): void {\n const visit = (n: ts.Node): void => {\n if (ts.isIdentifier(n)) cb(n);\n ts.forEachChild(n, visit);\n };\n visit(node);\n}\n\nexport function symbolOfRef(checker: ts.TypeChecker, id: ts.Identifier): ts.Symbol | undefined {\n if (ts.isShorthandPropertyAssignment(id.parent) && id.parent.name === id) {\n return checker.getShorthandAssignmentValueSymbol(id.parent);\n }\n return checker.getSymbolAtLocation(id);\n}\n\n/** Names declared by a binding name (identifier or destructuring pattern). */\nexport function bindingIdentifiers(name: ts.BindingName): ts.Identifier[] {\n if (ts.isIdentifier(name)) return [name];\n const out: ts.Identifier[] = [];\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) continue;\n out.push(...bindingIdentifiers(element.name));\n }\n return out;\n}\n\nexport function containsRange(\n outer: { pos: number; end: number },\n inner: { pos: number; end: number },\n): boolean {\n return inner.pos >= outer.pos && inner.end <= outer.end;\n}\n\n/** The `.map(cb)` call whose first argument is `fn`, if any. */\nexport function mapCallOf(fn: ts.Node): ts.CallExpression | undefined {\n const parent = fn.parent;\n if (\n parent &&\n ts.isCallExpression(parent) &&\n parent.arguments[0] === fn &&\n ts.isPropertyAccessExpression(parent.expression) &&\n parent.expression.name.text === \"map\"\n ) {\n return parent;\n }\n return undefined;\n}\n\nexport function stripParens(expr: ts.Expression): ts.Expression {\n let e = expr;\n while (ts.isParenthesizedExpression(e)) e = e.expression;\n return e;\n}\n\nexport const HOOK_NAME_RE = /^use[A-Z]/;\n\n/** The called name for `foo()` / `React.foo()` / `a.b.foo()`. */\nexport function calleeName(call: ts.CallExpression): string | undefined {\n const callee = call.expression;\n if (ts.isIdentifier(callee)) return callee.text;\n if (ts.isPropertyAccessExpression(callee)) return callee.name.text;\n return undefined;\n}\n","import path from \"node:path\";\nimport { ts } from \"ts-morph\";\nimport type { ModuleGraph } from \"../project/moduleGraph.js\";\nimport type { ExternalModuleInfo } from \"../project/moduleTypes.js\";\nimport type { Directive } from \"./directives.js\";\nimport type { BindingClass, FrameworkAdapter } from \"./framework.js\";\n\nexport type ImportedModule =\n | { kind: \"project\"; file: string; directive: Directive | undefined }\n | { kind: \"external\"; info: ExternalModuleInfo };\n\nexport type ImportBinding = {\n local: string;\n /** \"default\", \"*\" (namespace) or the exported name. */\n imported: string;\n symbol: ts.Symbol;\n declaration: ts.ImportDeclaration;\n node: ts.ImportSpecifier | ts.ImportClause | ts.NamespaceImport;\n typeOnly: boolean;\n module: ImportedModule;\n specifier: string;\n};\n\nexport type ImportTable = {\n bindings: ImportBinding[];\n bySymbol: Map<ts.Symbol, ImportBinding>;\n declarations: ts.ImportDeclaration[];\n sideEffectImports: ts.ImportDeclaration[];\n};\n\n/** Special React/framework APIs that decide a whole-file skip rather than a client/server split. */\nexport type SpecialApi = \"context\" | \"class\" | \"hoc\" | \"lazy\" | \"dynamic\" | \"css-in-js\";\n\nexport type UsageClass = { cls: BindingClass; special?: SpecialApi; reason: string };\n\nconst REACT_NEUTRAL = new Set([\n \"default\",\n \"*\",\n \"Fragment\",\n \"Suspense\",\n \"StrictMode\",\n \"Profiler\",\n \"Children\",\n \"cloneElement\",\n \"isValidElement\",\n \"createElement\",\n \"cache\",\n \"version\",\n]);\nconst REACT_SPECIAL: Record<string, SpecialApi> = {\n createContext: \"context\",\n Component: \"class\",\n PureComponent: \"class\",\n memo: \"hoc\",\n forwardRef: \"hoc\",\n lazy: \"lazy\",\n};\nconst REACT_DOM_NEUTRAL = new Set([\n \"preload\",\n \"preinit\",\n \"preconnect\",\n \"prefetchDNS\",\n \"preloadModule\",\n \"preinitModule\",\n]);\n\nexport function buildImportTable(\n sf: ts.SourceFile,\n checker: ts.TypeChecker,\n graph: ModuleGraph,\n): ImportTable {\n const file = path.resolve(sf.fileName);\n const table: ImportTable = {\n bindings: [],\n bySymbol: new Map(),\n declarations: [],\n sideEffectImports: [],\n };\n for (const statement of sf.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))\n continue;\n table.declarations.push(statement);\n const specifier = statement.moduleSpecifier.text;\n const clause = statement.importClause;\n if (!clause) {\n table.sideEffectImports.push(statement);\n continue;\n }\n const edge = graph.edgeFor(file, specifier);\n const module: ImportedModule = edge?.to\n ? { kind: \"project\", file: edge.to, directive: graph.nodes.get(edge.to)?.directive }\n : {\n kind: \"external\",\n info: edge?.external ?? {\n specifier,\n packageName: specifier,\n kind: \"unresolved\",\n detail: \"not in module graph\",\n },\n };\n const add = (\n node: ImportBinding[\"node\"],\n nameNode: ts.Identifier,\n imported: string,\n typeOnly: boolean,\n ) => {\n const symbol = checker.getSymbolAtLocation(nameNode);\n if (!symbol) return;\n const binding: ImportBinding = {\n local: nameNode.text,\n imported,\n symbol,\n declaration: statement,\n node,\n typeOnly: typeOnly || clause.isTypeOnly,\n module,\n specifier,\n };\n table.bindings.push(binding);\n table.bySymbol.set(symbol, binding);\n };\n if (clause.name) add(clause, clause.name, \"default\", false);\n const bindings = clause.namedBindings;\n if (bindings && ts.isNamespaceImport(bindings)) add(bindings, bindings.name, \"*\", false);\n if (bindings && ts.isNamedImports(bindings)) {\n for (const element of bindings.elements) {\n add(element, element.name, (element.propertyName ?? element.name).text, element.isTypeOnly);\n }\n }\n }\n return table;\n}\n\nexport type ProjectModuleSafety = (file: string) => { safe: boolean; reason?: string };\n\n/**\n * How using `binding` (optionally `binding.member`) behaves in code that will run as a Server\n * Component. `asJsxTag` is true when the binding is rendered as `<Binding />`.\n */\nexport function classifyImportUsage(\n binding: ImportBinding,\n member: string | undefined,\n asJsxTag: boolean,\n framework: FrameworkAdapter,\n projectSafety: ProjectModuleSafety,\n): UsageClass {\n const name =\n binding.imported === \"default\" || binding.imported === \"*\"\n ? (member ?? binding.imported)\n : binding.imported;\n const from = binding.specifier;\n const mod = binding.module;\n\n if (mod.kind === \"project\") {\n if (mod.directive === \"use client\") {\n return asJsxTag\n ? { cls: \"client-reference\", reason: `${binding.local} is a Client Component from ${from}` }\n : {\n cls: \"client-only\",\n reason: `${binding.local} comes from the \"use client\" module ${from}`,\n };\n }\n if (mod.directive === \"use server\")\n return { cls: \"server-action\", reason: `${binding.local} is a Server Action` };\n const safety = projectSafety(mod.file);\n return safety.safe\n ? { cls: \"neutral\", reason: `${from} is server-safe` }\n : {\n cls: \"client-only\",\n reason: `${binding.local} from ${from} is client-only (${safety.reason ?? \"uses client APIs\"})`,\n };\n }\n\n const info = mod.info;\n switch (info.kind) {\n case \"react\": {\n const special = REACT_SPECIAL[name];\n if (special) return { cls: \"client-only\", special, reason: `React.${name}` };\n if (REACT_NEUTRAL.has(name)) return { cls: \"neutral\", reason: `React.${name}` };\n return { cls: \"client-only\", reason: `React.${name} only works in Client Components` };\n }\n case \"react-dom\":\n return REACT_DOM_NEUTRAL.has(name)\n ? { cls: \"neutral\", reason: `ReactDOM.${name}` }\n : { cls: \"client-only\", reason: `ReactDOM.${name} only works in the browser` };\n case \"framework\": {\n const rule = framework.classifyModule(from);\n if (!rule) return { cls: \"client-only\", reason: `${from} is not understood` };\n if (rule.kind === \"dynamic-import\")\n return { cls: \"client-only\", special: \"dynamic\", reason: `${from}` };\n if (rule.kind === \"css-in-js\")\n return { cls: \"client-only\", special: \"css-in-js\", reason: `${from}` };\n const cls = rule.classify(name);\n return { cls, reason: `${name} from ${from}` };\n }\n case \"css-in-js\":\n return {\n cls: \"client-only\",\n special: \"css-in-js\",\n reason: `${from} is a runtime CSS-in-JS library`,\n };\n case \"use-client-entry\":\n return asJsxTag\n ? { cls: \"client-reference\", reason: `${binding.local} is a Client Component from ${from}` }\n : {\n cls: \"client-only\",\n reason: `${binding.local} comes from the \"use client\" package ${from}`,\n };\n case \"client-list\":\n return {\n cls: \"client-only\",\n reason: `${from} is a client-only package${info.detail ? ` (${info.detail})` : \"\"}`,\n };\n case \"client-only-marker\":\n return { cls: \"client-only\", reason: `${from} is marked client-only` };\n case \"react-unknown\":\n return {\n cls: \"client-only\",\n reason: info.detail ?? `${from} depends on React and isn't known to be server-safe`,\n };\n case \"unresolved\":\n return {\n cls: \"client-only\",\n reason: `${from} could not be resolved${info.detail ? ` (${info.detail})` : \"\"}`,\n };\n case \"builtin\":\n case \"server-only-marker\":\n return { cls: \"server-only\", reason: `${from} only works on the server` };\n case \"server-safe-list\":\n case \"neutral\":\n case \"json\":\n case \"asset\":\n case \"css-module\":\n case \"stylesheet\":\n return { cls: \"neutral\", reason: `${from} is server-safe` };\n }\n}\n","import { ts } from \"ts-morph\";\nimport type { ModuleGraph } from \"../project/moduleGraph.js\";\nimport type { ComponentInfo } from \"./components.js\";\nimport { componentDeclarationNode } from \"./components.js\";\nimport { lineCol } from \"./context.js\";\nimport { getModuleDirective, hasUseServerBody } from \"./directives.js\";\nimport type { Outcome } from \"./skip.js\";\nimport { ok, skip } from \"./skip.js\";\n\nfunction isInTypePosition(node: ts.Node): boolean {\n let current: ts.Node = node;\n while (current.parent) {\n const parent = current.parent;\n if (ts.isTypeNode(parent) && !ts.isExpressionWithTypeArguments(parent)) return true;\n if (ts.isTypeQueryNode(parent)) return true;\n if (ts.isStatement(parent) || ts.isSourceFile(parent)) return false;\n current = parent;\n }\n return false;\n}\n\nfunction isJsxTagPosition(id: ts.Identifier): boolean {\n let node: ts.Node = id;\n if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) node = node.parent;\n const parent = node.parent;\n return (\n (ts.isJsxOpeningElement(parent) ||\n ts.isJsxSelfClosingElement(parent) ||\n ts.isJsxClosingElement(parent)) &&\n parent.tagName === node\n );\n}\n\n/**\n * Every module that imports the file (directly or through barrels) must be a server\n * module, and must only render the components as JSX, so they can safely become Server Components.\n * Returns the importer files whose diagnostics the self-check should compare.\n */\nexport function checkImporters(\n program: ts.Program,\n graph: ModuleGraph,\n file: string,\n components: ComponentInfo[],\n): Outcome<{ importers: string[]; serverActionProps: Set<string> }> {\n const checker = program.getTypeChecker();\n // prop name -> true while every JSX usage seen so far passes a Server Action for it.\n const actionUsage = new Map<string, boolean>();\n let sawSpread = false;\n const componentDecls = new Set(components.map(componentDeclarationNode));\n const importers = new Set<string>();\n const queue = [file];\n const visited = new Set<string>([file]);\n\n while (queue.length > 0) {\n const target = queue.shift() as string;\n const edges = graph\n .importersOf(target)\n .filter((e) => e.kind !== \"type\")\n .sort((a, b) => a.from.localeCompare(b.from) || a.line - b.line);\n for (const edge of edges) {\n const importer = edge.from;\n const rel = graph.rel(importer);\n const node = graph.nodes.get(importer);\n if (graph.isClient(importer)) {\n const root = graph.clientRootOf(importer);\n const via = root && root !== importer ? `, reached from ${graph.rel(root)}` : \"\";\n return skip(\"imported-by-client\", `imported by ${rel} (client${via})`);\n }\n if (!node?.inProgram) {\n return skip(\n \"imported-by-client\",\n `imported by ${rel}, which is outside the TypeScript project, so its usage can't be verified`,\n );\n }\n if (edge.kind === \"dynamic\") {\n return skip(\"dynamic-import\", `loaded with import() by ${rel}`);\n }\n importers.add(importer);\n if (edge.kind === \"reexport\" && !visited.has(importer)) {\n visited.add(importer);\n queue.push(importer);\n }\n const sf = program.getSourceFile(importer);\n if (!sf) {\n return skip(\n \"imported-by-client\",\n `imported by ${rel}, which couldn't be loaded to verify how it uses the component`,\n );\n }\n let misuse: ts.Identifier | undefined;\n const recordActionProps = (tag: ts.Identifier) => {\n let tagNode: ts.Node = tag;\n if (ts.isPropertyAccessExpression(tagNode.parent)) tagNode = tagNode.parent;\n const element = tagNode.parent;\n if (!ts.isJsxOpeningElement(element) && !ts.isJsxSelfClosingElement(element)) return;\n for (const attr of element.attributes.properties) {\n if (ts.isJsxSpreadAttribute(attr)) {\n sawSpread = true;\n continue;\n }\n const name = attr.name.getText(sf);\n const init = attr.initializer;\n const expr = init && ts.isJsxExpression(init) ? init.expression : undefined;\n const isAction = expr !== undefined && isServerActionReference(expr, checker);\n actionUsage.set(name, (actionUsage.get(name) ?? true) && isAction);\n }\n };\n const visit = (n: ts.Node): void => {\n if (misuse) return;\n if (ts.isIdentifier(n)) {\n const symbol = checker.getSymbolAtLocation(n);\n const resolved =\n symbol && symbol.flags & ts.SymbolFlags.Alias\n ? checker.getAliasedSymbol(symbol)\n : symbol;\n if (resolved?.declarations?.some((d) => componentDecls.has(d))) {\n const p = n.parent;\n const benign =\n ts.isImportSpecifier(p) ||\n ts.isImportClause(p) ||\n ts.isExportSpecifier(p) ||\n ts.isNamespaceImport(p) ||\n isJsxTagPosition(n) ||\n isInTypePosition(n);\n if (!benign) misuse = n;\n if (isJsxTagPosition(n)) recordActionProps(n);\n }\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(sf);\n if (misuse) {\n const { line } = lineCol(sf, misuse.getStart(sf));\n return skip(\n \"unsupported-pattern\",\n `${misuse.text} is used as a value in ${rel}:${line}; only <${misuse.text} /> usage can be verified`,\n );\n }\n }\n }\n const serverActionProps = new Set<string>();\n if (!sawSpread) for (const [name, all] of actionUsage) if (all) serverActionProps.add(name);\n return ok({ importers: [...importers], serverActionProps });\n}\n\n/** True if `expr` names a Server Action: an export of a \"use server\" module or a \"use server\" function. */\nfunction isServerActionReference(expr: ts.Expression, checker: ts.TypeChecker): boolean {\n let e = expr;\n while (ts.isParenthesizedExpression(e)) e = e.expression;\n if (!ts.isIdentifier(e) && !ts.isPropertyAccessExpression(e)) return false;\n const symbol = checker.getSymbolAtLocation(e);\n const resolved =\n symbol && symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;\n const decl = resolved?.valueDeclaration ?? resolved?.declarations?.[0];\n if (!decl) return false;\n const sf = decl.getSourceFile();\n if (sf.isDeclarationFile) return false;\n if (getModuleDirective(sf).directive === \"use server\") return true;\n if (ts.isFunctionDeclaration(decl) || ts.isFunctionExpression(decl) || ts.isArrowFunction(decl)) {\n return hasUseServerBody(decl);\n }\n if (ts.isVariableDeclaration(decl) && decl.initializer) {\n const init = decl.initializer;\n if (ts.isArrowFunction(init) || ts.isFunctionExpression(init)) return hasUseServerBody(init);\n }\n return false;\n}\n","import { ts } from \"ts-morph\";\n\nexport type Directive = \"use client\" | \"use server\";\n\ntype DirectiveInfo = {\n directive: Directive | undefined;\n /** The directive statement itself, when present. */\n statement: ts.ExpressionStatement | undefined;\n};\n\n/** Reads the directive prologue (leading string-literal statements) of a module. */\nexport function getModuleDirective(sf: ts.SourceFile): DirectiveInfo {\n for (const statement of sf.statements) {\n if (!ts.isExpressionStatement(statement) || !ts.isStringLiteral(statement.expression)) break;\n const text = statement.expression.text;\n if (text === \"use client\" || text === \"use server\") return { directive: text, statement };\n }\n return { directive: undefined, statement: undefined };\n}\n\n/** True if a function body starts with a \"use server\" directive (an inline Server Action). */\nexport function hasUseServerBody(fn: ts.FunctionLikeDeclaration): boolean {\n const body = fn.body;\n if (!body || !ts.isBlock(body)) return false;\n for (const statement of body.statements) {\n if (!ts.isExpressionStatement(statement) || !ts.isStringLiteral(statement.expression)) break;\n if (statement.expression.text === \"use server\") return true;\n }\n return false;\n}\n","import { ts } from \"ts-morph\";\nimport type { ComponentInfo, FileShape, ModuleDecl } from \"./components.js\";\nimport { componentDeclarationNode } from \"./components.js\";\nimport type { AnalysisContext } from \"./context.js\";\nimport { locOf } from \"./context.js\";\nimport { hasUseServerBody } from \"./directives.js\";\nimport type { ImportBinding, UsageClass } from \"./importTable.js\";\nimport {\n bindingIdentifiers,\n containsRange,\n forEachValueRef,\n isIntrinsicTagName,\n isJsxElementLike,\n mapCallOf,\n stripParens,\n symbolOfRef,\n tagNameText,\n} from \"./refs.js\";\nimport type { PickedProp } from \"./mongoose.js\";\nimport { isMongooseLike, pickMongooseFields } from \"./mongoose.js\";\nimport { checkSerializable, isCallableType } from \"./serializable.js\";\nimport type { Outcome, Skip } from \"./skip.js\";\nimport { ok, skip } from \"./skip.js\";\nimport type { FileFacts, Marker } from \"./taint.js\";\n\nexport type JsxLike = ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment;\n\n/** One top-level statement of the component body. */\nexport type Unit = {\n index: number;\n node: ts.Statement;\n kind: \"var\" | \"function\" | \"hook-call\" | \"early-return\";\n declares: Set<ts.Symbol>;\n localDeps: Set<Unit>;\n moduleDeps: Set<ModuleDecl>;\n markers: Marker[];\n client: boolean;\n /** For early returns: the returned expression. */\n returned?: ts.Expression;\n};\n\nexport type JNode = {\n id: number;\n node: JsxLike;\n parent: JNode | undefined;\n children: JNode[];\n rootIndex: number;\n /** Functions between the parent JNode (or the render root) and this node, outermost first. */\n fnBetween: ts.SignatureDeclaration[];\n depth: number;\n};\n\ntype Origin =\n | { kind: \"param\"; symbol: ts.Symbol }\n | { kind: \"local\"; symbol: ts.Symbol; unit: Unit }\n | { kind: \"inner\"; symbol: ts.Symbol; declaration: ts.Declaration }\n | { kind: \"module\"; symbol: ts.Symbol; decl: ModuleDecl }\n | { kind: \"component\"; symbol: ts.Symbol; component: ComponentInfo }\n | { kind: \"import\"; binding: ImportBinding; usage: UsageClass }\n | { kind: \"browser-global\"; name: string }\n | { kind: \"global\" }\n | { kind: \"unknown\" };\n\nexport type PropInfo = {\n name: string;\n symbol: ts.Symbol;\n type: ts.Type;\n /** A reference inside the island, used as the location for type printing and narrowing. */\n refNode: ts.Identifier;\n /** Mongoose/ObjectId values: only the fields the island reads, built on the server. */\n picked?: PickedProp;\n};\n\nexport type IslandPlan = {\n name: string;\n root: JNode;\n rootTag: string;\n /** `key` attribute moved from a mapped root onto the island usage. */\n keyAttr: ts.JsxAttribute | undefined;\n /** Body statements the island needs, in source order. */\n units: Unit[];\n props: PropInfo[];\n /** Import bindings used in value positions inside the island. */\n valueImports: Set<ImportBinding>;\n /** Module-level declarations that must be copied into the island file. */\n moduleDecls: Set<ModuleDecl>;\n /**\n * Static subtrees inside the island that stay on the server and are passed in as JSX props\n * (\"donut\" pattern): `children` for a single slot, otherwise `slot1`, `slot2`, ...\n */\n slots: { j: JNode; name: string }[];\n line: number;\n};\n\nexport type ComponentPlan = {\n component: ComponentInfo;\n islands: IslandPlan[];\n /** Body statements removed from the server component. */\n removedUnits: Set<Unit>;\n /** Module declarations no longer used by the server file (copied into the island file). */\n movedModuleDecls: Set<ModuleDecl>;\n staticRatio: number;\n jsxTotal: number;\n};\n\n/** React hooks whose result is the same for every caller under the same provider. */\nconst REACT_SHARED_CONTEXT_HOOKS = [\"useContext\", \"use\"];\n\nclass UnionFind {\n private parent = new Map<number, number>();\n find(x: number): number {\n let p = this.parent.get(x) ?? x;\n if (p !== x) {\n p = this.find(p);\n this.parent.set(x, p);\n }\n return p;\n }\n union(a: number, b: number): void {\n const ra = this.find(a);\n const rb = this.find(b);\n if (ra !== rb) this.parent.set(rb, ra);\n }\n}\n\n/** Lowest common ancestor in the JSX tree, or undefined if the nodes live in different render roots. */\nexport function lowestCommonAncestor(nodes: JNode[]): JNode | undefined {\n const [first, ...rest] = nodes;\n if (!first) return undefined;\n let lca: JNode | undefined = first;\n for (const node of rest) {\n if (!lca) return undefined;\n if (node.rootIndex !== lca.rootIndex) return undefined;\n let a: JNode | undefined = lca;\n let b: JNode | undefined = node;\n while (a && b && a.depth > b.depth) a = a.parent;\n while (a && b && b.depth > a.depth) b = b.parent;\n while (a && b && a !== b) {\n a = a.parent;\n b = b.parent;\n }\n lca = a;\n }\n return lca;\n}\n\nfunction isAncestorOrSelf(ancestor: JNode, node: JNode): boolean {\n let current: JNode | undefined = node;\n while (current) {\n if (current === ancestor) return true;\n current = current.parent;\n }\n return false;\n}\n\nfunction pascal(text: string): string {\n return text\n .split(/[^A-Za-z0-9]+/)\n .filter(Boolean)\n .map((part) => part[0]?.toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\nexport function islandBaseName(componentName: string, rootTag: string): string {\n return `${componentName}${pascal(rootTag) || \"Island\"}`;\n}\n\n/**\n * Plans the split of one component: which JSX subtrees become islands, which statements move with\n * them, and which values cross the boundary as props.\n */\ntype PlanOptions = {\n /** Component props that every importer passes a Server Action for (see checkImporters). */\n serverActionProps?: ReadonlySet<string>;\n /** Other components of the file that move wholesale into the island file (client references). */\n wholesale?: ReadonlySet<ComponentInfo>;\n};\n\nexport function planComponent(\n ctx: AnalysisContext,\n facts: FileFacts,\n shape: FileShape,\n component: ComponentInfo,\n options: PlanOptions = {},\n): Outcome<ComponentPlan> {\n const { checker, sf } = ctx;\n const fn = component.fn;\n const body = fn.body;\n if (!body) return skip(\"unsupported-pattern\", `${component.name} has no body`, locOf(ctx, fn));\n if (fn.parameters.length > 1) {\n return skip(\n \"unsupported-pattern\",\n `${component.name} takes more than one parameter`,\n locOf(ctx, fn),\n );\n }\n\n // ---- parameters ---------------------------------------------------------------------------\n const paramSymbols = new Set<ts.Symbol>();\n const serverActionParams = new Set<ts.Symbol>();\n for (const param of fn.parameters) {\n for (const id of bindingIdentifiers(param.name)) {\n const symbol = checker.getSymbolAtLocation(id);\n if (symbol) paramSymbols.add(symbol);\n }\n if (ts.isObjectBindingPattern(param.name)) {\n for (const element of param.name.elements) {\n const propName = element.propertyName ?? element.name;\n if (!ts.isIdentifier(propName) || !ts.isIdentifier(element.name)) continue;\n if (!options.serverActionProps?.has(propName.text)) continue;\n const symbol = checker.getSymbolAtLocation(element.name);\n if (symbol) serverActionParams.add(symbol);\n }\n }\n }\n\n // ---- body units and render roots ------------------------------------------------------------\n const units: Unit[] = [];\n const renderRoots: ts.Expression[] = [];\n const earlyReturnConditions: ts.Expression[] = [];\n const symbolToUnit = new Map<ts.Symbol, Unit>();\n\n const newUnit = (node: ts.Statement, kind: Unit[\"kind\"]): Unit => {\n const unit: Unit = {\n index: units.length,\n node,\n kind,\n declares: new Set(),\n localDeps: new Set(),\n moduleDeps: new Set(),\n markers: [],\n client: false,\n };\n units.push(unit);\n return unit;\n };\n\n if (!ts.isBlock(body)) {\n renderRoots.push(stripParens(body));\n } else {\n const statements = body.statements;\n let sawReturn = false;\n for (let i = 0; i < statements.length; i++) {\n const statement = statements[i] as ts.Statement;\n if (ts.isEmptyStatement(statement)) continue;\n if (sawReturn)\n return skip(\n \"unsupported-pattern\",\n \"has statements after the final return\",\n locOf(ctx, statement),\n );\n if (ts.isReturnStatement(statement)) {\n if (!statement.expression)\n return skip(\"unsupported-pattern\", \"returns nothing\", locOf(ctx, statement));\n renderRoots.push(stripParens(statement.expression));\n sawReturn = true;\n continue;\n }\n if (ts.isIfStatement(statement)) {\n const then = statement.thenStatement;\n const ret = ts.isReturnStatement(then)\n ? then\n : ts.isBlock(then) &&\n then.statements.length === 1 &&\n ts.isReturnStatement(then.statements[0] as ts.Statement)\n ? (then.statements[0] as ts.ReturnStatement)\n : undefined;\n if (!ret || statement.elseStatement || !ret.expression) {\n return skip(\n \"unsupported-pattern\",\n \"has an `if` statement other than a simple early return\",\n locOf(ctx, statement),\n );\n }\n const unit = newUnit(statement, \"early-return\");\n unit.returned = stripParens(ret.expression);\n renderRoots.push(unit.returned);\n earlyReturnConditions.push(statement.expression);\n continue;\n }\n if (ts.isVariableStatement(statement)) {\n if (!(statement.declarationList.flags & ts.NodeFlags.Const)) {\n return skip(\n \"unsupported-pattern\",\n \"declares a `let`/`var` in the component body\",\n locOf(ctx, statement),\n );\n }\n const unit = newUnit(statement, \"var\");\n for (const decl of statement.declarationList.declarations) {\n for (const id of bindingIdentifiers(decl.name)) {\n const symbol = checker.getSymbolAtLocation(id);\n if (symbol) {\n unit.declares.add(symbol);\n symbolToUnit.set(symbol, unit);\n }\n }\n }\n continue;\n }\n if (ts.isFunctionDeclaration(statement) && statement.name) {\n const unit = newUnit(statement, \"function\");\n const symbol = checker.getSymbolAtLocation(statement.name);\n if (symbol) {\n unit.declares.add(symbol);\n symbolToUnit.set(symbol, unit);\n }\n continue;\n }\n if (ts.isExpressionStatement(statement)) {\n const expr = stripParens(statement.expression);\n if (ts.isCallExpression(expr) && facts.isHookCall(expr)) {\n newUnit(statement, \"hook-call\");\n continue;\n }\n return skip(\n \"unsupported-pattern\",\n \"has a statement with side effects in the component body (only declarations, hook calls and early returns are supported)\",\n locOf(ctx, statement),\n );\n }\n return skip(\n \"unsupported-pattern\",\n `has a \\`${ts.SyntaxKind[statement.kind]}\\` in the component body`,\n locOf(ctx, statement),\n );\n }\n if (renderRoots.length === 0)\n return skip(\"unsupported-pattern\", `${component.name} never returns JSX`, locOf(ctx, fn));\n }\n\n // ---- origins ----------------------------------------------------------------------------------\n const moduleDeclByStatement = new Map<ts.Statement, ModuleDecl>();\n for (const decl of shape.moduleDecls) moduleDeclByStatement.set(decl.statement, decl);\n const componentStatements = new Set(shape.components.map((c) => c.statement));\n\n const topLevelStatement = (node: ts.Node): ts.Statement | undefined => {\n let current: ts.Node | undefined = node;\n while (current && current.parent !== sf) current = current.parent;\n return current as ts.Statement | undefined;\n };\n\n const originOf = (id: ts.Identifier): Origin => {\n const info = facts.classifyRef(id);\n switch (info.kind) {\n case \"import\":\n return { kind: \"import\", binding: info.binding, usage: info.usage };\n case \"browser-global\":\n return { kind: \"browser-global\", name: info.name };\n case \"global\":\n return { kind: \"global\" };\n case \"unknown\":\n return { kind: \"unknown\" };\n case \"file\": {\n const { symbol, declaration } = info;\n if (paramSymbols.has(symbol)) return { kind: \"param\", symbol };\n const unit = symbolToUnit.get(symbol);\n if (unit) return { kind: \"local\", symbol, unit };\n if (containsRange(fn, declaration)) return { kind: \"inner\", symbol, declaration };\n const top = topLevelStatement(declaration);\n if (top && componentStatements.has(top)) {\n const target = shape.components.find((c) => c.statement === top);\n if (target && componentDeclarationNode(target) === declaration)\n return { kind: \"component\", symbol, component: target };\n // A name declared inside another component of the file (its params, locals).\n return { kind: \"inner\", symbol, declaration };\n }\n const decl = top ? moduleDeclByStatement.get(top) : undefined;\n if (decl) return { kind: \"module\", symbol, decl };\n return { kind: \"unknown\" };\n }\n }\n };\n\n // ---- module declaration taint (helpers, constants) ---------------------------------------------\n const clientModuleDecls = new Set<ModuleDecl>();\n const moduleDeclDeps = new Map<ModuleDecl, Set<ModuleDecl>>();\n for (const decl of shape.moduleDecls) {\n if (decl.kind === \"type\") continue;\n const deps = new Set<ModuleDecl>();\n forEachValueRef(decl.statement, (id) => {\n const origin = originOf(id);\n if (origin.kind === \"module\" && origin.decl !== decl) deps.add(origin.decl);\n });\n moduleDeclDeps.set(decl, deps);\n if (facts.scanMarkers(decl.statement).length > 0) clientModuleDecls.add(decl);\n }\n for (let changed = true; changed;) {\n changed = false;\n for (const [decl, deps] of moduleDeclDeps) {\n if (clientModuleDecls.has(decl)) continue;\n if ([...deps].some((d) => clientModuleDecls.has(d))) {\n clientModuleDecls.add(decl);\n changed = true;\n }\n }\n }\n\n // ---- unit dependencies, markers, conditional hooks ----------------------------------------------\n let seenEarlyReturn = false;\n for (const unit of units) {\n if (unit.kind === \"early-return\") seenEarlyReturn = true;\n const scanned =\n unit.kind === \"early-return\" ? (unit.node as ts.IfStatement).expression : unit.node;\n unit.markers = facts.scanMarkers(scanned);\n forEachValueRef(scanned, (id) => {\n const origin = originOf(id);\n if (origin.kind === \"local\" && origin.unit !== unit) unit.localDeps.add(origin.unit);\n if (origin.kind === \"module\") unit.moduleDeps.add(origin.decl);\n if (origin.kind === \"component\")\n unit.markers.push({\n kind: \"client-import\",\n node: id,\n detail:\n origin.component === component\n ? \"recursive component reference\"\n : `component ${id.text} used as a value`,\n });\n });\n for (const marker of unit.markers) {\n if (marker.kind !== \"hook\") continue;\n if (unit.kind === \"early-return\") {\n return skip(\n \"conditional-hooks-or-returns\",\n `calls ${marker.detail} inside an early-return condition`,\n locOf(ctx, marker.node),\n );\n }\n if (seenEarlyReturn) {\n return skip(\n \"conditional-hooks-or-returns\",\n `calls ${marker.detail} after an early return`,\n locOf(ctx, marker.node),\n );\n }\n const conditional = conditionalAncestor(marker.node, unit.node);\n if (conditional) {\n return skip(\n \"conditional-hooks-or-returns\",\n `calls ${marker.detail} ${conditional}`,\n locOf(ctx, marker.node),\n );\n }\n }\n }\n for (let changed = true; changed;) {\n changed = false;\n for (const unit of units) {\n if (unit.client) continue;\n if (\n unit.markers.length > 0 ||\n [...unit.localDeps].some((d) => d.client) ||\n [...unit.moduleDeps].some((d) => clientModuleDecls.has(d))\n ) {\n unit.client = true;\n changed = true;\n }\n }\n }\n for (const unit of units) {\n if (unit.kind === \"early-return\" && unit.client) {\n return skip(\n \"conditional-hooks-or-returns\",\n \"returns early based on client-only state, so the server can't decide what to render\",\n locOf(ctx, unit.node),\n );\n }\n }\n\n // ---- JSX tree ---------------------------------------------------------------------------------------\n const jnodes: JNode[] = [];\n const jnodeOf = new Map<ts.Node, JNode>();\n const topJNodes: JNode[][] = renderRoots.map(() => []);\n\n const build = (\n node: ts.Node,\n parent: JNode | undefined,\n rootIndex: number,\n fns: ts.SignatureDeclaration[],\n ): void => {\n if (isJsxElementLike(node)) {\n const j: JNode = {\n id: jnodes.length,\n node,\n parent,\n children: [],\n rootIndex,\n fnBetween: fns,\n depth: parent ? parent.depth + 1 : 0,\n };\n jnodes.push(j);\n jnodeOf.set(node, j);\n if (parent) parent.children.push(j);\n else topJNodes[rootIndex]?.push(j);\n const inner = (n: ts.Node) => build(n, j, rootIndex, []);\n if (ts.isJsxElement(node)) {\n ts.forEachChild(node.openingElement, inner);\n node.children.forEach(inner);\n } else if (ts.isJsxSelfClosingElement(node)) {\n ts.forEachChild(node, inner);\n } else {\n node.children.forEach(inner);\n }\n return;\n }\n const nextFns = ts.isFunctionLike(node) ? [...fns, node] : fns;\n ts.forEachChild(node, (c) => build(c, parent, rootIndex, nextFns));\n };\n renderRoots.forEach((root, i) => build(root, undefined, i, []));\n\n const isNestedJsx = (self: ts.Node) => (n: ts.Node) => n !== self && isJsxElementLike(n);\n\n // Hooks may not be called from JSX.\n for (const root of renderRoots) {\n for (const marker of facts.scanMarkers(root)) {\n if (marker.kind === \"hook\") {\n return skip(\n \"conditional-hooks-or-returns\",\n `calls ${marker.detail} inside the returned JSX`,\n locOf(ctx, marker.node),\n );\n }\n }\n }\n\n // Context providers.\n for (const j of jnodes) {\n if (ts.isJsxFragment(j.node)) continue;\n const tag = ts.isJsxElement(j.node) ? j.node.openingElement.tagName : j.node.tagName;\n if (isIntrinsicTagName(tag)) continue;\n if (\n ts.isPropertyAccessExpression(tag) &&\n (tag.name.text === \"Provider\" || tag.name.text === \"Consumer\")\n ) {\n return skip(\"context-provider\", `renders <${tag.getText(sf)}>`, locOf(ctx, tag));\n }\n const tagType = checker.getTypeAtLocation(tag);\n if (tagType.getProperty(\"Provider\") && tagType.getProperty(\"Consumer\")) {\n return skip(\n \"context-provider\",\n `renders the context <${tag.getText(sf)}> as a provider`,\n locOf(ctx, tag),\n );\n }\n }\n\n // ---- anchors -----------------------------------------------------------------------------------------\n type Anchor = { j: JNode; reasons: string[]; refs: ts.Identifier[] };\n const anchors: Anchor[] = [];\n const isServerActionRef = (expr: ts.Expression): boolean => {\n const e = stripParens(expr);\n if (!ts.isIdentifier(e)) return false;\n const origin = originOf(e);\n if (origin.kind === \"import\") return origin.usage.cls === \"server-action\";\n if (origin.kind === \"param\") return serverActionParams.has(origin.symbol);\n if (origin.kind === \"module\" && origin.decl.kind === \"function\") {\n return (\n ts.isFunctionDeclaration(origin.decl.statement) && hasUseServerBody(origin.decl.statement)\n );\n }\n return false;\n };\n\n for (const j of jnodes) {\n const reasons: string[] = [];\n const refs: ts.Identifier[] = [];\n const stop = isNestedJsx(j.node);\n forEachValueRef(j.node, (id) => refs.push(id), stop);\n\n let tagClass: \"intrinsic\" | \"fragment\" | \"server\" | \"client-reference\" | \"client\" = \"fragment\";\n let attributes: ts.JsxAttributes | undefined;\n if (!ts.isJsxFragment(j.node)) {\n const tag = ts.isJsxElement(j.node) ? j.node.openingElement.tagName : j.node.tagName;\n attributes = ts.isJsxElement(j.node) ? j.node.openingElement.attributes : j.node.attributes;\n if (isIntrinsicTagName(tag)) tagClass = \"intrinsic\";\n else {\n let head: ts.Expression = tag as ts.Expression;\n while (ts.isPropertyAccessExpression(head)) head = head.expression;\n const origin = ts.isIdentifier(head) ? originOf(head) : ({ kind: \"unknown\" } as Origin);\n if (origin.kind === \"import\") {\n tagClass =\n origin.usage.cls === \"client-reference\"\n ? \"client-reference\"\n : origin.usage.cls === \"neutral\"\n ? \"server\"\n : \"client\";\n if (tagClass === \"client\") reasons.push(origin.usage.reason);\n } else if (origin.kind === \"param\" || origin.kind === \"local\" || origin.kind === \"inner\") {\n tagClass = \"server\"; // a dynamic tag; its binding is checked through `refs`\n } else if (origin.kind === \"module\") {\n tagClass = clientModuleDecls.has(origin.decl) ? \"client\" : \"server\";\n if (tagClass === \"client\")\n reasons.push(`<${tag.getText(sf)}> is built from client-only code`);\n } else if (origin.kind === \"component\") {\n if (origin.component === component) {\n return skip(\n \"unsupported-pattern\",\n `${component.name} renders itself recursively`,\n locOf(ctx, tag),\n );\n }\n // Another component of this file: a client reference if it moves to the island file,\n // otherwise it stays a Server Component next to this one.\n tagClass = options.wholesale?.has(origin.component) ? \"client-reference\" : \"server\";\n } else {\n tagClass = \"client\";\n reasons.push(`<${tag.getText(sf)}> can't be proven server-safe`);\n }\n }\n if (\n tagClass === \"intrinsic\" &&\n ts.isIdentifier(tag) &&\n tag.text === \"style\" &&\n attributes.properties.some((p) => ts.isJsxAttribute(p) && p.name.getText(sf) === \"jsx\")\n ) {\n return skip(\"css-in-js-runtime\", \"uses <style jsx> (styled-jsx)\", locOf(ctx, tag));\n }\n\n for (const prop of attributes.properties) {\n if (ts.isJsxSpreadAttribute(prop)) {\n const type = checker.getTypeAtLocation(prop.expression);\n const risky = checker\n .getPropertiesOfType(type)\n .find(\n (p) =>\n /^on[A-Z]/.test(p.getName()) ||\n p.getName() === \"ref\" ||\n isCallableType(checker.getTypeOfSymbolAtLocation(p, prop)),\n );\n if (risky) reasons.push(`spreads a value that can carry \\`${risky.getName()}\\``);\n else if (\n tagClass === \"client-reference\" &&\n !checkSerializable(checker, type, { primitivesOnly: ctx.isJs }).ok\n ) {\n reasons.push(\"spreads non-serializable props into a Client Component\");\n }\n continue;\n }\n const name = prop.name.getText(sf);\n if (/^on[A-Z]/.test(name) || name === \"ref\") {\n reasons.push(`has ${name}`);\n continue;\n }\n const init = prop.initializer;\n if (init && ts.isJsxExpression(init) && init.expression) {\n const expr = init.expression;\n const type = checker.getTypeAtLocation(expr);\n if (isCallableType(type)) {\n const unwrapped = stripParens(expr);\n if (\n (ts.isArrowFunction(unwrapped) || ts.isFunctionExpression(unwrapped)) &&\n containsJsxNode(unwrapped)\n ) {\n return skip(\n \"render-prop\",\n `passes a render function to \\`${name}\\``,\n locOf(ctx, prop),\n );\n }\n const actionOk =\n isServerActionRef(expr) &&\n (tagClass !== \"intrinsic\" || name === \"action\" || name === \"formAction\");\n if (!actionOk) reasons.push(`passes a function to \\`${name}\\``);\n } else if (tagClass === \"client-reference\") {\n const verdict = checkSerializable(checker, type, { primitivesOnly: ctx.isJs });\n if (!verdict.ok)\n reasons.push(`passes a non-serializable \\`${name}\\` to a Client Component`);\n }\n }\n }\n }\n\n const children = ts.isJsxSelfClosingElement(j.node) ? [] : j.node.children;\n for (const child of children) {\n if (!ts.isJsxExpression(child) || !child.expression) continue;\n const type = checker.getTypeAtLocation(child.expression);\n if (isCallableType(type))\n return skip(\"render-prop\", \"uses a function as a child (render prop)\", locOf(ctx, child));\n if (tagClass === \"client-reference\") {\n const verdict = checkSerializable(checker, type, { primitivesOnly: ctx.isJs });\n if (!verdict.ok) reasons.push(\"passes non-serializable children to a Client Component\");\n }\n }\n\n for (const id of refs) {\n const origin = originOf(id);\n if (origin.kind === \"local\" && origin.unit.client) reasons.push(`reads ${id.text}`);\n else if (origin.kind === \"module\" && clientModuleDecls.has(origin.decl))\n reasons.push(`uses ${id.text}`);\n else if (origin.kind === \"import\" && origin.usage.cls === \"client-only\" && !isTagRef(id))\n reasons.push(origin.usage.reason);\n else if (origin.kind === \"browser-global\") reasons.push(`uses ${origin.name}`);\n else if (origin.kind === \"unknown\" && !isTagRef(id))\n reasons.push(`uses ${id.text}, which can't be resolved`);\n }\n for (const marker of facts.scanMarkers(j.node, stop)) {\n if (marker.kind === \"nondeterministic\") reasons.push(`calls ${marker.detail}`);\n }\n if (reasons.length > 0) anchors.push({ j, reasons, refs });\n }\n\n // Non-JSX parts of the returned expressions (e.g. `cond ? <A/> : <B/>`) run on the server.\n for (const root of renderRoots) {\n if (isJsxElementLike(root)) continue; // an element is covered by its own anchor rules\n let problem: ts.Identifier | undefined;\n forEachValueRef(\n root,\n (id) => {\n if (problem) return;\n const origin = originOf(id);\n if ((origin.kind === \"local\" && origin.unit.client) || origin.kind === \"browser-global\")\n problem = id;\n },\n (n) => isJsxElementLike(n),\n );\n if (problem) {\n return skip(\n \"state-spans-component\",\n `the returned expression itself reads client-only \\`${problem.text}\\``,\n locOf(ctx, problem),\n );\n }\n }\n\n // ---- grouping -------------------------------------------------------------------------------------\n const closureOf = (refs: Iterable<ts.Identifier>): Set<Unit> => {\n const out = new Set<Unit>();\n const stack: Unit[] = [];\n for (const id of refs) {\n const origin = originOf(id);\n if (origin.kind === \"local\" && !out.has(origin.unit)) {\n out.add(origin.unit);\n stack.push(origin.unit);\n }\n }\n while (stack.length > 0) {\n const unit = stack.pop() as Unit;\n for (const dep of unit.localDeps) {\n if (!out.has(dep)) {\n out.add(dep);\n stack.push(dep);\n }\n }\n }\n return out;\n };\n\n const clientUnits = units.filter((u) => u.client);\n const totalJsx = jnodes.length;\n\n if (anchors.length === 0) {\n if (clientUnits.length === 0 && clientModuleDecls.size === 0) {\n return skip(\n \"no-islands\",\n `${component.name} uses no client-only features; removing \"use client\" may be enough (the tool never removes it automatically)`,\n );\n }\n const first = clientUnits[0];\n return skip(\n \"unsupported-pattern\",\n first\n ? `client-only code at line ${locOf(ctx, first.node).line} isn't connected to any rendered element`\n : \"client-only helpers aren't connected to any rendered element\",\n first ? locOf(ctx, first.node) : undefined,\n );\n }\n\n const uf = new UnionFind();\n const unitOwner = new Map<Unit, number>();\n anchors.forEach((anchor, i) => {\n for (const unit of closureOf(anchor.refs)) {\n if (!unit.client) continue;\n const owner = unitOwner.get(unit);\n if (owner === undefined) unitOwner.set(unit, i);\n else uf.union(owner, i);\n }\n });\n\n /** `extra`: client statements no element reads directly (effects...) attached to this island. */\n type Group = { anchors: Anchor[]; root: JNode; extra: Set<Unit> };\n const groupsByRoot = new Map<number, Anchor[]>();\n anchors.forEach((anchor, i) => {\n const key = uf.find(i);\n const list = groupsByRoot.get(key) ?? [];\n list.push(anchor);\n groupsByRoot.set(key, list);\n });\n\n /**\n * Applies the loop rule. An island inside a `.map` callback renders once per item, so its root is\n * the mapped element. That is only safe when the island carries no component-level hooks:\n * moving `useState` into a per-item island would give every item its own copy of the state.\n * In that case the root climbs out to the element that contains the `.map`.\n */\n const mappedRoot = (root: JNode, perItemSafe: boolean): Outcome<JNode> => {\n let current: JNode | undefined = root;\n while (current) {\n const opaque = current.fnBetween.find((f) => !mapCallOf(f));\n if (opaque) {\n return skip(\n \"render-prop\",\n \"an interactive element sits inside a callback other than .map()\",\n locOf(ctx, current.node),\n );\n }\n if (current.fnBetween.some((f) => mapCallOf(f))) {\n if (perItemSafe) return ok(current);\n const container: JNode | undefined = current.parent;\n if (!container) {\n return skip(\n \"state-spans-component\",\n \"state shared by every list item is used by the list itself, which is the returned element\",\n locOf(ctx, current.node),\n );\n }\n root = container;\n }\n current = current.parent;\n }\n return ok(root);\n };\n\n // Hooks that only read shared context return the same value in every list item, so a per-item\n // island may call them; any other hook (state, refs, effects, custom hooks) must not be duplicated.\n const sharedContextHooks = new Set([\n ...REACT_SHARED_CONTEXT_HOOKS,\n ...ctx.framework.sharedContextHooks,\n ]);\n const hasComponentHooks = (groupAnchors: Anchor[]): boolean =>\n [...closureOf(groupAnchors.flatMap((a) => a.refs))].some((u) =>\n u.markers.some(\n (m) => m.kind === \"hook\" && !sharedContextHooks.has(m.detail.replace(/\\(\\)$/, \"\")),\n ),\n );\n\n let groups: Group[] = [];\n for (const groupAnchors of groupsByRoot.values()) {\n const lca = lowestCommonAncestor(groupAnchors.map((a) => a.j));\n if (!lca) {\n return skip(\n \"state-spans-component\",\n \"the same client state is used in different returned trees\",\n locOf(ctx, groupAnchors[0]?.j.node ?? fn),\n );\n }\n const mapped = mappedRoot(lca, !hasComponentHooks(groupAnchors));\n if (!mapped.ok) return mapped;\n groups.push({ anchors: groupAnchors, root: mapped.value, extra: new Set() });\n }\n\n // Merge nested / overlapping islands and apply the escape check until stable.\n const unitClosure = (start: Iterable<Unit>): Set<Unit> => {\n const out = new Set<Unit>();\n const stack = [...start];\n while (stack.length > 0) {\n const unit = stack.pop() as Unit;\n if (out.has(unit)) continue;\n out.add(unit);\n stack.push(...unit.localDeps);\n }\n return out;\n };\n const unitHasOwnHooks = (u: Unit) =>\n u.markers.some(\n (m) => m.kind === \"hook\" && !sharedContextHooks.has(m.detail.replace(/\\(\\)$/, \"\")),\n );\n const groupHasHooks = (g: Group): boolean =>\n hasComponentHooks(g.anchors) || [...unitClosure(g.extra)].some(unitHasOwnHooks);\n const unitsOfGroup = (group: Group): Set<Unit> => {\n const refs: ts.Identifier[] = [];\n forEachValueRef(group.root.node, (id) => refs.push(id));\n const units = closureOf(refs);\n for (const unit of unitClosure(group.extra)) units.add(unit);\n return units;\n };\n /**\n * Client statements that no element reads directly (typically `useEffect` syncing some state)\n * belong to the island that owns the state they use. Returns true if something changed.\n */\n const attachUnreadClientUnits = (): Outcome<boolean> => {\n let changed = false;\n for (const unit of units) {\n if (!unit.client || unit.kind === \"early-return\") continue;\n const owned = groups.map((g) => unitsOfGroup(g));\n if (owned.some((set) => set.has(unit))) continue;\n const deps = unitClosure(unit.localDeps);\n const owners = groups.filter((_, i) => [...deps].some((d) => d.client && owned[i]?.has(d)));\n const [first, ...rest] = owners;\n if (!first) continue; // uses no island's state: reported as unconnected later\n if (rest.length > 0) {\n const lca = lowestCommonAncestor(owners.map((g) => g.root));\n if (!lca)\n return skip(\n \"state-spans-component\",\n \"client state is shared across returned trees\",\n locOf(ctx, unit.node),\n );\n const merged = [...owners.flatMap((g) => g.anchors)];\n const mapped = mappedRoot(lca, !owners.some(groupHasHooks));\n if (!mapped.ok) return mapped;\n first.anchors = merged;\n first.root = mapped.value;\n for (const other of rest) other.extra.forEach((u) => first.extra.add(u));\n groups = groups.filter((g) => !rest.includes(g));\n }\n first.extra.add(unit);\n if (unitHasOwnHooks(unit)) {\n // An effect must run once, not once per list item: keep the island out of any .map.\n const hoisted = mappedRoot(first.root, false);\n if (!hoisted.ok) return hoisted;\n first.root = hoisted.value;\n }\n changed = true;\n }\n return ok(changed);\n };\n\n for (let iteration = 0; iteration < 100; iteration++) {\n const attached = attachUnreadClientUnits();\n if (!attached.ok) return attached;\n let changed = attached.value;\n outer: for (const a of groups) {\n for (const b of groups) {\n if (a === b) continue;\n if (isAncestorOrSelf(a.root, b.root)) {\n a.anchors.push(...b.anchors);\n b.extra.forEach((u) => a.extra.add(u));\n groups = groups.filter((g) => g !== b);\n changed = true;\n break outer;\n }\n }\n }\n if (changed) continue;\n // Client units shared between two islands -> merge at their LCA.\n const owner = new Map<Unit, Group>();\n for (const group of groups) {\n for (const unit of unitsOfGroup(group)) {\n if (!unit.client) continue;\n const other = owner.get(unit);\n if (other && other !== group) {\n const lca = lowestCommonAncestor([other.root, group.root]);\n if (!lca)\n return skip(\n \"state-spans-component\",\n \"client state is shared across returned trees\",\n locOf(ctx, unit.node),\n );\n const mapped = mappedRoot(lca, !(groupHasHooks(other) || groupHasHooks(group)));\n if (!mapped.ok) return mapped;\n other.anchors.push(...group.anchors);\n group.extra.forEach((u) => other.extra.add(u));\n other.root = mapped.value;\n groups = groups.filter((g) => g !== group);\n changed = true;\n break;\n }\n owner.set(unit, group);\n }\n if (changed) break;\n }\n if (changed) continue;\n // Escape check: every read of an island's client bindings must be inside that island.\n for (const group of groups) {\n const islandUnits = unitsOfGroup(group);\n const clientDeclared = new Set<ts.Symbol>();\n for (const unit of islandUnits)\n if (unit.client) unit.declares.forEach((s) => clientDeclared.add(s));\n let escape: { node: ts.Identifier; j: JNode | undefined } | undefined;\n const check = (scope: ts.Node) =>\n forEachValueRef(scope, (id) => {\n if (escape) return;\n const symbol = symbolOfRef(checker, id);\n if (!symbol || !clientDeclared.has(symbol)) return;\n if (containsRange(group.root.node, id)) return;\n escape = { node: id, j: enclosingJNode(id, jnodeOf) };\n });\n for (const root of renderRoots) check(root);\n for (const unit of units) if (!islandUnits.has(unit)) check(unit.node);\n if (escape) {\n if (!escape.j) {\n return skip(\n \"state-spans-component\",\n `client-only \\`${escape.node.text}\\` is read outside the interactive part`,\n locOf(ctx, escape.node),\n );\n }\n const lca = lowestCommonAncestor([group.root, escape.j]);\n if (!lca)\n return skip(\n \"state-spans-component\",\n `client-only \\`${escape.node.text}\\` is read in another returned tree`,\n locOf(ctx, escape.node),\n );\n const mapped = mappedRoot(lca, !groupHasHooks(group));\n if (!mapped.ok) return mapped;\n group.root = mapped.value;\n changed = true;\n break;\n }\n }\n if (!changed) break;\n }\n\n for (const group of groups) {\n if (!group.root.parent) {\n const single = group.anchors.length === 1 && group.anchors[0]?.j === group.root;\n if (single) {\n return skip(\n \"fully-interactive\",\n `the root <${tagNameText(sf, group.root.node)}> itself is interactive (${group.anchors[0]?.reasons[0] ?? \"client-only\"}), so nothing would stay on the server`,\n locOf(ctx, group.root.node),\n );\n }\n return skip(\n \"state-spans-component\",\n `client state is used across the whole returned tree (${describeAnchors(sf, group.anchors)})`,\n locOf(ctx, group.root.node),\n );\n }\n }\n\n // Every client statement must belong to exactly one island.\n const assigned = new Map<Unit, Group>();\n for (const group of groups)\n for (const unit of unitsOfGroup(group)) if (unit.client) assigned.set(unit, group);\n for (const unit of clientUnits) {\n if (unit.kind === \"early-return\") continue;\n if (!assigned.has(unit)) {\n return skip(\n \"unsupported-pattern\",\n `client-only code at line ${locOf(ctx, unit.node).line} isn't connected to any rendered element; moving it would change when it runs`,\n locOf(ctx, unit.node),\n );\n }\n }\n\n // ---- build island plans: statements, props, imports ----------------------------------------------\n groups.sort((a, b) => a.root.node.getStart(sf) - b.root.node.getStart(sf));\n const islands: IslandPlan[] = [];\n const copiedUnits = new Set<Unit>();\n\n // ---- donut slots: static subtrees inside an island stay on the server ---------------------------\n const anchorNodes = new Set(anchors.map((a) => a.j));\n const subtreeOf = (j: JNode): JNode[] => jnodes.filter((other) => isAncestorOrSelf(j, other));\n const isStaticSubtree = (j: JNode): boolean => {\n if (subtreeOf(j).some((n) => anchorNodes.has(n))) return false;\n if (facts.scanMarkers(j.node).length > 0) return false;\n let clientRead = false;\n forEachValueRef(j.node, (id) => {\n if (clientRead) return;\n const origin = originOf(id);\n if (\n (origin.kind === \"local\" && origin.unit.client) ||\n (origin.kind === \"module\" && clientModuleDecls.has(origin.decl)) ||\n (origin.kind === \"import\" &&\n origin.usage.cls !== \"neutral\" &&\n !(origin.usage.cls === \"client-reference\" && isTagRef(id))) ||\n origin.kind === \"browser-global\" ||\n origin.kind === \"unknown\" ||\n (origin.kind === \"component\" && !isTagRef(id))\n ) {\n clientRead = true;\n }\n });\n return !clientRead;\n };\n const isNonTrivial = (j: JNode): boolean => {\n if (subtreeOf(j).length > 1) return true;\n let importedCall = false;\n const visit = (n: ts.Node): void => {\n if (importedCall) return;\n if (ts.isCallExpression(n)) {\n let callee: ts.Expression = n.expression;\n while (ts.isPropertyAccessExpression(callee)) callee = callee.expression;\n if (ts.isIdentifier(callee) && originOf(callee).kind === \"import\") importedCall = true;\n }\n ts.forEachChild(n, visit);\n };\n visit(j.node);\n return importedCall;\n };\n /** Maximal static, non-trivial subtrees reachable from the island root through direct JSX children. */\n const findSlots = (root: JNode): JNode[] => {\n const found: JNode[] = [];\n const visit = (j: JNode): void => {\n for (const child of j.children) {\n const direct = child.fnBetween.length === 0 && child.node.parent === j.node;\n if (!direct) continue;\n if (isStaticSubtree(child)) {\n if (isNonTrivial(child)) found.push(child);\n continue;\n }\n visit(child);\n }\n };\n visit(root);\n return found;\n };\n\n for (const group of groups) {\n const rootNode = group.root.node;\n const rootTag = tagNameText(sf, rootNode);\n const islandUnits = new Set<Unit>([...unitsOfGroup(group)].filter((u) => u.client));\n const props = new Map<string, PropInfo>();\n const valueImports = new Set<ImportBinding>();\n const moduleDecls = new Set<ModuleDecl>();\n let keyAttr: ts.JsxAttribute | undefined;\n\n if (!ts.isJsxFragment(rootNode) && group.root.fnBetween.some((f) => mapCallOf(f))) {\n const attrs = ts.isJsxElement(rootNode)\n ? rootNode.openingElement.attributes\n : rootNode.attributes;\n keyAttr = attrs.properties.find(\n (p): p is ts.JsxAttribute => ts.isJsxAttribute(p) && p.name.getText(sf) === \"key\",\n );\n }\n\n const slotNodes = findSlots(group.root);\n const inSlot = (node: ts.Node): boolean =>\n slotNodes.some((slot) => containsRange(slot.node, node));\n const inIsland = (node: ts.Node): boolean =>\n (containsRange(rootNode, node) &&\n !(keyAttr && containsRange(keyAttr, node)) &&\n !inSlot(node)) ||\n [...islandUnits].some((u) => containsRange(u.node, node));\n\n const pending: ts.Node[] = [rootNode, ...[...islandUnits].map((u) => u.node)];\n const visitedNodes = new Set<ts.Node>();\n const moduleLevelScopes = new Set<ts.Node>();\n const addProp = (id: ts.Identifier, symbol: ts.Symbol): Skip | undefined => {\n const name = symbol.getName();\n const existing = props.get(name);\n if (existing) {\n if (existing.symbol !== symbol) {\n return {\n code: \"unsupported-pattern\",\n message: `two different values named \\`${name}\\` would cross the boundary`,\n location: locOf(ctx, id),\n };\n }\n if (containsRange(rootNode, id) && !containsRange(rootNode, existing.refNode))\n existing.refNode = id;\n return undefined;\n }\n if (name === \"key\" || name === \"ref\") {\n return {\n code: \"unsupported-pattern\",\n message: `a value named \\`${name}\\` can't be passed as a prop`,\n location: locOf(ctx, id),\n };\n }\n props.set(name, { name, symbol, type: checker.getTypeAtLocation(id), refNode: id });\n return undefined;\n };\n\n while (pending.length > 0) {\n const scope = pending.pop() as ts.Node;\n if (visitedNodes.has(scope)) continue;\n visitedNodes.add(scope);\n let failure: Skip | undefined;\n forEachValueRef(scope, (id) => {\n if (failure) return;\n if (keyAttr && containsRange(keyAttr, id)) return;\n if (inSlot(id)) return; // rendered on the server and passed in as JSX\n const origin = originOf(id);\n switch (origin.kind) {\n case \"param\":\n failure = addProp(id, origin.symbol);\n return;\n case \"local\": {\n const unit = origin.unit;\n if (islandUnits.has(unit)) return;\n if (unit.client) {\n failure = {\n code: \"state-spans-component\",\n message: `client-only \\`${id.text}\\` is shared between islands`,\n location: locOf(ctx, id),\n };\n return;\n }\n const type = checker.getTypeAtLocation(id);\n const needsCopy =\n unit.kind === \"function\" ||\n isCallableType(type) ||\n !checkSerializable(checker, type, { primitivesOnly: ctx.isJs }).ok;\n if (needsCopy) {\n islandUnits.add(unit);\n copiedUnits.add(unit);\n pending.push(unit.node);\n } else {\n failure = addProp(id, origin.symbol);\n }\n return;\n }\n case \"inner\":\n if (inIsland(origin.declaration)) return;\n if (\n [...moduleLevelScopes].some((scopeNode) =>\n containsRange(scopeNode, origin.declaration),\n )\n )\n return;\n failure = addProp(id, origin.symbol);\n return;\n case \"module\": {\n const decl = origin.decl;\n if (moduleDecls.has(decl)) return;\n // Inside copied module-level code, names resolve at module scope of the island file,\n // so they're copied too; only references from the component body can become props.\n const fromModuleLevel = moduleLevelScopes.has(scope);\n if (!fromModuleLevel && decl.kind === \"const\" && !clientModuleDecls.has(decl)) {\n const type = checker.getTypeAtLocation(id);\n if (checkSerializable(checker, type, { primitivesOnly: ctx.isJs }).ok) {\n failure = addProp(id, origin.symbol);\n return;\n }\n }\n moduleDecls.add(decl);\n moduleLevelScopes.add(decl.statement);\n pending.push(decl.statement);\n return;\n }\n case \"import\":\n if (origin.usage.cls === \"server-only\") {\n failure = {\n code: \"unsupported-pattern\",\n message: `${id.text} (${origin.binding.specifier}) is server-only but the interactive part uses it`,\n location: locOf(ctx, id),\n };\n return;\n }\n valueImports.add(origin.binding);\n return;\n case \"component\": {\n const target = origin.component;\n if (target === component) {\n failure = {\n code: \"unsupported-pattern\",\n message: \"an island would reference the component itself\",\n location: locOf(ctx, id),\n };\n return;\n }\n if (!isTagRef(id)) {\n failure = {\n code: \"unsupported-pattern\",\n message: `an island uses the component ${id.text} as a value`,\n location: locOf(ctx, id),\n };\n return;\n }\n if (options.wholesale?.has(target)) return; // lives in the island file already\n // A server-safe component rendered inside an island: copy it into the island file.\n const decl = shape.componentDecls.get(target);\n if (!decl || moduleDecls.has(decl)) return;\n moduleDecls.add(decl);\n moduleLevelScopes.add(decl.statement);\n pending.push(decl.statement);\n return;\n }\n case \"browser-global\":\n case \"global\":\n return;\n case \"unknown\":\n failure = {\n code: \"unsupported-pattern\",\n message: `can't resolve \\`${id.text}\\``,\n location: locOf(ctx, id),\n };\n return;\n }\n });\n if (failure) return { ok: false, skip: failure };\n }\n\n for (const prop of props.values()) {\n if (serverActionParams.has(prop.symbol)) continue; // a Server Action reference crosses as-is\n const verdict = checkSerializable(checker, prop.type, { primitivesOnly: ctx.isJs });\n if (\n !verdict.ok &&\n !ctx.isJs &&\n ctx.config.mongoose.autoSerialize &&\n isMongooseLike(checker, prop.type)\n ) {\n const refs: ts.Identifier[] = [];\n for (const scope of [rootNode, ...[...islandUnits].map((u) => u.node)]) {\n forEachValueRef(scope, (id) => {\n if ((keyAttr && containsRange(keyAttr, id)) || inSlot(id)) return;\n if (symbolOfRef(checker, id) === prop.symbol) refs.push(id);\n });\n }\n const picked = pickMongooseFields(checker, prop.name, refs, (t) =>\n checker.typeToString(\n t,\n rootNode,\n ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,\n ),\n );\n if (picked.ok) {\n prop.picked = picked.value;\n continue;\n }\n return skip(\n \"non-serializable-prop\",\n `\\`${prop.name}\\` holds Mongoose/ObjectId data and the island ${picked.reason}`,\n locOf(ctx, prop.refNode),\n );\n }\n if (!verdict.ok) {\n const typeText = checker.typeToString(prop.type, rootNode, ts.TypeFormatFlags.NoTruncation);\n const usedInSpread = isSpreadInside(rootNode, prop.symbol, checker);\n if (ctx.isJs) {\n return skip(\n \"untyped-boundary\",\n `\\`${prop.name}\\` would cross the server/client boundary, but its type in this untyped file (\\`${typeText}\\`) can't be proven serializable`,\n locOf(ctx, prop.refNode),\n );\n }\n return skip(\n usedInSpread ? \"spread-props\" : \"non-serializable-prop\",\n `\\`${prop.name}\\` (type \\`${typeText}\\`) would be passed to a Client Component, but it ${verdict.reason}`,\n locOf(ctx, prop.refNode),\n );\n }\n }\n\n if (keyAttr) {\n let clientKey: ts.Identifier | undefined;\n forEachValueRef(keyAttr, (id) => {\n const origin = originOf(id);\n if (origin.kind === \"local\" && origin.unit.client) clientKey = id;\n });\n if (clientKey)\n return skip(\n \"unsupported-pattern\",\n `the list key reads client-only \\`${clientKey.text}\\``,\n locOf(ctx, clientKey),\n );\n }\n\n islands.push({\n name: \"\",\n root: group.root,\n rootTag,\n keyAttr,\n units: [...islandUnits].sort((a, b) => a.index - b.index),\n props: [...props.values()].sort(\n (a, b) =>\n declarationPos(a.symbol) - declarationPos(b.symbol) || a.name.localeCompare(b.name),\n ),\n valueImports,\n moduleDecls,\n slots: slotNodes.map((j, i) => ({\n j,\n name: slotNodes.length === 1 && !props.has(\"children\") ? \"children\" : `slot${i + 1}`,\n })),\n line: locOf(ctx, rootNode).line,\n });\n }\n\n // ---- which statements leave the server component ---------------------------------------------------\n const removedUnits = new Set<Unit>(clientUnits.filter((u) => u.kind !== \"early-return\"));\n // Copied (non-client) statements stay only if server code still reads them.\n const islandRanges = islands.map((i) => i.root.node);\n const slotRanges = islands.flatMap((i) => i.slots.map((slot) => slot.j.node));\n const inAnySlot = (node: ts.Node): boolean => slotRanges.some((r) => containsRange(r, node));\n const serverReads = (unit: Unit): boolean => {\n let read = false;\n const scan = (scope: ts.Node) =>\n forEachValueRef(scope, (id) => {\n if (read) return;\n if (islandRanges.some((r) => containsRange(r, id)) && !inAnySlot(id)) return;\n const symbol = symbolOfRef(checker, id);\n if (symbol && unit.declares.has(symbol)) read = true;\n });\n for (const root of renderRoots) scan(root);\n for (const cond of earlyReturnConditions) scan(cond);\n for (const other of units) if (other !== unit && !removedUnits.has(other)) scan(other.node);\n // Props are evaluated on the server.\n for (const island of islands)\n for (const prop of island.props) if (unit.declares.has(prop.symbol)) read = true;\n return read;\n };\n for (let changed = true; changed;) {\n changed = false;\n for (const unit of copiedUnits) {\n if (removedUnits.has(unit)) continue;\n if (!serverReads(unit)) {\n removedUnits.add(unit);\n changed = true;\n }\n }\n }\n\n // Module declarations: client-only ones may never stay in the server file.\n const movedModuleDecls = new Set<ModuleDecl>();\n for (const decl of clientModuleDecls) movedModuleDecls.add(decl);\n\n const staticCount = jnodes.filter(\n (j) =>\n !islands.some((i) => isAncestorOrSelf(i.root, j)) ||\n islands.some((i) => i.slots.some((slot) => isAncestorOrSelf(slot.j, j))),\n ).length;\n return ok({\n component,\n islands,\n removedUnits,\n movedModuleDecls,\n staticRatio: totalJsx === 0 ? 0 : staticCount / totalJsx,\n jsxTotal: totalJsx,\n });\n}\n\nfunction declarationPos(symbol: ts.Symbol): number {\n return symbol.declarations?.[0]?.getStart() ?? Number.MAX_SAFE_INTEGER;\n}\n\nfunction containsJsxNode(node: ts.Node): boolean {\n if (isJsxElementLike(node)) return true;\n return ts.forEachChild(node, (c) => (containsJsxNode(c) ? true : undefined)) ?? false;\n}\n\nfunction isTagRef(id: ts.Identifier): boolean {\n let node: ts.Node = id;\n while (ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)\n node = node.parent;\n const parent = node.parent;\n return (\n (ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) &&\n parent.tagName === node\n );\n}\n\nfunction enclosingJNode(node: ts.Node, jnodeOf: Map<ts.Node, JNode>): JNode | undefined {\n let current: ts.Node | undefined = node.parent;\n while (current) {\n const j = jnodeOf.get(current);\n if (j) return j;\n current = current.parent;\n }\n return undefined;\n}\n\nfunction conditionalAncestor(node: ts.Node, stopAt: ts.Node): string | undefined {\n let child: ts.Node = node;\n let current: ts.Node | undefined = node.parent;\n while (current && current !== stopAt) {\n if (ts.isConditionalExpression(current) && child !== current.condition)\n return \"inside a conditional expression\";\n if (\n ts.isBinaryExpression(current) &&\n child === current.right &&\n [\n ts.SyntaxKind.AmpersandAmpersandToken,\n ts.SyntaxKind.BarBarToken,\n ts.SyntaxKind.QuestionQuestionToken,\n ].includes(current.operatorToken.kind)\n ) {\n return \"inside a logical expression\";\n }\n if (ts.isIfStatement(current) || ts.isSwitchStatement(current)) return \"inside a condition\";\n if (ts.isIterationStatement(current, false)) return \"inside a loop\";\n if (ts.isFunctionLike(current)) return \"inside a nested function\";\n child = current;\n current = current.parent;\n }\n return undefined;\n}\n\nfunction isSpreadInside(root: ts.Node, symbol: ts.Symbol, checker: ts.TypeChecker): boolean {\n let found = false;\n const visit = (n: ts.Node): void => {\n if (found) return;\n if (\n (ts.isJsxSpreadAttribute(n) || ts.isSpreadAssignment(n) || ts.isSpreadElement(n)) &&\n ts.isIdentifier(n.expression)\n ) {\n if (checker.getSymbolAtLocation(n.expression) === symbol) found = true;\n }\n ts.forEachChild(n, visit);\n };\n visit(root);\n return found;\n}\n\nfunction describeAnchors(sf: ts.SourceFile, anchors: { j: JNode }[]): string {\n const tags = [...new Set(anchors.map((a) => `<${tagNameText(sf, a.j.node)}>`))];\n return tags.slice(0, 4).join(\", \") + (tags.length > 4 ? \", ...\" : \"\");\n}\n","import { ts } from \"ts-morph\";\nimport { checkSerializable } from \"./serializable.js\";\n\n/**\n * Mongoose / BSON support (opt-in with `mongoose.autoSerialize`). A prop whose type is a\n * Mongoose document or contains an ObjectId isn't serializable, but the island usually reads only a\n * few fields. We pass exactly those fields as a plain object built on the server, converting\n * ObjectIds with String() and keeping Dates as they are.\n */\n\nconst MONGO_TYPES_RE =\n /\\/node_modules\\/(?:\\.pnpm\\/[^/]+\\/node_modules\\/)?(bson|mongodb|mongoose)\\//;\n\nfunction declaredInMongoPackage(symbol: ts.Symbol | undefined): boolean {\n return (symbol?.declarations ?? []).some((d) => MONGO_TYPES_RE.test(d.getSourceFile().fileName));\n}\n\nfunction isObjectIdType(type: ts.Type): boolean {\n const symbol = type.getSymbol() ?? type.aliasSymbol;\n return symbol?.getName() === \"ObjectId\" && declaredInMongoPackage(symbol);\n}\n\n/** True if the type is a Mongoose document or (transitively) contains an ObjectId. */\nexport function isMongooseLike(checker: ts.TypeChecker, type: ts.Type): boolean {\n const seen = new Set<ts.Type>();\n const visit = (t: ts.Type, depth: number): boolean => {\n if (depth > 6 || seen.has(t)) return false;\n seen.add(t);\n if (isObjectIdType(t)) return true;\n if (t.isUnionOrIntersection()) return t.types.some((m) => visit(m, depth + 1));\n if (!(t.flags & ts.TypeFlags.Object)) return false;\n const isDoc =\n t.getProperty(\"$isNew\") !== undefined && declaredInMongoPackage(t.getProperty(\"$isNew\"));\n if (isDoc) return true;\n if (checker.isArrayType(t))\n return checker.getTypeArguments(t as ts.TypeReference).some((a) => visit(a, depth + 1));\n for (const prop of checker.getPropertiesOfType(t).slice(0, 200)) {\n const decl = prop.valueDeclaration ?? prop.declarations?.[0];\n if (!decl || MONGO_TYPES_RE.test(decl.getSourceFile().fileName)) continue;\n if (visit(checker.getTypeOfSymbolAtLocation(prop, decl), depth + 1)) return true;\n }\n return false;\n };\n return visit(type, 0);\n}\n\ntype Leaf = { kind: \"leaf\"; source: string; type: ts.Type; objectId: boolean; nullable: boolean };\ntype Branch = { kind: \"branch\"; fields: Map<string, Leaf | Branch> };\n\nexport type PickedProp = {\n /** Object literal evaluated on the server, e.g. `{ _id: String(post._id), title: post.title }`. */\n serverExpr: string;\n /** TypeScript type of that object, e.g. `{ _id: string; title: string }`. */\n typeText: string;\n};\n\ntype PickResult = { ok: true; value: PickedProp } | { ok: false; reason: string };\n\nfunction stripNullish(type: ts.Type): { type: ts.Type; nullable: boolean } {\n if (!type.isUnion()) return { type, nullable: false };\n const rest = type.types.filter((t) => !(t.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)));\n if (rest.length === type.types.length || rest.length !== 1 || !rest[0])\n return { type, nullable: false };\n return { type: rest[0], nullable: true };\n}\n\n/**\n * Builds the picked object for `name` from its references inside the island. Fails (with a reason)\n * when the island uses the whole object, uses optional chaining or element access on it, or calls\n * ObjectId methods other than toString().\n */\nexport function pickMongooseFields(\n checker: ts.TypeChecker,\n name: string,\n refs: ts.Identifier[],\n printType: (type: ts.Type) => string,\n): PickResult {\n const root: Branch = { kind: \"branch\", fields: new Map() };\n for (const ref of refs) {\n let node: ts.Expression = ref;\n const path: string[] = [];\n let leafType: ts.Type | undefined;\n for (;;) {\n const parent: ts.Node = node.parent;\n if (!ts.isPropertyAccessExpression(parent) || parent.expression !== node) break;\n if (parent.questionDotToken)\n return { ok: false, reason: `uses optional chaining on \\`${name}\\`` };\n path.push(parent.name.text);\n node = parent;\n const type = checker.getTypeAtLocation(node);\n const { type: inner } = stripNullish(type);\n if (isObjectIdType(inner) || checkSerializable(checker, type).ok) {\n leafType = type;\n break;\n }\n }\n if (path.length === 0) {\n return {\n ok: false,\n reason: `uses \\`${name}\\` as a whole (spread, passed on, or iterated), so its fields can't be picked`,\n };\n }\n if (!leafType) {\n return {\n ok: false,\n reason: `reads \\`${name}.${path.join(\".\")}\\`, which isn't serializable even after picking fields`,\n };\n }\n const { type: inner, nullable } = stripNullish(leafType);\n const objectId = isObjectIdType(inner);\n if (objectId) {\n const after = node.parent;\n if (\n ts.isPropertyAccessExpression(after) &&\n after.expression === node &&\n after.name.text !== \"toString\"\n ) {\n return {\n ok: false,\n reason: `calls ObjectId.${after.name.text}() on \\`${name}.${path.join(\".\")}\\`, which a string doesn't have`,\n };\n }\n }\n let branch = root;\n for (const [i, key] of path.entries()) {\n const last = i === path.length - 1;\n const existing = branch.fields.get(key);\n if (last) {\n if (existing?.kind === \"branch\")\n return {\n ok: false,\n reason: `reads \\`${name}.${path.join(\".\")}\\` both as a value and as an object`,\n };\n if (!existing)\n branch.fields.set(key, {\n kind: \"leaf\",\n source: `${name}.${path.join(\".\")}`,\n type: leafType,\n objectId,\n nullable,\n });\n } else {\n if (existing?.kind === \"leaf\")\n return {\n ok: false,\n reason: `reads \\`${name}.${path.slice(0, i + 1).join(\".\")}\\` both as a value and as an object`,\n };\n if (!existing) {\n const next: Branch = { kind: \"branch\", fields: new Map() };\n branch.fields.set(key, next);\n branch = next;\n } else {\n branch = existing;\n }\n }\n }\n }\n\n const render = (node: Branch): { expr: string; type: string } => {\n const exprs: string[] = [];\n const types: string[] = [];\n for (const [key, child] of node.fields) {\n const prop = /^[A-Za-z_$][\\w$]*$/.test(key) ? key : JSON.stringify(key);\n if (child.kind === \"branch\") {\n const inner = render(child);\n exprs.push(`${prop}: ${inner.expr}`);\n types.push(`${prop}: ${inner.type}`);\n } else if (child.objectId) {\n exprs.push(\n child.nullable\n ? `${prop}: ${child.source} == null ? ${child.source} : String(${child.source})`\n : `${prop}: String(${child.source})`,\n );\n types.push(\n `${prop}: ${child.nullable ? `string | ${printNullish(child.type)}` : \"string\"}`,\n );\n } else {\n exprs.push(`${prop}: ${child.source}`);\n types.push(`${prop}: ${printType(child.type)}`);\n }\n }\n return { expr: `{ ${exprs.join(\", \")} }`, type: `{ ${types.join(\"; \")} }` };\n };\n const rendered = render(root);\n return { ok: true, value: { serverExpr: rendered.expr, typeText: rendered.type } };\n}\n\nfunction printNullish(type: ts.Type): string {\n if (!type.isUnion()) return \"null\";\n const parts: string[] = [];\n if (type.types.some((t) => t.flags & ts.TypeFlags.Null)) parts.push(\"null\");\n if (type.types.some((t) => t.flags & ts.TypeFlags.Undefined)) parts.push(\"undefined\");\n return parts.join(\" | \") || \"null\";\n}\n","import { ts } from \"ts-morph\";\n\ntype Verdict = { ok: true } | { ok: false; reason: string };\n\nconst OK: Verdict = { ok: true };\nconst fail = (reason: string): Verdict => ({ ok: false, reason });\n\n/** Built-in object types React can serialize across the server/client boundary. */\nconst BUILTIN_SERIALIZABLE = new Set([\n \"Date\",\n \"ArrayBuffer\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"Float16Array\",\n \"Float32Array\",\n \"Float64Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n \"FormData\",\n]);\n/** Container types whose type arguments must themselves be serializable. */\nconst BUILTIN_CONTAINERS = new Set([\n \"Map\",\n \"ReadonlyMap\",\n \"Set\",\n \"ReadonlySet\",\n \"Promise\",\n \"PromiseLike\",\n \"Array\",\n \"ReadonlyArray\",\n \"Iterable\",\n]);\n/** React element / node types (JSX is serializable). */\nconst REACT_NODE_TYPES = new Set([\n \"ReactElement\",\n \"ReactPortal\",\n \"Element\",\n \"ReactNode\",\n \"AwaitedReactNode\",\n \"JSXElementConstructor\",\n]);\n\ntype SerializableOptions = {\n /** Untyped (.js/.jsx) files: only primitives can be proven. */\n primitivesOnly?: boolean;\n};\n\n/**\n * True if the symbol is declared by a file matching `test` and only augmented by other ambient\n * declarations (e.g. @types/react adds an empty `interface FormData {}` in global.d.ts).\n */\nfunction isFromDeclarationFile(\n symbol: ts.Symbol | undefined,\n test: (fileName: string) => boolean,\n): boolean {\n const decls = symbol?.declarations ?? [];\n return (\n decls.some((d) => test(d.getSourceFile().fileName)) &&\n decls.every((d) => d.getSourceFile().isDeclarationFile)\n );\n}\n\n/** TypeScript's lib files, plus the Node/undici declarations of the same web globals (FormData...). */\nconst isLibFile = (f: string) =>\n /\\/lib\\.[a-z0-9.]*\\.d\\.ts$/.test(f) || /\\/@types\\/node\\//.test(f) || /\\/undici-types\\//.test(f);\nconst isReactTypes = (f: string) => /\\/@types\\/react\\//.test(f) || /\\/react\\/[^/]*\\.d\\.ts$/.test(f);\n\n/**\n * Proves (or refuses) that values of `type` can be passed from a Server Component to a Client\n * Component, following the React \"Serializable types\" rules. Anything the checker can't prove is\n * rejected.\n */\nexport function checkSerializable(\n checker: ts.TypeChecker,\n type: ts.Type,\n options: SerializableOptions = {},\n): Verdict {\n const seen = new Set<ts.Type>();\n\n const visit = (t: ts.Type, depth: number): Verdict => {\n if (depth > 40) return fail(\"is too deeply nested to verify\");\n const flags = t.flags;\n const text = () => checker.typeToString(t);\n\n if (flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {\n const unresolved = \"intrinsicName\" in t && t.intrinsicName === \"error\";\n return fail(\n unresolved\n ? `has the type \\`${text()}\\`, which couldn't be resolved (missing import or generated types?)`\n : `is \\`${text()}\\`, which can't be proven serializable`,\n );\n }\n if (flags & ts.TypeFlags.Never) return fail(\"is `never`\");\n if (\n flags &\n (ts.TypeFlags.StringLike |\n ts.TypeFlags.NumberLike |\n ts.TypeFlags.BooleanLike |\n ts.TypeFlags.BigIntLike |\n ts.TypeFlags.Null |\n ts.TypeFlags.Undefined |\n ts.TypeFlags.Void |\n ts.TypeFlags.EnumLike)\n ) {\n return OK;\n }\n if (options.primitivesOnly)\n return fail(`has the non-primitive type \\`${text()}\\` in an untyped file`);\n // React nodes / elements (JSX) are serializable; check the alias before expanding the union.\n if (\n t.aliasSymbol &&\n REACT_NODE_TYPES.has(t.aliasSymbol.getName()) &&\n isFromDeclarationFile(t.aliasSymbol, isReactTypes)\n ) {\n return OK;\n }\n if (flags & ts.TypeFlags.UniqueESSymbol && isSymbolForDeclaration(t.getSymbol())) return OK;\n if (flags & ts.TypeFlags.ESSymbolLike)\n return fail(\"is a symbol (only Symbol.for symbols are serializable)\");\n if (t.isUnion()) {\n for (const member of t.types) {\n const v = visit(member, depth + 1);\n if (!v.ok) return v;\n }\n return OK;\n }\n if (t.isIntersection()) {\n for (const member of t.types) {\n const v = visit(member, depth + 1);\n if (!v.ok) return v;\n }\n return OK;\n }\n if (flags & ts.TypeFlags.TypeParameter) {\n const constraint = checker.getBaseConstraintOfType(t);\n return constraint && constraint !== t\n ? visit(constraint, depth + 1)\n : fail(`is the unconstrained type parameter \\`${text()}\\``);\n }\n if (!(flags & ts.TypeFlags.Object) && !(flags & ts.TypeFlags.NonPrimitive))\n return fail(`has the type \\`${text()}\\``);\n if (flags & ts.TypeFlags.NonPrimitive)\n return fail(\"is `object`, which can't be proven serializable\");\n\n if (seen.has(t)) return OK; // recursive types: the other branches decide\n seen.add(t);\n\n const symbol = t.getSymbol();\n const aliasSymbol = t.aliasSymbol;\n const name = symbol?.getName();\n\n if (\n (aliasSymbol &&\n REACT_NODE_TYPES.has(aliasSymbol.getName()) &&\n isFromDeclarationFile(aliasSymbol, isReactTypes)) ||\n (name && REACT_NODE_TYPES.has(name) && isFromDeclarationFile(symbol, isReactTypes))\n ) {\n return OK;\n }\n\n if (name && BUILTIN_SERIALIZABLE.has(name) && isFromDeclarationFile(symbol, isLibFile))\n return OK;\n\n if (checker.isArrayType(t) || checker.isTupleType(t)) {\n for (const arg of checker.getTypeArguments(t as ts.TypeReference)) {\n const v = visit(arg, depth + 1);\n if (!v.ok) return fail(`contains an element that ${v.reason}`);\n }\n return OK;\n }\n\n if (name && BUILTIN_CONTAINERS.has(name) && isFromDeclarationFile(symbol, isLibFile)) {\n const args = (t as ts.TypeReference).target\n ? checker.getTypeArguments(t as ts.TypeReference)\n : [];\n for (const arg of args) {\n const v = visit(arg, depth + 1);\n if (!v.ok) return fail(`contains a ${name} value that ${v.reason}`);\n }\n return OK;\n }\n\n if (t.getCallSignatures().length > 0 || t.getConstructSignatures().length > 0) {\n return fail(`is a function (\\`${text()}\\`)`);\n }\n\n // Class instances and built-in/library object types other than the ones above are rejected.\n if (symbol && symbol.flags & ts.SymbolFlags.Class)\n return fail(`is an instance of the class ${name ?? text()}`);\n if (\n symbol &&\n isFromDeclarationFile(symbol, isLibFile) &&\n !(symbol.flags & ts.SymbolFlags.TypeLiteral) &&\n name !== \"__object\"\n ) {\n return fail(`is a built-in \\`${name}\\` object, which React can't serialize`);\n }\n if (symbol && symbol.declarations?.some((d) => ts.isClassLike(d)))\n return fail(`is an instance of the class ${name}`);\n\n // Plain object: every property (and index signature) must be serializable.\n for (const prop of checker.getPropertiesOfType(t)) {\n if (prop.flags & ts.SymbolFlags.Method) return fail(`has the method \\`${prop.getName()}\\``);\n const decl = prop.valueDeclaration ?? prop.declarations?.[0];\n const propType = decl\n ? checker.getTypeOfSymbolAtLocation(prop, decl)\n : checker.getTypeOfSymbol(prop);\n const v = visit(propType, depth + 1);\n if (!v.ok) return fail(`has a property \\`${prop.getName()}\\` that ${v.reason}`);\n }\n for (const info of checker.getIndexInfosOfType(t)) {\n const v = visit(info.type, depth + 1);\n if (!v.ok) return fail(`has index values that ${v.reason}`);\n }\n return OK;\n };\n\n return visit(type, 0);\n}\n\n/** `const KEY = Symbol.for(\"...\")`: a globally registered symbol, which React can serialize. */\nfunction isSymbolForDeclaration(symbol: ts.Symbol | undefined): boolean {\n const decl = symbol?.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer) return false;\n const init = decl.initializer;\n return (\n ts.isCallExpression(init) &&\n ts.isPropertyAccessExpression(init.expression) &&\n ts.isIdentifier(init.expression.expression) &&\n init.expression.expression.text === \"Symbol\" &&\n init.expression.name.text === \"for\"\n );\n}\n\n/** True if values of this type can be called (a function or a union containing one). */\nexport function isCallableType(type: ts.Type): boolean {\n if (type.isUnion()) return type.types.some(isCallableType);\n return type.getCallSignatures().length > 0;\n}\n","import { ts } from \"ts-morph\";\nimport type { ModuleGraph } from \"../project/moduleGraph.js\";\nimport type { FrameworkAdapter } from \"./framework.js\";\nimport { buildImportTable } from \"./importTable.js\";\nimport { FileFacts, findEnvProblem } from \"./taint.js\";\n\ntype SafetyResult = { safe: boolean; reason?: string };\n\n/**\n * Decides whether a project module without a directive can be evaluated and used inside a Server\n * Component: neither it nor anything it imports (stopping at \"use client\" modules, which become\n * client references) may use hooks, event handlers, browser globals, client-only packages,\n * createContext/class components, or server/browser-dependent env values. Memoised per run.\n */\nexport class ModuleSafety {\n private readonly cache = new Map<string, SafetyResult>();\n private readonly inProgress = new Set<string>();\n\n constructor(\n private readonly getProgram: () => ts.Program,\n private readonly graph: ModuleGraph,\n private readonly framework: FrameworkAdapter,\n private readonly serverSafeHooks: ReadonlySet<string>,\n ) {}\n\n check = (file: string): SafetyResult => {\n const cached = this.cache.get(file);\n if (cached) return cached;\n // Cycles: assume safe while the cycle is being evaluated; the other modules decide.\n if (this.inProgress.has(file)) return { safe: true };\n this.inProgress.add(file);\n try {\n const result = this.compute(file);\n this.cache.set(file, result);\n return result;\n } finally {\n this.inProgress.delete(file);\n }\n };\n\n private compute(file: string): SafetyResult {\n const node = this.graph.nodes.get(file);\n const rel = this.graph.rel(file);\n if (!node || !node.inProgram)\n return { safe: false, reason: `${rel} is outside the TypeScript project` };\n if (node.directive === \"use client\")\n return { safe: false, reason: `${rel} is a \"use client\" module` };\n if (node.directive === \"use server\") return { safe: true };\n\n const program = this.getProgram();\n const sf = program.getSourceFile(file);\n if (!sf) return { safe: false, reason: `${rel} is not in the program` };\n const checker = program.getTypeChecker();\n\n for (const statement of sf.statements) {\n if (\n ts.isImportDeclaration(statement) &&\n !statement.importClause &&\n ts.isStringLiteral(statement.moduleSpecifier)\n ) {\n const spec = statement.moduleSpecifier.text;\n if (!/\\.(css|scss|sass|less)$/.test(spec)) {\n return { safe: false, reason: `${rel} has a side-effect import of ${spec}` };\n }\n }\n if (ts.isExportDeclaration(statement) && statement.moduleSpecifier && !statement.isTypeOnly) {\n const edge = this.graph.edgeFor(file, (statement.moduleSpecifier as ts.StringLiteral).text);\n if (edge?.to) {\n const target = this.graph.nodes.get(edge.to);\n if (target?.directive !== \"use client\" && target?.directive !== \"use server\") {\n const inner = this.check(edge.to);\n if (!inner.safe)\n return { safe: false, reason: inner.reason ?? `${rel} re-exports client code` };\n }\n } else if (\n edge?.external &&\n ![\"neutral\", \"server-safe-list\", \"json\", \"asset\", \"use-client-entry\"].includes(\n edge.external.kind,\n )\n ) {\n return { safe: false, reason: `${rel} re-exports ${edge.specifier}` };\n }\n }\n }\n\n const imports = buildImportTable(sf, checker, this.graph);\n const facts = new FileFacts(\n sf,\n checker,\n imports,\n this.framework,\n this.check,\n this.serverSafeHooks,\n );\n const markers = facts.scanMarkers(sf);\n const first = markers[0];\n if (first) {\n const line = sf.getLineAndCharacterOfPosition(first.node.getStart(sf)).line + 1;\n return { safe: false, reason: `${rel}:${line} uses ${first.detail}` };\n }\n const env = findEnvProblem(sf, checker, this.framework);\n if (env) return { safe: false, reason: `${rel} ${env.message}` };\n\n let reason: string | undefined;\n const visit = (n: ts.Node): void => {\n if (reason) return;\n if (ts.isJsxAttribute(n)) {\n const name = n.name.getText(sf);\n if (/^on[A-Z]/.test(name) || name === \"ref\") reason = `${rel} attaches ${name} handlers`;\n }\n if (\n ts.isClassDeclaration(n) &&\n n.heritageClauses?.some((h) => /Component/.test(h.getText(sf)))\n ) {\n reason = `${rel} declares a class component`;\n }\n ts.forEachChild(n, visit);\n };\n visit(sf);\n if (reason) return { safe: false, reason };\n return { safe: true };\n }\n}\n","import { ts } from \"ts-morph\";\nimport type { FrameworkAdapter } from \"./framework.js\";\nimport type { ImportBinding, ImportTable, ProjectModuleSafety, UsageClass } from \"./importTable.js\";\nimport { classifyImportUsage } from \"./importTable.js\";\nimport { HOOK_NAME_RE, calleeName, forEachValueRef, symbolOfRef } from \"./refs.js\";\n\n/** Globals that only exist (or only make sense) in the browser. */\nconst BROWSER_GLOBALS = new Set([\n \"window\",\n \"document\",\n \"localStorage\",\n \"sessionStorage\",\n \"navigator\",\n \"location\",\n \"history\",\n \"matchMedia\",\n \"IntersectionObserver\",\n \"ResizeObserver\",\n \"MutationObserver\",\n \"PerformanceObserver\",\n \"requestAnimationFrame\",\n \"cancelAnimationFrame\",\n \"requestIdleCallback\",\n \"cancelIdleCallback\",\n \"alert\",\n \"confirm\",\n \"prompt\",\n \"self\",\n \"screen\",\n \"innerWidth\",\n \"innerHeight\",\n \"outerWidth\",\n \"outerHeight\",\n \"scrollX\",\n \"scrollY\",\n \"pageXOffset\",\n \"pageYOffset\",\n \"devicePixelRatio\",\n \"visualViewport\",\n \"getComputedStyle\",\n \"getSelection\",\n \"customElements\",\n \"indexedDB\",\n \"caches\",\n \"Notification\",\n \"FileReader\",\n \"Image\",\n \"Audio\",\n \"Worker\",\n \"XMLHttpRequest\",\n \"WebSocket\",\n \"EventSource\",\n \"DOMParser\",\n \"HTMLElement\",\n \"Element\",\n \"CustomEvent\",\n \"KeyboardEvent\",\n \"MouseEvent\",\n \"scrollTo\",\n \"scrollBy\",\n \"print\",\n \"open\",\n \"close\",\n \"postMessage\",\n \"frames\",\n \"parent\",\n \"top\",\n \"opener\",\n \"origin\",\n \"event\",\n \"setTimeout\",\n \"setInterval\",\n \"clearTimeout\",\n \"clearInterval\",\n]);\n\nexport type MarkerKind = \"hook\" | \"browser-global\" | \"client-import\" | \"nondeterministic\";\n\nexport type Marker = {\n kind: MarkerKind;\n node: ts.Node;\n detail: string;\n special?: UsageClass[\"special\"];\n};\n\ntype RefInfo =\n | { kind: \"import\"; binding: ImportBinding; usage: UsageClass }\n | { kind: \"browser-global\"; name: string }\n | { kind: \"global\" }\n | { kind: \"file\"; symbol: ts.Symbol; declaration: ts.Declaration }\n | { kind: \"unknown\" };\n\nfunction isAmbientDeclaration(decl: ts.Declaration): boolean {\n return decl.getSourceFile().isDeclarationFile;\n}\n\n/** Per-file helper that classifies identifiers and finds client-only markers. */\nexport class FileFacts {\n constructor(\n readonly sf: ts.SourceFile,\n readonly checker: ts.TypeChecker,\n readonly imports: ImportTable,\n readonly framework: FrameworkAdapter,\n readonly projectSafety: ProjectModuleSafety,\n readonly serverSafeHooks: ReadonlySet<string>,\n ) {}\n\n classifyRef(id: ts.Identifier): RefInfo {\n const symbol = symbolOfRef(this.checker, id);\n if (!symbol)\n return BROWSER_GLOBALS.has(id.text)\n ? { kind: \"browser-global\", name: id.text }\n : { kind: \"unknown\" };\n const binding = this.imports.bySymbol.get(symbol);\n if (binding) {\n const parent = id.parent;\n const member =\n parent && ts.isPropertyAccessExpression(parent) && parent.expression === id\n ? parent.name.text\n : undefined;\n const asJsxTag =\n (parent &&\n (ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) &&\n parent.tagName === id) ||\n (parent !== undefined &&\n ts.isPropertyAccessExpression(parent) &&\n parent.expression === id &&\n (ts.isJsxOpeningElement(parent.parent) || ts.isJsxSelfClosingElement(parent.parent)) &&\n parent.parent.tagName === parent);\n return {\n kind: \"import\",\n binding,\n usage: classifyImportUsage(binding, member, asJsxTag, this.framework, this.projectSafety),\n };\n }\n const decl = symbol.valueDeclaration ?? symbol.declarations?.[0];\n // Intrinsic globals such as `undefined` and `globalThis` have no declarations.\n if (!decl) return { kind: \"global\" };\n if (decl.getSourceFile() === this.sf) return { kind: \"file\", symbol, declaration: decl };\n if (isAmbientDeclaration(decl)) {\n return BROWSER_GLOBALS.has(id.text) && !(symbol.flags & ts.SymbolFlags.Alias)\n ? { kind: \"browser-global\", name: id.text }\n : { kind: \"global\" };\n }\n return { kind: \"unknown\" };\n }\n\n isHookCall(call: ts.CallExpression): boolean {\n const name = calleeName(call);\n if (!name) return false;\n if (this.serverSafeHooks.has(name)) return false;\n if (HOOK_NAME_RE.test(name)) return true;\n if (name === \"use\") {\n const [arg] = call.arguments;\n if (!arg) return false;\n const type = this.checker.getTypeAtLocation(arg);\n // A Context has Provider/Consumer; use(promise) is fine on the server.\n return (\n type.getProperty(\"Provider\") !== undefined || type.getProperty(\"Consumer\") !== undefined\n );\n }\n return false;\n }\n\n /**\n * Client-only markers under `node`. `stop` prunes subtrees (nested JSX elements when scanning\n * one element's own attributes and children).\n */\n scanMarkers(node: ts.Node, stop?: (n: ts.Node) => boolean): Marker[] {\n const markers: Marker[] = [];\n const visit = (n: ts.Node): void => {\n if (n !== node && stop?.(n)) return;\n if (ts.isCallExpression(n) && this.isHookCall(n)) {\n markers.push({ kind: \"hook\", node: n, detail: `${calleeName(n) ?? \"hook\"}()` });\n }\n const nondeterministic = nondeterministicCall(n);\n if (nondeterministic)\n markers.push({ kind: \"nondeterministic\", node: n, detail: nondeterministic });\n ts.forEachChild(n, visit);\n };\n visit(node);\n forEachValueRef(\n node,\n (id) => {\n const info = this.classifyRef(id);\n if (info.kind === \"browser-global\")\n markers.push({ kind: \"browser-global\", node: id, detail: info.name });\n else if (info.kind === \"import\" && info.usage.cls === \"client-only\") {\n markers.push({\n kind: \"client-import\",\n node: id,\n detail: info.usage.reason,\n special: info.usage.special,\n });\n } else if (info.kind === \"import\" && info.usage.special) {\n markers.push({\n kind: \"client-import\",\n node: id,\n detail: info.usage.reason,\n special: info.usage.special,\n });\n }\n },\n stop,\n );\n return markers;\n }\n}\n\n/** Calls whose result differs between the server render and the browser render. */\nfunction nondeterministicCall(n: ts.Node): string | undefined {\n if (\n ts.isNewExpression(n) &&\n ts.isIdentifier(n.expression) &&\n n.expression.text === \"Date\" &&\n (n.arguments?.length ?? 0) === 0\n ) {\n return \"new Date()\";\n }\n if (\n ts.isCallExpression(n) &&\n ts.isPropertyAccessExpression(n.expression) &&\n ts.isIdentifier(n.expression.expression)\n ) {\n const object = n.expression.expression.text;\n const method = n.expression.name.text;\n if (\n (object === \"Date\" && method === \"now\") ||\n (object === \"Math\" && method === \"random\") ||\n (object === \"performance\" && method === \"now\") ||\n (object === \"crypto\" && (method === \"randomUUID\" || method === \"getRandomValues\"))\n ) {\n return `${object}.${method}()`;\n }\n }\n return undefined;\n}\n\ntype EnvProblem = { node: ts.Node; message: string };\n\n/**\n * Finds reads of environment values that differ between the server and the browser bundle:\n * `process.env.SECRET` is defined on the server but `undefined` in the browser.\n */\nexport function findEnvProblem(\n node: ts.Node,\n checker: ts.TypeChecker,\n framework: FrameworkAdapter,\n): EnvProblem | undefined {\n let problem: EnvProblem | undefined;\n const visit = (n: ts.Node): void => {\n if (problem) return;\n if (ts.isIdentifier(n) && n.text === \"process\" && isGlobalProcess(n, checker)) {\n const parent = n.parent;\n if (\n ts.isPropertyAccessExpression(parent) &&\n parent.expression === n &&\n parent.name.text === \"env\"\n ) {\n const outer = parent.parent;\n if (ts.isPropertyAccessExpression(outer) && outer.expression === parent) {\n const name = outer.name.text;\n if (!framework.isClientVisibleEnv(name)) {\n problem = {\n node: outer,\n message: `reads process.env.${name}, which is defined on the server but not in the browser bundle`,\n };\n }\n return;\n }\n if (\n ts.isElementAccessExpression(outer) &&\n outer.expression === parent &&\n ts.isStringLiteralLike(outer.argumentExpression)\n ) {\n const name = outer.argumentExpression.text;\n if (!framework.isClientVisibleEnv(name)) {\n problem = {\n node: outer,\n message: `reads process.env[\"${name}\"], which is defined on the server but not in the browser bundle`,\n };\n }\n return;\n }\n problem = {\n node: parent,\n message:\n \"reads process.env dynamically; its value differs between the server and the browser\",\n };\n return;\n }\n if (!(ts.isTypeOfExpression(parent) || ts.isTypeQueryNode(parent))) {\n problem = {\n node: n,\n message: \"reads `process`, which differs between the server and the browser\",\n };\n }\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return problem;\n}\n\nfunction isGlobalProcess(id: ts.Identifier, checker: ts.TypeChecker): boolean {\n if (ts.isPropertyAccessExpression(id.parent) && id.parent.name === id) return false;\n const symbol = checker.getSymbolAtLocation(id);\n const decl = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n return !decl || decl.getSourceFile().isDeclarationFile;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { ts } from \"ts-morph\";\nimport type { BindingClass, FrameworkAdapter, FrameworkModuleRule } from \"../analysis/framework.js\";\n\nconst perName = (classify: (name: string) => BindingClass): FrameworkModuleRule => ({\n kind: \"per-name\",\n classify,\n});\nconst hooksClient = (name: string): BindingClass =>\n /^use[A-Z]/.test(name) ? \"client-only\" : \"neutral\";\n\n/** next/navigation functions that work in Server Components (everything else there is a hook). */\nconst NAVIGATION_SERVER_SAFE = new Set([\n \"redirect\",\n \"permanentRedirect\",\n \"notFound\",\n \"forbidden\",\n \"unauthorized\",\n \"RedirectType\",\n \"unstable_rethrow\",\n]);\n\nexport const nextAdapter: FrameworkAdapter = {\n name: \"next\",\n\n classifyModule(specifier) {\n if (specifier === \"next/dynamic\") return { kind: \"dynamic-import\" };\n if (specifier === \"styled-jsx\" || specifier.startsWith(\"styled-jsx/\"))\n return { kind: \"css-in-js\" };\n // Client Components shipped by Next: rendering them from the server is the normal pattern.\n if (\n [\"next/link\", \"next/image\", \"next/script\", \"next/form\", \"next/legacy/image\"].includes(\n specifier,\n )\n ) {\n return perName((name) =>\n name === \"default\" || /^[A-Z]/.test(name) ? \"client-reference\" : \"neutral\",\n );\n }\n if (specifier === \"next/navigation\") {\n return perName((name) => (NAVIGATION_SERVER_SAFE.has(name) ? \"neutral\" : \"client-only\"));\n }\n if (specifier === \"next/router\" || specifier === \"next/head\" || specifier === \"next/amp\") {\n return perName(() => \"client-only\");\n }\n if (\n [\"next/headers\", \"next/server\", \"next/cache\", \"next/after\", \"next/og\"].includes(specifier)\n ) {\n return perName(() => \"server-only\");\n }\n if (specifier.startsWith(\"next/font/\")) return perName(() => \"neutral\");\n if (specifier === \"next\" || specifier === \"next/types\") return perName(hooksClient);\n if (specifier.startsWith(\"next/\")) return perName(() => \"client-only\");\n return undefined;\n },\n\n isClientVisibleEnv(name) {\n return name.startsWith(\"NEXT_PUBLIC_\") || name === \"NODE_ENV\";\n },\n\n mustStayClientFiles: [\"error\", \"global-error\"],\n\n sharedContextHooks: [\n \"usePathname\",\n \"useSearchParams\",\n \"useParams\",\n \"useRouter\",\n \"useSelectedLayoutSegment\",\n \"useSelectedLayoutSegments\",\n ],\n};\n\nconst NEXT_ROUTE_FILE_BASENAMES = [\"page\", \"route\"];\nconst DEFAULT_PAGE_EXTENSIONS = [\"tsx\", \"ts\", \"jsx\", \"js\"];\n\ntype PageExtensionsResult = { ok: true; extensions: string[] } | { ok: false; reason: string };\n\n/**\n * Reads `pageExtensions` from next.config.* without executing it. If the config mentions\n * pageExtensions in a form we can't read statically, we report that instead of guessing.\n */\nexport function readPageExtensions(root: string): PageExtensionsResult {\n const candidates = [\n \"next.config.ts\",\n \"next.config.mjs\",\n \"next.config.js\",\n \"next.config.cjs\",\n \"next.config.mts\",\n ];\n const file = candidates.map((c) => path.join(root, c)).find((f) => existsSync(f));\n if (!file) return { ok: true, extensions: DEFAULT_PAGE_EXTENSIONS };\n const text = readFileSync(file, \"utf8\");\n if (!text.includes(\"pageExtensions\")) return { ok: true, extensions: DEFAULT_PAGE_EXTENSIONS };\n\n const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true);\n let found: string[] | undefined;\n let unreadable = false;\n const visit = (node: ts.Node): void => {\n if (\n (ts.isPropertyAssignment(node) && node.name.getText(sf) === \"pageExtensions\") ||\n (ts.isShorthandPropertyAssignment(node) && node.name.text === \"pageExtensions\")\n ) {\n const init = ts.isPropertyAssignment(node) ? node.initializer : undefined;\n if (\n init &&\n ts.isArrayLiteralExpression(init) &&\n init.elements.every(ts.isStringLiteralLike)\n ) {\n found = init.elements.map((e) => (e as ts.StringLiteralLike).text);\n } else {\n unreadable = true;\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sf);\n if (unreadable || !found) {\n return {\n ok: false,\n reason: `${path.basename(file)} sets pageExtensions in a way that can't be read statically`,\n };\n }\n return { ok: true, extensions: found };\n}\n\n/**\n * True if a generated file at `absPath` could be picked up as a route by Next.js: anything under a\n * `pages/` directory, or an app-router `page`/`route` file for one of the configured extensions.\n */\nexport function couldBecomeRoute(root: string, absPath: string, pageExtensions: string[]): boolean {\n const rel = path.relative(root, absPath).split(path.sep);\n if (rel[0] === \"pages\" || (rel[0] === \"src\" && rel[1] === \"pages\")) return true;\n const base = path.basename(absPath);\n return pageExtensions.some((ext) =>\n NEXT_ROUTE_FILE_BASENAMES.some((name) => base === `${name}.${ext}`),\n );\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport fg from \"fast-glob\";\nimport type { SourceFile } from \"ts-morph\";\nimport { Project, ts } from \"ts-morph\";\n\nconst IGNORED_DIRS = [\n \"node_modules\",\n \".next\",\n \".git\",\n \"dist\",\n \"out\",\n \"build\",\n \"coverage\",\n \".turbo\",\n \".vercel\",\n];\nexport const IGNORE_GLOBS = IGNORED_DIRS.map((d) => `**/${d}/**`);\n\nexport type LoadedProject = {\n project: Project;\n root: string;\n /** tsconfig.json / jsconfig.json used, if any. */\n configFile: string | undefined;\n compilerOptions: ts.CompilerOptions;\n /**\n * Lazy projects (used by the ESLint rule without typed linting) only load the files the\n * analysis touches; this lists every file the tsconfig covers, for the module graph.\n */\n lazyFileNames?: string[];\n};\n\ntype LoadOptions = {\n /** Explicit tsconfig/jsconfig path (default: the one in `root`). */\n tsconfig?: string;\n lazy?: boolean;\n};\n\n/** Compiler options used when the project has no tsconfig/jsconfig (mirrors create-next-app). */\nexport const DEFAULT_COMPILER_OPTIONS: ts.CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n lib: [\"lib.dom.d.ts\", \"lib.dom.iterable.d.ts\", \"lib.esnext.d.ts\"],\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n jsx: ts.JsxEmit.ReactJSX,\n strict: true,\n skipLibCheck: true,\n allowJs: true,\n esModuleInterop: true,\n isolatedModules: true,\n resolveJsonModule: true,\n noEmit: true,\n};\n\n/**\n * Builds one ts-morph Project for the whole run. Path aliases resolve through TypeScript's own\n * module resolution, so `@/lib/x` works exactly as it does for `tsc`.\n */\nexport function loadProject(root: string, options: LoadOptions = {}): LoadedProject {\n const configFile =\n options.tsconfig ??\n [\"tsconfig.json\", \"jsconfig.json\"].map((f) => path.join(root, f)).find((f) => existsSync(f));\n\n if (configFile) {\n const isJsConfig = path.basename(configFile) === \"jsconfig.json\";\n const project = new Project({\n tsConfigFilePath: configFile,\n skipAddingFilesFromTsConfig: options.lazy === true,\n ...(isJsConfig ? { compilerOptions: { allowJs: true, checkJs: false } } : {}),\n });\n const compilerOptions = project.getCompilerOptions();\n if (!options.lazy) return { project, root, configFile, compilerOptions };\n const parsed = ts.parseJsonConfigFileContent(\n ts.readConfigFile(configFile, ts.sys.readFile).config,\n ts.sys,\n path.dirname(configFile),\n isJsConfig ? { allowJs: true } : undefined,\n configFile,\n );\n const lazyFileNames = parsed.fileNames.map((f) => path.resolve(f));\n // Ambient declarations (e.g. `declare module \"*.module.css\"`) apply to every file: load them up front.\n for (const file of lazyFileNames) if (file.endsWith(\".d.ts\")) project.addSourceFileAtPath(file);\n return { project, root, configFile, compilerOptions, lazyFileNames };\n }\n\n const project = new Project({ compilerOptions: DEFAULT_COMPILER_OPTIONS });\n const files = fg.sync([\"**/*.{ts,tsx,js,jsx,mts,cts}\"], {\n cwd: root,\n ignore: IGNORE_GLOBS,\n absolute: true,\n dot: false,\n });\n if (options.lazy)\n return {\n project,\n root,\n configFile: undefined,\n compilerOptions: DEFAULT_COMPILER_OPTIONS,\n lazyFileNames: files.map((f) => path.resolve(f)),\n };\n for (const file of files) project.addSourceFileAtPath(file);\n project.resolveSourceFileDependencies();\n return { project, root, configFile: undefined, compilerOptions: project.getCompilerOptions() };\n}\n\n/**\n * Sets a source file's text byte for byte. ts-morph's `replaceWithText` rewrites every line break\n * as LF, which would turn a CRLF original into an LF one for the rest of the run.\n */\nexport function setSourceText(sf: SourceFile, text: string): void {\n sf.applyTextChanges([{ span: { start: 0, length: sf.getFullText().length }, newText: text }]);\n}\n\n/** In a lazy project, loads the given files (and whatever they import) before analysis. */\nexport function ensureLoaded(loaded: LoadedProject, files: Iterable<string>): void {\n if (!loaded.lazyFileNames) return;\n let added = false;\n for (const file of files) {\n if (!loaded.project.getSourceFile(file) && existsSync(file)) {\n loaded.project.addSourceFileAtPath(file);\n added = true;\n }\n }\n if (added) loaded.project.resolveSourceFileDependencies();\n}\n\n/** Source files that belong to the user's project (not node_modules, not declaration files). */\nexport function projectSourceFiles(loaded: LoadedProject): ts.SourceFile[] {\n return loaded.project\n .getSourceFiles()\n .map((sf) => sf.compilerNode)\n .filter((sf) => !sf.isDeclarationFile && !sf.fileName.includes(\"/node_modules/\"));\n}\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport fg from \"fast-glob\";\nimport { ts } from \"ts-morph\";\nimport { getModuleDirective } from \"../analysis/directives.js\";\nimport type { LoadedProject } from \"./loadProject.js\";\nimport { IGNORE_GLOBS, projectSourceFiles } from \"./loadProject.js\";\nimport type { ModuleEdge, ModuleNode, EdgeKind } from \"./moduleTypes.js\";\nimport type { PackageClassifier } from \"./packages.js\";\n\nconst SOURCE_EXT_RE = /\\.(tsx?|jsx?|mts|cts|mjs|cjs)$/;\n\n/**\n * Import graph over every project module (the whole tsconfig program plus JS/MDX files under the\n * root that the program doesn't cover), with client reachability computed from \"use client\" roots.\n */\nexport class ModuleGraph {\n readonly nodes = new Map<string, ModuleNode>();\n private readonly importers = new Map<string, ModuleEdge[]>();\n /** Client-graph membership: file -> the module it was first reached from (null for \"use client\" roots). */\n private readonly clientParent = new Map<string, string | null>();\n\n constructor(readonly root: string) {}\n\n addNode(node: ModuleNode): void {\n this.nodes.set(node.file, node);\n }\n\n finalize(): void {\n for (const node of this.nodes.values()) {\n for (const edge of node.edges) {\n if (!edge.to) continue;\n const list = this.importers.get(edge.to) ?? [];\n list.push(edge);\n this.importers.set(edge.to, list);\n }\n }\n const queue: string[] = [];\n for (const node of this.nodes.values()) {\n if (node.directive === \"use client\") {\n this.clientParent.set(node.file, null);\n queue.push(node.file);\n }\n }\n while (queue.length > 0) {\n const file = queue.shift() as string;\n for (const edge of this.nodes.get(file)?.edges ?? []) {\n if (!edge.to || edge.kind === \"type\" || this.clientParent.has(edge.to)) continue;\n this.clientParent.set(edge.to, file);\n queue.push(edge.to);\n }\n }\n }\n\n importersOf(file: string): ModuleEdge[] {\n return this.importers.get(file) ?? [];\n }\n\n isClient(file: string): boolean {\n return this.clientParent.has(file);\n }\n\n /** The \"use client\" module that pulls `file` into the client graph, if it's not a root itself. */\n clientRootOf(file: string): string | undefined {\n let current: string | null | undefined = file;\n let guard = 0;\n while (current && guard++ < 10_000) {\n const parent = this.clientParent.get(current);\n if (parent === null) return current;\n current = parent;\n }\n return undefined;\n }\n\n edgesFrom(file: string): ModuleEdge[] {\n return this.nodes.get(file)?.edges ?? [];\n }\n\n edgeFor(file: string, specifier: string): ModuleEdge | undefined {\n return this.edgesFrom(file).find((e) => e.specifier === specifier && e.kind !== \"dynamic\");\n }\n\n rel(file: string): string {\n return path.relative(this.root, file).split(path.sep).join(\"/\");\n }\n}\n\ntype RawImport = { specifier: string; kind: EdgeKind; line: number };\n\nfunction collectImports(sf: ts.SourceFile): RawImport[] {\n const out: RawImport[] = [];\n const lineOf = (node: ts.Node) => sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;\n for (const statement of sf.statements) {\n if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {\n const typeOnly = statement.importClause?.isTypeOnly === true;\n out.push({\n specifier: statement.moduleSpecifier.text,\n kind: typeOnly ? \"type\" : \"static\",\n line: lineOf(statement),\n });\n } else if (\n ts.isExportDeclaration(statement) &&\n statement.moduleSpecifier &&\n ts.isStringLiteral(statement.moduleSpecifier)\n ) {\n out.push({\n specifier: statement.moduleSpecifier.text,\n kind: statement.isTypeOnly ? \"type\" : \"reexport\",\n line: lineOf(statement),\n });\n } else if (\n ts.isImportEqualsDeclaration(statement) &&\n ts.isExternalModuleReference(statement.moduleReference)\n ) {\n const expr = statement.moduleReference.expression;\n if (ts.isStringLiteral(expr))\n out.push({ specifier: expr.text, kind: \"static\", line: lineOf(statement) });\n }\n }\n // import(\"x\"), require(\"x\") and next/dynamic(() => import(\"x\")) anywhere in the file.\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) {\n const [arg] = node.arguments;\n if (arg && ts.isStringLiteralLike(arg)) {\n if (node.expression.kind === ts.SyntaxKind.ImportKeyword)\n out.push({ specifier: arg.text, kind: \"dynamic\", line: lineOf(node) });\n else if (ts.isIdentifier(node.expression) && node.expression.text === \"require\") {\n out.push({ specifier: arg.text, kind: \"static\", line: lineOf(node) });\n }\n }\n }\n if (ts.isImportTypeNode(node)) return;\n ts.forEachChild(node, visit);\n };\n visit(sf);\n return out;\n}\n\nconst MDX_IMPORT_RE = /^\\s*(?:import|export)\\s+(?:[^'\"]*?\\s+from\\s+)?['\"]([^'\"]+)['\"]/gm;\n\nexport function buildModuleGraph(\n loaded: LoadedProject,\n classifier: PackageClassifier,\n): ModuleGraph {\n const graph = new ModuleGraph(loaded.root);\n // Resolve with allowJs so edges into JS files are never lost, whatever the user's tsconfig says.\n const options: ts.CompilerOptions = { ...loaded.compilerOptions, allowJs: true };\n const host: ts.ModuleResolutionHost = ts.sys;\n const cache = ts.createModuleResolutionCache(loaded.root, (f) => f, options);\n\n const resolve = (specifier: string, from: string): string | undefined => {\n const result = ts.resolveModuleName(specifier, from, options, host, cache).resolvedModule;\n if (!result || result.isExternalLibraryImport) return undefined;\n const resolved = path.resolve(result.resolvedFileName);\n if (resolved.includes(`${path.sep}node_modules${path.sep}`) || resolved.endsWith(\".d.ts\"))\n return undefined;\n return resolved;\n };\n\n const addFile = (\n file: string,\n sf: ts.SourceFile | undefined,\n inProgram: boolean,\n mdxText?: string,\n ) => {\n const raw: RawImport[] = sf\n ? collectImports(sf)\n : [...(mdxText ?? \"\").matchAll(MDX_IMPORT_RE)].map((m) => ({\n specifier: m[1] ?? \"\",\n kind: \"static\" as const,\n line: (mdxText ?? \"\").slice(0, m.index).split(\"\\n\").length,\n }));\n const edges: ModuleEdge[] = raw.map((imp) => {\n const to = resolve(imp.specifier, file);\n return {\n from: file,\n specifier: imp.specifier,\n kind: imp.kind,\n to,\n external: to ? undefined : classifier.classify(imp.specifier, file),\n line: imp.line,\n };\n });\n graph.addNode({\n file,\n directive: sf ? getModuleDirective(sf).directive : undefined,\n inProgram,\n edges,\n });\n };\n\n if (loaded.lazyFileNames) {\n // Lazy projects: parse every tsconfig file syntactically (no type checking needed for imports),\n // then follow imports the way TypeScript builds the program: an imported TS file is always part\n // of it, a JS file only with allowJs (edges resolve with allowJs on, so check the project's own).\n const allowJs = loaded.compilerOptions.allowJs === true;\n const queue = [...loaded.lazyFileNames];\n for (const file of queue) {\n if (graph.nodes.has(file) || !SOURCE_EXT_RE.test(file)) continue;\n if (file.endsWith(\".d.ts\") || file.includes(`${path.sep}node_modules${path.sep}`)) continue;\n let text: string;\n try {\n text = readFileSync(file, \"utf8\");\n } catch {\n continue;\n }\n const kind = /\\.(tsx|jsx)$/.test(file)\n ? ts.ScriptKind.TSX\n : /\\.(js|mjs|cjs)$/.test(file)\n ? ts.ScriptKind.JS\n : ts.ScriptKind.TS;\n addFile(file, ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, kind), true);\n for (const edge of graph.nodes.get(file)?.edges ?? []) {\n if (edge.to && (allowJs || !/\\.(jsx?|mjs|cjs)$/.test(edge.to))) queue.push(edge.to);\n }\n }\n } else {\n for (const sf of projectSourceFiles(loaded)) addFile(path.resolve(sf.fileName), sf, true);\n }\n\n // Files the program doesn't cover can still import a component; they count as importers.\n const extra = fg.sync([\"**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts,mdx}\"], {\n cwd: loaded.root,\n ignore: [...IGNORE_GLOBS, \"**/*.d.ts\"],\n absolute: true,\n });\n for (const file of extra.map((f) => path.resolve(f))) {\n if (graph.nodes.has(file)) continue;\n let text: string;\n try {\n text = readFileSync(file, \"utf8\");\n } catch {\n continue;\n }\n if (file.endsWith(\".mdx\")) addFile(file, undefined, false, text);\n else if (SOURCE_EXT_RE.test(file)) {\n const kind = /\\.(tsx|jsx)$/.test(file) ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n addFile(file, ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, kind), false);\n }\n }\n\n graph.finalize();\n return graph;\n}\n","import { existsSync, openSync, readFileSync, readSync, closeSync, statSync } from \"node:fs\";\nimport { builtinModules } from \"node:module\";\nimport path from \"node:path\";\nimport {\n BUILTIN_CLIENT_ONLY_PACKAGES,\n BUILTIN_SERVER_SAFE_PACKAGES,\n CSS_IN_JS_PACKAGES,\n matchesPackageList,\n packageNameOf,\n} from \"../analysis/clientPackages.js\";\nimport type { FrameworkAdapter } from \"../analysis/framework.js\";\nimport type { ExternalKind, ExternalModuleInfo } from \"./moduleTypes.js\";\n\nconst STYLESHEET_RE = /\\.(css|scss|sass|less|styl|pcss)$/;\nconst CSS_MODULE_RE = /\\.module\\.(css|scss|sass|less|styl|pcss)$/;\nconst ASSET_RE = /\\.(svg|png|jpe?g|gif|webp|avif|ico|bmp|mp4|webm|mp3|wav|woff2?|ttf|otf)$/;\n\ntype PackageJson = {\n name?: string;\n main?: string;\n module?: string;\n browser?: unknown;\n exports?: unknown;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n};\n\nexport class PackageClassifier {\n private cache = new Map<string, ExternalModuleInfo>();\n\n constructor(\n private readonly framework: FrameworkAdapter,\n private readonly extraClientOnly: readonly string[],\n ) {}\n\n /** Classifies a non-relative specifier (or an unresolved relative one with an asset extension). */\n classify(specifier: string, fromFile: string): ExternalModuleInfo {\n const key = `${path.dirname(fromFile)}\\0${specifier}`;\n const cached = this.cache.get(key);\n if (cached) return cached;\n const info = {\n specifier,\n packageName: packageNameOf(specifier),\n ...this.compute(specifier, fromFile),\n };\n this.cache.set(key, info);\n return info;\n }\n\n private compute(specifier: string, fromFile: string): { kind: ExternalKind; detail?: string } {\n if (CSS_MODULE_RE.test(specifier)) return { kind: \"css-module\" };\n if (STYLESHEET_RE.test(specifier)) return { kind: \"stylesheet\" };\n if (specifier.endsWith(\".json\")) return { kind: \"json\" };\n if (ASSET_RE.test(specifier)) return { kind: \"asset\" };\n if (specifier.startsWith(\".\") || specifier.startsWith(\"/\")) return { kind: \"unresolved\" };\n\n const name = packageNameOf(specifier);\n if (\n specifier.startsWith(\"node:\") ||\n builtinModules.includes(name) ||\n builtinModules.includes(specifier)\n ) {\n return { kind: \"builtin\" };\n }\n if (name === \"react\") return { kind: \"react\" };\n if (name === \"react-dom\") return { kind: \"react-dom\" };\n if (specifier === \"server-only\") return { kind: \"server-only-marker\" };\n if (specifier === \"client-only\") return { kind: \"client-only-marker\" };\n if (this.framework.classifyModule(specifier)) return { kind: \"framework\" };\n if (matchesPackageList(specifier, CSS_IN_JS_PACKAGES)) return { kind: \"css-in-js\" };\n if (matchesPackageList(specifier, this.extraClientOnly))\n return { kind: \"client-list\", detail: \"clientOnlyPackages config\" };\n if (matchesPackageList(specifier, BUILTIN_SERVER_SAFE_PACKAGES))\n return { kind: \"server-safe-list\" };\n if (matchesPackageList(specifier, BUILTIN_CLIENT_ONLY_PACKAGES)) return { kind: \"client-list\" };\n\n const pkgDir = findPackageDir(name, path.dirname(fromFile));\n if (!pkgDir) return { kind: \"unresolved\", detail: `package ${name} is not installed` };\n const pkg = readPackageJson(pkgDir);\n if (!pkg) return { kind: \"unresolved\", detail: `can't read ${name}/package.json` };\n\n const entry = resolveEntry(pkgDir, pkg, specifier.slice(name.length));\n if (entry && startsWithUseClient(entry)) return { kind: \"use-client-entry\" };\n\n const deps = { ...pkg.dependencies, ...pkg.peerDependencies, ...pkg.optionalDependencies };\n if (\"react\" in deps || \"react-dom\" in deps || \"next\" in deps || \"preact\" in deps) {\n return {\n kind: \"react-unknown\",\n detail: `${name} depends on React and isn't known to be server-safe`,\n };\n }\n return { kind: \"neutral\" };\n }\n}\n\nfunction findPackageDir(name: string, fromDir: string): string | undefined {\n let dir = fromDir;\n for (;;) {\n const candidate = path.join(dir, \"node_modules\", name);\n if (existsSync(path.join(candidate, \"package.json\"))) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\nfunction readPackageJson(dir: string): PackageJson | undefined {\n try {\n return JSON.parse(readFileSync(path.join(dir, \"package.json\"), \"utf8\")) as PackageJson;\n } catch {\n return undefined;\n }\n}\n\nconst CONDITIONS = [\"browser\", \"import\", \"module\", \"default\", \"require\"];\n\nfunction pickConditional(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n for (const v of value) {\n const picked = pickConditional(v);\n if (picked) return picked;\n }\n return undefined;\n }\n if (value && typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n for (const condition of CONDITIONS) {\n if (condition in record) {\n const picked = pickConditional(record[condition]);\n if (picked) return picked;\n }\n }\n }\n return undefined;\n}\n\n/** Minimal package entry resolution, enough to read the first bytes of the file a bundler would use. */\nfunction resolveEntry(pkgDir: string, pkg: PackageJson, subpath: string): string | undefined {\n const key = subpath ? `.${subpath}` : \".\";\n let target: string | undefined;\n if (pkg.exports !== undefined) {\n const exportsField = pkg.exports;\n const isSubpathMap =\n exportsField !== null &&\n typeof exportsField === \"object\" &&\n !Array.isArray(exportsField) &&\n Object.keys(exportsField).some((k) => k.startsWith(\".\"));\n if (isSubpathMap) {\n const map = exportsField as Record<string, unknown>;\n if (key in map) target = pickConditional(map[key]);\n else {\n for (const [pattern, value] of Object.entries(map)) {\n const star = pattern.indexOf(\"*\");\n if (star === -1) continue;\n const prefix = pattern.slice(0, star);\n const suffix = pattern.slice(star + 1);\n if (key.startsWith(prefix) && key.endsWith(suffix)) {\n const matched = key.slice(prefix.length, key.length - suffix.length);\n target = pickConditional(value)?.replace(\"*\", matched);\n break;\n }\n }\n }\n } else if (key === \".\") {\n target = pickConditional(exportsField);\n }\n } else if (key === \".\") {\n target = pkg.module ?? pkg.main ?? \"index.js\";\n } else {\n target = subpath.slice(1);\n }\n if (!target) return undefined;\n const base = path.join(pkgDir, target);\n for (const candidate of [base, `${base}.js`, `${base}.mjs`, path.join(base, \"index.js\")]) {\n if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;\n }\n return undefined;\n}\n\nfunction startsWithUseClient(file: string): boolean {\n let fd: number | undefined;\n try {\n fd = openSync(file, \"r\");\n const buffer = Buffer.alloc(1024);\n const read = readSync(fd, buffer, 0, buffer.length, 0);\n const head = buffer\n .subarray(0, read)\n .toString(\"utf8\")\n .replace(/^\\uFEFF/, \"\")\n .replace(/^(\\s|\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/)*/, \"\");\n return (\n /^(['\"])use client\\1/.test(head) || /^(['\"])use strict\\1;?\\s*(['\"])use client\\2/.test(head)\n );\n } catch {\n return false;\n } finally {\n if (fd !== undefined) closeSync(fd);\n }\n}\n","import MagicString from \"magic-string\";\nimport { ts } from \"ts-morph\";\nimport type { FileShape, ModuleDecl } from \"../analysis/components.js\";\nimport type { AnalysisContext } from \"../analysis/context.js\";\nimport { locOf } from \"../analysis/context.js\";\nimport { getModuleDirective } from \"../analysis/directives.js\";\nimport type { ImportBinding, ImportTable } from \"../analysis/importTable.js\";\nimport type { ComponentPlan, IslandPlan, Unit } from \"../analysis/islands.js\";\nimport { islandBaseName } from \"../analysis/islands.js\";\nimport {\n containsRange,\n forEachIdentifier,\n forEachValueRef,\n symbolOfRef,\n} from \"../analysis/refs.js\";\nimport type { Outcome } from \"../analysis/skip.js\";\nimport { ok, skip } from \"../analysis/skip.js\";\nimport type { CodeStyle } from \"./text.js\";\nimport {\n detectStyle,\n hasMultilineLiteral,\n indentationOfLine,\n lineEndOf,\n lineStartOf,\n reindent,\n statementLineRange,\n} from \"./text.js\";\nimport { TypeRefCollector } from \"./typeRefs.js\";\n\ntype EmitInput = {\n ctx: AnalysisContext;\n shape: FileShape;\n imports: ImportTable;\n plans: ComponentPlan[];\n /** Specifier used by the server file to import the islands, e.g. \"./PostCard.client\". */\n islandSpecifier: string;\n /** Specifier used by the island file to import exported types from the original, e.g. \"./PostCard\". */\n originalSpecifier: string;\n /** Rewrites a relative specifier of the original file so it works from the island file. */\n rebaseSpecifier: (specifier: string) => string;\n /** Non-exported, fully interactive components that move wholesale into the island file. */\n movedComponents?: ModuleDecl[];\n /** Island renames: default name -> chosen name. */\n renames?: Readonly<Record<string, string>>;\n};\n\ntype EmitOutput = { serverText: string; islandText: string; islands: IslandPlan[] };\n\ntype Range = { start: number; end: number };\n\nfunction mergeRanges(ranges: Range[]): Range[] {\n const sorted = [...ranges].sort((a, b) => a.start - b.start);\n const out: Range[] = [];\n for (const r of sorted) {\n const last = out[out.length - 1];\n if (last && r.start <= last.end) last.end = Math.max(last.end, r.end);\n else out.push({ ...r });\n }\n return out;\n}\n\nconst inAny = (ranges: Range[], pos: number) => ranges.some((r) => pos >= r.start && pos < r.end);\n\n/**\n * Assigns deterministic island names: <Component><PascalCase root tag>, then 2, 3... on collision.\n * `renames` maps a default name to a user-chosen one (interactive mode).\n */\nfunction assignNames(\n plans: ComponentPlan[],\n taken: Set<string>,\n renames: Readonly<Record<string, string>>,\n): string | undefined {\n // Default names first, so a rename never shifts another island's default name.\n const islands = plans.flatMap((plan) => plan.islands.map((island) => ({ plan, island })));\n for (const { plan, island } of islands) {\n const base = islandBaseName(plan.component.name, island.rootTag);\n let name = base;\n for (let n = 2; taken.has(name); n++) name = `${base}${n}`;\n taken.add(name);\n island.name = name;\n }\n for (const { island } of islands) {\n const renamed = renames[island.name];\n if (renamed === undefined || renamed === island.name) continue;\n if (!/^[A-Z][A-Za-z0-9_$]*$/.test(renamed)) return `\"${renamed}\" is not a valid component name`;\n if (taken.has(renamed)) return `\"${renamed}\" is already used in this file`;\n taken.delete(island.name);\n taken.add(renamed);\n island.name = renamed;\n }\n return undefined;\n}\n\nfunction importClauseText(\n entries: { binding: ImportBinding; typeOnly: boolean }[],\n allTypeOnly: boolean,\n): string {\n const def = entries.find((e) => e.binding.imported === \"default\");\n const ns = entries.find((e) => e.binding.imported === \"*\");\n const named = entries.filter(\n (e) => e.binding.imported !== \"default\" && e.binding.imported !== \"*\",\n );\n const parts: string[] = [];\n if (def) parts.push(def.binding.local);\n if (ns) parts.push(`* as ${ns.binding.local}`);\n if (named.length > 0) {\n const items = named.map((e) => {\n const prefix = e.typeOnly && !allTypeOnly ? \"type \" : \"\";\n const name =\n e.binding.imported === e.binding.local\n ? e.binding.local\n : `${e.binding.imported} as ${e.binding.local}`;\n return prefix + name;\n });\n parts.push(`{ ${items.join(\", \")} }`);\n }\n return parts.join(\", \");\n}\n\nfunction importStatement(\n decl: ts.ImportDeclaration,\n sf: ts.SourceFile,\n entries: { binding: ImportBinding; typeOnly: boolean }[],\n style: CodeStyle,\n specifierText: string,\n): string[] {\n const allTypeOnly = entries.every((e) => e.typeOnly);\n const attributes = decl.attributes ? ` ${decl.attributes.getText(sf)}` : \"\";\n const semi = style.semi ? \";\" : \"\";\n const def = entries.find((e) => e.binding.imported === \"default\");\n const rest = entries.filter((e) => e !== def);\n // `import type X, { Y }` is invalid; split default and named when both are type-only.\n if (allTypeOnly && def && rest.length > 0) {\n return [\n `import type ${def.binding.local} from ${specifierText}${attributes}${semi}`,\n `import type ${importClauseText(rest, true)} from ${specifierText}${attributes}${semi}`,\n ];\n }\n return [\n `import ${allTypeOnly ? \"type \" : \"\"}${importClauseText(entries, allTypeOnly)} from ${specifierText}${attributes}${semi}`,\n ];\n}\n\n/** Produces the rewritten server file and the generated island file. */\nexport function emitSplit(input: EmitInput): Outcome<EmitOutput> {\n const { ctx, shape, imports, plans } = input;\n const { sf, checker } = ctx;\n const text = sf.text;\n const style = detectStyle(sf);\n const q = style.quote;\n const semi = style.semi ? \";\" : \"\";\n\n // ---- names ----------------------------------------------------------------------------------\n const taken = new Set<string>();\n for (const b of imports.bindings) taken.add(b.local);\n for (const d of shape.moduleDecls) d.names.forEach((n) => taken.add(n));\n for (const c of shape.components) taken.add(c.name);\n const nameProblem = assignNames(plans, taken, input.renames ?? {});\n if (nameProblem) return skip(\"unsupported-pattern\", nameProblem);\n const islands = plans.flatMap((p) => p.islands);\n\n // ---- island file -----------------------------------------------------------------------------\n const islandContent: ts.Node[] = islands.flatMap((i) => [\n i.root.node,\n ...i.units.map((u) => u.node),\n ]);\n const collector = new TypeRefCollector(sf, checker, imports, shape.moduleDecls, islandContent);\n const valueImports = new Set<ImportBinding>();\n const movedComponents = input.movedComponents ?? [];\n const copiedDecls = new Set<ModuleDecl>(movedComponents);\n for (const decl of movedComponents) islandContent.push(decl.statement);\n for (const island of islands) {\n island.valueImports.forEach((b) => valueImports.add(b));\n island.moduleDecls.forEach((d) => copiedDecls.add(d));\n }\n // Values referenced by copied module declarations (helpers, constants and whole components).\n const allDecls = [...shape.moduleDecls, ...shape.componentDecls.values()];\n for (const decl of copiedDecls)\n if (decl.component && !islandContent.includes(decl.statement))\n islandContent.push(decl.statement);\n const declQueue = [...copiedDecls];\n while (declQueue.length > 0) {\n const decl = declQueue.pop() as ModuleDecl;\n let failure: string | undefined;\n forEachValueRef(decl.statement, (id) => {\n const symbol = symbolOfRef(checker, id);\n if (!symbol) return;\n const binding = imports.bySymbol.get(symbol);\n if (binding) {\n valueImports.add(binding);\n return;\n }\n const d = symbol.declarations?.[0];\n if (!d || d.getSourceFile() !== sf || containsRange(decl.statement, d)) return;\n const other = allDecls.find((m) => containsRange(m.statement, d));\n if (other && !copiedDecls.has(other)) {\n copiedDecls.add(other);\n if (other.component) islandContent.push(other.statement);\n declQueue.push(other);\n } else if (!other) {\n failure = `copied helper refers to \\`${id.text}\\`, which can't be moved`;\n }\n });\n if (failure) return skip(\"unsupported-pattern\", failure, locOf(ctx, decl.statement));\n }\n\n const slotNodes: ts.Node[] = islands.flatMap((i) => i.slots.map((slot) => slot.j.node));\n for (const node of islandContent) {\n const failure = collector.collectFromNode(node, slotNodes);\n if (failure)\n return skip(\n \"unsupported-pattern\",\n failure.message,\n failure.node ? locOf(ctx, failure.node) : undefined,\n );\n }\n for (const decl of copiedDecls) {\n const failure = collector.collectFromNode(decl.statement);\n if (failure) return skip(\"unsupported-pattern\", failure.message, locOf(ctx, decl.statement));\n }\n\n // Slots are typed as ReactNode: reuse the file's own React import when there is one.\n const extraTypeImports = new Map<string, string[]>();\n let reactNodeType = \"ReactNode\";\n if (!ctx.isJs && islands.some((i) => i.slots.length > 0)) {\n const fromReact = (b: ImportBinding) =>\n b.module.kind === \"external\" && b.module.info.kind === \"react\";\n const named = imports.bindings.find((b) => fromReact(b) && b.imported === \"ReactNode\");\n const namespace = imports.bindings.find(\n (b) => fromReact(b) && (b.imported === \"*\" || b.imported === \"default\"),\n );\n if (named) {\n reactNodeType = named.local;\n collector.deps.imports.add(named);\n } else if (namespace) {\n reactNodeType = `${namespace.local}.ReactNode`;\n collector.deps.imports.add(namespace);\n } else if (taken.has(\"ReactNode\")) {\n return skip(\n \"unsupported-pattern\",\n \"`ReactNode` is already declared in this file, so slot props can't be typed\",\n );\n } else {\n extraTypeImports.set(\"react\", [\"ReactNode\"]);\n }\n }\n\n const signatures = new Map<IslandPlan, string>();\n for (const island of islands) {\n if (island.props.length === 0 && island.slots.length === 0) {\n signatures.set(island, \"\");\n continue;\n }\n const names = [\n ...island.props.map((p) => p.name),\n ...island.slots.map((slot) => slot.name),\n ].join(\", \");\n if (ctx.isJs) {\n signatures.set(island, `{ ${names} }`);\n continue;\n }\n const members: string[] = [];\n for (const prop of island.props) {\n if (prop.picked) {\n const result = collector.collectFromPrinted(prop.picked.typeText, island.root.node);\n if (\"message\" in result)\n return skip(\n \"unsupported-pattern\",\n `prop \\`${prop.name}\\`: ${result.message}`,\n locOf(ctx, prop.refNode),\n );\n members.push(`${prop.name}: ${result.text}`);\n continue;\n }\n const printed = checker.typeToString(\n prop.type,\n island.root.node,\n ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,\n );\n const result = collector.collectFromPrinted(printed, island.root.node);\n if (\"message\" in result)\n return skip(\n \"unsupported-pattern\",\n `prop \\`${prop.name}\\`: ${result.message}`,\n locOf(ctx, prop.refNode),\n );\n members.push(`${prop.name}: ${result.text}`);\n }\n for (const slot of island.slots) members.push(`${slot.name}: ${reactNodeType}`);\n signatures.set(island, `{ ${names} }: { ${members.join(\"; \")} }`);\n }\n\n const allCopied = new Set<ModuleDecl>([...copiedDecls]);\n for (const decl of collector.deps.moduleDecls) if (!decl.exported) allCopied.add(decl);\n const exportedTypeImports = [...collector.deps.moduleDecls]\n .filter((d) => d.exported)\n .flatMap((d) => d.names);\n\n const islandLines: string[] = [];\n const directiveQuote = q;\n islandLines.push(`${directiveQuote}use client${directiveQuote}${semi}`);\n for (const decl of imports.declarations) {\n const entries: { binding: ImportBinding; typeOnly: boolean }[] = [];\n for (const binding of imports.bindings) {\n if (binding.declaration !== decl) continue;\n const usedAsValue = valueImports.has(binding);\n const usedAsType = collector.deps.imports.has(binding);\n if (!usedAsValue && !usedAsType) continue;\n entries.push({ binding, typeOnly: binding.typeOnly || !usedAsValue });\n }\n if (entries.length === 0) continue;\n const spec = decl.moduleSpecifier as ts.StringLiteral;\n const rebased = input.rebaseSpecifier(spec.text);\n const specText = rebased === spec.text ? spec.getText(sf) : `${q}${rebased}${q}`;\n const all = imports.bindings.filter((b) => b.declaration === decl);\n const sameAsOriginal =\n rebased === spec.text &&\n entries.length === all.length &&\n entries.every((e) => e.typeOnly === e.binding.typeOnly);\n const extra = extraTypeImports.get(spec.text);\n if (\n extra &&\n !entries.every((e) => e.typeOnly) &&\n decl.importClause?.namedBindings &&\n !ts.isNamespaceImport(decl.importClause.namedBindings)\n ) {\n extraTypeImports.delete(spec.text);\n const clause = importClauseText(entries, false).replace(\n / \\}$/,\n `, ${extra.map((n) => `type ${n}`).join(\", \")} }`,\n );\n islandLines.push(\n `import ${clause} from ${specText}${decl.attributes ? ` ${decl.attributes.getText(sf)}` : \"\"}${semi}`,\n );\n continue;\n }\n if (sameAsOriginal) islandLines.push(decl.getText(sf));\n else islandLines.push(...importStatement(decl, sf, entries, style, specText));\n }\n for (const [spec, names] of extraTypeImports) {\n islandLines.push(`import type { ${names.join(\", \")} } from ${q}${spec}${q}${semi}`);\n }\n if (exportedTypeImports.length > 0) {\n islandLines.push(\n `import type { ${exportedTypeImports.join(\", \")} } from ${q}${input.originalSpecifier}${q}${semi}`,\n );\n }\n for (const [spec, names] of collector.deps.synthetic) {\n islandLines.push(`import type { ${[...names].join(\", \")} } from ${q}${spec}${q}${semi}`);\n }\n\n const blocks: string[] = [islandLines.join(\"\\n\")];\n const moved = new Set(movedComponents);\n for (const decl of [...allDecls].sort(\n (a, b) => a.statement.getStart(sf) - b.statement.getStart(sf),\n )) {\n if (!allCopied.has(decl)) continue;\n let declText = statementSource(decl.statement, sf);\n if (decl.component) declText = withoutExportModifiers(decl.statement, sf);\n if (moved.has(decl)) declText = `export ${declText}`;\n blocks.push(declText);\n }\n\n for (const island of islands) {\n blocks.push(renderIsland(island, signatures.get(island) ?? \"\", sf, style));\n }\n const islandText = `${blocks.join(\"\\n\\n\")}\\n`;\n\n // ---- server file -------------------------------------------------------------------------------\n const ms = new MagicString(text);\n const removed: Range[] = [];\n\n const directive = getModuleDirective(sf).statement;\n if (directive) {\n let end = directive.getEnd();\n while (end < text.length && /\\s/.test(text[end] ?? \"\")) end++;\n removed.push({ start: directive.getStart(sf), end });\n }\n\n // Body statements that leave the server component.\n const unitRanges: Range[] = [];\n for (const plan of plans) {\n for (const unit of plan.removedUnits) unitRanges.push(statementLineRange(sf, unit.node));\n }\n for (const r of mergeRanges(unitRanges)) removed.push(collapseBlankLines(text, r));\n\n // Module declarations that move entirely (client-only helpers) or are no longer used on the server.\n const replacedRoots: Range[] = islands.map((i) => ({\n start: i.root.node.getStart(sf),\n end: i.root.node.getEnd(),\n }));\n // Slots are re-emitted in the server file, so references inside them still count there.\n const keptInside: Range[] = slotNodes.map((n) => ({ start: n.getStart(sf), end: n.getEnd() }));\n const moduleRemovals = new Set<ModuleDecl>();\n for (const plan of plans) plan.movedModuleDecls.forEach((d) => moduleRemovals.add(d));\n // Wholesale components leave the server file and are imported back from the island file.\n for (const decl of movedComponents) {\n removed.push(collapseBlankLines(text, statementLineRange(sf, decl.statement)));\n }\n const baseRemoved = () => [\n ...removed,\n ...replacedRoots,\n ...[...moduleRemovals].map((d) => statementLineRange(sf, d.statement)),\n ];\n for (let changed = true; changed;) {\n changed = false;\n for (const decl of allCopied) {\n if (moduleRemovals.has(decl) || decl.exported || moved.has(decl)) continue;\n if (!isReferencedOutside(decl, sf, checker, baseRemoved(), keptInside)) {\n moduleRemovals.add(decl);\n changed = true;\n }\n }\n }\n for (const decl of moduleRemovals) {\n if (isReferencedOutside(decl, sf, checker, baseRemoved(), keptInside)) {\n return skip(\n \"unsupported-pattern\",\n `client-only helper ${decl.names.join(\", \")} is still used by the server part`,\n locOf(ctx, decl.statement),\n );\n }\n removed.push(collapseBlankLines(text, statementLineRange(sf, decl.statement)));\n }\n\n // Imports: keep only what the server part still references.\n const allRemoved = [...removed, ...replacedRoots];\n const keyRanges: Range[] = islands.flatMap((i) =>\n i.keyAttr ? [{ start: i.keyAttr.getStart(sf), end: i.keyAttr.getEnd() }] : [],\n );\n const remainingUse = new Map<ImportBinding, { value: boolean; type: boolean }>();\n forEachIdentifier(sf, (id) => {\n const pos = id.getStart(sf);\n if (inAny(allRemoved, pos) && !inAny(keyRanges, pos) && !inAny(keptInside, pos)) return;\n const symbol = symbolOfRef(checker, id);\n const binding = symbol ? imports.bySymbol.get(symbol) : undefined;\n if (!binding) return;\n if (containsRange(binding.declaration, id)) return;\n const use = remainingUse.get(binding) ?? { value: false, type: false };\n if (isInTypePosition(id)) use.type = true;\n else use.value = true;\n remainingUse.set(binding, use);\n });\n\n let lastKeptImport: ts.ImportDeclaration | undefined;\n for (const decl of imports.declarations) {\n const all = imports.bindings.filter((b) => b.declaration === decl);\n if (!decl.importClause) {\n lastKeptImport = decl; // side-effect imports (CSS) stay with the server component\n continue;\n }\n const kept = all.filter((b) => remainingUse.has(b));\n const range = statementLineRange(sf, decl);\n if (kept.length === 0) {\n removed.push(range);\n ms.remove(range.start, range.end);\n continue;\n }\n lastKeptImport = decl;\n const valueUsed = kept.some((b) => remainingUse.get(b)?.value && !b.typeOnly);\n const moduleIsNeutral = kept.every((b) => isNeutralModule(b));\n const needsTypeOnly = !valueUsed && !decl.importClause.isTypeOnly && !moduleIsNeutral;\n if (kept.length === all.length && !needsTypeOnly) continue;\n const entries = kept.map((b) => ({ binding: b, typeOnly: b.typeOnly || needsTypeOnly }));\n const spec = (decl.moduleSpecifier as ts.StringLiteral).getText(sf);\n ms.overwrite(\n decl.getStart(sf),\n decl.getEnd(),\n importStatement(decl, sf, entries, style, spec).join(\"\\n\"),\n );\n }\n\n if (directive) ms.remove(directive.getStart(sf), removed[0]?.end ?? directive.getEnd());\n for (const r of mergeRanges(unitRanges)) {\n const collapsed = collapseBlankLines(text, r);\n ms.remove(collapsed.start, collapsed.end);\n }\n for (const decl of moduleRemovals) {\n const r = collapseBlankLines(text, statementLineRange(sf, decl.statement));\n ms.remove(r.start, r.end);\n }\n\n for (const island of islands) {\n const attrs: string[] = [];\n if (island.keyAttr) attrs.push(island.keyAttr.getText(sf));\n for (const prop of island.props)\n attrs.push(`${prop.name}={${prop.picked ? prop.picked.serverExpr : prop.name}}`);\n const rootStart = island.root.node.getStart(sf);\n const slotIndent = indentationOfLine(text, rootStart) + style.indent;\n const slotSource = (node: ts.Node) => {\n const start = node.getStart(sf);\n const raw = text.slice(start, node.getEnd());\n return hasMultilineLiteral(node, sf)\n ? raw\n : reindent(raw, indentationOfLine(text, start), slotIndent);\n };\n let usage: string;\n const [onlySlot] = island.slots;\n if (island.slots.length === 1 && onlySlot?.name === \"children\") {\n const open = `<${island.name}${attrs.length > 0 ? ` ${attrs.join(\" \")}` : \"\"}>`;\n usage = `${open}\\n${slotIndent}${slotSource(onlySlot.j.node)}\\n${indentationOfLine(text, rootStart)}</${island.name}>`;\n } else {\n for (const slot of island.slots) attrs.push(`${slot.name}={${slotSource(slot.j.node)}}`);\n usage = `<${island.name}${attrs.length > 0 ? ` ${attrs.join(\" \")}` : \"\"} />`;\n }\n ms.overwrite(rootStart, island.root.node.getEnd(), usage);\n }\n\n for (const decl of movedComponents) {\n const r = collapseBlankLines(text, statementLineRange(sf, decl.statement));\n ms.remove(r.start, r.end);\n }\n const importedBack = movedComponents\n .filter((decl) =>\n isReferencedOutside(decl, sf, checker, [...removed, ...replacedRoots], keptInside),\n )\n .flatMap((decl) => decl.names);\n const importNames = [...islands.map((i) => i.name), ...importedBack];\n if (importNames.length === 0)\n return skip(\"unsupported-pattern\", \"nothing would be imported from the island file\");\n const importLine = `import { ${importNames.join(\", \")} } from ${q}${input.islandSpecifier}${q}${semi}`;\n const firstImport = imports.declarations[0];\n if (lastKeptImport) ms.appendLeft(lastKeptImport.getEnd(), `\\n${importLine}`);\n else if (firstImport) {\n // Every import was removed: the island import takes the place of the first one.\n ms.prependRight(statementLineRange(sf, firstImport).start, `${importLine}\\n`);\n } else {\n const firstKept = sf.statements.find((s) => s !== directive && !inAny(removed, s.getStart(sf)));\n const at = firstKept ? lineStartOf(text, firstKept.getStart(sf)) : text.length;\n ms.prependRight(at, `${importLine}\\n\\n`);\n }\n\n return ok({ serverText: ms.toString(), islandText, islands });\n}\n\nfunction statementSource(statement: ts.Statement, sf: ts.SourceFile): string {\n const range = statementLineRange(sf, statement);\n return sf.text.slice(range.start, statement.getEnd()).replace(/^\\s*\\n/, \"\");\n}\n\n/** Statement text (with leading comments) minus `export` / `export default`. */\nfunction withoutExportModifiers(statement: ts.Statement, sf: ts.SourceFile): string {\n const range = statementLineRange(sf, statement);\n const base = range.start;\n const ms = new MagicString(sf.text.slice(base, statement.getEnd()));\n const modifiers = ts.canHaveModifiers(statement) ? (ts.getModifiers(statement) ?? []) : [];\n for (const modifier of modifiers) {\n if (\n modifier.kind !== ts.SyntaxKind.ExportKeyword &&\n modifier.kind !== ts.SyntaxKind.DefaultKeyword\n )\n continue;\n let end = modifier.getEnd();\n while (/\\s/.test(sf.text[end] ?? \"\")) end++;\n ms.remove(modifier.getStart(sf) - base, end - base);\n }\n return ms.toString().replace(/^\\s*\\n/, \"\");\n}\n\nfunction isNeutralModule(binding: ImportBinding): boolean {\n if (binding.module.kind === \"project\") return binding.module.directive !== \"use client\";\n return [\n \"neutral\",\n \"server-safe-list\",\n \"json\",\n \"asset\",\n \"css-module\",\n \"stylesheet\",\n \"react\",\n \"builtin\",\n \"server-only-marker\",\n ].includes(binding.module.info.kind);\n}\n\nfunction isInTypePosition(id: ts.Identifier): boolean {\n let node: ts.Node = id;\n while (node.parent) {\n if (ts.isTypeNode(node.parent) && !ts.isExpressionWithTypeArguments(node.parent)) return true;\n if (ts.isTypeAliasDeclaration(node.parent) || ts.isInterfaceDeclaration(node.parent))\n return true;\n if (ts.isExpression(node.parent) || ts.isStatement(node.parent)) return false;\n node = node.parent;\n }\n return false;\n}\n\nfunction isReferencedOutside(\n decl: ModuleDecl,\n sf: ts.SourceFile,\n checker: ts.TypeChecker,\n removed: Range[],\n kept: Range[] = [],\n): boolean {\n const symbols = new Set<ts.Symbol>();\n for (const name of decl.names) {\n const nameNode = (decl.statement as ts.Statement & { name?: ts.Identifier }).name;\n if (nameNode && ts.isIdentifier(nameNode)) {\n const s = checker.getSymbolAtLocation(nameNode);\n if (s) symbols.add(s);\n }\n if (ts.isVariableStatement(decl.statement)) {\n for (const d of decl.statement.declarationList.declarations) {\n if (ts.isIdentifier(d.name) && d.name.text === name) {\n const s = checker.getSymbolAtLocation(d.name);\n if (s) symbols.add(s);\n }\n }\n }\n }\n let found = false;\n forEachIdentifier(sf, (id) => {\n if (found) return;\n if (containsRange(decl.statement, id)) return;\n const pos = id.getStart(sf);\n if (inAny(removed, pos) && !inAny(kept, pos)) return;\n const symbol = symbolOfRef(checker, id);\n if (symbol && symbols.has(symbol)) found = true;\n });\n return found;\n}\n\n/** Extends a whole-line removal so it doesn't leave a blank line right after `{` or a double blank line. */\nfunction collapseBlankLines(text: string, range: Range): Range {\n const { start } = range;\n let { end } = range;\n const prevLineEnd = start - 1;\n const prevLine = prevLineEnd >= 0 ? text.slice(lineStartOf(text, prevLineEnd), prevLineEnd) : \"\";\n const isBlankAt = (pos: number) =>\n pos < text.length && text.slice(pos, lineEndOf(text, pos)).trim() === \"\";\n if (start > 0 && text[start - 1] === \"\\n\") {\n if (prevLine.trimEnd().endsWith(\"{\") || prevLine.trimEnd().endsWith(\"(\")) {\n while (end < text.length && isBlankAt(end) && text[lineEndOf(text, end)] === \"\\n\")\n end = lineEndOf(text, end) + 1;\n } else if (prevLine.trim() === \"\" && isBlankAt(end) && text[lineEndOf(text, end)] === \"\\n\") {\n end = lineEndOf(text, end) + 1;\n }\n }\n return { start, end };\n}\n\nfunction renderIsland(\n island: IslandPlan,\n signature: string,\n sf: ts.SourceFile,\n style: CodeStyle,\n): string {\n const text = sf.text;\n const semi = style.semi ? \";\" : \"\";\n const ind = style.indent;\n const lines: string[] = [`export function ${island.name}(${signature}) {`];\n // Keep the original's blank lines between moved statements (and after the last one).\n const blankAfter = (node: ts.Node) => {\n const rest = text.slice(node.getEnd());\n const gap = /^[^\\S\\n]*(?:\\/\\/[^\\n]*)?\\n([^\\S\\n]*\\n)/.exec(rest);\n return gap !== null;\n };\n island.units.forEach((unit, i) => {\n lines.push(renderUnit(unit, sf, ind));\n const next = island.units[i + 1];\n const separated = next\n ? /\\n[^\\S\\n]*\\n/.test(text.slice(unit.node.getEnd(), statementLineRange(sf, next.node).start))\n : blankAfter(unit.node);\n if (separated) lines.push(\"\");\n });\n\n const root = island.root.node;\n const rootStart = root.getStart(sf);\n const ms = new MagicString(text);\n for (const slot of island.slots) {\n ms.overwrite(slot.j.node.getStart(sf), slot.j.node.getEnd(), `{${slot.name}}`);\n }\n if (island.keyAttr) {\n let start = island.keyAttr.getStart(sf);\n while (start > 0 && /[ \\t]/.test(text[start - 1] ?? \"\")) start--;\n ms.remove(start, island.keyAttr.getEnd());\n }\n let rootText = ms.slice(rootStart, root.getEnd());\n const multiline = rootText.includes(\"\\n\");\n if (!multiline) {\n lines.push(`${ind}return ${rootText}${semi}`);\n } else {\n if (!hasMultilineLiteral(root, sf))\n rootText = reindent(rootText, indentationOfLine(text, rootStart), ind + ind);\n lines.push(`${ind}return (`, `${ind}${ind}${rootText}`, `${ind})${semi}`);\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\nfunction renderUnit(unit: Unit, sf: ts.SourceFile, ind: string): string {\n const text = sf.text;\n const range = statementLineRange(sf, unit.node);\n const start = range.whole ? range.start : unit.node.getStart(sf);\n let chunk = text.slice(start, unit.node.getEnd());\n const lineIndent = indentationOfLine(text, unit.node.getStart(sf));\n chunk = chunk.replace(/^[ \\t]*/, \"\");\n if (!hasMultilineLiteral(unit.node, sf)) chunk = reindent(chunk, lineIndent, ind);\n return `${ind}${chunk}`;\n}\n","import { ts } from \"ts-morph\";\n\nexport type CodeStyle = { quote: '\"' | \"'\"; semi: boolean; indent: string };\n\n/** Infers quote style, semicolons and indentation unit from the original file. */\nexport function detectStyle(sf: ts.SourceFile): CodeStyle {\n let quote: '\"' | \"'\" = '\"';\n let semi = true;\n const first = sf.statements.find((s) => ts.isImportDeclaration(s) || ts.isExpressionStatement(s));\n if (first) {\n const text = first.getText(sf);\n semi = text.trimEnd().endsWith(\";\");\n const literal = ts.isImportDeclaration(first)\n ? first.moduleSpecifier\n : (first as ts.ExpressionStatement).expression;\n const raw = literal.getText(sf);\n if (raw.startsWith(\"'\")) quote = \"'\";\n }\n // The indentation unit is the smallest indentation used by any line.\n let indent = \" \";\n let smallest = Number.POSITIVE_INFINITY;\n for (const match of sf.text.matchAll(/\\n([ \\t]+)\\S/g)) {\n const ws = match[1] ?? \"\";\n if (ws.startsWith(\"\\t\")) {\n indent = \"\\t\";\n break;\n }\n if (ws.length < smallest) {\n smallest = ws.length;\n indent = \" \".repeat(ws.length);\n }\n }\n return { quote, semi, indent };\n}\n\n/** The file's line ending, from its first line break (as Prettier's `endOfLine: \"auto\"` decides). */\nexport function lineEndingOf(text: string): \"\\r\\n\" | \"\\n\" {\n const i = text.indexOf(\"\\n\");\n return i > 0 && text[i - 1] === \"\\r\" ? \"\\r\\n\" : \"\\n\";\n}\n\n/** True if `text` uses both CRLF and bare LF line breaks. */\nexport function hasMixedLineEndings(text: string): boolean {\n return text.includes(\"\\r\\n\") && /(?:^|[^\\r])\\n/.test(text);\n}\n\n/**\n * Converts every line break to `eol`. Safe for code: template literals and line continuations\n * read CRLF and LF the same, and JSX text treats both as a line break.\n */\nexport function withLineEnding(text: string, eol: \"\\r\\n\" | \"\\n\"): string {\n return text.replace(/\\r?\\n/g, eol);\n}\n\nexport function lineStartOf(text: string, pos: number): number {\n const i = text.lastIndexOf(\"\\n\", pos - 1);\n return i === -1 ? 0 : i + 1;\n}\n\nexport function lineEndOf(text: string, pos: number): number {\n const i = text.indexOf(\"\\n\", pos);\n return i === -1 ? text.length : i;\n}\n\nexport function indentationOfLine(text: string, pos: number): string {\n const start = lineStartOf(text, pos);\n const match = /^[ \\t]*/.exec(text.slice(start));\n return match?.[0] ?? \"\";\n}\n\n/** True if the node contains a string or template literal that spans lines (re-indenting would change it). */\nexport function hasMultilineLiteral(node: ts.Node, sf: ts.SourceFile): boolean {\n let found = false;\n const visit = (n: ts.Node): void => {\n if (found) return;\n if (\n (ts.isTemplateLiteral(n) || ts.isStringLiteral(n) || ts.isNoSubstitutionTemplateLiteral(n)) &&\n n.getText(sf).includes(\"\\n\")\n ) {\n found = true;\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return found;\n}\n\n/** Re-indents lines 2..n of `text` from `fromIndent` to `toIndent` (first line is placed by the caller). */\nexport function reindent(text: string, fromIndent: string, toIndent: string): string {\n const lines = text.split(\"\\n\");\n return lines\n .map((line, i) => {\n if (i === 0) return line;\n if (line.trim() === \"\") return \"\";\n if (line.startsWith(fromIndent)) return toIndent + line.slice(fromIndent.length);\n return toIndent + line.trimStart();\n })\n .join(\"\\n\");\n}\n\n/**\n * The range covering a statement plus its own-line leading comments, extended to whole lines\n * when the statement sits alone on its lines.\n */\nexport function statementLineRange(\n sf: ts.SourceFile,\n node: ts.Node,\n): { start: number; end: number; whole: boolean } {\n const text = sf.text;\n let start = node.getStart(sf);\n const comments = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];\n for (const comment of comments) {\n const before = text.slice(lineStartOf(text, comment.pos), comment.pos);\n if (before.trim() === \"\") {\n start = Math.min(start, comment.pos);\n break;\n }\n }\n const end = node.getEnd();\n const lineStart = lineStartOf(text, start);\n const lineEnd = lineEndOf(text, end);\n const before = text.slice(lineStart, start);\n const after = text.slice(end, lineEnd);\n if (before.trim() === \"\" && after.trim() === \"\") {\n return { start: lineStart, end: Math.min(text.length, lineEnd + 1), whole: true };\n }\n return { start, end, whole: false };\n}\n","import { ts } from \"ts-morph\";\nimport type { ModuleDecl } from \"../analysis/components.js\";\nimport type { ImportBinding, ImportTable } from \"../analysis/importTable.js\";\nimport { containsRange } from \"../analysis/refs.js\";\n\ntype TypeDeps = {\n /** Import bindings needed only as types. */\n imports: Set<ImportBinding>;\n /** Module-level declarations of this file needed by the island (types, or values used via typeof). */\n moduleDecls: Set<ModuleDecl>;\n /** `import type { Name } from \"spec\"` lines synthesised from `import(\"spec\").Name` in printed types. */\n synthetic: Map<string, Set<string>>;\n};\n\ntype TypeRefFailure = { message: string; node?: ts.Node };\n\n/** Leftmost identifiers of every type reference under `node`. */\nfunction typeReferenceHeads(node: ts.Node): ts.Identifier[] {\n const out: ts.Identifier[] = [];\n const head = (name: ts.EntityName | ts.Expression): ts.Identifier | undefined => {\n let current: ts.Node = name;\n while (ts.isQualifiedName(current) || ts.isPropertyAccessExpression(current)) {\n current = ts.isQualifiedName(current) ? current.left : current.expression;\n }\n return ts.isIdentifier(current) ? current : undefined;\n };\n const visit = (n: ts.Node): void => {\n if (ts.isTypeReferenceNode(n)) {\n const id = head(n.typeName);\n if (id) out.push(id);\n } else if (ts.isExpressionWithTypeArguments(n) && ts.isHeritageClause(n.parent)) {\n const id = head(n.expression);\n if (id) out.push(id);\n } else if (ts.isTypeQueryNode(n)) {\n const id = head(n.exprName);\n if (id) out.push(id);\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return out;\n}\n\nexport class TypeRefCollector {\n readonly deps: TypeDeps = { imports: new Set(), moduleDecls: new Set(), synthetic: new Map() };\n\n constructor(\n private readonly sf: ts.SourceFile,\n private readonly checker: ts.TypeChecker,\n private readonly imports: ImportTable,\n private readonly moduleDecls: ModuleDecl[],\n /** Nodes whose declarations travel into the island (their local type names are in scope there). */\n private readonly islandContent: ts.Node[],\n ) {}\n\n private classify(\n symbol: ts.Symbol | undefined,\n name: string,\n node: ts.Node | undefined,\n ): TypeRefFailure | undefined {\n if (!symbol) return undefined; // unresolved names are globals or errors already present in the input\n const binding = this.imports.bySymbol.get(symbol);\n if (binding) {\n this.deps.imports.add(binding);\n return undefined;\n }\n const decl = symbol.declarations?.[0];\n if (!decl) return undefined;\n if (decl.getSourceFile() !== this.sf) return undefined; // global / ambient\n if (this.islandContent.some((c) => containsRange(c, decl))) return undefined;\n let top: ts.Node = decl;\n while (top.parent && top.parent !== this.sf) top = top.parent;\n const moduleDecl = this.moduleDecls.find((d) => d.statement === top);\n if (moduleDecl) {\n if (!this.deps.moduleDecls.has(moduleDecl)) {\n this.deps.moduleDecls.add(moduleDecl);\n if (!moduleDecl.exported) {\n const failure = this.collectFromNode(moduleDecl.statement);\n if (failure) return failure;\n }\n }\n return undefined;\n }\n return {\n message: `the type \\`${name}\\` is declared inside the component and can't be referenced from the island`,\n node,\n };\n }\n\n /** Type names used inside a node that moves into the island. */\n collectFromNode(node: ts.Node, exclude: readonly ts.Node[] = []): TypeRefFailure | undefined {\n for (const id of typeReferenceHeads(node)) {\n if (exclude.some((e) => containsRange(e, id))) continue;\n const failure = this.classify(this.checker.getSymbolAtLocation(id), id.text, id);\n if (failure) return failure;\n }\n return undefined;\n }\n\n /**\n * Type names inside a printed type (from checker.typeToString at `location`). `import(\"x\").Y`\n * forms become `import type { Y } from \"x\"` when x is a package name.\n */\n collectFromPrinted(printed: string, location: ts.Node): { text: string } | TypeRefFailure {\n let text = printed;\n const importTypeRe = /import\\(\"([^\"]+)\"\\)\\.([A-Za-z_$][\\w$]*)/g;\n for (const match of printed.matchAll(importTypeRe)) {\n const spec = match[1] ?? \"\";\n const name = match[2] ?? \"\";\n if (spec.startsWith(\".\") || spec.startsWith(\"/\")) {\n return { message: `can't name the type \\`${name}\\` from ${spec} in the generated file` };\n }\n const names = this.deps.synthetic.get(spec) ?? new Set<string>();\n names.add(name);\n this.deps.synthetic.set(spec, names);\n text = text.replace(match[0], name);\n }\n const parsed = ts.createSourceFile(\n \"__type.ts\",\n `type __T = ${text};`,\n ts.ScriptTarget.Latest,\n true,\n );\n const inScope = new Map<string, ts.Symbol>();\n for (const symbol of this.checker.getSymbolsInScope(\n location,\n ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | ts.SymbolFlags.Alias,\n )) {\n if (!inScope.has(symbol.getName())) inScope.set(symbol.getName(), symbol);\n }\n for (const id of typeReferenceHeads(parsed)) {\n if (id.text === \"__T\") continue;\n if (\n ts.isTypeQueryNode(id.parent) ||\n (ts.isQualifiedName(id.parent) && ts.isTypeQueryNode(id.parent.parent))\n ) {\n return {\n message: `a prop's type refers to the value \\`${id.text}\\` (typeof), which can't be named in the generated file`,\n };\n }\n if ([...this.deps.synthetic.values()].some((s) => s.has(id.text))) continue;\n const symbol = inScope.get(id.text);\n if (!symbol) {\n return {\n message: `can't name the type \\`${id.text}\\` in the generated file (it isn't imported here)`,\n };\n }\n const failure = this.classify(symbol, id.text, undefined);\n if (failure) return failure;\n }\n return { text };\n }\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\ntype PrettierApi = {\n resolveConfigFile(file: string): Promise<string | null>;\n resolveConfig(\n file: string,\n options?: { config?: string },\n ): Promise<Record<string, unknown> | null>;\n format(source: string, options: Record<string, unknown>): Promise<string>;\n};\n\nconst cache = new Map<string, Promise<PrettierApi | undefined>>();\n\n/** Loads the project's own Prettier (never ours), if it has one. */\nfunction loadPrettier(root: string): Promise<PrettierApi | undefined> {\n let pending = cache.get(root);\n if (!pending) {\n pending = (async () => {\n try {\n const require = createRequire(path.join(root, \"package.json\"));\n const entry = require.resolve(\"prettier\");\n const mod = (await import(pathToFileURL(entry).href)) as PrettierApi & {\n default?: PrettierApi;\n };\n // CJS entry points expose the API on `default`.\n return typeof mod.format === \"function\" ? mod : mod.default;\n } catch {\n return undefined;\n }\n })();\n cache.set(root, pending);\n }\n return pending;\n}\n\n/**\n * Formats `text` as `file` with the project's Prettier config. Returns the text unchanged when the\n * project has no Prettier installed or no Prettier config applies to the file.\n */\nexport async function formatWithProjectPrettier(\n root: string,\n file: string,\n text: string,\n): Promise<string> {\n const prettier = await loadPrettier(root);\n if (!prettier) return text;\n const configFile = await prettier.resolveConfigFile(file);\n // Only a config that belongs to this project counts (not one in a parent directory).\n if (!configFile || path.relative(root, configFile).startsWith(\"..\")) return text;\n const options = (await prettier.resolveConfig(file, { config: configFile })) ?? {};\n return prettier.format(text, { ...options, filepath: file });\n}\n","import path from \"node:path\";\nimport { ts } from \"ts-morph\";\nimport { getModuleDirective } from \"../analysis/directives.js\";\nimport type { FrameworkAdapter } from \"../analysis/framework.js\";\nimport { buildImportTable } from \"../analysis/importTable.js\";\nimport type { ModuleSafety } from \"../analysis/moduleSafety.js\";\nimport { isIntrinsicTagName, stripParens } from \"../analysis/refs.js\";\nimport { checkSerializable, isCallableType } from \"../analysis/serializable.js\";\nimport type { Outcome } from \"../analysis/skip.js\";\nimport { ok, skip } from \"../analysis/skip.js\";\nimport { FileFacts } from \"../analysis/taint.js\";\nimport type { LoadedProject } from \"../project/loadProject.js\";\nimport { setSourceText } from \"../project/loadProject.js\";\nimport type { ModuleGraph } from \"../project/moduleGraph.js\";\nimport type { PackageClassifier } from \"../project/packages.js\";\n\ntype SelfCheckInput = {\n loaded: LoadedProject;\n graph: ModuleGraph;\n framework: FrameworkAdapter;\n classifier: PackageClassifier;\n moduleSafety: ModuleSafety;\n serverSafeHooks: ReadonlySet<string>;\n file: string;\n islandFile: string;\n islandSpecifier: string;\n serverText: string;\n islandText: string;\n /** Files whose diagnostics must not change (importers of `file`). */\n importers: string[];\n /** Component props that importers fill with Server Actions; they may cross the boundary. */\n serverActionProps?: ReadonlySet<string>;\n isJs: boolean;\n};\n\ntype DiagKey = string;\n\nfunction diagnosticsOf(\n program: ts.Program,\n sf: ts.SourceFile,\n bucket: string,\n): Map<DiagKey, number> {\n const out = new Map<DiagKey, number>();\n const all = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];\n for (const d of all) {\n const key = `${bucket}|TS${d.code}|${ts.flattenDiagnosticMessageText(d.messageText, \" \")}`;\n out.set(key, (out.get(key) ?? 0) + 1);\n }\n return out;\n}\n\nfunction merge(into: Map<DiagKey, number>, from: Map<DiagKey, number>): void {\n for (const [k, v] of from) into.set(k, (into.get(k) ?? 0) + v);\n}\n\n/**\n * Re-verifies the generated code in memory before anything is reported or written:\n * both files parse, typechecking finds no new diagnostics, the rewritten file has no client-only\n * code left, every island prop is serializable, and the island file has no server-only imports.\n */\nexport function selfCheck(input: SelfCheckInput): Outcome<void> {\n const { loaded, file, islandFile } = input;\n const project = loaded.project;\n const original = project.getSourceFile(file);\n if (!original) return skip(\"self-check-failed\", \"the original file is not in the project\");\n const originalText = original.getFullText();\n\n const before = new Map<DiagKey, number>();\n {\n const program = project.getProgram().compilerObject;\n const sf = program.getSourceFile(file);\n if (sf) merge(before, diagnosticsOf(program, sf, \"self\"));\n for (const importer of input.importers) {\n const isf = program.getSourceFile(importer);\n if (isf) merge(before, diagnosticsOf(program, isf, importer));\n }\n }\n\n let islandWrapper: ReturnType<typeof project.createSourceFile> | undefined;\n try {\n setSourceText(original, input.serverText);\n islandWrapper = project.createSourceFile(islandFile, input.islandText, { overwrite: false });\n const program = project.getProgram().compilerObject;\n const checker = program.getTypeChecker();\n const serverSf = program.getSourceFile(file);\n const islandSf = program.getSourceFile(islandFile);\n if (!serverSf || !islandSf)\n return skip(\"self-check-failed\", \"generated files are missing from the program\");\n\n // 1. Both files parse.\n for (const sf of [serverSf, islandSf]) {\n const syntax = program.getSyntacticDiagnostics(sf);\n const first = syntax[0];\n if (first) {\n return skip(\n \"self-check-failed\",\n `${path.basename(sf.fileName)} doesn't parse: ${ts.flattenDiagnosticMessageText(first.messageText, \" \")}`,\n );\n }\n }\n\n // 2. No new type errors.\n const after = new Map<DiagKey, number>();\n merge(after, diagnosticsOf(program, serverSf, \"self\"));\n merge(after, diagnosticsOf(program, islandSf, \"self\"));\n for (const importer of input.importers) {\n const isf = program.getSourceFile(importer);\n if (isf) merge(after, diagnosticsOf(program, isf, importer));\n }\n const added: string[] = [];\n for (const [key, count] of after) {\n if (count > (before.get(key) ?? 0)) added.push(key.split(\"|\").slice(1).join(\": \"));\n }\n if (added.length > 0) {\n return skip(\n \"self-check-failed\",\n `typechecking the output found new errors: ${added.slice(0, 3).join(\"; \")}`,\n );\n }\n\n // 3. The rewritten file is a Server Component with no client-only code left.\n if (getModuleDirective(serverSf).directive === \"use client\") {\n return skip(\"self-check-failed\", 'the rewritten file still starts with \"use client\"');\n }\n const imports = buildImportTable(serverSf, checker, input.graph);\n const facts = new FileFacts(\n serverSf,\n checker,\n imports,\n input.framework,\n input.moduleSafety.check,\n input.serverSafeHooks,\n );\n const islandSymbols = new Set(\n imports.bindings.filter((b) => b.specifier === input.islandSpecifier).map((b) => b.symbol),\n );\n for (const marker of facts.scanMarkers(serverSf)) {\n if (\n marker.kind === \"client-import\" &&\n islandSymbols.size > 0 &&\n isIslandTag(marker.node, checker, islandSymbols)\n )\n continue;\n return skip(\n \"self-check-failed\",\n `the rewritten file still uses client-only code (${marker.detail})`,\n );\n }\n\n // 4. Every element that crosses into client code gets serializable props.\n let problem: string | undefined;\n const visit = (n: ts.Node): void => {\n if (problem) return;\n if (ts.isJsxOpeningElement(n) || ts.isJsxSelfClosingElement(n)) {\n const intrinsic = isIntrinsicTagName(n.tagName);\n const crossesBoundary =\n !intrinsic && isClientReferenceTag(n.tagName, facts, islandSymbols, checker);\n for (const attr of n.attributes.properties) {\n if (ts.isJsxSpreadAttribute(attr)) {\n if (\n crossesBoundary &&\n !checkSerializable(checker, checker.getTypeAtLocation(attr.expression), {\n primitivesOnly: input.isJs,\n }).ok\n ) {\n problem = `spread props on <${n.tagName.getText(serverSf)}> are not serializable`;\n }\n continue;\n }\n const name = attr.name.getText(serverSf);\n // Event/ref props only matter on DOM elements; component props are checked by value below.\n if (intrinsic && (/^on[A-Z]/.test(name) || name === \"ref\")) {\n problem = `<${n.tagName.getText(serverSf)}> still has ${name}`;\n return;\n }\n const init = attr.initializer;\n if (!init || !ts.isJsxExpression(init) || !init.expression) continue;\n const type = checker.getTypeAtLocation(init.expression);\n const action = isServerActionExpr(init.expression, facts, input.serverActionProps);\n if (isCallableType(type) && !action) {\n problem = `<${n.tagName.getText(serverSf)}> receives a function in ${name}`;\n return;\n }\n if (crossesBoundary && !action) {\n const verdict = checkSerializable(checker, type, { primitivesOnly: input.isJs });\n if (!verdict.ok) {\n problem = `prop ${name} of <${n.tagName.getText(serverSf)}> ${verdict.reason}`;\n return;\n }\n }\n }\n }\n ts.forEachChild(n, visit);\n };\n visit(serverSf);\n if (problem) return skip(\"self-check-failed\", problem);\n\n // 5. The island file imports nothing server-only.\n for (const statement of islandSf.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))\n continue;\n if (statement.importClause?.isTypeOnly) continue;\n const spec = statement.moduleSpecifier.text;\n const resolved = ts.resolveModuleName(\n spec,\n islandFile,\n { ...loaded.compilerOptions, allowJs: true },\n ts.sys,\n ).resolvedModule;\n // Project modules were already imported by the original client file, so they are client-safe.\n if (\n resolved &&\n !resolved.isExternalLibraryImport &&\n !resolved.resolvedFileName.includes(\"/node_modules/\")\n )\n continue;\n const info = input.classifier.classify(spec, islandFile);\n if (info.kind === \"builtin\" || info.kind === \"server-only-marker\") {\n return skip(\"self-check-failed\", `the island file imports the server-only module ${spec}`);\n }\n if (info.kind === \"framework\") {\n const rule = input.framework.classifyModule(spec);\n if (rule?.kind === \"per-name\") {\n const names = namedImports(statement);\n if (names.some((n) => rule.classify(n) === \"server-only\")) {\n return skip(\n \"self-check-failed\",\n `the island file imports the server-only module ${spec}`,\n );\n }\n }\n }\n }\n\n return ok(undefined);\n } finally {\n setSourceText(original, originalText);\n if (islandWrapper) project.removeSourceFile(islandWrapper);\n }\n}\n\nfunction namedImports(decl: ts.ImportDeclaration): string[] {\n const clause = decl.importClause;\n if (!clause) return [];\n const out: string[] = [];\n if (clause.name) out.push(\"default\");\n const b = clause.namedBindings;\n if (b && ts.isNamedImports(b))\n for (const e of b.elements) out.push((e.propertyName ?? e.name).text);\n if (b && ts.isNamespaceImport(b)) out.push(\"*\");\n return out;\n}\n\nfunction isIslandTag(\n node: ts.Node,\n checker: ts.TypeChecker,\n islandSymbols: Set<ts.Symbol>,\n): boolean {\n if (!ts.isIdentifier(node)) return false;\n const symbol = checker.getSymbolAtLocation(node);\n return symbol !== undefined && islandSymbols.has(symbol);\n}\n\nfunction isClientReferenceTag(\n tag: ts.JsxTagNameExpression,\n facts: FileFacts,\n islandSymbols: Set<ts.Symbol>,\n checker: ts.TypeChecker,\n): boolean {\n let head: ts.Node = tag;\n while (ts.isPropertyAccessExpression(head)) head = head.expression;\n if (!ts.isIdentifier(head)) return true;\n const symbol = checker.getSymbolAtLocation(head);\n if (symbol && islandSymbols.has(symbol)) return true;\n const info = facts.classifyRef(head);\n if (info.kind === \"import\") return info.usage.cls !== \"neutral\";\n return info.kind !== \"file\";\n}\n\nfunction isServerActionExpr(\n expr: ts.Expression,\n facts: FileFacts,\n serverActionProps: ReadonlySet<string> | undefined,\n): boolean {\n const e = stripParens(expr);\n if (!ts.isIdentifier(e)) return false;\n const info = facts.classifyRef(e);\n if (info.kind === \"import\") return info.usage.cls === \"server-action\";\n if (info.kind === \"file\" && serverActionProps && ts.isBindingElement(info.declaration)) {\n const element = info.declaration;\n const propName = element.propertyName ?? element.name;\n const inParameter =\n ts.isObjectBindingPattern(element.parent) && ts.isParameter(element.parent.parent);\n return inParameter && ts.isIdentifier(propName) && serverActionProps.has(propName.text);\n }\n return false;\n}\n"],"mappings":";;;;;;;;;AAIO,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAaO,IAAM,cAAwC;AAAA,EACnD,sBAAsB;AAAA,E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uB;AACvC,MAAI,IAAI;AACR,QAAM,QAAQ,CAAC,UAAyB;AACtC,QAAIA,KAAG,aAAa,KAAK,KAAKA,KAAG,wBAAwB,KAAK,KAAKA,KAAG,cAAc,KAAK,EAAG;AAC5F,IAAAA,KAAG,aAAa,OAAO,KAAK;AAAA,EAC9B;AACA,QAAM,IAAI;AACV,SAAO;AACT;AAEA,SAAS,kBAAkB,SAAiB,QAAgB,gBAAgB,OAAe;AACzF,MAAI,SAASL,MAAK,SAAS,SAAS,MAAM,EAAE,MAAMA,MAAK,GAAG,EAAE,KAAK,GAAG;AACpE,MAAI,CAAC,cAAe,UAAS,OAAO,QAAQ,8BAA8B,EAAE;AAC5E,SAAO,OAAO,WAAW,GAAG,IAAI,SAAS,KAAK,MAAM;AACtD;AAEO,SAAS,YAAY,OAAuB;AACjD,SAAO,SAAS,OAAO,IAAI,QAAQ,MAAM,QAAQ,CAAC,CAAC,QAAQ,GAAG,KAAK;AACrE;","names":["rel","existsSync","writeFileSync","path","fg","ts","ts","ts","path","ts","ts","ts","ts","rel","ts","ts","ts","ts","path","inner","ts","units","ts","ts","ts","rel","ts","existsSync","readFileSync","path","ts","rel","existsSync","path","ts","project","readFileSync","path","fg","ts","path","ts","cache","readFileSync","fg","existsSync","readFileSync","path","path","existsSync","readFileSync","ts","ts","before","ts","ts","result","ts","isInTypePosition","createRequire","path","pathToFileURL","require","path","ts","ts","path","STYLESHEET_RE","path","rel","writeFileSync","existsSync","fg","ts"]}
|