/** * ZIP container — create and read multi-file archives. * * Interoperates with standard tools (`unzip`, Explorer, fflate): `store` and * `deflate` entries round-trip everywhere. ZipKit additionally supports `zstd` * (method 93) inside the container for much denser archives between ZipKit-aware * peers. Entry metadata (modification time, Unix permissions, comment) is * preserved both ways, and archives over 4 GB / 65 535 entries transparently * use ZIP64. * * Everything is in-memory and async (the codecs are Wasm). Reading supports a * `filter` so you only pay to decompress the entries you want. * * @example * ```ts * import { zip, unzip } from '@myrialabs/zipkit'; * const archive = await zip([ * { name: 'hello.txt', data: strToU8('hi') }, * { name: 'data.json', data: bytes, method: 'zstd' } * ]); * const files = await unzip(archive, { filter: (e) => e.name.endsWith('.json') }); * ``` */ /** Built-in ZIP compression methods, by friendly name. */ export type ZipMethod = 'store' | 'deflate' | 'zstd'; /** An entry to add to an archive. */ export interface ZipEntryInput { /** Path within the archive, using `/` separators. */ name: string; /** Uncompressed contents. */ data: Uint8Array; /** Compression method (default `'deflate'`). */ method?: ZipMethod; /** DEFLATE/zstd level. */ level?: number; /** Last-modified time (default: now). */ mtime?: Date | number; /** Unix permission bits, e.g. `0o644`. Stored in the external attributes. */ unixPermissions?: number; /** Optional per-entry comment. */ comment?: string; } /** A decoded archive entry. */ export interface ZipEntry { /** Path within the archive. */ name: string; /** Decompressed contents (omitted when a `filter` rejected the entry). */ data: Uint8Array; /** Numeric compression method as stored (0 = store, 8 = deflate, 93 = zstd). */ method: number; /** Last-modified time. */ mtime: Date; /** Uncompressed size in bytes. */ size: number; /** Compressed size in bytes. */ compressedSize: number; /** Stored CRC-32 of the uncompressed data. */ crc32: number; /** Unix permission bits, if the archive recorded any. */ unixPermissions?: number; /** Per-entry comment, if present. */ comment?: string; } /** Metadata for an entry, passed to a read `filter` before decompression. */ export interface ZipEntryInfo { name: string; method: number; size: number; compressedSize: number; mtime: Date; unixPermissions?: number; } /** Options for {@link unzip}. */ export interface UnzipOptions { /** Decompress only the entries for which this returns `true`. */ filter?: (entry: ZipEntryInfo) => boolean; /** * Recompute each decompressed entry's CRC-32 and compare it to the value * stored in the archive, throwing {@link ZipKitError} on a mismatch. Off by * default — turn it on to detect silent corruption explicitly rather than * trusting the codec's own (format-dependent) integrity checks. */ verify?: boolean; /** * Password for encrypted entries. Decrypts WinZip AES (AE-1/AE-2) and legacy * ZipCrypto entries. Required if the archive is encrypted; a wrong password * throws {@link ZipKitError}. */ password?: string; } /** Options for {@link zip}. */ export interface ZipOptions { /** * Compress entries concurrently across the worker pool. Independent entries * fan out over every core while the container is assembled in order, so the * output is byte-identical to the single-threaded path. * * Defaults to automatic: on when there are at least two entries and the * archive totals at least 256 KB, off otherwise (the worker hand-off would * cost more than it saves on tiny archives). Set explicitly to override. */ parallel?: boolean; /** * Reports archive-build progress as each entry finishes compressing: * `(entriesDone, totalEntries)`. Fires up to once per entry; the final call * has `entriesDone === totalEntries`. */ onProgress?: (entriesDone: number, totalEntries: number) => void; /** * Encrypt every entry with WinZip AES (AE-2). Reads back with the same * `password` via {@link unzip}, and interoperates with 7-Zip / WinZip. AES-256 * by default; the per-entry CRC is omitted as the AE-2 spec requires. */ password?: string; } /** * Build a ZIP archive from a list of entries. Returns the complete archive * bytes. Uses ZIP64 automatically when any size/offset exceeds 4 GB or there * are more than 65 535 entries. */ export declare function zip(entries: ZipEntryInput[], opts?: ZipOptions): Promise; /** * Read a ZIP archive. Returns one {@link ZipEntry} per file. Pass * `opts.filter` to skip decompressing entries you don't need — rejected * entries are omitted from the result. */ export declare function unzip(data: Uint8Array, opts?: UnzipOptions): Promise; /** * List the entries in an archive without decompressing them. Cheaper than * {@link unzip} when you only need names, sizes, and metadata. */ export declare function listEntries(data: Uint8Array): Promise; export { zipStream, type ZipStreamOptions } from './stream.js'; //# sourceMappingURL=index.d.ts.map