import { LinkedFileSystem } from "./linkedFileSystem.js"; import type { LayoutPackage, PnpmLayout } from "./pnpmLayout.js"; import type { CompilerBundle, TypeScript } from "./typescriptCompiler.js"; /** * adept's `/types//@`: a package version's * declaration files and every `package.json`, by path relative to the * package's root, and the names of its JavaScript files. */ export type TypesBundle = { files: Record; stubs: string[]; }; export type PackageRef = { name: string; version: string; integrity: string | null; }; /** * Where bundles and compilers come from. In the Studio that is adept, * through the Studio's server (`adeptSources.ts`); tests and Node scripts * give their own. */ export type TypecheckSources = { types(pkg: PackageRef): Promise; compiler(version: string): Promise; }; /** * A failed request for a bundle or a compiler, by what can be done about it. * `status` 401 means signed out, and stops the whole check: every other * request would fail the same way. */ export declare class SourceError extends Error { readonly code: string; readonly retryable: boolean; readonly status: number | null; constructor(message: string, code: string, retryable: boolean, status?: number | null); } /** A package whose types could not be had, so the check that follows is incomplete. */ export type MissingTypes = PackageRef & { code: string; message: string; retryable: boolean; }; export type AcquisitionStats = { /** Bundles fetched because an import or a type reference named them. */ scanned: number; /** Bundles fetched because TypeScript went looking in them while resolving. */ resolved: number; files: number; stubs: number; /** Characters of declaration text, about the bytes once unpacked. */ bytes: number; }; /** * The package a bare specifier names: `react` of `react/jsx-runtime`, * `@tanstack/react-router` of itself. `null` for anything that is not looked * up in `node_modules`: relative and absolute paths, `#subpath` imports and * `node:` and other schemes. */ export declare function packageNameOf(specifier: string): string | null; /** `@types/node` for `node`, `@types/scope__name` for `@scope/name`. */ export declare function typesPackageOf(name: string): string; /** The package directory a real path is in: up to the name after its last `node_modules`. */ export declare function packageDirOf(realPath: string): string | null; /** * Fetches the types a project's imports reach, and only those, and writes * each bundle at its snapshot's directory in the virtual store, so that the * layout's links make it visible wherever pnpm would. * * {@link wantImportsOf} scans a file's imports and type references; each * bare one is looked for as Node looks for it, from the file's directory up * through each `node_modules` (and its `@types` twin), and the nearest level * that has it is fetched. A fetched bundle's declaration files are scanned in * turn, so type dependencies are followed transitively. {@link wantPackage} * fetches a package by directory, for when TypeScript itself went looking in * one. */ export declare class TypeAcquisition { private readonly ts; private readonly fs; private readonly layout; private readonly sources; private readonly concurrency; private readonly started; private readonly running; private readonly queue; private fatal; readonly missing: MissingTypes[]; readonly stats: AcquisitionStats; constructor(ts: TypeScript, fs: LinkedFileSystem, layout: PnpmLayout, sources: TypecheckSources, concurrency?: number); /** Whether `dir` is a package this has fetched, or tried to. */ has(dir: string): boolean; /** The installed package at a real directory, if it is one. */ packageAt(dir: string): LayoutPackage | undefined; /** * The packages a bare name reaches from `fromDir`: at the nearest * `node_modules` that has the package or its `@types`, both. */ findPackages(fromDir: string, name: string): string[]; /** Wants what a bare specifier names, from a file in `fromDir`. */ wantSpecifier(fromDir: string, specifier: string): void; /** Wants every package a file's imports and type references reach. */ wantImportsOf(realPath: string, text: string): void; wantPackage(dir: string, via: "scanned" | "resolved"): void; private pump; /** Resolves when everything wanted so far, and everything that wanted, is fetched. */ settle(): Promise; private fetch; }