Fix missing commits in v2.8.35
Full Changelog: v2.8.35...v2.8.36
What's Changed in v2.8.36
This release focuses on streaming I/O: readers can now hand over a native stream instead of
being read chunk by chunk, which removes a copy for blobs and a whole series of HTTP requests
for remote archives read with range requests. It also fixes several zip64 and split-archive issues, and replaces the
hand-maintained list of property names protected from minification with a derived one checked
at build time.
New features
Reader#createReadable(options), introduced internally in 2.8.31, is now part of the documented
API, with the newCreateReadableOptionstype (offset,size,chunkSize). Custom readers can
override it to return a stream provided natively by the underlying data source instead of relying
onreadUint8Array(). It also accepts a byte range, and no longer takes adiskNumberStart
option: split readers now use linear disk offsetsBlobReadernow returnsblob.stream(), orblob.slice(offset, end).stream()for a range,
instead of reading the data inchunkSizeslices throughreadUint8Array()- When range requests are used, i.e. with
HttpRangeReaderor with theuseRangeHeaderand
forceRangeRequestsoptions ofHttpReader, the data of an entry is now read with range requests
of 16MB at most whose response bodies are streamed, instead of one range request perchunkSize
bytes. Reading a 4GB entry sends 256 requests instead of 65536, and no request is ever sized after
the entry. This requiresfetch, theuseXHRoption still reads the data chunk by chunk - Add the
maximumRangeSizeoption toHttpReaderandHttpRangeReaderto tune the size of these
range requests, e.g. to lower it behind a proxy closing long-lived responses - These two changes only affect how the bytes are obtained: the chunks emitted by the platform are
still normalized tochunkSizebefore reaching the codec, and the chunks received by writers are
unchanged - Add the
closeDisk()method toSplitDataWriterto close the disk being written, the next
disk being opened when more data is written - Add the
checkResourceChangesoption toHttpRangeOptionsand theERR_HTTP_RESOURCE_CHANGED
error constant: range requests now detect a resource modified while being read by comparing the
ETag,Last-Modifiedand total size headers against the ones returned by the first request - Add
resetConfiguration()to restore the default configuration of zip.js
Behavior changes
checkResourceChangesdefaults totrue, so reading an HTTP resource that changes mid-read now
throwsERR_HTTP_RESOURCE_CHANGEDinstead of silently producing corrupt data. Headers missing
from the responses are ignored; note thatAccess-Control-Expose-Headersmust include them when
the resource is fetched cross-origin- Entries requiring no codec work at all, i.e. no compression, no CRC-32 and no encryption, now
always bypass web workers. They previously went through a worker whentransferStreamswas
enabled, i.e. by default. In practice this covers reading stored entries without the
checkSignatureoption, andpassThroughtransfers; entries needing the CRC-32, which includes
every entry written byadd()withoutpassThrough, still go through a worker - Writers always receive a
Uint8Arraythat owns its entire buffer, sochunk.bufferinside a
customwriteUint8Array()implementation is the chunk and nothing more - Non-split writers no longer get
diskNumber,diskOffset,availableSizeandmaxSize
properties assigned on them byZipWriter - The
chunkSizeoption ofcreateReadable()defaults to thechunkSizevalue of the global
configuration instead of a hardcoded 64KB. It only applies to the default implementation, the
readers overriding it emit chunks sized by the platform
Fixes
- Fix
configure({ transferStreams })being silently ignored: the option was documented and
honored per entry, but absent from the list of configurable properties, so it could not be set
globally. It is now a global option defaulting totrue - Fix the
chunkSizeoption being ignored when the codec runs without a web worker: the codec
output is now rechunked in that path too - Fix reading zip64 archives whose end of central directory record is not on the last disk: the
disk number is now read from the zip64 end of central directory locator instead of being assumed - Fix
prependZip()writing a wrong zip64 offset flag and leaking the disk numbers of the source
archive into the central directory of the new archive - Fix
createSyncAccessHandlebeing mangled away in the minified builds, which broke
createOPFSTempStream()indist/*.min.js,index.min.jsandindex-native.min.js - Make the error message reported for uncaught errors more informative
- Fix the web worker configuration of the test suite in
distmode - Fix the
build-devconfiguration, broken by the removal of mini-lz
Performance
- Make
ChunkStreamaccumulate a queue of pending chunks instead of concatenating into a growing
buffer, which removes the copies that the iterative rechunking introduced in 2.8.27 still made
on every incoming chunk - Copy a chunk sent through the web worker message protocol only when it is a partial view of its
buffer, and stop copying chunks received from a worker - Return the cached data view instead of a copy when an HTTP read is served from the buffer
- Remove the redundant copies made when reading extra fields
- Initialize the reader lazily when prepending a zip file, so nothing is read if no entry is added
- Let rollup drop the default configuration table from the web worker bundles
Build and packaging
- Derive the property names reserved from minification instead of maintaining them by hand: they
are now collected from thelib.dom/lib.webworkerTypeScript declarations, the export table of
the WASM module,index.d.ts, and an explicit list of the names crossingpostMessage - Fail the build when the set of mangled property names changes, so a name newly exposed at a
boundary has to be audited instead of being silently renamed in one bundle only - Add a test recording every property name crossing
postMessageduring worker round trips
(deflate, signed, AES-256, AES-128, ZipCrypto, raw password, with and withouttransferStreams)
and asserting each one is declared - Do not publish the
.githubfolder on NPM and JSR
Tests
- Add tests for zip64 split boundaries, HTTP range requests, HTTP resource changes, exact chunks
passed to writers, andSplitDataWriteredge cases - Reset the configuration between tests
- Make the Deno
MessagePortleak repro runnable withdeno test(still reproduced with Deno 2.9.5)
Internal
- Centralize the array helpers in a
util/array.jsmodule
Documentation
- Add a bundle size section to the README documenting tree-shaking and the smaller entry points
- Clarify the meaning of the
nativesuffix in thedistREADME: every bundle uses the native
CompressionStream/DecompressionStreamAPIs when available, the suffix names the
implementation embedded for everything else - Clarify the comment describing the
Blob.slice()workaround inBlobReader
Full Changelog: v2.8.34...v2.8.35