@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.
package/dist/zip.js CHANGED
@@ -2159,23 +2159,8 @@
2159
2159
  }
2160
2160
 
2161
2161
  function watchClosedStream(writableSource) {
2162
- let resolveStreamClosed;
2163
- const closed = new Promise(resolve => resolveStreamClosed = resolve);
2164
- const writable = new WritableStream({
2165
- async write(chunk) {
2166
- const writer = writableSource.getWriter();
2167
- await writer.ready;
2168
- await writer.write(chunk);
2169
- writer.releaseLock();
2170
- },
2171
- close() {
2172
- resolveStreamClosed();
2173
- },
2174
- abort(reason) {
2175
- const writer = writableSource.getWriter();
2176
- return writer.abort(reason);
2177
- }
2178
- });
2162
+ const { writable, readable } = new TransformStream();
2163
+ const closed = readable.pipeTo(writableSource, { preventClose: true });
2179
2164
  return { writable, closed };
2180
2165
  }
2181
2166
 
@@ -3464,6 +3449,7 @@
3464
3449
  const OPTION_KEEP_ORDER = "keepOrder";
3465
3450
  const OPTION_LEVEL = "level";
3466
3451
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
3452
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
3467
3453
  const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
3468
3454
  const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
3469
3455
  const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
@@ -4728,7 +4714,9 @@
4728
4714
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
4729
4715
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
4730
4716
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
4717
+ const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
4731
4718
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
4719
+ const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
4732
4720
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
4733
4721
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
4734
4722
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
@@ -4834,10 +4822,12 @@
4834
4822
  rawPassword,
4835
4823
  level,
4836
4824
  useWebWorkers,
4825
+ transferStreams,
4837
4826
  encryptionStrength,
4838
4827
  extendedTimestamp,
4839
4828
  zipCrypto,
4840
4829
  bufferedWrite,
4830
+ createTempStream,
4841
4831
  keepOrder,
4842
4832
  useUnicodeFileNames,
4843
4833
  dataDescriptor,
@@ -4914,7 +4904,11 @@
4914
4904
  requestLockCurrentFileEntry();
4915
4905
  }
4916
4906
  if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
4917
- fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4907
+ if (options.createTempStream) {
4908
+ fileWriter = await options.createTempStream();
4909
+ } else {
4910
+ fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4911
+ }
4918
4912
  fileWriter.size = 0;
4919
4913
  bufferedWrite = true;
4920
4914
  zipWriter.bufferedWrites++;
@@ -5079,6 +5073,7 @@
5079
5073
  rawComment,
5080
5074
  rawExtraField,
5081
5075
  useWebWorkers,
5076
+ transferStreams,
5082
5077
  onstart,
5083
5078
  onprogress,
5084
5079
  onend,
@@ -5159,7 +5154,7 @@
5159
5154
  encrypted: encrypted && !passThrough,
5160
5155
  useWebWorkers,
5161
5156
  useCompressionStream,
5162
- transferStreams: false
5157
+ transferStreams
5163
5158
  },
5164
5159
  config,
5165
5160
  streamOptions: { signal, size, onstart, onprogress, onend }