/** A ZIP archive decoded to a `path → bytes` map of its file members. */
export type Unzipped = Record<string, Uint8Array>;
/** Read a single ZIP entry as UTF-8 text, or `undefined` when the entry is absent. */
export declare function unzipText(entries: Unzipped, entryPath: string): string | undefined;
/**
 * Decode an in-memory ZIP archive into a `path → bytes` map of its file members
 * (directory entries and `..`-escaping names are dropped). Shares the
 * central-directory record parser with the lazy, file-backed reader.
 */
export declare function unzip(bytes: Uint8Array): Unzipped;
export type ArchiveFormat = "zip" | "tar" | "tar.gz";
/**
 * Where to read an archive from: a filesystem path (format inferred from the
 * extension; ZIP is read lazily via ranged central-directory access) or
 * in-memory bytes with an explicit format.
 */
export type ArchiveSource = string | {
    bytes: Uint8Array;
    format: ArchiveFormat;
};
/** Content for a member when packing or extracting an archive. */
export type ArchiveMemberContent = string | Uint8Array | Blob;
export interface ArchivePathCandidate {
    archivePath: string;
    subPath: string;
}
export interface ArchiveNode {
    path: string;
    isDirectory: boolean;
    size: number;
    mtimeMs?: number;
}
export interface ArchiveDirectoryEntry extends ArchiveNode {
    name: string;
}
export interface ExtractedArchiveFile extends ArchiveNode {
    bytes: Uint8Array;
}
/** A byte window into an archive — file-backed (lazy) or in-memory. */
interface ByteSource {
    readonly size: number;
    read(start: number, end: number): Promise<Uint8Array>;
}
interface TarStorage {
    type: "tar";
    file: File;
}
interface ZipStorage {
    type: "zip";
    source: ByteSource;
    compressedSize: number;
    compression: number;
    flags: number;
    localHeaderOffset: number;
}
type EntryStorage = TarStorage | ZipStorage;
interface ArchiveIndexEntry extends ArchiveNode {
    storage?: EntryStorage;
}
/** Infer an archive format from a filesystem path's extension. */
export declare function archiveFormatFromPath(filePath: string): ArchiveFormat | undefined;
export declare function formatArchiveEntryLines(entries: readonly ArchiveDirectoryEntry[]): string[];
export declare function sniffArchiveFormat(bytes: Uint8Array): ArchiveFormat | undefined;
/**
 * Split an `archive.ext:inner/path` reference into every plausible
 * `{ archivePath, subPath }` pair, longest archive prefix first. A path may
 * contain more than one archive extension, so each candidate is a guess at
 * where the archive ends and the member portion begins.
 */
export declare function parseArchivePathCandidates(filePath: string): ArchivePathCandidate[];
/**
 * An indexed, read-only view over a single archive. ZIP archives are indexed
 * from the central directory and members are inflated on demand; tar archives
 * are fully materialized by `Bun.Archive` up front.
 */
export declare class ArchiveReader {
    #private;
    readonly format: ArchiveFormat;
    constructor(format: ArchiveFormat, entries: ArchiveIndexEntry[]);
    getNode(subPath?: string): ArchiveNode | undefined;
    listDirectory(subPath?: string): ArchiveDirectoryEntry[];
    readFile(subPath: string): Promise<ExtractedArchiveFile>;
}
/**
 * Open an archive for reading. ZIP archives opened from a path are indexed
 * lazily via ranged central-directory reads (members inflate on demand); tar
 * archives and in-memory ZIPs are read from a single buffer.
 */
export declare function openArchive(source: ArchiveSource): Promise<ArchiveReader>;
/** Render the top-level entries of an in-memory archive as one line each. */
export declare function listArchiveRoot(bytes: Uint8Array, format: ArchiveFormat, opts?: {
    limit?: number;
}): Promise<string>;
/**
 * Fully materialize every file member into a `path → content` map: ZIP members
 * are inflated in memory, tar members are returned as lazy `File`s. Use this
 * when you need every entry (rewrite, extract); for browsing or single-member
 * reads prefer `openArchive`, which is lazy for ZIP.
 */
export declare function readArchiveEntries(source: ArchiveSource): Promise<Map<string, ArchiveMemberContent>>;
/**
 * Serialize `entries` into an archive of `format` and write it to `destPath`.
 * ZIP is framed in memory, tar / tar.gz via `Bun.Archive` (gzip for tar.gz).
 * String members are encoded as UTF-8.
 */
export declare function writeArchive(destPath: string, format: ArchiveFormat, entries: Iterable<readonly [string, ArchiveMemberContent]>): Promise<void>;
/**
 * Extract every file member to `destDir`, creating parent directories as
 * needed. Entries that would escape `destDir` (via `..` or an absolute path)
 * are rejected. Returns the number of files written.
 */
export declare function extractArchive(source: ArchiveSource, destDir: string): Promise<number>;
/**
 * Frame a `path → bytes` map into a ZIP archive in memory. Each member is raw
 * DEFLATE unless that would not shrink it, in which case it is stored. ZIP64 is
 * not emitted; archives beyond the 32-bit limits throw rather than corrupt.
 */
export declare function zip(entries: Unzipped): Uint8Array;
export {};
