@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/index-native.cjs CHANGED
@@ -2149,23 +2149,8 @@ async function runWebWorker(workerData, config) {
2149
2149
  }
2150
2150
 
2151
2151
  function watchClosedStream(writableSource) {
2152
- let resolveStreamClosed;
2153
- const closed = new Promise(resolve => resolveStreamClosed = resolve);
2154
- const writable = new WritableStream({
2155
- async write(chunk) {
2156
- const writer = writableSource.getWriter();
2157
- await writer.ready;
2158
- await writer.write(chunk);
2159
- writer.releaseLock();
2160
- },
2161
- close() {
2162
- resolveStreamClosed();
2163
- },
2164
- abort(reason) {
2165
- const writer = writableSource.getWriter();
2166
- return writer.abort(reason);
2167
- }
2168
- });
2152
+ const { writable, readable } = new TransformStream();
2153
+ const closed = readable.pipeTo(writableSource, { preventClose: true });
2169
2154
  return { writable, closed };
2170
2155
  }
2171
2156
 
@@ -3454,6 +3439,7 @@ const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
3454
3439
  const OPTION_KEEP_ORDER = "keepOrder";
3455
3440
  const OPTION_LEVEL = "level";
3456
3441
  const OPTION_BUFFERED_WRITE = "bufferedWrite";
3442
+ const OPTION_CREATE_TEMP_STREAM = "createTempStream";
3457
3443
  const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
3458
3444
  const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
3459
3445
  const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
@@ -4718,7 +4704,9 @@ async function addFile(zipWriter, name, reader, options) {
4718
4704
  const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
4719
4705
  const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
4720
4706
  const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
4707
+ const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
4721
4708
  const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
4709
+ const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
4722
4710
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
4723
4711
  const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
4724
4712
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
@@ -4824,10 +4812,12 @@ async function addFile(zipWriter, name, reader, options) {
4824
4812
  rawPassword,
4825
4813
  level,
4826
4814
  useWebWorkers,
4815
+ transferStreams,
4827
4816
  encryptionStrength,
4828
4817
  extendedTimestamp,
4829
4818
  zipCrypto,
4830
4819
  bufferedWrite,
4820
+ createTempStream,
4831
4821
  keepOrder,
4832
4822
  useUnicodeFileNames,
4833
4823
  dataDescriptor,
@@ -4904,7 +4894,11 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
4904
4894
  requestLockCurrentFileEntry();
4905
4895
  }
4906
4896
  if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
4907
- fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4897
+ if (options.createTempStream) {
4898
+ fileWriter = await options.createTempStream();
4899
+ } else {
4900
+ fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
4901
+ }
4908
4902
  fileWriter.size = 0;
4909
4903
  bufferedWrite = true;
4910
4904
  zipWriter.bufferedWrites++;
@@ -5069,6 +5063,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
5069
5063
  rawComment,
5070
5064
  rawExtraField,
5071
5065
  useWebWorkers,
5066
+ transferStreams,
5072
5067
  onstart,
5073
5068
  onprogress,
5074
5069
  onend,
@@ -5149,7 +5144,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
5149
5144
  encrypted: encrypted && !passThrough,
5150
5145
  useWebWorkers,
5151
5146
  useCompressionStream,
5152
- transferStreams: false
5147
+ transferStreams
5153
5148
  },
5154
5149
  config,
5155
5150
  streamOptions: { signal, size, onstart, onprogress, onend }