@zip.js/zip.js 2.6.78 → 2.6.80

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/README.md CHANGED
@@ -10,6 +10,10 @@ encryption.
10
10
 
11
11
  See here for more info: https://gildas-lormeau.github.io/zip.js/
12
12
 
13
+ ## PWA Demo based on React
14
+
15
+ See https://gildas-lormeau.github.io/zipjs-react-app
16
+
13
17
  # Examples
14
18
 
15
19
  ## Hello world
@@ -164,8 +168,6 @@ function downloadFile(blob) {
164
168
 
165
169
  Run the code on Plunker: https://plnkr.co/edit/4sVljNIpqSUE9HCA?preview
166
170
 
167
- See here for more examples:
168
- https://github.com/gildas-lormeau/zip.js/tree/master/tests/all
171
+ ## Tests
169
172
 
170
- Demo written wth React:
171
- https://gildas-lormeau.github.io/zipjs-react-app
173
+ See https://github.com/gildas-lormeau/zip.js/tree/master/tests/all
@@ -10100,6 +10100,7 @@
10100
10100
  fs,
10101
10101
  name,
10102
10102
  data: params.data,
10103
+ options: params.options,
10103
10104
  id: fs.entries.length,
10104
10105
  parent,
10105
10106
  children: [],
@@ -10266,39 +10267,43 @@
10266
10267
  return clonedEntry;
10267
10268
  }
10268
10269
 
10269
- addDirectory(name) {
10270
- return addChild(this, name, null, true);
10270
+ addDirectory(name, options) {
10271
+ return addChild(this, name, { options }, true);
10271
10272
  }
10272
10273
 
10273
- addText(name, text) {
10274
+ addText(name, text, options = {}) {
10274
10275
  return addChild(this, name, {
10275
10276
  data: text,
10276
10277
  Reader: TextReader,
10277
- Writer: TextWriter
10278
+ Writer: TextWriter,
10279
+ options
10278
10280
  });
10279
10281
  }
10280
10282
 
10281
- addBlob(name, blob) {
10283
+ addBlob(name, blob, options = {}) {
10282
10284
  return addChild(this, name, {
10283
10285
  data: blob,
10284
10286
  Reader: BlobReader,
10285
- Writer: BlobWriter
10287
+ Writer: BlobWriter,
10288
+ options
10286
10289
  });
10287
10290
  }
10288
10291
 
10289
- addData64URI(name, dataURI) {
10292
+ addData64URI(name, dataURI, options = {}) {
10290
10293
  return addChild(this, name, {
10291
10294
  data: dataURI,
10292
10295
  Reader: Data64URIReader,
10293
- Writer: Data64URIWriter
10296
+ Writer: Data64URIWriter,
10297
+ options
10294
10298
  });
10295
10299
  }
10296
10300
 
10297
- addUint8Array(name, array) {
10301
+ addUint8Array(name, array, options = {}) {
10298
10302
  return addChild(this, name, {
10299
10303
  data: array,
10300
10304
  Reader: Uint8ArrayReader,
10301
- Writer: Uint8ArrayWriter
10305
+ Writer: Uint8ArrayWriter,
10306
+ options
10302
10307
  });
10303
10308
  }
10304
10309
 
@@ -10309,18 +10314,20 @@
10309
10314
  constructor(url) {
10310
10315
  super(url, options);
10311
10316
  }
10312
- }
10317
+ },
10318
+ options
10313
10319
  });
10314
10320
  }
10315
10321
 
