@zip.js/zip.js 2.9.0 → 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.
package/index.cjs CHANGED
@@ -3475,21 +3475,14 @@ async function terminateWorkers() {
3475
3475
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3476
3476
  */
3477
3477
 
3478
- /* global TextDecoder */
3479
-
3480
3478
  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("");
3481
- const VALID_CP437 = CP437.length == 256;
3482
3479
 
3483
3480
  function decodeCP437(stringValue) {
3484
- if (VALID_CP437) {
3485
- let result = "";
3486
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3487
- result += CP437[stringValue[indexCharacter]];
3488
- }
3489
- return result;
3490
- } else {
3491
- return new TextDecoder().decode(stringValue);
3481
+ let result = "";
3482
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
3483
+ result += CP437[stringValue[indexCharacter]];
3492
3484
  }
3485
+ return result;
3493
3486
  }
3494
3487
 
3495
3488
  /*
@@ -8624,7 +8617,7 @@ function formatSupported(StreamClass, format) {
8624
8617
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8625
8618
  */
8626
8619
 
8627
- const VERSION = "2.9.0";
8620
+ const VERSION = "2.10.0";
8628
8621
 
8629
8622
  /*
8630
8623
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -9516,7 +9509,14 @@ l(setDefaultConfiguration);
9516
9509
 
9517
9510
 
9518
9511
  const ERR_ENTRY_EXISTS = "Entry filename already exists";
9512
+ const ERR_DUPLICATE_IMPORTED_ENTRY = "Duplicate entry filename in the imported zip file";
9513
+ const ERR_INVALID_DUPLICATES = "Invalid duplicates option (must be \"throw\", \"keep-first\" or \"keep-last\")";
9514
+ const ERR_ANCESTOR_ENTRY = "Entry is a ancestor of target entry";
9519
9515
  const ERR_READABLE_CONSUMED = "Readable stream already consumed";
9516
+ const DUPLICATES_THROW = "throw";
9517
+ const DUPLICATES_KEEP_FIRST = "keep-first";
9518
+ const DUPLICATES_KEEP_LAST = "keep-last";
9519
+ const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPLICATES_KEEP_LAST]);
9520
9520
  const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
9521
9521
  const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
9522
9522
  const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
@@ -9593,12 +9593,26 @@ class ZipEntry {
9593
9593
  }
9594
9594
 
9595
9595
  rename(name) {
9596
- const parent = this.parent;
9597
- if (parent && parent.getChildByName(name)) {
9598
- throw new Error(ERR_ENTRY_EXISTS);
9599
- } else {
9600
- this.name = name;
9596
+ const zipEntry = this;
9597
+ let parent = zipEntry.parent;
9598
+ if (parent) {
9599
+ const path = splitPath(name);
9600
+ if (path) {
9601
+ name = path.pop();
9602
+ parent = getPathParent(parent, path, zipEntry);
9603
+ }
9604
+ const existingChild = parent.getChildByName(name);
9605
+ if (existingChild && existingChild != zipEntry) {
9606
+ throw new Error(ERR_ENTRY_EXISTS);
9607
+ }
9608
+ if (parent != zipEntry.parent) {
9609
+ detach(zipEntry);
9610
+ zipEntry.parent = parent;
9611
+ parent.children.push(zipEntry);
9612
+ registerEntries(zipEntry.fs, zipEntry);
9613
+ }
9601
9614
  }
9615
+ zipEntry.name = name;
9602
9616
  }
9603
9617
 
9604
9618
  setOptions(options) {
@@ -9691,47 +9705,47 @@ class ZipFileEntry extends ZipEntry {
9691
9705
  }
9692
9706
 
9693
9707
  replaceBlob(blob) {
9694
- Object.assign(this, {
9708
+ replaceContent(this, {
9695
9709
  data: blob,
9696
9710
  Reader: BlobReader,
9697
9711
  Writer: BlobWriter,
9698
- reader: null
9712
+ uncompressedSize: blob.size
9699
9713
  });
9700
9714
  }
9701
9715
 
9702
9716
  replaceText(text) {
9703
- Object.assign(this, {
9717
+ replaceContent(this, {
9704
9718
  data: text,
9705
9719
  Reader: TextReader,
9706
9720
  Writer: TextWriter,
9707
- reader: null
9721
+ uncompressedSize: getTextSize(text)
9708
9722
  });
9709
9723
  }
9710
9724
 
9711
9725
  replaceData64URI(dataURI) {
9712
- Object.assign(this, {
9726
+ replaceContent(this, {
9713
9727
  data: dataURI,
9714
9728
  Reader: Data64URIReader,
9715
9729
  Writer: Data64URIWriter,
9716
- reader: null
9730
+ uncompressedSize: getData64URISize(dataURI)
9717
9731
  });
9718
9732
  }
9719
9733
 
9720
9734
  replaceUint8Array(array) {
9721
- Object.assign(this, {
9735
+ replaceContent(this, {
9722
9736
  data: array,
9723
9737
  Reader: Uint8ArrayReader,
9724
9738
  Writer: Uint8ArrayWriter,
9725
- reader: null
9739
+ uncompressedSize: array.length
9726
9740
  });
9727
9741
  }
9728
9742
 
9729
9743
  replaceReadable(readable) {
9730
- Object.assign(this, {
9744
+ replaceContent(this, {
9731
9745
  data: null,
9732
9746
  Reader: getReadableReader(readable),
9733
9747
  Writer: null,
9734
- reader: null
9748
+ uncompressedSize: UNDEFINED_VALUE
9735
9749
  });
9736
9750
  }
9737
9751
  }
@@ -9781,17 +9795,12 @@ class ZipDirectoryEntry extends ZipEntry {
9781
9795
  }
9782
9796
 
9783
9797
  addData64URI(name, dataURI, options = {}) {
9784
- let dataEnd = dataURI.length;
9785
- while (dataURI.charAt(dataEnd - 1) == "=") {
9786
- dataEnd--;
9787
- }
9788
- const dataStart = dataURI.indexOf(",") + 1;
9789
9798
  return addChild(this, name, {
9790
9799
  data: dataURI,
9791
9800
  Reader: Data64URIReader,
9792
9801
  Writer: Data64URIWriter,
9793
9802
  options,
9794
- uncompressedSize: Math.floor((dataEnd - dataStart) * 0.75)
9803
+ uncompressedSize: getData64URISize(dataURI)
9795
9804
  });
9796
9805
  }
9797
9806
 
@@ -9899,6 +9908,7 @@ class ZipDirectoryEntry extends ZipEntry {
9899
9908
  await initStream(reader);
9900
9909
  zipReader = new ZipReader(reader, options);
9901
9910
  }
9911
+ const duplicates = checkDuplicatesOption(options.duplicates);
9902
9912
  const importedEntries = [];
9903
9913
  const entries = await zipReader.getEntries(options);
9904
9914
  for (const entry of entries) {
@@ -9906,19 +9916,42 @@ class ZipDirectoryEntry extends ZipEntry {
9906
9916
  try {
9907
9917
  const path = entry.filename.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
9908
9918
  const name = path.pop();
9909
- path.forEach(pathPart => {
9919
+ let skippedEntry = false;
9920
+ for (const pathPart of path) {
9910
9921
  const previousParent = parent;
9911
9922
  parent = parent.getChildByName(pathPart);
9912
9923
  if (parent) {
9913
9924
  if (!parent.directory) {
9914
- throw new Error(ERR_ENTRY_EXISTS);
9925
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9926
+ skippedEntry = true;
9927
+ break;
9928
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9929
+ this.fs.remove(parent);
9930
+ parent = new ZipDirectoryEntry(this.fs, pathPart, { data: null }, previousParent);
9931
+ importedEntries.push(parent);
9932
+ } else {
9933
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9934
+ }
9915
9935
  }
9916
9936
  } else {
9917
9937
  parent = new ZipDirectoryEntry(this.fs, pathPart, { data: null }, previousParent);
9918
9938
  importedEntries.push(parent);
9919
9939
  }
9920
- });
9940
+ }
9941
+ if (skippedEntry) {
9942
+ continue;
9943
+ }
9921
9944
  if (!entry.directory) {
9945
+ const existingChild = parent.getChildByName(name);
9946
+ if (existingChild) {
9947
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9948
+ continue;
9949
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9950
+ this.fs.remove(existingChild);
9951
+ } else {
9952
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9953
+ }
9954
+ }
9922
9955
  importedEntries.push(addChild(parent, name, {
9923
9956
  data: entry,
9924
9957
  Reader: getZipBlobReader(Object.assign({}, options)),
@@ -9929,11 +9962,17 @@ class ZipDirectoryEntry extends ZipEntry {
9929
9962
  let directoryEntry = parent;
9930
9963
  if (name) {
9931
9964
  directoryEntry = parent.getChildByName(name);
9932
- if (directoryEntry) {
9933
- if (!directoryEntry.directory) {
9934
- throw new Error(ERR_ENTRY_EXISTS);
9965
+ if (directoryEntry && !directoryEntry.directory) {
9966
+ if (duplicates == DUPLICATES_KEEP_FIRST) {
9967
+ continue;
9968
+ } else if (duplicates == DUPLICATES_KEEP_LAST) {
9969
+ this.fs.remove(directoryEntry);
9970
+ directoryEntry = UNDEFINED_VALUE;
9971
+ } else {
9972
+ throw new Error(ERR_DUPLICATE_IMPORTED_ENTRY);
9935
9973
  }
9936
- } else {
9974
+ }
9975
+ if (!directoryEntry) {
9937
9976
  directoryEntry = new ZipDirectoryEntry(this.fs, name, { data: null }, parent);
9938
9977
  importedEntries.push(directoryEntry);
9939
9978
  }
@@ -9943,6 +9982,7 @@ class ZipDirectoryEntry extends ZipEntry {
9943
9982
  }
9944
9983
  }
9945
9984
  } catch (error) {
9985
+ importedEntries.reverse().forEach(importedEntry => this.fs.remove(importedEntry));
9946
9986
  try {
9947
9987
  error.cause = {
9948
9988
  entry
@@ -10061,7 +10101,7 @@ class ZipFS {
10061
10101
  }
10062
10102
  }
10063
10103
  } else {
10064
- throw new Error("Entry is a ancestor of target entry");
10104
+ throw new Error(ERR_ANCESTOR_ENTRY);
10065
10105
  }
10066
10106
  } else {
10067
10107
  throw new Error("Target entry is not a directory");
@@ -10073,7 +10113,7 @@ class ZipFS {
10073
10113
  const path = fullname.split("/");
10074
10114
  let node = this.root;
10075
10115
  for (let index = 0; node && index < path.length; index++) {
10076
- node = node.getChildByName(path[index]);
10116
+ node = node.directory ? node.getChildByName(path[index]) : UNDEFINED_VALUE;
10077
10117
  }
10078
10118
  if (!node) {
10079
10119
  node = this.entries.find(entry => entry && (entry == this.root || entry.isDescendantOf(this.root)) &&
@@ -10135,33 +10175,27 @@ class ZipFS {
10135
10175
  }
10136
10176
 
10137
10177
  importBlob(blob, options) {
10138
- resetFS(this);
10139
- return this.root.importBlob(blob, options);
10178
+ return resetAndImport(this, root => root.importBlob(blob, options));
10140
10179
  }
10141
10180
 
10142
10181
  importData64URI(dataURI, options) {
10143
- resetFS(this);
10144
- return this.root.importData64URI(dataURI, options);
10182
+ return resetAndImport(this, root => root.importData64URI(dataURI, options));
10145
10183
  }
10146
10184
 
10147
10185
  importUint8Array(array, options) {
10148
- resetFS(this);
10149
- return this.root.importUint8Array(array, options);
10186
+ return resetAndImport(this, root => root.importUint8Array(array, options));
10150
10187
  }
10151
10188
 
10152
10189
  importHttpContent(url, options) {
10153
- resetFS(this);
10154
- return this.root.importHttpContent(url, options);
10190
+ return resetAndImport(this, root => root.importHttpContent(url, options));
10155
10191
  }
10156
10192
 
10157
10193
  importReadable(readable, options) {
10158
- resetFS(this);
10159
- return this.root.importReadable(readable, options);
10194
+ return resetAndImport(this, root => root.importReadable(readable, options));
10160
10195
  }
10161
10196
 
10162
10197
  importZip(reader, options) {
10163
- resetFS(this);
10164
- return this.root.importZip(reader, options);
10198
+ return resetAndImport(this, root => root.importZip(reader, options));
10165
10199
  }
10166
10200
 
10167
10201
  exportBlob(options) {
@@ -10481,6 +10515,25 @@ function checkReaderOptions(readerOptions) {
10481
10515
  return readerOptions;
10482
10516
  }
10483
10517
 
10518
+ function replaceContent(zipEntry, params) {
10519
+ const { uncompressedSize } = params;
10520
+ Object.assign(zipEntry, params, {
10521
+ reader: null,
10522
+ passThrough: UNDEFINED_VALUE,
10523
+ uncompressedSize: uncompressedSize === UNDEFINED_VALUE ? 0 : uncompressedSize,
10524
+ undeterminedSize: uncompressedSize === UNDEFINED_VALUE
10525
+ });
10526
+ }
10527
+
10528
+ function getData64URISize(dataURI) {
10529
+ let dataEnd = dataURI.length;
10530
+ while (dataURI.charAt(dataEnd - 1) == "=") {
10531
+ dataEnd--;
10532
+ }
10533
+ const dataStart = dataURI.indexOf(",") + 1;
10534
+ return Math.floor((dataEnd - dataStart) * 0.75);
10535
+ }
10536
+
10484
10537
  function isPassThrough(child, options) {
10485
10538
  const { readerOptions } = options;
10486
10539
  return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
@@ -10770,6 +10823,15 @@ function resetFS(fs) {
10770
10823
  fs.root = new ZipDirectoryEntry(fs);
10771
10824
  }
10772
10825
 
10826
+ function resetAndImport(fs, importFunction) {
10827
+ const { entries, entryIdCounter, root } = fs;
10828
+ resetFS(fs);
10829
+ return importFunction(fs.root).catch(error => {
10830
+ Object.assign(fs, { entries, entryIdCounter, root });
10831
+ throw error;
10832
+ });
10833
+ }
10834
+
10773
10835
  function collectChildren(directory, recursive) {
10774
10836
  const children = [];
10775
10837
  const pendingDirectories = [directory];
@@ -10798,12 +10860,54 @@ function registerEntries(fs, entry) {
10798
10860
 
10799
10861
  function addChild(parent, name, params, directory) {
10800
10862
  if (parent.directory) {
10863
+ const path = splitPath(name);
10864
+ if (path) {
10865
+ name = path.pop();
10866
+ parent = getPathParent(parent, path);
10867
+ }
10801
10868
  return directory ? new ZipDirectoryEntry(parent.fs, name, params, parent) : new ZipFileEntry(parent.fs, name, params, parent);
10802
10869
  } else {
10803
10870
  throw new Error("Parent entry is not a directory");
10804
10871
  }
10805
10872
  }
10806
10873
 
10874
+ function checkDuplicatesOption(duplicates) {
10875
+ if (duplicates === UNDEFINED_VALUE) {
10876
+ return DUPLICATES_THROW;
10877
+ } else if (DUPLICATES_VALUES.has(duplicates)) {
10878
+ return duplicates;
10879
+ } else {
10880
+ throw new Error(ERR_INVALID_DUPLICATES);
10881
+ }
10882
+ }
10883
+
10884
+ function splitPath(name) {
10885
+ if (name.includes("/")) {
10886
+ const path = name.split("/").filter(pathPart => pathPart != "" && pathPart != ".");
10887
+ if (path.length) {
10888
+ return path;
10889
+ }
10890
+ }
10891
+ }
10892
+
10893
+ function getPathParent(parent, path, movedEntry) {
10894
+ path.forEach(pathPart => {
10895
+ const previousParent = parent;
10896
+ parent = parent.getChildByName(pathPart);
10897
+ if (parent) {
10898
+ if (!parent.directory) {
10899
+ throw new Error(ERR_ENTRY_EXISTS);
10900
+ }
10901
+ if (movedEntry && (parent == movedEntry || parent.isDescendantOf(movedEntry))) {
10902
+ throw new Error(ERR_ANCESTOR_ENTRY);
10903
+ }
10904
+ } else {
10905
+ parent = new ZipDirectoryEntry(previousParent.fs, pathPart, { data: null }, previousParent);
10906
+ }
10907
+ });
10908
+ return parent;
10909
+ }
10910
+
10807
10911
  const encodedMimeTypes = "application:0andrew-inset ez,2nodex anx,1pplixware aw,1tom!,4cat!,4serv! atomsrv,5vc!,0bbolin lin,0ccxml!,1dmi-capability cdmia,6ontainer cdmic,5domain cdmid,5object cdmio,5queue cdmiq,1u-seeme cu,0davmount!,1ocbook! dbk,1sptype tsp,2sc+der,4! xdssc,0ecmascript es ecma,1mma!,1nvoy evy,1pub+zip,1xi,0font-tdpfr pfr,1ractals fif,1uturesplash spl,0gml!,1px!,1xf,1zip gz tgz,0hta,1yperstudio stk,0inkml! ink inkml,2ternet-property-stream acx,1pfix,0java-archive jar,5serialized-object ser,5vm class,1sonml+json,0lost! lostxml,0m3g,1ac-binhex40 hqx,2ds!,2rc mrc,4xml! mrcx,2thematica nb ma mb,4ml! mathml mml,1box,1ediaservercontrol! mscml,2talink!,84! meta4,3s!,1ods!,1p21 m21 mp21,24 mp4s,1saccess mdb,2word doc dot wiz,1xf,0oda,1ebps-package! opf,1gg ogx,1lescript axs,1mdoc!,1nenote onetoc onetoc2 onetmp onepkg,1xps,0patch-ops-error! xer,1df,1gp-encrypted pgp,4keys key,4signature asc sig,1ics-rules prf,1kcs10 p10,47-mime p7m p7c,6signature p7s,48 p8,2ix-attr-cert ac,5crl crl,5pkipath pkipath,4cmp pki,1ls!,1ostscript ps ai eps epsi epsf eps2 eps3,1rs.cww cww,1skc! pskcxml,0rar,1df!,1eginfo! rif,2lax-ng-compact-syntax rnc,2source-lists! rl,e-diff! rld,1ls-services! rs,1pki-ghostbusters gbr,5manifest mft,5roa roa,1sd!,2s!,1tf,0sbml!,1cvp-cv-request scq,asponse scs,5vp-request spq,asponse spp,1dp,1et-payment-initiation setpay,4registration-initiation setreg,1hf!,1mil! smi smil,1parql-query rq,7results! srx,1rgs gram,4! grxml,2u!,1sdl!,2ml!,0tei! tei teicorpus,1hraud! tfi,1imestamped-data tsd,0vnd.3gpp.pic-bw-large plb,gsmall psb,gvar pvb,82.tcap tcap,5m.post-it-notes pwn,4accpac.simply.aso aso,iimp imp,6ucobol acu,9rp atc acutc,5dobe.air-application-installer-package+zip air,aformscentral.fcdt fcdt,bxp fxp fxpl,axdp! xdp,bfdf xfdf,5head.space ahead,5irzip.filesecure.azf azf,os azs,5mazon.ebook azw,6ericandynamics.acc acc,6iga.ami ami,5ndroid.package-archive apk,6ser-web-certificate-issue-initiation cii,efunds-transfer-initiation fti,6tix.game-component atx,5pple.installer! mpkg,ampegurl m3u8,5ristanetworks.swi swi,5straea-software.iota iota,5udiograph aep,4blueice.multipass mpm,5mi bmi,5usinessobjects rep,4chemdraw! cdxml,6ipnuts.karaoke-mmd mmd,5inderella cdy,5laymore cla,6oanto.rp9 rp9,7nk.c4group c4g c4d c4f c4p c4u,6uetrust.cartomobile-config c11amc,w-pkg c11amz,5ommonspace csp,6ntact.cmsg cdbcmsg,6smocaller cmc,5rick.clicker clkx,h.keyboard clkk,ipalette clkp,itemplate clkt,iwordbank clkw,7ticaltools.wbs! wbs,5tc-posml pml,5ups-ppd ppd,6rl.car car,9pcurl pcurl,4dart dart,6ta-vision.rdz rdz,5ebian.binary-package deb udeb,6ce.data uvf uvvf uvd uvvd,9ttml! uvt uvvt,9unspecified uvx uvvx,9zip uvz uvvz,6novo.fcselayout-link fe_launch,5na dna,5olby.mlp mlp,5pgraph dpg,5reamfactory dfac,5s-keypoint kpxx,5vb.ait ait,8service svc,5ynageo geo,4ecowin.chart mag,5nliven nml,5pson.esf esf,amsf msf,aquickanime qam,asalt slt,bsf ssf,5szigno3! es3 et3,5zpix-album ez2,apackage ez3,4fdf fdf,6sn.mseed mseed,9seed seed dataless,5lographit gph,6uxtime.clip ftc,5ramemaker fm frame maker book,6ogans.fnc fnc,cltf ltf,5sc.weblaunch fsc,5ujitsu.oasys oas,h2 oa2,h3 oa3,hgp fg5,hprs bh2,8xerox.ddd ddd,focuworks xdw,n.binder xbd,6zzysheet fzs,4genomatix.tuxedo txd,6ogebra.file ggb,dtool ggt,7metry-explorer gex gre,7next gxt,7plan g2w,7space g3w,5mx gmx,5oogle-earth.kml! kml,jz kmz,5rafeq gqf gqs,6oove-account gac,bhelp ghf,bidentity-message gim,cnjector grv,btool-message gtm,gtemplate tpl,bvcard vcg,4hal! hal,6ndheld-entertainment! zmm,5bci hbci,5he.lesson-player les,5p-hpgl hpgl,9id hpid,9s hps,7jlyt jlt,7pcl pcl,axl pclxl,5ydrostatix.sof-data sfd-hdstx,5zn-3d-crossword x3d,4ibm.minipay mpy,9odcap afp listafp list3820,8rights-management irm,8secure-container sc,5ccprofile icc icm,5gloader igl,5mmervision-ivp ivp,iu ivu,5nsors.igm igm,6tercon.formnet xpw xpx,9geo i2g,7u.qbo qbo,afx qfx,5punplugged.rcprofile rcprofile,5repository.package! irp,5s-xpr xpr,6ac.fcs fcs,4jam jam,5cp.javame.midlet-rms rms,5isp jisp,5oost.joda-archive joda,4kahootz ktz ktr,5de.karbon karbon,9chart chrt,9formula kfo,9ivio flw,9ontour kon,9presenter kpr kpt,9spread ksp,9word kwd kwt,5enameaapp htke,5idspiration kia,6nar kne knp,5oan skp skd skt skm,6dak-descriptor sse,4las.las! lasxml,5lamagraphics.life-balance.desktop lbd,vexchange! lbe,5otus-1-2-3 123,aapproach apr,afreelance pre,anotes nsf,aorganizer org,ascreencam scm,awordpro lwp,4macports.portpkg portpkg,5cd mcd,5edcalcdata mc1,7iastation.cdkey cdkey,5fer mwf,6mp mfm,5icrografx.flo flo,figx igx,6f mif,5obius.daf daf,cis dis,bmbk mbk,cqy mqy,csl msl,bplc plc,btxf txf,6phun.application mpn,bcertificate mpc,6zilla.xul! xul,5s-artgalry cil,7cab-compressed cab,7excel xls xlb xlt xlm xla xlc xlw,c.addin.macroenabled.12 xlam,dsheet.binary.macroenabled.12 xlsb,jmacroenabled.12 xlsm,dtemplate.macroenabled.12 xltm,7fontobject eot,7htmlhelp chm,7ims ims,7lrm lrm,7officetheme thmx,8utlook msg,7pki.seccat cat,ctl stl,acertstore sst,8owerpoint ppt pps pot ppa pwz,h.addin.macroenabled.12 ppam,ipresentation.macroenabled.12 pptm,islide.macroenabled.12 sldm,nshow.macroenabled.12 ppsm,itemplate.macroenabled.12 potm,8roject mpp mpt,7word.document.macroenabled.12 docm,ctemplate.macroenabled.12 dotm,aks wps wks wcm wdb,8pl wpl,7xpsdocument xps,6eq mseq,5usician mus,6vee.style msty,5ynfc taglet,4neurolanguage.nlu nlu,5itf ntf nitf,5oblenet-directory nnd,dsealer nns,dweb nnw,6kia.n-gage.data ngdat,hsymbian.install n-gage,aradio-preset rpst,ms rpss,6vadigm.edm edm,fx edx,ext ext,4oasis.opendocument.chart odc,s-template otc,ndatabase odb,nformula odf,u-template odft,ngraphics odg,v-template otg,nimage odi,s-template oti,npresentation odp,z-template otp,nspreadsheet ods,y-template ots,ntext odt,r-master odm otm,stemplate ott,sweb oth,5lpc-sugar xo,5ma.dd2! dd2,5penofficeorg.extension oxt,8xmlformats-officedocument.presentationml.presentation pptx,zresentationml.slide sldx,zresentationml.slideshow ppsx,zresentationml.template potx,yspreadsheetml.sheet xlsx,zpreadsheetml.template xltx,ywordprocessingml.document docx,zordprocessingml.template dotx,5sgeo.mapguide.package mgp,7i.dp dp,9subsystem esa,4palm pdb pqa oprc,6waafile paw,5g.format str,7osasli ei6,5icsel efif,5mi.widget wg,5ocketlearn plf,6werbuilder6 pbd,5reviewsystems.box box,6oteus.magazine mgz,5ublishare-delta-tree qps,5vi.ptid1 ptid,4quark.quarkxpress qxd qxt qwd qwt qxl qxb,4realvnc.bed bed,6cordare.musicxml mxl,m! musicxml,5ig.cryptonote cryptonote,5n-realmedia rm,g-vbr rmvb,5oute66.link66! link66,4sailingtracker.track st,5eemail see,6ma sema,7d semd,7f semf,5hana.informed.formdata ifm,ntemplate itp,jinterchange iif,jpackage ipk,5imtech-mindmapper twd twds,5maf mmf,7rt.teacher teacher,5olent.sdkm! sdkm sdkd,5potfire.dxp dxp,dsfs sfs,5qlite3 db sqlite sqlite3 db-wal sqlite-wal db-shm sqlite-shm,5tardivision.calc sdc,ihart sds,hdraw sda,himpress sdd,hmath sdf smf,hwriter sdw vor,n-global sgl,6epmania.package smzip,estepchart sm,5un.xml.calc sxc,g.template stc,cdraw sxd,g.template std,cimpress sxi,j.template sti,cmath sxm,cwriter sxw,i.global sxg,jtemplate stw,6s-calendar sus susp,5vd svd,5ymbian.install sis sisx,6ncml! xsm,a.dm+wbxml bdm,d! xdm,4tao.intent-module-archive tao,5cpdump.pcap pcap cap dmp,5mobile-livetv tmo,5rid.tpt tpt,7scape.mxs mxs,6ueapp tra,4ufdl ufd ufdl,5iq.theme utz,5majin umj,5nity unityweb,5oml! uoml,4vcx vcx,5isio vsd vst vss vsw vsdx vssx vstx vssm vstm,9nary vis,5sf vsf,4wap.sic sic,9lc slc,8wbxml wbxml,9mlc wmlc,bscriptc wmlsc,5ebturbo wtb,5olfram.player nbp,6rdperfect wpd,f5.1 wp5,5qd wqd,5t.stf stf,4xara xar,5fdl xfdl,4yamaha.hv-dic hvd,escript hvs,evoice hvp,bopenscoreformat osf,q.osfpvg! osfpvg,bsmaf-audio saf,gphrase spf,5ellowriver-custom-menu cmp,4zul zir zirz,5zazz.deck! zaz,1oicexml! vxml,0widget wgt,2nhlp hlp,1sdl!,2policy!,0x-123 wk,27z-compressed 7z,2abiword abw,3ce-compressed ace,3pple-diskimage dmg,3uthorware-bin aab x32 u32 vox,dmap aam,dseg aas,2bcpio bcpio,3ittorrent torrent,3lorb blb blorb,3zip bz,62 bz2 boz,2cbr cbr cba cbt cb7,4z cbz,3df cdf cda,4link vcd,3fs-compressed cfs,3hat chat,4ess-pgn pgn,3ompress z,4nference nsc,3pio cpio,3sh csh,2dgc-compressed dgc,3irector dir dxr cst cct cxt w3d fgd swa,3ms dms,3oom wad,3tbncx! ncx,5ook! dtb,5resource! res,3vi dvi,2eva eva,2font-bdf bdf,7ghostscript gsf,7linux-psf psf,7pcf pcf,7snf snf,7ttf ttf ttc,8ype1 pfa pfb pfm afm,3reearc arc,6mind mm,2gca-compressed gca,3lulx ulx,3numeric gnumeric,3o-sgf sgf,3ramps-xml gramps,5phing-calculator gcf,3tar gtar taz,2hdf hdf,3ttpd-eruby rhtml,8php phtml pht php,b-source phps,b3 php3,c-preprocessed php3p,b4 php4,b5 php5,2ica ica,3nfo info,4stall-instructions install,4ternet-signup ins isp,3phone iii,3so9660-image iso,2java-jnlp-file jnlp,3mol jmz,2killustrator kil,3rita kra krz,2latex latex,3yx lyx,3zh-compressed lzh lha,4x lzx,2maker frm fb fbdoc,3ie mie,3obipocket-ebook prc mobi,3s-application application,5installer msi,5shortcut lnk,5wmd wmd,5xbap xbap,4binder obd,4cardfile crd,5lip clp,4dos-program com exe bat dll,4mediaview mvb m13 m14,6tafile wmf wmz emf emz,5oney mny,4publisher pub,4schedule scd,4terminal trm,4write wri,2netcdf nc,3s-proxy-autoconfig pac dat,3wc nwc,3zb nzb,2object o,3z-application oza,2perfmon pma pmc pmr pmw,5l pm pl,3kcs12 p12 pfx,67-certificates p7b spc,creqresp p7r,3ython-code pyc pyo,2qgis qgs shp shx,3uicktimeplayer qtl,2redhat-package-manager rpm rpa,4search-info-systems ris,3uby rb,2sh sh,4ar shar,4ockwave-flash swf swfl,3ilverlight scr,d-app xap,3ql sql,3tuffit sit,9x sitx,3ubrip srt,3v4cpio sv4cpio,6rc sv4crc,2t3vm-image t3,3ar tar,3ex-gf gf,6pk pk,6tfm tfm,5info texinfo texi,3gif obj,3rash ~ % bak old sik,2ustar ustar,2wais-source src,3ingz wz,2x509-ca-cert crt der cer,3cf xcf,3fig fig,3liff! xlf,3pinstall xpi,3z xz,2zmachine z1 z2 z3 z4 z5 z6 z7 z8,1aml!,1cap-diff! xdf,1enc!,1html! xhtml xht,1ml xml xsl xsd xpdl,3-dtd dtd,1op!,1proc! xpl,1slt!,2pf!,1v! mxml xhvml xvml xvm,0yaml yaml yml,2ng,1in!,1nd.ms-pkipko pko,0zip;audio:0aac,1dpcm adp,1iff aiff aif aff,1mr,3-wb awb,1nnodex axa,0basic au snd,0flac,0midi mid midi kar rmi,1p4 mp4a,2eg mpga mpega mp3 m4a mp2a m2a m3a,4url m3u,0ogg oga ogg spx,1pus,0prs.sid sid,0s3m,1ilk sil,0vnd.dece.audio uva uvva,5igital-winds eol,5ra dra,5ts dts,7.hd dtshd,4lucent.voice lvp,4ms-playready.media.pya pya,4nuera.ecelp4800 ecelp4800,f7470 ecelp7470,f9600 ecelp9600,4rip rip,0wav,1ebm weba,0x-aiff aifc,2caf caf,2gsm gsm,2matroska mka,3s-wax wax,6ma wma,2pn-realaudio ram,e-plugin rmp,2realaudio ra,2sd2 sd2,1m;chemical:0x-alchemy alc,2cache cac cache,7-csf csf,5tvs-binary cbin cascii ctab,3dx cdx,3hem3d c3d,3if cif,3mdf cmdf,4l cml,3ompass cpa,3rossfire bsd,3sml csml csm,3tx ctx,3xf cxf cef,2embl-dl-nucleotide emb embl,2gamess-input inp gam gamin,4ussian-checkpoint fch fchk,cube cub,binput gau gjc gjf,blog gal,3cg8-sequence gcg,3enbank gen,2hin hin,2isostar istr ist,2jcamp-dx jdx dx,2kinemage kin,2macmolecule mcm,5romodel-input mmod,3dl-molfile mol,6rdfile rd,7xnfile rxn,6sdfile sd,6tgf tgf,3mcif mcif,3ol2 mol2,5conn-Z b,4pac-graph gpt,8input mop mopcrt zmt,8out moo,2ncbi-asn1 asn,b-ascii prt ent,cbinary val,2rosdal ros,2swissprot sw,2vamas-iso14976 vms,3md vmd,2xtel xtel,3yz xyz;font:0otf,0woff,42;image:0avif avif avifs,0bmp,0cgm,1is-cod cod,0g3fax g3,1if,0heic heif heic,0ief,0jpeg jpeg jpg jpe jfif jfif-tbnl jif,0ktx,0pcx,1jpeg pjpg,1ng,1rs.btif btif,0sgi,1vg! svg svgz,0tiff tiff tif,0vnd.adobe.photoshop psd,4dece.graphic uvi uvvi uvg uvvg,5jvu djvu djv,5wg dwg,5xf dxf,4fastbidsheet fbs,5px fpx,5st fst,5ujixerox.edmics-mmr mmr,lrlc rlc,4ms-modi mdi,7photo wdp,4net-fpx npx,4wap.wbmp wbmp,4xiff xif,0webp,0x-3ds 3ds,2adobe-dng dng,2canon-cr2 cr2,aw crw,3mu-raster ras,4x cmx,3oreldraw cdr,bpattern pat,btemplate cdt,7photopaint cpt,2epson-erf erf,2freehand fh fhc fh4 fh5 fh7,3uji-raf raf,2icns icns,4on ico,2jg art,3ng jng,2kodak-dcr dcr,8k25 k25,9dc kdc,2minolta-mrw mrw,2nikon-nef nef,2olympus-orf orf,2panasonic-raw raw rw2 rwl,3entax-pef pef ptx,3ict pic pct,3ortable-anymap pnm,bbitmap pbm,bgraymap pgm,bpixmap ppm,2rgb rgb,2sigma-x3f x3f,3ony-arw arw,7sr2 sr2,9f srf,2tga tga,2xbitmap xbm,3pixmap xpm,3windowdump xwd;message:0rfc822 eml mime mht mhtml nws;model:0iges igs iges,0mesh msh mesh silo,0vnd.collada! dae,4dwf dwf,4gdl gdl,5tw gtw,4mts mts,4usdz+zip usdz,4vtu vtu,1rml wrl vrml,0x3d+binary x3db x3dbz,4vrml x3dv x3dvz,3! x3dz;text:0cache-manifest manifest appcache,2lendar ics icz ifb,1ss,2v,0h323 323,1tml html htm shtml stm,0iuls uls,0javascript js,1son,0markdown md markdown mdown markdn,0n3,0plain txt text brf conf def list log in bas diff ksh,1rs.lines.tag dsc,0richtext rtx,0scriptlet sct wsc,1gml sgml sgm,0tab-separated-values tsv,1exmacs tm,1roff t tr roff man me ms,1urtle ttl,0uri-list uri uris urls,0vcard,1nd.curl curl,8.dcurl dcurl,9mcurl mcurl,9scurl scurl,4dvb.subtitle sub,4fly fly,5mi.flexstor flx,4graphviz gv,4in3d.3dml 3dml,9spot spot,4sun.j2me.app-descriptor jad,4wap.si si,9l sl,8wml wml,bscript wmls,0webviewhtml htt,0x-asm s asm,2bibtex bib,3oo boo,2c c h dic,3++hdr h++ hpp hxx hh,5src c++ cpp cxx cc,3omponent htc,2diff patch,3src d,2fortran f for f77 f90,2haskell hs,2java java,2literate-haskell lhs,2moc moc,2nfo nfo,2opml opml,2pascal p pas pp inc,3cs-gcd gcd,3ython py,2scala scala,3etext etx,3fv sfv,2tcl tcl tk,3ex tex ltx sty cls,2uuencode uu,2vcalendar vcs,5rd vcf;video:03gpp 3gp,42 3g2,0annodex axv,0dl,1v dif dv,0fli,0gl,0h261,33,34,0jpeg jpgv,2m jpm jpgm,0mj2 mj2 mjp2,1p2t ts,24 mp4 mp4v mpg4,2eg mpeg mpg mpe m1v m2v mp2 mpa mpv2,0ogg ogv,0quicktime qt mov,0vnd.dece.hd uvh uvvh,9mobile uvm uvvm,9pd uvp uvvp,9sd uvs uvvs,9video uvv uvvv,5vb.file dvb,4fvt fvt,4mpegurl mxu m4u,5s-playready.media.pyv pyv,4uvvu.mp4 uvu uvvu,4vivo viv,0webm,0x-f4v f4v,3lv flv,2la-asf lsf lsx,2m4v m4v,3atroska mpv mkv mk3d mks,3ng mng,3s-asf asf asx asr,5vob vob,5wm wm,7v wmv,7x wmx,6vx wvx,4video avi,2sgi-movie movie,3mv smv;x-conference:0x-cooltalk ice;x-world:0x-vrml vrm flr wrz xaf xof";
10808
10912
 
10809
10913
  /*
@@ -10908,6 +11012,7 @@ exports.ERR_AMBIGUOUS_ARCHIVE = ERR_AMBIGUOUS_ARCHIVE;
10908
11012
  exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
10909
11013
  exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
10910
11014
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
11015
+ exports.ERR_DUPLICATE_IMPORTED_ENTRY = ERR_DUPLICATE_IMPORTED_ENTRY;
10911
11016
  exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
10912
11017
  exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
10913
11018
  exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
@@ -10925,6 +11030,7 @@ exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
10925
11030
  exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
10926
11031
  exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
10927
11032
  exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
11033
+ exports.ERR_INVALID_DUPLICATES = ERR_INVALID_DUPLICATES;
10928
11034
  exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
10929
11035
  exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
10930
11036
  exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
package/index.d.cts CHANGED
@@ -1594,10 +1594,17 @@ export interface ZipReaderGetEntriesOptions
1594
1594
  export interface GetEntriesOptions {
1595
1595
  /**
1596
1596
  * The encoding of the filename of the entry.
1597
+ *
1598
+ * The option is ignored when the general purpose bit 11 is set in the header of the entry: such a
1599
+ * filename is always decoded as UTF-8. It is only read when the bit is not set, and the filename is
1600
+ * then decoded as IBM Code Page 437 when the option is not set either.
1597
1601
  */
