@zip.js/zip.js 2.8.11 → 2.8.14
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/README.md +19 -7
- package/deno.json +1 -1
- package/dist/zip-core.js +33 -26
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core.js +33 -26
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-native.js +33 -26
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +33 -26
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +33 -26
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +33 -26
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +33 -26
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +33 -26
- package/index-native.min.js +1 -1
- package/index.cjs +33 -26
- package/index.d.ts +13 -2
- package/index.min.js +1 -1
- package/lib/core/zip-writer.js +33 -26
- package/package.json +4 -4
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));
|
|
@@ -5228,9 +5242,13 @@ function getHeaderInfo(options) {
|
|
|
5228
5242
|
setUint32(rawExtraFieldZip64View, rawExtraFieldZip64Offset, diskNumberStart);
|
|
5229
5243
|
rawExtraFieldZip64Offset += 4;
|
|
5230
5244
|
}
|
|
5245
|
+
if (rawLocalExtraFieldZip64Offset == 4) {
|
|
5246
|
+
rawLocalExtraFieldZip64 = new Uint8Array();
|
|
5247
|
+
}
|
|
5231
5248
|
}
|
|
5232
5249
|
} else {
|
|
5233
5250
|
rawExtraFieldZip64 = new Uint8Array();
|
|
5251
|
+
rawLocalExtraFieldZip64 = new Uint8Array();
|
|
5234
5252
|
}
|
|
5235
5253
|
let rawExtraFieldAES;
|
|
5236
5254
|
if (encrypted && !zipCrypto) {
|
|
@@ -5333,7 +5351,7 @@ function getHeaderInfo(options) {
|
|
|
5333
5351
|
rawExtraFieldAES[9] = compressionMethod;
|
|
5334
5352
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
5335
5353
|
}
|
|
5336
|
-
const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(
|
|
5354
|
+
const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
5337
5355
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
5338
5356
|
const {
|
|
5339
5357
|
headerArray,
|
|
@@ -5358,7 +5376,7 @@ function getHeaderInfo(options) {
|
|
|
5358
5376
|
arraySet(localHeaderArray, rawFilename, localHeaderOffset);
|
|
5359
5377
|
localHeaderOffset += getLength(rawFilename);
|
|
5360
5378
|
if (zip64ExtraFieldComplete) {
|
|
5361
|
-
arraySet(localHeaderArray,
|
|
5379
|
+
arraySet(localHeaderArray, rawLocalExtraFieldZip64, localHeaderOffset);
|
|
5362
5380
|
}
|
|
5363
5381
|
localHeaderOffset += localExtraFieldZip64Length;
|
|
5364
5382
|
arraySet(localHeaderArray, rawExtraFieldAES, localHeaderOffset);
|
|
@@ -5531,40 +5549,29 @@ function updateLocalHeader({
|
|
|
5531
5549
|
signature,
|
|
5532
5550
|
compressedSize,
|
|
5533
5551
|
uncompressedSize,
|
|
5534
|
-
offset,
|
|
5535
|
-
diskNumberStart,
|
|
5536
5552
|
zip64UncompressedSize,
|
|
5537
|
-
zip64CompressedSize
|
|
5538
|
-
zip64Offset,
|
|
5539
|
-
zip64DiskNumberStart
|
|
5553
|
+
zip64CompressedSize
|
|
5540
5554
|
}, localHeaderView, { dataDescriptor }) {
|
|
5541
5555
|
if (!dataDescriptor) {
|
|
5542
5556
|
if (!encrypted) {
|
|
5543
5557
|
setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + 4, signature);
|
|
5544
5558
|
}
|
|
5545
|
-
if (!
|
|
5559
|
+
if (!zip64CompressedSize) {
|
|
5546
5560
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, compressedSize);
|
|
5561
|
+
}
|
|
5562
|
+
if (!zip64UncompressedSize) {
|
|
5547
5563
|
setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, uncompressedSize);
|
|
5548
5564
|
}
|
|
5549
5565
|
}
|
|
5550
|
-
if (zip64) {
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
localHeaderOffset += 8;
|
|
5560
|
-
}
|
|
5561
|
-
if (zip64Offset) {
|
|
5562
|
-
setBigUint64(localHeaderView, localHeaderOffset, BigInt(offset));
|
|
5563
|
-
localHeaderOffset += 8;
|
|
5564
|
-
}
|
|
5565
|
-
if (zip64DiskNumberStart) {
|
|
5566
|
-
setUint32(localHeaderView, localHeaderOffset, diskNumberStart);
|
|
5567
|
-
}
|
|
5566
|
+
if (zip64 && localExtraFieldZip64Length) {
|
|
5567
|
+
let localHeaderOffset = HEADER_SIZE + getLength(rawFilename) + 4;
|
|
5568
|
+
if (zip64UncompressedSize) {
|
|
5569
|
+
setBigUint64(localHeaderView, localHeaderOffset, BigInt(uncompressedSize));
|
|
5570
|
+
localHeaderOffset += 8;
|
|
5571
|
+
}
|
|
5572
|
+
if (zip64CompressedSize) {
|
|
5573
|
+
setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
|
|
5574
|
+
localHeaderOffset += 8;
|
|
5568
5575
|
}
|
|
5569
5576
|
}
|
|
5570
5577
|
}
|
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
|
|
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;
|