@zip.js/zip.js 2.7.13 → 2.7.15

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.
@@ -71,7 +71,7 @@ class ZipEntry {
71
71
  id: fs.entries.length,
72
72
  parent,
73
73
  children: [],
74
- uncompressedSize: 0
74
+ uncompressedSize: params.uncompressedSize || 0
75
75
  });
76
76
  fs.entries.push(zipEntry);
77
77
  if (parent) {
@@ -268,7 +268,8 @@ class ZipDirectoryEntry extends ZipEntry {
268
268
  data: text,
269
269
  Reader: TextReader,
270
270
  Writer: TextWriter,
271
- options
271
+ options,
272
+ uncompressedSize: text.length
272
273
  });
273
274
  }
274
275
 
@@ -277,16 +278,23 @@ class ZipDirectoryEntry extends ZipEntry {
277
278
  data: blob,
278
279
  Reader: BlobReader,
279
280
  Writer: BlobWriter,
280
- options
281
+ options,
282
+ uncompressedSize: blob.size
281
283
  });
282
284
  }
283
285
 
284
286
  addData64URI(name, dataURI, options = {}) {
287
+ let dataEnd = dataURI.length;
288
+ while (dataURI.charAt(dataEnd - 1) == "=") {
289
+ dataEnd--;
290
+ }
291
+ const dataStart = dataURI.indexOf(",") + 1;
285
292
  return addChild(this, name, {
286
293
  data: dataURI,
287
294
  Reader: Data64URIReader,
288
295
  Writer: Data64URIWriter,
289
- options
296
+ options,
297
+ uncompressedSize: Math.floor((dataEnd - dataStart) * 0.75)
290
298
  });
291
299
  }
292
300
 
@@ -295,7 +303,8 @@ class ZipDirectoryEntry extends ZipEntry {
295
303
  data: array,
296
304
  Reader: Uint8ArrayReader,
297
305
  Writer: Uint8ArrayWriter,
298
- options
306
+ options,
307
+ uncompressedSize: array.length
299
308
  });
300
309
  }
301
310
 
@@ -337,7 +346,8 @@ class ZipDirectoryEntry extends ZipEntry {
337
346
  const size = file.size;
338
347
  return { readable, size };
339
348
  },
340
- options
349
+ options,
350
+ uncompressedSize: file.size
341
351
  });
342
352
  }
343
353
 
@@ -403,7 +413,8 @@ class ZipDirectoryEntry extends ZipEntry {
403
413
  if (!entry.directory) {
404
414
  importedEntries.push(addChild(parent, name, {
405
415
  data: entry,
406
- Reader: getZipBlobReader(Object.assign({}, options))
416
+ Reader: getZipBlobReader(Object.assign({}, options)),
417
+ uncompressedSize: entry.uncompressedSize
407
418
  }));
408
419
  }
409
420
  } catch (error) {
@@ -757,10 +768,9 @@ async function addFileSystemHandle(zipEntry, handle, options) {
757
768
  const size = file.size;
758
769
  return { readable, size };
759
770
  },
760
- options: {
761
- lastModDate: new Date(file.lastModified)
762
- }
763
- }, options)
771
+ options: Object.assign({}, { lastModDate: new Date(file.lastModified) }, options),
772
+ uncompressedSize: file.size
773
+ })
764
774
  );
765
775
  } else if (handle.kind == "directory") {
766
776
  const directoryEntry = parentEntry.addDirectory(handle.name);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "2.7.13",
6
+ "version": "2.7.15",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "zip",