///
///
import { Workspace } from './package-files/workspace';
export interface PackageJsonInput {
/**
* Path used to identify this package.json in the hash. Should be a
* forward-slash relative path matching the file's location in the
* eventual archive (e.g. "package.json" or "packages/cli/package.json").
*/
path: string;
raw: Buffer;
}
export interface LockfileInput {
/**
* Basename of the lockfile (e.g. "package-lock.json").
*/
name: string;
/**
* Raw 32-byte SHA-256 digest of the lockfile contents.
*/
hash: Buffer;
}
export interface ComposeCacheHashInput {
lockfile?: LockfileInput;
packageJsons: PackageJsonInput[];
excludedFields: string[];
}
/**
* Encodes a value as JSON in a way that's stable across runs and machines.
*
* Differences from {@link JSON.stringify}:
* - Object keys are sorted (byte-wise / code-point order) before
* serialization. This is the load-bearing difference — without it, two
* equivalent package.json files written in different key orders would
* produce different hashes.
* - HTML-significant characters (`<`, `>`, `&`) are escaped as
* `\u003c`/`\u003e`/`\u0026`.
* - U+2028 and U+2029 are escaped as `\u2028`/`\u2029`.
* - No whitespace between tokens.
* - Numbers use {@link String}; floating-point edge cases may differ from
* other encoders. Package.json content is effectively never numeric
* outside config blobs, so this is negligible in practice.
*/
export declare function stableJsonEncode(value: unknown): string;
/**
* Parses a package.json, removes the named top-level fields, and re-encodes
* the result via {@link stableJsonEncode}.
*/
export declare function canonicalizePackageJson(raw: Buffer, excludedFields: string[]): Buffer;
/**
* Combines a lockfile digest and a set of canonicalized package.json
* entries into a single SHA-256 hex digest.
*
* Each record contributes:
* uint64-be(label length) || label bytes ||
* uint64-be(content length) || content bytes
*
* Records are written in the following order:
* 1. The lockfile record (if present), labeled `lockfile:`,
* whose content is the raw 32-byte SHA-256 digest of the lockfile.
* 2. One record per package.json sorted byte-wise by path, labeled
* `package.json:`, whose content is the canonicalized
* package.json bytes.
*/
export declare function composeCacheHash(input: ComposeCacheHashInput): string;
/**
* Reads the workspace lockfile and every workspace package.json (root +
* member packages) and returns the inputs needed by {@link composeCacheHash}.
*
* Paths are normalized to forward slashes and made relative to the
* workspace root so that they match what ends up in the bundle archive.
*/
export declare function loadWorkspaceCacheHashInputs(workspace: Workspace): Promise<{
lockfile?: LockfileInput;
packageJsons: PackageJsonInput[];
}>;
/**
* Convenience wrapper that loads workspace inputs and composes the cache
* hash with the standard set of excluded package.json fields.
*/
export declare function computeWorkspaceCacheHash(workspace: Workspace): Promise;