@zip.js/zip.js 2.11.1 → 2.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -3608,11 +3608,10 @@ class Reader extends Stream {
3608
3608
  const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
3609
3609
  if (data.length) {
3610
3610
  controller.enqueue(data);
3611
+ chunkOffset += data.length;
3611
3612
  }
3612
- if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
3613
+ if ((size !== UNDEFINED_VALUE && chunkOffset >= size) || (!data.length && dataSize)) {
3613
3614
  controller.close();
3614
- } else {
3615
- chunkOffset += chunkSize;
3616
3615
  }
3617
3616
  }
3618
3617
  });
@@ -6267,6 +6266,7 @@ const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
6267
6266
  const ERR_INVALID_VERSION = "Version exceeds 65535";
6268
6267
  const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
6269
6268
  const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
6269
+ const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
6270
6270
  const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
6271
6271
  const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
6272
6272
  const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
@@ -6281,6 +6281,7 @@ const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
6281
6281
  const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
6282
6282
  const ERR_UNDETERMINED_SIZE = "Undetermined size";
6283
6283
  const ERR_UNDEFINED_READER = "Undefined reader";
6284
+ const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
6284
6285
  const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
6285
6286
  const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
6286
6287
  const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
@@ -6312,6 +6313,9 @@ class ZipWriter {
6312
6313
  const addSplitZipSignature =
6313
6314
  availableSize > 0 && availableSize !== INFINITY_VALUE &&
6314
6315
  maxSize > 0 && maxSize !== INFINITY_VALUE;
6316
+ if (addSplitZipSignature && options[OPTION_USDZ]) {
6317
+ throw new Error(ERR_UNSUPPORTED_SPLIT_USDZ);
6318
+ }
6315
6319
  Object.assign(this, {
6316
6320
  writer,
6317
6321
  addSplitZipSignature,
@@ -6323,6 +6327,7 @@ class ZipWriter {
6323
6327
  pendingAddFileCalls: new Set(),
6324
6328
  pendingErrors: [],
6325
6329
  bufferedWrites: 0,
6330
+ directWrites: 0,
6326
6331
  lastFileEntry: UNDEFINED_VALUE
6327
6332
  });
6328
6333
  }
@@ -6426,6 +6431,7 @@ class ZipWriter {
6426
6431
  }
6427
6432
  const { offset, diskNumberStart } = entryPositions.get(entry);
6428
6433
  Object.assign(entry, {
6434
+ zip64Enabled: true,
6429
6435
  zip64UncompressedSize,
6430
6436
  zip64CompressedSize,
6431
6437
  offset,
@@ -7001,6 +7007,9 @@ async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, op
7001
7007
  if (reader) {
7002
7008
  reader = new GenericReader(reader);
7003
7009
  await initStream(reader);
7010
+ if (!reader.readable && !reader.readUint8Array) {
7011
+ throw new Error(ERR_INVALID_READER);
7012
+ }
7004
7013
  ({ size: contentSize } = reader);
7005
7014
  }
7006
7015
  return Object.assign({ reader }, resolveEntrySizes(zipWriter, Boolean(reader), contentSize, metadata, options));
@@ -7011,6 +7020,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7011
7020
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
7012
7021
  let maximumCompressedSize = 0;
7013
7022
  let uncompressedSize = 0;
7023
+ let unknownSize = false;
7014
7024
  if (passThrough && hasContent) {
7015
7025
  uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
7016
7026
  if (uncompressedSize === UNDEFINED_VALUE) {
@@ -7036,8 +7046,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7036
7046
  if (contentSize === UNDEFINED_VALUE) {
7037
7047
  dataDescriptor = true;
7038
7048
  if (zip64 || zip64 === UNDEFINED_VALUE) {
7039
- zip64 = true;
7040
- uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
7049
+ zip64 = unknownSize = true;
7050
+ maximumCompressedSize = MAX_32_BITS + 1;
7041
7051
  }
7042
7052
  } else {
7043
7053
  options.uncompressedSize = uncompressedSize = contentSize;
@@ -7052,7 +7062,7 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7052
7062
  if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
7053
7063
  dataDescriptor = false;
7054
7064
  }
7055
- const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
7065
+ const zip64UncompressedSize = zip64Enabled || unknownSize || uncompressedSize >= MAX_32_BITS;
7056
7066
  const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
7057
7067
  if (zip64UncompressedSize || zip64CompressedSize) {
7058
7068
  if (zip64 === false) {
@@ -7068,6 +7078,8 @@ function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options
7068
7078
  dataDescriptor,
7069
7079
  emptyEntry,
7070
7080
  zip64,
7081
+ zip64Enabled,
7082
+ unknownSize,
7071
7083
  zip64UncompressedSize,
7072
7084
  zip64CompressedSize,
7073
7085
  uncompressedSize,
@@ -7141,7 +7153,7 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
7141
7153
  if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
7142
7154
  throw new Error(ERR_UNDETERMINED_SIZE);
7143
7155
  }
7144
- const directoryDataLength = createDirectoryRecords(files);
7156
+ const { directoryDataLength, zip64Entries } = createDirectoryRecords(files);
7145
7157
  let zip64 = getOptionValue(zipWriter, writerOptions, PROPERTY_NAME_ZIP64);
7146
7158
  if (offset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || files.size >= MAX_16_BITS) {
7147
7159
  if (zip64 === false) {
@@ -7149,6 +7161,8 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
7149
7161
  } else {
7150
7162
  zip64 = true;
7151
7163
  }
7164
+ } else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
7165
+ zip64 = true;
7152
7166
  }
7153
7167
  return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
7154
7168
  }
@@ -7173,6 +7187,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
7173
7187
  const usdz = zipWriter.options[OPTION_USDZ];
7174
7188
  let fileEntry = pendingFileEntry;
7175
7189
  let bufferedWrite;
7190
+ let directWrite;
7176
7191
  let releaseLockWriter;
7177
7192
  let writingBufferedEntryData;
7178
7193
  let writingEntryData;
@@ -7182,7 +7197,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
7182
7197
  const lockPreviousFileEntry = keepOrder && previousFileEntry ? previousFileEntry.lockFileEntry : UNDEFINED_VALUE;
7183
7198
  fileEntries.set(name, fileEntry);
7184
7199
  try {
7185
- if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
7200
+ if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || zipWriter.directWrites || (!dataDescriptor && !emptyEntry)) {
7186
7201
  bufferedWrite = true;
7187
7202
  zipWriter.bufferedWrites++;
7188
7203
  if (options.createTempStream) {
@@ -7193,6 +7208,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
7193
7208
  fileWriter.size = 0;
7194
7209
  await initStream(writer);
7195
7210
  } else {
7211
+ directWrite = true;
7212
+ zipWriter.directWrites++;
7196
7213
  fileWriter = writer;
7197
7214
  await lockPreviousFileEntry;
7198
7215
  await requestLockWriter();
@@ -7271,6 +7288,9 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
7271
7288
  if (bufferedWrite) {
7272
7289
  zipWriter.bufferedWrites--;
7273
7290
  }
7291
+ if (directWrite) {
7292
+ zipWriter.directWrites--;
7293
+ }
7274
7294
  if (releaseLockFileEntry) {
7275
7295
  releaseLockFileEntry(lockPreviousFileEntry);
7276
7296
  }
@@ -7335,6 +7355,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7335
7355
  rawPassword,
7336
7356
  level,
7337
7357
  zip64,
7358
+ zip64Enabled,
7338
7359
  zip64UncompressedSize,
7339
7360
  zip64CompressedSize,
7340
7361
  zipCrypto,
@@ -7375,6 +7396,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7375
7396
  lockFileEntry,
7376
7397
  versionMadeBy,
7377
7398
  zip64,
7399
+ zip64Enabled,
7378
7400
  directory: Boolean(directory),
7379
7401
  executable: Boolean(executable),
7380
7402
  filenameUTF8: true,
@@ -7415,8 +7437,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
7415
7437
  }
7416
7438
  const { writable } = writer;
7417
7439
  if (reader) {
7418
- const readable = toCompatibleReadable(createReadable(reader));
7419
7440
  const size = reader.size;
7441
+ const readable = toCompatibleReadable(createReadable(reader, { size }));
7420
7442
  const workerOptions = {
7421
7443
  options: {
7422
7444
  codecType: CODEC_DEFLATE,
@@ -7518,13 +7540,14 @@ function getHeaderInfo(options) {
7518
7540
  zip64UncompressedSize,
7519
7541
  zip64CompressedSize,
7520
7542
  uncompressedSize,
7543
+ unknownSize,
7521
7544
  crc32
7522
7545
  } = options;
7523
7546
  let { version, compressionMethod } = options;
7524
7547
  const compressed = !directory && isCompressed(compressionMethod, level);
7525
7548
  let rawLocalExtraFieldZip64;
7526
7549
  const uncompressedFile = passThrough || !compressed;
7527
- const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
7550
+ const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
7528
7551
  const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
7529
7552
  if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
7530
7553
  const length = 4 + 16;
@@ -7658,6 +7681,10 @@ function getHeaderInfo(options) {
7658
7681
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
7659
7682
  }
7660
7683
  const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
7684
+ const clampedLastModDate = dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate;
7685
+ const storedLastModDate = getLength(rawExtraFieldExtendedTimestamp) ?
7686
+ new Date(getTimeUnix(lastModDate) * 1000) :
7687
+ getLength(rawExtraFieldNTFS) ? lastModDate : clampedLastModDate;
7661
7688
  const {
7662
7689
  headerArray,
7663
7690
  headerView,
@@ -7667,7 +7694,7 @@ function getHeaderInfo(options) {
7667
7694
  bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
7668
7695
  compressionMethod,
7669
7696
  uncompressedSize,
7670
- lastModDate: dosLastModDate < MIN_DATE ? MIN_DATE : dosLastModDate > MAX_DATE ? MAX_DATE : dosLastModDate,
7697
+ lastModDate: clampedLastModDate,
7671
7698
  rawLastModDate: rawLastModDateOption,
7672
7699
  rawFilename,
7673
7700
  zip64CompressedSize,
@@ -7702,7 +7729,7 @@ function getHeaderInfo(options) {
7702
7729
  localHeaderView,
7703
7730
  headerArray,
7704
7731
  headerView,
7705
- lastModDate,
7732
+ lastModDate: storedLastModDate,
7706
7733
  rawLastModDate,
7707
7734
  encrypted,
7708
7735
  compressed,
@@ -7874,14 +7901,15 @@ function updateLocalHeader({
7874
7901
 
7875
7902
 
7876
7903
  async function closeFile(zipWriter, comment, options) {
7877
- const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
7904
+ const { directoryDataLength, zip64Entries } = createDirectoryRecords(zipWriter.fileEntries);
7878
7905
  const { directoryStart, directoryEnd, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
7879
7906
  const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
7880
- await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength });
7907
+ await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryEnd, directoryDataLength, signatureLength, zip64Entries });
7881
7908
  }
7882
7909
 
7883
7910
  function createDirectoryRecords(files) {
7884
7911
  let directoryDataLength = 0;
7912
+ let zip64Entries = false;
7885
7913
  for (const [, fileEntry] of files) {
7886
7914
  const {
7887
7915
  rawFilename,
@@ -7894,11 +7922,20 @@ function createDirectoryRecords(files) {
7894
7922
  extendedTimestamp,
7895
7923
  extraFieldExtendedTimestampFlag,
7896
7924
  lastModDate,
7897
- zip64UncompressedSize,
7898
- zip64CompressedSize,
7925
+ zip64Enabled,
7899
7926
  uncompressedSize,
7900
7927
  compressedSize
7901
7928
  } = fileEntry;
7929
+ let { zip64UncompressedSize, zip64CompressedSize } = fileEntry;
7930
+ if (!zip64Enabled) {
7931
+ if (zip64UncompressedSize && uncompressedSize < MAX_32_BITS) {
7932
+ zip64UncompressedSize = fileEntry.zip64UncompressedSize = false;
7933
+ }
7934
+ if (zip64CompressedSize && compressedSize < MAX_32_BITS) {
7935
+ zip64CompressedSize = fileEntry.zip64CompressedSize = false;
7936
+ }
7937
+ }
7938
+ zip64Entries = zip64Entries || zip64UncompressedSize || zip64CompressedSize;
7902
7939
  const zip64Offset = fileEntry.offset >= MAX_32_BITS;
7903
7940
  const zip64DiskNumberStart = fileEntry.diskNumberStart >= MAX_16_BITS;
7904
7941
  let rawExtraFieldZip64;
@@ -7952,7 +7989,7 @@ function createDirectoryRecords(files) {
7952
7989
  }
7953
7990
  directoryDataLength += CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
7954
7991
  }
7955
- return directoryDataLength;
7992
+ return { directoryDataLength, zip64Entries };
7956
7993
  }
7957
7994
 
7958
7995
  async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
@@ -8072,7 +8109,7 @@ async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
8072
8109
 
8073
8110
  async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
8074
8111
  const { writer } = zipWriter;
8075
- const { directoryStart, directoryEnd, signatureLength } = cdInfo;
8112
+ const { directoryStart, directoryEnd, signatureLength, zip64Entries } = cdInfo;
8076
8113
  let { directoryDataLength } = cdInfo;
8077
8114
  let fileEntriesLength = zipWriter.fileEntries.size;
8078
8115
  let diskNumber = directoryStart.diskNumber;
@@ -8092,6 +8129,8 @@ async function writeEndOfDirectoryRecord(zipWriter, comment, options, cdInfo) {
8092
8129
  } else {
8093
8130
  zip64 = true;
8094
8131
  }
8132
+ } else if (zip64 === UNDEFINED_VALUE && zip64Entries) {
8133
+ zip64 = true;
8095
8134
  }
8096
8135
  const endOfdirectoryRecord = createRecordWriter(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
8097
8136
  if (exceedsAvailableSize(writer, getLength(endOfdirectoryRecord.array) + commentLength)) {
@@ -8595,7 +8634,7 @@ function formatSupported(StreamClass, format) {
8595
8634
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8596
8635
  */
8597
8636
 
8598
- const VERSION = "2.11.1";
8637
+ const VERSION = "2.11.3";
8599
8638
 
8600
8639
  /*
8601
8640
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -9991,12 +10030,14 @@ class ZipDirectoryEntry extends ZipEntry {
9991
10030
  if (options.bufferedWrite === UNDEFINED_VALUE) {
9992
10031
  options.bufferedWrite = true;
9993
10032
  }
9994
- const entries = zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
10033
+ const children = zipEntry.getChildren({ recursive: true });
10034
+ const entries = children.filter(child => !isImplicitDirectory(child)).map(child => {
9995
10035
  const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
9996
10036
  return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
9997
10037
  });
9998
10038
  const writeOrderGuaranteed = !options.bufferedWrite ||
9999
- (entries.every(entry => entry.options.keepOrder !== false) && zipEntry.children.every(child => !child.children.length));
10039
+ (entries.every(entry => entry.options.keepOrder !== false) &&
10040
+ children.every(child => isImplicitDirectory(child) || !child.children.length));
10000
10041
  return getEntriesSize(options, entries, writeOrderGuaranteed, options.globalComment);
10001
10042
  }
10002
10043
 
@@ -11025,6 +11066,7 @@ exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
11025
11066
  exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
11026
11067
  exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
11027
11068
  exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
11069
+ exports.ERR_INVALID_READER = ERR_INVALID_READER;
11028
11070
  exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
11029
11071
  exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
11030
11072
  exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
@@ -11053,6 +11095,7 @@ exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
11053
11095
  exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
11054
11096
  exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
11055
11097
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
11098
+ exports.ERR_UNSUPPORTED_SPLIT_USDZ = ERR_UNSUPPORTED_SPLIT_USDZ;
11056
11099
  exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
11057
11100
  exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
11058
11101
  exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
package/index.d.cts CHANGED
@@ -161,7 +161,7 @@
161
161
  /**
162
162
  * Represents the `FileSystemEntry` class.
163
163
  *
164
- * @see {@link https://wicg.github.io/entries-api/#api-entry|specification}
164
+ * @see {@link https://wicg.github.io/entries-api/#api-entry}
165
165
  */
166
166
  // deno-lint-ignore no-empty-interface
167
167
  interface FileSystemEntryLike {}
@@ -177,7 +177,7 @@ interface FileSystemHandleLike {}
177
177
  /**
178
178
  * Represents a generic `TransformStream` class.
179
179
  *
180
- * @see {@link https://streams.spec.whatwg.org/#generictransformstream|specification}
180
+ * @see {@link https://streams.spec.whatwg.org/#generictransformstream}
181
181
  */
182
182
  declare class TransformStreamLike {
183
183
  /**
@@ -3027,6 +3027,8 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
3027
3027
  /**
3028
3028
  * `true` to use Zip64 to write the entries directory.
3029
3029
  *
3030
+ * Zip64 is also used when the directory does not fit in the standard record, or when an entry is stored with Zip64.
3031
+ *
3030
3032
  * @defaultValue false
3031
3033
  */
3032
3034
  zip64?: boolean;
@@ -3059,6 +3061,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3059
3061
  * `true` to use Zip64 to store the entry.
3060
3062
  *
3061
3063
  * `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
3064
+ * An entry of unknown size is stored with Zip64 in its local header, because the size of the data descriptor must be
3065
+ * chosen before writing the data. Its central directory record drops Zip64 when the actual sizes fit in 32 bits.
3062
3066
  *
3063
3067
  * @defaultValue false
3064
3068
  */
@@ -3080,6 +3084,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3080
3084
  * between platforms. Set `useCompressionStream` to `false` to get deterministic output across
3081
3085
  * platforms.
3082
3086
  *
3087
+ * When no deflate implementation is available at all, i.e. the environment provides no usable
3088
+ * `CompressionStream` and the embedded implementation cannot be loaded, the entry is stored
3089
+ * instead of being compressed rather than failing. The {@link EntryMetaData#compressionMethod} of
3090
+ * the entry returned by {@link ZipWriter#add} is `0` in that case, which is how the fallback is
3091
+ * detected.
3092
+ *
3083
3093
  * @defaultValue 6
3084
3094
  */
3085
3095
  level?: number;
@@ -3112,10 +3122,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3112
3122
  * `true` to keep the order of the entry physically in the zip file.
3113
3123
  *
3114
3124
  * @remarks
3115
- * The entries are then written one after another, so concurrent calls to {@link ZipWriter#add} compress one
3116
- * entry at a time and use a single web worker. Set {@link ZipWriterConstructorOptions#bufferedWrite} to `true`
3117
- * to compress them concurrently while still keeping the order, at the cost of buffering each entry until the
3118
- * previous ones are written.
3125
+ * The entries are then written one after another, but concurrent calls to {@link ZipWriter#add} still compress
3126
+ * concurrently: one entry is written directly into the zip file while the others are buffered until it is their
3127
+ * turn, i.e. {@link ZipWriterConstructorOptions#bufferedWrite} is set automatically for them.
3119
3128
  *
3120
3129
  * @defaultValue true
3121
3130
  */
@@ -3390,6 +3399,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3390
3399
  * boundaries and stored uncompressed unless the {@link ZipWriterConstructorOptions#level} or
3391
3400
  * {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
3392
3401
  * {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
3402
+ * Writing into a split zip file throws an {@link ERR_UNSUPPORTED_SPLIT_USDZ} error, since the 64-byte alignment
3403
+ * of an entry is invalidated when the disk it is written into rolls over.
3393
3404
  *
3394
3405
  * These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
3395
3406
  * {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
@@ -4635,6 +4646,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
4635
4646
  * Unsupported encryption in USDZ files error
4636
4647
  */
4637
4648
  export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
4649
+ /**
4650
+ * Unsupported split zip file in USDZ files error
4651
+ */
4652
+ export const ERR_UNSUPPORTED_SPLIT_USDZ: string;
4638
4653
  /**
4639
4654
  * Unsupported encryption in pass-through entries error
4640
4655
  */
@@ -4729,6 +4744,15 @@ export const ERR_UNDETERMINED_SIZE: string;
4729
4744
  * is not there. Directory entries are exempt, they have no content to write as-is.
4730
4745
  */
4731
4746
  export const ERR_UNDEFINED_READER: string;
4747
+ /**
4748
+ * Invalid reader error
4749
+ *
4750
+ * @remarks Thrown when the second argument of {@link ZipWriter#add} is neither a {@link Reader} instance, a
4751
+ * `ReadableStream` instance, nor an object exposing a `readable` property. A `Blob`, a string or a
4752
+ * `Uint8Array` must be wrapped in the matching Reader class, e.g. {@link BlobReader}, {@link TextReader}
4753
+ * or {@link Uint8ArrayReader}.
4754
+ */
4755
+ export const ERR_INVALID_READER: string;
4732
4756
  /**
4733
4757
  * Writer not initialized error
4734
4758
  */
package/index.d.ts CHANGED
@@ -161,7 +161,7 @@
161
161
  /**
162
162
  * Represents the `FileSystemEntry` class.
163
163
  *
164
- * @see {@link https://wicg.github.io/entries-api/#api-entry|specification}
164
+ * @see {@link https://wicg.github.io/entries-api/#api-entry}
165
165
  */
166
166
  // deno-lint-ignore no-empty-interface
167
167
  interface FileSystemEntryLike {}
@@ -177,7 +177,7 @@ interface FileSystemHandleLike {}
177
177
  /**
178
178
  * Represents a generic `TransformStream` class.
179
179
  *
180
- * @see {@link https://streams.spec.whatwg.org/#generictransformstream|specification}
180
+ * @see {@link https://streams.spec.whatwg.org/#generictransformstream}
181
181
  */
182
182
  declare class TransformStreamLike {
183
183
  /**
@@ -3027,6 +3027,8 @@ export interface ZipWriterCloseOptions extends EntryOnprogressOptions {
3027
3027
  /**
3028
3028
  * `true` to use Zip64 to write the entries directory.
3029
3029
  *
3030
+ * Zip64 is also used when the directory does not fit in the standard record, or when an entry is stored with Zip64.
3031
+ *
3030
3032
  * @defaultValue false
3031
3033
  */
3032
3034
  zip64?: boolean;
@@ -3059,6 +3061,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3059
3061
  * `true` to use Zip64 to store the entry.
3060
3062
  *
3061
3063
  * `zip64` is automatically set to `true` when necessary (e.g. compressed data larger than 4GB or with unknown size).
3064
+ * An entry of unknown size is stored with Zip64 in its local header, because the size of the data descriptor must be
3065
+ * chosen before writing the data. Its central directory record drops Zip64 when the actual sizes fit in 32 bits.
3062
3066
  *
3063
3067
  * @defaultValue false
3064
3068
  */
@@ -3080,6 +3084,12 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3080
3084
  * between platforms. Set `useCompressionStream` to `false` to get deterministic output across
3081
3085
  * platforms.
3082
3086
  *
3087
+ * When no deflate implementation is available at all, i.e. the environment provides no usable
3088
+ * `CompressionStream` and the embedded implementation cannot be loaded, the entry is stored
3089
+ * instead of being compressed rather than failing. The {@link EntryMetaData#compressionMethod} of
3090
+ * the entry returned by {@link ZipWriter#add} is `0` in that case, which is how the fallback is
3091
+ * detected.
3092
+ *
3083
3093
  * @defaultValue 6
3084
3094
  */
3085
3095
  level?: number;
@@ -3112,10 +3122,9 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3112
3122
  * `true` to keep the order of the entry physically in the zip file.
3113
3123
  *
3114
3124
  * @remarks
3115
- * The entries are then written one after another, so concurrent calls to {@link ZipWriter#add} compress one
3116
- * entry at a time and use a single web worker. Set {@link ZipWriterConstructorOptions#bufferedWrite} to `true`
3117
- * to compress them concurrently while still keeping the order, at the cost of buffering each entry until the
3118
- * previous ones are written.
3125
+ * The entries are then written one after another, but concurrent calls to {@link ZipWriter#add} still compress
3126
+ * concurrently: one entry is written directly into the zip file while the others are buffered until it is their
3127
+ * turn, i.e. {@link ZipWriterConstructorOptions#bufferedWrite} is set automatically for them.
3119
3128
  *
3120
3129
  * @defaultValue true
3121
3130
  */
@@ -3390,6 +3399,8 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3390
3399
  * boundaries and stored uncompressed unless the {@link ZipWriterConstructorOptions#level} or
3391
3400
  * {@link ZipWriterAddDataOptions#compressionMethod} options are set explicitly. Setting the
3392
3401
  * {@link ZipWriterConstructorOptions#password} option throws an {@link ERR_UNSUPPORTED_ENCRYPTION_USDZ} error.
3402
+ * Writing into a split zip file throws an {@link ERR_UNSUPPORTED_SPLIT_USDZ} error, since the 64-byte alignment
3403
+ * of an entry is invalidated when the disk it is written into rolls over.
3393
3404
  *
3394
3405
  * These constraints apply to the entries written with {@link ZipWriter#add} only. The entries copied with
3395
3406
  * {@link ZipWriter#appendZip} keep the layout of the source zip file and are not checked, so appending a
@@ -4635,6 +4646,10 @@ export const ERR_INVALID_ENCRYPTION_STRENGTH: string;
4635
4646
  * Unsupported encryption in USDZ files error
4636
4647
  */
4637
4648
  export const ERR_UNSUPPORTED_ENCRYPTION_USDZ: string;
4649
+ /**
4650
+ * Unsupported split zip file in USDZ files error
4651
+ */
4652
+ export const ERR_UNSUPPORTED_SPLIT_USDZ: string;
4638
4653
  /**
4639
4654
  * Unsupported encryption in pass-through entries error
4640
4655
  */
@@ -4729,6 +4744,15 @@ export const ERR_UNDETERMINED_SIZE: string;
4729
4744
  * is not there. Directory entries are exempt, they have no content to write as-is.
4730
4745
  */
4731
4746
  export const ERR_UNDEFINED_READER: string;
4747
+ /**
4748
+ * Invalid reader error
4749
+ *
4750
+ * @remarks Thrown when the second argument of {@link ZipWriter#add} is neither a {@link Reader} instance, a
4751
+ * `ReadableStream` instance, nor an object exposing a `readable` property. A `Blob`, a string or a
4752
+ * `Uint8Array` must be wrapped in the matching Reader class, e.g. {@link BlobReader}, {@link TextReader}
4753
+ * or {@link Uint8ArrayReader}.
4754
+ */
4755
+ export const ERR_INVALID_READER: string;
4732
4756
  /**
4733
4757
  * Writer not initialized error
4734
4758
  */