@zip.js/zip.js 2.6.79 → 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/dist/zip-fs.js CHANGED
@@ -4876,6 +4876,7 @@
4876
4876
  fs,
4877
4877
  name,
4878
4878
  data: params.data,
4879
+ options: params.options,
4879
4880
  id: fs.entries.length,
4880
4881
  parent,
4881
4882
  children: [],
@@ -5042,39 +5043,43 @@
5042
5043
  return clonedEntry;
5043
5044
  }
5044
5045
 
5045
- addDirectory(name) {
5046
- return addChild(this, name, null, true);
5046
+ addDirectory(name, options) {
5047
+ return addChild(this, name, { options }, true);
5047
5048
  }
5048
5049
 
5049
- addText(name, text) {
5050
+ addText(name, text, options = {}) {
5050
5051
  return addChild(this, name, {
5051
5052
  data: text,
5052
5053
  Reader: TextReader,
5053
- Writer: TextWriter
5054
+ Writer: TextWriter,
5055
+ options
5054
5056
  });
5055
5057
  }
5056
5058
 
5057
- addBlob(name, blob) {
5059
+ addBlob(name, blob, options = {}) {
5058
5060
  return addChild(this, name, {
5059
5061
  data: blob,
5060
5062
  Reader: BlobReader,
5061
- Writer: BlobWriter
5063
+ Writer: BlobWriter,
5064
+ options
5062
5065
  });
5063
5066
  }
5064
5067
 
5065
- addData64URI(name, dataURI) {
5068
+ addData64URI(name, dataURI, options = {}) {
5066
5069
  return addChild(this, name, {
5067
5070
  data: dataURI,
5068
5071
  Reader: Data64URIReader,
5069
- Writer: Data64URIWriter
5072
+ Writer: Data64URIWriter,
5073
+ options
5070
5074
  });
5071
5075
  }
5072
5076
 
5073
- addUint8Array(name, array) {
5077
+ addUint8Array(name, array, options = {}) {
5074
5078
  return addChild(this, name, {
5075
5079
  data: array,
5076
5080
  Reader: Uint8ArrayReader,
5077
- Writer: Uint8ArrayWriter
5081
+ Writer: Uint8ArrayWriter,
5082
+ options
5078
5083
  });
5079
5084
  }
5080
5085
 
@@ -5085,18 +5090,20 @@
5085
5090
  constructor(url) {
5086
5091
  super(url, options);
5087
5092
  }
5088
- }
5093
+ },
5094
+ options
5089
5095
  });
5090
5096
  }
5091
5097
 
