UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

56 lines (55 loc) 3.01 kB
import { type Range } from 'semver'; import type { NamespaceInfo } from '../file-plugins/files/flowr-namespace-file'; export type PackageType = 'package' | 'system' | 'r'; /** what a source can contribute about a package; everything else a {@link Package} exposes is derived from these */ export type PackageOptions = { type?: PackageType; dependencies?: Package[]; namespaceInfo?: NamespaceInfo; /** what this source declared for the package (a `DESCRIPTION` range, a lockfile pin, ...) */ versionConstraints?: Range[]; /** the concrete version the exports were resolved from (e.g. the package database entry), for information only */ resolvedVersion?: string; }; /** * A package as the sources describe it, accumulated with {@link addInfo}/{@link mergeInPlace}: only those may * change it, everything else reads. Its three version views run from the rawest to the most concrete: * - {@link versionConstraints}: what each source declared, unmerged. * - {@link derivedRange}: their intersection, whether or not a version can satisfy it (see * {@link hasSatisfiableVersion}, and `inferredRange` on the dependencies context for the range that is only * handed out once it is). * - {@link resolvedVersion}: the one concrete version the exports were read from. */ export declare class Package { readonly name: string; private _type?; private _dependencies?; private _namespaceInfo?; private _resolvedVersion?; private readonly _versionConstraints; /** the intersection of {@link versionConstraints}, computed on demand and dropped whenever one is added */ private _derivedRange?; get type(): PackageType | undefined; get dependencies(): readonly Package[] | undefined; get namespaceInfo(): NamespaceInfo | undefined; get resolvedVersion(): string | undefined; get versionConstraints(): readonly Range[]; get derivedRange(): Range | undefined; /** {@link derivedRange} if a source declared one, else the {@link resolvedVersion} the exports were read from. */ get effectiveRange(): Range | undefined; constructor(info: { name: string; } & PackageOptions); /** Builds a package from a raw `NAMESPACE` body and its list of callable exports. */ static fromConstants(name: string, namespace: string, callable: string[]): Package; has(name: string, className?: string): boolean; s3For(generic: string): string[]; mergeInPlace(other: Package): void; addInfo({ type, dependencies, namespaceInfo, versionConstraints, resolvedVersion }: PackageOptions): void; /** The combined (intersected) range of all recorded constraints, or `undefined` if none were given. */ private deriveRange; /** Whether some concrete version can satisfy every recorded constraint at once. */ hasSatisfiableVersion(): boolean; static parsePkgVersionRange(constraint?: string, version?: string): Range | undefined; static functionIdentifier(dependency: string, func: string): string; }