@nodesecure/js-x-ray
Version:
JavaScript AST XRay analysis
54 lines • 2.03 kB
TypeScript
import { DiGraph, type VertexBody, type VertexDefinition } from "digraph-js";
import { AstAnalyser, type ReportOnFile, type RuntimeOptions } from "./AstAnalyser.ts";
import { JsSourceParser, type SourceParser } from "./parsers/JsSourceParser.ts";
export type ReportOnEntryFile = ReportOnFile & {
file: string;
};
export interface EntryFilesAnalyserOptions {
/**
* An instance of `AstAnalyser` to use for analysing the entry files.
* If not provided, a default instance will be created with a `DefaultCollectableSet` for "dependency".
*/
astAnalyzer?: AstAnalyser;
/**
* A function that receives the default allowed extensions and
* returns a new array of extensions to allow when resolving internal dependencies.
*/
loadExtensions?: (defaults: string[]) => string[];
rootPath?: string | URL;
/**
* Whether to ignore ENOENT errors when analysing files.
* If set to `true`, files that do not exist will be skipped without throwing an error.
*
* @default false
*/
ignoreENOENT?: boolean;
/**
* A set of dependencies to ignore when resolving internal dependencies.
*
* @default []
*/
packageDependencies?: Iterable<string>;
}
export interface EntryFilesRuntimeOptions extends RuntimeOptions {
fileMetadata?: (file: string) => Record<string, unknown>;
}
export declare class EntryFilesAnalyser {
#private;
static Parsers: {
readonly js: JsSourceParser;
readonly ts: SourceParser;
};
astAnalyzer: AstAnalyser;
allowedExtensions: Set<string>;
dependencies: DiGraph<VertexDefinition<VertexBody>>;
ignoreENOENT: boolean;
stats: {
numberOfImportsDetected: number;
numberOfFilesProcessed: number;
};
uniqueImports: Set<string>;
constructor(options?: EntryFilesAnalyserOptions);
analyse(entryFiles: Iterable<string | URL>, options?: EntryFilesRuntimeOptions): AsyncGenerator<ReportOnEntryFile>;
}
//# sourceMappingURL=EntryFilesAnalyser.d.ts.map