foresthouse 1.0.0-dev.14 → 1.0.0-dev.15

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/README.md CHANGED
@@ -65,8 +65,10 @@ src/main.ts
65
65
  `react` command:
66
66
 
67
67
  - `foresthouse react <path>`: print a React usage tree from an entry file
68
+ - `foresthouse react --nextjs`: infer Next.js page entries from `app/`, `pages/`, `src/app/`, and `src/pages/`
68
69
  - `--cwd <path>`: working directory for resolving the entry file and config
69
70
  - `--config <path>`: use a specific `tsconfig.json` or `jsconfig.json`
71
+ - `--nextjs`: allow omitting the explicit React entry file and discover Next.js page entries relative to `--cwd` or the current directory
70
72
  - `--filter <component|hook|builtin>`: limit the output to a specific React symbol kind
71
73
  - `--builtin`: include built-in HTML nodes such as `button` and `div`
72
74
  - `--no-workspaces`: stop at sibling workspace package boundaries instead of expanding them
package/dist/cli.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { c as analyzeReactUsage, i as printDependencyTree, l as analyzeDependencies, n as graphToSerializableTree, r as printReactUsageTree, t as graphToSerializableReactTree } from "./react-qiCwZtzi.mjs";
2
+ import { c as analyzeReactUsage, i as printDependencyTree, l as analyzeDependencies, n as graphToSerializableTree, r as printReactUsageTree, t as graphToSerializableReactTree, u as isSourceCodeFile } from "./react-B0frvTuH.mjs";
3
3
  import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+ import fs from "node:fs";
4
6
  import process$1 from "node:process";
5
7
  import { cac } from "cac";
6
8
  //#region src/commands/base.ts
@@ -46,10 +48,71 @@ var ImportCommand = class extends BaseCommand {
46
48
  }
47
49
  };
48
50
  //#endregion
51
+ //#region src/app/react-entry-files.ts
52
+ const NEXT_JS_ENTRY_ROOTS = [
53
+ "pages",
54
+ "app",
55
+ path.join("src", "pages"),
56
+ path.join("src", "app")
57
+ ];
58
+ function resolveReactEntryFiles(options) {
59
+ if (options.entryFile !== void 0) return [options.entryFile];
60
+ if (!options.nextjs) throw new Error("Missing React entry file. Use `foresthouse react <entry-file>` or `foresthouse react --nextjs`.");
61
+ return discoverNextJsPageEntries(options.cwd);
62
+ }
63
+ function discoverNextJsPageEntries(cwd) {
64
+ const effectiveCwd = path.resolve(cwd ?? process.cwd());
65
+ const entries = /* @__PURE__ */ new Set();
66
+ collectPagesRouterEntries(path.join(effectiveCwd, "pages"), effectiveCwd, entries);
67
+ collectAppRouterEntries(path.join(effectiveCwd, "app"), effectiveCwd, entries);
68
+ collectPagesRouterEntries(path.join(effectiveCwd, "src", "pages"), effectiveCwd, entries);
69
+ collectAppRouterEntries(path.join(effectiveCwd, "src", "app"), effectiveCwd, entries);
70
+ const resolvedEntries = [...entries].sort();
71
+ if (resolvedEntries.length > 0) return resolvedEntries;
72
+ const searchedRoots = NEXT_JS_ENTRY_ROOTS.map((root) => `\`${root}/\``).join(", ");
73
+ throw new Error(`No Next.js page entries found. Searched ${searchedRoots} relative to ${effectiveCwd}.`);
74
+ }
75
+ function collectPagesRouterEntries(rootDirectory, cwd, entries) {
76
+ walkDirectory(rootDirectory, (filePath, relativePath) => {
77
+ if (!isSourceCodeFile(filePath) || filePath.endsWith(".d.ts")) return;
78
+ if (relativePath.split(path.sep)[0] === "api") return;
79
+ if (path.basename(filePath).startsWith("_")) return;
80
+ entries.add(path.relative(cwd, filePath));
81
+ });
82
+ }
83
+ function collectAppRouterEntries(rootDirectory, cwd, entries) {
84
+ walkDirectory(rootDirectory, (filePath) => {
85
+ if (!isSourceCodeFile(filePath) || filePath.endsWith(".d.ts")) return;
86
+ const extension = path.extname(filePath);
87
+ if (path.basename(filePath, extension) !== "page") return;
88
+ entries.add(path.relative(cwd, filePath));
89
+ });
90
+ }
91
+ function walkDirectory(rootDirectory, visitor) {
92
+ if (!fs.existsSync(rootDirectory)) return;
93
+ const stack = [rootDirectory];
94
+ while (stack.length > 0) {
95
+ const directory = stack.pop();
96
+ if (directory === void 0) continue;
97
+ const directoryEntries = fs.readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
98
+ for (let index = directoryEntries.length - 1; index >= 0; index -= 1) {
99
+ const entry = directoryEntries[index];
100
+ if (entry === void 0) continue;
101
+ const entryPath = path.join(directory, entry.name);
102
+ if (entry.isDirectory()) {
103
+ stack.push(entryPath);
104
+ continue;
105
+ }
106
+ if (!entry.isFile()) continue;
107
+ visitor(entryPath, path.relative(rootDirectory, entryPath));
108
+ }
109
+ }
110
+ }
111
+ //#endregion
49
112
  //#region src/commands/react.ts
