@zip.js/zip.js 2.5.24 → 2.6.0

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
@@ -1861,7 +1861,6 @@
1861
1861
  const MESSAGE_PULL = "pull";
1862
1862
  const MESSAGE_DATA = "data";
1863
1863
  const MESSAGE_CLOSE = "close";
1864
- const ERR_ABORT = "AbortError";
1865
1864
 
1866
1865
  class Codec {
1867
1866
 
@@ -2129,7 +2128,7 @@
2129
2128
  let indexWorker = 0;
2130
2129
 
2131
2130
  async function runWorker(stream, workerOptions) {
2132
- const { options, config, streamOptions } = workerOptions;
2131
+ const { options, config } = workerOptions;
2133
2132
  const streamCopy = !options.compressed && !options.signed && !options.encrypted;
2134
2133
  const { useWebWorkers, useCompressionStream, codecType } = options;
2135
2134
  const { workerScripts } = config;
@@ -2151,16 +2150,7 @@
2151
2150
  worker = await new Promise(resolve => pendingRequests.push({ resolve, stream, workerOptions }));
2152
2151
  }
2153
2152
  }
2154
- try {
2155
- return await worker.run();
2156
- } catch (error) {
2157
- const { signal } = streamOptions;
2158
- if (signal && signal.aborted && (signal.reason == error || error.name == ERR_ABORT)) {
2159
- throw new Error(ERR_ABORT);
2160
- } else {
2161
- throw error;
2162
- }
2163
- }
2153
+ return worker.run();
2164
2154
 
2165
2155
  function onTaskFinished(workerData) {
2166
2156
  if (pendingRequests.length) {
@@ -2224,11 +2214,10 @@
2224
2214
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2225
2215
  */
2226
2216
 
2227
- /* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream */
2217
+ /* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream, FileReader */
2228
2218
 
2229
2219
  const ERR_HTTP_STATUS = "HTTP error ";
2230
2220
  const ERR_HTTP_RANGE = "HTTP Range not supported";
2231
- const ERR_NOT_SEEKABLE_READER = "Reader is not seekable";
2232
2221
 
2233
2222
  const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
2234
2223
  const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
@@ -2334,7 +2323,16 @@
2334
2323
 
2335
2324
  getData() {
2336
2325
  const writer = this;
2337
- return writer.blob.text();
2326
+ if (writer.blob.text && (writer.encoding === undefined || (writer.encoding && writer.encoding.toLowerCase() == "utf-8"))) {
2327
+ return writer.blob.text();
2328
+ } else {
2329
+ const reader = new FileReader();
2330
+ return new Promise((resolve, reject) => {
2331
+ reader.onload = event => resolve(event.target.result);
2332
+ reader.onerror = () => reject(reader.error);
2333
+ reader.readAsText(writer.blob, writer.encoding);
2334
+ });
2335
+ }
2338
2336
  }
2339
2337
  }
2340
2338
 
@@ -2454,32 +2452,6 @@
2454
2452
  blobWriter.arrayBuffers = [];
2455
2453
  }
2456
2454
 
2457
- class ReadableStreamReader extends Stream {
2458
-
2459
- constructor(readable) {
2460
- super();
2461
- if (!readable) {
2462
- this.readable = new ReadableStream({});
2463
- }
2464
- }
2465
- }
2466
-
2467
- class WritableStreamWriter extends Writer {
2468
-
2469
- constructor(writable, { preventClose } = {}) {
2470
- super();
2471
- this.preventClose = preventClose;
2472
- if (!writable) {
2473
- writable = new WritableStream({});
2474
- }
2475
- Object.defineProperty(this, "writable", {
2476
- get() {
2477
- return writable;
2478
- }
2479
- });
2480
- }
2481
- }
2482
-
2483
2455
  class FetchReader extends Reader {
2484
2456
 
2485
2457
  constructor(url, options) {
@@ -3096,7 +3068,7 @@
3096
3068
  const extractPrependedData = getOptionValue$1(zipReader, options, "extractPrependedData");
3097
3069
  const extractAppendedData = getOptionValue$1(zipReader, options, "extractAppendedData");
3098
3070
  if (extractPrependedData) {
3099
- zipReader.prependedData = await readUint8Array(reader, 0, startOffset);
3071
+ zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : new Uint8Array();
3100
3072
  }
3101
3073
  zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : new Uint8Array();
3102
3074
  if (extractAppendedData) {
@@ -4848,7 +4820,6 @@
4848
4820
  exports.BlobWriter = BlobWriter;
4849
4821
  exports.Data64URIReader = Data64URIReader;
4850
4822
  exports.Data64URIWriter = Data64URIWriter;
4851
- exports.ERR_ABORT = ERR_ABORT;
4852
4823
  exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
4853
4824
  exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
4854
4825
  exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
@@ -4868,19 +4839,16 @@
4868
4839
  exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
4869
4840
  exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
4870
4841
  exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
4871
- exports.ERR_NOT_SEEKABLE_READER = ERR_NOT_SEEKABLE_READER;
4872
4842
  exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
4873
4843
  exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
4874
4844
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
4875
4845
  exports.HttpRangeReader = HttpRangeReader;
4876
4846
  exports.HttpReader = HttpReader;
4877
- exports.ReadableStreamReader = ReadableStreamReader;
4878
4847
  exports.Reader = Reader;
4879
4848
  exports.TextReader = TextReader;
4880
4849
  exports.TextWriter = TextWriter;
4881
4850
  exports.Uint8ArrayReader = Uint8ArrayReader;
4882
4851
  exports.Uint8ArrayWriter = Uint8ArrayWriter;
4883
- exports.WritableStreamWriter = WritableStreamWriter;
4884
4852
  exports.Writer = Writer;
4885
4853
  exports.ZipReader = ZipReader;
4886
4854
  exports.ZipWriter = ZipWriter;