import { StandardFilenameEncoding } from "./types"; declare const Uint8Array_: Uint8ArrayConstructor; type Uint8Array_ = Uint8Array; declare const TransformStream_: { new (transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy): TransformStream; prototype: TransformStream; }; export interface ZipEntryMeta { comment?: string; extraField?: Uint8Array; modifiedAt?: Date; createdAt?: Date; lastAccess?: Date; unixPermissions?: number; dosAttributes?: number; externalAttributes?: number; } export type ZipCompressionMethod = "store" | "deflate"; export type ZipPathMode = "strict" | "sanitize" | "unsafe" | "strict-package"; export interface ZipProgress { path?: string; loaded: number; total?: number; entries?: number; phase: "read" | "compress" | "write" | "parse"; } /** * Fully prepared ZIP entry data returned by an optional worker backend. * * This is intentionally a structural data contract: the main writer still owns * ZIP ordering, duplicate-path checks, local headers, central directory records, * and output shaping. Backends should only prepare one already-reserved entry. */ export interface ZipPreparedEntry { /** Normalized path reserved by the writer for this entry. */ path: string; /** Whether the normalized path is a directory entry. */ isDirectory: boolean; /** Modification time used for DOS and optional timestamp extra fields. */ modifiedAt: Date; /** Creation time used when NTFS timestamp extras are enabled. */ createdAt?: Date; /** Last-access time used when NTFS timestamp extras are enabled. */ lastAccess?: Date; /** Per-entry central-directory comment. */ comment: string; /** Caller-supplied raw extra fields, before writer-generated extras. */ extraField: Uint8Array; /** Uncompressed payload size in bytes. */ sourceSize: number; /** Final stored or raw-DEFLATE payload bytes. */ compressed: Uint8Array; /** ZIP compression method number: 0 for store, 8 for deflate. */ method: number; /** CRC-32 of the uncompressed payload. */ crc32: number; /** External file attributes written into the central directory. */ externalAttributes: number; } /** * Encoder options after JSZipp has applied defaults, excluding the worker * backend itself so backends cannot recursively invoke themselves. */ export type ZipEncoderRuntimeOptions = Required>; /** * Optional async entry-preparation backend used by `ZipWriter.add()` and * `ZipTransformStream`. * * Return a `ZipPreparedEntry` to let the backend supply compressed bytes, or * return `undefined` to ask JSZipp to use the normal in-thread preparation path. * Implementations should be reusable across writers unless their own * documentation says otherwise; JSZipp does not terminate or dispose them. * Returned prepared entries are treated as trusted input by the writer. */ export interface ZipWorkerBackend { /** * Prepare one already-reserved entry. * * `path` is produced by JSZipp's normal path validation/reservation path. * Throw to fail the write; return `undefined` for ordinary fallback. */ prepare(input: ZipInputEntry, options: ZipEncoderRuntimeOptions, path: string): Promise; } export interface ZipEncoderOptions { level?: number; zip64?: Zip64Mode; comment?: string; timestamps?: TimestampMode; pathMode?: ZipPathMode; signal?: AbortSignal; onProgress?: (progress: ZipProgress) => void; /** * Optional backend used to prepare/compress async entries off the main thread. * * Usually created with `createWorkerBackend()` from * `web-jszipp/worker-plugin`. Only async `add()` / `ZipTransformStream` * writes consult this backend; `writeSync()` remains fully synchronous and * local. The caller owns backend lifetime and should terminate reusable * worker backends when they are no longer needed. When the backend is backed * by one specific `Worker` instance instead of a factory, it cannot be * recreated after termination. */ worker?: ZipWorkerBackend; explicitDirectoryEntries?: boolean; } export type Zip64Mode = "auto" | "force" | "off"; export declare const TimestampMode: { readonly Dos: 1; readonly Unix: 2; readonly Ntfs: 4; }; export type TimestampMode = number; export type ZipWriterOutput = "stream" | "blob" | "response" | "uint8array" | "arraybuffer"; export type ZipWriterCloseResult = T extends "blob" ? Blob : T extends "response" ? Response : T extends "uint8array" ? Uint8Array_ : T extends "arraybuffer" ? ArrayBuffer : ReadableStream>; export interface ZipWriterOptions extends ZipEncoderOptions { outputAs?: T; mimeType?: string; } export interface ZipInputEntry { path: string; data: string | Uint8Array | ArrayBuffer | Blob | ReadableStream>; method?: ZipCompressionMethod; level?: number; meta?: ZipEntryMeta; } export interface ZipSyncInputEntry extends Omit { data: string | Uint8Array | ArrayBuffer; } export interface ZipStreamEntry extends ZipEntryMeta { readonly path: string; readonly size: number | null; readonly compressedSize: number | null; readonly crc32: number | null; readonly isDirectory: boolean; stream(): ReadableStream>; text(): Promise; bytes(): Promise>; arrayBuffer(): Promise; skip(): Promise; } export interface ZipRandomAccessReader { readonly comment?: string; readonly entries: readonly ZipRandomAccessEntry[]; get(path: string): ZipRandomAccessEntry | undefined; close(): Promise; } export interface ZipRandomAccessEntry extends ZipEntryMeta { readonly path: string; readonly size: number; readonly compressedSize: number; readonly crc32: number; readonly isDirectory: boolean; stream(): ReadableStream>; text(): Promise; bytes(): Promise>; arrayBuffer(): Promise; } type FilenameEncoding = "cp437" | StandardFilenameEncoding; export interface ZipReadOptions { filenameEncoding?: FilenameEncoding | ITextDecoder; pathMode?: ZipPathMode; maxArchiveSize?: number; maxEntrySize?: number; signal?: AbortSignal; onProgress?: (progress: ZipProgress) => void; } interface ITextDecoder { encoding: string; fatal: boolean; ignoreBOM: boolean; decode(bytes: Uint8Array): string; } export declare class ZipTransformStream extends TransformStream_> { constructor(options?: ZipEncoderOptions); } export declare class ZipWriter { readonly output: ReadableStream>; private readonly encoder; private readonly outputAs; private readonly mimeType; private controller?; private closed; private mode; private collected; constructor(options?: ZipWriterOptions); private assertOpen; add(entry: ZipInputEntry): Promise; close(): Promise>; writeSync(entry: ZipSyncInputEntry): void; closeSync(): ZipWriterCloseResult; } export declare function readZipStream(zipStream: ReadableStream>, options?: ZipReadOptions): AsyncIterable; export declare const openZip: (source: Blob | File | Uint8Array | ArrayBuffer, options?: ZipReadOptions) => Promise; declare const JSZipp: { ZipTransformStream: typeof ZipTransformStream; ZipWriter: typeof ZipWriter; readZipStream: typeof readZipStream; openZip: (source: Blob | File | Uint8Array | ArrayBuffer, options?: ZipReadOptions) => Promise; TimestampMode: { readonly Dos: 1; readonly Unix: 2; readonly Ntfs: 4; }; }; export default JSZipp;