@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.
package/dist/zip.js CHANGED
@@ -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$1 = () => { };
1973
1978
 
1974
1979
  function configureWorker({ initModule: initModuleFunction }) {
@@ -2159,23 +2164,8 @@
2159
2164
  }
2160
2165
 
2161
2166
  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
- });
2167
+ const { writable, readable } = new TransformStream();
2168
+ const closed = readable.pipeTo(writableSource, { preventClose: true });
2179
2169
  return { writable, closed };
2180
2170
  }
2181
2171
 
@@ -3464,6 +3454,7 @@
3464
3454
  const OPTION_KEEP_ORDER = "keepOrder";
3465
3455
  const OPTION_LEVEL = "level";
3466
3456
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
3457
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
3467
3458
  const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
3468
3459
  const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
3469
3460
  const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
@@ -4728,7 +4719,9 @@
4728
4719
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
4729
4720
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
4730
4721
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
4722
+ const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
4731
4723
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
4724
+ const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
4732
4725
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
4733
4726
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
4734
4727
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
@@ -4834,10 +4827,12 @@
4834
4827
  rawPassword,
4835
4828
  level,
4836
4829
  useWebWorkers,
4830
+ transferStreams,
4837
4831
  encryptionStrength,
4838
4832
  extendedTimestamp,
4839
4833
  zipCrypto,
4840
4834
  bufferedWrite,
4835
+ createTempStream,
4841
4836
  keepOrder,
4842
4837
  useUnicodeFileNames,
4843
4838
  dataDescriptor,
@@ -4914,7 +4909,11 @@
4914
4909
  requestLockCurrentFileEntry();
4915
4910
  }
4916
4911
  if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
4917
- fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4912
+ if (options.createTempStream) {
4913
+ fileWriter = await options.createTempStream();
4914
+ } else {
4915
+ fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4916
+ }
4918
4917
  fileWriter.size = 0;
4919
4918
  bufferedWrite = true;
4920
4919
  zipWriter.bufferedWrites++;
@@ -5079,6 +5078,7 @@
5079
5078
  rawComment,
5080
5079
  rawExtraField,
5081
5080
  useWebWorkers,
5081
+ transferStreams,
5082
5082
  onstart,
5083
5083
  onprogress,
5084
5084
  onend,
@@ -5159,7 +5159,7 @@
5159
5159
  encrypted: encrypted && !passThrough,
5160
5160
  useWebWorkers,
5161
5161
  useCompressionStream,
5162
- transferStreams: false
5162
+ transferStreams
5163
5163
  },
5164
5164
  config,
5165
5165
  streamOptions: { signal, size, onstart, onprogress, onend }