import type { LockfileObject, LockfileResolution, PackageSnapshot } from '@pnpm/lockfile.types'; import type { AllowBuild, DepPath, PkgIdWithPatchHash, SupportedArchitectures } from '@pnpm/types'; /** * Scan an iterable of lockfile snapshot keys for the resolved * `engines.runtime` / `devEngines.runtime` Node version and return * its bare version string (e.g. `"22.11.0"`), or `undefined` when * no snapshot pins a runtime. * * Pnpm's runtime resolver writes the pinned Node into the lockfile as * a snapshot with key `node@runtime:[()]` * (see [`engine/runtime/node-resolver/src/index.ts`](https://github.com/pnpm/pnpm/blob/29a42efc3b/engine/runtime/node-resolver/src/index.ts)). * The first such key found is treated as authoritative. This is fine * as an install-wide fallback (project-pin in the typical case), but * snapshots that pin their own Node still need * {@link readSnapshotRuntimePin} to get a per-snapshot result. * * Callers typically pass `Object.keys(lockfile.packages ?? {})` — the * in-memory `LockfileObject` merges the on-disk `packages:` and * `snapshots:` sections under a single `packages` field, so its keys * include every snapshot key the install will hash. */ export declare function findRuntimeNodeVersion(snapshotKeys: Iterable): string | undefined; /** * Read a single graph node's own `engines.runtime` Node pin from its * `children` map. The resolver desugars `engines.runtime` declared on * a dependency's manifest into `dependencies.node: 'runtime:'` * (see [`installing/deps-resolver/src/resolveDependencies.ts`](https://github.com/pnpm/pnpm/blob/29a42efc3b/installing/deps-resolver/src/resolveDependencies.ts)), * which then becomes a `children.node` entry pointing at the * `node@runtime:[(peers)]` snapshot key. * * Returns the bare version (e.g. `"22.11.0"`) when this snapshot pins * its own Node — or `undefined` when it doesn't and the caller should * fall back to the install-wide pin / host probe. * * Per-snapshot resolution matters because the bin linker routes * lifecycle-script spawns for a pinning package through *that * package's* downloaded Node — anchoring the snapshot's GVS engine * hash to an install-wide value would produce the wrong * side-effects-cache key for cross-pinning installs. */ export declare function readSnapshotRuntimePin(children: Record | undefined): string | undefined; export type DepsGraph = Record>; export interface DepsGraphNode { children: { [alias: string]: T; }; pkgIdWithPatchHash?: PkgIdWithPatchHash; resolution?: LockfileResolution; fullPkgId?: string; } export interface DepsStateCache { [depPath: string]: string; } export declare function calcDepState(depsGraph: DepsGraph, cache: DepsStateCache, depPath: string, opts: { patchFileHash?: string; includeDepGraphHash: boolean; supportedArchitectures?: SupportedArchitectures; /** * Install-wide fallback `engines.runtime` / `devEngines.runtime` * Node version (e.g. `"22.11.0"`). Used only when the snapshot at * `depPath` doesn't itself pin a Node: per-snapshot pins take * precedence so the side-effects-cache key reflects the actual * script-runner Node the bin linker would spawn for the package * (see {@link readSnapshotRuntimePin}). Typically computed once * per install via {@link findRuntimeNodeVersion} over the * lockfile's snapshot keys. */ nodeVersion?: string; }): string; export interface PkgMeta { depPath: DepPath; name: string; version: string; } export type PkgMetaIterator = IterableIterator; export interface HashedDepPath { pkgMeta: T; hash: string; } export declare function iterateHashedGraphNodes(graph: DepsGraph, pkgMetaIterator: PkgMetaIterator, allowBuild?: AllowBuild, supportedArchitectures?: SupportedArchitectures, /** * Install-wide fallback `engines.runtime` / `devEngines.runtime` * Node version. Used only for snapshots that don't pin their own * Node; pinning snapshots get resolved per-snapshot via * {@link readSnapshotRuntimePin} so the GVS engine hash matches * the Node the bin linker would actually spawn for each package * (see [`bins/linker/src/index.ts`](https://github.com/pnpm/pnpm/blob/29a42efc3b/bins/linker/src/index.ts)). * Typically obtained via {@link findRuntimeNodeVersion} over the * lockfile's snapshot keys. `undefined` falls back to * {@link engineName}'s default (system `node --version`, with * `process.version` as a last resort). */ nodeVersion?: string): IterableIterator>; export declare function calcGraphNodeHash({ graph, cache, builtDepPaths, buildRequiredCache, supportedArchitectures, nodeVersion }: { graph: DepsGraph; cache: DepsStateCache; builtDepPaths?: Set; buildRequiredCache?: Record; supportedArchitectures?: SupportedArchitectures; /** See [`iterateHashedGraphNodes`]'s `nodeVersion` parameter. */ nodeVersion?: string; }, pkgMeta: T): string; export declare function calcLeafGlobalVirtualStorePath(fullPkgId: string, name: string, version: string): string; /** * `subdepIds` maps each direct child's alias to its full pkg id * (`${name}@${version}:${integrity}`). Each child contributes a leaf hash * (no transitive walk) to the parent's hash, so the resulting path differs * whenever the set or versions of children change. One level deep only — * use {@link calcGraphNodeHash} when full graph traversal is needed. */ export declare function calcGlobalVirtualStorePathWithSubdeps(fullPkgId: string, name: string, version: string, subdepIds: Record): string; export interface PkgMetaAndSnapshot extends PkgMeta { pkgSnapshot: PackageSnapshot; pkgIdWithPatchHash: PkgIdWithPatchHash; } export declare function iteratePkgMeta(lockfile: LockfileObject, graph: DepsGraph): PkgMetaIterator; export declare function lockfileToDepGraph(lockfile: LockfileObject, supportedArchitectures?: SupportedArchitectures): DepsGraph;