1598
1602
  filenameEncoding?: string;
1599
1603
  /**
1600
1604
  * The encoding of the comment of the entry.
1605
+ *
1606
+ * The option is ignored when the general purpose bit 11 is set in the header of the entry, see
1607
+ * {@link GetEntriesOptions#filenameEncoding}.
1601
1608
  */
1602
1609
  commentEncoding?: string;
1603
1610
  /**
@@ -3244,6 +3251,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3244
3251
  * Note that this option only sets the flag, it does not ensure that the file names are in the correct
3245
3252
  * encoding: when it is set to `false`, the names are still encoded in UTF-8 unless the
3246
3253
  * {@link ZipWriterConstructorOptions#encodeText} option is also set to encode them in the intended code page.
3254
+ * Setting it to `false` alone therefore produces an archive whose file names are mislabeled, holding UTF-8
3255
+ * bytes announced as Code Page 437: the names holding characters outside of ASCII are decoded incorrectly
3256
+ * by the readers honoring the flag, including {@link ZipReader} unless
3257
+ * {@link GetEntriesOptions#filenameEncoding} is set to `"utf-8"`.
3247
3258
  *
3248
3259
  * @defaultValue true
3249
3260
  */
@@ -3458,6 +3469,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
3458
3469
  /**
3459
3470
  * The function called for encoding the filename and the comment of the entry.
3460
3471
  *
3472
+ * zip.js encodes them in UTF-8 when the option is not set, so it must be set to write them in another
3473
+ * code page, together with {@link ZipWriterConstructorOptions#useUnicodeFileNames} set to `false` to
3474
+ * announce them as Code Page 437 instead of UTF-8.
3475
+ *
3461
3476
  * @param text The text to encode.
3462
3477
  * @param type The type of the encoded text, `"filename"` or `"comment"`.
3463
3478
  * @returns The encoded text or `undefined` if the text should be encoded by zip.js.
@@ -3545,6 +3560,9 @@ export class ZipEntry {
3545
3560
  * @remarks It is the size of the raw compressed content when the entry has been imported with the
3546
3561
  * `passThrough` option set to `true`, since the entry holds the compressed data in that case. The
3547
3562
  * uncompressed size of the original entry remains available in {@link ZipEntry#data}.
3563
+ *
3564
+ * It is updated by the `{@link ZipFileEntry}#replace*()` methods, and it is `0` for an entry holding
3565
+ * a `ReadableStream` instance, whose size is only known once the entry has been read.
3548
3566
  */
