import type { AnalyserSystem } from './system/analyser-system.js'; import { AnalyserDiagnostic } from './analyser-diagnostic.js'; import type { AnalyserOptions } from './analyser-options.js'; import { ModuleNode } from './nodes/module-node.js'; import type { Module } from './models/module.js'; import ts from 'typescript'; /** * Represents a collection of modules * (TypeScript/JavaScript files) that have been * successfully analysed. */ export declare class Project { private _program; private _commandLine; private readonly _fileNames; private readonly _modules; private readonly _compilerHost; private readonly _context; private readonly _packageJson; private readonly _diagnostics; private readonly _system; private readonly _options; private constructor(); static fromTSConfig(system: AnalyserSystem, options?: Partial): Project; static fromFiles(system: AnalyserSystem, files: readonly string[], options?: Partial): Project; static fromSource(system: AnalyserSystem, source: string, options?: Partial): Project; /** * An abstraction layer around how we interact with the environment (browser or Node.js) * * @returns The system environment used */ getSystem(): AnalyserSystem; /** * A Program is an immutable collection of source files and the compiler options. Together * represent a compilation unit. * * @returns The TypeScript program created with the TypeScript compiler API */ getProgram(): ts.Program; /** * The TypeScript type checker. * * Useful to resolve the types and location of the reflected nodes. * * @returns The TypeScript type checker */ getTypeChecker(): ts.TypeChecker; /** * The user provided analyzer options. * * @returns The options that were provided when calling the parser function */ getOptions(): Partial; /** * Here we save all the errors we find while analysing the source files * * @returns An instance of the `AnalyserDiagnostic` where all errors are enqueue */ getDiagnostics(): AnalyserDiagnostic; /** * All the reflected modules/files that have been successfully analysed. * * @returns The reflected modules */ getModules(): ModuleNode[]; /** * Whether the given source file path is present in the reflected modules * * @param filePath - The source file path to check * @returns True if the source file has been already analysed, false otherwise */ has(filePath: string): boolean; /** * Adds a new source file to the collection of reflected modules. * * Will throw an error if the source file already exists in the program. * * @param filePath - The path of the new source file * @param content - The content of the source file * @returns The new reflected module */ add(filePath: string, content: string): ModuleNode; /** * Updates the content of an existing source file. * * Will throw an error if the source file doesn't exist in the program. * * @param filePath - The path of the source file to update * @param content - The new content of the source file * @returns The updated reflected module */ update(filePath: string, content: string): ModuleNode; /** * The name of the package defined in the `package.json` in * case one was found * * @returns The package name if found, otherwise an empty string */ getName(): string; /** * Serializes the project * * @returns The reflected node as a serializable object */ serialize(): Module[]; private _getPackageJSON; private _upsertFile; } //# sourceMappingURL=project.d.ts.map