@zip.js/zip.js 2.8.61 → 2.10.0

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.
@@ -520,7 +520,7 @@ function getDataView(array) {
520
520
  // Every table MUST stay a PACKED_SMI array: build with array literals (not `new Array(n)`,
521
521
  // which is HOLEY) and store the signed int32 XOR result (no `>>> 0`). An unsigned or holey
522
522
  // table becomes a V8 FixedDoubleArray whose every hot-loop lookup unboxes a double (~1.6x
523
- // slower). Signedness is irrelevant to the result — the reads mask/shift it and the final
523
+ // slower). Signedness is irrelevant to the result: the reads mask/shift it and the final
524
524
  // `~crc` normalizes it. Do NOT reintroduce `>>> 0` here or switch to `new Array(256)`.
525
525
  const T = [[], [], [], [], [], [], [], []];
526
526
  for (let n = 0; n < 256; n++) {
@@ -3506,21 +3506,14 @@ async function terminateWorkers() {
3506
3506
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3507
3507
  */
3508
3508
 
3509
- /* global TextDecoder */
3510
-
3511
- const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
3512
- const VALID_CP437 = CP437.length == 256;
3509
+ const CP437 = "\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\u00B6\u00A7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0".split("");
3513
3510
 
3514
3511
  function decodeCP437(stringValue) {
3515
- if (VALID_CP437) {
3516
- let result = "";
3517
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3518
- result += CP437[stringValue[indexCharacter]];
3519
- }
3520
- return result;
3521
- } else {
3522
- return new TextDecoder().decode(stringValue);
3512
+ let result = "";
3513
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3514
+ result += CP437[stringValue[indexCharacter]];
3523
3515
  }
3516
+ return result;
3524
3517
  }
3525
3518
 
3526
3519
  /*
@@ -4774,6 +4767,7 @@ const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA = "unknown zip64 extensible data";
4774
4767
  const WARNING_WRAPPED_ENTRIES_COUNT = "wrapped entries count";
4775
4768
  const WARNING_APPENDED_DATA = "appended data";
4776
4769
  const WARNING_PREPENDED_DATA = "prepended data";
4770
+ const WARNING_PREPENDED_CENTRAL_DIRECTORY = "prepended central directory";
4777
4771
  const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
4778
4772
  const WARNING_DUPLICATE_FILENAME = "duplicate filename";
4779
4773
  const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
@@ -4867,6 +4861,7 @@ class ZipReader {
4867
4861
  let diskNumber = getUint16$1(endOfDirectoryView, 6);
4868
4862
  let filesLength = getUint16$1(endOfDirectoryView, 10);
4869
4863
  let prependedDataLength = 0;
4864
+ let prependedCentralDirectory;
4870
4865
  let startOffset;
4871
4866
  let zip64EndOfDirectory;
4872
4867
  let zip64EndOfDirectoryVersion2;
@@ -4970,6 +4965,7 @@ class ZipReader {
4970
4965
  directoryDataOffset = expectedDirectoryDataOffset;
4971
4966
  if (directoryDataOffset > originalDirectoryDataOffset) {
4972
4967
  prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
4968
+ prependedCentralDirectory = storedPointsAtDirectory;
4973
4969
  }
4974
4970
  directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength);
4975
4971
  directoryView = getDataView(directoryArray);
@@ -5197,6 +5193,9 @@ class ZipReader {
5197
5193
  if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
5198
5194
  addWarning(warnings, WARNING_PREPENDED_DATA);
5199
5195
  }
5196
+ if (prependedCentralDirectory) {
5197
+ addWarning(warnings, WARNING_PREPENDED_CENTRAL_DIRECTORY);
5198
+ }
5200
5199
  if (extractPrependedData) {
5201
5200
  zipReader.prependedData = startOffset > splitZipSignatureLength ?
5202
5201
  await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
@@ -6257,6 +6256,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
6257
6256
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
6258
6257
  WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
6259
6258
  WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
6259
+ WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
6260
6260
  WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
6261
6261
  WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
6262
6262
  WARNING_UNKNOWN_VERSION: WARNING_UNKNOWN_VERSION,
@@ -8648,7 +8648,7 @@ function formatSupported(StreamClass, format) {
8648
8648
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8649
8649
  */
8650
8650
 
8651
- const VERSION = "2.8.61";
8651
+ const VERSION = "2.10.0";
8652
8652
 
8653
8653
  /*
8654
8654
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -9512,7 +9512,14 @@ configureExternalAssets();
9512
9512
 
9513
9513
 
9514
9514
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
9515
+ const ERR_DUPLICATE_IMPORTED_ENTRY = "Duplicate entry filename in the imported zip file";
9516
+ const ERR_INVALID_DUPLICATES = "Invalid duplicates option (must be \"throw\", \"keep-first\" or \"keep-last\")";
9517
+ const ERR_ANCESTOR_ENTRY = "Entry is a ancestor of target entry";
9515
9518
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
9519
+ const DUPLICATES_THROW = "throw";
9520
+ const DUPLICATES_KEEP_FIRST = "keep-first";
9521
+ const DUPLICATES_KEEP_LAST = "keep-last";
9522
+ const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
9516
9523
  const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
9517
9524
  const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
9518
9525
  const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
@@ -9589,12 +9596,26 @@ class ZipEntry {
9589
9596
  }
9590
9597
 
9591
9598
  rename(name) {
9592
- const parent = this.parent;
9593
- if (parent && parent.getChildByName(name)) {
9594
- throw new Error(ERR_ENTRY_EXISTS);
9595
- } else {
9596
- this.name = name;
9599
+ const zipEntry = this;
9600
+ let parent = zipEntry.parent;
9601
+ if (parent) {
9602
+ const path = splitPath(name);
9603
+ if (path) {
9604
+ name = path.pop();
9605
+ parent = getPathParent(parent, path, zipEntry);
9606
+ }
9607
+ const existingChild = parent.getChildByName(name);
9608
+ if (existingChild && existingChild != zipEntry) {
9609
+ throw new Error(ERR_ENTRY_EXISTS);
9610
+ }
9611
+ if (parent != zipEntry.parent) {
9612
+ detach(zipEntry);
9613
+ zipEntry.parent = parent;
9614
+ parent.children.push(zipEntry);
9615
+ registerEntries(zipEntry.fs, zipEntry);
9616
+ }
9597
9617
  }
9618
+ zipEntry.name = name;
9598
9619
  }
9599
9620
 
9600
9621
  setOptions(options) {
@@ -9687,47 +9708,47 @@ class ZipFileEntry extends ZipEntry {
9687
9708
  }
9688
9709
 
9689
9710
  replaceBlob(blob) {
9690
- Object.assign(this, {
9711
+ replaceContent(this, {
9691
9712
  data: blob,
9692
9713
  Reader: BlobReader,
9693
9714
  Writer: BlobWriter,
9694
- reader: null
9715
+ uncompressedSize: blob.size
9695
9716
  });
9696
9717
  }
9697
9718
 
9698
9719
  replaceText(text) {
9699
- Object.assign(this, {
9720
+ replaceContent(this, {
9700
9721
  data: text,
9701
9722
  Reader: TextReader,
9702
9723
  Writer: TextWriter,
9703
- reader: null
9724
+ uncompressedSize: getTextSize(text)
9704
9725
  });
9705
9726
  }
9706
9727
 
9707
9728
  replaceData64URI(dataURI) {
9708
- Object.assign(this, {
9729
+ replaceContent(this, {
9709
9730
  data: dataURI,
9710
9731
  Reader: Data64URIReader,
9711
9732
  Writer: Data64URIWriter,
9712
- reader: null
9733
+ uncompressedSize: getData64URISize(dataURI)
9713
9734
  });
9714
9735
  }
9715
9736
 
9716
9737
  replaceUint8Array(array) {
9717
- Object.assign(this, {
9738
+ replaceContent(this, {
9718
9739
  data: array,
9719
9740
  Reader: Uint8ArrayReader,
9720
9741
  Writer: Uint8ArrayWriter,
9721
- reader: null
9742
+ uncompressedSize: array.length
9722
9743
  });
9723
9744
  }
9724
9745
 
9725
9746
  replaceReadable(readable) {
9726
- Object.assign(this, {
9747
+ replaceContent(this, {
9727
9748
  data: null,
9728
9749
  Reader: getReadableReader(readable),
9729
9750
  Writer: null,
9730
- reader: null
9751
+ uncompressedSize: UNDEFINED_VALUE
9731
9752
  });
9732
9753
  }
9733
9754
  }
@@ -9777,17 +9798,12 @@ class ZipDirectoryEntry extends ZipEntry {
9777
9798
  }
9778
9799
 
9779
9800
  addData64URI(name, dataURI, options = {}) {
9780
- let dataEnd = dataURI.length;
9781
- while (dataURI.charAt(dataEnd - 1) == "=") {
9782
- dataEnd--;
9783
- }
9784
- const dataStart = dataURI.indexOf(",") + 1;
9785
9801
  return addChild(this, name, {
9786
9802
  data: dataURI,
9787
9803
  Reader: Data64URIReader,
9788
9804
  Writer: Data64URIWriter,
9789
9805
  options,
9790
- uncompressedSize: Math.floor((dataEnd - dataStart) * 0.75)
9806
+ uncompressedSize: getData64URISize(dataURI)
9791
9807
  });
9792
9808
  }
9793
9809
 
@@ -9895,6 +9911,7 @@ class ZipDirectoryEntry extends ZipEntry {
9895
9911
  await initStream(reader);
9896
9912
  zipReader = new ZipReader(reader, options);
9897
9913
  }
9914
+ const duplicates = checkDuplicatesOption(options.duplicates);
9898
9915
  const importedEntries = [];
9899
9916
  const entries = await zipReader.getEntries(options);
9900
9917
  for (const entry of entries) {
@@ -9902,19 +9919,42 @@ class ZipDirectoryEntry extends ZipEntry {
9902
9919
  try {
9903
9920
  const path = entry.filename.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
9904
9921
  const name = path.pop();
9905
- path.forEach(pathPart => {
9922
+ let skippedEntry = false;
9923
+ for (const pathPart of path) {
9906
9924
  const previousParent = parent;
9907
9925
  parent = parent.getChildByName(pathPart);
9908
9926
  if (parent) {
9909
9927
  if (!parent.directory) {
9910
- throw new Error(ERR_ENTRY_EXISTS);
9928
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9929
+ skippedEntry = true;
9930
+ break;
9931
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9932
+ this.fs.remove(parent);
9933
+ parent = new ZipDirectoryEntry(this.fs, pathPart, { data: null }, previousParent);
9934
+ importedEntries.push(parent);
9935
+ } else {
9936
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9937
+ }
9911
9938
  }
9912
9939
  } else {
9913
9940
  parent = new ZipDirectoryEntry(this.fs, pathPart, { data: null }, previousParent);
9914
9941
  importedEntries.push(parent);
9915
9942
  }
9916
- });
9943
+ }
9944
+ if (skippedEntry) {
9945
+ continue;
9946
+ }
9917
9947
  if (!entry.directory) {
9948
+ const existingChild = parent.getChildByName(name);
9949
+ if (existingChild) {
9950
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9951
+ continue;
9952
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9953
+ this.fs.remove(existingChild);
9954
+ } else {
9955
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9956
+ }
9957
+ }
9918
9958
  importedEntries.push(addChild(parent, name, {
9919
9959
  data: entry,
9920
9960
  Reader: getZipBlobReader(Object.assign({}, options)),
@@ -9925,11 +9965,17 @@ class ZipDirectoryEntry extends ZipEntry {
9925
9965
  let directoryEntry = parent;
9926
9966
  if (name) {
9927
9967
  directoryEntry = parent.getChildByName(name);
9928
- if (directoryEntry) {
9929
- if (!directoryEntry.directory) {
9930
- throw new Error(ERR_ENTRY_EXISTS);
9968
+ if (directoryEntry && !directoryEntry.directory) {
9969
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9970
+ continue;
9971
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9972
+ this.fs.remove(directoryEntry);
9973
+ directoryEntry = UNDEFINED_VALUE;
9974
+ } else {
9975
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9931
9976
  }
9932
- } else {
9977
+ }
9978
+ if (!directoryEntry) {
9933
9979
  directoryEntry = new ZipDirectoryEntry(this.fs, name, { data: null }, parent);
9934
9980
  importedEntries.push(directoryEntry);
9935
9981
  }
@@ -9939,6 +9985,7 @@ class ZipDirectoryEntry extends ZipEntry {
9939
9985
  }
9940
9986
  }
9941
9987
  } catch (error) {
9988
+ importedEntries.reverse().forEach(importedEntry => this.fs.remove(importedEntry));
9942
9989
  try {
9943
9990
  error.cause = {
9944
9991
  entry
@@ -10057,7 +10104,7 @@ class ZipFS {
10057
10104
  }
10058
10105
  }
10059
10106
  } else {
10060
- throw new Error("Entry is a ancestor of target entry");
10107
+ throw new Error(ERR_ANCESTOR_ENTRY);
10061
10108
  }
10062
10109
  } else {
10063
10110
  throw new Error("Target entry is not a directory");
@@ -10069,7 +10116,7 @@ class ZipFS {
10069
10116
  const path = fullname.split("/");
10070
10117
  let node = this.root;
10071
10118
  for (let index = 0; node && index < path.length; index++) {
10072
- node = node.getChildByName(path[index]);
10119
+ node = node.directory ? node.getChildByName(path[index]) : UNDEFINED_VALUE;
10073
10120
  }
10074
10121
  if (!node) {
10075
10122
  node = this.entries.find(entry => entry && (entry == this.root || entry.isDescendantOf(this.root)) &&
@@ -10131,33 +10178,27 @@ class ZipFS {
10131
10178
  }
10132
10179
 
10133
10180
  importBlob(blob, options) {
10134
- resetFS(this);
10135
- return this.root.importBlob(blob, options);
10181
+ return resetAndImport(this, root => root.importBlob(blob, options));
10136
10182
  }
10137
10183
 
10138
10184
  importData64URI(dataURI, options) {
10139
- resetFS(this);
10140
- return this.root.importData64URI(dataURI, options);
10185
+ return resetAndImport(this, root => root.importData64URI(dataURI, options));
10141
10186
  }
10142
10187
 
10143
10188
  importUint8Array(array, options) {
10144
- resetFS(this);
10145
- return this.root.importUint8Array(array, options);
10189
+ return resetAndImport(this, root => root.importUint8Array(array, options));
10146
10190
  }
10147
10191
 
10148
10192
  importHttpContent(url, options) {
10149
- resetFS(this);
10150
- return this.root.importHttpContent(url, options);
10193
+ return resetAndImport(this, root => root.importHttpContent(url, options));
10151
10194
  }
10152
10195
 
10153
10196
  importReadable(readable, options) {
10154
- resetFS(this);
10155
- return this.root.importReadable(readable, options);
10197
+ return resetAndImport(this, root => root.importReadable(readable, options));
10156
10198
  }
10157
10199
 
10158
10200
  importZip(reader, options) {
10159
- resetFS(this);
10160
- return this.root.importZip(reader, options);
10201
+ return resetAndImport(this, root => root.importZip(reader, options));
10161
10202
  }
10162
10203
 
10163
10204
  exportBlob(options) {
@@ -10477,6 +10518,25 @@ function checkReaderOptions(readerOptions) {
10477
10518
  return readerOptions;
10478
10519
  }
10479
10520
 
10521
+ function replaceContent(zipEntry, params) {
10522
+ const { uncompressedSize } = params;
10523
+ Object.assign(zipEntry, params, {
10524
+ reader: null,
10525
+ passThrough: UNDEFINED_VALUE,
10526
+ uncompressedSize: uncompressedSize === UNDEFINED_VALUE ? 0 : uncompressedSize,
10527
+ undeterminedSize: uncompressedSize === UNDEFINED_VALUE
10528
+ });
10529
+ }
10530
+
10531
+ function getData64URISize(dataURI) {
10532
+ let dataEnd = dataURI.length;
10533
+ while (dataURI.charAt(dataEnd - 1) == "=") {
10534
+ dataEnd--;
10535
+ }
10536
+ const dataStart = dataURI.indexOf(",") + 1;
10537
+ return Math.floor((dataEnd - dataStart) * 0.75);
10538
+ }
10539
+
10480
10540
  function isPassThrough(child, options) {
10481
10541
  const { readerOptions } = options;
10482
10542
  return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
@@ -10766,6 +10826,15 @@ function resetFS(fs) {
10766
10826
  fs.root = new ZipDirectoryEntry(fs);
10767
10827
  }
10768
10828
 
10829
+ function resetAndImport(fs, importFunction) {
10830
+ const { entries, entryIdCounter, root } = fs;
10831
+ resetFS(fs);
10832
+ return importFunction(fs.root).catch(error => {
10833
+ Object.assign(fs, { entries, entryIdCounter, root });
10834
+ throw error;
10835
+ });
10836
+ }
10837
+
10769
10838
  function collectChildren(directory, recursive) {
10770
10839
  const children = [];
10771
10840
  const pendingDirectories = [directory];
@@ -10794,10 +10863,52 @@ function registerEntries(fs, entry) {
10794
10863
 
10795
10864
  function addChild(parent, name, params, directory) {
10796
10865
  if (parent.directory) {
10866
+ const path = splitPath(name);
10867
+ if (path) {
10868
+ name = path.pop();
10869
+ parent = getPathParent(parent, path);
10870
+ }
10797
10871
  return directory ? new ZipDirectoryEntry(parent.fs, name, params, parent) : new ZipFileEntry(parent.fs, name, params, parent);
10798
10872
  } else {
10799
10873
  throw new Error("Parent entry is not a directory");
10800
10874
  }
10801
10875
  }
10802
10876
 
10803
- export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_COMPRESSED_PATCHED_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_UNKNOWN_VERSION, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_WRAPPED_ENTRIES_COUNT, Writer, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
10877
+ function checkDuplicatesOption(duplicates) {
10878
+ if (duplicates === UNDEFINED_VALUE) {
10879
+ return DUPLICATES_THROW;
10880
+ } else if (DUPLICATES_VALUES.has(duplicates)) {
10881
+ return duplicates;
10882
+ } else {
10883
+ throw new Error(ERR_INVALID_DUPLICATES);
10884
+ }
10885
+ }
10886
+
10887
+ function splitPath(name) {
10888
+ if (name.includes("/")) {
10889
+ const path = name.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
10890
+ if (path.length) {
10891
+ return path;
10892
+ }
10893
+ }
10894
+ }
10895
+
10896
+ function getPathParent(parent, path, movedEntry) {
10897
+ path.forEach(pathPart => {
10898
+ const previousParent = parent;
10899
+ parent = parent.getChildByName(pathPart);
10900
+ if (parent) {
10901
+ if (!parent.directory) {
10902
+ throw new Error(ERR_ENTRY_EXISTS);
10903
+ }
10904
+ if (movedEntry && (parent == movedEntry || parent.isDescendantOf(movedEntry))) {
10905
+ throw new Error(ERR_ANCESTOR_ENTRY);
10906
+ }
10907
+ } else {
10908
+ parent = new ZipDirectoryEntry(previousParent.fs, pathPart, { data: null }, previousParent);
10909
+ }
10910
+ });
10911
+ return parent;
10912
+ }
10913
+
10914
+ export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_DUPLICATE_IMPORTED_ENTRY, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_DATE, ERR_INVALID_DUPLICATES, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_COMMENT_TYPE, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_DATA_TYPE, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_FUNCTION_OPTION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MAX_WORKERS, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_PASS_THROUGH, ERR_INVALID_READER_OPTIONS, ERR_INVALID_SIGNAL, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_COMPRESSION_METHOD, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_UNSUPPORTED_UINT64, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_CRYPTO_LAST_MOD_DATE, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, VERSION, WARNING_APPENDED_DATA, WARNING_COMPRESSED_PATCHED_DATA, WARNING_DUPLICATE_FILENAME, WARNING_MALFORMED_EXTRA_FIELD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY, WARNING_PREPENDED_CENTRAL_DIRECTORY, WARNING_PREPENDED_DATA, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA, WARNING_UNKNOWN_VERSION, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA, WARNING_UNSORTED_CENTRAL_DIRECTORY, WARNING_WRAPPED_ENTRIES_COUNT, Writer, ZipDirectoryEntry, ZipEntry, ZipFS, ZipFileEntry, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, getRegisteredCodecs, getSupportedCompressionMethods, isZipFile, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };