@zip.js/zip.js 2.8.50 → 2.8.51
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/deno.json +1 -1
- package/dist/zip-fs-core-external.js +130 -101
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +130 -100
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +130 -101
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +130 -100
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +130 -100
- package/dist/zip-fs.min.js +1 -1
- package/index-native.cjs +130 -100
- package/index-native.min.js +1 -1
- package/index.cjs +130 -100
- package/index.d.cts +43 -0
- package/index.d.ts +43 -0
- package/index.min.js +1 -1
- package/lib/core/zip-fs.js +131 -102
- package/package.json +1 -1
package/deno.json
CHANGED
|
@@ -8601,6 +8601,8 @@ configureExternalAssets();
|
|
|
8601
8601
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8602
8602
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8603
8603
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
8604
|
+
const ERR_ABORTED = "The operation was aborted";
|
|
8605
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
8604
8606
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
8605
8607
|
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
8606
8608
|
EXTRAFIELD_TYPE_ZIP64,
|
|
@@ -9053,6 +9055,10 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
9053
9055
|
}
|
|
9054
9056
|
}
|
|
9055
9057
|
|
|
9058
|
+
getChildren(options = {}) {
|
|
9059
|
+
return collectChildren(this, options.recursive);
|
|
9060
|
+
}
|
|
9061
|
+
|
|
9056
9062
|
isPasswordProtected() {
|
|
9057
9063
|
const children = this.children;
|
|
9058
9064
|
for (let childIndex = 0; childIndex < children.length; childIndex++) {
|
|
@@ -9144,6 +9150,10 @@ class FS {
|
|
|
9144
9150
|
return this.root.getChildByName(name);
|
|
9145
9151
|
}
|
|
9146
9152
|
|
|
9153
|
+
getChildren(options) {
|
|
9154
|
+
return this.root.getChildren(options);
|
|
9155
|
+
}
|
|
9156
|
+
|
|
9147
9157
|
addDirectory(name, options) {
|
|
9148
9158
|
return this.root.addDirectory(name, options);
|
|
9149
9159
|
}
|
|
@@ -9403,103 +9413,101 @@ function getUserExtraField(extraField) {
|
|
|
9403
9413
|
async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
9404
9414
|
const selectedEntry = entry;
|
|
9405
9415
|
const entryOffsets = new Map();
|
|
9406
|
-
|
|
9416
|
+
if (options.bufferedWrite) {
|
|
9417
|
+
await processChildren(entry);
|
|
9418
|
+
} else {
|
|
9419
|
+
for (const child of entry.getChildren({ recursive: true })) {
|
|
9420
|
+
await addChild(child);
|
|
9421
|
+
}
|
|
9422
|
+
}
|
|
9407
9423
|
|
|
9408
|
-
async function
|
|
9409
|
-
await
|
|
9424
|
+
async function processChildren(entry) {
|
|
9425
|
+
const results = await Promise.allSettled(entry.children.map(async child => {
|
|
9426
|
+
await addChild(child);
|
|
9427
|
+
await processChildren(child);
|
|
9428
|
+
}));
|
|
9429
|
+
const errorResult = results.find(result => result.status == "rejected");
|
|
9430
|
+
if (errorResult) {
|
|
9431
|
+
throw errorResult.reason;
|
|
9432
|
+
}
|
|
9433
|
+
}
|
|
9410
9434
|
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9435
|
+
async function addChild(child) {
|
|
9436
|
+
const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
|
|
9437
|
+
const childOptions = child.options || {};
|
|
9438
|
+
let zipEntryOptions = {};
|
|
9439
|
+
if (child.data instanceof Entry) {
|
|
9440
|
+
const {
|
|
9441
|
+
externalFileAttributes,
|
|
9442
|
+
versionMadeBy,
|
|
9443
|
+
comment,
|
|
9444
|
+
lastModDate,
|
|
9445
|
+
creationDate,
|
|
9446
|
+
lastAccessDate,
|
|
9447
|
+
uncompressedSize,
|
|
9448
|
+
encrypted,
|
|
9449
|
+
zipCrypto,
|
|
9450
|
+
crc32,
|
|
9451
|
+
compressionMethod,
|
|
9452
|
+
extraFieldAES,
|
|
9453
|
+
internalFileAttributes,
|
|
9454
|
+
extraField,
|
|
9455
|
+
uid,
|
|
9456
|
+
gid
|
|
9457
|
+
} = child.data;
|
|
9458
|
+
zipEntryOptions = {
|
|
9459
|
+
externalFileAttributes,
|
|
9460
|
+
versionMadeBy,
|
|
9461
|
+
comment,
|
|
9462
|
+
lastModDate,
|
|
9463
|
+
creationDate,
|
|
9464
|
+
lastAccessDate,
|
|
9465
|
+
internalFileAttributes
|
|
9466
|
+
};
|
|
9467
|
+
const userExtraField = getUserExtraField(extraField);
|
|
9468
|
+
if (userExtraField) {
|
|
9469
|
+
zipEntryOptions.extraField = userExtraField;
|
|
9470
|
+
}
|
|
9471
|
+
if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
|
|
9472
|
+
Object.assign(zipEntryOptions, {
|
|
9473
|
+
uid,
|
|
9474
|
+
gid,
|
|
9475
|
+
unixExtraFieldType: options.unixExtraFieldType || INFOZIP_EXTRA_FIELD_TYPE
|
|
9476
|
+
});
|
|
9477
|
+
}
|
|
9478
|
+
if (child.passThrough) {
|
|
9479
|
+
let level, encryptionStrength;
|
|
9480
|
+
if (compressionMethod === 0) {
|
|
9481
|
+
level = 0;
|
|
9417
9482
|
}
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
await processChild(child);
|
|
9483
|
+
if (extraFieldAES) {
|
|
9484
|
+
encryptionStrength = extraFieldAES.strength;
|
|
9421
9485
|
}
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
async function processChild(child) {
|
|
9426
|
-
const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
|
|
9427
|
-
const childOptions = child.options || {};
|
|
9428
|
-
let zipEntryOptions = {};
|
|
9429
|
-
if (child.data instanceof Entry) {
|
|
9430
|
-
const {
|
|
9431
|
-
externalFileAttributes,
|
|
9432
|
-
versionMadeBy,
|
|
9433
|
-
comment,
|
|
9434
|
-
lastModDate,
|
|
9435
|
-
creationDate,
|
|
9436
|
-
lastAccessDate,
|
|
9437
|
-
uncompressedSize,
|
|
9486
|
+
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
9487
|
+
passThrough: true,
|
|
9438
9488
|
encrypted,
|
|
9439
9489
|
zipCrypto,
|
|
9440
9490
|
crc32,
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
gid
|
|
9447
|
-
} = child.data;
|
|
9448
|
-
zipEntryOptions = {
|
|
9449
|
-
externalFileAttributes,
|
|
9450
|
-
versionMadeBy,
|
|
9451
|
-
comment,
|
|
9452
|
-
lastModDate,
|
|
9453
|
-
creationDate,
|
|
9454
|
-
lastAccessDate,
|
|
9455
|
-
internalFileAttributes
|
|
9456
|
-
};
|
|
9457
|
-
const userExtraField = getUserExtraField(extraField);
|
|
9458
|
-
if (userExtraField) {
|
|
9459
|
-
zipEntryOptions.extraField = userExtraField;
|
|
9460
|
-
}
|
|
9461
|
-
if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
|
|
9462
|
-
Object.assign(zipEntryOptions, {
|
|
9463
|
-
uid,
|
|
9464
|
-
gid,
|
|
9465
|
-
unixExtraFieldType: options.unixExtraFieldType || INFOZIP_EXTRA_FIELD_TYPE
|
|
9466
|
-
});
|
|
9467
|
-
}
|
|
9468
|
-
if (child.passThrough) {
|
|
9469
|
-
let level, encryptionStrength;
|
|
9470
|
-
if (compressionMethod === 0) {
|
|
9471
|
-
level = 0;
|
|
9472
|
-
}
|
|
9473
|
-
if (extraFieldAES) {
|
|
9474
|
-
encryptionStrength = extraFieldAES.strength;
|
|
9475
|
-
}
|
|
9476
|
-
zipEntryOptions = Object.assign(zipEntryOptions, {
|
|
9477
|
-
passThrough: true,
|
|
9478
|
-
encrypted,
|
|
9479
|
-
zipCrypto,
|
|
9480
|
-
crc32,
|
|
9481
|
-
uncompressedSize,
|
|
9482
|
-
level,
|
|
9483
|
-
encryptionStrength,
|
|
9484
|
-
compressionMethod
|
|
9485
|
-
});
|
|
9486
|
-
}
|
|
9491
|
+
uncompressedSize,
|
|
9492
|
+
level,
|
|
9493
|
+
encryptionStrength,
|
|
9494
|
+
compressionMethod
|
|
9495
|
+
});
|
|
9487
9496
|
}
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9497
|
+
}
|
|
9498
|
+
await zipWriter.add(name, readers.get(child), Object.assign({}, options, zipEntryOptions, childOptions, {
|
|
9499
|
+
directory: child.directory,
|
|
9500
|
+
onprogress: async indexProgress => {
|
|
9501
|
+
if (options.onprogress) {
|
|
9502
|
+
entryOffsets.set(name, indexProgress);
|
|
9503
|
+
try {
|
|
9504
|
+
await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
|
|
9505
|
+
} catch {
|
|
9506
|
+
// ignored
|
|
9498
9507
|
}
|
|
9499
9508
|
}
|
|
9500
|
-
}
|
|
9501
|
-
|
|
9502
|
-
}
|
|
9509
|
+
}
|
|
9510
|
+
}));
|
|
9503
9511
|
}
|
|
9504
9512
|
}
|
|
9505
9513
|
|
|
@@ -9555,6 +9563,7 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9555
9563
|
const { signal } = abortController;
|
|
9556
9564
|
const releaseSignal = forwardAbort(options.signal, abortController);
|
|
9557
9565
|
const exportedEntryNames = [];
|
|
9566
|
+
let exportAborted = false;
|
|
9558
9567
|
try {
|
|
9559
9568
|
await exportChildren(zipEntry, directoryHandle);
|
|
9560
9569
|
} catch (error) {
|
|
@@ -9587,10 +9596,10 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9587
9596
|
|
|
9588
9597
|
async function exportChild(child, parentHandle) {
|
|
9589
9598
|
if (signal.aborted) {
|
|
9590
|
-
if (isExportAborted(signal.reason)) {
|
|
9599
|
+
if (exportAborted || isExportAborted(signal.reason)) {
|
|
9591
9600
|
return;
|
|
9592
9601
|
}
|
|
9593
|
-
throw signal.reason;
|
|
9602
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
9594
9603
|
}
|
|
9595
9604
|
try {
|
|
9596
9605
|
if (child.directory) {
|
|
@@ -9599,22 +9608,27 @@ async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
|
9599
9608
|
} else {
|
|
9600
9609
|
const fileHandle = await parentHandle.getFileHandle(child.name, { create: true });
|
|
9601
9610
|
const writable = await fileHandle.createWritable();
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
+
try {
|
|
9612
|
+
await child.getData({ writable }, Object.assign({}, options, {
|
|
9613
|
+
signal,
|
|
9614
|
+
onprogress: async progress => {
|
|
9615
|
+
if (options.onprogress) {
|
|
9616
|
+
writtenSizes.set(child.id, progress);
|
|
9617
|
+
try {
|
|
9618
|
+
await options.onprogress(Array.from(writtenSizes.values()).reduce((previousValue, currentValue) => previousValue + currentValue, 0), totalSize);
|
|
9619
|
+
} catch {
|
|
9620
|
+
// ignored
|
|
9621
|
+
}
|
|
9611
9622
|
}
|
|
9612
9623
|
}
|
|
9613
|
-
}
|
|
9614
|
-
})
|
|
9624
|
+
}));
|
|
9625
|
+
} catch (error) {
|
|
9626
|
+
throw exportAborted ? new Error(ERR_ABORT_EXPORT) : error;
|
|
9627
|
+
}
|
|
9615
9628
|
exportedEntryNames.push(child.getRelativeName(zipEntry));
|
|
9616
9629
|
}
|
|
9617
9630
|
} catch (error) {
|
|
9631
|
+
exportAborted = true;
|
|
9618
9632
|
abortController.abort(new Error(ERR_ABORT_EXPORT));
|
|
9619
9633
|
try {
|
|
9620
9634
|
if (error.entryName === UNDEFINED_VALUE) {
|
|
@@ -9686,6 +9700,21 @@ function resetFS(fs) {
|
|
|
9686
9700
|
fs.root = new ZipDirectoryEntry(fs);
|
|
9687
9701
|
}
|
|
9688
9702
|
|
|
9703
|
+
function collectChildren(directory, recursive) {
|
|
9704
|
+
const children = [];
|
|
9705
|
+
const pendingDirectories = [directory];
|
|
9706
|
+
let directoryIndex = 0;
|
|
9707
|
+
while (directoryIndex < pendingDirectories.length) {
|
|
9708
|
+
for (const child of pendingDirectories[directoryIndex++].children) {
|
|
9709
|
+
children.push(child);
|
|
9710
|
+
if (recursive) {
|
|
9711
|
+
pendingDirectories.push(child);
|
|
9712
|
+
}
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9715
|
+
return children;
|
|
9716
|
+
}
|
|
9717
|
+
|
|
9689
9718
|
function registerEntries(fs, entry) {
|
|
9690
9719
|
const pendingEntries = [entry];
|
|
9691
9720
|
while (pendingEntries.length) {
|
|
@@ -9705,4 +9734,4 @@ function addChild(parent, name, params, directory) {
|
|
|
9705
9734
|
}
|
|
9706
9735
|
}
|
|
9707
9736
|
|
|
9708
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
9737
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_ABORTED, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_EXISTS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_READABLE_CONSUMED, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, fs, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|