Skip to main content

ZIP API · archive loader

Open an archive into named resources.

ZipLoader turns a ZIP archive into a file map, keeping each path and its decoded contents available to the application. It is the useful boundary for bundled assets, fixtures, and nested data packages.

The archive path

Keep the archive boundary simple: path in, content out.

The loader handles ZIP structure and returns an object keyed by archive paths. The application decides which entries to parse next and which loaders should handle them.

Input

ZIP bytes as an ArrayBuffer or loader input

Output

File map keyed by names or relative paths

Contents

ArrayBuffer values for each file

Next step

Dispatch extracted resources to their format loaders

Detailed guide

ZipLoader reference

The sections below document archive metadata, usage, file-map output, and native validation and decoded-output limits.

From-v1.0

Decodes a Zip Archive into a file map.

ZipLoader
File Extension.zip
File TypeBinary
File FormatZIP Archive
Data Format"File Map"
Decoder TypeAsynchronous
Worker Thread❌ No
Streaming❌ No

Usage​

import {parse} from '@loaders.gl/core';
import {ZipLoader} from '@loaders.gl/archives/zip';

const fileMap = await parse(arrayBuffer, ZipLoader);
for (const fileName in fileMap) {
const fileData = fileMap[fileName];
// Do something with the subfile
}

Data Format​

The file map is an object with keys representing file names or relative paths in the zip file, and values being the contents of each sub file as an ArrayBuffer. Directory entries are omitted. The map has a null prototype, so names such as __proto__ remain ordinary file keys. Errors reject the parse instead of appearing as map values.

Options​

The typed zip namespace accepts the limits and signal documented for openZipArchive. Complete reads always verify decoded sizes and CRC-32. Unsupported ZIP profiles reject.

OptionTypeDefaultDescription
zip.maxTotalDecodedBytesbigint64n * 1024n * 1024nSum of file sizes retained in the result; checked before decoding payloads.
zip.maxDecodedBytesbigint64n * 1024n * 1024nMaximum decoded bytes per complete entry.
zip.maxCompressedBytesbigint64n * 1024n * 1024nMaximum compressed bytes per complete entry.
zip.signalAbortSignal—Cancels archive initialization and reads.

The total-map, decoded-entry and compressed-entry limits are independent. Raising maxTotalDecodedBytes does not raise either entry limit. For an entry larger than 64 MiB, set maxDecodedBytes and, when its compressed payload is also larger, maxCompressedBytes. These limits bound encoded/decoded byte counts, not decoder intermediates or total heap. Use the shared archive API for incremental or range reads instead of retaining a complete map.

The package root exports metadata. For direct parser access:

import {ZipLoaderWithParser} from '@loaders.gl/archives/zip-loader';
const files = await ZipLoaderWithParser.parse(arrayBuffer, {
zip: {
maxTotalDecodedBytes: 256n * 1024n * 1024n,
maxDecodedBytes: 128n * 1024n * 1024n,
maxCompressedBytes: 128n * 1024n * 1024n
}
});