5092
- addReadable(name, readable) {
5098
+ addReadable(name, readable, options = {}) {
5093
5099
  return addChild(this, name, {
5094
- Reader: function () { return { readable }; }
5100
+ Reader: function () { return { readable }; },
5101
+ options
5095
5102
  });
5096
5103
  }
5097
5104
 
5098
- addFileSystemEntry(fileSystemEntry) {
5099
- return addFileSystemEntry(this, fileSystemEntry);
5105
+ addFileSystemEntry(fileSystemEntry, options = {}) {
5106
+ return addFileSystemEntry(this, fileSystemEntry, options);
5100
5107
  }
5101
5108
 
5102
5109
  addData(name, params) {
@@ -5234,32 +5241,32 @@
5234
5241
  return this.root.getChildByName(name);
5235
5242
  }
5236
5243
 
5237
- addDirectory(name) {
5238
- return this.root.addDirectory(name);
5244
+ addDirectory(name, options) {
5245
+ return this.root.addDirectory(name, options);
5239
5246
  }
5240
5247
 
5241
- addText(name, text) {
5242
- return this.root.addText(name, text);
5248
+ addText(name, text, options) {
5249
+ return this.root.addText(name, text, options);
5243
5250
  }
5244
5251
 
5245
- addBlob(name, blob) {
5246
- return this.root.addBlob(name, blob);
5252
+ addBlob(name, blob, options) {
5253
+ return this.root.addBlob(name, blob, options);
5247
5254
  }
5248
5255
 
5249
- addData64URI(name, dataURI) {
5250
- return this.root.addData64URI(name, dataURI);
5256
+ addData64URI(name, dataURI, options) {
5257
+ return this.root.addData64URI(name, dataURI, options);
5251
5258
  }
5252
5259
 
5253
5260
  addHttpContent(name, url, options) {
5254
5261
  return this.root.addHttpContent(name, url, options);
5255
5262
  }
5256
5263
 
5257
- addReadable(name, readable) {
5258
- return this.root.addReadable(name, readable);
5264
+ addReadable(name, readable, options) {
5265
+ return this.root.addReadable(name, readable, options);
5259
5266
  }
5260
5267
 
5261
- addFileSystemEntry(fileSystemEntry) {
5262
- return this.root.addFileSystemEntry(fileSystemEntry);
5268
+ addFileSystemEntry(fileSystemEntry, options) {
5269
+ return this.root.addFileSystemEntry(fileSystemEntry, options);
5263
5270
  }
5264
5271
 
5265
5272
  addData(name, params) {
@@ -5401,9 +5408,32 @@
5401
5408
 
5402
5409
  async function processChild(child) {
5403
5410
  const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
5411
+ let externalFileAttribute;
5412
+ let versionMadeBy;
5413
+ let comment;
5414
+ let lastModDate;
5415
+ let lastAccessDate;
5416
+ let creationDate;
5417
+ let childOptions = child.options || {};
5418
+ if (child.data instanceof Entry) {
5419
+ ({
5420
+ externalFileAttribute,
5421
+ versionMadeBy,
5422
+ comment,
5423
+ lastModDate,
5424
+ lastAccessDate,
5425
+ creationDate
5426
+ } = child.data);
5427
+ }
5404
5428
  await zipWriter.add(name, child.reader, Object.assign({
5405
5429
  directory: child.directory
5406
5430
  }, Object.assign({}, options, {
5431
+ externalFileAttribute,
5432
+ versionMadeBy,
5433
+ comment,
5434
+ lastModDate,
5435
+ lastAccessDate,
5436
+ creationDate,
5407
5437
  onprogress: async indexProgress => {
5408
5438
  if (options.onprogress) {
5409
5439
  entryOffsets.set(name, indexProgress);
@@ -5414,30 +5444,30 @@
5414
5444
  }
5415
5445
  }
5416
5446
  }
5417
- })));
5447
+ }, childOptions)));
5418
5448
  await process(zipWriter, child);
5419
5449
  }
5420
5450
  }
5421
5451
  }
5422
5452
 
5423
- async function addFileSystemEntry(zipEntry, fileSystemEntry) {
5453
+ async function addFileSystemEntry(zipEntry, fileSystemEntry, options) {
5424
5454
  if (fileSystemEntry.isDirectory) {
5425
- const entry = zipEntry.addDirectory(fileSystemEntry.name);
5455
+ const entry = zipEntry.addDirectory(fileSystemEntry.name, options);
5426
5456
  await addDirectory(entry, fileSystemEntry);
5427
5457
  return entry;
5428
5458
  } else {
5429
- return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file)), reject));
5459
+ return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file, options)), reject));
5430
5460
  }
5431
5461
 
5432
5462
  async function addDirectory(zipEntry, fileEntry) {
5433
5463
  const children = await getChildren(fileEntry);
5434
5464
  for (const child of children) {
5435
5465
  if (child.isDirectory) {
5436
- await addDirectory(zipEntry.addDirectory(child.name), child);
5466
+ await addDirectory(zipEntry.addDirectory(child.name, options), child);
5437
5467
  } else {
5438
5468
  await new Promise((resolve, reject) => {
5439
5469
  child.file(file => {
5440
- const childZipEntry = zipEntry.addBlob(child.name, file);
5470
+ const childZipEntry = zipEntry.addBlob(child.name, file, options);
5441
5471
  childZipEntry.uncompressedSize = file.size;
5442
5472
  resolve(childZipEntry);
5443
5473
  }, reject);