@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.
86 lines • 2.35 kB
TypeScript
/**
* Direct stream entry for immediate streaming without buffering
* Used for fast-path entries with pre-calculated metadata
*/
import { FastPathStoreEntry, FastPathDeflateEntry } from './zip-format.js';
import { CompressionMethod } from './compression.js';
export declare enum DirectStreamState {
PENDING = "pending",
STREAMING = "streaming",
COMPLETED = "completed",
ERROR = "error"
}
export interface DirectStreamMetadata {
crc32: number;
compressedSize: number;
uncompressedSize: number;
localHeaderOffset: number;
compressionMethod: CompressionMethod;
}
/**
* DirectStreamEntry bypasses buffering for immediate streaming
* when all required metadata is pre-calculated
*/
export declare class DirectStreamEntry {
readonly entry: FastPathStoreEntry | FastPathDeflateEntry;
readonly index: number;
private state;
private streamReader;
private metadata;
private error;
constructor(entry: FastPathStoreEntry | FastPathDeflateEntry, index: number, compressionMethod: CompressionMethod);
/**
* Get current state
*/
getState(): DirectStreamState;
/**
* Check if entry is ready for immediate streaming
*/
isReadyForStreaming(): boolean;
/**
* Check if streaming is complete
*/
isCompleted(): boolean;
/**
* Check if there was an error
*/
hasError(): boolean;
/**
* Get error if any
*/
getError(): Error | null;
/**
* Get pre-calculated metadata
*/
getMetadata(): DirectStreamMetadata;
/**
* Set local header offset (called during writing)
*/
setLocalHeaderOffset(offset: number): void;
/**
* Start streaming data directly from the source
* Returns a readable stream that can be piped directly to output
*/
startDirectStreaming(): ReadableStream<Uint8Array>;
/**
* Mark entry as completed
*/
markCompleted(): void;
/**
* Mark entry as failed
*/
markError(error: Error): void;
/**
* Pump data from input stream to output controller
*/
private pumpStream;
/**
* Convert Node.js stream or ReadableStream to Web ReadableStream
*/
private convertToWebStream;
/**
* Clean up resources
*/
private cleanup;
}
//# sourceMappingURL=direct-stream-entry.d.ts.map