@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/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,26 @@
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 childOptions = child.options || {};
5416
+ if (child.data instanceof Entry) {
5417
+ ({
5418
+ externalFileAttribute,
5419
+ versionMadeBy,
5420
+ comment,
5421
+ lastModDate
5422
+ } = child.data);
5423
+ }
5404
5424
  await zipWriter.add(name, child.reader, Object.assign({
5405
5425
  directory: child.directory
5406
5426
  }, Object.assign({}, options, {
5427
+ externalFileAttribute,
5428
+ versionMadeBy,
5429
+ comment,
5430
+ lastModDate,
5407
5431
  onprogress: async indexProgress => {
5408
5432
  if (options.onprogress) {
5409
5433
  entryOffsets.set(name, indexProgress);
@@ -5414,30 +5438,30 @@
5414
5438
  }
5415
5439
  }
5416
5440
  }
5417
- })));
5441
+ }, childOptions)));
5418
5442
  await process(zipWriter, child);
5419
5443
  }
5420
5444
  }
5421
5445
  }
5422
5446
 
5423
- async function addFileSystemEntry(zipEntry, fileSystemEntry) {
5447
+ async function addFileSystemEntry(zipEntry, fileSystemEntry, options) {
5424
5448
  if (fileSystemEntry.isDirectory) {
5425
- const entry = zipEntry.addDirectory(fileSystemEntry.name);
5449
+ const entry = zipEntry.addDirectory(fileSystemEntry.name, options);
5426
5450
  await addDirectory(entry, fileSystemEntry);
5427
5451
  return entry;
5428
5452
  } else {
5429
- return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file)), reject));
5453
+ return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file, options)), reject));
5430
5454
  }
5431
5455
 
5432
5456
  async function addDirectory(zipEntry, fileEntry) {
5433
5457
  const children = await getChildren(fileEntry);
5434
5458
  for (const child of children) {
5435
5459
  if (child.isDirectory) {
5436
- await addDirectory(zipEntry.addDirectory(child.name), child);
5460
+ await addDirectory(zipEntry.addDirectory(child.name, options), child);
5437
5461
  } else {
5438
5462
  await new Promise((resolve, reject) => {
5439
5463
  child.file(file => {
5440
- const childZipEntry = zipEntry.addBlob(child.name, file);
5464
+ const childZipEntry = zipEntry.addBlob(child.name, file, options);
5441
5465
  childZipEntry.uncompressedSize = file.size;
5442
5466
  resolve(childZipEntry);
5443
5467
  }, reject);