UNPKG

@lyleunderwood/streaming-zipper

Version:

Memory-efficient streaming ZIP creation with automatic backpressure control. Supports parallel reading + sequential writing for both Web Streams and Node.js streams with ZIP64 support.

117 lines 2.91 kB
/** * Entry buffer system for parallel reading with sequential writing */ import { ZipEntry } from './zip-format.js'; import { CompressionMethod } from './compression.js'; export declare enum EntryState { PENDING = "pending", READING = "reading", READY = "ready", WRITING = "writing", COMPLETED = "completed", ERROR = "error" } export interface BufferedChunk { data: Uint8Array; offset: number; } export interface EntryMetadata { crc32: number; compressedSize: number; uncompressedSize: number; localHeaderOffset: number; compressionMethod: CompressionMethod; } export declare class EntryBuffer { readonly entry: ZipEntry; readonly index: number; readonly compressionMethod: CompressionMethod; private chunks; private totalSize; private maxBufferSize; private crc32Stream; private state; private readPromise; private readResolver; private readError; private metadata; private waitingReaders; constructor(entry: ZipEntry, index: number, compressionMethod?: CompressionMethod, maxBufferSize?: number); /** * Get current entry state */ getState(): EntryState; /** * Check if entry is ready to be written */ isReady(): boolean; /** * Check if entry has been completely read */ isReadComplete(): boolean; /** * Get buffered size in bytes */ getBufferedSize(): number; /** * Check if buffer has space for more data */ hasBufferSpace(): boolean; /** * Start reading from the entry's data stream */ startReading(): Promise<void>; /** * Wait for entry to be ready for writing */ waitForReady(): Promise<void>; /** * Read the next chunk from the buffer */ readChunk(): BufferedChunk | null; /** * Get entry metadata */ getMetadata(): EntryMetadata; /** * Set the local header offset */ setLocalHeaderOffset(offset: number): void; /** * Mark entry as being written */ startWriting(): void; /** * Mark entry as completed */ markCompleted(): void; /** * Get total uncompressed size */ getUncompressedSize(): number; /** * Get total compressed size (same as uncompressed for store method) */ getCompressedSize(): number; /** * Get CRC32 checksum */ getCRC32(): number; /** * Perform the actual reading from the stream */ private performRead; /** * Wait for buffer space to become available */ private waitForBufferSpace; /** * Notify that buffer space has been freed up (called when chunks are consumed) */ notifySpaceFreed(): void; /** * Create a Web ReadableStream from a Node.js stream */ private createWebStreamFromNodeStream; } //# sourceMappingURL=entry-buffer.d.ts.map