OptionalbaseThe base URL against which the relative URIs are resolved, i.e. Configuration#workerURI, Configuration#wasmURI and CodecDefinition#codecURI.
OptionalchunkThe 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.
OptionalCompressionThe stream implementation used to compress data when useCompressionStream is set to true.
OptionalCompressionThe stream implementation used to compress data when useCompressionStream is set to false.
OptionalCompressionUse Configuration#CompressionStreamFallback instead.
OptionalcreateThe 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")
});
OptionalDecompressionThe stream implementation used to decompress data when useCompressionStream is set to true.
OptionalDecompressionThe stream implementation used to decompress data when useCompressionStream is set to false.
OptionalDecompressionUse Configuration#DecompressionStreamFallback instead.
OptionalmaxThe maximum number of web workers used to compress/decompress data simultaneously.
It must be an integer greater than 0, see ERR_INVALID_MAX_WORKERS.
OptionalterminateThe delay in milliseconds before idle web workers are automatically terminated. You can call terminateWorkers() to terminate idle workers.
Optionaltransfertrue to transfer stream ownership to web workers.
Optionalusetrue 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.
Optionalusetrue to use web workers to compress/decompress data in non-blocking background processes.
OptionalwasmThe 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
});
OptionalworkerThe 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.
OptionalworkerThe 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.
OptionalworkerThe 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.
Represents the configuration passed to configure.