50
113
  var ReactCommand = class extends BaseCommand {
51
114
  analyze() {
52
- return analyzeReactUsage(this.options.entryFile, this.getAnalyzeOptions());
115
+ return analyzeReactUsage(resolveReactEntryFiles(this.options), this.getAnalyzeOptions());
53
116
  }
54
117
  serialize(graph) {
55
118
  return graphToSerializableReactTree(graph, { filter: this.getFilter() });
@@ -117,7 +180,7 @@ var CliMain = class {
117
180
  cli.command("import [entry-file]", "Analyze an entry file and print its dependency tree.").usage("import <entry-file> [options]").option("--entry <path>", "Entry file to analyze.").option("--cwd <path>", "Working directory used for relative paths.").option("--config <path>", "Explicit tsconfig.json or jsconfig.json path.").option("--include-externals", "Include packages and Node built-ins in the tree.").option("--no-workspaces", "Do not expand sibling workspace packages into source subtrees.").option("--project-only", "Restrict traversal to the active tsconfig.json or jsconfig.json project.").option("--no-unused", "Omit imports that are never referenced.").option("--json", "Print the dependency tree as JSON.").action((entryFile, rawOptions) => {
118
181
  runCli(normalizeImportCliOptions(entryFile, rawOptions));
119
182
  });
120
- cli.command("react <entry-file>", "Analyze React usage from an entry file.").usage("react <entry-file> [options]").option("--cwd <path>", "Working directory used for relative paths.").option("--config <path>", "Explicit tsconfig.json or jsconfig.json path.").option("--filter <mode>", "Limit output to `component`, `hook`, or `builtin` usages.").option("--builtin", "Include built-in HTML nodes in the React tree.").option("--no-workspaces", "Do not expand sibling workspace packages into source subtrees.").option("--project-only", "Restrict traversal to the active tsconfig.json or jsconfig.json project.").option("--json", "Print the React usage tree as JSON.").action((entryFile, rawOptions) => {
183
+ cli.command("react [entry-file]", "Analyze React usage from an entry file.").usage("react [entry-file] [options]").option("--cwd <path>", "Working directory used for relative paths.").option("--config <path>", "Explicit tsconfig.json or jsconfig.json path.").option("--nextjs", "Infer Next.js page entries from app/ and pages/ when no entry is provided.").option("--filter <mode>", "Limit output to `component`, `hook`, or `builtin` usages.").option("--builtin", "Include built-in HTML nodes in the React tree.").option("--no-workspaces", "Do not expand sibling workspace packages into source subtrees.").option("--project-only", "Restrict traversal to the active tsconfig.json or jsconfig.json project.").option("--json", "Print the React usage tree as JSON.").action((entryFile, rawOptions) => {
121
184
  runCli(normalizeReactCliOptions(entryFile, rawOptions));
122
185
  });
123
186
  cli.help();
@@ -157,13 +220,14 @@ function normalizeImportCliOptions(entryFile, options) {
157
220
  function normalizeReactCliOptions(entryFile, options) {
158
221
  return {
159
222
  command: "react",
160
- entryFile,
223
+ entryFile: resolveReactEntryFile(entryFile, options.nextjs),
161
224
  cwd: options.cwd,
162
225
  configPath: options.config,
163
226
  expandWorkspaces: options.workspaces !== false,
164
227
  projectOnly: options.projectOnly === true,
165
228
  json: options.json === true,
166
229
  filter: normalizeReactFilter(options.filter),
230
+ nextjs: options.nextjs === true,
167
231
  includeBuiltins: options.builtin === true
168
232
  };
169
233
  }
@@ -178,6 +242,11 @@ function normalizeReactFilter(filter) {
178
242
  if (filter === "component" || filter === "hook" || filter === "builtin") return filter;
179
243
  throw new Error(`Unknown React filter: ${filter}`);
180
244
  }
245
+ function resolveReactEntryFile(entryFile, nextjs) {
246
+ if (entryFile !== void 0) return entryFile;
247
+ if (nextjs === true) return;
248
+ throw new Error("Missing React entry file. Use `foresthouse react <entry-file>` or `foresthouse react --nextjs`.");
249
+ }
181
250
  //#endregion
182
251
  //#region src/cli.ts
183
252
  const { version } = createRequire(import.meta.url)("../package.json");
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":["process"],"sources":["../src/commands/base.ts","../src/commands/import.ts","../src/commands/react.ts","../src/app/run.ts","../src/app/cli.ts","../src/cli.ts"],"sourcesContent":["import type { CliOptions } from '../app/args.js'\nimport type { AnalyzeOptions } from '../types/analyze-options.js'\n\nexport abstract class BaseCommand<\n TGraph,\n TOptions extends CliOptions = CliOptions,\n> {\n constructor(protected readonly options: TOptions) {}\n\n run(): void {\n const graph = this.analyze()\n\n if (this.isJsonMode()) {\n process.stdout.write(\n `${JSON.stringify(this.serialize(graph), null, 2)}\\n`,\n )\n return\n }\n\n process.stdout.write(`${this.render(graph)}\\n`)\n }\n\n protected isJsonMode(): boolean {\n return this.options.json\n }\n\n protected getAnalyzeOptions(): AnalyzeOptions {\n return {\n ...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),\n ...(this.options.configPath === undefined\n ? {}\n : { configPath: this.options.configPath }),\n expandWorkspaces: this.options.expandWorkspaces,\n projectOnly: this.options.projectOnly,\n }\n }\n\n protected abstract analyze(): TGraph\n protected abstract serialize(graph: TGraph): object\n protected abstract render(graph: TGraph): string\n}\n","import { analyzeDependencies } from '../analyzers/import/index.js'\nimport type { ImportCliOptions } from '../app/args.js'\nimport { printDependencyTree } from '../output/ascii/import.js'\nimport { graphToSerializableTree } from '../output/json/import.js'\nimport type { DependencyGraph } from '../types/dependency-graph.js'\nimport { BaseCommand } from './base.js'\n\nexport class ImportCommand extends BaseCommand<\n DependencyGraph,\n ImportCliOptions\n> {\n protected analyze(): DependencyGraph {\n return analyzeDependencies(this.options.entryFile, this.getAnalyzeOptions())\n }\n\n protected serialize(graph: DependencyGraph): object {\n return graphToSerializableTree(graph, {\n omitUnused: this.options.omitUnused,\n })\n }\n\n protected render(graph: DependencyGraph): string {\n return printDependencyTree(graph, {\n cwd: this.options.cwd ?? graph.cwd,\n includeExternals: this.options.includeExternals,\n omitUnused: this.options.omitUnused,\n })\n }\n}\n","import { analyzeReactUsage } from '../analyzers/react/index.js'\nimport type { ReactCliOptions } from '../app/args.js'\nimport { printReactUsageTree } from '../output/ascii/react.js'\nimport { graphToSerializableReactTree } from '../output/json/react.js'\nimport type { AnalyzeOptions } from '../types/analyze-options.js'\nimport type { ReactUsageFilter } from '../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../types/react-usage-graph.js'\nimport { BaseCommand } from './base.js'\n\nexport class ReactCommand extends BaseCommand<\n ReactUsageGraph,\n ReactCliOptions\n> {\n protected analyze(): ReactUsageGraph {\n return analyzeReactUsage(this.options.entryFile, this.getAnalyzeOptions())\n }\n\n protected serialize(graph: ReactUsageGraph): object {\n return graphToSerializableReactTree(graph, {\n filter: this.getFilter(),\n })\n }\n\n protected render(graph: ReactUsageGraph): string {\n return printReactUsageTree(graph, {\n cwd: this.options.cwd ?? graph.cwd,\n filter: this.getFilter(),\n })\n }\n\n protected getAnalyzeOptions(): AnalyzeOptions {\n return {\n ...super.getAnalyzeOptions(),\n includeBuiltins: this.options.includeBuiltins,\n }\n }\n\n private getFilter(): ReactUsageFilter {\n return this.options.filter\n }\n}\n","import { ImportCommand } from '../commands/import.js'\nimport { ReactCommand } from '../commands/react.js'\nimport type { CliOptions } from './args.js'\n\nexport function runCli(options: CliOptions): void {\n new CliApplication(options).run()\n}\n\nclass CliApplication {\n constructor(private readonly options: CliOptions) {}\n\n run(): void {\n this.createCommand().run()\n }\n\n private createCommand(): {\n run(): void\n } {\n if (this.options.command === 'react') {\n return new ReactCommand(this.options)\n }\n\n return new ImportCommand(this.options)\n }\n}\n","import process from 'node:process'\n\nimport { cac } from 'cac'\n\nimport type { ReactUsageFilter } from '../types/react-usage-filter.js'\nimport type { ImportCliOptions, ReactCliOptions } from './args.js'\nimport { runCli } from './run.js'\n\nexport function main(version: string, argv = process.argv.slice(2)): void {\n new CliMain(version, argv).run()\n}\n\nclass CliMain {\n constructor(\n private readonly version: string,\n private readonly argv: string[],\n ) {}\n\n run(): void {\n try {\n const cli = this.createCli()\n\n if (this.argv.length === 0) {\n cli.outputHelp()\n return\n }\n\n this.validateCommandSyntax()\n cli.parse(this.toProcessArgv())\n } catch (error) {\n const message =\n error instanceof Error ? error.message : 'Unknown error occurred.'\n process.stderr.write(`foresthouse: ${message}\\n`)\n process.exitCode = 1\n }\n }\n\n private createCli() {\n const cli = cac('foresthouse')\n\n cli\n .command(\n 'import [entry-file]',\n 'Analyze an entry file and print its dependency tree.',\n )\n .usage('import <entry-file> [options]')\n .option('--entry <path>', 'Entry file to analyze.')\n .option('--cwd <path>', 'Working directory used for relative paths.')\n .option(\n '--config <path>',\n 'Explicit tsconfig.json or jsconfig.json path.',\n )\n .option(\n '--include-externals',\n 'Include packages and Node built-ins in the tree.',\n )\n .option(\n '--no-workspaces',\n 'Do not expand sibling workspace packages into source subtrees.',\n )\n .option(\n '--project-only',\n 'Restrict traversal to the active tsconfig.json or jsconfig.json project.',\n )\n .option('--no-unused', 'Omit imports that are never referenced.')\n .option('--json', 'Print the dependency tree as JSON.')\n .action(\n (entryFile: string | undefined, rawOptions: ParsedImportCliOptions) => {\n runCli(normalizeImportCliOptions(entryFile, rawOptions))\n },\n )\n\n cli\n .command('react <entry-file>', 'Analyze React usage from an entry file.')\n .usage('react <entry-file> [options]')\n .option('--cwd <path>', 'Working directory used for relative paths.')\n .option(\n '--config <path>',\n 'Explicit tsconfig.json or jsconfig.json path.',\n )\n .option(\n '--filter <mode>',\n 'Limit output to `component`, `hook`, or `builtin` usages.',\n )\n .option('--builtin', 'Include built-in HTML nodes in the React tree.')\n .option(\n '--no-workspaces',\n 'Do not expand sibling workspace packages into source subtrees.',\n )\n .option(\n '--project-only',\n 'Restrict traversal to the active tsconfig.json or jsconfig.json project.',\n )\n .option('--json', 'Print the React usage tree as JSON.')\n .action((entryFile: string, rawOptions: ParsedReactCliOptions) => {\n runCli(normalizeReactCliOptions(entryFile, rawOptions))\n })\n\n cli.help()\n cli.version(this.version)\n\n return cli\n }\n\n private validateCommandSyntax(): void {\n if (this.argv.length === 0) {\n return\n }\n\n const firstArgument = this.argv[0]\n\n if (firstArgument === undefined) {\n return\n }\n\n if (firstArgument === '--react' || firstArgument.startsWith('--react=')) {\n throw new Error('Unknown option `--react`')\n }\n\n if (firstArgument.startsWith('-')) {\n return\n }\n\n if (firstArgument === 'import' || firstArgument === 'react') {\n return\n }\n\n throw new Error(`Unknown command \\`${firstArgument}\\``)\n }\n\n private toProcessArgv(): string[] {\n return ['node', 'foresthouse', ...this.argv]\n }\n}\n\ninterface ParsedBaseCliOptions {\n readonly cwd?: string\n readonly config?: string\n readonly workspaces?: boolean\n readonly projectOnly?: boolean\n readonly json?: boolean\n}\n\ninterface ParsedImportCliOptions extends ParsedBaseCliOptions {\n readonly entry?: string\n readonly includeExternals?: boolean\n readonly unused?: boolean\n}\n\ninterface ParsedReactCliOptions extends ParsedBaseCliOptions {\n readonly filter?: string\n readonly builtin?: boolean\n}\n\nfunction normalizeImportCliOptions(\n entryFile: string | undefined,\n options: ParsedImportCliOptions,\n): ImportCliOptions {\n return {\n command: 'import',\n entryFile: resolveImportEntryFile(entryFile, options.entry),\n cwd: options.cwd,\n configPath: options.config,\n expandWorkspaces: options.workspaces !== false,\n projectOnly: options.projectOnly === true,\n includeExternals: options.includeExternals === true,\n omitUnused: options.unused === false,\n json: options.json === true,\n }\n}\n\nfunction normalizeReactCliOptions(\n entryFile: string,\n options: ParsedReactCliOptions,\n): ReactCliOptions {\n return {\n command: 'react',\n entryFile,\n cwd: options.cwd,\n configPath: options.config,\n expandWorkspaces: options.workspaces !== false,\n projectOnly: options.projectOnly === true,\n json: options.json === true,\n filter: normalizeReactFilter(options.filter),\n includeBuiltins: options.builtin === true,\n }\n}\n\nfunction resolveImportEntryFile(\n positionalEntryFile: string | undefined,\n optionEntryFile: string | undefined,\n): string {\n if (\n positionalEntryFile !== undefined &&\n optionEntryFile !== undefined &&\n positionalEntryFile !== optionEntryFile\n ) {\n throw new Error(\n 'Provide the import entry only once, either as `foresthouse import <entry-file>` or `foresthouse import --entry <path>`.',\n )\n }\n\n const resolvedEntryFile = positionalEntryFile ?? optionEntryFile\n\n if (resolvedEntryFile === undefined) {\n throw new Error(\n 'Missing import entry file. Use `foresthouse import <entry-file>` or `foresthouse import --entry <path>`.',\n )\n }\n\n return resolvedEntryFile\n}\n\nfunction normalizeReactFilter(\n filter: ParsedReactCliOptions['filter'],\n): ReactUsageFilter {\n if (filter === undefined) {\n return 'all'\n }\n\n if (filter === 'component' || filter === 'hook' || filter === 'builtin') {\n return filter\n }\n\n throw new Error(`Unknown React filter: ${filter}`)\n}\n","#!/usr/bin/env node\n\nimport { createRequire } from 'node:module'\n\nimport { main } from './app/cli.js'\n\nconst require = createRequire(import.meta.url)\nconst { version } = require('../package.json') as { version: string }\n\nmain(version)\n"],"mappings":";;;;;;AAGA,IAAsB,cAAtB,MAGE;CACA,YAAY,SAAsC;AAAnB,OAAA,UAAA;;CAE/B,MAAY;EACV,MAAM,QAAQ,KAAK,SAAS;AAE5B,MAAI,KAAK,YAAY,EAAE;AACrB,WAAQ,OAAO,MACb,GAAG,KAAK,UAAU,KAAK,UAAU,MAAM,EAAE,MAAM,EAAE,CAAC,IACnD;AACD;;AAGF,UAAQ,OAAO,MAAM,GAAG,KAAK,OAAO,MAAM,CAAC,IAAI;;CAGjD,aAAgC;AAC9B,SAAO,KAAK,QAAQ;;CAGtB,oBAA8C;AAC5C,SAAO;GACL,GAAI,KAAK,QAAQ,QAAQ,KAAA,IAAY,EAAE,GAAG,EAAE,KAAK,KAAK,QAAQ,KAAK;GACnE,GAAI,KAAK,QAAQ,eAAe,KAAA,IAC5B,EAAE,GACF,EAAE,YAAY,KAAK,QAAQ,YAAY;GAC3C,kBAAkB,KAAK,QAAQ;GAC/B,aAAa,KAAK,QAAQ;GAC3B;;;;;AC3BL,IAAa,gBAAb,cAAmC,YAGjC;CACA,UAAqC;AACnC,SAAO,oBAAoB,KAAK,QAAQ,WAAW,KAAK,mBAAmB,CAAC;;CAG9E,UAAoB,OAAgC;AAClD,SAAO,wBAAwB,OAAO,EACpC,YAAY,KAAK,QAAQ,YAC1B,CAAC;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AAkC;AAChC,SAAO;GAAC;GAAQ;GAAe,GAAG,KAAK;GAAK;;;AAuBhD,SAAS,0BACP,WACA,SACkB;AAClB,QAAO;EACL,SAAS;EACT,WAAW,uBAAuB,WAAW,QAAQ,MAAM;EAC3D,KAAK,QAAQ;EACb,YAAY,QAAQ;EACpB,kBAAkB,QAAQ,eAAe;EACzC,aAAa,QAAQ,gBAAgB;EACrC,kBAAkB,QAAQ,qBAAqB;EAC/C,YAAY,QAAQ,WAAW;EAC/B,MAAM,QAAQ,SAAS;EACxB;;AAGH,SAAS,yBACP,WACA,SACiB;AACjB,QAAO;EACL,SAAS;EACT;EACA,KAAK,QAAQ;EACb,YAAY,QAAQ;EACpB,kBAAkB,QAAQ,eAAe;EACzC,aAAa,QAAQ,gBAAgB;EACrC,MAAM,QAAQ,SAAS;EACvB,QAAQ,qBAAqB,QAAQ,OAAO;EAC5C,iBAAiB,QAAQ,YAAY;EACtC;;AAGH,SAAS,uBACP,qBACA,iBACQ;AACR,KACE,wBAAwB,KAAA,KACxB,oBAAoB,KAAA,KACpB,wBAAwB,gBAExB,OAAM,IAAI,MACR,0HACD;CAGH,MAAM,oBAAoB,uBAAuB;AAEjD,KAAI,sBAAsB,KAAA,EACxB,OAAM,IAAI,MACR,2GACD;AAGH,QAAO;;AAGT,SAAS,qBACP,QACkB;AAClB,KAAI,WAAW,KAAA,EACb,QAAO;AAGT,KAAI,WAAW,eAAe,WAAW,UAAU,WAAW,UAC5D,QAAO;AAGT,OAAM,IAAI,MAAM,yBAAyB,SAAS;;;;ACzNpD,MAAM,EAAE,YADQ,cAAc,OAAO,KAAK,IAAI,CAClB,kBAAkB;AAE9C,KAAK,QAAQ"}
1
+ {"version":3,"file":"cli.mjs","names":["process"],"sources":["../src/commands/base.ts","../src/commands/import.ts","../src/app/react-entry-files.ts","../src/commands/react.ts","../src/app/run.ts","../src/app/cli.ts","../src/cli.ts"],"sourcesContent":["import type { CliOptions } from '../app/args.js'\nimport type { AnalyzeOptions } from '../types/analyze-options.js'\n\nexport abstract class BaseCommand<\n TGraph,\n TOptions extends CliOptions = CliOptions,\n> {\n constructor(protected readonly options: TOptions) {}\n\n run(): void {\n const graph = this.analyze()\n\n if (this.isJsonMode()) {\n process.stdout.write(\n `${JSON.stringify(this.serialize(graph), null, 2)}\\n`,\n )\n return\n }\n\n process.stdout.write(`${this.render(graph)}\\n`)\n }\n\n protected isJsonMode(): boolean {\n return this.options.json\n }\n\n protected getAnalyzeOptions(): AnalyzeOptions {\n return {\n ...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),\n ...(this.options.configPath === undefined\n ? {}\n : { configPath: this.options.configPath }),\n expandWorkspaces: this.options.expandWorkspaces,\n projectOnly: this.options.projectOnly,\n }\n }\n\n protected abstract analyze(): TGraph\n protected abstract serialize(graph: TGraph): object\n protected abstract render(graph: TGraph): string\n}\n","import { analyzeDependencies } from '../analyzers/import/index.js'\nimport type { ImportCliOptions } from '../app/args.js'\nimport { printDependencyTree } from '../output/ascii/import.js'\nimport { graphToSerializableTree } from '../output/json/import.js'\nimport type { DependencyGraph } from '../types/dependency-graph.js'\nimport { BaseCommand } from './base.js'\n\nexport class ImportCommand extends BaseCommand<\n DependencyGraph,\n ImportCliOptions\n> {\n protected analyze(): DependencyGraph {\n return analyzeDependencies(this.options.entryFile, this.getAnalyzeOptions())\n }\n\n protected serialize(graph: DependencyGraph): object {\n return graphToSerializableTree(graph, {\n omitUnused: this.options.omitUnused,\n })\n }\n\n protected render(graph: DependencyGraph): string {\n return printDependencyTree(graph, {\n cwd: this.options.cwd ?? graph.cwd,\n includeExternals: this.options.includeExternals,\n omitUnused: this.options.omitUnused,\n })\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport { isSourceCodeFile } from '../utils/is-source-code-file.js'\nimport type { ReactCliOptions } from './args.js'\n\nconst NEXT_JS_ENTRY_ROOTS = [\n 'pages',\n 'app',\n path.join('src', 'pages'),\n path.join('src', 'app'),\n]\n\nexport function resolveReactEntryFiles(options: ReactCliOptions): string[] {\n if (options.entryFile !== undefined) {\n return [options.entryFile]\n }\n\n if (!options.nextjs) {\n throw new Error(\n 'Missing React entry file. Use `foresthouse react <entry-file>` or `foresthouse react --nextjs`.',\n )\n }\n\n return discoverNextJsPageEntries(options.cwd)\n}\n\nexport function discoverNextJsPageEntries(cwd?: string): string[] {\n const effectiveCwd = path.resolve(cwd ?? process.cwd())\n const entries = new Set<string>()\n\n collectPagesRouterEntries(\n path.join(effectiveCwd, 'pages'),\n effectiveCwd,\n entries,\n )\n collectAppRouterEntries(path.join(effectiveCwd, 'app'), effectiveCwd, entries)\n collectPagesRouterEntries(\n path.join(effectiveCwd, 'src', 'pages'),\n effectiveCwd,\n entries,\n )\n collectAppRouterEntries(\n path.join(effectiveCwd, 'src', 'app'),\n effectiveCwd,\n entries,\n )\n\n const resolvedEntries = [...entries].sort()\n if (resolvedEntries.length > 0) {\n return resolvedEntries\n }\n\n const searchedRoots = NEXT_JS_ENTRY_ROOTS.map((root) => `\\`${root}/\\``).join(\n ', ',\n )\n throw new Error(\n `No Next.js page entries found. Searched ${searchedRoots} relative to ${effectiveCwd}.`,\n )\n}\n\nfunction collectPagesRouterEntries(\n rootDirectory: string,\n cwd: string,\n entries: Set<string>,\n): void {\n walkDirectory(rootDirectory, (filePath, relativePath) => {\n if (!isSourceCodeFile(filePath) || filePath.endsWith('.d.ts')) {\n return\n }\n\n const segments = relativePath.split(path.sep)\n if (segments[0] === 'api') {\n return\n }\n\n const baseName = path.basename(filePath)\n if (baseName.startsWith('_')) {\n return\n }\n\n entries.add(path.relative(cwd, filePath))\n })\n}\n\nfunction collectAppRouterEntries(\n rootDirectory: string,\n cwd: string,\n entries: Set<string>,\n): void {\n walkDirectory(rootDirectory, (filePath) => {\n if (!isSourceCodeFile(filePath) || filePath.endsWith('.d.ts')) {\n return\n }\n\n const extension = path.extname(filePath)\n const baseName = path.basename(filePath, extension)\n if (baseName !== 'page') {\n return\n }\n\n entries.add(path.relative(cwd, filePath))\n })\n}\n\nfunction walkDirectory(\n rootDirectory: string,\n visitor: (filePath: string, relativePath: string) => void,\n): void {\n if (!fs.existsSync(rootDirectory)) {\n return\n }\n\n const stack = [rootDirectory]\n\n while (stack.length > 0) {\n const directory = stack.pop()\n if (directory === undefined) {\n continue\n }\n\n const directoryEntries = fs\n .readdirSync(directory, { withFileTypes: true })\n .sort((left, right) => left.name.localeCompare(right.name))\n\n for (let index = directoryEntries.length - 1; index >= 0; index -= 1) {\n const entry = directoryEntries[index]\n if (entry === undefined) {\n continue\n }\n\n const entryPath = path.join(directory, entry.name)\n if (entry.isDirectory()) {\n stack.push(entryPath)\n continue\n }\n\n if (!entry.isFile()) {\n continue\n }\n\n visitor(entryPath, path.relative(rootDirectory, entryPath))\n }\n }\n}\n","import { analyzeReactUsage } from '../analyzers/react/index.js'\nimport type { ReactCliOptions } from '../app/args.js'\nimport { resolveReactEntryFiles } from '../app/react-entry-files.js'\nimport { printReactUsageTree } from '../output/ascii/react.js'\nimport { graphToSerializableReactTree } from '../output/json/react.js'\nimport type { AnalyzeOptions } from '../types/analyze-options.js'\nimport type { ReactUsageFilter } from '../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../types/react-usage-graph.js'\nimport { BaseCommand } from './base.js'\n\nexport class ReactCommand extends BaseCommand<\n ReactUsageGraph,\n ReactCliOptions\n> {\n protected analyze(): ReactUsageGraph {\n return analyzeReactUsage(\n resolveReactEntryFiles(this.options),\n this.getAnalyzeOptions(),\n )\n }\n\n protected serialize(graph: ReactUsageGraph): object {\n return graphToSerializableReactTree(graph, {\n filter: this.getFilter(),\n })\n }\n\n protected render(graph: ReactUsageGraph): string {\n return printReactUsageTree(graph, {\n cwd: this.options.cwd ?? graph.cwd,\n filter: this.getFilter(),\n })\n }\n\n protected getAnalyzeOptions(): AnalyzeOptions {\n return {\n ...super.getAnalyzeOptions(),\n includeBuiltins: this.options.includeBuiltins,\n }\n }\n\n private getFilter(): ReactUsageFilter {\n return this.options.filter\n }\n}\n","import { ImportCommand } from '../commands/import.js'\nimport { ReactCommand } from '../commands/react.js'\nimport type { CliOptions } from './args.js'\n\nexport function runCli(options: CliOptions): void {\n new CliApplication(options).run()\n}\n\nclass CliApplication {\n constructor(private readonly options: CliOptions) {}\n\n run(): void {\n this.createCommand().run()\n }\n\n private createCommand(): {\n run(): void\n } {\n if (this.options.command === 'react') {\n return new ReactCommand(this.options)\n }\n\n return new ImportCommand(this.options)\n }\n}\n","import process from 'node:process'\n\nimport { cac } from 'cac'\n\nimport type { ReactUsageFilter } from '../types/react-usage-filter.js'\nimport type { ImportCliOptions, ReactCliOptions } from './args.js'\nimport { runCli } from './run.js'\n\nexport function main(version: string, argv = process.argv.slice(2)): void {\n new CliMain(version, argv).run()\n}\n\nclass CliMain {\n constructor(\n private readonly version: string,\n private readonly argv: string[],\n ) {}\n\n run(): void {\n try {\n const cli = this.createCli()\n\n if (this.argv.length === 0) {\n cli.outputHelp()\n return\n }\n\n this.validateCommandSyntax()\n cli.parse(this.toProcessArgv())\n } catch (error) {\n const message =\n error instanceof Error ? error.message : 'Unknown error occurred.'\n process.stderr.write(`foresthouse: ${message}\\n`)\n process.exitCode = 1\n }\n }\n\n private createCli() {\n const cli = cac('foresthouse')\n\n cli\n .command(\n 'import [entry-file]',\n 'Analyze an entry file and print its dependency tree.',\n )\n .usage('import <entry-file> [options]')\n .option('--entry <path>', 'Entry file to analyze.')\n .option('--cwd <path>', 'Working directory used for relative paths.')\n .option(\n '--config <path>',\n 'Explicit tsconfig.json or jsconfig.json path.',\n )\n .option(\n '--include-externals',\n 'Include packages and Node built-ins in the tree.',\n )\n .option(\n '--no-workspaces',\n 'Do not expand sibling workspace packages into source subtrees.',\n )\n .option(\n '--project-only',\n 'Restrict traversal to the active tsconfig.json or jsconfig.json project.',\n )\n .option('--no-unused', 'Omit imports that are never referenced.')\n .option('--json', 'Print the dependency tree as JSON.')\n .action(\n (entryFile: string | undefined, rawOptions: ParsedImportCliOptions) => {\n runCli(normalizeImportCliOptions(entryFile, rawOptions))\n },\n )\n\n cli\n .command('react [entry-file]', 'Analyze React usage from an entry file.')\n .usage('react [entry-file] [options]')\n .option('--cwd <path>', 'Working directory used for relative paths.')\n .option(\n '--config <path>',\n 'Explicit tsconfig.json or jsconfig.json path.',\n )\n .option(\n '--nextjs',\n 'Infer Next.js page entries from app/ and pages/ when no entry is provided.',\n )\n .option(\n '--filter <mode>',\n 'Limit output to `component`, `hook`, or `builtin` usages.',\n )\n .option('--builtin', 'Include built-in HTML nodes in the React tree.')\n .option(\n '--no-workspaces',\n 'Do not expand sibling workspace packages into source subtrees.',\n )\n .option(\n '--project-only',\n 'Restrict traversal to the active tsconfig.json or jsconfig.json project.',\n )\n .option('--json', 'Print the React usage tree as JSON.')\n .action(\n (entryFile: string | undefined, rawOptions: ParsedReactCliOptions) => {\n runCli(normalizeReactCliOptions(entryFile, rawOptions))\n },\n )\n\n cli.help()\n cli.version(this.version)\n\n return cli\n }\n\n private validateCommandSyntax(): void {\n if (this.argv.length === 0) {\n return\n }\n\n const firstArgument = this.argv[0]\n\n if (firstArgument === undefined) {\n return\n }\n\n if (firstArgument === '--react' || firstArgument.startsWith('--react=')) {\n throw new Error('Unknown option `--react`')\n }\n\n if (firstArgument.startsWith('-')) {\n return\n }\n\n if (firstArgument === 'import' || firstArgument === 'react') {\n return\n }\n\n throw new Error(`Unknown command \\`${firstArgument}\\``)\n }\n\n private toProcessArgv(): string[] {\n return ['node', 'foresthouse', ...this.argv]\n }\n}\n\ninterface ParsedBaseCliOptions {\n readonly cwd?: string\n readonly config?: string\n readonly workspaces?: boolean\n readonly projectOnly?: boolean\n readonly json?: boolean\n}\n\ninterface ParsedImportCliOptions extends ParsedBaseCliOptions {\n readonly entry?: string\n readonly includeExternals?: boolean\n readonly unused?: boolean\n}\n\ninterface ParsedReactCliOptions extends ParsedBaseCliOptions {\n readonly filter?: string\n readonly nextjs?: boolean\n readonly builtin?: boolean\n}\n\nfunction normalizeImportCliOptions(\n entryFile: string | undefined,\n options: ParsedImportCliOptions,\n): ImportCliOptions {\n return {\n command: 'import',\n entryFile: resolveImportEntryFile(entryFile, options.entry),\n cwd: options.cwd,\n configPath: options.config,\n expandWorkspaces: options.workspaces !== false,\n projectOnly: options.projectOnly === true,\n includeExternals: options.includeExternals === true,\n omitUnused: options.unused === false,\n json: options.json === true,\n }\n}\n\nfunction normalizeReactCliOptions(\n entryFile: string | undefined,\n options: ParsedReactCliOptions,\n): ReactCliOptions {\n return {\n command: 'react',\n entryFile: resolveReactEntryFile(entryFile, options.nextjs),\n cwd: options.cwd,\n configPath: options.config,\n expandWorkspaces: options.workspaces !== false,\n projectOnly: options.projectOnly === true,\n json: options.json === true,\n filter: normalizeReactFilter(options.filter),\n nextjs: options.nextjs === true,\n includeBuiltins: options.builtin === true,\n }\n}\n\nfunction resolveImportEntryFile(\n positionalEntryFile: string | undefined,\n optionEntryFile: string | undefined,\n): string {\n if (\n positionalEntryFile !== undefined &&\n optionEntryFile !== undefined &&\n positionalEntryFile !== optionEntryFile\n ) {\n throw new Error(\n 'Provide the import entry only once, either as `foresthouse import <entry-file>` or `foresthouse import --entry <path>`.',\n )\n }\n\n const resolvedEntryFile = positionalEntryFile ?? optionEntryFile\n\n if (resolvedEntryFile === undefined) {\n throw new Error(\n 'Missing import entry file. Use `foresthouse import <entry-file>` or `foresthouse import --entry <path>`.',\n )\n }\n\n return resolvedEntryFile\n}\n\nfunction normalizeReactFilter(\n filter: ParsedReactCliOptions['filter'],\n): ReactUsageFilter {\n if (filter === undefined) {\n return 'all'\n }\n\n if (filter === 'component' || filter === 'hook' || filter === 'builtin') {\n return filter\n }\n\n throw new Error(`Unknown React filter: ${filter}`)\n}\n\nfunction resolveReactEntryFile(\n entryFile: string | undefined,\n nextjs: boolean | undefined,\n): string | undefined {\n if (entryFile !== undefined) {\n return entryFile\n }\n\n if (nextjs === true) {\n return undefined\n }\n\n throw new Error(\n 'Missing React entry file. Use `foresthouse react <entry-file>` or `foresthouse react --nextjs`.',\n )\n}\n","#!/usr/bin/env node\n\nimport { createRequire } from 'node:module'\n\nimport { main } from './app/cli.js'\n\nconst require = createRequire(import.meta.url)\nconst { version } = require('../package.json') as { version: string }\n\nmain(version)\n"],"mappings":";;;;;;;;AAGA,IAAsB,cAAtB,MAGE;CACA,YAAY,SAAsC;AAAnB,OAAA,UAAA;;CAE/B,MAAY;EACV,MAAM,QAAQ,KAAK,SAAS;AAE5B,MAAI,KAAK,YAAY,EAAE;AACrB,WAAQ,OAAO,MACb,GAAG,KAAK,UAAU,KAAK,UAAU,MAAM,EAAE,MAAM,EAAE,CAAC,IACnD;AACD;;AAGF,UAAQ,OAAO,MAAM,GAAG,KAAK,OAAO,MAAM,CAAC,IAAI;;CAGjD,aAAgC;AAC9B,SAAO,KAAK,QAAQ;;CAGtB,oBAA8C;AAC5C,SAAO;GACL,GAAI,KAAK,QAAQ,QAAQ,KAAA,IAAY,EAAE,GAAG,EAAE,KAAK,KAAK,QAAQ,KAAK;GACnE,GAAI,KAAK,QAAQ,eAAe,KAAA,IAC5B,EAAE,GACF,EAAE,YAAY,KAAK,QAAQ,YAAY;GAC3C,kBAAkB,KAAK,QAAQ;GAC/B,aAAa,KAAK,QAAQ;GAC3B;;;;;AC3BL,IAAa,gBAAb,cAAmC,YAGjC;CACA,UAAqC;AACnC,SAAO,oBAAoB,KAAK,QAAQ,WAAW,KAAK,mBAAmB,CAAC;;CAG9E,UAAoB,OAAgC;AAClD,SAAO,wBAAwB,OAAO,EACpC,YAAY,KAAK,QAAQ,YAC1B,CAAC;;CAGJ,OAAiB,OAAgC;AAC/C,SAAO,oBAAoB,OAAO;GAChC,KAAK,KAAK,QAAQ,OAAO,MAAM;GAC/B,kBAAkB,KAAK,QAAQ;GAC/B,YAAY,KAAK,QAAQ;GAC1B,CAAC;;;;;ACrBN,MAAM,sBAAsB;CAC1B;CACA;CACA,KAAK,KAAK,OAAO,QAAQ;CACzB,KAAK,KAAK,OAAO,MAAM;CACxB;AAED,SAAgB,uBAAuB,SAAoC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BACQ;AACR,KACE,wBAAwB,KAAA,KACxB,oBAAoB,KAAA,KACpB,wBAAwB,gBAExB,OAAM,IAAI,MACR,0HACD;CAGH,MAAM,oBAAoB,uBAAuB;AAEjD,KAAI,sBAAsB,KAAA,EACxB,OAAM,IAAI,MACR,2GACD;AAGH,QAAO;;AAGT,SAAS,qBACP,QACkB;AAClB,KAAI,WAAW,KAAA,EACb,QAAO;AAGT,KAAI,WAAW,eAAe,WAAW,UAAU,WAAW,UAC5D,QAAO;AAGT,OAAM,IAAI,MAAM,yBAAyB,SAAS;;AAGpD,SAAS,sBACP,WACA,QACoB;AACpB,KAAI,cAAc,KAAA,EAChB,QAAO;AAGT,KAAI,WAAW,KACb;AAGF,OAAM,IAAI,MACR,kGACD;;;;AClPH,MAAM,EAAE,YADQ,cAAc,OAAO,KAAK,IAAI,CAClB,kBAAkB;AAE9C,KAAK,QAAQ"}
package/dist/index.d.mts CHANGED
@@ -82,12 +82,13 @@ interface ReactUsageNode {
82
82
  interface ReactUsageGraph {
83
83
  readonly cwd: string;
84
84
  readonly entryId: string;
85
+ readonly entryIds: readonly string[];
85
86
  readonly nodes: ReadonlyMap<string, ReactUsageNode>;
86
87
  readonly entries: readonly ReactUsageEntry[];
87
88
  }
88
89
  //#endregion
89
90
  //#region src/analyzers/react/index.d.ts
90
- declare function analyzeReactUsage(entryFile: string, options?: AnalyzeOptions): ReactUsageGraph;
91
+ declare function analyzeReactUsage(entryFile: string | readonly string[], options?: AnalyzeOptions): ReactUsageGraph;
91
92
  //#endregion
92
93
  //#region src/types/react-usage-filter.d.ts
93
94
  type ReactUsageFilter = 'all' | ReactSymbolKind;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/analyze-options.ts","../src/types/dependency-kind.ts","../src/types/reference-kind.ts","../src/types/dependency-edge.ts","../src/types/source-module-node.ts","../src/types/dependency-graph.ts","../src/analyzers/import/index.ts","../src/types/react-usage-location.ts","../src/types/react-usage-entry.ts","../src/types/react-symbol-kind.ts","../src/types/react-usage-edge-kind.ts","../src/types/react-usage-edge.ts","../src/types/react-usage-node.ts","../src/types/react-usage-graph.ts","../src/analyzers/react/index.ts","../src/types/react-usage-filter.ts","../src/analyzers/react/queries.ts","../src/types/color-mode.ts","../src/types/print-tree-options.ts","../src/output/ascii/import.ts","../src/types/print-react-tree-options.ts","../src/output/ascii/react.ts","../src/output/json/import.ts","../src/output/json/react.ts"],"mappings":";UAAiB,cAAA;EAAA,SACN,GAAA;EAAA,SACA,UAAA;EAAA,SACA,gBAAA;EAAA,SACA,WAAA;EAAA,SACA,eAAA;AAAA;;;KCLC,cAAA;;;KCAA,aAAA;;;UCGK,cAAA;EAAA,SACN,SAAA;EAAA,SACA,aAAA,EAAe,aAAA;EAAA,SACf,UAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA,EAAM,cAAA;EAAA,SACN,MAAA;EAAA,SACA,QAAA;AAAA;;;UCRM,gBAAA;EAAA,SACN,EAAA;EAAA,SACA,YAAA,WAAuB,cAAA;AAAA;;;UCFjB,eAAA;EAAA,SACN,GAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA,EAAO,WAAA,SAAoB,gBAAA;EAAA,SAC3B,UAAA;AAAA;;;iBCGK,mBAAA,CACd,SAAA,UACA,OAAA,GAAS,cAAA,GACR,eAAA;;;UCZc,kBAAA;EAAA,SACN,QAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;;;UCDM,eAAA;EAAA,SACN,MAAA;EAAA,SACA,aAAA;EAAA,SACA,QAAA,EAAU,kBAAA;AAAA;;;KCLT,eAAA;;;KCAA,kBAAA;;;UCEK,cAAA;EAAA,SACN,IAAA,EAAM,kBAAA;EAAA,SACN,MAAA;EAAA,SACA,aAAA;AAAA;;;UCFM,cAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA,EAAM,eAAA;EAAA,SACN,QAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,WAAiB,cAAA;AAAA;;;UCNX,eAAA;EAAA,SACN,GAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA,EAAO,WAAA,SAAoB,cAAA;EAAA,SAC3B,OAAA,WAAkB,eAAA;AAAA;;;iBCgBb,iBAAA,CACd,SAAA,UACA,OAAA,GAAS,cAAA,GACR,eAAA;;;KCxBS,gBAAA,WAA2B,eAAA;;;iBCKvB,oBAAA,CACd,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA,GACP,eAAA;AAAA,iBAOa,kBAAA,CACd,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA;AAAA,iBAsCM,iBAAA,CACd,IAAA,EAAM,cAAA,EACN,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA,GACP,cAAA;;;KC7DS,SAAA;;;UCEK,gBAAA;EAAA,SACN,GAAA;EAAA,SACA,gBAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA,GAAQ,SAAA;AAAA;;;iBCAH,mBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,gBAAA;;;UCLM,qBAAA;EAAA,SACN,GAAA;EAAA,SACA,MAAA,GAAS,gBAAA;EAAA,SACT,KAAA,GAAQ,SAAA;AAAA;;;iBCaH,mBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,qBAAA;;;iBCjBK,uBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA;EAAA,SACW,UAAA;AAAA;;;iBC8BG,4BAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA;EAAA,SACW,MAAA,GAAS,gBAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/analyze-options.ts","../src/types/dependency-kind.ts","../src/types/reference-kind.ts","../src/types/dependency-edge.ts","../src/types/source-module-node.ts","../src/types/dependency-graph.ts","../src/analyzers/import/index.ts","../src/types/react-usage-location.ts","../src/types/react-usage-entry.ts","../src/types/react-symbol-kind.ts","../src/types/react-usage-edge-kind.ts","../src/types/react-usage-edge.ts","../src/types/react-usage-node.ts","../src/types/react-usage-graph.ts","../src/analyzers/react/index.ts","../src/types/react-usage-filter.ts","../src/analyzers/react/queries.ts","../src/types/color-mode.ts","../src/types/print-tree-options.ts","../src/output/ascii/import.ts","../src/types/print-react-tree-options.ts","../src/output/ascii/react.ts","../src/output/json/import.ts","../src/output/json/react.ts"],"mappings":";UAAiB,cAAA;EAAA,SACN,GAAA;EAAA,SACA,UAAA;EAAA,SACA,gBAAA;EAAA,SACA,WAAA;EAAA,SACA,eAAA;AAAA;;;KCLC,cAAA;;;KCAA,aAAA;;;UCGK,cAAA;EAAA,SACN,SAAA;EAAA,SACA,aAAA,EAAe,aAAA;EAAA,SACf,UAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA,EAAM,cAAA;EAAA,SACN,MAAA;EAAA,SACA,QAAA;AAAA;;;UCRM,gBAAA;EAAA,SACN,EAAA;EAAA,SACA,YAAA,WAAuB,cAAA;AAAA;;;UCFjB,eAAA;EAAA,SACN,GAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA,EAAO,WAAA,SAAoB,gBAAA;EAAA,SAC3B,UAAA;AAAA;;;iBCGK,mBAAA,CACd,SAAA,UACA,OAAA,GAAS,cAAA,GACR,eAAA;;;UCZc,kBAAA;EAAA,SACN,QAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;;;UCDM,eAAA;EAAA,SACN,MAAA;EAAA,SACA,aAAA;EAAA,SACA,QAAA,EAAU,kBAAA;AAAA;;;KCLT,eAAA;;;KCAA,kBAAA;;;UCEK,cAAA;EAAA,SACN,IAAA,EAAM,kBAAA;EAAA,SACN,MAAA;EAAA,SACA,aAAA;AAAA;;;UCFM,cAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA,EAAM,eAAA;EAAA,SACN,QAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,WAAiB,cAAA;AAAA;;;UCNX,eAAA;EAAA,SACN,GAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA,EAAO,WAAA,SAAoB,cAAA;EAAA,SAC3B,OAAA,WAAkB,eAAA;AAAA;;;iBCgBb,iBAAA,CACd,SAAA,8BACA,OAAA,GAAS,cAAA,GACR,eAAA;;;KCzBS,gBAAA,WAA2B,eAAA;;;iBCKvB,oBAAA,CACd,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA,GACP,eAAA;AAAA,iBAOa,kBAAA,CACd,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA;AAAA,iBAsCM,iBAAA,CACd,IAAA,EAAM,cAAA,EACN,KAAA,EAAO,eAAA,EACP,MAAA,GAAQ,gBAAA,GACP,cAAA;;;KC7DS,SAAA;;;UCEK,gBAAA;EAAA,SACN,GAAA;EAAA,SACA,gBAAA;EAAA,SACA,UAAA;EAAA,SACA,KAAA,GAAQ,SAAA;AAAA;;;iBCAH,mBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,gBAAA;;;UCLM,qBAAA;EAAA,SACN,GAAA;EAAA,SACA,MAAA,GAAS,gBAAA;EAAA,SACT,KAAA,GAAQ,SAAA;AAAA;;;iBCaH,mBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,qBAAA;;;iBCjBK,uBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA;EAAA,SACW,UAAA;AAAA;;;iBC8BG,4BAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA;EAAA,SACW,MAAA,GAAS,gBAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as getFilteredUsages, c as analyzeReactUsage, i as printDependencyTree, l as analyzeDependencies, n as graphToSerializableTree, o as getReactUsageEntries, r as printReactUsageTree, s as getReactUsageRoots, t as graphToSerializableReactTree } from "./react-qiCwZtzi.mjs";
1
+ import { a as getFilteredUsages, c as analyzeReactUsage, i as printDependencyTree, l as analyzeDependencies, n as graphToSerializableTree, o as getReactUsageEntries, r as printReactUsageTree, s as getReactUsageRoots, t as graphToSerializableReactTree } from "./react-B0frvTuH.mjs";
2
2
  export { analyzeDependencies, analyzeReactUsage, getFilteredUsages, getReactUsageEntries, getReactUsageRoots, graphToSerializableReactTree, graphToSerializableTree, printDependencyTree, printReactUsageTree };
@@ -988,11 +988,19 @@ function compareReactNodes(left, right) {
988
988
  //#endregion
989
989
  //#region src/analyzers/react/index.ts
990
990
  function analyzeReactUsage(entryFile, options = {}) {
991
- return new ReactAnalyzer(entryFile, options).analyze();
991
+ return new ReactAnalyzer(normalizeEntryFiles(entryFile), options).analyze();
992
992
  }
993
993
  var ReactAnalyzer = class extends BaseAnalyzer {
994
+ constructor(entryFiles, options) {
995
+ const [firstEntryFile] = entryFiles;
996
+ if (firstEntryFile === void 0) throw new Error("At least one React entry file is required.");
997
+ super(firstEntryFile, options);
998
+ this.entryFiles = entryFiles;
999
+ }
994
1000
  doAnalyze() {
995
- const dependencyGraph = analyzeDependencies(this.entryFile, this.options);
1001
+ const dependencyGraphs = this.entryFiles.map((entryFile) => analyzeDependencies(entryFile, this.options));
1002
+ const dependencyGraph = mergeDependencyGraphs(dependencyGraphs);
1003
+ const entryIds = dependencyGraphs.map((graph) => graph.entryId);
996
1004
  const fileAnalyses = this.collectFileAnalyses(dependencyGraph);
997
1005
  const nodes = this.createNodes(fileAnalyses);
998
1006
  this.attachUsages(fileAnalyses, nodes);
@@ -1000,12 +1008,13 @@ var ReactAnalyzer = class extends BaseAnalyzer {
1000
1008
  return {
1001
1009
  cwd: dependencyGraph.cwd,
1002
1010
  entryId: dependencyGraph.entryId,
1011
+ entryIds,
1003
1012
  nodes,
1004
1013
  entries
1005
1014
  };
1006
1015
  }
1007
1016
  collectFileAnalyses(dependencyGraph) {
1008
- const reachableFiles = new Set([dependencyGraph.entryId, ...dependencyGraph.nodes.keys()]);
1017
+ const reachableFiles = new Set([...dependencyGraph.entryIds, ...dependencyGraph.nodes.keys()]);
1009
1018
  const fileAnalyses = /* @__PURE__ */ new Map();
1010
1019
  for (const filePath of [...reachableFiles].sort()) {
1011
1020
  if (!isSourceCodeFile(filePath) || filePath.endsWith(".d.ts")) continue;
@@ -1019,7 +1028,7 @@ var ReactAnalyzer = class extends BaseAnalyzer {
1019
1028
  dependencyNode?.dependencies.forEach((dependency) => {
1020
1029
  if (dependency.kind === "source") sourceDependencies.set(dependency.specifier, dependency.target);
1021
1030
  });
1022
- fileAnalyses.set(filePath, analyzeReactFile(parseResult.program, filePath, sourceText, filePath === dependencyGraph.entryId, sourceDependencies, this.options.includeBuiltins === true));
1031
+ fileAnalyses.set(filePath, analyzeReactFile(parseResult.program, filePath, sourceText, dependencyGraph.entryIds.includes(filePath), sourceDependencies, this.options.includeBuiltins === true));
1023
1032
  }
1024
1033
  return fileAnalyses;
1025
1034
  }
@@ -1088,6 +1097,27 @@ var ReactAnalyzer = class extends BaseAnalyzer {
1088
1097
  return [...entriesByKey.values()].sort((left, right) => compareReactUsageEntries(left, right, nodes));
1089
1098
  }
1090
1099
  };
1100
+ function normalizeEntryFiles(entryFile) {
1101
+ const entryFiles = Array.isArray(entryFile) ? entryFile : [entryFile];
1102
+ const dedupedEntryFiles = [...new Set(entryFiles)];
1103
+ if (dedupedEntryFiles.length === 0) throw new Error("At least one React entry file is required.");
1104
+ return dedupedEntryFiles;
1105
+ }
1106
+ function mergeDependencyGraphs(graphs) {
1107
+ const firstGraph = graphs[0];
1108
+ if (firstGraph === void 0) throw new Error("At least one dependency graph is required.");
1109
+ const nodes = /* @__PURE__ */ new Map();
1110
+ for (const graph of graphs) for (const [nodeId, node] of graph.nodes) if (!nodes.has(nodeId)) nodes.set(nodeId, node);
1111
+ const uniqueConfigPaths = [...new Set(graphs.map((graph) => graph.configPath))];
1112
+ const configPath = uniqueConfigPaths.length === 1 ? uniqueConfigPaths[0] : void 0;
1113
+ return {
1114
+ cwd: firstGraph.cwd,
1115
+ entryId: firstGraph.entryId,
1116
+ entryIds: graphs.map((graph) => graph.entryId),
1117
+ nodes,
1118
+ ...configPath === void 0 ? {} : { configPath }
1119
+ };
1120
+ }
1091
1121
  //#endregion
1092
1122
  //#region src/analyzers/react/queries.ts
1093
1123
  function getReactUsageEntries(graph, filter = "all") {
@@ -1409,6 +1439,6 @@ function formatReactNodeFilePath(filePath, kind, cwd) {
1409
1439
  return kind === "builtin" ? "html" : toDisplayPath(filePath, cwd);
1410
1440
  }
1411
1441
  //#endregion
1412
- export { getFilteredUsages as a, analyzeReactUsage as c, printDependencyTree as i, analyzeDependencies as l, graphToSerializableTree as n, getReactUsageEntries as o, printReactUsageTree as r, getReactUsageRoots as s, graphToSerializableReactTree as t };
1442
+ export { getFilteredUsages as a, analyzeReactUsage as c, printDependencyTree as i, analyzeDependencies as l, graphToSerializableTree as n, getReactUsageEntries as o, printReactUsageTree as r, getReactUsageRoots as s, graphToSerializableReactTree as t, isSourceCodeFile as u };
1413
1443
 
1414
- //# sourceMappingURL=react-qiCwZtzi.mjs.map
1444
+ //# sourceMappingURL=react-B0frvTuH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-B0frvTuH.mjs","names":["isInsideNodeModules","process","formatReactNodeFilePath"],"sources":["../src/typescript/config.ts","../src/analyzers/base.ts","../src/utils/is-source-code-file.ts","../src/utils/normalize-file-path.ts","../src/analyzers/import/entry.ts","../src/typescript/program.ts","../src/analyzers/import/unused.ts","../src/analyzers/import/references.ts","../src/analyzers/import/resolver.ts","../src/analyzers/import/graph.ts","../src/analyzers/import/index.ts","../src/analyzers/react/bindings.ts","../src/analyzers/react/walk.ts","../src/analyzers/react/entries.ts","../src/analyzers/react/symbols.ts","../src/analyzers/react/usage.ts","../src/analyzers/react/file.ts","../src/analyzers/react/references.ts","../src/analyzers/react/index.ts","../src/analyzers/react/queries.ts","../src/color.ts","../src/utils/to-display-path.ts","../src/output/ascii/import.ts","../src/output/ascii/react.ts","../src/output/json/import.ts","../src/output/json/react.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\n\nexport interface LoadedConfig {\n readonly path?: string\n readonly compilerOptions: ts.CompilerOptions\n}\n\nexport function loadCompilerOptions(\n searchFrom: string,\n explicitConfigPath?: string,\n): LoadedConfig {\n const configPath =\n explicitConfigPath === undefined\n ? findNearestConfig(searchFrom)\n : path.resolve(searchFrom, explicitConfigPath)\n\n if (configPath === undefined) {\n return {\n compilerOptions: defaultCompilerOptions(),\n }\n }\n\n const readResult = ts.readConfigFile(configPath, ts.sys.readFile)\n if (readResult.error !== undefined) {\n throw new Error(\n `Failed to read TypeScript config at ${configPath}: ${formatDiagnostic(\n readResult.error,\n )}`,\n )\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n readResult.config,\n ts.sys,\n path.dirname(configPath),\n defaultCompilerOptions(),\n configPath,\n )\n\n if (parsed.errors.length > 0) {\n const [firstError] = parsed.errors\n if (firstError === undefined) {\n throw new Error(`Failed to parse TypeScript config at ${configPath}.`)\n }\n\n throw new Error(\n `Failed to parse TypeScript config at ${configPath}: ${formatDiagnostic(\n firstError,\n )}`,\n )\n }\n\n return {\n path: configPath,\n compilerOptions: parsed.options,\n }\n}\n\nfunction findNearestConfig(searchFrom: string): string | undefined {\n let currentDirectory = path.resolve(searchFrom)\n\n while (true) {\n if (!isInsideNodeModules(currentDirectory)) {\n const tsconfigPath = path.join(currentDirectory, 'tsconfig.json')\n if (ts.sys.fileExists(tsconfigPath)) {\n return tsconfigPath\n }\n\n const jsconfigPath = path.join(currentDirectory, 'jsconfig.json')\n if (ts.sys.fileExists(jsconfigPath)) {\n return jsconfigPath\n }\n }\n\n const parentDirectory = path.dirname(currentDirectory)\n if (parentDirectory === currentDirectory) {\n return undefined\n }\n\n currentDirectory = parentDirectory\n }\n}\n\nfunction defaultCompilerOptions(): ts.CompilerOptions {\n return {\n allowJs: true,\n jsx: ts.JsxEmit.ReactJSX,\n module: ts.ModuleKind.NodeNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n target: ts.ScriptTarget.ESNext,\n resolveJsonModule: true,\n esModuleInterop: true,\n }\n}\n\nfunction formatDiagnostic(diagnostic: ts.Diagnostic): string {\n return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n}\n\nfunction isInsideNodeModules(filePath: string): boolean {\n return filePath.includes(`${path.sep}node_modules${path.sep}`)\n}\n","import type { AnalyzeOptions } from '../types/analyze-options.js'\n\nexport abstract class BaseAnalyzer<TGraph> {\n constructor(\n protected readonly entryFile: string,\n protected readonly options: AnalyzeOptions,\n ) {}\n\n analyze(): TGraph {\n return this.doAnalyze()\n }\n\n protected abstract doAnalyze(): TGraph\n}\n","import path from 'node:path'\n\nexport const SOURCE_EXTENSIONS = new Set([\n '.js',\n '.jsx',\n '.ts',\n '.tsx',\n '.mjs',\n '.cjs',\n '.mts',\n '.cts',\n])\n\nexport function isSourceCodeFile(filePath: string): boolean {\n return SOURCE_EXTENSIONS.has(path.extname(filePath).toLowerCase())\n}\n","import path from 'node:path'\n\nexport function normalizeFilePath(filePath: string): string {\n return path.normalize(filePath)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\n\nexport function resolveExistingPath(cwd: string, entryFile: string): string {\n const absolutePath = path.resolve(cwd, entryFile)\n const normalizedPath = normalizeFilePath(absolutePath)\n\n if (!fs.existsSync(normalizedPath)) {\n throw new Error(`Entry file not found: ${entryFile}`)\n }\n\n if (!isSourceCodeFile(normalizedPath)) {\n throw new Error(`Entry file must be a JS/TS source file: ${entryFile}`)\n }\n\n return normalizedPath\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript'\n\nexport function createProgram(\n entryFile: string,\n compilerOptions: ts.CompilerOptions,\n currentDirectory: string,\n): ts.Program {\n const host = ts.createCompilerHost(compilerOptions, true)\n host.getCurrentDirectory = () => currentDirectory\n\n if (ts.sys.realpath !== undefined) {\n host.realpath = ts.sys.realpath\n }\n\n return ts.createProgram({\n rootNames: [entryFile],\n options: compilerOptions,\n host,\n })\n}\n\nexport function createSourceFile(filePath: string): ts.SourceFile {\n const sourceText = fs.readFileSync(filePath, 'utf8')\n return ts.createSourceFile(\n filePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true,\n getScriptKind(filePath),\n )\n}\n\nexport function createModuleResolutionHost(\n currentDirectory: string,\n): ts.ModuleResolutionHost {\n return {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n directoryExists: ts.sys.directoryExists,\n getCurrentDirectory: () => currentDirectory,\n getDirectories: ts.sys.getDirectories,\n ...(ts.sys.realpath === undefined ? {} : { realpath: ts.sys.realpath }),\n }\n}\n\nfunction getScriptKind(filePath: string): ts.ScriptKind {\n switch (path.extname(filePath).toLowerCase()) {\n case '.js':\n case '.mjs':\n case '.cjs':\n return ts.ScriptKind.JS\n case '.jsx':\n return ts.ScriptKind.JSX\n case '.tsx':\n return ts.ScriptKind.TSX\n case '.json':\n return ts.ScriptKind.JSON\n default:\n return ts.ScriptKind.TS\n }\n}\n","import ts from 'typescript'\n\nexport function collectUnusedImports(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n): ReadonlyMap<ts.ImportDeclaration, boolean> {\n const importUsage = new Map<\n ts.ImportDeclaration,\n {\n canTrack: boolean\n used: boolean\n }\n >()\n const symbolToImportDeclaration = new Map<ts.Symbol, ts.ImportDeclaration>()\n const importedLocalNames = new Set<string>()\n\n sourceFile.statements.forEach((statement) => {\n if (\n !ts.isImportDeclaration(statement) ||\n statement.importClause === undefined\n ) {\n return\n }\n\n const identifiers = getImportBindingIdentifiers(statement.importClause)\n if (identifiers.length === 0) {\n return\n }\n\n importUsage.set(statement, {\n canTrack: false,\n used: false,\n })\n\n identifiers.forEach((identifier) => {\n importedLocalNames.add(identifier.text)\n\n const symbol = tryGetSymbolAtLocation(checker, identifier)\n if (symbol === undefined) {\n return\n }\n\n symbolToImportDeclaration.set(symbol, statement)\n const state = importUsage.get(statement)\n if (state !== undefined) {\n state.canTrack = true\n }\n })\n })\n\n function visit(node: ts.Node): void {\n if (ts.isImportDeclaration(node)) {\n return\n }\n\n if (\n ts.isIdentifier(node) &&\n importedLocalNames.has(node.text) &&\n isReferenceIdentifier(node)\n ) {\n const symbol = tryGetSymbolAtLocation(checker, node)\n const declaration =\n symbol === undefined ? undefined : symbolToImportDeclaration.get(symbol)\n if (declaration !== undefined) {\n const state = importUsage.get(declaration)\n if (state !== undefined) {\n state.used = true\n }\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n return new Map(\n [...importUsage.entries()].map(([declaration, state]) => [\n declaration,\n state.canTrack && !state.used,\n ]),\n )\n}\n\nfunction getImportBindingIdentifiers(\n importClause: ts.ImportClause,\n): ts.Identifier[] {\n const identifiers: ts.Identifier[] = []\n\n if (importClause.name !== undefined) {\n identifiers.push(importClause.name)\n }\n\n const namedBindings = importClause.namedBindings\n if (namedBindings === undefined) {\n return identifiers\n }\n\n if (ts.isNamespaceImport(namedBindings)) {\n identifiers.push(namedBindings.name)\n return identifiers\n }\n\n namedBindings.elements.forEach((element) => {\n identifiers.push(element.name)\n })\n\n return identifiers\n}\n\nfunction isReferenceIdentifier(node: ts.Identifier): boolean {\n const parent = node.parent\n\n if (ts.isPropertyAccessExpression(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isQualifiedName(parent) && parent.right === node) {\n return false\n }\n\n if (ts.isPropertyAssignment(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isBindingElement(parent) && parent.propertyName === node) {\n return false\n }\n\n if (ts.isJsxAttribute(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isExportSpecifier(parent)) {\n return parent.propertyName === node || parent.propertyName === undefined\n }\n\n return true\n}\n\nfunction tryGetSymbolAtLocation(\n checker: ts.TypeChecker,\n node: ts.Node,\n): ts.Symbol | undefined {\n try {\n return checker.getSymbolAtLocation(node)\n } catch {\n return undefined\n }\n}\n","import ts from 'typescript'\n\nimport type { ReferenceKind } from '../../types/reference-kind.js'\nimport { collectUnusedImports } from './unused.js'\n\nexport interface ModuleReference {\n readonly specifier: string\n readonly referenceKind: ReferenceKind\n readonly isTypeOnly: boolean\n readonly unused: boolean\n}\n\nexport function collectModuleReferences(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n): ModuleReference[] {\n const references = new Map<string, ModuleReference>()\n const unusedImports = collectUnusedImports(sourceFile, checker)\n\n function addReference(\n specifier: string,\n referenceKind: ReferenceKind,\n isTypeOnly: boolean,\n unused: boolean,\n ): void {\n const key = `${referenceKind}:${isTypeOnly ? 'type' : 'value'}:${specifier}`\n const existing = references.get(key)\n if (existing !== undefined) {\n if (existing.unused && !unused) {\n references.set(key, {\n ...existing,\n unused: false,\n })\n }\n return\n }\n\n references.set(key, {\n specifier,\n referenceKind,\n isTypeOnly,\n unused,\n })\n }\n\n function visit(node: ts.Node): void {\n if (\n ts.isImportDeclaration(node) &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n addReference(\n node.moduleSpecifier.text,\n 'import',\n node.importClause?.isTypeOnly ?? false,\n unusedImports.get(node) ?? false,\n )\n } else if (\n ts.isExportDeclaration(node) &&\n node.moduleSpecifier !== undefined &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n addReference(\n node.moduleSpecifier.text,\n 'export',\n node.isTypeOnly ?? false,\n false,\n )\n } else if (ts.isImportEqualsDeclaration(node)) {\n const moduleReference = node.moduleReference\n if (\n ts.isExternalModuleReference(moduleReference) &&\n moduleReference.expression !== undefined &&\n ts.isStringLiteralLike(moduleReference.expression)\n ) {\n addReference(\n moduleReference.expression.text,\n 'import-equals',\n false,\n false,\n )\n }\n } else if (ts.isCallExpression(node)) {\n if (\n node.expression.kind === ts.SyntaxKind.ImportKeyword &&\n node.arguments.length === 1\n ) {\n const [argument] = node.arguments\n if (argument !== undefined && ts.isStringLiteralLike(argument)) {\n addReference(argument.text, 'dynamic-import', false, false)\n }\n }\n\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'require' &&\n node.arguments.length === 1\n ) {\n const [argument] = node.arguments\n if (argument !== undefined && ts.isStringLiteralLike(argument)) {\n addReference(argument.text, 'require', false, false)\n }\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return [...references.values()]\n}\n","import { builtinModules } from 'node:module'\nimport path from 'node:path'\nimport type { ResolverFactory } from 'oxc-resolver'\nimport ts from 'typescript'\n\nimport type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyKind } from '../../types/dependency-kind.js'\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\nimport type { ModuleReference } from './references.js'\n\nconst BUILTIN_MODULES = new Set(\n builtinModules.flatMap((name) => [name, `node:${name}`]),\n)\n\nexport interface ResolverConfigContext {\n readonly path?: string\n readonly compilerOptions: ts.CompilerOptions\n}\n\nexport interface ResolveDependencyOptions {\n readonly cwd: string\n readonly entryConfigPath?: string\n readonly expandWorkspaces: boolean\n readonly projectOnly: boolean\n readonly getConfigForFile: (filePath: string) => ResolverConfigContext\n readonly getResolverForFile: (filePath: string) => ResolverFactory\n}\n\nexport function resolveDependency(\n reference: ModuleReference,\n containingFile: string,\n options: ResolveDependencyOptions,\n): DependencyEdge {\n const specifier = reference.specifier\n if (BUILTIN_MODULES.has(specifier)) {\n return createEdge(reference, 'builtin', specifier)\n }\n\n const containingConfig = options.getConfigForFile(containingFile)\n const oxcResolution = resolveWithOxc(\n reference,\n specifier,\n containingFile,\n options,\n )\n if (oxcResolution !== undefined) {\n return oxcResolution\n }\n\n const host = createResolutionHost(containingConfig, options.cwd)\n const resolution = ts.resolveModuleName(\n specifier,\n containingFile,\n containingConfig.compilerOptions,\n host,\n ).resolvedModule\n\n if (resolution !== undefined) {\n const resolvedPath = normalizeFilePath(resolution.resolvedFileName)\n const realPath = resolveRealPath(resolvedPath)\n const sourcePath = pickSourcePath(resolvedPath, realPath)\n\n if (sourcePath !== undefined) {\n const boundary = classifyBoundary(specifier, sourcePath, options)\n if (boundary !== undefined) {\n return createEdge(reference, 'boundary', sourcePath, boundary)\n }\n\n if (\n !resolution.isExternalLibraryImport ||\n !isInsideNodeModules(sourcePath) ||\n (realPath !== undefined && !isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'source', sourcePath)\n }\n }\n\n if (\n resolution.isExternalLibraryImport ||\n isInsideNodeModules(resolvedPath) ||\n (realPath !== undefined && isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'external', specifier)\n }\n }\n\n if (!specifier.startsWith('.') && !path.isAbsolute(specifier)) {\n return createEdge(reference, 'external', specifier)\n }\n\n return createEdge(reference, 'missing', specifier)\n}\n\nfunction resolveWithOxc(\n reference: ModuleReference,\n specifier: string,\n containingFile: string,\n options: ResolveDependencyOptions,\n): DependencyEdge | undefined {\n try {\n const result = options\n .getResolverForFile(containingFile)\n .resolveFileSync(containingFile, specifier)\n\n if (result.builtin !== undefined) {\n return createEdge(reference, 'builtin', result.builtin.resolved)\n }\n\n if (result.path !== undefined) {\n return classifyResolvedPath(reference, specifier, result.path, options)\n }\n } catch {\n return undefined\n }\n\n return undefined\n}\n\nfunction createEdge(\n reference: ModuleReference,\n kind: DependencyKind,\n target: string,\n boundary?: 'workspace' | 'project',\n): DependencyEdge {\n return {\n specifier: reference.specifier,\n referenceKind: reference.referenceKind,\n isTypeOnly: reference.isTypeOnly,\n unused: reference.unused,\n kind,\n target,\n ...(boundary === undefined ? {} : { boundary }),\n }\n}\n\nfunction createResolutionHost(\n config: ResolverConfigContext,\n cwd: string,\n): ts.ModuleResolutionHost {\n return {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n directoryExists: ts.sys.directoryExists,\n getCurrentDirectory: () =>\n config.path === undefined ? cwd : path.dirname(config.path),\n getDirectories: ts.sys.getDirectories,\n ...(ts.sys.realpath === undefined ? {} : { realpath: ts.sys.realpath }),\n }\n}\n\nfunction resolveRealPath(resolvedPath: string): string | undefined {\n if (ts.sys.realpath === undefined) {\n return undefined\n }\n\n try {\n return normalizeFilePath(ts.sys.realpath(resolvedPath))\n } catch {\n return undefined\n }\n}\n\nfunction classifyResolvedPath(\n reference: ModuleReference,\n specifier: string,\n resolvedPathValue: string,\n options: ResolveDependencyOptions,\n): DependencyEdge {\n const resolvedPath = normalizeFilePath(resolvedPathValue)\n const realPath = resolveRealPath(resolvedPath)\n const sourcePath = pickSourcePath(resolvedPath, realPath)\n\n if (sourcePath !== undefined) {\n const boundary = classifyBoundary(specifier, sourcePath, options)\n if (boundary !== undefined) {\n return createEdge(reference, 'boundary', sourcePath, boundary)\n }\n\n if (\n !isInsideNodeModules(sourcePath) ||\n (realPath !== undefined && !isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'source', sourcePath)\n }\n }\n\n return createEdge(reference, 'external', specifier)\n}\n\nfunction pickSourcePath(\n resolvedPath: string,\n realPath: string | undefined,\n): string | undefined {\n const candidates = [realPath, resolvedPath]\n\n for (const candidate of candidates) {\n if (\n candidate !== undefined &&\n isSourceCodeFile(candidate) &&\n !candidate.endsWith('.d.ts')\n ) {\n return candidate\n }\n }\n\n return undefined\n}\n\nfunction classifyBoundary(\n specifier: string,\n sourcePath: string,\n options: ResolveDependencyOptions,\n): 'workspace' | 'project' | undefined {\n const targetConfigPath = options.getConfigForFile(sourcePath).path\n const entryConfigPath = options.entryConfigPath\n\n if (\n options.projectOnly &&\n entryConfigPath !== undefined &&\n targetConfigPath !== entryConfigPath\n ) {\n return 'project'\n }\n\n if (\n !options.expandWorkspaces &&\n isWorkspaceLikeImport(specifier) &&\n entryConfigPath !== undefined &&\n targetConfigPath !== entryConfigPath\n ) {\n return 'workspace'\n }\n\n return undefined\n}\n\nfunction isWorkspaceLikeImport(specifier: string): boolean {\n return !specifier.startsWith('.') && !path.isAbsolute(specifier)\n}\n\nfunction isInsideNodeModules(filePath: string): boolean {\n return filePath.includes(`${path.sep}node_modules${path.sep}`)\n}\n","import path from 'node:path'\nimport { ResolverFactory } from 'oxc-resolver'\nimport type ts from 'typescript'\n\nimport type { SourceModuleNode } from '../../types/source-module-node.js'\nimport { loadCompilerOptions } from '../../typescript/config.js'\nimport { createProgram, createSourceFile } from '../../typescript/program.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\nimport { collectModuleReferences } from './references.js'\nimport { resolveDependency } from './resolver.js'\n\nexport function buildDependencyGraph(\n entryPath: string,\n options: BuildDependencyGraphOptions,\n): Map<string, SourceModuleNode> {\n return new DependencyGraphBuilder(entryPath, options).build()\n}\n\nexport interface BuildDependencyGraphOptions {\n readonly cwd: string\n readonly entryConfigPath?: string\n readonly entryCompilerOptions: ts.CompilerOptions\n readonly expandWorkspaces: boolean\n readonly projectOnly: boolean\n}\n\nclass DependencyGraphBuilder {\n private readonly nodes = new Map<string, SourceModuleNode>()\n private readonly configCache = new Map<\n string,\n import('./resolver.js').ResolverConfigContext\n >()\n private readonly programCache = new Map<string, ts.Program>()\n private readonly checkerCache = new Map<string, ts.TypeChecker>()\n private readonly resolverCache = new Map<string, ResolverFactory>()\n\n constructor(\n private readonly entryPath: string,\n private readonly options: BuildDependencyGraphOptions,\n ) {\n const entryConfig: import('./resolver.js').ResolverConfigContext = {\n compilerOptions: options.entryCompilerOptions,\n ...(options.entryConfigPath === undefined\n ? {}\n : { path: options.entryConfigPath }),\n }\n\n this.configCache.set(path.dirname(this.entryPath), entryConfig)\n }\n\n build(): Map<string, SourceModuleNode> {\n this.visitFile(this.entryPath)\n return this.nodes\n }\n\n private visitFile(filePath: string): void {\n const normalizedPath = normalizeFilePath(filePath)\n if (this.nodes.has(normalizedPath)) {\n return\n }\n\n const config = this.getConfigForFile(normalizedPath)\n const program = this.getProgramForFile(normalizedPath, config)\n const checker = this.getCheckerForFile(normalizedPath, config)\n const sourceFile =\n program.getSourceFile(normalizedPath) ?? createSourceFile(normalizedPath)\n\n const references = collectModuleReferences(sourceFile, checker)\n const dependencies = references.map((reference) =>\n resolveDependency(reference, normalizedPath, {\n cwd: this.options.cwd,\n expandWorkspaces: this.options.expandWorkspaces,\n projectOnly: this.options.projectOnly,\n getConfigForFile: (targetPath) => this.getConfigForFile(targetPath),\n getResolverForFile: (targetPath) => this.getResolverForFile(targetPath),\n ...(this.options.entryConfigPath === undefined\n ? {}\n : { entryConfigPath: this.options.entryConfigPath }),\n }),\n )\n\n this.nodes.set(normalizedPath, {\n id: normalizedPath,\n dependencies,\n })\n\n for (const dependency of dependencies) {\n if (dependency.kind === 'source') {\n this.visitFile(dependency.target)\n }\n }\n }\n\n private getConfigForFile(\n filePath: string,\n ): import('./resolver.js').ResolverConfigContext {\n const directory = path.dirname(filePath)\n const cached = this.configCache.get(directory)\n if (cached !== undefined) {\n return cached\n }\n\n const loaded = loadCompilerOptions(directory)\n this.configCache.set(directory, loaded)\n return loaded\n }\n\n private getProgramForFile(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): ts.Program {\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.programCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const currentDirectory =\n config.path === undefined\n ? path.dirname(filePath)\n : path.dirname(config.path)\n const program = createProgram(\n filePath,\n config.compilerOptions,\n currentDirectory,\n )\n this.programCache.set(cacheKey, program)\n return program\n }\n\n private getCheckerForFile(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): ts.TypeChecker {\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.checkerCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const checker = this.getProgramForFile(filePath, config).getTypeChecker()\n this.checkerCache.set(cacheKey, checker)\n return checker\n }\n\n private getProgramCacheKey(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): string {\n return config.path ?? `default:${path.dirname(filePath)}`\n }\n\n private getResolverForFile(filePath: string): ResolverFactory {\n const config = this.getConfigForFile(filePath)\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.resolverCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const resolver = new ResolverFactory({\n builtinModules: true,\n conditionNames: ['import', 'require', 'default'],\n extensions: [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.mts',\n '.cts',\n '.mjs',\n '.cjs',\n '.json',\n ],\n mainFields: ['types', 'module', 'main'],\n tsconfig:\n config.path === undefined ? 'auto' : { configFile: config.path },\n })\n this.resolverCache.set(cacheKey, resolver)\n return resolver\n }\n}\n","import path from 'node:path'\n\nimport type { AnalyzeOptions } from '../../types/analyze-options.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport { loadCompilerOptions } from '../../typescript/config.js'\nimport { BaseAnalyzer } from '../base.js'\nimport { resolveExistingPath } from './entry.js'\nimport { buildDependencyGraph } from './graph.js'\n\nexport function analyzeDependencies(\n entryFile: string,\n options: AnalyzeOptions = {},\n): DependencyGraph {\n return new ImportAnalyzer(entryFile, options).analyze()\n}\n\nclass ImportAnalyzer extends BaseAnalyzer<DependencyGraph> {\n private readonly cwd: string\n private readonly entryPath: string\n\n constructor(entryFile: string, options: AnalyzeOptions) {\n super(entryFile, options)\n this.cwd = path.resolve(options.cwd ?? process.cwd())\n this.entryPath = resolveExistingPath(this.cwd, entryFile)\n }\n\n protected doAnalyze(): DependencyGraph {\n const { compilerOptions, path: configPath } = loadCompilerOptions(\n path.dirname(this.entryPath),\n this.options.configPath,\n )\n const nodes = buildDependencyGraph(this.entryPath, {\n cwd: this.cwd,\n entryCompilerOptions: compilerOptions,\n expandWorkspaces: this.options.expandWorkspaces ?? true,\n projectOnly: this.options.projectOnly ?? false,\n ...(configPath === undefined ? {} : { entryConfigPath: configPath }),\n })\n\n return {\n cwd: this.cwd,\n entryId: this.entryPath,\n nodes,\n ...(configPath === undefined ? {} : { configPath }),\n }\n }\n}\n","import type {\n ExportAllDeclaration,\n ExportDefaultDeclaration,\n ExportNamedDeclaration,\n ImportDeclaration,\n ImportDeclarationSpecifier,\n ModuleExportName,\n Statement,\n} from 'oxc-parser'\n\nimport type { PendingReactUsageNode } from './file.js'\n\nexport interface ImportBinding {\n readonly importedName: string\n readonly sourceSpecifier: string\n readonly sourcePath?: string\n}\n\nexport function collectImportsAndExports(\n statement: Statement,\n sourceDependencies: ReadonlyMap<string, string>,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n importsByLocalName: Map<string, ImportBinding>,\n exportsByName: Map<string, string>,\n reExportBindingsByName: Map<string, ImportBinding>,\n exportAllBindings: ImportBinding[],\n): void {\n switch (statement.type) {\n case 'ImportDeclaration':\n collectImportBindings(statement, sourceDependencies, importsByLocalName)\n return\n case 'ExportNamedDeclaration':\n collectNamedExports(\n statement,\n sourceDependencies,\n symbolsByName,\n exportsByName,\n reExportBindingsByName,\n )\n return\n case 'ExportAllDeclaration':\n collectExportAllBindings(statement, sourceDependencies, exportAllBindings)\n return\n case 'ExportDefaultDeclaration':\n collectDefaultExport(statement, symbolsByName, exportsByName)\n return\n default:\n return\n }\n}\n\nfunction collectImportBindings(\n declaration: ImportDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n importsByLocalName: Map<string, ImportBinding>,\n): void {\n if (declaration.importKind === 'type') {\n return\n }\n\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(declaration.source.value)\n\n declaration.specifiers.forEach((specifier) => {\n const binding = getImportBinding(specifier, sourceSpecifier, sourcePath)\n if (binding === undefined) {\n return\n }\n\n importsByLocalName.set(binding.localName, {\n importedName: binding.importedName,\n sourceSpecifier: binding.sourceSpecifier,\n ...(binding.sourcePath === undefined\n ? {}\n : { sourcePath: binding.sourcePath }),\n })\n })\n}\n\nfunction getImportBinding(\n specifier: ImportDeclarationSpecifier,\n sourceSpecifier: string,\n sourcePath: string | undefined,\n):\n | {\n readonly localName: string\n readonly importedName: string\n readonly sourceSpecifier: string\n readonly sourcePath?: string\n }\n | undefined {\n if (specifier.type === 'ImportSpecifier') {\n if (specifier.importKind === 'type') {\n return undefined\n }\n\n return {\n localName: specifier.local.name,\n importedName: toModuleExportName(specifier.imported),\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n }\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n return {\n localName: specifier.local.name,\n importedName: 'default',\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n }\n }\n\n return undefined\n}\n\nfunction collectNamedExports(\n declaration: ExportNamedDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n reExportBindingsByName: Map<string, ImportBinding>,\n): void {\n if (declaration.exportKind === 'type') {\n return\n }\n\n if (declaration.declaration !== null) {\n if (declaration.declaration.type === 'FunctionDeclaration') {\n const name = declaration.declaration.id?.name\n if (name !== undefined) {\n addExportBinding(name, name, symbolsByName, exportsByName)\n }\n } else if (declaration.declaration.type === 'VariableDeclaration') {\n declaration.declaration.declarations.forEach((declarator) => {\n if (declarator.id.type === 'Identifier') {\n addExportBinding(\n declarator.id.name,\n declarator.id.name,\n symbolsByName,\n exportsByName,\n )\n }\n })\n }\n\n return\n }\n\n if (declaration.source !== null) {\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(sourceSpecifier)\n\n declaration.specifiers.forEach((specifier) => {\n if (specifier.exportKind === 'type') {\n return\n }\n\n reExportBindingsByName.set(toModuleExportName(specifier.exported), {\n importedName: toModuleExportName(specifier.local),\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n })\n })\n return\n }\n\n declaration.specifiers.forEach((specifier) => {\n if (specifier.exportKind === 'type') {\n return\n }\n\n const localName = toModuleExportName(specifier.local)\n const exportedName = toModuleExportName(specifier.exported)\n addExportBinding(localName, exportedName, symbolsByName, exportsByName)\n })\n}\n\nfunction collectExportAllBindings(\n declaration: ExportAllDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n exportAllBindings: ImportBinding[],\n): void {\n if (declaration.exportKind === 'type') {\n return\n }\n\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(sourceSpecifier)\n\n exportAllBindings.push({\n importedName: '*',\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n })\n}\n\nfunction collectDefaultExport(\n declaration: ExportDefaultDeclaration,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n): void {\n if (\n declaration.declaration.type === 'FunctionDeclaration' ||\n declaration.declaration.type === 'FunctionExpression'\n ) {\n const localName = declaration.declaration.id?.name\n if (localName !== undefined) {\n addExportBinding(localName, 'default', symbolsByName, exportsByName)\n }\n return\n }\n\n if (declaration.declaration.type === 'Identifier') {\n addExportBinding(\n declaration.declaration.name,\n 'default',\n symbolsByName,\n exportsByName,\n )\n return\n }\n\n if (declaration.declaration.type === 'ArrowFunctionExpression') {\n addExportBinding('default', 'default', symbolsByName, exportsByName)\n }\n}\n\nfunction addExportBinding(\n localName: string,\n exportedName: string,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n): void {\n const symbol = symbolsByName.get(localName)\n if (symbol === undefined) {\n return\n }\n\n symbol.exportNames.add(exportedName)\n exportsByName.set(exportedName, symbol.id)\n}\n\nfunction toModuleExportName(name: ModuleExportName): string {\n return name.type === 'Literal' ? name.value : name.name\n}\n","import type {\n ArrowFunctionExpression,\n CallExpression,\n Expression,\n FunctionBody,\n JSXElement,\n JSXElementName,\n JSXFragment,\n Node,\n} from 'oxc-parser'\nimport { visitorKeys } from 'oxc-parser'\n\nexport const FUNCTION_NODE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'TSDeclareFunction',\n 'TSEmptyBodyFunctionExpression',\n])\n\nexport function walkReactUsageTree(\n root: FunctionBody | Expression | JSXFragment | JSXElement,\n visit: (node: Node) => void,\n): void {\n walkNode(root, visit, true)\n}\n\nexport function walkNode(\n node: Node,\n visit: (node: Node) => void,\n allowNestedFunctions = false,\n): void {\n visit(node)\n\n const keys = visitorKeys[node.type]\n if (keys === undefined) {\n return\n }\n\n keys.forEach((key) => {\n const value = (node as unknown as Record<string, unknown>)[key]\n walkChild(value, visit, allowNestedFunctions)\n })\n}\n\nfunction walkChild(\n value: unknown,\n visit: (node: Node) => void,\n allowNestedFunctions: boolean,\n): void {\n if (Array.isArray(value)) {\n value.forEach((entry) => {\n walkChild(entry, visit, allowNestedFunctions)\n })\n return\n }\n\n if (!isNode(value)) {\n return\n }\n\n if (!allowNestedFunctions && FUNCTION_NODE_TYPES.has(value.type)) {\n return\n }\n\n walkNode(value, visit, false)\n}\n\nexport function isNode(value: unknown): value is Node {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n typeof (value as { type: unknown }).type === 'string'\n )\n}\n\nexport function classifyReactSymbol(\n name: string,\n declaration: ArrowFunctionExpression | import('oxc-parser').Function,\n): import('../../types/react-symbol-kind.js').ReactSymbolKind | undefined {\n if (isHookName(name)) {\n return 'hook'\n }\n\n if (isComponentName(name) && returnsReactElement(declaration)) {\n return 'component'\n }\n\n return undefined\n}\n\nexport function containsReactElementLikeExpression(\n expression: Expression,\n): boolean {\n let found = false\n\n walkNode(expression, (node) => {\n if (\n node.type === 'JSXElement' ||\n node.type === 'JSXFragment' ||\n (node.type === 'CallExpression' && isReactCreateElementCall(node))\n ) {\n found = true\n }\n })\n\n return found\n}\n\nexport function getComponentReferenceName(\n node: JSXElement,\n): string | undefined {\n const name = getJsxName(node.openingElement.name)\n return name !== undefined && isComponentName(name) ? name : undefined\n}\n\nexport function getBuiltinReferenceName(node: JSXElement): string | undefined {\n const name = getJsxName(node.openingElement.name)\n return name !== undefined && isIntrinsicElementName(name) ? name : undefined\n}\n\nexport function getHookReferenceName(node: CallExpression): string | undefined {\n const calleeName = getIdentifierName(node.callee)\n return calleeName !== undefined && isHookName(calleeName)\n ? calleeName\n : undefined\n}\n\nexport function getCreateElementComponentReferenceName(\n node: CallExpression,\n): string | undefined {\n if (!isReactCreateElementCall(node)) {\n return undefined\n }\n\n const [firstArgument] = node.arguments\n if (firstArgument === undefined || firstArgument.type !== 'Identifier') {\n return undefined\n }\n\n return isComponentName(firstArgument.name) ? firstArgument.name : undefined\n}\n\nexport function isHookName(name: string): boolean {\n return /^use[A-Z0-9]/.test(name)\n}\n\nexport function isComponentName(name: string): boolean {\n return /^[A-Z]/.test(name)\n}\n\nfunction isIntrinsicElementName(name: string): boolean {\n return /^[a-z]/.test(name)\n}\n\nfunction returnsReactElement(\n declaration: ArrowFunctionExpression | import('oxc-parser').Function,\n): boolean {\n if (\n declaration.type === 'ArrowFunctionExpression' &&\n declaration.expression\n ) {\n return containsReactElementLikeExpression(declaration.body as Expression)\n }\n\n const body = declaration.body\n if (body === null) {\n return false\n }\n\n let found = false\n walkReactUsageTree(body, (node) => {\n if (node.type !== 'ReturnStatement' || node.argument === null) {\n return\n }\n\n if (containsReactElementLikeExpression(node.argument)) {\n found = true\n }\n })\n\n return found\n}\n\nfunction isReactCreateElementCall(node: CallExpression): boolean {\n const callee = unwrapExpression(node.callee)\n if (callee.type !== 'MemberExpression' || callee.computed) {\n return false\n }\n\n return (\n callee.object.type === 'Identifier' &&\n callee.object.name === 'React' &&\n callee.property.name === 'createElement'\n )\n}\n\nfunction getJsxName(name: JSXElementName): string | undefined {\n if (name.type === 'JSXIdentifier') {\n return name.name\n }\n\n return undefined\n}\n\nfunction getIdentifierName(expression: Expression): string | undefined {\n const unwrapped = unwrapExpression(expression)\n return unwrapped.type === 'Identifier' ? unwrapped.name : undefined\n}\n\nfunction unwrapExpression(expression: Expression): Expression {\n let current = expression\n\n while (true) {\n if (\n current.type === 'ParenthesizedExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSTypeAssertion' ||\n current.type === 'TSNonNullExpression'\n ) {\n current = current.expression\n continue\n }\n\n return current\n }\n}\n","import type { Node, Program, Statement } from 'oxc-parser'\nimport { visitorKeys } from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ReactUsageLocation } from '../../types/react-usage-location.js'\nimport {\n FUNCTION_NODE_TYPES,\n getBuiltinReferenceName,\n getComponentReferenceName,\n getCreateElementComponentReferenceName,\n getHookReferenceName,\n isNode,\n} from './walk.js'\n\nexport interface PendingReactUsageEntry {\n readonly referenceName: string\n readonly kind: ReactSymbolKind\n readonly location: ReactUsageLocation\n}\n\nexport function collectEntryUsages(\n program: Program,\n filePath: string,\n sourceText: string,\n includeBuiltins: boolean,\n): PendingReactUsageEntry[] {\n const entries = new Map<string, PendingReactUsageEntry>()\n\n program.body.forEach((statement) => {\n collectStatementEntryUsages(\n statement,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n )\n })\n\n return [...entries.values()].sort(comparePendingReactUsageEntries)\n}\n\nfunction collectStatementEntryUsages(\n statement: Statement,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n): void {\n collectNodeEntryUsages(\n statement,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n false,\n )\n}\n\nfunction collectNodeEntryUsages(\n node: Node,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n hasComponentAncestor: boolean,\n): void {\n if (FUNCTION_NODE_TYPES.has(node.type)) {\n return\n }\n\n let nextHasComponentAncestor = hasComponentAncestor\n\n if (node.type === 'JSXElement') {\n const referenceName = getComponentReferenceName(node)\n if (referenceName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n referenceName,\n 'component',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n } else if (includeBuiltins) {\n const builtinName = getBuiltinReferenceName(node)\n if (builtinName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n builtinName,\n 'builtin',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n }\n }\n } else if (node.type === 'CallExpression') {\n const hookReference = getHookReferenceName(node)\n if (hookReference !== undefined) {\n addPendingReactUsageEntry(\n entries,\n hookReference,\n 'hook',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n\n const referenceName = getCreateElementComponentReferenceName(node)\n if (referenceName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n referenceName,\n 'component',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n }\n }\n\n const keys = visitorKeys[node.type]\n if (keys === undefined) {\n return\n }\n\n keys.forEach((key) => {\n const value = (node as unknown as Record<string, unknown>)[key]\n collectEntryUsageChild(\n value,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n nextHasComponentAncestor,\n )\n })\n}\n\nfunction collectEntryUsageChild(\n value: unknown,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n hasComponentAncestor: boolean,\n): void {\n if (Array.isArray(value)) {\n value.forEach((entry) => {\n collectEntryUsageChild(\n entry,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n hasComponentAncestor,\n )\n })\n return\n }\n\n if (!isNode(value)) {\n return\n }\n\n collectNodeEntryUsages(\n value,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n hasComponentAncestor,\n )\n}\n\nfunction addPendingReactUsageEntry(\n entries: Map<string, PendingReactUsageEntry>,\n referenceName: string,\n kind: ReactSymbolKind,\n location: ReactUsageLocation,\n): void {\n const key = `${location.filePath}:${location.line}:${location.column}:${kind}:${referenceName}`\n entries.set(key, {\n referenceName,\n kind,\n location,\n })\n}\n\nexport function createReactUsageLocation(\n filePath: string,\n sourceText: string,\n offset: number,\n): ReactUsageLocation {\n return {\n filePath,\n ...offsetToLineAndColumn(sourceText, offset),\n }\n}\n\nfunction offsetToLineAndColumn(\n sourceText: string,\n offset: number,\n): Pick<ReactUsageLocation, 'line' | 'column'> {\n let line = 1\n let column = 1\n\n for (let index = 0; index < offset && index < sourceText.length; index += 1) {\n if (sourceText[index] === '\\n') {\n line += 1\n column = 1\n continue\n }\n\n column += 1\n }\n\n return { line, column }\n}\n\nfunction comparePendingReactUsageEntries(\n left: PendingReactUsageEntry,\n right: PendingReactUsageEntry,\n): number {\n return (\n left.location.filePath.localeCompare(right.location.filePath) ||\n left.location.line - right.location.line ||\n left.location.column - right.location.column ||\n left.kind.localeCompare(right.kind) ||\n left.referenceName.localeCompare(right.referenceName)\n )\n}\n","import type {\n ArrowFunctionExpression,\n ExportDefaultDeclaration,\n Function as OxcFunction,\n Statement,\n VariableDeclarator,\n} from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { PendingReactUsageNode } from './file.js'\nimport { classifyReactSymbol } from './walk.js'\n\nexport function collectTopLevelReactSymbols(\n statement: Statement,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n switch (statement.type) {\n case 'FunctionDeclaration':\n addFunctionSymbol(statement, filePath, symbolsByName)\n return\n case 'VariableDeclaration':\n statement.declarations.forEach((declarator) => {\n addVariableSymbol(declarator, filePath, symbolsByName)\n })\n return\n case 'ExportNamedDeclaration':\n if (statement.declaration !== null) {\n collectTopLevelReactSymbols(\n statement.declaration,\n filePath,\n symbolsByName,\n )\n }\n return\n case 'ExportDefaultDeclaration':\n addDefaultExportSymbol(statement, filePath, symbolsByName)\n return\n default:\n return\n }\n}\n\nfunction addFunctionSymbol(\n declaration: OxcFunction,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n const name = declaration.id?.name\n if (name === undefined) {\n return\n }\n\n const kind = classifyReactSymbol(name, declaration)\n if (kind === undefined) {\n return\n }\n\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declaration),\n )\n}\n\nfunction addVariableSymbol(\n declarator: VariableDeclarator,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n if (declarator.id.type !== 'Identifier' || declarator.init === null) {\n return\n }\n\n if (\n declarator.init.type !== 'ArrowFunctionExpression' &&\n declarator.init.type !== 'FunctionExpression'\n ) {\n return\n }\n\n const name = declarator.id.name\n const kind = classifyReactSymbol(name, declarator.init)\n if (kind === undefined) {\n return\n }\n\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declarator.init),\n )\n}\n\nfunction addDefaultExportSymbol(\n declaration: ExportDefaultDeclaration,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n if (\n declaration.declaration.type === 'FunctionDeclaration' ||\n declaration.declaration.type === 'FunctionExpression'\n ) {\n addFunctionSymbol(declaration.declaration, filePath, symbolsByName)\n } else if (declaration.declaration.type === 'ArrowFunctionExpression') {\n const name = 'default'\n const kind = declaration.declaration.body\n ? classifyReactSymbol(name, declaration.declaration)\n : undefined\n if (kind !== undefined) {\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declaration.declaration),\n )\n }\n }\n}\n\nfunction createPendingSymbol(\n filePath: string,\n name: string,\n kind: ReactSymbolKind,\n declaration: OxcFunction | ArrowFunctionExpression,\n): PendingReactUsageNode {\n return {\n id: `${filePath}#${kind}:${name}`,\n name,\n kind,\n filePath,\n declarationOffset: declaration.id?.start ?? declaration.start,\n declaration,\n exportNames: new Set<string>(),\n componentReferences: new Set<string>(),\n hookReferences: new Set<string>(),\n builtinReferences: new Set<string>(),\n }\n}\n","import type { PendingReactUsageNode } from './file.js'\nimport {\n getBuiltinReferenceName,\n getComponentReferenceName,\n getCreateElementComponentReferenceName,\n getHookReferenceName,\n walkReactUsageTree,\n} from './walk.js'\n\nexport function analyzeSymbolUsages(\n symbol: PendingReactUsageNode,\n includeBuiltins: boolean,\n): void {\n const root =\n symbol.declaration.type === 'ArrowFunctionExpression'\n ? symbol.declaration.body\n : symbol.declaration.body\n\n if (root === null) {\n return\n }\n\n walkReactUsageTree(root, (node) => {\n if (node.type === 'JSXElement') {\n const name = getComponentReferenceName(node)\n if (name !== undefined) {\n symbol.componentReferences.add(name)\n }\n\n if (includeBuiltins) {\n const builtinName = getBuiltinReferenceName(node)\n if (builtinName !== undefined) {\n symbol.builtinReferences.add(builtinName)\n }\n }\n return\n }\n\n if (node.type === 'CallExpression') {\n const hookReference = getHookReferenceName(node)\n if (hookReference !== undefined) {\n symbol.hookReferences.add(hookReference)\n }\n\n const componentReference = getCreateElementComponentReferenceName(node)\n if (componentReference !== undefined) {\n symbol.componentReferences.add(componentReference)\n }\n }\n })\n}\n","import type {\n ArrowFunctionExpression,\n Function as OxcFunction,\n Program,\n} from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ImportBinding } from './bindings.js'\nimport { collectImportsAndExports } from './bindings.js'\nimport type { PendingReactUsageEntry } from './entries.js'\nimport { collectEntryUsages, createReactUsageLocation } from './entries.js'\nimport { collectTopLevelReactSymbols } from './symbols.js'\nimport { analyzeSymbolUsages } from './usage.js'\n\nexport interface PendingReactUsageNode {\n readonly id: string\n readonly name: string\n readonly kind: ReactSymbolKind\n readonly filePath: string\n readonly declarationOffset: number\n readonly declaration: OxcFunction | ArrowFunctionExpression\n readonly exportNames: Set<string>\n readonly componentReferences: Set<string>\n readonly hookReferences: Set<string>\n readonly builtinReferences: Set<string>\n}\n\nexport interface FileAnalysis {\n readonly filePath: string\n readonly importsByLocalName: Map<string, ImportBinding>\n readonly exportsByName: Map<string, string>\n readonly reExportBindingsByName: Map<string, ImportBinding>\n readonly exportAllBindings: readonly ImportBinding[]\n readonly entryUsages: readonly PendingReactUsageEntry[]\n readonly symbolsById: Map<string, PendingReactUsageNode>\n readonly symbolsByName: Map<string, PendingReactUsageNode>\n}\n\nexport function analyzeReactFile(\n program: Program,\n filePath: string,\n sourceText: string,\n includeNestedRenderEntries: boolean,\n sourceDependencies: ReadonlyMap<string, string>,\n includeBuiltins: boolean,\n): FileAnalysis {\n const symbolsByName = new Map<string, PendingReactUsageNode>()\n\n program.body.forEach((statement) => {\n collectTopLevelReactSymbols(statement, filePath, symbolsByName)\n })\n\n const importsByLocalName = new Map<string, ImportBinding>()\n const exportsByName = new Map<string, string>()\n const reExportBindingsByName = new Map<string, ImportBinding>()\n const exportAllBindings: ImportBinding[] = []\n const directEntryUsages = includeNestedRenderEntries\n ? collectEntryUsages(program, filePath, sourceText, includeBuiltins)\n : []\n\n program.body.forEach((statement) => {\n collectImportsAndExports(\n statement,\n sourceDependencies,\n symbolsByName,\n importsByLocalName,\n exportsByName,\n reExportBindingsByName,\n exportAllBindings,\n )\n })\n\n symbolsByName.forEach((symbol) => {\n analyzeSymbolUsages(symbol, includeBuiltins)\n })\n\n const entryUsages =\n directEntryUsages.length > 0\n ? directEntryUsages\n : includeNestedRenderEntries\n ? collectComponentDeclarationEntryUsages(symbolsByName, sourceText)\n : []\n\n return {\n filePath,\n importsByLocalName,\n exportsByName,\n reExportBindingsByName,\n exportAllBindings,\n entryUsages,\n symbolsById: new Map(\n [...symbolsByName.values()].map((symbol) => [symbol.id, symbol]),\n ),\n symbolsByName,\n }\n}\n\nfunction collectComponentDeclarationEntryUsages(\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n sourceText: string,\n): PendingReactUsageEntry[] {\n const componentSymbols = [...symbolsByName.values()].filter(\n (symbol) => symbol.kind === 'component',\n )\n if (componentSymbols.length === 0) {\n return []\n }\n\n const exportedComponentSymbols = componentSymbols.filter(\n (symbol) => symbol.exportNames.size > 0,\n )\n const fallbackSymbols =\n exportedComponentSymbols.length > 0\n ? exportedComponentSymbols\n : componentSymbols\n\n return fallbackSymbols\n .sort((left, right) => {\n return (\n left.declarationOffset - right.declarationOffset ||\n left.name.localeCompare(right.name)\n )\n })\n .map((symbol) => ({\n referenceName: symbol.name,\n kind: 'component',\n location: createReactUsageLocation(\n symbol.filePath,\n sourceText,\n symbol.declarationOffset,\n ),\n }))\n}\n","import type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport type { ImportBinding } from './bindings.js'\nimport type { FileAnalysis } from './file.js'\nimport { isHookName } from './walk.js'\n\nexport function resolveReactReference(\n fileAnalysis: FileAnalysis,\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n name: string,\n kind: ReactSymbolKind,\n): string | undefined {\n if (kind === 'builtin') {\n return getBuiltinNodeId(name)\n }\n\n const localSymbol = fileAnalysis.symbolsByName.get(name)\n if (localSymbol !== undefined && localSymbol.kind === kind) {\n return localSymbol.id\n }\n\n const importBinding = fileAnalysis.importsByLocalName.get(name)\n if (importBinding === undefined) {\n return undefined\n }\n\n if (importBinding.sourcePath === undefined) {\n return kind === 'hook'\n ? getExternalHookNodeId(importBinding, name)\n : undefined\n }\n\n const sourceFileAnalysis = fileAnalyses.get(importBinding.sourcePath)\n if (sourceFileAnalysis === undefined) {\n return undefined\n }\n\n const targetId = resolveExportedSymbol(\n sourceFileAnalysis,\n importBinding.importedName,\n kind,\n fileAnalyses,\n new Set<string>(),\n )\n if (targetId === undefined) {\n return undefined\n }\n\n return targetId\n}\n\nfunction resolveExportedSymbol(\n fileAnalysis: FileAnalysis,\n exportName: string,\n kind: ReactSymbolKind,\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n visited: Set<string>,\n): string | undefined {\n const visitKey = `${fileAnalysis.filePath}:${exportName}:${kind}`\n if (visited.has(visitKey)) {\n return undefined\n }\n\n visited.add(visitKey)\n\n const directTargetId = fileAnalysis.exportsByName.get(exportName)\n if (directTargetId !== undefined) {\n const directTargetSymbol = fileAnalysis.symbolsById.get(directTargetId)\n if (directTargetSymbol?.kind === kind) {\n return directTargetId\n }\n }\n\n const reExportBinding = fileAnalysis.reExportBindingsByName.get(exportName)\n if (reExportBinding?.sourcePath !== undefined) {\n const reExportSourceAnalysis = fileAnalyses.get(reExportBinding.sourcePath)\n if (reExportSourceAnalysis !== undefined) {\n const reExportTargetId = resolveExportedSymbol(\n reExportSourceAnalysis,\n reExportBinding.importedName,\n kind,\n fileAnalyses,\n visited,\n )\n if (reExportTargetId !== undefined) {\n return reExportTargetId\n }\n }\n }\n\n for (const exportAllBinding of fileAnalysis.exportAllBindings) {\n if (exportAllBinding.sourcePath === undefined) {\n continue\n }\n\n const exportAllSourceAnalysis = fileAnalyses.get(\n exportAllBinding.sourcePath,\n )\n if (exportAllSourceAnalysis === undefined) {\n continue\n }\n\n const exportAllTargetId = resolveExportedSymbol(\n exportAllSourceAnalysis,\n exportName,\n kind,\n fileAnalyses,\n visited,\n )\n if (exportAllTargetId !== undefined) {\n return exportAllTargetId\n }\n }\n\n return undefined\n}\n\nexport function addExternalHookNodes(\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n fileAnalysis.importsByLocalName.forEach((binding, localName) => {\n if (binding.sourcePath !== undefined) {\n return\n }\n\n if (!isHookName(localName) && !isHookName(binding.importedName)) {\n return\n }\n\n const externalNode = createExternalHookNode(binding, localName)\n if (!nodes.has(externalNode.id)) {\n nodes.set(externalNode.id, externalNode)\n }\n })\n }\n}\n\nexport function addBuiltinNodes(\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n fileAnalysis.entryUsages.forEach((entry) => {\n if (entry.kind !== 'builtin') {\n return\n }\n\n const builtinNode = createBuiltinNode(entry.referenceName)\n if (!nodes.has(builtinNode.id)) {\n nodes.set(builtinNode.id, builtinNode)\n }\n })\n\n fileAnalysis.symbolsById.forEach((symbol) => {\n symbol.builtinReferences.forEach((name) => {\n const builtinNode = createBuiltinNode(name)\n if (!nodes.has(builtinNode.id)) {\n nodes.set(builtinNode.id, builtinNode)\n }\n })\n })\n }\n}\n\nfunction createExternalHookNode(\n binding: ImportBinding,\n localName: string,\n): ReactUsageNode {\n const name = getExternalHookName(binding, localName)\n\n return {\n id: getExternalHookNodeId(binding, localName),\n name,\n kind: 'hook',\n filePath: binding.sourceSpecifier,\n exportNames: [binding.importedName],\n usages: [],\n }\n}\n\nfunction createBuiltinNode(name: string): ReactUsageNode {\n return {\n id: getBuiltinNodeId(name),\n name,\n kind: 'builtin',\n filePath: 'html',\n exportNames: [],\n usages: [],\n }\n}\n\nfunction getExternalHookNodeId(\n binding: ImportBinding,\n localName: string,\n): string {\n return `external:${binding.sourceSpecifier}#hook:${getExternalHookName(binding, localName)}`\n}\n\nexport function getBuiltinNodeId(name: string): string {\n return `builtin:${name}`\n}\n\nfunction getExternalHookName(\n binding: ImportBinding,\n localName: string,\n): string {\n return binding.importedName === 'default' ? localName : binding.importedName\n}\n\nexport function compareReactNodeIds(\n leftId: string,\n rightId: string,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n): number {\n const left = nodes.get(leftId)\n const right = nodes.get(rightId)\n\n if (left === undefined || right === undefined) {\n return leftId.localeCompare(rightId)\n }\n\n return compareReactNodes(left, right)\n}\n\nexport function compareReactUsageEntries(\n left: ReactUsageEntry,\n right: ReactUsageEntry,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n): number {\n return (\n left.location.filePath.localeCompare(right.location.filePath) ||\n left.location.line - right.location.line ||\n left.location.column - right.location.column ||\n left.referenceName.localeCompare(right.referenceName) ||\n compareReactNodeIds(left.target, right.target, nodes)\n )\n}\n\nfunction compareReactNodes(\n left: ReactUsageNode,\n right: ReactUsageNode,\n): number {\n return (\n left.filePath.localeCompare(right.filePath) ||\n left.name.localeCompare(right.name) ||\n left.kind.localeCompare(right.kind)\n )\n}\n","import fs from 'node:fs'\n\nimport { parseSync } from 'oxc-parser'\n\nimport type { AnalyzeOptions } from '../../types/analyze-options.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport type { SourceModuleNode } from '../../types/source-module-node.js'\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { BaseAnalyzer } from '../base.js'\nimport { analyzeDependencies } from '../import/index.js'\nimport { analyzeReactFile } from './file.js'\nimport {\n addBuiltinNodes,\n addExternalHookNodes,\n compareReactNodeIds,\n compareReactUsageEntries,\n getBuiltinNodeId,\n resolveReactReference,\n} from './references.js'\n\nexport function analyzeReactUsage(\n entryFile: string | readonly string[],\n options: AnalyzeOptions = {},\n): ReactUsageGraph {\n return new ReactAnalyzer(normalizeEntryFiles(entryFile), options).analyze()\n}\n\nclass ReactAnalyzer extends BaseAnalyzer<ReactUsageGraph> {\n constructor(\n private readonly entryFiles: readonly string[],\n options: AnalyzeOptions,\n ) {\n const [firstEntryFile] = entryFiles\n if (firstEntryFile === undefined) {\n throw new Error('At least one React entry file is required.')\n }\n\n super(firstEntryFile, options)\n }\n\n protected doAnalyze(): ReactUsageGraph {\n const dependencyGraphs = this.entryFiles.map((entryFile) =>\n analyzeDependencies(entryFile, this.options),\n )\n const dependencyGraph = mergeDependencyGraphs(dependencyGraphs)\n const entryIds = dependencyGraphs.map((graph) => graph.entryId)\n const fileAnalyses = this.collectFileAnalyses(dependencyGraph)\n const nodes = this.createNodes(fileAnalyses)\n this.attachUsages(fileAnalyses, nodes)\n const entries = this.collectEntries(fileAnalyses, nodes)\n\n return {\n cwd: dependencyGraph.cwd,\n entryId: dependencyGraph.entryId,\n entryIds,\n nodes,\n entries,\n }\n }\n\n private collectFileAnalyses(\n dependencyGraph: MergedDependencyGraph,\n ): Map<string, import('./file.js').FileAnalysis> {\n const reachableFiles = new Set<string>([\n ...dependencyGraph.entryIds,\n ...dependencyGraph.nodes.keys(),\n ])\n const fileAnalyses = new Map<string, import('./file.js').FileAnalysis>()\n\n for (const filePath of [...reachableFiles].sort()) {\n if (!isSourceCodeFile(filePath) || filePath.endsWith('.d.ts')) {\n continue\n }\n\n const sourceText = fs.readFileSync(filePath, 'utf8')\n const parseResult = parseSync(filePath, sourceText, {\n astType: 'ts',\n sourceType: 'unambiguous',\n })\n\n const dependencyNode = dependencyGraph.nodes.get(filePath)\n const sourceDependencies = new Map<string, string>()\n dependencyNode?.dependencies.forEach((dependency) => {\n if (dependency.kind === 'source') {\n sourceDependencies.set(dependency.specifier, dependency.target)\n }\n })\n\n fileAnalyses.set(\n filePath,\n analyzeReactFile(\n parseResult.program,\n filePath,\n sourceText,\n dependencyGraph.entryIds.includes(filePath),\n sourceDependencies,\n this.options.includeBuiltins === true,\n ),\n )\n }\n\n return fileAnalyses\n }\n\n private createNodes(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n ): Map<string, ReactUsageNode> {\n const nodes = new Map<string, ReactUsageNode>()\n\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const symbol of fileAnalysis.symbolsById.values()) {\n nodes.set(symbol.id, {\n id: symbol.id,\n name: symbol.name,\n kind: symbol.kind,\n filePath: symbol.filePath,\n exportNames: [...symbol.exportNames].sort(),\n usages: [],\n })\n }\n }\n\n addExternalHookNodes(fileAnalyses, nodes)\n if (this.options.includeBuiltins === true) {\n addBuiltinNodes(fileAnalyses, nodes)\n }\n return nodes\n }\n\n private attachUsages(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n ): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const symbol of fileAnalysis.symbolsById.values()) {\n const usages = new Map<string, ReactUsageEdge>()\n\n symbol.componentReferences.forEach((referenceName) => {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n referenceName,\n 'component',\n )\n if (targetId !== undefined && targetId !== symbol.id) {\n usages.set(`render:${targetId}:${referenceName}`, {\n kind: 'render',\n target: targetId,\n referenceName,\n })\n }\n })\n\n symbol.hookReferences.forEach((referenceName) => {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n referenceName,\n 'hook',\n )\n if (targetId !== undefined && targetId !== symbol.id) {\n usages.set(`hook:${targetId}:${referenceName}`, {\n kind: 'hook-call',\n target: targetId,\n referenceName,\n })\n }\n })\n\n if (this.options.includeBuiltins === true) {\n symbol.builtinReferences.forEach((referenceName) => {\n const targetId = getBuiltinNodeId(referenceName)\n usages.set(`render:${targetId}:${referenceName}`, {\n kind: 'render',\n target: targetId,\n referenceName,\n })\n })\n }\n\n const node = nodes.get(symbol.id)\n if (node === undefined) {\n continue\n }\n\n const sortedUsages = [...usages.values()].sort((left, right) =>\n compareReactNodeIds(left.target, right.target, nodes),\n )\n\n nodes.set(symbol.id, {\n ...node,\n usages: sortedUsages,\n })\n }\n }\n }\n\n private collectEntries(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n ): ReactUsageEntry[] {\n const entriesByKey = new Map<string, ReactUsageEntry>()\n\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const entry of fileAnalysis.entryUsages) {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n entry.referenceName,\n entry.kind,\n )\n if (targetId === undefined) {\n continue\n }\n\n const key = `${entry.location.filePath}:${entry.location.line}:${entry.location.column}:${targetId}`\n entriesByKey.set(key, {\n target: targetId,\n referenceName: entry.referenceName,\n location: entry.location,\n })\n }\n }\n\n return [...entriesByKey.values()].sort((left, right) =>\n compareReactUsageEntries(left, right, nodes),\n )\n }\n}\n\nfunction normalizeEntryFiles(entryFile: string | readonly string[]): string[] {\n const entryFiles = Array.isArray(entryFile) ? entryFile : [entryFile]\n const dedupedEntryFiles = [...new Set(entryFiles)]\n\n if (dedupedEntryFiles.length === 0) {\n throw new Error('At least one React entry file is required.')\n }\n\n return dedupedEntryFiles\n}\n\nfunction mergeDependencyGraphs(\n graphs: readonly DependencyGraph[],\n): MergedDependencyGraph {\n const firstGraph = graphs[0]\n if (firstGraph === undefined) {\n throw new Error('At least one dependency graph is required.')\n }\n\n const nodes = new Map<string, SourceModuleNode>()\n for (const graph of graphs) {\n for (const [nodeId, node] of graph.nodes) {\n if (!nodes.has(nodeId)) {\n nodes.set(nodeId, node)\n }\n }\n }\n\n const uniqueConfigPaths = [\n ...new Set(graphs.map((graph) => graph.configPath)),\n ]\n const configPath =\n uniqueConfigPaths.length === 1 ? uniqueConfigPaths[0] : undefined\n\n return {\n cwd: firstGraph.cwd,\n entryId: firstGraph.entryId,\n entryIds: graphs.map((graph) => graph.entryId),\n nodes,\n ...(configPath === undefined ? {} : { configPath }),\n }\n}\n\ninterface MergedDependencyGraph extends DependencyGraph {\n readonly entryIds: readonly string[]\n}\n","import type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageFilter } from '../../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport { compareReactNodeIds } from './references.js'\n\nexport function getReactUsageEntries(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): ReactUsageEntry[] {\n return graph.entries.filter((entry) => {\n const targetNode = graph.nodes.get(entry.target)\n return targetNode !== undefined && matchesReactFilter(targetNode, filter)\n })\n}\n\nexport function getReactUsageRoots(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): string[] {\n const entries = getReactUsageEntries(graph, filter)\n if (entries.length > 0) {\n return [...new Set(entries.map((entry) => entry.target))]\n }\n\n const filteredNodes = getFilteredReactUsageNodes(graph, filter)\n const inboundCounts = new Map<string, number>()\n\n filteredNodes.forEach((node) => {\n inboundCounts.set(node.id, 0)\n })\n\n filteredNodes.forEach((node) => {\n getFilteredUsages(node, graph, filter).forEach((usage) => {\n inboundCounts.set(\n usage.target,\n (inboundCounts.get(usage.target) ?? 0) + 1,\n )\n })\n })\n\n const roots = filteredNodes\n .filter((node) => (inboundCounts.get(node.id) ?? 0) === 0)\n .map((node) => node.id)\n\n if (roots.length > 0) {\n return roots.sort((left, right) =>\n compareReactNodeIds(left, right, graph.nodes),\n )\n }\n\n return filteredNodes\n .map((node) => node.id)\n .sort((left, right) => compareReactNodeIds(left, right, graph.nodes))\n}\n\nexport function getFilteredUsages(\n node: ReactUsageNode,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): ReactUsageEdge[] {\n return node.usages.filter((usage) => {\n const targetNode = graph.nodes.get(usage.target)\n return targetNode !== undefined && matchesReactFilter(targetNode, filter)\n })\n}\n\nfunction getFilteredReactUsageNodes(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n): ReactUsageNode[] {\n return [...graph.nodes.values()]\n .filter((node) => matchesReactFilter(node, filter))\n .sort((left, right) => {\n return (\n left.filePath.localeCompare(right.filePath) ||\n left.name.localeCompare(right.name) ||\n left.kind.localeCompare(right.kind)\n )\n })\n}\n\nfunction matchesReactFilter(\n node: ReactUsageNode,\n filter: ReactUsageFilter,\n): boolean {\n return filter === 'all' || node.kind === filter\n}\n","import process from 'node:process'\n\nimport type { ColorMode } from './types/color-mode.js'\nimport type { ReactSymbolKind } from './types/react-symbol-kind.js'\n\nconst ANSI_RESET = '\\u001B[0m'\nconst ANSI_COMPONENT = '\\u001B[36m'\nconst ANSI_HOOK = '\\u001B[35m'\nconst ANSI_BUILTIN = '\\u001B[34m'\nconst ANSI_MUTED = '\\u001B[38;5;244m'\nconst ANSI_UNUSED = '\\u001B[38;5;214m'\n\ninterface ResolveColorSupportOptions {\n readonly forceColor?: string | undefined\n readonly isTTY?: boolean | undefined\n readonly noColor?: string | undefined\n}\n\nexport function resolveColorSupport(\n mode: ColorMode = 'auto',\n options: ResolveColorSupportOptions = {},\n): boolean {\n if (mode === true) {\n return true\n }\n\n if (mode === false) {\n return false\n }\n\n const forceColor =\n 'forceColor' in options ? options.forceColor : process.env.FORCE_COLOR\n if (forceColor !== undefined) {\n return forceColor !== '0'\n }\n\n const noColor = 'noColor' in options ? options.noColor : process.env.NO_COLOR\n if (noColor !== undefined) {\n return false\n }\n\n const isTTY = 'isTTY' in options ? options.isTTY : process.stdout.isTTY\n return isTTY === true\n}\n\nexport function colorizeUnusedMarker(text: string, enabled: boolean): string {\n if (!enabled) {\n return text\n }\n\n return text.replaceAll('(unused)', `${ANSI_UNUSED}(unused)${ANSI_RESET}`)\n}\n\nexport function formatReactSymbolLabel(\n name: string,\n kind: ReactSymbolKind,\n enabled: boolean,\n): string {\n const label = `${formatReactSymbolName(name, kind)} [${kind}]`\n if (!enabled) {\n return label\n }\n\n return `${getReactSymbolColor(kind)}${label}${ANSI_RESET}`\n}\n\nexport function formatReactSymbolName(\n name: string,\n kind: ReactSymbolKind,\n): string {\n if (kind === 'component') {\n return `<${name} />`\n }\n\n if (kind === 'hook') {\n return `${name}()`\n }\n\n return `<${name}>`\n}\nexport function colorizeReactLabel(\n text: string,\n kind: ReactSymbolKind,\n enabled: boolean,\n): string {\n if (!enabled) {\n return text\n }\n\n return `${getReactSymbolColor(kind)}${text}${ANSI_RESET}`\n}\n\nexport function colorizeMuted(text: string, enabled: boolean): string {\n if (!enabled) {\n return text\n }\n\n return `${ANSI_MUTED}${text}${ANSI_RESET}`\n}\n\nfunction getReactSymbolColor(kind: ReactSymbolKind): string {\n if (kind === 'component') {\n return ANSI_COMPONENT\n }\n\n if (kind === 'hook') {\n return ANSI_HOOK\n }\n\n return ANSI_BUILTIN\n}\n","import path from 'node:path'\n\nexport function toDisplayPath(filePath: string, cwd: string): string {\n const relativePath = path.relative(cwd, filePath)\n if (relativePath === '') {\n return '.'\n }\n\n const normalizedPath = relativePath.split(path.sep).join('/')\n return normalizedPath.startsWith('..') ? filePath : normalizedPath\n}\n","import { colorizeUnusedMarker, resolveColorSupport } from '../../color.js'\nimport type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport type { PrintTreeOptions } from '../../types/print-tree-options.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function printDependencyTree(\n graph: DependencyGraph,\n options: PrintTreeOptions = {},\n): string {\n const cwd = options.cwd ?? graph.cwd\n const color = resolveColorSupport(options.color)\n const includeExternals = options.includeExternals ?? false\n const omitUnused = options.omitUnused ?? false\n const rootLines = [toDisplayPath(graph.entryId, cwd)]\n const visited = new Set<string>([graph.entryId])\n const entryNode = graph.nodes.get(graph.entryId)\n\n if (entryNode === undefined) {\n return rootLines.join('\\n')\n }\n\n const rootDependencies = filterDependencies(\n entryNode.dependencies,\n includeExternals,\n omitUnused,\n )\n\n rootDependencies.forEach((dependency, index) => {\n rootLines.push(\n ...renderDependency(\n dependency,\n graph,\n visited,\n '',\n index === rootDependencies.length - 1,\n includeExternals,\n omitUnused,\n color,\n cwd,\n ),\n )\n })\n\n return rootLines.join('\\n')\n}\n\nfunction renderDependency(\n dependency: DependencyEdge,\n graph: DependencyGraph,\n visited: ReadonlySet<string>,\n prefix: string,\n isLast: boolean,\n includeExternals: boolean,\n omitUnused: boolean,\n color: boolean,\n cwd: string,\n): string[] {\n const branch = `${prefix}${isLast ? '└─ ' : '├─ '}`\n const label = formatDependencyLabel(dependency, cwd, color)\n\n if (dependency.kind !== 'source') {\n return [`${branch}${label}`]\n }\n\n if (visited.has(dependency.target)) {\n return [`${branch}${label} (circular)`]\n }\n\n const childNode = graph.nodes.get(dependency.target)\n if (childNode === undefined) {\n return [`${branch}${label}`]\n }\n\n const nextPrefix = `${prefix}${isLast ? ' ' : '│ '}`\n const nextVisited = new Set(visited)\n nextVisited.add(dependency.target)\n\n const childLines = [`${branch}${label}`]\n const childDependencies = filterDependencies(\n childNode.dependencies,\n includeExternals,\n omitUnused,\n )\n\n childDependencies.forEach((childDependency, index) => {\n childLines.push(\n ...renderDependency(\n childDependency,\n graph,\n nextVisited,\n nextPrefix,\n index === childDependencies.length - 1,\n includeExternals,\n omitUnused,\n color,\n cwd,\n ),\n )\n })\n\n return childLines\n}\n\nfunction filterDependencies(\n dependencies: readonly DependencyEdge[],\n includeExternals: boolean,\n omitUnused: boolean,\n): DependencyEdge[] {\n return dependencies.filter((dependency) => {\n if (omitUnused && dependency.unused) {\n return false\n }\n\n if (\n dependency.kind === 'source' ||\n dependency.kind === 'missing' ||\n dependency.kind === 'boundary'\n ) {\n return true\n }\n\n return includeExternals\n })\n}\n\nfunction formatDependencyLabel(\n dependency: DependencyEdge,\n cwd: string,\n color: boolean,\n): string {\n const prefixes: string[] = []\n if (dependency.isTypeOnly) {\n prefixes.push('type')\n }\n\n if (dependency.referenceKind === 'require') {\n prefixes.push('require')\n } else if (dependency.referenceKind === 'dynamic-import') {\n prefixes.push('dynamic')\n } else if (dependency.referenceKind === 'export') {\n prefixes.push('re-export')\n } else if (dependency.referenceKind === 'import-equals') {\n prefixes.push('import=')\n }\n\n const annotation = prefixes.length > 0 ? `[${prefixes.join(', ')}] ` : ''\n\n if (dependency.kind === 'source') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${toDisplayPath(dependency.target, cwd)}`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'missing') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.specifier} [missing]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'boundary') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${toDisplayPath(dependency.target, cwd)} [${\n dependency.boundary === 'project'\n ? 'project boundary'\n : 'workspace boundary'\n }]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'builtin') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.target} [builtin]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.target} [external]`,\n dependency.unused,\n ),\n color,\n )\n}\n\nfunction withUnusedSuffix(label: string, unused: boolean): string {\n return unused ? `${label} (unused)` : label\n}\n","import {\n getFilteredUsages,\n getReactUsageEntries,\n getReactUsageRoots,\n} from '../../analyzers/react/queries.js'\nimport {\n colorizeMuted,\n colorizeReactLabel,\n formatReactSymbolLabel,\n formatReactSymbolName,\n resolveColorSupport,\n} from '../../color.js'\nimport type { PrintReactTreeOptions } from '../../types/print-react-tree-options.js'\nimport type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function printReactUsageTree(\n graph: ReactUsageGraph,\n options: PrintReactTreeOptions = {},\n): string {\n const cwd = options.cwd ?? graph.cwd\n const color = resolveColorSupport(options.color)\n const filter = options.filter ?? 'all'\n const entries = getReactUsageEntries(graph, filter)\n\n if (entries.length > 0) {\n return renderReactUsageEntries(graph, entries, cwd, filter, color)\n }\n\n const roots = getReactUsageRoots(graph, filter)\n if (roots.length === 0) {\n return 'No React symbols found.'\n }\n\n const lines: string[] = []\n roots.forEach((rootId, index) => {\n const root = graph.nodes.get(rootId)\n if (root === undefined) {\n return\n }\n\n lines.push(formatReactNodeLabel(root, cwd, color))\n const usages = getFilteredUsages(root, graph, filter)\n usages.forEach((usage, usageIndex) => {\n lines.push(\n ...renderUsage(\n usage,\n graph,\n cwd,\n filter,\n color,\n new Set([root.id]),\n '',\n usageIndex === usages.length - 1,\n ),\n )\n })\n\n if (index < roots.length - 1) {\n lines.push('')\n }\n })\n\n return lines.join('\\n')\n}\n\nfunction renderReactUsageEntries(\n graph: ReactUsageGraph,\n entries: readonly ReactUsageEntry[],\n cwd: string,\n filter: NonNullable<PrintReactTreeOptions['filter']>,\n color: boolean,\n): string {\n const lines: string[] = []\n\n entries.forEach((entry, index) => {\n const root = graph.nodes.get(entry.target)\n if (root === undefined) {\n return\n }\n\n lines.push(formatReactEntryLabel(entry, cwd))\n lines.push(formatReactNodeLabel(root, cwd, color, entry.referenceName))\n\n const usages = getFilteredUsages(root, graph, filter)\n usages.forEach((usage, usageIndex) => {\n lines.push(\n ...renderUsage(\n usage,\n graph,\n cwd,\n filter,\n color,\n new Set([root.id]),\n '',\n usageIndex === usages.length - 1,\n ),\n )\n })\n\n if (index < entries.length - 1) {\n lines.push('')\n }\n })\n\n return lines.join('\\n')\n}\n\nfunction renderUsage(\n usage: ReactUsageEdge,\n graph: ReactUsageGraph,\n cwd: string,\n filter: NonNullable<PrintReactTreeOptions['filter']>,\n color: boolean,\n visited: ReadonlySet<string>,\n prefix: string,\n isLast: boolean,\n): string[] {\n const branch = `${prefix}${isLast ? '└─ ' : '├─ '}`\n const target = graph.nodes.get(usage.target)\n\n if (target === undefined) {\n return [`${branch}${usage.target}`]\n }\n\n if (visited.has(target.id)) {\n return [\n `${branch}${formatReactNodeLabel(target, cwd, color, usage.referenceName)} (circular)`,\n ]\n }\n\n const childLines = [\n `${branch}${formatReactNodeLabel(target, cwd, color, usage.referenceName)}`,\n ]\n const nextVisited = new Set(visited)\n nextVisited.add(target.id)\n const nextPrefix = `${prefix}${isLast ? ' ' : '│ '}`\n const childUsages = getFilteredUsages(target, graph, filter)\n\n childUsages.forEach((childUsage, index) => {\n childLines.push(\n ...renderUsage(\n childUsage,\n graph,\n cwd,\n filter,\n color,\n nextVisited,\n nextPrefix,\n index === childUsages.length - 1,\n ),\n )\n })\n\n return childLines\n}\n\nfunction formatReactNodeLabel(\n node: ReactUsageNode,\n cwd: string,\n color: boolean,\n referenceName?: string,\n): string {\n const hasAlias = referenceName !== undefined && referenceName !== node.name\n const label = hasAlias\n ? `${colorizeReactLabel(formatReactSymbolName(node.name, node.kind), node.kind, color)} ${colorizeMuted(\n `as ${referenceName}`,\n color,\n )} ${colorizeReactLabel(`[${node.kind}]`, node.kind, color)}`\n : formatReactSymbolLabel(node.name, node.kind, color)\n\n return `${label} (${formatReactNodeFilePath(node, cwd)})`\n}\n\nfunction formatReactEntryLabel(entry: ReactUsageEntry, cwd: string): string {\n return `${toDisplayPath(entry.location.filePath, cwd)}:${entry.location.line}:${entry.location.column}`\n}\n\nfunction formatReactNodeFilePath(node: ReactUsageNode, cwd: string): string {\n return node.kind === 'builtin' ? 'html' : toDisplayPath(node.filePath, cwd)\n}\n","import type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function graphToSerializableTree(\n graph: DependencyGraph,\n options: {\n readonly omitUnused?: boolean\n } = {},\n): object {\n const visited = new Set<string>()\n return serializeNode(\n graph.entryId,\n graph,\n visited,\n options.omitUnused ?? false,\n )\n}\n\nfunction serializeNode(\n filePath: string,\n graph: DependencyGraph,\n visited: Set<string>,\n omitUnused: boolean,\n): object {\n const node = graph.nodes.get(filePath)\n const displayPath = toDisplayPath(filePath, graph.cwd)\n\n if (node === undefined) {\n return {\n path: displayPath,\n kind: 'missing',\n dependencies: [],\n }\n }\n\n if (visited.has(filePath)) {\n return {\n path: displayPath,\n kind: 'circular',\n dependencies: [],\n }\n }\n\n visited.add(filePath)\n\n const dependencies = node.dependencies\n .filter((dependency) => !omitUnused || !dependency.unused)\n .map((dependency) => {\n if (dependency.kind !== 'source') {\n return {\n specifier: dependency.specifier,\n referenceKind: dependency.referenceKind,\n isTypeOnly: dependency.isTypeOnly,\n unused: dependency.unused,\n kind: dependency.kind,\n ...(dependency.boundary === undefined\n ? {}\n : { boundary: dependency.boundary }),\n target: serializeDependencyTarget(dependency, graph.cwd),\n }\n }\n\n return {\n specifier: dependency.specifier,\n referenceKind: dependency.referenceKind,\n isTypeOnly: dependency.isTypeOnly,\n unused: dependency.unused,\n kind: dependency.kind,\n target: toDisplayPath(dependency.target, graph.cwd),\n node: serializeNode(\n dependency.target,\n graph,\n new Set(visited),\n omitUnused,\n ),\n }\n })\n\n return {\n path: displayPath,\n kind: filePath === graph.entryId ? 'entry' : 'source',\n dependencies,\n }\n}\n\nfunction serializeDependencyTarget(\n dependency: DependencyEdge,\n cwd: string,\n): string {\n if (dependency.kind === 'missing' || dependency.kind === 'external') {\n return dependency.target\n }\n\n if (dependency.kind === 'builtin') {\n return dependency.target\n }\n\n return toDisplayPath(dependency.target, cwd)\n}\n","import {\n getFilteredUsages,\n getReactUsageEntries,\n getReactUsageRoots,\n} from '../../analyzers/react/queries.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageFilter } from '../../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\ninterface SerializedReactUsageNode {\n readonly id: string\n readonly name: string\n readonly symbolKind:\n | import('../../types/react-symbol-kind.js').ReactSymbolKind\n | 'circular'\n readonly filePath: string\n readonly exportNames: readonly string[]\n readonly usages: readonly SerializedReactUsageEdge[]\n}\n\ninterface SerializedReactUsageEntry {\n readonly targetId: string\n readonly referenceName: string\n readonly filePath: string\n readonly line: number\n readonly column: number\n readonly node: SerializedReactUsageNode\n}\n\ninterface SerializedReactUsageEdge {\n readonly kind: import('../../types/react-usage-edge.js').ReactUsageEdge['kind']\n readonly targetId: string\n readonly referenceName: string\n readonly node: SerializedReactUsageNode\n}\n\nexport function graphToSerializableReactTree(\n graph: ReactUsageGraph,\n options: {\n readonly filter?: ReactUsageFilter\n } = {},\n): object {\n const filter = options.filter ?? 'all'\n const entries = getReactUsageEntries(graph, filter)\n const roots =\n entries.length > 0\n ? entries.map((entry) =>\n serializeReactUsageNode(entry.target, graph, filter, new Set()),\n )\n : getReactUsageRoots(graph, filter).map((rootId) =>\n serializeReactUsageNode(rootId, graph, filter, new Set()),\n )\n\n return {\n kind: 'react-usage',\n entries: entries.map((entry) =>\n serializeReactUsageEntry(entry, graph, filter),\n ),\n roots,\n }\n}\n\nfunction serializeReactUsageNode(\n nodeId: string,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n visited: Set<string>,\n): SerializedReactUsageNode {\n const node = graph.nodes.get(nodeId)\n if (node === undefined) {\n return {\n id: nodeId,\n name: nodeId,\n symbolKind: 'circular',\n filePath: '',\n exportNames: [],\n usages: [],\n }\n }\n\n if (visited.has(nodeId)) {\n return {\n id: node.id,\n name: node.name,\n symbolKind: 'circular',\n filePath: formatReactNodeFilePath(node.filePath, node.kind, graph.cwd),\n exportNames: node.exportNames,\n usages: [],\n }\n }\n\n const nextVisited = new Set(visited)\n nextVisited.add(nodeId)\n\n return {\n id: node.id,\n name: node.name,\n symbolKind: node.kind,\n filePath: formatReactNodeFilePath(node.filePath, node.kind, graph.cwd),\n exportNames: node.exportNames,\n usages: getFilteredUsages(node, graph, filter).map((usage) => ({\n kind: usage.kind,\n targetId: usage.target,\n referenceName: usage.referenceName,\n node: serializeReactUsageNode(usage.target, graph, filter, nextVisited),\n })),\n }\n}\n\nfunction serializeReactUsageEntry(\n entry: ReactUsageEntry,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n): SerializedReactUsageEntry {\n return {\n targetId: entry.target,\n referenceName: entry.referenceName,\n filePath: toDisplayPath(entry.location.filePath, graph.cwd),\n line: entry.location.line,\n column: entry.location.column,\n node: serializeReactUsageNode(entry.target, graph, filter, new Set()),\n }\n}\n\nfunction formatReactNodeFilePath(\n filePath: string,\n kind: import('../../types/react-symbol-kind.js').ReactSymbolKind,\n cwd: string,\n): string {\n return kind === 'builtin' ? 'html' : toDisplayPath(filePath, cwd)\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,oBACd,YACA,oBACc;CACd,MAAM,aACJ,uBAAuB,KAAA,IACnB,kBAAkB,WAAW,GAC7B,KAAK,QAAQ,YAAY,mBAAmB;AAElD,KAAI,eAAe,KAAA,EACjB,QAAO,EACL,iBAAiB,wBAAwB,EAC1C;CAGH,MAAM,aAAa,GAAG,eAAe,YAAY,GAAG,IAAI,SAAS;AACjE,KAAI,WAAW,UAAU,KAAA,EACvB,OAAM,IAAI,MACR,uCAAuC,WAAW,IAAI,iBACpD,WAAW,MACZ,GACF;CAGH,MAAM,SAAS,GAAG,2BA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M,QAAQ,OAAO,QAAQ,YAAY;GACxE,EAAE;EACJ;;AAGH,SAAS,yBACP,OACA,OACA,QAC2B;AAC3B,QAAO;EACL,UAAU,MAAM;EAChB,eAAe,MAAM;EACrB,UAAU,cAAc,MAAM,SAAS,UAAU,MAAM,IAAI;EAC3D,MAAM,MAAM,SAAS;EACrB,QAAQ,MAAM,SAAS;EACvB,MAAM,wBAAwB,MAAM,QAAQ,OAAO,wBAAQ,IAAI,KAAK,CAAC;EACtE;;AAGH,SAAS,wBACP,UACA,MACA,KACQ;AACR,QAAO,SAAS,YAAY,SAAS,cAAc,UAAU,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foresthouse",
3
- "version": "1.0.0-dev.14",
3
+ "version": "1.0.0-dev.15",
4
4
  "description": "A Node.js CLI that reads JavaScript and TypeScript entry files and prints an import tree.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.32.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-qiCwZtzi.mjs","names":["isInsideNodeModules","process","formatReactNodeFilePath"],"sources":["../src/typescript/config.ts","../src/analyzers/base.ts","../src/utils/is-source-code-file.ts","../src/utils/normalize-file-path.ts","../src/analyzers/import/entry.ts","../src/typescript/program.ts","../src/analyzers/import/unused.ts","../src/analyzers/import/references.ts","../src/analyzers/import/resolver.ts","../src/analyzers/import/graph.ts","../src/analyzers/import/index.ts","../src/analyzers/react/bindings.ts","../src/analyzers/react/walk.ts","../src/analyzers/react/entries.ts","../src/analyzers/react/symbols.ts","../src/analyzers/react/usage.ts","../src/analyzers/react/file.ts","../src/analyzers/react/references.ts","../src/analyzers/react/index.ts","../src/analyzers/react/queries.ts","../src/color.ts","../src/utils/to-display-path.ts","../src/output/ascii/import.ts","../src/output/ascii/react.ts","../src/output/json/import.ts","../src/output/json/react.ts"],"sourcesContent":["import path from 'node:path'\nimport ts from 'typescript'\n\nexport interface LoadedConfig {\n readonly path?: string\n readonly compilerOptions: ts.CompilerOptions\n}\n\nexport function loadCompilerOptions(\n searchFrom: string,\n explicitConfigPath?: string,\n): LoadedConfig {\n const configPath =\n explicitConfigPath === undefined\n ? findNearestConfig(searchFrom)\n : path.resolve(searchFrom, explicitConfigPath)\n\n if (configPath === undefined) {\n return {\n compilerOptions: defaultCompilerOptions(),\n }\n }\n\n const readResult = ts.readConfigFile(configPath, ts.sys.readFile)\n if (readResult.error !== undefined) {\n throw new Error(\n `Failed to read TypeScript config at ${configPath}: ${formatDiagnostic(\n readResult.error,\n )}`,\n )\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n readResult.config,\n ts.sys,\n path.dirname(configPath),\n defaultCompilerOptions(),\n configPath,\n )\n\n if (parsed.errors.length > 0) {\n const [firstError] = parsed.errors\n if (firstError === undefined) {\n throw new Error(`Failed to parse TypeScript config at ${configPath}.`)\n }\n\n throw new Error(\n `Failed to parse TypeScript config at ${configPath}: ${formatDiagnostic(\n firstError,\n )}`,\n )\n }\n\n return {\n path: configPath,\n compilerOptions: parsed.options,\n }\n}\n\nfunction findNearestConfig(searchFrom: string): string | undefined {\n let currentDirectory = path.resolve(searchFrom)\n\n while (true) {\n if (!isInsideNodeModules(currentDirectory)) {\n const tsconfigPath = path.join(currentDirectory, 'tsconfig.json')\n if (ts.sys.fileExists(tsconfigPath)) {\n return tsconfigPath\n }\n\n const jsconfigPath = path.join(currentDirectory, 'jsconfig.json')\n if (ts.sys.fileExists(jsconfigPath)) {\n return jsconfigPath\n }\n }\n\n const parentDirectory = path.dirname(currentDirectory)\n if (parentDirectory === currentDirectory) {\n return undefined\n }\n\n currentDirectory = parentDirectory\n }\n}\n\nfunction defaultCompilerOptions(): ts.CompilerOptions {\n return {\n allowJs: true,\n jsx: ts.JsxEmit.ReactJSX,\n module: ts.ModuleKind.NodeNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n target: ts.ScriptTarget.ESNext,\n resolveJsonModule: true,\n esModuleInterop: true,\n }\n}\n\nfunction formatDiagnostic(diagnostic: ts.Diagnostic): string {\n return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n}\n\nfunction isInsideNodeModules(filePath: string): boolean {\n return filePath.includes(`${path.sep}node_modules${path.sep}`)\n}\n","import type { AnalyzeOptions } from '../types/analyze-options.js'\n\nexport abstract class BaseAnalyzer<TGraph> {\n constructor(\n protected readonly entryFile: string,\n protected readonly options: AnalyzeOptions,\n ) {}\n\n analyze(): TGraph {\n return this.doAnalyze()\n }\n\n protected abstract doAnalyze(): TGraph\n}\n","import path from 'node:path'\n\nexport const SOURCE_EXTENSIONS = new Set([\n '.js',\n '.jsx',\n '.ts',\n '.tsx',\n '.mjs',\n '.cjs',\n '.mts',\n '.cts',\n])\n\nexport function isSourceCodeFile(filePath: string): boolean {\n return SOURCE_EXTENSIONS.has(path.extname(filePath).toLowerCase())\n}\n","import path from 'node:path'\n\nexport function normalizeFilePath(filePath: string): string {\n return path.normalize(filePath)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\n\nexport function resolveExistingPath(cwd: string, entryFile: string): string {\n const absolutePath = path.resolve(cwd, entryFile)\n const normalizedPath = normalizeFilePath(absolutePath)\n\n if (!fs.existsSync(normalizedPath)) {\n throw new Error(`Entry file not found: ${entryFile}`)\n }\n\n if (!isSourceCodeFile(normalizedPath)) {\n throw new Error(`Entry file must be a JS/TS source file: ${entryFile}`)\n }\n\n return normalizedPath\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport ts from 'typescript'\n\nexport function createProgram(\n entryFile: string,\n compilerOptions: ts.CompilerOptions,\n currentDirectory: string,\n): ts.Program {\n const host = ts.createCompilerHost(compilerOptions, true)\n host.getCurrentDirectory = () => currentDirectory\n\n if (ts.sys.realpath !== undefined) {\n host.realpath = ts.sys.realpath\n }\n\n return ts.createProgram({\n rootNames: [entryFile],\n options: compilerOptions,\n host,\n })\n}\n\nexport function createSourceFile(filePath: string): ts.SourceFile {\n const sourceText = fs.readFileSync(filePath, 'utf8')\n return ts.createSourceFile(\n filePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true,\n getScriptKind(filePath),\n )\n}\n\nexport function createModuleResolutionHost(\n currentDirectory: string,\n): ts.ModuleResolutionHost {\n return {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n directoryExists: ts.sys.directoryExists,\n getCurrentDirectory: () => currentDirectory,\n getDirectories: ts.sys.getDirectories,\n ...(ts.sys.realpath === undefined ? {} : { realpath: ts.sys.realpath }),\n }\n}\n\nfunction getScriptKind(filePath: string): ts.ScriptKind {\n switch (path.extname(filePath).toLowerCase()) {\n case '.js':\n case '.mjs':\n case '.cjs':\n return ts.ScriptKind.JS\n case '.jsx':\n return ts.ScriptKind.JSX\n case '.tsx':\n return ts.ScriptKind.TSX\n case '.json':\n return ts.ScriptKind.JSON\n default:\n return ts.ScriptKind.TS\n }\n}\n","import ts from 'typescript'\n\nexport function collectUnusedImports(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n): ReadonlyMap<ts.ImportDeclaration, boolean> {\n const importUsage = new Map<\n ts.ImportDeclaration,\n {\n canTrack: boolean\n used: boolean\n }\n >()\n const symbolToImportDeclaration = new Map<ts.Symbol, ts.ImportDeclaration>()\n const importedLocalNames = new Set<string>()\n\n sourceFile.statements.forEach((statement) => {\n if (\n !ts.isImportDeclaration(statement) ||\n statement.importClause === undefined\n ) {\n return\n }\n\n const identifiers = getImportBindingIdentifiers(statement.importClause)\n if (identifiers.length === 0) {\n return\n }\n\n importUsage.set(statement, {\n canTrack: false,\n used: false,\n })\n\n identifiers.forEach((identifier) => {\n importedLocalNames.add(identifier.text)\n\n const symbol = tryGetSymbolAtLocation(checker, identifier)\n if (symbol === undefined) {\n return\n }\n\n symbolToImportDeclaration.set(symbol, statement)\n const state = importUsage.get(statement)\n if (state !== undefined) {\n state.canTrack = true\n }\n })\n })\n\n function visit(node: ts.Node): void {\n if (ts.isImportDeclaration(node)) {\n return\n }\n\n if (\n ts.isIdentifier(node) &&\n importedLocalNames.has(node.text) &&\n isReferenceIdentifier(node)\n ) {\n const symbol = tryGetSymbolAtLocation(checker, node)\n const declaration =\n symbol === undefined ? undefined : symbolToImportDeclaration.get(symbol)\n if (declaration !== undefined) {\n const state = importUsage.get(declaration)\n if (state !== undefined) {\n state.used = true\n }\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n return new Map(\n [...importUsage.entries()].map(([declaration, state]) => [\n declaration,\n state.canTrack && !state.used,\n ]),\n )\n}\n\nfunction getImportBindingIdentifiers(\n importClause: ts.ImportClause,\n): ts.Identifier[] {\n const identifiers: ts.Identifier[] = []\n\n if (importClause.name !== undefined) {\n identifiers.push(importClause.name)\n }\n\n const namedBindings = importClause.namedBindings\n if (namedBindings === undefined) {\n return identifiers\n }\n\n if (ts.isNamespaceImport(namedBindings)) {\n identifiers.push(namedBindings.name)\n return identifiers\n }\n\n namedBindings.elements.forEach((element) => {\n identifiers.push(element.name)\n })\n\n return identifiers\n}\n\nfunction isReferenceIdentifier(node: ts.Identifier): boolean {\n const parent = node.parent\n\n if (ts.isPropertyAccessExpression(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isQualifiedName(parent) && parent.right === node) {\n return false\n }\n\n if (ts.isPropertyAssignment(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isBindingElement(parent) && parent.propertyName === node) {\n return false\n }\n\n if (ts.isJsxAttribute(parent) && parent.name === node) {\n return false\n }\n\n if (ts.isExportSpecifier(parent)) {\n return parent.propertyName === node || parent.propertyName === undefined\n }\n\n return true\n}\n\nfunction tryGetSymbolAtLocation(\n checker: ts.TypeChecker,\n node: ts.Node,\n): ts.Symbol | undefined {\n try {\n return checker.getSymbolAtLocation(node)\n } catch {\n return undefined\n }\n}\n","import ts from 'typescript'\n\nimport type { ReferenceKind } from '../../types/reference-kind.js'\nimport { collectUnusedImports } from './unused.js'\n\nexport interface ModuleReference {\n readonly specifier: string\n readonly referenceKind: ReferenceKind\n readonly isTypeOnly: boolean\n readonly unused: boolean\n}\n\nexport function collectModuleReferences(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n): ModuleReference[] {\n const references = new Map<string, ModuleReference>()\n const unusedImports = collectUnusedImports(sourceFile, checker)\n\n function addReference(\n specifier: string,\n referenceKind: ReferenceKind,\n isTypeOnly: boolean,\n unused: boolean,\n ): void {\n const key = `${referenceKind}:${isTypeOnly ? 'type' : 'value'}:${specifier}`\n const existing = references.get(key)\n if (existing !== undefined) {\n if (existing.unused && !unused) {\n references.set(key, {\n ...existing,\n unused: false,\n })\n }\n return\n }\n\n references.set(key, {\n specifier,\n referenceKind,\n isTypeOnly,\n unused,\n })\n }\n\n function visit(node: ts.Node): void {\n if (\n ts.isImportDeclaration(node) &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n addReference(\n node.moduleSpecifier.text,\n 'import',\n node.importClause?.isTypeOnly ?? false,\n unusedImports.get(node) ?? false,\n )\n } else if (\n ts.isExportDeclaration(node) &&\n node.moduleSpecifier !== undefined &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n addReference(\n node.moduleSpecifier.text,\n 'export',\n node.isTypeOnly ?? false,\n false,\n )\n } else if (ts.isImportEqualsDeclaration(node)) {\n const moduleReference = node.moduleReference\n if (\n ts.isExternalModuleReference(moduleReference) &&\n moduleReference.expression !== undefined &&\n ts.isStringLiteralLike(moduleReference.expression)\n ) {\n addReference(\n moduleReference.expression.text,\n 'import-equals',\n false,\n false,\n )\n }\n } else if (ts.isCallExpression(node)) {\n if (\n node.expression.kind === ts.SyntaxKind.ImportKeyword &&\n node.arguments.length === 1\n ) {\n const [argument] = node.arguments\n if (argument !== undefined && ts.isStringLiteralLike(argument)) {\n addReference(argument.text, 'dynamic-import', false, false)\n }\n }\n\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'require' &&\n node.arguments.length === 1\n ) {\n const [argument] = node.arguments\n if (argument !== undefined && ts.isStringLiteralLike(argument)) {\n addReference(argument.text, 'require', false, false)\n }\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return [...references.values()]\n}\n","import { builtinModules } from 'node:module'\nimport path from 'node:path'\nimport type { ResolverFactory } from 'oxc-resolver'\nimport ts from 'typescript'\n\nimport type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyKind } from '../../types/dependency-kind.js'\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\nimport type { ModuleReference } from './references.js'\n\nconst BUILTIN_MODULES = new Set(\n builtinModules.flatMap((name) => [name, `node:${name}`]),\n)\n\nexport interface ResolverConfigContext {\n readonly path?: string\n readonly compilerOptions: ts.CompilerOptions\n}\n\nexport interface ResolveDependencyOptions {\n readonly cwd: string\n readonly entryConfigPath?: string\n readonly expandWorkspaces: boolean\n readonly projectOnly: boolean\n readonly getConfigForFile: (filePath: string) => ResolverConfigContext\n readonly getResolverForFile: (filePath: string) => ResolverFactory\n}\n\nexport function resolveDependency(\n reference: ModuleReference,\n containingFile: string,\n options: ResolveDependencyOptions,\n): DependencyEdge {\n const specifier = reference.specifier\n if (BUILTIN_MODULES.has(specifier)) {\n return createEdge(reference, 'builtin', specifier)\n }\n\n const containingConfig = options.getConfigForFile(containingFile)\n const oxcResolution = resolveWithOxc(\n reference,\n specifier,\n containingFile,\n options,\n )\n if (oxcResolution !== undefined) {\n return oxcResolution\n }\n\n const host = createResolutionHost(containingConfig, options.cwd)\n const resolution = ts.resolveModuleName(\n specifier,\n containingFile,\n containingConfig.compilerOptions,\n host,\n ).resolvedModule\n\n if (resolution !== undefined) {\n const resolvedPath = normalizeFilePath(resolution.resolvedFileName)\n const realPath = resolveRealPath(resolvedPath)\n const sourcePath = pickSourcePath(resolvedPath, realPath)\n\n if (sourcePath !== undefined) {\n const boundary = classifyBoundary(specifier, sourcePath, options)\n if (boundary !== undefined) {\n return createEdge(reference, 'boundary', sourcePath, boundary)\n }\n\n if (\n !resolution.isExternalLibraryImport ||\n !isInsideNodeModules(sourcePath) ||\n (realPath !== undefined && !isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'source', sourcePath)\n }\n }\n\n if (\n resolution.isExternalLibraryImport ||\n isInsideNodeModules(resolvedPath) ||\n (realPath !== undefined && isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'external', specifier)\n }\n }\n\n if (!specifier.startsWith('.') && !path.isAbsolute(specifier)) {\n return createEdge(reference, 'external', specifier)\n }\n\n return createEdge(reference, 'missing', specifier)\n}\n\nfunction resolveWithOxc(\n reference: ModuleReference,\n specifier: string,\n containingFile: string,\n options: ResolveDependencyOptions,\n): DependencyEdge | undefined {\n try {\n const result = options\n .getResolverForFile(containingFile)\n .resolveFileSync(containingFile, specifier)\n\n if (result.builtin !== undefined) {\n return createEdge(reference, 'builtin', result.builtin.resolved)\n }\n\n if (result.path !== undefined) {\n return classifyResolvedPath(reference, specifier, result.path, options)\n }\n } catch {\n return undefined\n }\n\n return undefined\n}\n\nfunction createEdge(\n reference: ModuleReference,\n kind: DependencyKind,\n target: string,\n boundary?: 'workspace' | 'project',\n): DependencyEdge {\n return {\n specifier: reference.specifier,\n referenceKind: reference.referenceKind,\n isTypeOnly: reference.isTypeOnly,\n unused: reference.unused,\n kind,\n target,\n ...(boundary === undefined ? {} : { boundary }),\n }\n}\n\nfunction createResolutionHost(\n config: ResolverConfigContext,\n cwd: string,\n): ts.ModuleResolutionHost {\n return {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n directoryExists: ts.sys.directoryExists,\n getCurrentDirectory: () =>\n config.path === undefined ? cwd : path.dirname(config.path),\n getDirectories: ts.sys.getDirectories,\n ...(ts.sys.realpath === undefined ? {} : { realpath: ts.sys.realpath }),\n }\n}\n\nfunction resolveRealPath(resolvedPath: string): string | undefined {\n if (ts.sys.realpath === undefined) {\n return undefined\n }\n\n try {\n return normalizeFilePath(ts.sys.realpath(resolvedPath))\n } catch {\n return undefined\n }\n}\n\nfunction classifyResolvedPath(\n reference: ModuleReference,\n specifier: string,\n resolvedPathValue: string,\n options: ResolveDependencyOptions,\n): DependencyEdge {\n const resolvedPath = normalizeFilePath(resolvedPathValue)\n const realPath = resolveRealPath(resolvedPath)\n const sourcePath = pickSourcePath(resolvedPath, realPath)\n\n if (sourcePath !== undefined) {\n const boundary = classifyBoundary(specifier, sourcePath, options)\n if (boundary !== undefined) {\n return createEdge(reference, 'boundary', sourcePath, boundary)\n }\n\n if (\n !isInsideNodeModules(sourcePath) ||\n (realPath !== undefined && !isInsideNodeModules(realPath))\n ) {\n return createEdge(reference, 'source', sourcePath)\n }\n }\n\n return createEdge(reference, 'external', specifier)\n}\n\nfunction pickSourcePath(\n resolvedPath: string,\n realPath: string | undefined,\n): string | undefined {\n const candidates = [realPath, resolvedPath]\n\n for (const candidate of candidates) {\n if (\n candidate !== undefined &&\n isSourceCodeFile(candidate) &&\n !candidate.endsWith('.d.ts')\n ) {\n return candidate\n }\n }\n\n return undefined\n}\n\nfunction classifyBoundary(\n specifier: string,\n sourcePath: string,\n options: ResolveDependencyOptions,\n): 'workspace' | 'project' | undefined {\n const targetConfigPath = options.getConfigForFile(sourcePath).path\n const entryConfigPath = options.entryConfigPath\n\n if (\n options.projectOnly &&\n entryConfigPath !== undefined &&\n targetConfigPath !== entryConfigPath\n ) {\n return 'project'\n }\n\n if (\n !options.expandWorkspaces &&\n isWorkspaceLikeImport(specifier) &&\n entryConfigPath !== undefined &&\n targetConfigPath !== entryConfigPath\n ) {\n return 'workspace'\n }\n\n return undefined\n}\n\nfunction isWorkspaceLikeImport(specifier: string): boolean {\n return !specifier.startsWith('.') && !path.isAbsolute(specifier)\n}\n\nfunction isInsideNodeModules(filePath: string): boolean {\n return filePath.includes(`${path.sep}node_modules${path.sep}`)\n}\n","import path from 'node:path'\nimport { ResolverFactory } from 'oxc-resolver'\nimport type ts from 'typescript'\n\nimport type { SourceModuleNode } from '../../types/source-module-node.js'\nimport { loadCompilerOptions } from '../../typescript/config.js'\nimport { createProgram, createSourceFile } from '../../typescript/program.js'\nimport { normalizeFilePath } from '../../utils/normalize-file-path.js'\nimport { collectModuleReferences } from './references.js'\nimport { resolveDependency } from './resolver.js'\n\nexport function buildDependencyGraph(\n entryPath: string,\n options: BuildDependencyGraphOptions,\n): Map<string, SourceModuleNode> {\n return new DependencyGraphBuilder(entryPath, options).build()\n}\n\nexport interface BuildDependencyGraphOptions {\n readonly cwd: string\n readonly entryConfigPath?: string\n readonly entryCompilerOptions: ts.CompilerOptions\n readonly expandWorkspaces: boolean\n readonly projectOnly: boolean\n}\n\nclass DependencyGraphBuilder {\n private readonly nodes = new Map<string, SourceModuleNode>()\n private readonly configCache = new Map<\n string,\n import('./resolver.js').ResolverConfigContext\n >()\n private readonly programCache = new Map<string, ts.Program>()\n private readonly checkerCache = new Map<string, ts.TypeChecker>()\n private readonly resolverCache = new Map<string, ResolverFactory>()\n\n constructor(\n private readonly entryPath: string,\n private readonly options: BuildDependencyGraphOptions,\n ) {\n const entryConfig: import('./resolver.js').ResolverConfigContext = {\n compilerOptions: options.entryCompilerOptions,\n ...(options.entryConfigPath === undefined\n ? {}\n : { path: options.entryConfigPath }),\n }\n\n this.configCache.set(path.dirname(this.entryPath), entryConfig)\n }\n\n build(): Map<string, SourceModuleNode> {\n this.visitFile(this.entryPath)\n return this.nodes\n }\n\n private visitFile(filePath: string): void {\n const normalizedPath = normalizeFilePath(filePath)\n if (this.nodes.has(normalizedPath)) {\n return\n }\n\n const config = this.getConfigForFile(normalizedPath)\n const program = this.getProgramForFile(normalizedPath, config)\n const checker = this.getCheckerForFile(normalizedPath, config)\n const sourceFile =\n program.getSourceFile(normalizedPath) ?? createSourceFile(normalizedPath)\n\n const references = collectModuleReferences(sourceFile, checker)\n const dependencies = references.map((reference) =>\n resolveDependency(reference, normalizedPath, {\n cwd: this.options.cwd,\n expandWorkspaces: this.options.expandWorkspaces,\n projectOnly: this.options.projectOnly,\n getConfigForFile: (targetPath) => this.getConfigForFile(targetPath),\n getResolverForFile: (targetPath) => this.getResolverForFile(targetPath),\n ...(this.options.entryConfigPath === undefined\n ? {}\n : { entryConfigPath: this.options.entryConfigPath }),\n }),\n )\n\n this.nodes.set(normalizedPath, {\n id: normalizedPath,\n dependencies,\n })\n\n for (const dependency of dependencies) {\n if (dependency.kind === 'source') {\n this.visitFile(dependency.target)\n }\n }\n }\n\n private getConfigForFile(\n filePath: string,\n ): import('./resolver.js').ResolverConfigContext {\n const directory = path.dirname(filePath)\n const cached = this.configCache.get(directory)\n if (cached !== undefined) {\n return cached\n }\n\n const loaded = loadCompilerOptions(directory)\n this.configCache.set(directory, loaded)\n return loaded\n }\n\n private getProgramForFile(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): ts.Program {\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.programCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const currentDirectory =\n config.path === undefined\n ? path.dirname(filePath)\n : path.dirname(config.path)\n const program = createProgram(\n filePath,\n config.compilerOptions,\n currentDirectory,\n )\n this.programCache.set(cacheKey, program)\n return program\n }\n\n private getCheckerForFile(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): ts.TypeChecker {\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.checkerCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const checker = this.getProgramForFile(filePath, config).getTypeChecker()\n this.checkerCache.set(cacheKey, checker)\n return checker\n }\n\n private getProgramCacheKey(\n filePath: string,\n config: import('./resolver.js').ResolverConfigContext,\n ): string {\n return config.path ?? `default:${path.dirname(filePath)}`\n }\n\n private getResolverForFile(filePath: string): ResolverFactory {\n const config = this.getConfigForFile(filePath)\n const cacheKey = this.getProgramCacheKey(filePath, config)\n const cached = this.resolverCache.get(cacheKey)\n if (cached !== undefined) {\n return cached\n }\n\n const resolver = new ResolverFactory({\n builtinModules: true,\n conditionNames: ['import', 'require', 'default'],\n extensions: [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.mts',\n '.cts',\n '.mjs',\n '.cjs',\n '.json',\n ],\n mainFields: ['types', 'module', 'main'],\n tsconfig:\n config.path === undefined ? 'auto' : { configFile: config.path },\n })\n this.resolverCache.set(cacheKey, resolver)\n return resolver\n }\n}\n","import path from 'node:path'\n\nimport type { AnalyzeOptions } from '../../types/analyze-options.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport { loadCompilerOptions } from '../../typescript/config.js'\nimport { BaseAnalyzer } from '../base.js'\nimport { resolveExistingPath } from './entry.js'\nimport { buildDependencyGraph } from './graph.js'\n\nexport function analyzeDependencies(\n entryFile: string,\n options: AnalyzeOptions = {},\n): DependencyGraph {\n return new ImportAnalyzer(entryFile, options).analyze()\n}\n\nclass ImportAnalyzer extends BaseAnalyzer<DependencyGraph> {\n private readonly cwd: string\n private readonly entryPath: string\n\n constructor(entryFile: string, options: AnalyzeOptions) {\n super(entryFile, options)\n this.cwd = path.resolve(options.cwd ?? process.cwd())\n this.entryPath = resolveExistingPath(this.cwd, entryFile)\n }\n\n protected doAnalyze(): DependencyGraph {\n const { compilerOptions, path: configPath } = loadCompilerOptions(\n path.dirname(this.entryPath),\n this.options.configPath,\n )\n const nodes = buildDependencyGraph(this.entryPath, {\n cwd: this.cwd,\n entryCompilerOptions: compilerOptions,\n expandWorkspaces: this.options.expandWorkspaces ?? true,\n projectOnly: this.options.projectOnly ?? false,\n ...(configPath === undefined ? {} : { entryConfigPath: configPath }),\n })\n\n return {\n cwd: this.cwd,\n entryId: this.entryPath,\n nodes,\n ...(configPath === undefined ? {} : { configPath }),\n }\n }\n}\n","import type {\n ExportAllDeclaration,\n ExportDefaultDeclaration,\n ExportNamedDeclaration,\n ImportDeclaration,\n ImportDeclarationSpecifier,\n ModuleExportName,\n Statement,\n} from 'oxc-parser'\n\nimport type { PendingReactUsageNode } from './file.js'\n\nexport interface ImportBinding {\n readonly importedName: string\n readonly sourceSpecifier: string\n readonly sourcePath?: string\n}\n\nexport function collectImportsAndExports(\n statement: Statement,\n sourceDependencies: ReadonlyMap<string, string>,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n importsByLocalName: Map<string, ImportBinding>,\n exportsByName: Map<string, string>,\n reExportBindingsByName: Map<string, ImportBinding>,\n exportAllBindings: ImportBinding[],\n): void {\n switch (statement.type) {\n case 'ImportDeclaration':\n collectImportBindings(statement, sourceDependencies, importsByLocalName)\n return\n case 'ExportNamedDeclaration':\n collectNamedExports(\n statement,\n sourceDependencies,\n symbolsByName,\n exportsByName,\n reExportBindingsByName,\n )\n return\n case 'ExportAllDeclaration':\n collectExportAllBindings(statement, sourceDependencies, exportAllBindings)\n return\n case 'ExportDefaultDeclaration':\n collectDefaultExport(statement, symbolsByName, exportsByName)\n return\n default:\n return\n }\n}\n\nfunction collectImportBindings(\n declaration: ImportDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n importsByLocalName: Map<string, ImportBinding>,\n): void {\n if (declaration.importKind === 'type') {\n return\n }\n\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(declaration.source.value)\n\n declaration.specifiers.forEach((specifier) => {\n const binding = getImportBinding(specifier, sourceSpecifier, sourcePath)\n if (binding === undefined) {\n return\n }\n\n importsByLocalName.set(binding.localName, {\n importedName: binding.importedName,\n sourceSpecifier: binding.sourceSpecifier,\n ...(binding.sourcePath === undefined\n ? {}\n : { sourcePath: binding.sourcePath }),\n })\n })\n}\n\nfunction getImportBinding(\n specifier: ImportDeclarationSpecifier,\n sourceSpecifier: string,\n sourcePath: string | undefined,\n):\n | {\n readonly localName: string\n readonly importedName: string\n readonly sourceSpecifier: string\n readonly sourcePath?: string\n }\n | undefined {\n if (specifier.type === 'ImportSpecifier') {\n if (specifier.importKind === 'type') {\n return undefined\n }\n\n return {\n localName: specifier.local.name,\n importedName: toModuleExportName(specifier.imported),\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n }\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n return {\n localName: specifier.local.name,\n importedName: 'default',\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n }\n }\n\n return undefined\n}\n\nfunction collectNamedExports(\n declaration: ExportNamedDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n reExportBindingsByName: Map<string, ImportBinding>,\n): void {\n if (declaration.exportKind === 'type') {\n return\n }\n\n if (declaration.declaration !== null) {\n if (declaration.declaration.type === 'FunctionDeclaration') {\n const name = declaration.declaration.id?.name\n if (name !== undefined) {\n addExportBinding(name, name, symbolsByName, exportsByName)\n }\n } else if (declaration.declaration.type === 'VariableDeclaration') {\n declaration.declaration.declarations.forEach((declarator) => {\n if (declarator.id.type === 'Identifier') {\n addExportBinding(\n declarator.id.name,\n declarator.id.name,\n symbolsByName,\n exportsByName,\n )\n }\n })\n }\n\n return\n }\n\n if (declaration.source !== null) {\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(sourceSpecifier)\n\n declaration.specifiers.forEach((specifier) => {\n if (specifier.exportKind === 'type') {\n return\n }\n\n reExportBindingsByName.set(toModuleExportName(specifier.exported), {\n importedName: toModuleExportName(specifier.local),\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n })\n })\n return\n }\n\n declaration.specifiers.forEach((specifier) => {\n if (specifier.exportKind === 'type') {\n return\n }\n\n const localName = toModuleExportName(specifier.local)\n const exportedName = toModuleExportName(specifier.exported)\n addExportBinding(localName, exportedName, symbolsByName, exportsByName)\n })\n}\n\nfunction collectExportAllBindings(\n declaration: ExportAllDeclaration,\n sourceDependencies: ReadonlyMap<string, string>,\n exportAllBindings: ImportBinding[],\n): void {\n if (declaration.exportKind === 'type') {\n return\n }\n\n const sourceSpecifier = declaration.source.value\n const sourcePath = sourceDependencies.get(sourceSpecifier)\n\n exportAllBindings.push({\n importedName: '*',\n sourceSpecifier,\n ...(sourcePath === undefined ? {} : { sourcePath }),\n })\n}\n\nfunction collectDefaultExport(\n declaration: ExportDefaultDeclaration,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n): void {\n if (\n declaration.declaration.type === 'FunctionDeclaration' ||\n declaration.declaration.type === 'FunctionExpression'\n ) {\n const localName = declaration.declaration.id?.name\n if (localName !== undefined) {\n addExportBinding(localName, 'default', symbolsByName, exportsByName)\n }\n return\n }\n\n if (declaration.declaration.type === 'Identifier') {\n addExportBinding(\n declaration.declaration.name,\n 'default',\n symbolsByName,\n exportsByName,\n )\n return\n }\n\n if (declaration.declaration.type === 'ArrowFunctionExpression') {\n addExportBinding('default', 'default', symbolsByName, exportsByName)\n }\n}\n\nfunction addExportBinding(\n localName: string,\n exportedName: string,\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n exportsByName: Map<string, string>,\n): void {\n const symbol = symbolsByName.get(localName)\n if (symbol === undefined) {\n return\n }\n\n symbol.exportNames.add(exportedName)\n exportsByName.set(exportedName, symbol.id)\n}\n\nfunction toModuleExportName(name: ModuleExportName): string {\n return name.type === 'Literal' ? name.value : name.name\n}\n","import type {\n ArrowFunctionExpression,\n CallExpression,\n Expression,\n FunctionBody,\n JSXElement,\n JSXElementName,\n JSXFragment,\n Node,\n} from 'oxc-parser'\nimport { visitorKeys } from 'oxc-parser'\n\nexport const FUNCTION_NODE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'TSDeclareFunction',\n 'TSEmptyBodyFunctionExpression',\n])\n\nexport function walkReactUsageTree(\n root: FunctionBody | Expression | JSXFragment | JSXElement,\n visit: (node: Node) => void,\n): void {\n walkNode(root, visit, true)\n}\n\nexport function walkNode(\n node: Node,\n visit: (node: Node) => void,\n allowNestedFunctions = false,\n): void {\n visit(node)\n\n const keys = visitorKeys[node.type]\n if (keys === undefined) {\n return\n }\n\n keys.forEach((key) => {\n const value = (node as unknown as Record<string, unknown>)[key]\n walkChild(value, visit, allowNestedFunctions)\n })\n}\n\nfunction walkChild(\n value: unknown,\n visit: (node: Node) => void,\n allowNestedFunctions: boolean,\n): void {\n if (Array.isArray(value)) {\n value.forEach((entry) => {\n walkChild(entry, visit, allowNestedFunctions)\n })\n return\n }\n\n if (!isNode(value)) {\n return\n }\n\n if (!allowNestedFunctions && FUNCTION_NODE_TYPES.has(value.type)) {\n return\n }\n\n walkNode(value, visit, false)\n}\n\nexport function isNode(value: unknown): value is Node {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n typeof (value as { type: unknown }).type === 'string'\n )\n}\n\nexport function classifyReactSymbol(\n name: string,\n declaration: ArrowFunctionExpression | import('oxc-parser').Function,\n): import('../../types/react-symbol-kind.js').ReactSymbolKind | undefined {\n if (isHookName(name)) {\n return 'hook'\n }\n\n if (isComponentName(name) && returnsReactElement(declaration)) {\n return 'component'\n }\n\n return undefined\n}\n\nexport function containsReactElementLikeExpression(\n expression: Expression,\n): boolean {\n let found = false\n\n walkNode(expression, (node) => {\n if (\n node.type === 'JSXElement' ||\n node.type === 'JSXFragment' ||\n (node.type === 'CallExpression' && isReactCreateElementCall(node))\n ) {\n found = true\n }\n })\n\n return found\n}\n\nexport function getComponentReferenceName(\n node: JSXElement,\n): string | undefined {\n const name = getJsxName(node.openingElement.name)\n return name !== undefined && isComponentName(name) ? name : undefined\n}\n\nexport function getBuiltinReferenceName(node: JSXElement): string | undefined {\n const name = getJsxName(node.openingElement.name)\n return name !== undefined && isIntrinsicElementName(name) ? name : undefined\n}\n\nexport function getHookReferenceName(node: CallExpression): string | undefined {\n const calleeName = getIdentifierName(node.callee)\n return calleeName !== undefined && isHookName(calleeName)\n ? calleeName\n : undefined\n}\n\nexport function getCreateElementComponentReferenceName(\n node: CallExpression,\n): string | undefined {\n if (!isReactCreateElementCall(node)) {\n return undefined\n }\n\n const [firstArgument] = node.arguments\n if (firstArgument === undefined || firstArgument.type !== 'Identifier') {\n return undefined\n }\n\n return isComponentName(firstArgument.name) ? firstArgument.name : undefined\n}\n\nexport function isHookName(name: string): boolean {\n return /^use[A-Z0-9]/.test(name)\n}\n\nexport function isComponentName(name: string): boolean {\n return /^[A-Z]/.test(name)\n}\n\nfunction isIntrinsicElementName(name: string): boolean {\n return /^[a-z]/.test(name)\n}\n\nfunction returnsReactElement(\n declaration: ArrowFunctionExpression | import('oxc-parser').Function,\n): boolean {\n if (\n declaration.type === 'ArrowFunctionExpression' &&\n declaration.expression\n ) {\n return containsReactElementLikeExpression(declaration.body as Expression)\n }\n\n const body = declaration.body\n if (body === null) {\n return false\n }\n\n let found = false\n walkReactUsageTree(body, (node) => {\n if (node.type !== 'ReturnStatement' || node.argument === null) {\n return\n }\n\n if (containsReactElementLikeExpression(node.argument)) {\n found = true\n }\n })\n\n return found\n}\n\nfunction isReactCreateElementCall(node: CallExpression): boolean {\n const callee = unwrapExpression(node.callee)\n if (callee.type !== 'MemberExpression' || callee.computed) {\n return false\n }\n\n return (\n callee.object.type === 'Identifier' &&\n callee.object.name === 'React' &&\n callee.property.name === 'createElement'\n )\n}\n\nfunction getJsxName(name: JSXElementName): string | undefined {\n if (name.type === 'JSXIdentifier') {\n return name.name\n }\n\n return undefined\n}\n\nfunction getIdentifierName(expression: Expression): string | undefined {\n const unwrapped = unwrapExpression(expression)\n return unwrapped.type === 'Identifier' ? unwrapped.name : undefined\n}\n\nfunction unwrapExpression(expression: Expression): Expression {\n let current = expression\n\n while (true) {\n if (\n current.type === 'ParenthesizedExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSTypeAssertion' ||\n current.type === 'TSNonNullExpression'\n ) {\n current = current.expression\n continue\n }\n\n return current\n }\n}\n","import type { Node, Program, Statement } from 'oxc-parser'\nimport { visitorKeys } from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ReactUsageLocation } from '../../types/react-usage-location.js'\nimport {\n FUNCTION_NODE_TYPES,\n getBuiltinReferenceName,\n getComponentReferenceName,\n getCreateElementComponentReferenceName,\n getHookReferenceName,\n isNode,\n} from './walk.js'\n\nexport interface PendingReactUsageEntry {\n readonly referenceName: string\n readonly kind: ReactSymbolKind\n readonly location: ReactUsageLocation\n}\n\nexport function collectEntryUsages(\n program: Program,\n filePath: string,\n sourceText: string,\n includeBuiltins: boolean,\n): PendingReactUsageEntry[] {\n const entries = new Map<string, PendingReactUsageEntry>()\n\n program.body.forEach((statement) => {\n collectStatementEntryUsages(\n statement,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n )\n })\n\n return [...entries.values()].sort(comparePendingReactUsageEntries)\n}\n\nfunction collectStatementEntryUsages(\n statement: Statement,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n): void {\n collectNodeEntryUsages(\n statement,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n false,\n )\n}\n\nfunction collectNodeEntryUsages(\n node: Node,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n hasComponentAncestor: boolean,\n): void {\n if (FUNCTION_NODE_TYPES.has(node.type)) {\n return\n }\n\n let nextHasComponentAncestor = hasComponentAncestor\n\n if (node.type === 'JSXElement') {\n const referenceName = getComponentReferenceName(node)\n if (referenceName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n referenceName,\n 'component',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n } else if (includeBuiltins) {\n const builtinName = getBuiltinReferenceName(node)\n if (builtinName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n builtinName,\n 'builtin',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n }\n }\n } else if (node.type === 'CallExpression') {\n const hookReference = getHookReferenceName(node)\n if (hookReference !== undefined) {\n addPendingReactUsageEntry(\n entries,\n hookReference,\n 'hook',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n\n const referenceName = getCreateElementComponentReferenceName(node)\n if (referenceName !== undefined) {\n if (!hasComponentAncestor) {\n addPendingReactUsageEntry(\n entries,\n referenceName,\n 'component',\n createReactUsageLocation(filePath, sourceText, node.start),\n )\n }\n nextHasComponentAncestor = true\n }\n }\n\n const keys = visitorKeys[node.type]\n if (keys === undefined) {\n return\n }\n\n keys.forEach((key) => {\n const value = (node as unknown as Record<string, unknown>)[key]\n collectEntryUsageChild(\n value,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n nextHasComponentAncestor,\n )\n })\n}\n\nfunction collectEntryUsageChild(\n value: unknown,\n filePath: string,\n sourceText: string,\n entries: Map<string, PendingReactUsageEntry>,\n includeBuiltins: boolean,\n hasComponentAncestor: boolean,\n): void {\n if (Array.isArray(value)) {\n value.forEach((entry) => {\n collectEntryUsageChild(\n entry,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n hasComponentAncestor,\n )\n })\n return\n }\n\n if (!isNode(value)) {\n return\n }\n\n collectNodeEntryUsages(\n value,\n filePath,\n sourceText,\n entries,\n includeBuiltins,\n hasComponentAncestor,\n )\n}\n\nfunction addPendingReactUsageEntry(\n entries: Map<string, PendingReactUsageEntry>,\n referenceName: string,\n kind: ReactSymbolKind,\n location: ReactUsageLocation,\n): void {\n const key = `${location.filePath}:${location.line}:${location.column}:${kind}:${referenceName}`\n entries.set(key, {\n referenceName,\n kind,\n location,\n })\n}\n\nexport function createReactUsageLocation(\n filePath: string,\n sourceText: string,\n offset: number,\n): ReactUsageLocation {\n return {\n filePath,\n ...offsetToLineAndColumn(sourceText, offset),\n }\n}\n\nfunction offsetToLineAndColumn(\n sourceText: string,\n offset: number,\n): Pick<ReactUsageLocation, 'line' | 'column'> {\n let line = 1\n let column = 1\n\n for (let index = 0; index < offset && index < sourceText.length; index += 1) {\n if (sourceText[index] === '\\n') {\n line += 1\n column = 1\n continue\n }\n\n column += 1\n }\n\n return { line, column }\n}\n\nfunction comparePendingReactUsageEntries(\n left: PendingReactUsageEntry,\n right: PendingReactUsageEntry,\n): number {\n return (\n left.location.filePath.localeCompare(right.location.filePath) ||\n left.location.line - right.location.line ||\n left.location.column - right.location.column ||\n left.kind.localeCompare(right.kind) ||\n left.referenceName.localeCompare(right.referenceName)\n )\n}\n","import type {\n ArrowFunctionExpression,\n ExportDefaultDeclaration,\n Function as OxcFunction,\n Statement,\n VariableDeclarator,\n} from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { PendingReactUsageNode } from './file.js'\nimport { classifyReactSymbol } from './walk.js'\n\nexport function collectTopLevelReactSymbols(\n statement: Statement,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n switch (statement.type) {\n case 'FunctionDeclaration':\n addFunctionSymbol(statement, filePath, symbolsByName)\n return\n case 'VariableDeclaration':\n statement.declarations.forEach((declarator) => {\n addVariableSymbol(declarator, filePath, symbolsByName)\n })\n return\n case 'ExportNamedDeclaration':\n if (statement.declaration !== null) {\n collectTopLevelReactSymbols(\n statement.declaration,\n filePath,\n symbolsByName,\n )\n }\n return\n case 'ExportDefaultDeclaration':\n addDefaultExportSymbol(statement, filePath, symbolsByName)\n return\n default:\n return\n }\n}\n\nfunction addFunctionSymbol(\n declaration: OxcFunction,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n const name = declaration.id?.name\n if (name === undefined) {\n return\n }\n\n const kind = classifyReactSymbol(name, declaration)\n if (kind === undefined) {\n return\n }\n\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declaration),\n )\n}\n\nfunction addVariableSymbol(\n declarator: VariableDeclarator,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n if (declarator.id.type !== 'Identifier' || declarator.init === null) {\n return\n }\n\n if (\n declarator.init.type !== 'ArrowFunctionExpression' &&\n declarator.init.type !== 'FunctionExpression'\n ) {\n return\n }\n\n const name = declarator.id.name\n const kind = classifyReactSymbol(name, declarator.init)\n if (kind === undefined) {\n return\n }\n\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declarator.init),\n )\n}\n\nfunction addDefaultExportSymbol(\n declaration: ExportDefaultDeclaration,\n filePath: string,\n symbolsByName: Map<string, PendingReactUsageNode>,\n): void {\n if (\n declaration.declaration.type === 'FunctionDeclaration' ||\n declaration.declaration.type === 'FunctionExpression'\n ) {\n addFunctionSymbol(declaration.declaration, filePath, symbolsByName)\n } else if (declaration.declaration.type === 'ArrowFunctionExpression') {\n const name = 'default'\n const kind = declaration.declaration.body\n ? classifyReactSymbol(name, declaration.declaration)\n : undefined\n if (kind !== undefined) {\n symbolsByName.set(\n name,\n createPendingSymbol(filePath, name, kind, declaration.declaration),\n )\n }\n }\n}\n\nfunction createPendingSymbol(\n filePath: string,\n name: string,\n kind: ReactSymbolKind,\n declaration: OxcFunction | ArrowFunctionExpression,\n): PendingReactUsageNode {\n return {\n id: `${filePath}#${kind}:${name}`,\n name,\n kind,\n filePath,\n declarationOffset: declaration.id?.start ?? declaration.start,\n declaration,\n exportNames: new Set<string>(),\n componentReferences: new Set<string>(),\n hookReferences: new Set<string>(),\n builtinReferences: new Set<string>(),\n }\n}\n","import type { PendingReactUsageNode } from './file.js'\nimport {\n getBuiltinReferenceName,\n getComponentReferenceName,\n getCreateElementComponentReferenceName,\n getHookReferenceName,\n walkReactUsageTree,\n} from './walk.js'\n\nexport function analyzeSymbolUsages(\n symbol: PendingReactUsageNode,\n includeBuiltins: boolean,\n): void {\n const root =\n symbol.declaration.type === 'ArrowFunctionExpression'\n ? symbol.declaration.body\n : symbol.declaration.body\n\n if (root === null) {\n return\n }\n\n walkReactUsageTree(root, (node) => {\n if (node.type === 'JSXElement') {\n const name = getComponentReferenceName(node)\n if (name !== undefined) {\n symbol.componentReferences.add(name)\n }\n\n if (includeBuiltins) {\n const builtinName = getBuiltinReferenceName(node)\n if (builtinName !== undefined) {\n symbol.builtinReferences.add(builtinName)\n }\n }\n return\n }\n\n if (node.type === 'CallExpression') {\n const hookReference = getHookReferenceName(node)\n if (hookReference !== undefined) {\n symbol.hookReferences.add(hookReference)\n }\n\n const componentReference = getCreateElementComponentReferenceName(node)\n if (componentReference !== undefined) {\n symbol.componentReferences.add(componentReference)\n }\n }\n })\n}\n","import type {\n ArrowFunctionExpression,\n Function as OxcFunction,\n Program,\n} from 'oxc-parser'\n\nimport type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ImportBinding } from './bindings.js'\nimport { collectImportsAndExports } from './bindings.js'\nimport type { PendingReactUsageEntry } from './entries.js'\nimport { collectEntryUsages, createReactUsageLocation } from './entries.js'\nimport { collectTopLevelReactSymbols } from './symbols.js'\nimport { analyzeSymbolUsages } from './usage.js'\n\nexport interface PendingReactUsageNode {\n readonly id: string\n readonly name: string\n readonly kind: ReactSymbolKind\n readonly filePath: string\n readonly declarationOffset: number\n readonly declaration: OxcFunction | ArrowFunctionExpression\n readonly exportNames: Set<string>\n readonly componentReferences: Set<string>\n readonly hookReferences: Set<string>\n readonly builtinReferences: Set<string>\n}\n\nexport interface FileAnalysis {\n readonly filePath: string\n readonly importsByLocalName: Map<string, ImportBinding>\n readonly exportsByName: Map<string, string>\n readonly reExportBindingsByName: Map<string, ImportBinding>\n readonly exportAllBindings: readonly ImportBinding[]\n readonly entryUsages: readonly PendingReactUsageEntry[]\n readonly symbolsById: Map<string, PendingReactUsageNode>\n readonly symbolsByName: Map<string, PendingReactUsageNode>\n}\n\nexport function analyzeReactFile(\n program: Program,\n filePath: string,\n sourceText: string,\n includeNestedRenderEntries: boolean,\n sourceDependencies: ReadonlyMap<string, string>,\n includeBuiltins: boolean,\n): FileAnalysis {\n const symbolsByName = new Map<string, PendingReactUsageNode>()\n\n program.body.forEach((statement) => {\n collectTopLevelReactSymbols(statement, filePath, symbolsByName)\n })\n\n const importsByLocalName = new Map<string, ImportBinding>()\n const exportsByName = new Map<string, string>()\n const reExportBindingsByName = new Map<string, ImportBinding>()\n const exportAllBindings: ImportBinding[] = []\n const directEntryUsages = includeNestedRenderEntries\n ? collectEntryUsages(program, filePath, sourceText, includeBuiltins)\n : []\n\n program.body.forEach((statement) => {\n collectImportsAndExports(\n statement,\n sourceDependencies,\n symbolsByName,\n importsByLocalName,\n exportsByName,\n reExportBindingsByName,\n exportAllBindings,\n )\n })\n\n symbolsByName.forEach((symbol) => {\n analyzeSymbolUsages(symbol, includeBuiltins)\n })\n\n const entryUsages =\n directEntryUsages.length > 0\n ? directEntryUsages\n : includeNestedRenderEntries\n ? collectComponentDeclarationEntryUsages(symbolsByName, sourceText)\n : []\n\n return {\n filePath,\n importsByLocalName,\n exportsByName,\n reExportBindingsByName,\n exportAllBindings,\n entryUsages,\n symbolsById: new Map(\n [...symbolsByName.values()].map((symbol) => [symbol.id, symbol]),\n ),\n symbolsByName,\n }\n}\n\nfunction collectComponentDeclarationEntryUsages(\n symbolsByName: ReadonlyMap<string, PendingReactUsageNode>,\n sourceText: string,\n): PendingReactUsageEntry[] {\n const componentSymbols = [...symbolsByName.values()].filter(\n (symbol) => symbol.kind === 'component',\n )\n if (componentSymbols.length === 0) {\n return []\n }\n\n const exportedComponentSymbols = componentSymbols.filter(\n (symbol) => symbol.exportNames.size > 0,\n )\n const fallbackSymbols =\n exportedComponentSymbols.length > 0\n ? exportedComponentSymbols\n : componentSymbols\n\n return fallbackSymbols\n .sort((left, right) => {\n return (\n left.declarationOffset - right.declarationOffset ||\n left.name.localeCompare(right.name)\n )\n })\n .map((symbol) => ({\n referenceName: symbol.name,\n kind: 'component',\n location: createReactUsageLocation(\n symbol.filePath,\n sourceText,\n symbol.declarationOffset,\n ),\n }))\n}\n","import type { ReactSymbolKind } from '../../types/react-symbol-kind.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport type { ImportBinding } from './bindings.js'\nimport type { FileAnalysis } from './file.js'\nimport { isHookName } from './walk.js'\n\nexport function resolveReactReference(\n fileAnalysis: FileAnalysis,\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n name: string,\n kind: ReactSymbolKind,\n): string | undefined {\n if (kind === 'builtin') {\n return getBuiltinNodeId(name)\n }\n\n const localSymbol = fileAnalysis.symbolsByName.get(name)\n if (localSymbol !== undefined && localSymbol.kind === kind) {\n return localSymbol.id\n }\n\n const importBinding = fileAnalysis.importsByLocalName.get(name)\n if (importBinding === undefined) {\n return undefined\n }\n\n if (importBinding.sourcePath === undefined) {\n return kind === 'hook'\n ? getExternalHookNodeId(importBinding, name)\n : undefined\n }\n\n const sourceFileAnalysis = fileAnalyses.get(importBinding.sourcePath)\n if (sourceFileAnalysis === undefined) {\n return undefined\n }\n\n const targetId = resolveExportedSymbol(\n sourceFileAnalysis,\n importBinding.importedName,\n kind,\n fileAnalyses,\n new Set<string>(),\n )\n if (targetId === undefined) {\n return undefined\n }\n\n return targetId\n}\n\nfunction resolveExportedSymbol(\n fileAnalysis: FileAnalysis,\n exportName: string,\n kind: ReactSymbolKind,\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n visited: Set<string>,\n): string | undefined {\n const visitKey = `${fileAnalysis.filePath}:${exportName}:${kind}`\n if (visited.has(visitKey)) {\n return undefined\n }\n\n visited.add(visitKey)\n\n const directTargetId = fileAnalysis.exportsByName.get(exportName)\n if (directTargetId !== undefined) {\n const directTargetSymbol = fileAnalysis.symbolsById.get(directTargetId)\n if (directTargetSymbol?.kind === kind) {\n return directTargetId\n }\n }\n\n const reExportBinding = fileAnalysis.reExportBindingsByName.get(exportName)\n if (reExportBinding?.sourcePath !== undefined) {\n const reExportSourceAnalysis = fileAnalyses.get(reExportBinding.sourcePath)\n if (reExportSourceAnalysis !== undefined) {\n const reExportTargetId = resolveExportedSymbol(\n reExportSourceAnalysis,\n reExportBinding.importedName,\n kind,\n fileAnalyses,\n visited,\n )\n if (reExportTargetId !== undefined) {\n return reExportTargetId\n }\n }\n }\n\n for (const exportAllBinding of fileAnalysis.exportAllBindings) {\n if (exportAllBinding.sourcePath === undefined) {\n continue\n }\n\n const exportAllSourceAnalysis = fileAnalyses.get(\n exportAllBinding.sourcePath,\n )\n if (exportAllSourceAnalysis === undefined) {\n continue\n }\n\n const exportAllTargetId = resolveExportedSymbol(\n exportAllSourceAnalysis,\n exportName,\n kind,\n fileAnalyses,\n visited,\n )\n if (exportAllTargetId !== undefined) {\n return exportAllTargetId\n }\n }\n\n return undefined\n}\n\nexport function addExternalHookNodes(\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n fileAnalysis.importsByLocalName.forEach((binding, localName) => {\n if (binding.sourcePath !== undefined) {\n return\n }\n\n if (!isHookName(localName) && !isHookName(binding.importedName)) {\n return\n }\n\n const externalNode = createExternalHookNode(binding, localName)\n if (!nodes.has(externalNode.id)) {\n nodes.set(externalNode.id, externalNode)\n }\n })\n }\n}\n\nexport function addBuiltinNodes(\n fileAnalyses: ReadonlyMap<string, FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n fileAnalysis.entryUsages.forEach((entry) => {\n if (entry.kind !== 'builtin') {\n return\n }\n\n const builtinNode = createBuiltinNode(entry.referenceName)\n if (!nodes.has(builtinNode.id)) {\n nodes.set(builtinNode.id, builtinNode)\n }\n })\n\n fileAnalysis.symbolsById.forEach((symbol) => {\n symbol.builtinReferences.forEach((name) => {\n const builtinNode = createBuiltinNode(name)\n if (!nodes.has(builtinNode.id)) {\n nodes.set(builtinNode.id, builtinNode)\n }\n })\n })\n }\n}\n\nfunction createExternalHookNode(\n binding: ImportBinding,\n localName: string,\n): ReactUsageNode {\n const name = getExternalHookName(binding, localName)\n\n return {\n id: getExternalHookNodeId(binding, localName),\n name,\n kind: 'hook',\n filePath: binding.sourceSpecifier,\n exportNames: [binding.importedName],\n usages: [],\n }\n}\n\nfunction createBuiltinNode(name: string): ReactUsageNode {\n return {\n id: getBuiltinNodeId(name),\n name,\n kind: 'builtin',\n filePath: 'html',\n exportNames: [],\n usages: [],\n }\n}\n\nfunction getExternalHookNodeId(\n binding: ImportBinding,\n localName: string,\n): string {\n return `external:${binding.sourceSpecifier}#hook:${getExternalHookName(binding, localName)}`\n}\n\nexport function getBuiltinNodeId(name: string): string {\n return `builtin:${name}`\n}\n\nfunction getExternalHookName(\n binding: ImportBinding,\n localName: string,\n): string {\n return binding.importedName === 'default' ? localName : binding.importedName\n}\n\nexport function compareReactNodeIds(\n leftId: string,\n rightId: string,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n): number {\n const left = nodes.get(leftId)\n const right = nodes.get(rightId)\n\n if (left === undefined || right === undefined) {\n return leftId.localeCompare(rightId)\n }\n\n return compareReactNodes(left, right)\n}\n\nexport function compareReactUsageEntries(\n left: ReactUsageEntry,\n right: ReactUsageEntry,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n): number {\n return (\n left.location.filePath.localeCompare(right.location.filePath) ||\n left.location.line - right.location.line ||\n left.location.column - right.location.column ||\n left.referenceName.localeCompare(right.referenceName) ||\n compareReactNodeIds(left.target, right.target, nodes)\n )\n}\n\nfunction compareReactNodes(\n left: ReactUsageNode,\n right: ReactUsageNode,\n): number {\n return (\n left.filePath.localeCompare(right.filePath) ||\n left.name.localeCompare(right.name) ||\n left.kind.localeCompare(right.kind)\n )\n}\n","import fs from 'node:fs'\n\nimport { parseSync } from 'oxc-parser'\n\nimport type { AnalyzeOptions } from '../../types/analyze-options.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport { isSourceCodeFile } from '../../utils/is-source-code-file.js'\nimport { BaseAnalyzer } from '../base.js'\nimport { analyzeDependencies } from '../import/index.js'\nimport { analyzeReactFile } from './file.js'\nimport {\n addBuiltinNodes,\n addExternalHookNodes,\n compareReactNodeIds,\n compareReactUsageEntries,\n getBuiltinNodeId,\n resolveReactReference,\n} from './references.js'\n\nexport function analyzeReactUsage(\n entryFile: string,\n options: AnalyzeOptions = {},\n): ReactUsageGraph {\n return new ReactAnalyzer(entryFile, options).analyze()\n}\n\nclass ReactAnalyzer extends BaseAnalyzer<ReactUsageGraph> {\n protected doAnalyze(): ReactUsageGraph {\n const dependencyGraph = analyzeDependencies(this.entryFile, this.options)\n const fileAnalyses = this.collectFileAnalyses(dependencyGraph)\n const nodes = this.createNodes(fileAnalyses)\n this.attachUsages(fileAnalyses, nodes)\n const entries = this.collectEntries(fileAnalyses, nodes)\n\n return {\n cwd: dependencyGraph.cwd,\n entryId: dependencyGraph.entryId,\n nodes,\n entries,\n }\n }\n\n private collectFileAnalyses(\n dependencyGraph: DependencyGraph,\n ): Map<string, import('./file.js').FileAnalysis> {\n const reachableFiles = new Set<string>([\n dependencyGraph.entryId,\n ...dependencyGraph.nodes.keys(),\n ])\n const fileAnalyses = new Map<string, import('./file.js').FileAnalysis>()\n\n for (const filePath of [...reachableFiles].sort()) {\n if (!isSourceCodeFile(filePath) || filePath.endsWith('.d.ts')) {\n continue\n }\n\n const sourceText = fs.readFileSync(filePath, 'utf8')\n const parseResult = parseSync(filePath, sourceText, {\n astType: 'ts',\n sourceType: 'unambiguous',\n })\n\n const dependencyNode = dependencyGraph.nodes.get(filePath)\n const sourceDependencies = new Map<string, string>()\n dependencyNode?.dependencies.forEach((dependency) => {\n if (dependency.kind === 'source') {\n sourceDependencies.set(dependency.specifier, dependency.target)\n }\n })\n\n fileAnalyses.set(\n filePath,\n analyzeReactFile(\n parseResult.program,\n filePath,\n sourceText,\n filePath === dependencyGraph.entryId,\n sourceDependencies,\n this.options.includeBuiltins === true,\n ),\n )\n }\n\n return fileAnalyses\n }\n\n private createNodes(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n ): Map<string, ReactUsageNode> {\n const nodes = new Map<string, ReactUsageNode>()\n\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const symbol of fileAnalysis.symbolsById.values()) {\n nodes.set(symbol.id, {\n id: symbol.id,\n name: symbol.name,\n kind: symbol.kind,\n filePath: symbol.filePath,\n exportNames: [...symbol.exportNames].sort(),\n usages: [],\n })\n }\n }\n\n addExternalHookNodes(fileAnalyses, nodes)\n if (this.options.includeBuiltins === true) {\n addBuiltinNodes(fileAnalyses, nodes)\n }\n return nodes\n }\n\n private attachUsages(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n nodes: Map<string, ReactUsageNode>,\n ): void {\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const symbol of fileAnalysis.symbolsById.values()) {\n const usages = new Map<string, ReactUsageEdge>()\n\n symbol.componentReferences.forEach((referenceName) => {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n referenceName,\n 'component',\n )\n if (targetId !== undefined && targetId !== symbol.id) {\n usages.set(`render:${targetId}:${referenceName}`, {\n kind: 'render',\n target: targetId,\n referenceName,\n })\n }\n })\n\n symbol.hookReferences.forEach((referenceName) => {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n referenceName,\n 'hook',\n )\n if (targetId !== undefined && targetId !== symbol.id) {\n usages.set(`hook:${targetId}:${referenceName}`, {\n kind: 'hook-call',\n target: targetId,\n referenceName,\n })\n }\n })\n\n if (this.options.includeBuiltins === true) {\n symbol.builtinReferences.forEach((referenceName) => {\n const targetId = getBuiltinNodeId(referenceName)\n usages.set(`render:${targetId}:${referenceName}`, {\n kind: 'render',\n target: targetId,\n referenceName,\n })\n })\n }\n\n const node = nodes.get(symbol.id)\n if (node === undefined) {\n continue\n }\n\n const sortedUsages = [...usages.values()].sort((left, right) =>\n compareReactNodeIds(left.target, right.target, nodes),\n )\n\n nodes.set(symbol.id, {\n ...node,\n usages: sortedUsages,\n })\n }\n }\n }\n\n private collectEntries(\n fileAnalyses: ReadonlyMap<string, import('./file.js').FileAnalysis>,\n nodes: ReadonlyMap<string, ReactUsageNode>,\n ): ReactUsageEntry[] {\n const entriesByKey = new Map<string, ReactUsageEntry>()\n\n for (const fileAnalysis of fileAnalyses.values()) {\n for (const entry of fileAnalysis.entryUsages) {\n const targetId = resolveReactReference(\n fileAnalysis,\n fileAnalyses,\n entry.referenceName,\n entry.kind,\n )\n if (targetId === undefined) {\n continue\n }\n\n const key = `${entry.location.filePath}:${entry.location.line}:${entry.location.column}:${targetId}`\n entriesByKey.set(key, {\n target: targetId,\n referenceName: entry.referenceName,\n location: entry.location,\n })\n }\n }\n\n return [...entriesByKey.values()].sort((left, right) =>\n compareReactUsageEntries(left, right, nodes),\n )\n }\n}\n","import type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageFilter } from '../../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport { compareReactNodeIds } from './references.js'\n\nexport function getReactUsageEntries(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): ReactUsageEntry[] {\n return graph.entries.filter((entry) => {\n const targetNode = graph.nodes.get(entry.target)\n return targetNode !== undefined && matchesReactFilter(targetNode, filter)\n })\n}\n\nexport function getReactUsageRoots(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): string[] {\n const entries = getReactUsageEntries(graph, filter)\n if (entries.length > 0) {\n return [...new Set(entries.map((entry) => entry.target))]\n }\n\n const filteredNodes = getFilteredReactUsageNodes(graph, filter)\n const inboundCounts = new Map<string, number>()\n\n filteredNodes.forEach((node) => {\n inboundCounts.set(node.id, 0)\n })\n\n filteredNodes.forEach((node) => {\n getFilteredUsages(node, graph, filter).forEach((usage) => {\n inboundCounts.set(\n usage.target,\n (inboundCounts.get(usage.target) ?? 0) + 1,\n )\n })\n })\n\n const roots = filteredNodes\n .filter((node) => (inboundCounts.get(node.id) ?? 0) === 0)\n .map((node) => node.id)\n\n if (roots.length > 0) {\n return roots.sort((left, right) =>\n compareReactNodeIds(left, right, graph.nodes),\n )\n }\n\n return filteredNodes\n .map((node) => node.id)\n .sort((left, right) => compareReactNodeIds(left, right, graph.nodes))\n}\n\nexport function getFilteredUsages(\n node: ReactUsageNode,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter = 'all',\n): ReactUsageEdge[] {\n return node.usages.filter((usage) => {\n const targetNode = graph.nodes.get(usage.target)\n return targetNode !== undefined && matchesReactFilter(targetNode, filter)\n })\n}\n\nfunction getFilteredReactUsageNodes(\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n): ReactUsageNode[] {\n return [...graph.nodes.values()]\n .filter((node) => matchesReactFilter(node, filter))\n .sort((left, right) => {\n return (\n left.filePath.localeCompare(right.filePath) ||\n left.name.localeCompare(right.name) ||\n left.kind.localeCompare(right.kind)\n )\n })\n}\n\nfunction matchesReactFilter(\n node: ReactUsageNode,\n filter: ReactUsageFilter,\n): boolean {\n return filter === 'all' || node.kind === filter\n}\n","import process from 'node:process'\n\nimport type { ColorMode } from './types/color-mode.js'\nimport type { ReactSymbolKind } from './types/react-symbol-kind.js'\n\nconst ANSI_RESET = '\\u001B[0m'\nconst ANSI_COMPONENT = '\\u001B[36m'\nconst ANSI_HOOK = '\\u001B[35m'\nconst ANSI_BUILTIN = '\\u001B[34m'\nconst ANSI_MUTED = '\\u001B[38;5;244m'\nconst ANSI_UNUSED = '\\u001B[38;5;214m'\n\ninterface ResolveColorSupportOptions {\n readonly forceColor?: string | undefined\n readonly isTTY?: boolean | undefined\n readonly noColor?: string | undefined\n}\n\nexport function resolveColorSupport(\n mode: ColorMode = 'auto',\n options: ResolveColorSupportOptions = {},\n): boolean {\n if (mode === true) {\n return true\n }\n\n if (mode === false) {\n return false\n }\n\n const forceColor =\n 'forceColor' in options ? options.forceColor : process.env.FORCE_COLOR\n if (forceColor !== undefined) {\n return forceColor !== '0'\n }\n\n const noColor = 'noColor' in options ? options.noColor : process.env.NO_COLOR\n if (noColor !== undefined) {\n return false\n }\n\n const isTTY = 'isTTY' in options ? options.isTTY : process.stdout.isTTY\n return isTTY === true\n}\n\nexport function colorizeUnusedMarker(text: string, enabled: boolean): string {\n if (!enabled) {\n return text\n }\n\n return text.replaceAll('(unused)', `${ANSI_UNUSED}(unused)${ANSI_RESET}`)\n}\n\nexport function formatReactSymbolLabel(\n name: string,\n kind: ReactSymbolKind,\n enabled: boolean,\n): string {\n const label = `${formatReactSymbolName(name, kind)} [${kind}]`\n if (!enabled) {\n return label\n }\n\n return `${getReactSymbolColor(kind)}${label}${ANSI_RESET}`\n}\n\nexport function formatReactSymbolName(\n name: string,\n kind: ReactSymbolKind,\n): string {\n if (kind === 'component') {\n return `<${name} />`\n }\n\n if (kind === 'hook') {\n return `${name}()`\n }\n\n return `<${name}>`\n}\nexport function colorizeReactLabel(\n text: string,\n kind: ReactSymbolKind,\n enabled: boolean,\n): string {\n if (!enabled) {\n return text\n }\n\n return `${getReactSymbolColor(kind)}${text}${ANSI_RESET}`\n}\n\nexport function colorizeMuted(text: string, enabled: boolean): string {\n if (!enabled) {\n return text\n }\n\n return `${ANSI_MUTED}${text}${ANSI_RESET}`\n}\n\nfunction getReactSymbolColor(kind: ReactSymbolKind): string {\n if (kind === 'component') {\n return ANSI_COMPONENT\n }\n\n if (kind === 'hook') {\n return ANSI_HOOK\n }\n\n return ANSI_BUILTIN\n}\n","import path from 'node:path'\n\nexport function toDisplayPath(filePath: string, cwd: string): string {\n const relativePath = path.relative(cwd, filePath)\n if (relativePath === '') {\n return '.'\n }\n\n const normalizedPath = relativePath.split(path.sep).join('/')\n return normalizedPath.startsWith('..') ? filePath : normalizedPath\n}\n","import { colorizeUnusedMarker, resolveColorSupport } from '../../color.js'\nimport type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport type { PrintTreeOptions } from '../../types/print-tree-options.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function printDependencyTree(\n graph: DependencyGraph,\n options: PrintTreeOptions = {},\n): string {\n const cwd = options.cwd ?? graph.cwd\n const color = resolveColorSupport(options.color)\n const includeExternals = options.includeExternals ?? false\n const omitUnused = options.omitUnused ?? false\n const rootLines = [toDisplayPath(graph.entryId, cwd)]\n const visited = new Set<string>([graph.entryId])\n const entryNode = graph.nodes.get(graph.entryId)\n\n if (entryNode === undefined) {\n return rootLines.join('\\n')\n }\n\n const rootDependencies = filterDependencies(\n entryNode.dependencies,\n includeExternals,\n omitUnused,\n )\n\n rootDependencies.forEach((dependency, index) => {\n rootLines.push(\n ...renderDependency(\n dependency,\n graph,\n visited,\n '',\n index === rootDependencies.length - 1,\n includeExternals,\n omitUnused,\n color,\n cwd,\n ),\n )\n })\n\n return rootLines.join('\\n')\n}\n\nfunction renderDependency(\n dependency: DependencyEdge,\n graph: DependencyGraph,\n visited: ReadonlySet<string>,\n prefix: string,\n isLast: boolean,\n includeExternals: boolean,\n omitUnused: boolean,\n color: boolean,\n cwd: string,\n): string[] {\n const branch = `${prefix}${isLast ? '└─ ' : '├─ '}`\n const label = formatDependencyLabel(dependency, cwd, color)\n\n if (dependency.kind !== 'source') {\n return [`${branch}${label}`]\n }\n\n if (visited.has(dependency.target)) {\n return [`${branch}${label} (circular)`]\n }\n\n const childNode = graph.nodes.get(dependency.target)\n if (childNode === undefined) {\n return [`${branch}${label}`]\n }\n\n const nextPrefix = `${prefix}${isLast ? ' ' : '│ '}`\n const nextVisited = new Set(visited)\n nextVisited.add(dependency.target)\n\n const childLines = [`${branch}${label}`]\n const childDependencies = filterDependencies(\n childNode.dependencies,\n includeExternals,\n omitUnused,\n )\n\n childDependencies.forEach((childDependency, index) => {\n childLines.push(\n ...renderDependency(\n childDependency,\n graph,\n nextVisited,\n nextPrefix,\n index === childDependencies.length - 1,\n includeExternals,\n omitUnused,\n color,\n cwd,\n ),\n )\n })\n\n return childLines\n}\n\nfunction filterDependencies(\n dependencies: readonly DependencyEdge[],\n includeExternals: boolean,\n omitUnused: boolean,\n): DependencyEdge[] {\n return dependencies.filter((dependency) => {\n if (omitUnused && dependency.unused) {\n return false\n }\n\n if (\n dependency.kind === 'source' ||\n dependency.kind === 'missing' ||\n dependency.kind === 'boundary'\n ) {\n return true\n }\n\n return includeExternals\n })\n}\n\nfunction formatDependencyLabel(\n dependency: DependencyEdge,\n cwd: string,\n color: boolean,\n): string {\n const prefixes: string[] = []\n if (dependency.isTypeOnly) {\n prefixes.push('type')\n }\n\n if (dependency.referenceKind === 'require') {\n prefixes.push('require')\n } else if (dependency.referenceKind === 'dynamic-import') {\n prefixes.push('dynamic')\n } else if (dependency.referenceKind === 'export') {\n prefixes.push('re-export')\n } else if (dependency.referenceKind === 'import-equals') {\n prefixes.push('import=')\n }\n\n const annotation = prefixes.length > 0 ? `[${prefixes.join(', ')}] ` : ''\n\n if (dependency.kind === 'source') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${toDisplayPath(dependency.target, cwd)}`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'missing') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.specifier} [missing]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'boundary') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${toDisplayPath(dependency.target, cwd)} [${\n dependency.boundary === 'project'\n ? 'project boundary'\n : 'workspace boundary'\n }]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n if (dependency.kind === 'builtin') {\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.target} [builtin]`,\n dependency.unused,\n ),\n color,\n )\n }\n\n return colorizeUnusedMarker(\n withUnusedSuffix(\n `${annotation}${dependency.target} [external]`,\n dependency.unused,\n ),\n color,\n )\n}\n\nfunction withUnusedSuffix(label: string, unused: boolean): string {\n return unused ? `${label} (unused)` : label\n}\n","import {\n getFilteredUsages,\n getReactUsageEntries,\n getReactUsageRoots,\n} from '../../analyzers/react/queries.js'\nimport {\n colorizeMuted,\n colorizeReactLabel,\n formatReactSymbolLabel,\n formatReactSymbolName,\n resolveColorSupport,\n} from '../../color.js'\nimport type { PrintReactTreeOptions } from '../../types/print-react-tree-options.js'\nimport type { ReactUsageEdge } from '../../types/react-usage-edge.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport type { ReactUsageNode } from '../../types/react-usage-node.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function printReactUsageTree(\n graph: ReactUsageGraph,\n options: PrintReactTreeOptions = {},\n): string {\n const cwd = options.cwd ?? graph.cwd\n const color = resolveColorSupport(options.color)\n const filter = options.filter ?? 'all'\n const entries = getReactUsageEntries(graph, filter)\n\n if (entries.length > 0) {\n return renderReactUsageEntries(graph, entries, cwd, filter, color)\n }\n\n const roots = getReactUsageRoots(graph, filter)\n if (roots.length === 0) {\n return 'No React symbols found.'\n }\n\n const lines: string[] = []\n roots.forEach((rootId, index) => {\n const root = graph.nodes.get(rootId)\n if (root === undefined) {\n return\n }\n\n lines.push(formatReactNodeLabel(root, cwd, color))\n const usages = getFilteredUsages(root, graph, filter)\n usages.forEach((usage, usageIndex) => {\n lines.push(\n ...renderUsage(\n usage,\n graph,\n cwd,\n filter,\n color,\n new Set([root.id]),\n '',\n usageIndex === usages.length - 1,\n ),\n )\n })\n\n if (index < roots.length - 1) {\n lines.push('')\n }\n })\n\n return lines.join('\\n')\n}\n\nfunction renderReactUsageEntries(\n graph: ReactUsageGraph,\n entries: readonly ReactUsageEntry[],\n cwd: string,\n filter: NonNullable<PrintReactTreeOptions['filter']>,\n color: boolean,\n): string {\n const lines: string[] = []\n\n entries.forEach((entry, index) => {\n const root = graph.nodes.get(entry.target)\n if (root === undefined) {\n return\n }\n\n lines.push(formatReactEntryLabel(entry, cwd))\n lines.push(formatReactNodeLabel(root, cwd, color, entry.referenceName))\n\n const usages = getFilteredUsages(root, graph, filter)\n usages.forEach((usage, usageIndex) => {\n lines.push(\n ...renderUsage(\n usage,\n graph,\n cwd,\n filter,\n color,\n new Set([root.id]),\n '',\n usageIndex === usages.length - 1,\n ),\n )\n })\n\n if (index < entries.length - 1) {\n lines.push('')\n }\n })\n\n return lines.join('\\n')\n}\n\nfunction renderUsage(\n usage: ReactUsageEdge,\n graph: ReactUsageGraph,\n cwd: string,\n filter: NonNullable<PrintReactTreeOptions['filter']>,\n color: boolean,\n visited: ReadonlySet<string>,\n prefix: string,\n isLast: boolean,\n): string[] {\n const branch = `${prefix}${isLast ? '└─ ' : '├─ '}`\n const target = graph.nodes.get(usage.target)\n\n if (target === undefined) {\n return [`${branch}${usage.target}`]\n }\n\n if (visited.has(target.id)) {\n return [\n `${branch}${formatReactNodeLabel(target, cwd, color, usage.referenceName)} (circular)`,\n ]\n }\n\n const childLines = [\n `${branch}${formatReactNodeLabel(target, cwd, color, usage.referenceName)}`,\n ]\n const nextVisited = new Set(visited)\n nextVisited.add(target.id)\n const nextPrefix = `${prefix}${isLast ? ' ' : '│ '}`\n const childUsages = getFilteredUsages(target, graph, filter)\n\n childUsages.forEach((childUsage, index) => {\n childLines.push(\n ...renderUsage(\n childUsage,\n graph,\n cwd,\n filter,\n color,\n nextVisited,\n nextPrefix,\n index === childUsages.length - 1,\n ),\n )\n })\n\n return childLines\n}\n\nfunction formatReactNodeLabel(\n node: ReactUsageNode,\n cwd: string,\n color: boolean,\n referenceName?: string,\n): string {\n const hasAlias = referenceName !== undefined && referenceName !== node.name\n const label = hasAlias\n ? `${colorizeReactLabel(formatReactSymbolName(node.name, node.kind), node.kind, color)} ${colorizeMuted(\n `as ${referenceName}`,\n color,\n )} ${colorizeReactLabel(`[${node.kind}]`, node.kind, color)}`\n : formatReactSymbolLabel(node.name, node.kind, color)\n\n return `${label} (${formatReactNodeFilePath(node, cwd)})`\n}\n\nfunction formatReactEntryLabel(entry: ReactUsageEntry, cwd: string): string {\n return `${toDisplayPath(entry.location.filePath, cwd)}:${entry.location.line}:${entry.location.column}`\n}\n\nfunction formatReactNodeFilePath(node: ReactUsageNode, cwd: string): string {\n return node.kind === 'builtin' ? 'html' : toDisplayPath(node.filePath, cwd)\n}\n","import type { DependencyEdge } from '../../types/dependency-edge.js'\nimport type { DependencyGraph } from '../../types/dependency-graph.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\nexport function graphToSerializableTree(\n graph: DependencyGraph,\n options: {\n readonly omitUnused?: boolean\n } = {},\n): object {\n const visited = new Set<string>()\n return serializeNode(\n graph.entryId,\n graph,\n visited,\n options.omitUnused ?? false,\n )\n}\n\nfunction serializeNode(\n filePath: string,\n graph: DependencyGraph,\n visited: Set<string>,\n omitUnused: boolean,\n): object {\n const node = graph.nodes.get(filePath)\n const displayPath = toDisplayPath(filePath, graph.cwd)\n\n if (node === undefined) {\n return {\n path: displayPath,\n kind: 'missing',\n dependencies: [],\n }\n }\n\n if (visited.has(filePath)) {\n return {\n path: displayPath,\n kind: 'circular',\n dependencies: [],\n }\n }\n\n visited.add(filePath)\n\n const dependencies = node.dependencies\n .filter((dependency) => !omitUnused || !dependency.unused)\n .map((dependency) => {\n if (dependency.kind !== 'source') {\n return {\n specifier: dependency.specifier,\n referenceKind: dependency.referenceKind,\n isTypeOnly: dependency.isTypeOnly,\n unused: dependency.unused,\n kind: dependency.kind,\n ...(dependency.boundary === undefined\n ? {}\n : { boundary: dependency.boundary }),\n target: serializeDependencyTarget(dependency, graph.cwd),\n }\n }\n\n return {\n specifier: dependency.specifier,\n referenceKind: dependency.referenceKind,\n isTypeOnly: dependency.isTypeOnly,\n unused: dependency.unused,\n kind: dependency.kind,\n target: toDisplayPath(dependency.target, graph.cwd),\n node: serializeNode(\n dependency.target,\n graph,\n new Set(visited),\n omitUnused,\n ),\n }\n })\n\n return {\n path: displayPath,\n kind: filePath === graph.entryId ? 'entry' : 'source',\n dependencies,\n }\n}\n\nfunction serializeDependencyTarget(\n dependency: DependencyEdge,\n cwd: string,\n): string {\n if (dependency.kind === 'missing' || dependency.kind === 'external') {\n return dependency.target\n }\n\n if (dependency.kind === 'builtin') {\n return dependency.target\n }\n\n return toDisplayPath(dependency.target, cwd)\n}\n","import {\n getFilteredUsages,\n getReactUsageEntries,\n getReactUsageRoots,\n} from '../../analyzers/react/queries.js'\nimport type { ReactUsageEntry } from '../../types/react-usage-entry.js'\nimport type { ReactUsageFilter } from '../../types/react-usage-filter.js'\nimport type { ReactUsageGraph } from '../../types/react-usage-graph.js'\nimport { toDisplayPath } from '../../utils/to-display-path.js'\n\ninterface SerializedReactUsageNode {\n readonly id: string\n readonly name: string\n readonly symbolKind:\n | import('../../types/react-symbol-kind.js').ReactSymbolKind\n | 'circular'\n readonly filePath: string\n readonly exportNames: readonly string[]\n readonly usages: readonly SerializedReactUsageEdge[]\n}\n\ninterface SerializedReactUsageEntry {\n readonly targetId: string\n readonly referenceName: string\n readonly filePath: string\n readonly line: number\n readonly column: number\n readonly node: SerializedReactUsageNode\n}\n\ninterface SerializedReactUsageEdge {\n readonly kind: import('../../types/react-usage-edge.js').ReactUsageEdge['kind']\n readonly targetId: string\n readonly referenceName: string\n readonly node: SerializedReactUsageNode\n}\n\nexport function graphToSerializableReactTree(\n graph: ReactUsageGraph,\n options: {\n readonly filter?: ReactUsageFilter\n } = {},\n): object {\n const filter = options.filter ?? 'all'\n const entries = getReactUsageEntries(graph, filter)\n const roots =\n entries.length > 0\n ? entries.map((entry) =>\n serializeReactUsageNode(entry.target, graph, filter, new Set()),\n )\n : getReactUsageRoots(graph, filter).map((rootId) =>\n serializeReactUsageNode(rootId, graph, filter, new Set()),\n )\n\n return {\n kind: 'react-usage',\n entries: entries.map((entry) =>\n serializeReactUsageEntry(entry, graph, filter),\n ),\n roots,\n }\n}\n\nfunction serializeReactUsageNode(\n nodeId: string,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n visited: Set<string>,\n): SerializedReactUsageNode {\n const node = graph.nodes.get(nodeId)\n if (node === undefined) {\n return {\n id: nodeId,\n name: nodeId,\n symbolKind: 'circular',\n filePath: '',\n exportNames: [],\n usages: [],\n }\n }\n\n if (visited.has(nodeId)) {\n return {\n id: node.id,\n name: node.name,\n symbolKind: 'circular',\n filePath: formatReactNodeFilePath(node.filePath, node.kind, graph.cwd),\n exportNames: node.exportNames,\n usages: [],\n }\n }\n\n const nextVisited = new Set(visited)\n nextVisited.add(nodeId)\n\n return {\n id: node.id,\n name: node.name,\n symbolKind: node.kind,\n filePath: formatReactNodeFilePath(node.filePath, node.kind, graph.cwd),\n exportNames: node.exportNames,\n usages: getFilteredUsages(node, graph, filter).map((usage) => ({\n kind: usage.kind,\n targetId: usage.target,\n referenceName: usage.referenceName,\n node: serializeReactUsageNode(usage.target, graph, filter, nextVisited),\n })),\n }\n}\n\nfunction serializeReactUsageEntry(\n entry: ReactUsageEntry,\n graph: ReactUsageGraph,\n filter: ReactUsageFilter,\n): SerializedReactUsageEntry {\n return {\n targetId: entry.target,\n referenceName: entry.referenceName,\n filePath: toDisplayPath(entry.location.filePath, graph.cwd),\n line: entry.location.line,\n column: entry.location.column,\n node: serializeReactUsageNode(entry.target, graph, filter, new Set()),\n }\n}\n\nfunction formatReactNodeFilePath(\n filePath: string,\n kind: import('../../types/react-symbol-kind.js').ReactSymbolKind,\n cwd: string,\n): string {\n return kind === 'builtin' ? 'html' : toDisplayPath(filePath, cwd)\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,oBACd,YACA,oBACc;CACd,MAAM,aACJ,uBAAuB,KAAA,IACnB,kBAAkB,WAAW,GAC7B,KAAK,QAAQ,YAAY,mBAAmB;AAElD,KAAI,eAAe,KAAA,EACjB,QAAO,EACL,iBAAiB,wBAAwB,EAC1C;CAGH,MAAM,aAAa,GAAG,eAAe,YAAY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