@zip.js/zip.js 2.8.19 → 2.8.20

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.
@@ -2155,23 +2155,8 @@
2155
2155
  }
2156
2156
 
2157
2157
  function watchClosedStream(writableSource) {
2158
- let resolveStreamClosed;
2159
- const closed = new Promise(resolve => resolveStreamClosed = resolve);
2160
- const writable = new WritableStream({
2161
- async write(chunk) {
2162
- const writer = writableSource.getWriter();
2163
- await writer.ready;
2164
- await writer.write(chunk);
2165
- writer.releaseLock();
2166
- },
2167
- close() {
2168
- resolveStreamClosed();
2169
- },
2170
- abort(reason) {
2171
- const writer = writableSource.getWriter();
2172
- return writer.abort(reason);
2173
- }
2174
- });
2158
+ const { writable, readable } = new TransformStream();
2159
+ const closed = readable.pipeTo(writableSource, { preventClose: true });
2175
2160
  return { writable, closed };
2176
2161
  }
2177
2162
 
@@ -3460,6 +3445,7 @@
3460
3445
  const OPTION_KEEP_ORDER = "keepOrder";
3461
3446
  const OPTION_LEVEL = "level";
3462
3447
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
3448
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
3463
3449
  const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
3464
3450
  const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
3465
3451
  const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
@@ -4724,7 +4710,9 @@
4724
4710
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
4725
4711
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
4726
4712
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
4713
+ const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
4727
4714
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
4715
+ const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
4728
4716
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
4729
4717
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
4730
4718
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
@@ -4830,10 +4818,12 @@
4830
4818
  rawPassword,
4831
4819
  level,
4832
4820
  useWebWorkers,
4821
+ transferStreams,
4833
4822
  encryptionStrength,
4834
4823
  extendedTimestamp,
4835
4824
  zipCrypto,
4836
4825
  bufferedWrite,
4826
+ createTempStream,
4837
4827
  keepOrder,
4838
4828
  useUnicodeFileNames,
4839
4829
  dataDescriptor,
@@ -4910,7 +4900,11 @@
4910
4900
  requestLockCurrentFileEntry();
4911
4901
  }
4912
4902
  if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
4913
- fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4903
+ if (options.createTempStream) {
4904
+ fileWriter = await options.createTempStream();
4905
+ } else {
4906
+ fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4907
+ }
4914
4908
  fileWriter.size = 0;
4915
4909
  bufferedWrite = true;
4916
4910
  zipWriter.bufferedWrites++;
@@ -5075,6 +5069,7 @@
5075
5069
  rawComment,
5076
5070
  rawExtraField,
5077
5071
  useWebWorkers,
5072
+ transferStreams,
5078
5073
  onstart,
5079
5074
  onprogress,
5080
5075
  onend,
@@ -5155,7 +5150,7 @@
5155
5150
  encrypted: encrypted && !passThrough,
5156
5151
  useWebWorkers,
5157
5152
  useCompressionStream,
5158
- transferStreams: false
5153
+ transferStreams
5159
5154
  },
5160
5155
  config,
5161
5156
  streamOptions: { signal, size, onstart, onprogress, onend }