3549
3567
  uncompressedSize: number;
3550
3568
  /**
@@ -3594,6 +3612,12 @@ export class ZipEntry {
3594
3612
  /**
3595
3613
  * Set the name of the entry
3596
3614
  *
3615
+ * @remarks A name holding `"/"` is split into path components, like the name passed to a
3616
+ * `{@link ZipDirectoryEntry}#add*()` method, so it moves the entry into the directories it names,
3617
+ * creating them when they do not exist. Renaming an entry to the name it already has does nothing.
3618
+ * Renaming it onto an existing sibling throws an {@link ERR_ENTRY_EXISTS} error, and renaming it
3619
+ * into itself or into one of its descendants throws.
3620
+ *
3597
3621
  * @param name The new name of the entry.
3598
3622
  */
3599
3623
  rename(name: string): void;
@@ -3619,6 +3643,11 @@ export class ZipEntry {
3619
3643
 
3620
3644
  /**
3621
3645
  * Represents a file entry in the zip (Filesystem API).
3646
+ *
3647
+ * @remarks A `{@link ZipFileEntry}#replace*()` method describes the entry with the content it is
3648
+ * given: it updates {@link ZipEntry#uncompressedSize} and clears the pass-through state of an entry
3649
+ * imported with the {@link ZipReaderOptions#passThrough} option, since the bytes copied verbatim are
3650
+ * gone. Replacing the content of an entry therefore keeps {@link ZipFS#getExportedSize} exact.
3622
3651
  */
3623
3652
  export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
3624
3653
  /**
@@ -3737,6 +3766,10 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
3737
3766
  /**
3738
3767
  * Replaces the content of the entry with a `ReadableStream` instance
3739
3768
  *
3769
+ * @remarks The size of a `ReadableStream` instance is unknown, so the entry reports an undetermined
3770
+ * size, like an entry added with {@link ZipDirectoryEntry#addReadable}. {@link ZipFS#getExportedSize}
3771
+ * then throws an {@link ERR_UNDETERMINED_SIZE} error instead of returning a size it cannot predict.
3772
+ *
3740
3773
  * @param readable The `ReadableStream` instance.
3741
3774
  */
3742
3775
  replaceReadable(readable: ReadableStream): void;
@@ -3744,6 +3777,13 @@ export class ZipFileEntry<ReaderType, WriterType> extends ZipEntry {
3744
3777
 
3745
3778
  /**
3746
3779
  * Represents a directory entry in the zip (Filesystem API).
3780
+ *
3781
+ * @remarks The `name` passed to an `{@link ZipDirectoryEntry}#add*()` method is split into path
3782
+ * components, exactly like the filename of an imported entry, so `addText("a/b.txt", text)` adds
3783
+ * `"b.txt"` to the `"a"` directory and creates that directory when it does not exist. Empty
3784
+ * components and `"."` components are ignored. The directories created that way are navigable like
3785
+ * any other entry but are not written when the tree is exported, so the zip file holds the same
3786
+ * entries whichever way the path was built.
3747
3787
  */
3748
3788
  export class ZipDirectoryEntry extends ZipEntry {
3749
3789
  /**
@@ -3916,7 +3956,7 @@ export class ZipDirectoryEntry extends ZipEntry {
3916
3956
  */
3917
3957
  importBlob(
3918
3958
  blob: Blob,
3919
- options?: ZipReaderConstructorOptions
3959
+ options?: ZipDirectoryEntryImportOptions
3920
3960
  ): Promise<[ZipEntry]>;
3921
3961
  /**
3922
3962
  * Extracts a zip file provided as a Data URI `string` encoded in Base64 into the entry
@@ -3929,7 +3969,7 @@ export class ZipDirectoryEntry extends ZipEntry {
3929
3969
  */
3930
3970
  importData64URI(
3931
3971
  dataURI: string,
3932
- options?: ZipReaderConstructorOptions
3972
+ options?: ZipDirectoryEntryImportOptions
3933
3973
  ): Promise<[ZipEntry]>;
3934
3974
  /**
3935
3975
  * Extracts a zip file provided as a `Uint8Array` instance into the entry
@@ -3942,7 +3982,7 @@ export class ZipDirectoryEntry extends ZipEntry {
3942
3982
  */
3943
3983
  importUint8Array(
3944
3984
  array: Uint8Array,
3945
- options?: ZipReaderConstructorOptions
3985
+ options?: ZipDirectoryEntryImportOptions
3946
3986
  ): Promise<[ZipEntry]>;
3947
3987
  /**
3948
3988
  * Extracts a zip file fetched from a URL into the entry
@@ -3972,7 +4012,7 @@ export class ZipDirectoryEntry extends ZipEntry {
3972
4012
  */
3973
4013
  importReadable(
3974
4014
  readable: ReadableStream,
3975
- options?: ZipReaderConstructorOptions
4015
+ options?: ZipDirectoryEntryImportOptions
3976
4016
  ): Promise<[ZipEntry]>;
3977
4017
  /**
3978
4018
  * Extracts a zip file provided via a custom {@link Reader} instance or a {@link ZipReader} instance into
@@ -4008,7 +4048,7 @@ export class ZipDirectoryEntry extends ZipEntry {
4008
4048
  | ReadableReader[]
4009
4049
  | ReadableStream[]
4010
4050
  | ZipReader<unknown>,
4011
- options?: ZipReaderConstructorOptions
4051
+ options?: ZipDirectoryEntryImportOptions
4012
4052
  ): Promise<[ZipEntry]>;
4013
4053
  /**
4014
4054
  * Returns a `Blob` instance containing a zip file of the entry and its descendants
@@ -4112,7 +4152,9 @@ export class ZipDirectoryEntry extends ZipEntry {
4112
4152
  * This happens when `usdz` is set, since the alignment padding depends on the offset of each
4113
4153
  * entry, and when the archive exceeds 4GB, since the offsets recorded in the central directory
4114
4154
  * are then extended to 64 bits. Passing `bufferedWrite: false` makes both determinable again,
4115
- * as does exporting a directory whose children are all files. It is thrown as well when
4155
+ * as does exporting a directory whose children are all files. A name holding `"/"` creates the
4156
+ * directories it names, so `addText("a/b.txt", text)` builds a tree whose children are not all
4157
+ * files, even though the directories created that way are not written. It is thrown as well when
4116
4158
  * `signCentralDirectory` is set, the length of the signature being unknown until it is computed.
4117
4159
  *
4118
4160
  * @param options The options.
@@ -4122,11 +4164,39 @@ export class ZipDirectoryEntry extends ZipEntry {
4122
4164
  getExportedSize(options?: ZipDirectoryEntryExportOptions): Promise<number>;
4123
4165
  }
4124
4166
 
4167
+ /**
4168
+ * Represents the options passed to `{@link ZipDirectoryEntry}#import*()`.
4169
+ */
4170
+ export interface ZipDirectoryEntryImportOptions
4171
+ extends ZipReaderConstructorOptions {
4172
+ /**
4173
+ * The policy applied when two entries of the imported zip file claim the same node of the tree
4174
+ *
4175
+ * @remarks
4176
+ * The tree indexes the entries by path, whereas a zip file stores a flat list of filenames, so two
4177
+ * entries can claim one node: they can hold the same filename, hold filenames differing only by the
4178
+ * path components ignored when building the tree (e.g. `"a/b.txt"` and `"./a/b.txt"`), or one can be
4179
+ * a file and the other a directory holding it (e.g. `"a"` and `"a/b.txt"`).
4180
+ *
4181
+ * `"throw"` refuses the zip file with an {@link ERR_DUPLICATE_IMPORTED_ENTRY} error, whose `cause`
4182
+ * property holds the {@link EntryMetaData} instance of the entry that could not be imported. The
4183
+ * filesystem is left unchanged, i.e. the entries imported before the error are removed and the
4184
+ * content held before the import is restored.
4185
+ *
4186
+ * `"keep-first"` ignores the entry claiming a node already taken, and `"keep-last"` replaces the
4187
+ * entry holding the node, which is the behavior of most zip tools. The entries that do not collide
4188
+ * are imported in both cases.
4189
+ *
4190
+ * @defaultValue "throw"
4191
+ */
4192
+ duplicates?: "throw" | "keep-first" | "keep-last";
4193
+ }
4194
+
4125
4195
  /**
4126
4196
  * Represents the options passed to {@link ZipDirectoryEntry#importHttpContent}.
4127
4197
  */
4128
4198
  export interface ZipDirectoryEntryImportHttpOptions
4129
- extends ZipReaderConstructorOptions,
4199
+ extends ZipDirectoryEntryImportOptions,
4130
4200
  HttpOptions {}
4131
4201
 
4132
4202
  /**
@@ -4779,6 +4849,16 @@ export const ERR_ZIP_CRYPTO_LAST_MOD_DATE: string;
4779
4849
  * Entry already exists error (thrown by the filesystem API when adding an entry whose filename already exists)
4780
4850
  */
4781
4851
  export const ERR_ENTRY_EXISTS: string;
4852
+ /**
4853
+ * Duplicate imported entry error (thrown by `{@link ZipDirectoryEntry}#import*()` when two entries of the
4854
+ * zip file claim the same node of the tree and the {@link ZipDirectoryEntryImportOptions#duplicates} option
4855
+ * is set to `"throw"`)
4856
+ */
4857
+ export const ERR_DUPLICATE_IMPORTED_ENTRY: string;
4858
+ /**
4859
+ * Invalid duplicates option error
4860
+ */
4861
+ export const ERR_INVALID_DUPLICATES: string;
4782
4862
  /**
4783
4863
  * Readable stream already consumed error (thrown by the filesystem API when a readable stream is read more than once)
4784
4864
  */