v2.8.60
- New
VERSIONconstant exposing the version of the library at runtime (e.g."2.8.60"). It matches theversiondeclared inpackage.json; the continuous integration verifies the agreement - New
getRegisteredCodecs()function. It returns the definitions of the codecs registered withregisterCodec(), as snapshots that cannot alter the registry. TheCompressionStreamandDecompressionStreamclasses of a codec registered withcodecURIappear in the result once its module has been imported - New
getSupportedCompressionMethods()function. It returns the compression methods supported in the current environment and configuration: the built-in methods resolved against the compression streams available at the time of the call, followed by the registered codecs. Each entry reports thecompressionanddecompressionsupport separately, e.g. Deflate64 is read-only. The support of a codec registered withcodecURIonly is reported asundefineduntil its module is imported - Registered compression codecs now receive the size of the source data as
CompressionStreamOptions#uncompressedSizewhen the reader has a known size. Codecs such as Zstandard can use it as the pledged source size and include the content size in the compressed frame (#675)
- The
zip-fs-corebuild now exports the full core API. It previously exported only the filesystem classes, soconfigure(),registerCodec(), the reader and writer classes, and the constants were unreachable from this build
- The
Readerclass documents how to implement random access to files opened with the runtime APIs, with a Deno example - The
offsetandusdzoptions are documented as read when theZipWriteris created and ignored when passed toZipWriter#add, and the default value ofoffsetread fromWriter#sizeis documented
- New tests cover the registered codec snapshots, the codec constructor options transmitted to web workers, the
VERSIONconstant, and the supported compression methods including the deferred resolution ofcodecURIcodecs - The version bump now rebuilds the bundles so the published files embed the version, and the continuous integration verifies that the version constant agrees with the declared versions
- Thanks to @xqdoo00o for implementing the
uncompressedSizeoption of the compression codecs (#675) - Claude (Fable 5) contributed to every other change listed above
v2.8.59
- New
ZipReader#warningsproperty andwarningsproperty on entries. They report non-fatal anomalies noticed while reading, as an array of{ reason, filename? }objects deduplicated by reason.ZipReader#warningsis replaced on eachgetEntries()call and collects the archive-level observations: an unsorted central directory, an unknown "version needed to extract", the compressed patched data bit, a malformed extra field, unknown zip64 extensible data, and a wrapped 16-bit entry count. The entry-levelwarningsproperty is set bygetData()and collects the local file header observations. The checks controlled by thestrictnessoption deposit a warning with the same reason when a lower strictness tolerates what "strict" rejects: appended or prepended data, trailing central directory data, duplicate filenames, a mismatched zip64 end of central directory record, and local file header mismatches. The warnings only report bytes the parse already read, so enabling nothing costs no additional I/O. The reasons are exported as 14WARNING_*constants - New
isZipFile()function. It returnstrueif the data looks like a zip file, i.e. ifZipReader#getEntriescalled on the same data would locate the archive structure. It runs the same end-anchored search asZipReaderand verifies that a central directory record is stored where the end of central directory record points, without parsing the entries. ThestrictnessandmaxAppendedDataSizeoptions control the tolerated appended data with the same semantics and defaults asZipReader - New
centralExtraFieldoption ofZipWriter#add. It sets an extra field written only in the central directory record, complementing thelocalExtraFieldoption which targets the local file header and theextraFieldoption which targets both
- Leading and trailing whitespace in entry names is now preserved by
ZipWriter#addinstead of being silently trimmed. The zip specification does not restrict whitespace in filenames; note that Windows filesystems cannot represent a trailing space or dot in a name - Unclaimed bytes lying between the last central directory record and the end of central directory record are now detected, even when the declared central directory size matches the records. The "strict" strictness rejects such archives with the
ERR_AMBIGUOUS_ARCHIVEerror and the lower strictness levels deposit the "trailing central directory data" warning. These bytes were previously accepted silently at every strictness level, although the gap can hide records that other readers interpret, e.g. an unadvertised zip64 end of central directory record, and Info-ZIP and 7-Zip both flag such files. The check is skipped when the central directory is encrypted, because the plaintext is legitimately shorter than the stored data
- A new test suite covers the warnings: each reason is triggered by byte surgery on a well-formed zip file and asserted both as a warning at the tolerant levels and as a rejection at the levels that make the corresponding check throw
- New regression tests lock the preserved whitespace in entry names, the
isZipFile()probe, thecentralExtraFieldoption, and the detection of unclaimed bytes before the end of central directory record
v2.8.58
- New
ZipWriter#appendZipmethod. It copies the entries of an existing zip file into the current zip. UnlikeprependZip, it can be called at any position: after entries have been added, betweenadd()calls, and repeatedly to merge several zip files. The central directory of the copied file is rebuilt and its entries are relocated to the positions they get in the output.prependZipis kept as a deprecated alias - New
rawLastModDateoption ofZipWriter#add. It sets the raw MS-DOS date and time of the entry directly, whichpassThroughcopies of ZipCrypto entries need (see below) - New
localDirectory.dataOffsetproperty. It is the byte offset of the entry data, i.e. the entry offset plus the size of the local file header, of the filename and of the extra field. It can be used withReader#createReadableto serve ranged requests into an entry stored without compression - New
ERR_ZIP_CRYPTO_LAST_MOD_DATEerror constant
- Errors of
add()andappendZip()calls left un-awaited are not lost anymore.close()waits for the pending calls and throws the first unreported error, with all of them available in itsentryErrorsproperty. Throwing counts as reporting: catching the error and callingclose()again finalizes the zip file without the failed entries.ZipWriterStreamnow aborts its writable when an entry fails, so the readable errors instead of hanging - An interrupted
appendZip()copy now setshasCorruptedEntrieson the writer and keeps the offsets of the entries written after it consistent - The "version needed to extract" field is now 10 for entries stored without compression or encryption, instead of 20
- Last modification dates before 1980 are now clamped to the MS-DOS epoch instead of underflowing the date field
- The
directoryproperty of read entries is now derived from the trailing slash of the filename alone. A name ending with "/" is a folder even when the entry declares an uncompressed size - Unicode Path and Unicode Comment extra fields are now applied only when their version is 1, as required by section 4.6.8 of the zip specification
- Reading an archive with a multiple of 65,536 entries and no zip64 record now returns all the entries. The 16-bit count of the end of central directory record wraps around; the reader detects the wrap by walking the central directory records past the declared count. The recovery is skipped when the strictness checks reject ambiguous archives
- The
unsafe*optimizations of the minifier were removed from the builds. Two of them shipped real miscompilations in the past, one of which stayed undetected for four years, and the size they saved was about 50 bytes per compressed bundle
- ZipCrypto entries copied with
passThroughcan now be read back with their password. The password verification byte of ZipCrypto depends on the raw date of the entry when a data descriptor is used, so a copy that regenerated the date or forced the descriptor failed withERR_INVALID_PASSWORD. ThedataDescriptoroption is not forced anymore for pass-through ZipCrypto data, the newrawLastModDateoption preserves the raw date, and the filesystem API forwards both when exporting, throwing the newERR_ZIP_CRYPTO_LAST_MOD_DATEerror if the date is overridden - The end of central directory records of split zip files now declare the number of central directory entries stored on the last disk, as required by section 4.4.21 of the zip specification, instead of the total. The count is 0 when the record starts on a fresh disk, which is how Info-ZIP fills the field. The check deciding whether the disk number of the record requires zip64 also accounts for the actual record and comment length when predicting a disk rollover near 65,535 disks
- The spanning signature of split zip files is now written while holding the writer lock. A first entry written with
bufferedWrite, or interleaved un-awaitedadd()calls, could fail on the locked stream or misplace the signature - Duplicate filenames are now detected before the entry waits for a worker slot. Two
add()calls with the same filename made while the worker pool was saturated could both be accepted
- The
usdzoption states that its constraints apply to the entries written withadd()only. The entries copied withappendZipkeep the layout of the source zip file and are not checked - The
ZipReaderconstructor states that a stream input is buffered entirely in memory, because reading a zip file requires random access, and points at customReaderimplementations for large seekable resources WritableWriter#sizestates that a value set before the first write is used as the starting offsetuseUnicodeFileNamesstates that disabling it only clears the language encoding flag and does not re-encode the filenamespassThroughdocuments the coupling between ZipCrypto and the last modification datemsDosCompatibledocuments how PKUNZIP handles folder entries
- New PKZIP 1.10 and PKZIP 2.04g fixtures (attributes, comments, spanned archives) with tests reading the archives produced by the original tools
- New regression tests lock the fixes above: the spanning signature position with concurrent and buffered writes, the per-disk entry counts of spanning central directories, including in the golden output, the ZipCrypto pass-through copies, the queued duplicate names, and the retryable
close() - The Safari suite retries up to four times, the ZipCrypto tests are immune to date and wrong-password flakes, and the test fixtures are resolved independently of the working directory
- The dead extra field handling of the
appendZipentry rebuild was removed, making it explicit that copied entries carry their extra fields verbatim
v2.8.57
- New
ERR_UNSUPPORTED_UINT64error constant
- Folders and empty stored entries are now written without a data descriptor. Their checksum and sizes are zero and known before the data is written, so bit 3 of the general purpose bit flag and the descriptor declared nothing, and other writers, e.g. Info-ZIP, leave them out. The local file header now carries the zeroed values directly, which shrinks every folder by the length of the descriptor. Those entries are also written directly instead of going through the buffered write path, since there is nothing to buffer. The descriptor is still written when the
dataDescriptoroption is set explicitly, and for encrypted entries - Reading an archive that declares a 64-bit value above
Number.MAX_SAFE_INTEGERnow throws the newERR_UNSUPPORTED_UINT64error. JavaScript numbers lose integer precision above 2^53 - 1, so a size or an offset that large was silently rounded to a nearby value and every computation derived from it was wrong. No valid archive is affected, such values describe contents beyond 8 PB
- The central directory records rebuilt by
ZipWriter#prependZipnow keep the zip64 layout of the source entries. The zip64 fields were selected again from the sizes of each entry, so a record whose source stored, e.g., only one of its sizes in the zip64 extra field was rebuilt with a different layout, and the zip64 field left in the raw extra field of the entry could be written twice. Prepending an archive and adding entries now produces the same bytes as writing all the entries directly - The InfoZip Unix extra field now stores both ids when only one of the
uidandgidoptions is set, the missing one defaults to 0. The field used to declare the missing id with a length of 0, a layout Info-ZIP never writes and readers are not required to accept
unixExtraFieldTypenow states that the filesystem API re-emits the uid and gid of imported entries as "infozip" whatever the field type found in the imported zip file, unless the option is set explicitly
- The browser testing workflow was improved by @danny0838: the browser driver is determined automatically, the download URL of old Chromium versions is computed from the version, and the runner works on Windows (#674)
- The web test runner now waits for the cleanup of the test frames before removing them and reports the in-flight tests when a run fails, and the old Chromium versions of the matrix are pinned to their snapshot position
- The worker backpressure test now registers a codec that never signals backpressure and measures a deterministic bound on every runtime, instead of relying on the margin left by the native codec of each engine
- New regression tests lock the fixes and changes above: the data descriptor rules for folders and empty stored entries, including the golden output, the zip64 layout of prepended entries, and the layout of the InfoZip Unix extra field when a single id is set
- A new test locks that
ZipWriter#removereturnsfalsefor an entry whoseadd()is still in flight and that the entry is written normally
v2.8.56
- The compression method stored in the WinZip AES extra field is no longer truncated to its low byte. The field declares the actual compression method of an encrypted entry in a 16-bit slot, and it was written with a single byte store. An encrypted entry using a method above 255, which a codec registered with
registerCodeccan use, announced a different method, so readers selected the wrong codec after decrypting. Registered codecs exist since v2.8.37 - Writing an entry with the
usdzoption now throwsERR_INVALID_EXTRAFIELD_DATAwhen the extra field could exceed 64KB once the alignment padding is added. The padding is computed after the length check and adds up to 67 bytes, so an extra field close to the limit wrapped the 16-bit length field and produced a corrupt entry - The central directory written by
ZipWriter#prependZipnow points at the prepended entries when the writer has an initial offset. The offsets were computed from the source archive alone, so an archive written with theoffsetoption, or into a writer already holding data, declared offsets short by that initial offset and the prepended entries could not be read back. The two features could be combined since v2.7.71 - The digital signature record is now written within a single segment of a split archive. It could start at the end of one segment and continue in the next, unlike every other record, because only the end of central directory record checked the remaining space before being written. The writer now closes the disk first for the signature record as well. Signing is available since v2.8.47
ZipReader#digitalSignatureis now defined on a split archive whose central directory starts on an earlier disk than the end of central directory record. The reader looked for the record in the bytes read for the central directory, which stop at the declared directory length in that case, so the signature was never found. The record is now read from the file when it does not follow the directory in those bytesZipDirectoryEntry#getExportedSizenow throwsERR_UNDETERMINED_SIZEwhen the predicted size depends on the order the entries are written. The zip64 fields of an entry depend on its offset, so when the entries total more than 4GB and the write order is not guaranteed, e.g.keepOrderset tofalse, two orders can produce two sizes. The detection walked the entries in enumeration order, so it missed layouts where only another order crosses the threshold, and the exported archive could differ from the prediction. The prediction is available since v2.8.52ZipDirectoryEntry#getExportedSizenow honors theoffsetoption. The option shifts the offsets stored in the central directory, which select the zip64 fields, and the prediction computed them from zero. Predicting an export withoffsetat 4GB or above returned a size short by the zip64 records the export actually writes
CodecDefinition#codecURInow states that bundlers and single-file builds, e.g.deno compile, cannot follow the dynamic import of the codec module, so the module must be included explicitly, withdeno compile --includeor the equivalent option of the bundler
- Every fix above is locked by a regression test: an encrypted round trip with a registered method above 255, a
usdzentry with an extra field near the 64KB limit,prependZipinto a writer with an initial offset, a sweep of segment sizes checking the placement and the read back of the digital signature record on split archives, and size predictions with order-dependent zip64 layouts and with theoffsetoption
v2.8.55
- New
ERR_UNDEFINED_COMPRESSION_METHODerror constant
The two passThrough rules below change what the option accepts. Code that copies entries between archives by passing the compression method of the source entry, which is what the filesystem API does, is unaffected.
- Writing an entry with the
passThroughoption now requires thecompressionMethodoption, and throws the newERR_UNDEFINED_COMPRESSION_METHODwhen it is missing. The data is copied as-is, so that option selects no codec, it declares how the data is already compressed and is written into the headers of the entry verbatim. It used to fall back to Deflate whatever the data was, so copying a stored entry without setting it produced an archive announcing Deflate over stored bytes, which no reader can decompress. Copying an entry read withZipReaderis a matter of passing itscompressionMethodalong. The entries with no content, e.g. the directories, ignore the option, as they ignorepassThroughitself - The
leveloption is now ignored for the entries written withpassThrough. The data is never compressed, so the option describes nothing, and yetlevelset to 0 used to select the compression method written in the headers, stored instead of Deflate, and any level used to set the level bits of the general purpose bit flag. SetcompressionMethodto declare how the data is compressed.levelkeeps applying to the other entries of the same archive, so exporting a filesystem withlevelset andpassThroughset in the reader options still compresses the entries that were added to it and copies the entries that came from a zip file - The
decryptCentralDirectorycallback now receives the encrypted central directory alone. It used to be given the whole declared range of the directory, which also holds the digital signature record when the archive is signed, so the callback was handed bytes it cannot decrypt. The length is taken from the encryption header of the zip64 end of central directory record when it declares one, and falls back to the declared length of the directory. The callback has been given the whole range since it was introduced in v2.8.47
- Reading an archive whose central directory is encrypted no longer moves the directory somewhere else. The reader checks that the offset declared in the end of central directory record points at a central file header, and an encrypted directory carries no such signature, so the check failed and the offset was reconciled to another position. The offset is now trusted as well when the encryption header declares the size of the encrypted directory, and when the bytes at the offset look like an encrypted directory
- The extensible data sector of the zip64 end of central directory record is now counted in the length of that record. The sector holds the encryption header of an encrypted central directory, and the reader subtracted the fixed length of the record only, so the computed end of the central directory sat past its real end by the length of the sector, and every offset derived from it was wrong
ZipReader#digitalSignatureis now defined on an archive whose central directory is encrypted. The digital signature record follows the encrypted directory, so it is not part of what the decryption returns, and the reader looked for it in the decrypted bytes only- The local file headers masked by PKWARE strong encryption no longer make
FileEntry#getData()throwERR_AMBIGUOUS_ARCHIVE. When the central directory is encrypted, the local file header of an entry carries a placeholder filename and a zeroed checksum and sizes, and says so with bit 13 of its general purpose bit flag. The comparison against the central directory record that became the default in v2.8.53 rejected those archives. The filename, the checksum and the sizes are now left out of the comparison for those entries, the general purpose bit flag and the compression method are still compared - The published bundles no longer set the level bits of the general purpose bit flag on the entries written with the default compression level.
index.min.jsand the files ofdist/announced "super fast" on every Deflate entry whoseleveloption was left unset, where the sources announce nothing. The minifier was configured withunsafe_comps, enabled in February 2022, which rewrites a comparison into its negation:!(0 > level)is true for an undefined level wherelevel >= 0is false. Those bits are advisory and no reader decompresses differently because of them, but an archive written by a bundle differed from the same archive written from the sources. The option is dropped from both minifier configurations, which costs 40 bytes onindex.min.js
ZipReader#digitalSignaturenow describes what the signature covers: the records of the central directory, read atZipReader#directoryOffset, never including the digital signature record itself. zip.js does not verify signaturesZipReader#directoryLengthnow warns that some writers, e.g. SecureZIP, count the digital signature record in the length they declare, so verifying the whole declared range can never succeed. Subtract6 + digitalSignature.lengthfrom it when the record is stored inside the declared range- The
passThroughoption now describes howlevelandcompressionMethodare treated, and states that the compression method is written into the headers as-is instead of selecting a codec ZipReaderStreamnow states that it reads its input entirely into aBlobbefore it emits the first entry, since a zip file stores its central directory at the end. It is a convenience wrapper aroundZipReaderfor stream sources, it does not extract the entries while the data is still arriving
- New fixtures written by SecureZIP cover the strong encryption formats: AES-128, AES-192 and AES-256, stored and Deflate64 entries, an encrypted central directory, a certificate-based archive, a signed archive and an archive mixing encrypted and clear entries. They are read by the tests of
decryptCentralDirectoryand by the SecureZIP archive tests - A new fixture written by a third-party tool covers a zip64 entry whose sizes are stored in a data descriptor
- The zip64 fixture of the HTTP test is rebuilt with real zip64 records, the previous one carried none although the test was named after them
- The writer backpressure test now registers a codec that never signals backpressure on its writable side, instead of forcing the native one. It measured the invariant on Bun only, where the native
CompressionStreambehaved that way, and stopped measuring anything once Bun 1.4.0 fixed it. The registered codec keeps the test meaningful on every runtime - A new test locks the two
passThroughrules above: the compression method is required, the level is ignored, and the level keeps applying to the other entries of the archive
v2.8.54
ZipWriter#prependZip()now reads an array of readers as the disks of a split zip file, which is what an array denotes everywhere else in the API, and accepts aSplitDataReaderinstance the same way. The disks are read in order and the entries are relocated to the positions they get in the output. An array used to be concatenated and read as a single archive, which produced wrong offsets for a real split zip file. If you were passing an array of byte ranges of one zip file, concatenate them yourself and pass a single readerZipEntry#moveTo()is removed. It was deprecated and undeclared in the TypeScript definitions, and was a one-line alias ofZipFS#move(), which is the method to use- The undeclared
ZipFS#addData()andZipDirectoryEntry#addData()methods are removed. They were internal, never documented and never declared. The typedaddText(),addBlob(),addUint8Array(),addData64URI(),addHttpContent(),addReadable(),addFile(),addFileSystemEntry()andaddFileSystemHandle()methods cover what they did
Both fixes below are reachable from an untrusted zip file read with ZipReader. Upgrading is recommended for anyone reading archives they did not produce.
FileEntry#getData()now throws the newERR_ENTRY_DATA_OUT_OF_BOUNDSwhen the declared data of an entry, i.e. its offset plus its compressed size, ends past the end of the zip file. Such an entry used to makegetData()hang for ever, with no error and no CPU use, so nothing timed out and nothing showed up in a profile. Honestly truncated archives are affected as much as malformed ones. A read past the end of the source now ends the stream instead of stalling it, which also covers the entries the bounds check cannot detect in advance- The output of
FileEntry#getData()is no longer allocated from the declared uncompressed size of the entry. The size was reserved before a byte was read, so a 131-byte archive declaring 3 GiB reserved 3 GiB. The allocation is clamped to what the compressed data can decode to,compressedSize * 1032for a compressed entry andcompressedSizefor a stored one, 1032 being the maximum expansion ratio of Deflate. The clamp never binds on real data, a legitimate archive still preallocates exactly its uncompressed size
ZipFS,ZipEntry,ZipFileEntryandZipDirectoryEntryare now exported at the top level, and thefsnamespace is deprecated. Replacenew zip.fs.FS()withnew zip.ZipFS(), andzip.fs.ZipFileEntrywithzip.ZipFileEntry.zip.fskeeps working and the library emits no runtime warning, the deprecation is documentation only.ZipEntryis now a value as well, soentry instanceof zip.ZipEntryworks. The three entry classes were already declared as top-level exports but existed at runtime underzip.fs.*only, so importing them type-checked and then failed. In TypeScript, theFStype is deprecated and kept as an alias ofZipFS, solet fs: FSkeeps compiling- New
ZipEntry#setOptions()method andZipEntry#optionsproperty in the filesystem API.setOptions()merges the options into the ones the entry was added with, an option set toundefinedbeing removed instead of stored, and they are applied when the zip file is exported. It is the way to set the options of an entry imported from a zip file, which has none until it is called. The options describing the data of an entry exported withpassThrough, e.g.compressionMethodanduncompressedSize, are ignored, they are always the ones of the original entry, and so aredirectoryand the progress callbacks ZipWriter#prependZip()now writes a correct split zip file when the writer is a split zip file writer. The whole prepended archive used to be copied into the first disk, so every entry recorded an offset on the wrong disk. The data is copied disk by disk now, a disk is closed before an entry whose local file header would not fit in what is left of it, and each entry records the disk it starts on and its offset in that disk. The output also starts with the split zip file signature, unless the prepended zip file already carries oneTextWriternow decodes CP437.new TextWriter("cp437")used to return the data decoded as UTF-8, since the encoding was handed toFileReader#readAsText(), which falls back to UTF-8 for a label it does not know. It goes through the same decoder as the filenames and the comments now. It also decodes withTextDecoderinstead ofFileReader, which removes the last dependency on that class, missing from some worker scopes. The byte order mark is still removed, whichever branch decodes the data- The second argument of the codec stream constructors is now typed, by the exported
CompressionStreamOptionsandDecompressionStreamOptionsinterfaces. They document which members are set for which class, e.g.deflate64only for the deflate implementations, andrawBitFlag,compressionMethodanduncompressedSizeonly for the codecs registered withregisterCodec().Configuration#CompressionStream,Configuration#DecompressionStream, their*Fallbackand deprecated*Zlibforms andCodecDefinitionare declared with them instead of the untypedTransformStreamLike. This only concerns you if you pass a custom stream implementation or callregisterCodec() Configuration#baseURIis now declared. It resolves the relativeworkerURI,wasmURIandcodecURIvalues, and defaults to the URL of the module of zip.jsWritableWriter#sizeis now declared. zip.js sets it to 0 before the first write and keeps it updated, so a customWritercan read how many bytes have been written so far, e.g. to compute the offset of a disk. It is declared onWriter,TextWriter,BlobWriter,SplitDataWriterandUint8ArrayWriteras well- Members that existed and were not declared:
HttpReader#url,TextWriter#encoding,BlobWriter#contentType,Data64URIWriter#contentType,EntryError#overlappingEntryandEntryError#reason.overlappingEntryis the only way to identify the other entry of the pair reported byERR_OVERLAPPING_ENTRY, andreasondescribes the ambiguity reported byERR_AMBIGUOUS_ARCHIVE
The options listed first used to accept values of the wrong type and produced a wrong, empty or silently dropped result. They throw now. If your code passes the documented types, nothing changes.
lastModDate,lastAccessDateandcreationDatemust beDateinstances and throw the newERR_INVALID_DATEotherwise. An invalidDateused to be written as an entry carrying no timestamp at all. A timestamp expressed in milliseconds is the natural mistake and is rejected as well: passnew Date(file.lastModified), notfile.lastModified- The
commentoption of an entry must be a string and throws the newERR_INVALID_ENTRY_COMMENT_TYPEotherwise. AUint8Arrayused to be coerced and its textual representation written into the archive. Decode the bytes to a string before passing them - The
extraFieldoption must be aMap, and throws the newERR_INVALID_EXTRAFIELDotherwise. Its keys must be integers between 0 and 65535, andERR_INVALID_EXTRAFIELD_TYPEnow covers a non-integer or a negative key as well as a key above 65535. Its values must beUint8Arrayinstances, and throw the newERR_INVALID_EXTRAFIELD_DATA_TYPEotherwise - The
readerOptionsoption ofZipDirectoryEntry#export*(),ZipDirectoryEntry#getExportedSize()andZipDirectoryEntry#exportFileSystemHandle()must be an object and throws the newERR_INVALID_READER_OPTIONSotherwise. A value of another type was silently ignored: a password passed as a string instead of an object failed with the unrelatedERR_ENCRYPTED, while the other options were dropped without any error. An unknown property of areaderOptionsobject is still ignored, as everywhere else in the API - The options expecting a function throw the new
ERR_INVALID_FUNCTION_OPTIONwhen they are given a value of another type:encodeText,decodeText,createTempStream,signCentralDirectoryanddecryptCentralDirectory. A falsy value keeps meaning "use the default" - The
signaloption throws the newERR_INVALID_SIGNALwhen it does not look like anAbortSignal, i.e. when it does not expose anaddEventListener()method and a booleanabortedproperty. Duck-typed signals and signals coming from another realm keep working - The
passwordandrawPasswordoptions are now checked on the reader side as well, throwingERR_INVALID_PASSWORD_TYPE. A value of another type used to fail with the unrelatedERR_ENCRYPTEDorERR_INVALID_PASSWORD msdosAttributesRawthrowsERR_INVALID_MSDOS_ATTRIBUTESwhen the value is not an integer, and accepts a numeric string like the other numeric options. The range check used to be the only one, and the bitwise arithmetic folding the value into the external file attributes did the rest quietly: a fractional value was truncated, and a value that is not a number at all passed both comparisons and was written as 0.msdosAttributesthrowsERR_INVALID_MSDOS_DATAon an array, which used to be accepted as an object and wrote 0 as well, since none of the flag properties exist on itconfigure()andsetDefaultConfiguration()reject two kinds of bad input instead of storing them.maxWorkersmust be an integer greater than 0 and throws the newERR_INVALID_MAX_WORKERSotherwise: a value lower than 1 used to deadlockZipWriter#add()for ever, since no entry could start and none could release the next one.createWorkerand theCompressionStreamandDecompressionStreamoptions, including their*Fallbackand deprecated*Zlibforms, must be functions and throwERR_INVALID_FUNCTION_OPTIONotherwise, a falsy value still meaning "use the default". The numeric options accept a numeric string and are coerced, like the numeric options of the reader and the writer. Nothing is stored unless the whole call passes, so a rejected call leaves the configuration untouchedchunkSizeis normalized wherever it is read. A value lower than 64 is raised to 64, as before, and a value that is not an integer greater than 0 now falls back to the default of 65536 instead of being used as it is. This applies to the global configuration and to thechunkSizeoption ofReader#createReadable()
The rest of this section changes results rather than rejecting input.
- The configuration is read when it is used instead of when the reader or the writer is constructed. A
configure()call made betweennew ZipWriter()and the firstadd(), or betweennew ZipReader()and the firstgetData(), used to be ignored and is honored now. It affectsmaxWorkers,chunkSize, the compression stream implementations and the deflate support detection - The
executableoption now counts as Unix metadata, likeunixMode. It means a mode of0o755, and it was the only Unix metadata option taking the MS-DOS branch, so an entry written withexecutableset next tomsDosCompatible,msdosAttributesormsdosAttributesRawlost its executable bit without a word. It wins over the three of them now, and selects the Unix platform for the "Version made by" field.executableset tofalsechanges nothing, as before - The entries of the filesystem API are dated when they are added, not when they are written. An entry added without a
lastModDateoption used to be stamped with the current date at export time, so exporting an unchanged tree twice produced different bytes. The four sources of the date of an exported entry now rank as follows, weakest first: the moment the entry was added, the date of the entry the tree was imported from, thelastModDateoption passed to the export, and thelastModDateoption passed when the entry was added - The directories implied by the name of an imported entry are no longer written back when the tree is exported. Importing a zip file storing
"a/b.txt"and no directory entry creates a navigable"a"entry, which used to be exported as an entry of its own, so a round trip gained one entry per path component. Only the directories carried by the source zip file and the ones created withaddDirectory()are written now.getExportedSize()and the progress callbacks count them the same way - The options passed when an entry was added no longer override the values describing the data of an entry exported with
passThrough.compressionMethod,uncompressedSizeand the other pass-through values now win over the per-entry options, as they already did over the options passed to the export - The options passed when an entry is added are now copied. The object was stored as it was, so mutating it afterwards, or reusing one object for several entries and mutating it in between, changed entries that had already been added
- The split zip file signature at the start of a zip file is no longer reported as prepended data. A single-disk archive written by
SplitDataWriterstarts with the four bytesPK\x07\x08, which used to be read as prepended data byextractPrependedDataand rejected as an ambiguous archive bystrictnessset to"strict"or bycheckAmbiguity. The temporary spanning markerPK00, which PKZIP writes at the start of the first disk while a spanned archive is being created, is accepted the same way. If you read archives produced bySplitDataWriterwith either of those options, they are no longer misreported
ZipWriter#prependZip()no longer copies the central directory of the zip file it prepends. The whole source was piped into the output, then the entries were rewritten after it, so every prepended archive carried its old central directory as dead bytes in the middle of the result. Only the data region is copied now, i.e. everything before the first byte of the central directory. Archives already produced this way are still readable, they are only larger than they need to beZipWriter#prependZip()reads the zip file it prepends once instead of twice. A reader providingreadUint8Array()was buffered into aBlobbecause the central directory was read throughreader.readable, so aBlobReaderor anHttpRangeReaderwas fully downloaded into memory before anything was written- The transferred streams are no longer broken in a web worker installing a polyfill of the Streams API, the setup documented under
Configuration#createWorkerbelow. The worker received a nativeReadableStreamand a nativeWritableStreamthroughpostMessage()and piped them into streams of the polyfill, which rejected them. They go through the same compatibility wrappers as the streams created in the worker now
msdosAttributesRawandmsdosAttributesnow describe the platform they select. The behavior is unchanged: setting either of them selects the MS-DOS platform for the entry exactly asmsDosCompatibleset totruedoes, and overrides that option when it is explicitly set tofalse, soversionMadeByloses its Unix upper byte and no Unix mode is written. What counts is that the option is provided, not its value, so0and{}select it too. Any Unix metadata option wins over the three of them, with the MS-DOS attributes written into the low byte, see theexecutablechange aboveZipWriter#prependZip()now states that the data of the zip file is copied, its central directory rebuilt and its entries relocated, so the disks of a split zip file passed as input are unrelated to the disks of the outputZipReader#commentand thecommentoption of an entry now explain why one is bytes and the other a string. The encoding of the comment of an entry is recorded in its header by the general purpose bit 11, the encoding of the global comment is recorded nowhere, so it can only be decoded with the encoding agreed with the producer of the zip fileConfiguration#createWorkernow documents how to install a polyfill of the Streams API in the scope of the worker, which is the way to run the web workers on the engines whereTransformStreamis missing from that scope, e.g. Firefox before version 102. A polyfill imported by the page does not help, because the worker reads the globals of the Streams API from its own scopeConfiguration#workerURInow states that 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 workerZipDirectoryEntryExportOptionsnow documents the precedence of the four sources of the last modification date of an exported entry, andZipDirectoryEntry#importZip()documents that the directories implied by an entry name are not written backFile#lastModifiedis now a link to MDN in the generated documentation, instead of an unresolved reference
- A new audit checks that every property name reaching the public API is either declared in
index.d.tsor mangled on purpose. It reads the terser configuration and the declarations, walks the objects the library builds at runtime and reports the names belonging to neither list. It found eight internal fields shipped under their source names in the minified builds, e.g. the pending characters ofData64URIWriterand the source blob ofBlobReader, which are mangled now, two of them renamed on the way. The parameter names of the declarations are no longer reserved either: a parameter name is not a property name, and reserving it kept a field of the same name readable in every build - The internal methods writing the records of a zip file are renamed away from the DOM property names they shared, so that they are mangled instead of being kept by the terser reserved list
- Every public class is instantiated by the audit, so a member appearing only on an instance is covered. The classes reached only through a subclass, e.g.
ZipEntry, are matched by walking the prototype chain - The deprecated
checkSignatureoption is covered by a test of its own, and the rest of the suite usescheckCrc32. The option had lost all its usages when the tests were swept, so nothing exercised it any more - The
zip.fsnamespace is covered by a test of its own, for the same reason - The polyfill of the Streams API in the worker is tested with a classic worker, a module worker and the native build, one test per build since the WASM worker and the native worker bundle different codecs. The web runner gained a
nativeBuildfeature probe and caches the build probe instead of running it per test - New tests: the entries whose declared data extends past the end of the archive, the options of an entry of the filesystem API, the pass-through values against the per-entry options, the stability of the dates of an exported tree, the directories implied by an imported entry name, the encoding of
TextWriter, the single read ofprependZip(), the bytes it copies, its split zip file output, and the strictness of the split zip file signature - An option validation assertion is split into a test file of its own, since it needs the
signaloption ofpipeTo(), which Chrome 76 to 79 ignore. The runner skips the file there rather than reporting a failure - The release is now scripted.
npm run bump-patchbumps the version inpackage.json,package-lock.jsonanddeno.jsonand commits it, the version script of npm syncingdeno.json. A workflow step verifies that the three declared versions agree, and the release workflow verifies that the released tag matches the version declared inpackage.json
- Andrew Chin, Brian J Lee and Youngjoon Kim, SSLab at Georgia Tech, reported the declared uncompressed size of an entry driving the allocation of the output
- Claude (Opus 5) contributed to every change listed above
Full Changelog: https://github.com/gildas-lormeau/zip.js/compare/v2.8.53...v2.8.54
v2.8.53
- New
checkLocalDirectoryoption in the reader options. It compares the local file header of an entry against its central directory record whenFileEntry#getData()is called, and throwsERR_AMBIGUOUS_ARCHIVEwhen the two disagree.truecompares the filename, the general purpose bit flag, the compression method, the CRC-32 checksum and the sizes, likestrictnessset to"strict";falsecompares nothing, like"tolerant". Setting it explicitly always wins overstrictness, whetherstrictnesswas passed to the constructor ofZipReaderor to the call, so it is the way to ask for this one check without the archive-level checks ofcheckAmbiguity, and the way to drop it without giving up the other checksstrictnessperforms. It is also the only way to validate the local file headers of a self-extracting archive, sincecheckAmbiguityrejects prepended data outright - The local file header of an entry now reports the two records the reader had already read and dropped.
LocalDirectory#rawFilenameholds the filename stored in the local file header, which is allowed to differ fromEntryMetaData#rawFilename, and is defined whenstrictnessis"strict"orcheckLocalDirectoryistrue.LocalDirectory#dataDescriptorholds the data descriptor record written after the content, described by the newLocalDataDescriptorinterface, and is defined whencheckOverlappingEntryorcheckOverlappingEntryOnlyis set. It carries the CRC-32 checksum and the sizes stored in the record, each of which is allowed to differ from the central directory, and asignatureflag telling whether the record is preceded by its optional signature. That signature is not part of the original format, it is a later convention writers are free to follow. When the four bytes look like the signature but the values behind them disagree with the central directory, the flag isfalseand the record is read as starting at those four bytes instead - The parsed extra field records are now typed instead of being declared as the bare
EntryExtraField.EntryExtraFieldZip64,EntryExtraFieldNTFS,EntryExtraFieldExtendedTimestampandEntryExtraFieldUnixdescribe the members the reader fills in,EntryExtraFieldUnicodegainsversion,filenameandcomment, andEntryExtraFieldAESgainscompressionMethod, the real compression method of the entry, next tooriginalCompressionMethod, which is the99a WinZip AES header is required to carry in its place SplitDataReadernow accepts an array ofReaderinstances, ofReadableReaderinstances or ofReadableStreaminstances. The last two were declared in the TypeScript definitions and worked nowhere: reading a split archive requires the size of every disk to map a global offset onto one of them, so an element that only provides a stream is now buffered when the reader is initialized. This applies wherever an array of readers is accepted, i.e. the constructor ofZipReader,ZipWriter#add(),ZipWriter#prependZip(),ZipDirectoryEntry#importZip()and thereaderproperty of aZipFileEntryinstanceZipWriter#prependZip()now accepts a reader that only provides aReadableStream. It reads the central directory of the archive it prepends before piping it, so passing a stream used to fail withTypeError: ReadableStream is already locked. The stream is buffered once, like the disks above- New
ERR_INVALID_COMMENT_TYPEerror constant
- The local file header of an entry is now compared against its central directory record by default, except for the filename.
strictnessset to"balanced", the default, used to trust the central directory record entirely;getData()now throwsERR_AMBIGUOUS_ARCHIVEwhen the general purpose bit flag, the compression method, the CRC-32 checksum or the sizes disagree.getEntries()is unaffected, the local file header is only read when the data is. This costs nothing: every one of those fields is read from the local file header anyway to locate the entry data. Only the filename is left out, because comparing it reads the filename bytes as well, which costs one extra read per entry whenever the local file header carries no extra field, the common case."strict"still compares the filename too,"tolerant"still compares nothing, andcheckLocalDirectoryset tofalserestores the previous behavior. The new default was verified against 458,000 entries of real archives, where it rejects none of them - An explicit
checkAmbiguitynow wins over an inheritedstrictness.checkAmbiguityis the boolean form ofstrictness,truemeaning"strict", and the two used to be resolved without regard to where they came from, so acheckAmbiguitypassed togetEntries()or togetData()could not relax astrictnesspassed to the constructor ofZipReader. A value passed to the call now wins over a value passed to the constructor, andstrictnessstill wins overcheckAmbiguitywhen both are passed to the same one.checkAmbiguityset tofalsemeans "not strict" rather than "trust everything", so it downgrades an inherited"strict"to"balanced"and leaves an inherited"tolerant"alone; passstrictnessset to"tolerant"to compare nothing. Code that passesstrictnessand nevercheckAmbiguityresolves exactly as before - The platform byte of the "Version made by" field is now forced instead of being merged into the value given by the
versionMadeByoption. It is set to Unix (3) when the entry carries Unix metadata, i.e. whenuid,gid,unixModeorunixExtraFieldTypeis set, and to MS-DOS (0) whenmsdosAttributesormsdosAttributesRawis set. Only the lower byte of the given value survives in both cases. It used to be combined with the byte already present, so aversionMadeBycarrying another platform produced a value belonging to neither ZipWriter#close()now throws the newERR_INVALID_COMMENT_TYPEerror when the comment it is given is not aUint8Array. Passing a string, the natural mistake, used to fail deep inside the writer withTypeError: Cannot read properties of undefined (reading 'byteLength'), after the entries had been written.getExportedSize()performs the same check on theglobalCommentoption
- The Unix user and group ids are now read from the local file header when the central directory has none. The Info-ZIP Unix type 2 extra field (0x7855) stores them in the local file header only and leaves a zero-length copy in the central directory, so
uidandgidwere undefined on every archive written by Info-ZIP. They are filled in when the data of the entry is read: they are still undefined aftergetEntries()and appear oncegetData()has run, since that is when the local file header is read, and they are also readable onEntryMetaData#localDirectory. A value read from the central directory is never overwritten by the local file header, since the type 2 field truncates the ids to 16 bits while the New Unix field (0x7875) does not - An empty Info-ZIP Unix type 2 extra field no longer hides the ids of the Info-ZIP New Unix extra field next to it. The reader looked at 0x7875 only when 0x7855 was absent, so an entry carrying both, which is what Info-ZIP writes, reported no ids at all although 0x7875 held them
EntryMetaData#rawLastAccessDateandEntryMetaData#rawCreationDateare now filled from the NTFS extra field. They were declared but never set: the rawFILETIMEvalues were stored on the extra field record only.EntryMetaData#rawLastModDateis unaffected, it remains the MS-DOS date and time stored in the header- The entries returned by
ZipReader#getEntries()now carryrawBitFlag,filenameLength,extraFieldLengthandunixExternalUpper. The four properties were declared onEntryMetaDataand read from the central directory, they were simply dropped when the entry object was built unixExternalUpperis now the upper half of theexternalFileAttributesthe entry was written with, on the entry returned byZipWriter#add(). It was computed before theunixModeoption and the Unix file type were folded in, so it reported the default0o644for every entry, whatever the mode: an entry written with0o120777disagreed both with its ownexternalFileAttributesand with what the reader reports for it- A worker that fails to load now falls back to the main scope instead of throwing a
TypeError. The codec pool builds the worker and its interface, then calls it back one turn later; when theerrorevent of the worker arrived in that interval, the error was dropped and the pool went on to post a message to a worker it had already discarded, which failed withCannot read properties of null (reading 'postMessage'). The designed fallback now runs in that case too, with the error of the worker as the reason. This affects the engines where a worker cannot be started at all, e.g. Firefox extensions using manifest v2 and Chromium 76 to 79 - The entry returned by
ZipWriter#add()now defines the same members as the entries returned byZipReader#getEntries():zip64,symlink,encrypted,zipCryptoandmsDosCompatiblewere left undefined instead offalseon one side or the other, and the deprecatedinternalFileAttributeandexternalFileAttributealiases were missing from it
- The
strictnessoption now lists the fields each level compares, and states which of them are read from the local file header anyway - The
versionMadeBy,msDosCompatibleandunixModeoptions now describe how the platform byte and the Unix file type are chosen, including the fact that a folder entry is always written withS_IFDIRwhatever type the mode carries - The
symlinkproperty now points at the option that writes a symbolic link, since there is no option of that name: the file type goes inunixMode, i.e.0o120777with the path of the target as the content of the entry - Several documented defaults disagreed with the code and were corrected:
maxWorkersfalls back to 2 when the environment provides nonavigator.hardwareConcurrency,workerURIpoints at the worker of the build that was imported, the fourCompressionStreamandDecompressionStreamoptions default to the global implementations or to the one embedded in the entry point,lastAccessDateandcreationDatehave no default at all so that the entries do not carry a meaningless time, andversionMadeBydefaults to 768 rather than 20 preventHeadRequestnow states that leaving it unset is not the same as setting it tofalsewhenuseRangeHeaderorforceRangeRequestsis set: the size is then read from a rangedGETrequest, and only an explicitfalserestores theHEADrequestrawLastModDatenow states that it is the MS-DOS date and time of the header and is not replaced by the value of the NTFS extra field, unlikelastModDate
- A workflow step rebuilds the project on every push and fails when the committed build output differs. The release workflow publishes the committed files as they are, it never rebuilds, so a stale
dist/orindex.min.jsat a tag would ship to npm and JSR. Pull requests are exempt, asking outside contributors to commit build output would add an unreviewable diff to every change - The release workflow now publishes only when the test suite passed on the released commit
- A new audit compares the shapes of the objects the library builds at runtime against the interfaces declared in
index.d.ts, in addition to the audit of the read and write surfaces added in v2.8.52. It is what found the members left undefined and the extra field records declared as the bareEntryExtraField - A regression test covers the backpressure of the writer on the web worker path
- The browser runner restarts the browser and runs the suite again when the session is lost, and its
--headfuloption was renamed to--headed - The Safari job runs on macOS 15 instead of macOS latest, where the browser loses its window or its session in the middle of the suite more often
- The workers are terminated between the tests in the Node.js, Deno and Bun runners, and the Bun runner sets its own timeout
- A test reproduces the ordering that made a failing worker throw instead of falling back, i.e. the error of the worker arriving before the pool sends it its first message
- Claude (Opus 5) contributed to every change listed above
Full Changelog: https://github.com/gildas-lormeau/zip.js/compare/v2.8.52...v2.8.53
v2.8.52
- New
getExportedSize()method onZipDirectoryEntryandFSinstances. It returns the exact size of the zip file the matchingexport*()call would write, without writing it. It takes the same options as theexport*()methods, so the value it returns is the one the export produces. It is meant for theContent-Lengthheader of a streamed download. It throws the newERR_UNDETERMINED_SIZEerror when the size cannot be known before writing, i.e. when an entry is compressed, when an entry has no known size, whensignCentralDirectoryis set, and when thebufferedWriteoption lets the physical layout depend on the order in which the entries are written. Encryption does not prevent the prediction, its overhead is a fixed number of bytes - New
onentryprogressoption in theexport*()methods of the filesystem API. It is called once per written entry with the number of entries written, the total number of entries, and the entry itself. It reports the entries whereasonprogressreports the bytes. It is called after the entry has been written. WhenbufferedWriteis enabled the entries are written concurrently, so it counts the entries written instead of giving the position of the entry in the zip file - New
globalCommentoption in theexport*()methods of the filesystem API. It sets the comment of the zip file. The options of these methods are applied to every entry, so settingcommentthere comments each entry instead of the archive, exactly aslastModDatethere sets the date of each entry. The zip file comment therefore needed a name of its own importZip()now accepts aZipReaderinstance in addition to the data of a zip file. The caller builds the reader, passes it, and keeps it after the import. This is the way to readprependedData,appendedData,comment,digitalSignature,directoryOffsetanddirectoryLength, which are only filled once the entries have been read. The options of the reader are merged with the options of the import, and the options of the import win- New
symlinkproperty on entries. It istruewhen the entry is a symbolic link. The target of the link is the content of the entry, which is read like any other entry, e.g. withgetData(new TextWriter()). The target is not validated, it can be an absolute path or escape the directory of the entry, so it must be checked before being used. Writing a symbolic link is done by setting theunixModeoption to a mode carrying theS_IFLNKtype, e.g.0o120777, with the path of the target as content exportFileSystemHandle()now accepts thereaderOptionsoption. Thepasswordoption must be set there to export the entries of an encrypted zip file, since thepasswordoption of the export encrypts the written entries instead- The
readerOptionsoption of the filesystem export now acceptspassThrough. The entries imported from a zip file are then written as-is, without being decompressed and decrypted, exactly as importing them with this option does. The entries added to the filesystem are compressed as usual - The
signCentralDirectoryoption is now declared in the export options of the filesystem API. It was already forwarded to theZipWriterinstance, it was simply missing from the TypeScript definitions - New
ERR_UNDETERMINED_SIZE,ERR_INVALID_PASS_THROUGHandERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGHerror constants
- The
export*()methods of the filesystem API now report the progress of the whole archive instead of the progress of each entry.onstartandonendare called once, with the total size of the entries and with the number of bytes written. They used to be called once per entry, whileonprogresswas already reporting the archive as a whole, so the three callbacks disagreed with each other.onprogressis unchanged. Use the newonentryprogressoption to be notified for each entry - The export options of the filesystem API now take precedence over the metadata of the entries imported from a zip file. Setting
lastModDate,comment,versionMadeBy,uid,gidor the file attributes in the export options used to have no effect on those entries, althoughunixModeandmsdosAttributesdid reach them, so the same attribute word was writable one way and not the other. The order is now the metadata of the source entry, then the export options, then the description of the entries copied as-is, then the options of the entry. The description of the entries copied as-is stays above the export options because it describes the bytes being copied, not an intent. Alevelor acompressionMethodwinning over it would write headers that do not match the content. An export using the default options is unchanged, so round trips keep their fidelity ZipReader#close()now cancels theReadableStreaminstance passed to the constructor when nothing has been read from it. It used to do nothing at all. The stream of a reader whose entries have been read is left alone, and so is aReaderinstance, which belongs to the caller. The entries stay readable after the call- The
preventCloseoption is now honored only when the caller owns the writable, i.e. when aWritableWriterinstance is passed toexportZip()orexportWritable(). It is ignored by the otherexport*()methods of the filesystem API, whose Writer instance can only return its data once its writable is closed. Setting it there used to prevent the export from ever resolving - Writing an entry with the
passThroughoption and a password now throwsERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH. The data is copied as-is, so it cannot be encrypted. The password used to be ignored silently and the entry was written unencrypted although its header announced encryption - The
passThroughoption is now ignored for the entries with no content.add("dir/", undefined, { directory: true, passThrough: true })used to throwERR_UNDEFINED_READER, so aZipWriterinstance created withpassThroughset totruecould not write a single directory - Writing an entry with the
unixModeoption now stamps the type of the file in the external file attributes. zip.js used to write a mode with no type, e.g.0o000644where Info-ZIP writes0o100644, sounzip -llisted the entry as?rw-r--r--. A mode already carrying a type is left untouched, and theexternalFileAttributesoption still writes the value verbatim - The
executableproperty of an entry is nowfalsefor symbolic links. The permission bits of a link are always0o777, so the flag was meaningless on every link
- Reading a range of data no longer emits empty chunks.
Reader#createReadable()enqueued an empty chunk at the end of every entry whose size is known, and one extra read was issued for an entry of unknown size. The data was correct, the stream simply contained a chunk of length 0 getBlob()andgetData64URI()now honor the MIME type they are given. A filesystem entry holding aBlobinstance returned it as-is, with the MIME type it was created with, and ignored the requested one- The filesystem API now runs the overlapping entry check when
checkOverlappingEntryOnlyis set in its reader options. The option means "run the check and stop before reading the content" in the core API. The filesystem API needs the content, so it used to drop the option and skip the check altogether. It is now mapped tocheckOverlappingEntry, so the check runs and the content is still read - The reader options that withhold the content of an entry are now ignored by the filesystem API.
checkPasswordOnly,checkOverlappingEntryOnlyandpreventCloseused to be forwarded to the entries read from a zip file, which returned no data - Progress is now reported for the filesystem entries that were not imported from a zip file. Reading such an entry pipes the reader to the writer without going through a codec, so
onprogressnever fired. It is now reported for every entry exportFileSystemHandle()now counts the bytes it writes. It used to report the compressed size of each entry against the uncompressed size of the archive, so the progress stopped around 1% of the total, and it reported nothing at all for the entries that were not imported from a zip fileaddFileSystemHandle()now applies the entry options to the directories it creates. They were applied to the files only- The dates of the Info-ZIP unix extra field are now read as signed timestamps. A date before 1970 was read as a date in 2106
- Writing an entry whose name ends with a slash no longer corrupts the
unixModeoption. The type of the file was combined with the type already present in the mode instead of replacing it, so0o100644became a socket and0o120777became an invalid type. Both were then read back as neither a directory nor a symbolic link - The deprecated
externalFileAttributeandinternalFileAttributeoptions work again. They were removed when they were renamed toexternalFileAttributesandinternalFileAttributes. They are back as deprecated aliases, and an option passed toadd()now takes precedence over the option of theZipWriterinstance whatever the spelling of each addText()now stores the size of the text in bytes instead of its number of UTF-16 code units. OnlygetExportedSize()read that value, so the size was under-reported for any text containing non-ASCII characters. The export itself was correct- The buffer reserved for the expansion of the deflate algorithm is now allocated only for the entries that are really compressed. A stored entry reserved the same margin as a deflated one
- The
export*()methods of the filesystem API now keep a running total instead of summing the progress of every entry on every tick. The cost was quadratic in the number of entries. Passingonprogresson an archive of 10,000 entries added 50% to the duration of the export, and now adds nothing measurable
- The
useCompressionStreamoption now states that the native API is used for compression only whenlevelis undefined or equal to 6.CompressionStreamdoes not support compression levels, so any other value compresses the data with the embedded implementation. It also states that the data produced at a given level can vary between platforms, and thatuseCompressionStreammust be set tofalseto get the same output everywhere - The
uidandgidoptions now state which unix extra field carries them ZipReader#close()and thecreateTempStreamoption now describe what they do. A temporary stream must be able to hold a whole entry, because the local header written before it holds the size and the CRC-32 of the entry. Its readable side is therefore consumed only once its writable side has been closed. A factory returningnew TransformStream()deadlocks, whereas the default buffers everything
- The browser test runner uses Selenium instead of Playwright. It accepts
--exe-path,--url-search,--build,--headfuland--help, and thetest-webkitscript was renamed totest-safari - A workflow runs the test suite on every push, including the native build
- A workflow checks that the markdown documentation is up to date with
index.d.ts - The API documentation is published to the GitHub Pages site on each release
- The web runner accepts a
maxParallelTestsparameter. Chromium 87 loses the wake-up of the backpressure of a stream when 16 tests run in parallel, so its jobs cap the parallelism at 4 - The tests that check the abort reason are skipped on the browsers that ignore the signal of
pipeTo()instead of being reported as failures
- @danny0838 contributed the switch to Selenium, the test workflow and the arguments of the browser runner (#673)
- Claude (Opus 5) contributed to every change listed above
Full Changelog: https://github.com/gildas-lormeau/zip.js/compare/v2.8.51...v2.8.52
v2.8.51
getChildren()returns the children of a directory as an array, and all its descendants when therecursiveoption is set totrue. It is available onZipDirectoryEntryandFSinstances. The descendants are ordered level by level, like the result ofreaddir(path, { recursive: true })in Node.js, which is also the order in which the entries are written by theexport*()methods. Unlike theentriesproperty ofFS, the array excludes the root directory, leaves no empty slot for removed entries, and can start from any directory. It is a snapshot taken when the method is called, so the tree can be modified while the array is being iterated
- The
export*()methods of the filesystem API now write the entries in the same order whatever the value of thebufferedWriteoption. Setting it tofalseused to write each branch of the tree entirely before moving to the next one, whereas the default writes the entries level by level, so an archive exported withbufferedWriteset tofalsedoes not have the same entry order as in the previous versions. Only the order changes: the entries, their content and their metadata are identical, and a directory entry still precedes the entries it contains
exportFileSystemHandle()called withconcurrentset totruenow reports the failure that stopped the export on browsers which do not support thereasonargument ofAbortController#abort(), e.g. Firefox 79 and Chromium 87. zip.js used to recognize the cancellation of the sibling entries by the reason it had passed toabort(). These browsers discard that reason and report a plainAbortErrorinstead, so the cancellation was reported as the cause of the failure and the original error was demoted intoentryErrors. The cancellation is now tracked by zip.js itself and never read back from the platform (see #669)exportFileSystemHandle()now rejects with an error instead of rejecting withundefinedwhen the export is aborted through thesignaloption on these browsers. The reason passed toAbortController#abort()is discarded by the platform and cannot be recovered, so aDOMExceptionnamedAbortErroris thrown in its place. Its message is exposed as the newERR_ABORTEDconstant. Testingerror.name == "AbortError"now identifies an aborted export on every supported platform, whereas these browsers used to report a plainErrorwhen the export was aborted before it started and anAbortErrorwhen it was aborted while an entry was streaming
- The API documentation of
exportFileSystemHandle()now states that an entry flagged as a symbolic link is written as a regular file whose content is the path of the link target, since the File System Access API cannot create symbolic links
- The test verifying that the abort reason of the caller is forwarded is now skipped on browsers without support for
AbortSignal#reasoninstead of being reported as a failure. It moved to its own file and covers aborting before the export as well as aborting while an entry is streaming
- @danny0838 reported the failure on Firefox 79 and Chromium 87 and ran the test suite on these browsers
Full Changelog: https://github.com/gildas-lormeau/zip.js/compare/v2.8.50...v2.8.51