/** * Shared output pipeline for ZIP streaming operations. * * Both `ZipArchive` and `ZipEditor` use an identical scaffolding pattern for * their `operation()` method: signal/abort wiring, ProgressEmitter, async queue, * StreamingZip callback, error handling, and return object construction. * This module extracts that shared boilerplate into a single reusable function. */ import { ProgressEmitter } from "../shared/progress.js"; import type { ZipStringCodec, ZipStringEncoding } from "../shared/text.js"; import type { Zip64Mode } from "../zip-spec/zip-records.js"; import { StreamingZip } from "./stream.js"; import type { ZipOperation, ZipProgress, ZipStreamOptions } from "./progress.js"; /** Resolved signal/progress options passed to the pipeline. */ export interface ZipPipelineOptions { signal?: AbortSignal; onProgress?: ZipStreamOptions["onProgress"]; progressIntervalMs?: number; } /** Options for constructing the internal StreamingZip instance. */ export interface ZipPipelineZipOptions { comment?: string; zip64?: Zip64Mode; encoding?: ZipStringEncoding; codec?: ZipStringCodec; } /** * Callback that processes entries within the pipeline. * * The pipeline sets up all scaffolding (abort, progress, queue, StreamingZip) * and then calls this function to do the actual per-entry work. The callback * receives: * * - `zip` — the StreamingZip instance to add files to * - `signal` — the linked AbortSignal * - `progress` — the ProgressEmitter to update * * The callback MUST call `zip.end()` when all entries have been added. * It SHOULD call `throwIfAborted(signal)` between entries. */ export type ZipPipelineProcessFn = (ctx: { zip: StreamingZip; signal: AbortSignal; progress: ProgressEmitter; }) => Promise; /** * Create a streaming ZIP operation with all shared boilerplate wired up. * * @param entriesTotal - Total number of entries (for progress reporting) * @param zipOptions - Options for the StreamingZip instance * @param pipelineOpts - Signal, progress callback, and interval * @param processFn - Callback that adds entries to the StreamingZip * @returns A `ZipOperation` handle */ export declare function createZipOperation(entriesTotal: number, zipOptions: ZipPipelineZipOptions, pipelineOpts: ZipPipelineOptions, processFn: ZipPipelineProcessFn): ZipOperation;