@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
65 lines (64 loc) • 3.39 kB
TypeScript
import type { PackageSignatureSource } from './reader';
import type { VersionRelease } from './sigdb-version';
import type { LibraryExports } from './schema';
import type { ResolvedDependency } from './decode';
import { RVersion } from '../../util/r-version';
/**
* One package as {@link MemorySignatureSource} carries it: the exports are what attaching it brings, the rest
* is what the answers below need to stay honest. Everything but the name and the exports is optional, so a
* caller may ship no more than it has.
*/
export interface MemoryPackage {
readonly version?: string;
readonly exported: readonly string[];
readonly deprecated?: readonly string[];
readonly s3Classes?: readonly string[];
readonly s4Classes?: readonly string[];
readonly downloads?: number;
readonly deps?: readonly ResolvedDependency[];
/** when that version was released, which is what makes it a release rather than a label */
readonly released?: Date;
}
/**
* A signature source held entirely in memory, for the places that cannot open a database file: a browser
* (the playground bundles its packages rather than reading them) and a test that wants to state a package's
* exports outright. It answers what a package brings into scope; the per-function view a real database
* decodes from its blobs is not part of what it can say, so those answers stay empty.
* @see {@link SigDatabase} - the file-backed source
*/
export declare class MemorySignatureSource implements PackageSignatureSource {
private readonly packages;
/** reverse index `class -> owning package`, built on first use (see {@link classOwner}) */
private classIndex;
constructor(packages: Readonly<Record<string, MemoryPackage>> | ReadonlyMap<string, MemoryPackage>);
has(pkg: string): boolean;
hasVersion(pkg: string, version: string): boolean;
isCranVersion(pkg: string, version: string): boolean;
lookup(pkg: string, version?: string): LibraryExports | undefined;
packagesExporting(name: string): readonly string[];
classOwner(className: string, version?: string): string | undefined;
/** no blobs to decode, so the rich per-function view has nothing to give */
functions(): undefined;
functionByName(): undefined;
transitiveCallees(): undefined;
dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
packageNames(): string[];
isBaseR(pkg: string): boolean;
downloads(pkg: string): number;
/** the R releases a base package shipped with are a property of the database, which this source has none of */
coreVersions(): undefined;
releaseDate(pkg: string): Date | undefined;
releaseDates(pkg: string): VersionRelease[];
latestVersion(pkg: string): RVersion | undefined;
/** nothing is held open */
close(): void;
/** whether the package answers a lookup for `version`, which an unversioned one always does */
private answersFor;
private versionOf;
}
/**
* A {@link MemorySignatureSource} from what a page can carry: `package -> [version, release date, ...exports]`.
* The version is what the exports were read from, so recording it is what keeps a consumer from being told
* the package is unknown when only its history is.
*/
export declare function memorySourceOfPackages(packages: Readonly<Record<string, readonly string[]>>): MemorySignatureSource;