import { Project } from "ts-morph"; import type { ComponentEnvGraphOptions, FileNode } from "./types.js"; /** * Component environment type classification. * - 'client': Entry or dependency with "use client" directive * - 'server': Server-only component * - 'universal': Referenced from both client and server */ export type { ComponentEnvGraphOptions, ComponentType, FileNode, } from "./types.js"; /** * Builds and manages the dependency graph for a React Server Components (RSC) project. * UI components should use this class to retrieve file type information. */ export declare class ComponentEnvGraph { nodes: Map; project: Project; rootDir: string; private readonly excludePatterns; private readonly _onDidUpdate; /** * Creates a new DependencyGraph instance. * @param rootDir Project root directory * @param options Optional configuration options. */ constructor(rootDir: string, options?: ComponentEnvGraphOptions); /** * Rebuilds the dependency graph. If changedFiles is specified, only those files and their dependencies are re-parsed. * Otherwise, a full scan is performed. * @param changedFiles Array of changed file paths (if omitted, performs a full scan) */ build(changedFiles?: string[]): void; /** * Registers a listener for dependency graph update events. * @param listener Callback function to invoke when the graph updates */ onDidUpdate(listener: () => void): void; /** * Determines if the first statement in the file is a "use client" directive. * Only the first statement is checked, per the React specification. * @param sf ts-morph SourceFile * @returns true if the file is a client component */ private hasUseClientDirective; /** * Returns an array of absolute file paths statically imported or re-exported by the given file. * @param sf ts-morph SourceFile * @returns Array of imported/re-exported file paths */ private getStaticImports; /** * Emits an update event to all registered listeners. */ private fireDidUpdate; /** * Updates the ts-morph project with the latest source files. * @param changedFiles Optional array of specific files that have changed. * @returns A Set of file paths that were affected and need their nodes updated. */ private updateProjectSourceFiles; private refreshChangedFiles; /** * Returns whether the given absolute path matches any exclude glob (incremental updates). * - Source of truth: `excludePatterns` (DEFAULT_EXCLUDE + options.exclude) * - Normalizes both target path and patterns to POSIX form ("/" separators) * - Uses `dot: true` to match dot-prefixed paths like `.git/**` */ private readonly isGlobExcluded; private addAllSourceFiles; private removeDeletedFiles; private markAllFilesAsAffected; /** * Updates the internal `nodes` map for a given set of source files. * @param filesToUpdate A Set of file paths */ private updateFileNodes; } //# sourceMappingURL=index.d.ts.map