file-collection
    Preparing search index...

    Interface ZipJsConfiguration

    Represents the configuration passed to configure.

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

    Hierarchy

    • WorkerConfiguration
      • ZipJsConfiguration
    Index

    Properties

    chunkSize?: number

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

    65536
    
    CompressionStream?: typeof TransformStreamLike

    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 TransformStreamLike

    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 TransformStreamLike
    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" })
    });
    DecompressionStream?: typeof TransformStreamLike

    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 TransformStreamLike

    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 TransformStreamLike
    maxWorkers?: number

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

    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
    });
    "./core/web-worker-wasm.js", or "./core/web-worker-native.js" for the builds using the native implementations