10316
- addReadable(name, readable) {
10322
+ addReadable(name, readable, options = {}) {
10317
10323
  return addChild(this, name, {
10318
- Reader: function () { return { readable }; }
10324
+ Reader: function () { return { readable }; },
10325
+ options
10319
10326
  });
10320
10327
  }
10321
10328
 
10322
- addFileSystemEntry(fileSystemEntry) {
10323
- return addFileSystemEntry(this, fileSystemEntry);
10329
+ addFileSystemEntry(fileSystemEntry, options = {}) {
10330
+ return addFileSystemEntry(this, fileSystemEntry, options);
10324
10331
  }
10325
10332
 
10326
10333
  addData(name, params) {
@@ -10458,32 +10465,32 @@
10458
10465
  return this.root.getChildByName(name);
10459
10466
  }
10460
10467
 
10461
- addDirectory(name) {
10462
- return this.root.addDirectory(name);
10468
+ addDirectory(name, options) {
10469
+ return this.root.addDirectory(name, options);
10463
10470
  }
10464
10471
 
10465
- addText(name, text) {
10466
- return this.root.addText(name, text);
10472
+ addText(name, text, options) {
10473
+ return this.root.addText(name, text, options);
10467
10474
  }
10468
10475
 
10469
- addBlob(name, blob) {
10470
- return this.root.addBlob(name, blob);
10476
+ addBlob(name, blob, options) {
10477
+ return this.root.addBlob(name, blob, options);
10471
10478
  }
10472
10479
 
10473
- addData64URI(name, dataURI) {
10474
- return this.root.addData64URI(name, dataURI);
10480
+ addData64URI(name, dataURI, options) {
10481
+ return this.root.addData64URI(name, dataURI, options);
10475
10482
  }
10476
10483
 
10477
10484
  addHttpContent(name, url, options) {
10478
10485
  return this.root.addHttpContent(name, url, options);
10479
10486
  }
10480
10487
 
10481
- addReadable(name, readable) {
10482
- return this.root.addReadable(name, readable);
10488
+ addReadable(name, readable, options) {
10489
+ return this.root.addReadable(name, readable, options);
10483
10490
  }
10484
10491
 
10485
- addFileSystemEntry(fileSystemEntry) {
10486
- return this.root.addFileSystemEntry(fileSystemEntry);
10492
+ addFileSystemEntry(fileSystemEntry, options) {
10493
+ return this.root.addFileSystemEntry(fileSystemEntry, options);
10487
10494
  }
10488
10495
 
10489
10496
  addData(name, params) {
@@ -10578,7 +10585,16 @@
10578
10585
  await initReaders(child, options);
10579
10586
  } else {
10580
10587
  const reader = child.reader = new child.Reader(child.data, options);
10581
- await initStream(reader);
10588
+ try {
10589
+ await initStream(reader);
10590
+ } catch (error) {
10591
+ try {
10592
+ error.entryId = child.id;
10593
+ } catch (_error) {
10594
+ // ignored
10595
+ }
10596
+ throw error;
10597
+ }
10582
10598
  child.uncompressedSize = reader.size;
10583
10599
  }
10584
10600
  }));
@@ -10616,9 +10632,32 @@
10616
10632
 
10617
10633
  async function processChild(child) {
10618
10634
  const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
10635
+ let externalFileAttribute;
10636
+ let versionMadeBy;
10637
+ let comment;
10638
+ let lastModDate;
10639
+ let lastAccessDate;
10640
+ let creationDate;
10641
+ let childOptions = child.options || {};
10642
+ if (child.data instanceof Entry) {
10643
+ ({
10644
+ externalFileAttribute,
10645
+ versionMadeBy,
10646
+ comment,
10647
+ lastModDate,
10648
+ lastAccessDate,
10649
+ creationDate
10650
+ } = child.data);
10651
+ }
10619
10652
  await zipWriter.add(name, child.reader, Object.assign({
10620
10653
  directory: child.directory
10621
10654
  }, Object.assign({}, options, {
10655
+ externalFileAttribute,
10656
+ versionMadeBy,
10657
+ comment,
10658
+ lastModDate,
10659
+ lastAccessDate,
10660
+ creationDate,
10622
10661
  onprogress: async indexProgress => {
10623
10662
  if (options.onprogress) {
10624
10663
  entryOffsets.set(name, indexProgress);
@@ -10629,30 +10668,30 @@
10629
10668
  }
10630
10669
  }
10631
10670
  }
10632
- })));
10671
+ }, childOptions)));
10633
10672
  await process(zipWriter, child);
10634
10673
  }
10635
10674
  }
10636
10675
  }
10637
10676
 
10638
- async function addFileSystemEntry(zipEntry, fileSystemEntry) {
10677
+ async function addFileSystemEntry(zipEntry, fileSystemEntry, options) {
10639
10678
  if (fileSystemEntry.isDirectory) {
10640
- const entry = zipEntry.addDirectory(fileSystemEntry.name);
10679
+ const entry = zipEntry.addDirectory(fileSystemEntry.name, options);
10641
10680
  await addDirectory(entry, fileSystemEntry);
10642
10681
  return entry;
10643
10682
  } else {
10644
- return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file)), reject));
10683
+ return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file, options)), reject));
10645
10684
  }
10646
10685
 
10647
10686
  async function addDirectory(zipEntry, fileEntry) {
10648
10687
  const children = await getChildren(fileEntry);
10649
10688
  for (const child of children) {
10650
10689
  if (child.isDirectory) {
10651
- await addDirectory(zipEntry.addDirectory(child.name), child);
10690
+ await addDirectory(zipEntry.addDirectory(child.name, options), child);
10652
10691
  } else {
10653
10692
  await new Promise((resolve, reject) => {
10654
10693
  child.file(file => {
10655
- const childZipEntry = zipEntry.addBlob(child.name, file);
10694
+ const childZipEntry = zipEntry.addBlob(child.name, file, options);
10656
10695
  childZipEntry.uncompressedSize = file.size;
10657
10696
  resolve(childZipEntry);
10658
10697
  }, reject);