@zip.js/zip.js 2.8.11 → 2.8.13

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.cjs CHANGED
@@ -5189,15 +5189,19 @@ function getHeaderInfo(options) {
5189
5189
  let { version, compressionMethod } = options;
5190
5190
  const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
5191
5191
  let rawExtraFieldZip64;
5192
+ let rawLocalExtraFieldZip64;
5192
5193
  const uncompressedFile = passThrough || !compressed;
5193
5194
  const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
5194
5195
  if (zip64) {
5195
5196
  let rawExtraFieldZip64Length = 4;
5197
+ let rawLocalExtraFieldZip64Length = 4;
5196
5198
  if (zip64UncompressedSize) {
5197
5199
  rawExtraFieldZip64Length += 8;
5200
+ rawLocalExtraFieldZip64Length += 8;
5198
5201
  }
5199
5202
  if (zip64CompressedSize) {
5200
5203
  rawExtraFieldZip64Length += 8;
5204
+ rawLocalExtraFieldZip64Length += 8;
5201
5205
  }
5202
5206
  if (zip64Offset) {
5203
5207
  rawExtraFieldZip64Length += 8;
@@ -5207,18 +5211,28 @@ function getHeaderInfo(options) {
5207
5211
  }
5208
5212
  rawExtraFieldZip64 = new Uint8Array(rawExtraFieldZip64Length);
5209
5213
  const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
5214
+ rawLocalExtraFieldZip64 = new Uint8Array(rawLocalExtraFieldZip64Length);
5215
+ const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
5210
5216
  setUint16(rawExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
5211
5217
  setUint16(rawExtraFieldZip64View, 2, getLength(rawExtraFieldZip64) - 4);
5218
+ setUint16(rawLocalExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
5219
+ setUint16(rawLocalExtraFieldZip64View, 2, getLength(rawLocalExtraFieldZip64) - 4);
5212
5220
  if (zip64ExtraFieldComplete) {
5213
5221
  const rawExtraFieldZip64View = getDataView(rawExtraFieldZip64);
5222
+ const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
5214
5223
  let rawExtraFieldZip64Offset = 4;
5224
+ let rawLocalExtraFieldZip64Offset = 4;
5215
5225
  if (zip64UncompressedSize) {
5216
5226
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
5217
5227
  rawExtraFieldZip64Offset += 8;
5228
+ setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
5229
+ rawLocalExtraFieldZip64Offset += 8;
5218
5230
  }
5219
5231
  if (zip64CompressedSize && uncompressedFile) {
5220
5232
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(uncompressedSize));
5221
5233
  rawExtraFieldZip64Offset += 8;
5234
+ setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
5235
+ rawLocalExtraFieldZip64Offset += 8;
5222
5236
  }
5223
5237
  if (zip64Offset) {
5224
5238
  setBigUint64(rawExtraFieldZip64View, rawExtraFieldZip64Offset, BigInt(offset));
@@ -5231,6 +5245,7 @@ function getHeaderInfo(options) {
5231
5245
  }
5232
5246
  } else {
5233
5247
  rawExtraFieldZip64 = new Uint8Array();
5248
+ rawLocalExtraFieldZip64 = new Uint8Array();
5234
5249
  }
5235
5250
  let rawExtraFieldAES;
5236
5251
  if (encrypted && !zipCrypto) {
@@ -5333,7 +5348,7 @@ function getHeaderInfo(options) {
5333
5348
  rawExtraFieldAES[9] = compressionMethod;
5334
5349
  compressionMethod = COMPRESSION_METHOD_AES;
5335
5350
  }
5336
- const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawExtraFieldZip64) : 0;
5351
+ const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawLocalExtraFieldZip64) : 0;
5337
5352
  const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
5338
5353
  const {
5339
5354
  headerArray,
@@ -5358,7 +5373,7 @@ function getHeaderInfo(options) {
5358
5373
  arraySet(localHeaderArray, rawFilename, localHeaderOffset);
5359
5374
  localHeaderOffset += getLength(rawFilename);
5360
5375
  if (zip64ExtraFieldComplete) {
5361
- arraySet(localHeaderArray, rawExtraFieldZip64, localHeaderOffset);
5376
+ arraySet(localHeaderArray, rawLocalExtraFieldZip64, localHeaderOffset);
5362
5377
  }
5363
5378
  localHeaderOffset += localExtraFieldZip64Length;
5364
5379
  arraySet(localHeaderArray, rawExtraFieldAES, localHeaderOffset);
@@ -5531,12 +5546,8 @@ function updateLocalHeader({
5531
5546
  signature,
5532
5547
  compressedSize,
5533
5548
  uncompressedSize,
5534
- offset,
5535
- diskNumberStart,
5536
5549
  zip64UncompressedSize,
5537
- zip64CompressedSize,
5538
- zip64Offset,
5539
- zip64DiskNumberStart
5550
+ zip64CompressedSize
5540
5551
  }, localHeaderView, { dataDescriptor }) {
5541
5552
  if (!dataDescriptor) {
5542
5553
  if (!encrypted) {
@@ -5558,13 +5569,6 @@ function updateLocalHeader({
5558
5569
  setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
5559
5570
  localHeaderOffset += 8;
5560
5571
  }
5561
- if (zip64Offset) {
5562
- setBigUint64(localHeaderView, localHeaderOffset, BigInt(offset));
5563
- localHeaderOffset += 8;
5564
- }
5565
- if (zip64DiskNumberStart) {
5566
- setUint32(localHeaderView, localHeaderOffset, diskNumberStart);
5567
- }
5568
5572
  }
5569
5573
  }
5570
5574
  }
package/index.d.ts CHANGED
@@ -218,10 +218,12 @@ export interface Configuration extends WorkerConfiguration {
218
218
  *
219
219
  * It allows using alternative deflate implementations or specifying a URL to the worker script if the CSP of the page blocks scripts imported from a Data URI.
220
220
  *
221
- * Here is an example:
221
+ * Here is an example to import the worker module as a URL (see `?url`) and avoid CSP issues:
222
222
  * ```
223
+ * import workerURI from "@zip.js/zip.js/dist/zip-web-worker.js?url";
224
+ *
223
225
  * configure({
224
- * workerURI: "./custom-deflate.js"
226
+ * workerURI
225
227
  * });
226
228
  * ```
227
229
  *
@@ -231,6 +233,15 @@ export interface Configuration extends WorkerConfiguration {
231
233
  /**
232
234
  * The URI of the WebAssembly module used by default implementations to compress/decompress data. It is ignored if `useCompressionStream` is set to `true` and `CompressionStream`/`DecompressionStream` are supported by the environment.
233
235
  *
236
+ * Here is an example to import the WASM module as a URL (see `?url`) and avoid CSP issues:
237
+ * ```
238
+ * import wasmURI from "@zip.js/zip.js/dist/zip-module.wasm?url";
239
+ *
240
+ * configure({
241
+ * wasmURI
242
+ * });
243
+ * ```
244
+ *
234
245
  * @defaultValue "./core/streams/zlib-wasm/zlib-streams.wasm"
235
246
  */
236
247
  wasmURI?: string;