npm @zip.js/zip.js 2.25.1

one hour ago

What's Changed in v2.25.1

Bug fixes

  • A generator of disks passed to SplitDataWriter, the ZipWriter constructor, getData() or exportZip() can now yield a bare WritableStream, as declared, instead of failing with "Cannot read properties of undefined (reading 'getWriter')"; a disk given as an object exposing a writable property keeps working

Type declarations

  • A synchronous generator, and an asynchronous generator ending without a value, now type-check as the disks of a split zip file passed to SplitDataWriter, the ZipWriter constructor, FileEntry#getData(), ZipFileEntry#getData() and exportZip(). Both already worked at runtime. Previously SplitDataWriter, ZipWriter and FileEntry#getData() required an asynchronous generator returning a boolean, so the plain async function* () { yield writer; } did not type-check, and ZipFileEntry#getData() and exportZip() rejected synchronous generators. The new SplitDataWriterGenerator type declares these generators. The value a generator returns when it completes, if any, is the writer of the last disk
  • A generator returning a boolean, as the previous declaration required, no longer type-checks. Returning true made the write fail once the generator ran out of disks, with "Cannot create property 'size' on boolean 'true'" in 2.25.0 and "Invalid writer (size must be writable)" now. End the generator without a value, or with the writer of the last disk
  • The comment option of exportBlob(), exportData64URI(), exportUint8Array(), exportWritable(), exportZip() and getExportedSize(), on ZipDirectoryEntry and ZipFS, is now declared. It already worked at runtime. It sets the comment of the exported entries, replacing the comment of the entries imported from a zip file, while an entry added with a comment option of its own keeps that comment. The comment of the zip file itself is still the globalComment option
  • ZipFileEntry#writer is deprecated: zip.js never sets it, so its value is always undefined

Documentation

  • WritableWriter#maxSize and SplitDataWriter#maxSize: the limit set by a disk also applies to the following disks until one sets another limit. A disk without maxSize keeps the limit of the previous disk, not the maxSize passed to the SplitDataWriter constructor
  • The "Reading untrusted zip files" section moved to the end of the README, after "Tests"

Contributing

  • New REVIEW.md checklist in the repository: the generated files to rebuild and commit, the worker message property names, the test registration, the rules of the library code and the code style

Full Changelog: v2.25.0...v2.25.1

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Don't miss a new zip.js release

NewReleases is sending notifications on new releases.