import { type ArchiveSink } from "../io/archive-sink.js"; import { type ArchiveSource } from "../io/archive-source.js"; import type { ZipStringEncoding } from "../shared/text.js"; import type { ArchiveFormat } from "../shared/types.js"; import { type ParseOptions, type ZipEntry as ParseZipEntry } from "./stream.js"; import { type ZipEntryInfo } from "./zip-parser.js"; import type { ZipEntryType } from "../zip-spec/zip-entry-info.js"; import type { UnzipOperation, UnzipProgress, UnzipStreamOptions } from "./progress.js"; type PipeToOptions = { preventClose?: boolean; preventAbort?: boolean; preventCancel?: boolean; signal?: AbortSignal; }; export interface UnzipOptions { /** * Archive format: "zip" (default) or "tar". * Note: format dispatch is handled by `unzip()`. */ format?: ArchiveFormat; decodeStrings?: boolean; /** Optional string encoding for legacy (non-UTF8) names/comments. */ encoding?: ZipStringEncoding; parse?: ParseOptions; /** Password for encrypted entries (ZIP only). */ password?: string | Uint8Array; /** Default abort signal used by streaming operations. */ signal?: AbortSignal; /** Default progress callback used by streaming operations. */ onProgress?: (p: UnzipProgress) => void; /** Default throttle for progress callbacks. */ progressIntervalMs?: number; } export type { UnzipOperation, UnzipProgress, UnzipStreamOptions } from "./progress.js"; export declare class UnzipEntry { readonly path: string; /** Entry type: file, directory, or symlink */ readonly type: ZipEntryType; /** * For symlinks, returns the target path after calling bytes(). * Before extraction, this is undefined. */ linkTarget?: string; /** * Unix file mode/permissions (0 if unavailable). */ readonly mode: number; /** Whether this entry is encrypted (ZipCrypto or AES). */ readonly isEncrypted: boolean; private readonly _data?; private readonly _info?; private readonly _password?; private readonly _parseEntry?; private readonly _onBytesOut?; private readonly _signal?; constructor(args: { kind: "buffer"; data: Uint8Array; info: ZipEntryInfo; password?: string | Uint8Array; } | { kind: "stream"; entry: ParseZipEntry; password?: string | Uint8Array; }, hooks?: { onBytesOut?: (path: string, type: ZipEntryType, bytes: number) => void; signal?: AbortSignal; }); /** * Process extracted bytes: populate linkTarget for symlinks and notify progress. */ private _processExtractedBytes; bytes(): Promise; stream(): AsyncIterable; pipeTo(sink: WritableStream, options?: PipeToOptions): Promise; pipeTo(sink: ArchiveSink): Promise; readableStream(): ReadableStream; text(encoding?: string): Promise; discard(): void; } export declare class ZipReader { private readonly _source; private readonly _options; private _bufferParser; private _bufferData; constructor(source: ArchiveSource, options?: UnzipOptions); private get _encoding(); entries(options?: UnzipStreamOptions): AsyncIterable; entriesStream(options?: UnzipStreamOptions): ReadableStream; operation(options?: UnzipStreamOptions): UnzipOperation; private _ensureBufferParser; get(path: string): Promise; bytes(path: string): Promise; close(): Promise; } /** Unzip options with format: "tar" */ export interface UnzipOptionsTar extends UnzipOptions { format: "tar"; } /** Unzip options with format: "zip" (or default) */ export interface UnzipOptionsZip extends UnzipOptions { format?: "zip"; }