@zip.js/zip.js 2.6.15 → 2.6.16

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
@@ -79,8 +79,8 @@ import {
79
79
  // Write the zip file
80
80
  // ----
81
81
 
82
- // Creates a TransformStream object where the zip content will be written in
83
- // the `writable` property.
82
+ // Creates a TransformStream object, the zip content will be written in the
83
+ // `writable` property.
84
84
  const zipFileWriter = new TransformStream();
85
85
  // Creates a Promise object resolved to the zip content returned as a Blob
86
86
  // object via the `readable` property of `zipFileWriter`.
@@ -106,8 +106,8 @@ const zipFileBlob = await zipFileBlobPromise;
106
106
 
107
107
  // Creates a BlobReader object used to read `zipFileBlob`.
108
108
  const zipFileReader = new BlobReader(zipFileBlob);
109
- // Creates a TransformStream object where the content of the first entry in the
110
- // zip will be written in the `writable` property.
109
+ // Creates a TransformStream object, the content of the first entry in the zip
110
+ // will be written in the `writable` property.
111
111
  const helloWorldWriter = new TransformStream();
112
112
  // Creates a Promise object resolved to the content of the first entry returned
113
113
  // as text via the `readable` property of `helloWorldWriter`.
package/dist/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Built scripts of zip.js
2
-
2
+
3
+ **Warning**: These files are not compatible with ES modules, i.e. they cannot be imported with `import`. Instead, import `index.js` in the root folder of the project or one of the files prefixed with `zip-` in the [`/lib`](../lib) folder (e.g. `/lib/zip-no-worker-inflate.js`).
4
+
3
5
  - for production (minified):
4
6
 
5
- | | [`ZipReader`](https://gildas-lormeau.github.io/zip.js/core-api.html#zip-reading) API | [`ZipWriter`](https://gildas-lormeau.github.io/zip.js/core-api.html#zip-writing) API | [`zip.fs`](https://gildas-lormeau.github.io/zip.js/fs-api.html#fs-constructor) API | Web Workers | No Web Workers | Usage |
7
+ | | [`ZipReader`](https://gildas-lormeau.github.io/zip.js/api/classes/ZipReader.html) API | [`ZipWriter`](https://gildas-lormeau.github.io/zip.js/api/classes/ZipWriter.html) API | [`zip.fs`](https://gildas-lormeau.github.io/zip.js/api/classes/FS.html) API | Web Workers | No Web Workers | Usage |
6
8
  |--------------------------------|-----------------|-----------------|--------------|-------------|----------------|-------------------------------------------------------|
7
9
  | `zip.min.js` | x | x | | x | | compression/decompression with web workers |
8
10
  | `zip-no-worker.min.js` | x | x | | | x | compression/decompression without web workers |
@@ -14,13 +16,13 @@
14
16
 
15
17
  - for development/debugging:
16
18
 
17
- | | [`zip`](https://gildas-lormeau.github.io/zip.js/core-api.html) API | [`zip.fs`](https://gildas-lormeau.github.io/zip.js/fs-api.html#fs-constructor) API | Web Workers | No Web Workers |
19
+ | | `zip` API | [`zip.fs`](https://gildas-lormeau.github.io/zip.js/api/classes/FS.html) API | Web Workers | No Web Workers |
18
20
  |-----------------------|-----------|--------------|-------------|----------------|
19
21
  | `zip.js` | x | | x | |
20
22
  | `zip-full.js` | x | | x | x |
21
23
  | `zip-fs.js` | x | x | x | |
22
24
  | `zip-fs-full.js` | x | x | x | x |
23
25
 
24
- - `z-worker.js` can be used as a web worker script if the [CSP](https://developer.mozilla.org/docs/Web/HTTP/CSP) does not allow to load it with a Blob URI
26
+ - `z-worker.js` can be used as a web worker script if the [Content Security Policy](https://developer.mozilla.org/docs/Web/HTTP/CSP) blocks scripts loaded with a `blob:` scheme
25
27
  - `z-worker-fflate.js` is the web worker script for using [fflate](https://gildas-lormeau.github.io/zip.js/core-api.html#alternative-codec-fflate)
26
28
  - `z-worker-pako.js` is the web worker script for using [pako](https://gildas-lormeau.github.io/zip.js/core-api.html#alternative-codec-pako)
@@ -8767,6 +8767,7 @@
8767
8767
  const EXTRAFIELD_LENGTH_ZIP64 = 24;
8768
8768
 
8769
8769
  let workers = 0;
8770
+ const pendingEntries = [];
8770
8771
 
8771
8772
  class ZipWriter {
8772
8773
 
@@ -8779,7 +8780,6 @@
8779
8780
  filenames: new Set(),
8780
8781
  offset: writer.size || 0,
8781
8782
  pendingCompressedSize: 0,
8782
- pendingEntries: [],
8783
8783
  pendingAddFileCalls: new Set()
8784
8784
  });
8785
8785
  }
@@ -8788,36 +8788,34 @@
8788
8788
  const zipWriter = this;
8789
8789
  const {
8790
8790
  pendingAddFileCalls,
8791
- pendingEntries,
8792
8791
  config
8793
8792
  } = zipWriter;
8794
8793
  if (workers < config.maxWorkers) {
8795
8794
  workers++;
8796
- let promiseAddFile;
8797
- try {
8798
- name = name.trim();
8799
- if (zipWriter.filenames.has(name)) {
8800
- throw new Error(ERR_DUPLICATED_NAME);
8801
- }
8802
- zipWriter.filenames.add(name);
8803
- promiseAddFile = addFile(zipWriter, name, reader, options);
8804
- pendingAddFileCalls.add(promiseAddFile);
8805
- return await promiseAddFile;
8806
- } catch (error) {
8807
- zipWriter.filenames.delete(name);
8808
- throw error;
8809
- } finally {
8810
- pendingAddFileCalls.delete(promiseAddFile);
8795
+ } else {
8796
+ await new Promise(resolve => pendingEntries.push(resolve));
8797
+ }
8798
+ let promiseAddFile;
8799
+ try {
8800
+ name = name.trim();
8801
+ if (zipWriter.filenames.has(name)) {
8802
+ throw new Error(ERR_DUPLICATED_NAME);
8803
+ }
8804
+ zipWriter.filenames.add(name);
8805
+ promiseAddFile = addFile(zipWriter, name, reader, options);
8806
+ pendingAddFileCalls.add(promiseAddFile);
8807
+ return await promiseAddFile;
8808
+ } catch (error) {
8809
+ zipWriter.filenames.delete(name);
8810
+ throw error;
8811
+ } finally {
8812
+ pendingAddFileCalls.delete(promiseAddFile);
8813
+ const pendingEntry = pendingEntries.shift();
8814
+ if (pendingEntry) {
8815
+ pendingEntry();
8816
+ } else {
8811
8817
  workers--;
8812
- const pendingEntry = pendingEntries.shift();
8813
- if (pendingEntry) {
8814
- zipWriter.add(pendingEntry.name, pendingEntry.reader, pendingEntry.options)
8815
- .then(pendingEntry.resolve)
8816
- .catch(pendingEntry.reject);
8817
- }
8818
8818
  }
8819
- } else {
8820
- return new Promise((resolve, reject) => pendingEntries.push({ name, reader, options, resolve, reject }));
8821
8819
  }
8822
8820
  }
8823
8821