import type { Deep, Documented, Help, Taken } from '@variance-authority/package/help'; import type { PathGroup } from '../store-rows.js'; /** * Names imported by the path of a file, or through an entry no file was read * for, rather than through an entry the reading opened. * * Three kinds, and they read differently. An import past every specifier a * package declares is deep: the package says what it opens and the importer * names a file behind it. A package that declares no entry has nothing to be * past, so every import of it names a file and none of them is deep. An import * of a specifier the manifest declares, which this reading could not follow to * a source file, names the entry exactly and is not deep either: the names it * takes are known, the file that declares them is not. All three are the only * record of what is used, so all three answer `uses` and `symbol`; the words * say which kind each site is. */ /** How an import names what it takes, when no entry the reading opened carries it. */ export type PathKind = PathGroup; /** One name one import takes by path. */ export interface PathSite { readonly held: Deep; readonly taken: Taken; readonly kind: PathKind; /** The package the specifier names. */ readonly owner: string; } /** What a package whose declared entry leads to no source file is told about it. */ export declare const UNFOLLOWED = "this reading could not follow to a source file, such as a build output the checkout does not hold"; /** The package a specifier names. */ export declare function ownerOf(specifier: string): string; /** Every import by path, deep ones first, narrowed to a package or a specifier when one is given. */ export declare function importsByPath(help: Help, within?: string): readonly (readonly [Deep, PathKind])[]; /** Every place `name` is taken by path. */ export declare function sitesByPath(help: Help, name: string, within?: string): readonly PathSite[]; /** How a site names what it imports, as a suffix to ``. */ export declare function how(site: Pick): string; /** * Whether a published package declares an entry its reading opened nothing of: * its manifest declares one, as {@link Documented.entry} records, and no file of it was read. */ export declare function unfollowedEntry(published: Documented): boolean; /** * The imports of an entry `owner` declares that this reading could not follow, * in specifier, file and line order. A package's own imports of itself are left out. */ export declare function unfollowedOf(help: Help, owner: string): readonly Deep[]; /** * What other packages import by path from each package that declares no entry, * grouped by that package in one walk. A package's own imports of itself are * not what it is imported for, and are left out. */ export declare function takenByPath(help: Help): ReadonlyMap; /** * The names and files `imports` take: a name counted once per file that exports * it, a file once. A module held whole is not a name, as {@link isName} says. */ export declare function tally(imports: readonly Deep[]): { readonly names: number; readonly files: number; }; /** One file other packages import by path, as a package's name answers for it. */ export interface FileTaken { /** The specifiers the file is imported as, the one the most files write first, ties in code-unit order. */ readonly specifiers: readonly string[]; /** Distinct names taken from the file. */ readonly names: number; /** Distinct files that import it. */ readonly importers: number; /** * The name the most files take through the first specifier, ties in * code-unit order, for the narrower question about one name; none when every * import takes the whole module. */ readonly name?: string; } /** * `imports` counted per file they reach, the file the most files import first, * then the one with the most names, then in code-unit order of its first * specifier. One row per file, however many sites import it: asking for one * specifier counts them per name, and `uses` lists the sites of one name. */ export declare function perFile(imports: readonly Deep[]): readonly FileTaken[]; /** The imports written as one specifier, counted per name as asking for that specifier answers for them. */ export interface ByName { /** Distinct names taken, the whole module not among them. */ readonly names: number; /** One row per name, and one for the whole module when an import takes no name. */ readonly lines: readonly string[]; /** The name the most files take, for the narrower question about its sites; none when no import takes a name. */ readonly first?: string; } /** * `imports` counted per name: each name with the number of files importing it, * the most first, ties in code-unit order. A side-effect import and a module * held whole take no name, and are counted on a row of their own after the * names it ties with. One row per name, however many sites take it: the sites * of one name are what `uses` lists. */ export declare function byName(imports: readonly Deep[]): ByName; /** `N names from M of its files`, counted. */ export declare function counted(surface: { readonly names: number; readonly files: number; }): string; /** * Every package other packages import by path, counted in one walk of the * imports: what is taken from each package that declares no entry, how many * imports reach past the entry of each package that declares one, and how many * name an entry this reading could not follow. Most taken first, then in * code-unit order. A package's own imports of itself are left out of every count. * * One walk, because the counts are per package and the imports are not. In a * repository whose packages declare no entry there are a hundred thousand * imports, and a walk of all of them per package is quadratic. */ export declare function countsByPath(help: Help): { readonly unentered: readonly (readonly [string, { readonly names: number; readonly files: number; }])[]; readonly deep: readonly (readonly [string, number])[]; readonly unfollowed: readonly (readonly [string, number])[]; }; /** What a package that declares an entry is told about the imports past it. */ export declare const REACHING = "Either the manifest has stopped describing what the package is used for, or something is reaching into its internals"; /** * The imports past the entry of `owner` from other packages, in specifier, * file and line order. With `specifier`, only the imports written as that specifier. */ export declare function reachingPast(help: Help, owner: string, specifier?: string): readonly Deep[]; /** A name a reader could ask `uses` about: not the whole module, not a side effect. */ export declare const isName: (name: string) => boolean; //# sourceMappingURL=by-path.d.ts.map