@zip.js/zip.js
    Preparing search index...

    Interface Configuration

    Represents the configuration passed to configure.

    interface Configuration {
        baseURI?: string;
        chunkSize?: number;
        CompressionStream?: typeof CompressionStreamLike;
        CompressionStreamFallback?: typeof CompressionStreamLike;
        CompressionStreamZlib?: typeof CompressionStreamLike;
        createWorker?: () => Worker;
        DecompressionStream?: typeof DecompressionStreamLike;
        DecompressionStreamFallback?: typeof DecompressionStreamLike;
        DecompressionStreamZlib?: typeof DecompressionStreamLike;
        maxWorkers?: number;
        terminateWorkerTimeout?: number;
        transferStreams?: boolean;
        useCompressionStream?: boolean;
        useWebWorkers?: boolean;
        wasmURI?: string;
        workerStartupTimeout?: number;
        workerStarvationTimeout?: number;
        workerURI?: string;
    }

    Hierarchy (View Summary)

    Index
    baseURI?: string

    The base URL against which the relative URIs are resolved, i.e. Configuration#workerURI, Configuration#wasmURI and CodecDefinition#codecURI.

    the URL of the module of zip.js
    
    chunkSize?: number

    The size of the chunks in bytes during data compression/decompression.

    Values lower than 64 are raised to 64, and a value that is not an integer greater than 0 is replaced with the default value.

    65536
    
    CompressionStream?: typeof CompressionStreamLike

    The stream implementation used to compress data when useCompressionStream is set to true.

    the global CompressionStream, or false when the environment does not provide it

    CompressionStreamFallback?: typeof CompressionStreamLike

    The stream implementation used to compress data when useCompressionStream is set to false.

    the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
    
    CompressionStreamZlib?: typeof CompressionStreamLike
    createWorker?: () => Worker

    The function used to create the web workers, taking precedence over workerURI.

    It lets bundlers detect the worker script statically and compile it with its imports, e.g. a custom worker script embedding alternative compression streams.

    Here is an example with a custom worker script (see initWorker for the content of the script):

    configure({
    createWorker: () => new Worker(new URL("./zip-worker.js", import.meta.url), { type: "module" })
    });

    It is also the way to run the web workers on engines where TransformStream is missing from the scope of the workers, e.g. Firefox before version 102. There, the worker script of zip.js throws when it is evaluated and the data is silently compressed/decompressed in the main scope instead. A polyfill imported by the page does not help, because the worker reads the globals of the Streams API from its own scope, so it has to be installed by the worker itself before the worker script of zip.js runs. These engines predate the support of module workers, hence the classic worker script below:

    // zip-worker-with-polyfill.js
    importScripts("./web-streams-polyfill.js", "./zip-web-worker.js");
    configure({
    createWorker: () => new Worker("./zip-worker-with-polyfill.js")
    });
    DecompressionStream?: typeof DecompressionStreamLike

    The stream implementation used to decompress data when useCompressionStream is set to true.

    the global DecompressionStream, or false when the environment does not provide it

    DecompressionStreamFallback?: typeof DecompressionStreamLike

    The stream implementation used to decompress data when useCompressionStream is set to false.

    the implementation embedded in the entry point that was imported, e.g. the WebAssembly one
    
    DecompressionStreamZlib?: typeof DecompressionStreamLike
    maxWorkers?: number

    The maximum number of web workers used to compress/decompress data simultaneously.

    It must be an integer greater than 0, see ERR_INVALID_MAX_WORKERS.

    navigator.hardwareConcurrency, or 2 when the environment does not provide it

    terminateWorkerTimeout?: number

    The delay in milliseconds before idle web workers are automatically terminated. You can call terminateWorkers() to terminate idle workers.

    5000
    
    transferStreams?: boolean

    true to transfer stream ownership to web workers.

    true
    
    useCompressionStream?: boolean

    true to use the native API CompressionStream/DecompressionStream to compress/decompress data.

    When compressing, the native API is only used when level is undefined or equal to 6, see ZipWriterConstructorOptions#level.

    true
    
    useWebWorkers?: boolean

    true to use web workers to compress/decompress data in non-blocking background processes.

    true
    
    wasmURI?: string

    The URI of the WebAssembly module used by default implementations to compress/decompress data. It is ignored if useCompressionStream is set to true and CompressionStream/DecompressionStream are supported by the environment.

    Here is an example to import the WASM module as a URL (see ?url) and avoid CSP issues:

    import wasmURI from "@zip.js/zip.js/dist/zip-module.wasm?url";

    configure({
    wasmURI
    });
    "./core/streams/zlib-wasm/zlib-streams.wasm"
    
    workerStartupTimeout?: number

    The delay in milliseconds before a newly created web worker which has not sent any message is considered dead, terminated, and replaced with inline processing.

    It allows recovering from environments where web workers fail silently, e.g. extension pages blocking worker scripts via their Content Security Policy.

    5000
    
    workerStarvationTimeout?: number

    The delay in milliseconds after which the oldest pending compression/decompression task is run without a web worker when no task completes.

    It prevents deadlocks when entries read from a ZipReader are added concurrently into a ZipWriter and all the web workers are waiting for data.

    5000
    
    workerURI?: string

    The URI of the web worker.

    It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Data URI.

    Here is an example to import the worker module as a URL (see ?url) and avoid CSP issues:

    import workerURI from "@zip.js/zip.js/dist/zip-web-worker.js?url";

    configure({
    workerURI
    });

    The worker is created as a module worker, unless the URI is a Data URI or a Blob URI, in which case it is created as a classic worker. See Configuration#createWorker for an example of classic worker script installing a polyfill of the Streams API.

    "./core/web-worker-wasm.js", or "./core/web-worker-native.js" for the builds using the native implementations