@zip.js/zip.js 2.6.79 → 2.6.81

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,10 +168,6 @@ function downloadFile(blob) {
164
168
 
165
169
  Run the code on Plunker: https://plnkr.co/edit/4sVljNIpqSUE9HCA?preview
166
170
 
167
- ## Demo of the FS API based on React
168
-
169
- See https://gildas-lormeau.github.io/zipjs-react-app
170
-
171
171
  ## Tests
172
172
 
173
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) {
@@ -10625,9 +10632,26 @@
10625
10632
 
10626
10633
  async function processChild(child) {
10627
10634
  const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
10635
+ let externalFileAttribute;
10636
+ let versionMadeBy;
10637
+ let comment;
10638
+ let lastModDate;
10639
+ let childOptions = child.options || {};
10640
+ if (child.data instanceof Entry) {
10641
+ ({
10642
+ externalFileAttribute,
10643
+ versionMadeBy,
10644
+ comment,
10645
+ lastModDate
10646
+ } = child.data);
10647
+ }
10628
10648
  await zipWriter.add(name, child.reader, Object.assign({
10629
10649
  directory: child.directory
10630
10650
  }, Object.assign({}, options, {
10651
+ externalFileAttribute,
10652
+ versionMadeBy,
10653
+ comment,
10654
+ lastModDate,
10631
10655
  onprogress: async indexProgress => {
10632
10656
  if (options.onprogress) {
10633
10657
  entryOffsets.set(name, indexProgress);
@@ -10638,30 +10662,30 @@
10638
10662
  }
10639
10663
  }
10640
10664
  }
10641
- })));
10665
+ }, childOptions)));
10642
10666
  await process(zipWriter, child);
10643
10667
  }
10644
10668
  }
10645
10669
  }
10646
10670
 
10647
- async function addFileSystemEntry(zipEntry, fileSystemEntry) {
10671
+ async function addFileSystemEntry(zipEntry, fileSystemEntry, options) {
10648
10672
  if (fileSystemEntry.isDirectory) {
10649
- const entry = zipEntry.addDirectory(fileSystemEntry.name);
10673
+ const entry = zipEntry.addDirectory(fileSystemEntry.name, options);
10650
10674
  await addDirectory(entry, fileSystemEntry);
10651
10675
  return entry;
10652
10676
  } else {
10653
- return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file)), reject));
10677
+ return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file, options)), reject));
10654
10678
  }
10655
10679
 
10656
10680
  async function addDirectory(zipEntry, fileEntry) {
10657
10681
  const children = await getChildren(fileEntry);
10658
10682
  for (const child of children) {
10659
10683
  if (child.isDirectory) {
10660
- await addDirectory(zipEntry.addDirectory(child.name), child);
10684
+ await addDirectory(zipEntry.addDirectory(child.name, options), child);
10661
10685
  } else {
10662
10686
  await new Promise((resolve, reject) => {
10663
10687
  child.file(file => {
10664
- const childZipEntry = zipEntry.addBlob(child.name, file);
10688
+ const childZipEntry = zipEntry.addBlob(child.name, file, options);
10665
10689
  childZipEntry.uncompressedSize = file.size;
10666
10690
  resolve(childZipEntry);
10667
10691
  }, reject);