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 { ZipTimestampMode } from "../zip-spec/timestamps.js"; import type { ZipPathOptions } from "../zip-spec/zip-path.js"; import { type Zip64Mode } from "../zip-spec/zip-records.js"; import type { ZipOperation, ZipProgress, ZipStreamOptions } from "./progress.js"; /** Archive options */ export interface ZipOptions { /** * Archive format: "zip" (default) or "tar". * Note: format dispatch is handled by `zip()`. */ format?: ArchiveFormat; level?: number; timestamps?: ZipTimestampMode; comment?: string; /** Optional entry name normalization. `false` keeps names as-is. */ path?: false | ZipPathOptions; /** Optional string encoding for entry names/comments and archive comment. */ encoding?: ZipStringEncoding; /** Default abort signal used by streaming operations. */ signal?: AbortSignal; /** Default progress callback used by streaming operations. */ onProgress?: (p: ZipProgress) => void; /** Default throttle for progress callbacks. */ progressIntervalMs?: number; /** * ZIP64 mode: * - "auto" (default): write ZIP64 only when required by limits. * - true: force ZIP64 structures even for small archives. * - false: forbid ZIP64; throws if ZIP64 is required. */ zip64?: Zip64Mode; /** * Default modification time for entries that don't specify `modTime`. * * If you need stable output across runs, either pass this explicitly or use `reproducible: true`. */ modTime?: Date; /** * If true, bias defaults toward reproducible output: * - default `modTime` becomes 1980-01-01 00:00:00 (local time) * - default `timestamps` becomes "dos" (no UTC extra field) */ reproducible?: boolean; /** * If true (default), automatically STORE incompressible data. * If false, always follow `level` (DEFLATE when level > 0). */ smartStore?: boolean; /** * If true, entries are written in their original input order. * If false (default), entries are sorted alphabetically by name. * * Note: streaming output preserves the input order. */ noSort?: boolean; } export interface ZipEntryOptions { level?: number; modTime?: Date; atime?: Date; ctime?: Date; birthTime?: Date; comment?: string; /** Optional Unix mode/permissions for this entry. */ mode?: number; /** Optional MS-DOS attributes (low 8 bits). */ msDosAttributes?: number; /** Advanced override for external attributes. */ externalAttributes?: number; /** Advanced override for versionMadeBy. */ versionMadeBy?: number; /** Per-entry ZIP64 override. Defaults to the archive-level zip64 mode. */ zip64?: Zip64Mode; /** Optional string encoding for this entry name/comment. */ encoding?: ZipStringEncoding; } export type { ZipOperation, ZipProgress, ZipStreamOptions } from "./progress.js"; export declare class ZipArchive { private readonly _options; private readonly _streamDefaults; private readonly _entries; private _sealed; constructor(options?: ZipOptions); private _getCreateZipOptions; add(name: string, source: ArchiveSource, options?: ZipEntryOptions): this; /** * Add a directory entry. * * Unified API consistent with TarArchive. */ addDirectory(name: string, options?: Omit): this; /** * Add a symbolic link entry. * * Unified API consistent with TarArchive. */ addSymlink(name: string, target: string, options?: Omit): this; stream(options?: ZipStreamOptions): AsyncIterable; operation(options?: ZipStreamOptions): ZipOperation; /** * Browser-only fast path: stream sources through CompressionStream while * computing CRC incrementally. Avoids Blob.arrayBuffer() materialization. */ private _browserStreamingBytes; bytes(options?: ZipStreamOptions): Promise; bytesSync(): Uint8Array; pipeTo(sink: ArchiveSink, options?: ZipStreamOptions): Promise; } /** ZIP options with format: "tar" */ export interface ZipOptionsTar extends ZipOptions { format: "tar"; } /** ZIP options with format: "zip" (or default) */ export interface ZipOptionsZip extends ZipOptions { format?: "zip"; }