@zip.js/zip.js 2.8.19 → 2.8.21

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.
@@ -1969,6 +1969,11 @@
1969
1969
 
1970
1970
  let webWorkerSupported, webWorkerURI, webWorkerOptions;
1971
1971
  let transferStreamsSupported = true;
1972
+ try {
1973
+ transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
1974
+ } catch {
1975
+ // ignored
1976
+ }
1972
1977
  let initModule = () => { };
1973
1978
 
1974
1979
  class CodecWorker {
@@ -2155,23 +2160,8 @@
2155
2160
  }
2156
2161
 
2157
2162
  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
- });
2163
+ const { writable, readable } = new TransformStream();
2164
+ const closed = readable.pipeTo(writableSource, { preventClose: true });
2175
2165
  return { writable, closed };
2176
2166
  }
2177
2167
 
@@ -3460,6 +3450,7 @@
3460
3450
  const OPTION_KEEP_ORDER = "keepOrder";
3461
3451
  const OPTION_LEVEL = "level";
3462
3452
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
3453
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
3463
3454
  const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
3464
3455
  const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
3465
3456
  const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
@@ -4724,7 +4715,9 @@
4724
4715
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
4725
4716
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
4726
4717
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
4718
+ const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
4727
4719
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
4720
+ const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
4728
4721
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
4729
4722
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
4730
4723
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
@@ -4830,10 +4823,12 @@
4830
4823
  rawPassword,
4831
4824
  level,
4832
4825
  useWebWorkers,
4826
+ transferStreams,
4833
4827
  encryptionStrength,
4834
4828
  extendedTimestamp,
4835
4829
  zipCrypto,
4836
4830
  bufferedWrite,
4831
+ createTempStream,
4837
4832
  keepOrder,
4838
4833
  useUnicodeFileNames,
4839
4834
  dataDescriptor,
@@ -4910,7 +4905,11 @@
4910
4905
  requestLockCurrentFileEntry();
4911
4906
  }
4912
4907
  if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
4913
- fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4908
+ if (options.createTempStream) {
4909
+ fileWriter = await options.createTempStream();
4910
+ } else {
4911
+ fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4912
+ }
4914
4913
  fileWriter.size = 0;
4915
4914
  bufferedWrite = true;
4916
4915
  zipWriter.bufferedWrites++;
@@ -5075,6 +5074,7 @@
5075
5074
  rawComment,
5076
5075
  rawExtraField,
5077
5076
  useWebWorkers,
5077
+ transferStreams,
5078
5078
  onstart,
5079
5079
  onprogress,
5080
5080
  onend,
@@ -5155,7 +5155,7 @@
5155
5155
  encrypted: encrypted && !passThrough,
5156
5156
  useWebWorkers,
5157
5157
  useCompressionStream,
5158
- transferStreams: false
5158
+ transferStreams
5159
5159
  },
5160
5160
  config,
5161
5161
  streamOptions: { signal, size, onstart, onprogress, onend }