@loaders.gl/zip 4.3.4 → 4.4.0-alpha.10
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/dist.dev.js +275 -248
- package/dist/dist.min.js +2 -2
- package/dist/filesystems/IndexedArchive.d.ts +4 -4
- package/dist/filesystems/IndexedArchive.d.ts.map +1 -1
- package/dist/filesystems/IndexedArchive.js +6 -5
- package/dist/filesystems/IndexedArchive.js.map +1 -0
- package/dist/filesystems/zip-filesystem.d.ts +7 -6
- package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
- package/dist/filesystems/zip-filesystem.js +25 -22
- package/dist/filesystems/zip-filesystem.js.map +1 -0
- package/dist/hash-file-utility.d.ts +3 -3
- package/dist/hash-file-utility.d.ts.map +1 -1
- package/dist/hash-file-utility.js +2 -1
- package/dist/hash-file-utility.js.map +1 -0
- package/dist/index.cjs +181 -82
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/tar/header.js +1 -0
- package/dist/lib/tar/header.js.map +1 -0
- package/dist/lib/tar/tar.js +1 -0
- package/dist/lib/tar/tar.js.map +1 -0
- package/dist/lib/tar/types.js +1 -0
- package/dist/lib/tar/types.js.map +1 -0
- package/dist/lib/tar/utils.js +1 -0
- package/dist/lib/tar/utils.js.map +1 -0
- package/dist/parse-zip/cd-file-header.d.ts +4 -4
- package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
- package/dist/parse-zip/cd-file-header.js +9 -6
- package/dist/parse-zip/cd-file-header.js.map +1 -0
- package/dist/parse-zip/end-of-central-directory.d.ts +3 -3
- package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -1
- package/dist/parse-zip/end-of-central-directory.js +13 -11
- package/dist/parse-zip/end-of-central-directory.js.map +1 -0
- package/dist/parse-zip/local-file-header.d.ts +2 -2
- package/dist/parse-zip/local-file-header.d.ts.map +1 -1
- package/dist/parse-zip/local-file-header.js +5 -3
- package/dist/parse-zip/local-file-header.js.map +1 -0
- package/dist/parse-zip/readable-file-utils.d.ts +34 -0
- package/dist/parse-zip/readable-file-utils.d.ts.map +1 -0
- package/dist/parse-zip/readable-file-utils.js +111 -0
- package/dist/parse-zip/readable-file-utils.js.map +1 -0
- package/dist/parse-zip/search-from-the-end.d.ts +2 -2
- package/dist/parse-zip/search-from-the-end.d.ts.map +1 -1
- package/dist/parse-zip/search-from-the-end.js +7 -8
- package/dist/parse-zip/search-from-the-end.js.map +1 -0
- package/dist/parse-zip/zip-composition.d.ts.map +1 -1
- package/dist/parse-zip/zip-composition.js +16 -8
- package/dist/parse-zip/zip-composition.js.map +1 -0
- package/dist/parse-zip/zip64-info-generation.js +1 -0
- package/dist/parse-zip/zip64-info-generation.js.map +1 -0
- package/dist/tar-builder.js +1 -0
- package/dist/tar-builder.js.map +1 -0
- package/dist/zip-loader.js +2 -1
- package/dist/zip-loader.js.map +1 -0
- package/dist/zip-writer.js +3 -2
- package/dist/zip-writer.js.map +1 -0
- package/package.json +6 -6
- package/src/filesystems/IndexedArchive.ts +6 -10
- package/src/filesystems/zip-filesystem.ts +26 -28
- package/src/hash-file-utility.ts +4 -7
- package/src/index.ts +5 -0
- package/src/parse-zip/cd-file-header.ts +18 -16
- package/src/parse-zip/end-of-central-directory.ts +16 -17
- package/src/parse-zip/local-file-header.ts +8 -9
- package/src/parse-zip/readable-file-utils.ts +134 -0
- package/src/parse-zip/search-from-the-end.ts +8 -10
- package/src/parse-zip/zip-composition.ts +25 -18
- package/src/zip-writer.ts +1 -1
package/dist/dist.dev.js
CHANGED
|
@@ -6960,6 +6960,7 @@ var __exports__ = (() => {
|
|
|
6960
6960
|
var bundle_exports = {};
|
|
6961
6961
|
__export(bundle_exports, {
|
|
6962
6962
|
CD_HEADER_SIGNATURE: () => signature2,
|
|
6963
|
+
DataViewReadableFile: () => DataViewReadableFile,
|
|
6963
6964
|
IndexedArchive: () => IndexedArchive,
|
|
6964
6965
|
TarBuilder: () => TarBuilder,
|
|
6965
6966
|
ZIP_COMPRESSION_HANDLERS: () => ZIP_COMPRESSION_HANDLERS,
|
|
@@ -6971,6 +6972,7 @@ var __exports__ = (() => {
|
|
|
6971
6972
|
createZip: () => createZip,
|
|
6972
6973
|
generateCDHeader: () => generateCDHeader,
|
|
6973
6974
|
generateLocalHeader: () => generateLocalHeader,
|
|
6975
|
+
getReadableFileSize: () => getReadableFileSize,
|
|
6974
6976
|
localHeaderSignature: () => signature3,
|
|
6975
6977
|
makeHashTableFromZipHeaders: () => makeHashTableFromZipHeaders,
|
|
6976
6978
|
makeZipCDHeaderIterator: () => makeZipCDHeaderIterator,
|
|
@@ -6978,6 +6980,7 @@ var __exports__ = (() => {
|
|
|
6978
6980
|
parseHashTable: () => parseHashTable,
|
|
6979
6981
|
parseZipCDFileHeader: () => parseZipCDFileHeader,
|
|
6980
6982
|
parseZipLocalFileHeader: () => parseZipLocalFileHeader,
|
|
6983
|
+
readRange: () => readRange,
|
|
6981
6984
|
searchFromTheEnd: () => searchFromTheEnd
|
|
6982
6985
|
});
|
|
6983
6986
|
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
@@ -7064,7 +7067,7 @@ var __exports__ = (() => {
|
|
|
7064
7067
|
zipOptions.onUpdate
|
|
7065
7068
|
);
|
|
7066
7069
|
} catch (error) {
|
|
7067
|
-
options.log
|
|
7070
|
+
options.core?.log?.error(`Unable to encode zip archive: ${error}`);
|
|
7068
7071
|
throw error;
|
|
7069
7072
|
}
|
|
7070
7073
|
}
|
|
@@ -7307,6 +7310,9 @@ var __exports__ = (() => {
|
|
|
7307
7310
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
7308
7311
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
7309
7312
|
|
|
7313
|
+
// ../loader-utils/src/lib/javascript-utils/is-type.ts
|
|
7314
|
+
var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
7315
|
+
|
|
7310
7316
|
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
7311
7317
|
function registerJSModules(modules) {
|
|
7312
7318
|
globalThis.loaders ||= {};
|
|
@@ -7350,10 +7356,26 @@ var __exports__ = (() => {
|
|
|
7350
7356
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
7351
7357
|
const arrayBuffers = [];
|
|
7352
7358
|
for await (const chunk of asyncIterator) {
|
|
7353
|
-
arrayBuffers.push(chunk);
|
|
7359
|
+
arrayBuffers.push(copyToArrayBuffer(chunk));
|
|
7354
7360
|
}
|
|
7355
7361
|
return concatenateArrayBuffers(...arrayBuffers);
|
|
7356
7362
|
}
|
|
7363
|
+
function copyToArrayBuffer(chunk) {
|
|
7364
|
+
if (chunk instanceof ArrayBuffer) {
|
|
7365
|
+
return chunk;
|
|
7366
|
+
}
|
|
7367
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
7368
|
+
const { buffer, byteOffset, byteLength } = chunk;
|
|
7369
|
+
return copyFromBuffer(buffer, byteOffset, byteLength);
|
|
7370
|
+
}
|
|
7371
|
+
return copyFromBuffer(chunk);
|
|
7372
|
+
}
|
|
7373
|
+
function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
7374
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
7375
|
+
const copy = new Uint8Array(view.length);
|
|
7376
|
+
copy.set(view);
|
|
7377
|
+
return copy.buffer;
|
|
7378
|
+
}
|
|
7357
7379
|
|
|
7358
7380
|
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
7359
7381
|
function toArrayBuffer(buffer) {
|
|
@@ -7371,11 +7393,15 @@ var __exports__ = (() => {
|
|
|
7371
7393
|
if (data instanceof ArrayBuffer) {
|
|
7372
7394
|
return data;
|
|
7373
7395
|
}
|
|
7396
|
+
if (isSharedArrayBuffer(data)) {
|
|
7397
|
+
return copyToArrayBuffer2(data);
|
|
7398
|
+
}
|
|
7374
7399
|
if (ArrayBuffer.isView(data)) {
|
|
7400
|
+
const buffer = data.buffer;
|
|
7375
7401
|
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
7376
|
-
return
|
|
7402
|
+
return buffer;
|
|
7377
7403
|
}
|
|
7378
|
-
return
|
|
7404
|
+
return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
7379
7405
|
}
|
|
7380
7406
|
if (typeof data === "string") {
|
|
7381
7407
|
const text = data;
|
|
@@ -7387,6 +7413,12 @@ var __exports__ = (() => {
|
|
|
7387
7413
|
}
|
|
7388
7414
|
throw new Error("toArrayBuffer");
|
|
7389
7415
|
}
|
|
7416
|
+
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
7417
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
7418
|
+
const copy = new Uint8Array(view.length);
|
|
7419
|
+
copy.set(view);
|
|
7420
|
+
return copy.buffer;
|
|
7421
|
+
}
|
|
7390
7422
|
|
|
7391
7423
|
// ../loader-utils/src/lib/node/promisify.ts
|
|
7392
7424
|
function promisify1(fn) {
|
|
@@ -7416,7 +7448,7 @@ var __exports__ = (() => {
|
|
|
7416
7448
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
7417
7449
|
function filename(url) {
|
|
7418
7450
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
7419
|
-
return slashIndex >= 0 ? url.substr(slashIndex + 1) :
|
|
7451
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
|
|
7420
7452
|
}
|
|
7421
7453
|
function dirname(url) {
|
|
7422
7454
|
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
@@ -7538,6 +7570,33 @@ var __exports__ = (() => {
|
|
|
7538
7570
|
return res;
|
|
7539
7571
|
}
|
|
7540
7572
|
|
|
7573
|
+
// ../loader-utils/src/lib/files/blob-file.ts
|
|
7574
|
+
var BlobFile = class {
|
|
7575
|
+
handle;
|
|
7576
|
+
size;
|
|
7577
|
+
bigsize;
|
|
7578
|
+
url;
|
|
7579
|
+
constructor(blob) {
|
|
7580
|
+
this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
|
|
7581
|
+
this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
|
|
7582
|
+
this.bigsize = BigInt(this.size);
|
|
7583
|
+
this.url = blob instanceof File ? blob.name : "";
|
|
7584
|
+
}
|
|
7585
|
+
async close() {
|
|
7586
|
+
}
|
|
7587
|
+
async stat() {
|
|
7588
|
+
return {
|
|
7589
|
+
size: this.handle.size,
|
|
7590
|
+
bigsize: BigInt(this.handle.size),
|
|
7591
|
+
isDirectory: false
|
|
7592
|
+
};
|
|
7593
|
+
}
|
|
7594
|
+
async read(start, length) {
|
|
7595
|
+
const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length)).arrayBuffer();
|
|
7596
|
+
return arrayBuffer;
|
|
7597
|
+
}
|
|
7598
|
+
};
|
|
7599
|
+
|
|
7541
7600
|
// ../loader-utils/src/lib/files/node-file-facade.ts
|
|
7542
7601
|
var NOT_IMPLEMENTED = new Error("Not implemented");
|
|
7543
7602
|
var NodeFileFacade = class {
|
|
@@ -7620,179 +7679,109 @@ var __exports__ = (() => {
|
|
|
7620
7679
|
}
|
|
7621
7680
|
};
|
|
7622
7681
|
|
|
7623
|
-
//
|
|
7624
|
-
|
|
7625
|
-
return
|
|
7626
|
-
}
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
file;
|
|
7632
|
-
/** Create a new FileHandleFile */
|
|
7633
|
-
constructor(path, append = false) {
|
|
7634
|
-
this.file = new NodeFileFacade(path, append ? "a+" : "r");
|
|
7635
|
-
}
|
|
7636
|
-
/**
|
|
7637
|
-
* Truncates the file descriptor.
|
|
7638
|
-
* @param length desired file lenght
|
|
7639
|
-
*/
|
|
7640
|
-
async truncate(length) {
|
|
7641
|
-
await this.file.truncate(length);
|
|
7642
|
-
}
|
|
7643
|
-
/**
|
|
7644
|
-
* Append data to a file.
|
|
7645
|
-
* @param buffer data to append
|
|
7646
|
-
*/
|
|
7647
|
-
async append(buffer) {
|
|
7648
|
-
await this.file.append(buffer);
|
|
7649
|
-
}
|
|
7650
|
-
/** Close file */
|
|
7651
|
-
async destroy() {
|
|
7652
|
-
await this.file.close();
|
|
7682
|
+
// src/parse-zip/readable-file-utils.ts
|
|
7683
|
+
function toBigInt(value) {
|
|
7684
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
7685
|
+
}
|
|
7686
|
+
function toNumber(value) {
|
|
7687
|
+
const numberValue = Number(value);
|
|
7688
|
+
if (!Number.isFinite(numberValue)) {
|
|
7689
|
+
throw new Error("Offset is out of bounds");
|
|
7653
7690
|
}
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
const arrayBuffer = await this.file.read(offset, 1);
|
|
7660
|
-
const val = new Uint8Array(arrayBuffer).at(0);
|
|
7661
|
-
if (val === void 0) {
|
|
7662
|
-
throw new Error("something went wrong");
|
|
7663
|
-
}
|
|
7664
|
-
return val;
|
|
7691
|
+
return numberValue;
|
|
7692
|
+
}
|
|
7693
|
+
function normalizeOffset(offset, size) {
|
|
7694
|
+
if (offset < 0) {
|
|
7695
|
+
return Math.max(size + offset, 0);
|
|
7665
7696
|
}
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7697
|
+
return Math.min(offset, size);
|
|
7698
|
+
}
|
|
7699
|
+
async function readRange(file, start, end) {
|
|
7700
|
+
const startOffset = toBigInt(start);
|
|
7701
|
+
const endOffset = toBigInt(end);
|
|
7702
|
+
const length = endOffset - startOffset;
|
|
7703
|
+
if (length < 0) {
|
|
7704
|
+
throw new Error("Invalid range requested");
|
|
7705
|
+
}
|
|
7706
|
+
return await file.read(startOffset, toNumber(length));
|
|
7707
|
+
}
|
|
7708
|
+
async function readDataView(file, start, end) {
|
|
7709
|
+
const arrayBuffer = await readRange(file, start, end);
|
|
7710
|
+
return new DataView(arrayBuffer);
|
|
7711
|
+
}
|
|
7712
|
+
async function readUint16(file, offset) {
|
|
7713
|
+
const dataView = await readDataView(file, offset, toBigInt(offset) + 2n);
|
|
7714
|
+
return dataView.getUint16(0, true);
|
|
7715
|
+
}
|
|
7716
|
+
async function readUint32(file, offset) {
|
|
7717
|
+
const dataView = await readDataView(file, offset, toBigInt(offset) + 4n);
|
|
7718
|
+
return dataView.getUint32(0, true);
|
|
7719
|
+
}
|
|
7720
|
+
async function readBigUint64(file, offset) {
|
|
7721
|
+
const dataView = await readDataView(file, offset, toBigInt(offset) + 8n);
|
|
7722
|
+
return dataView.getBigUint64(0, true);
|
|
7723
|
+
}
|
|
7724
|
+
async function getReadableFileSize(file) {
|
|
7725
|
+
if (file.bigsize > 0n) {
|
|
7726
|
+
return file.bigsize;
|
|
7677
7727
|
}
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7681
|
-
*/
|
|
7682
|
-
async getUint32(offset) {
|
|
7683
|
-
const arrayBuffer = await this.file.read(offset, 4);
|
|
7684
|
-
const val = new Uint32Array(arrayBuffer).at(0);
|
|
7685
|
-
if (val === void 0) {
|
|
7686
|
-
throw new Error("something went wrong");
|
|
7687
|
-
}
|
|
7688
|
-
return val;
|
|
7728
|
+
if (file.size > 0) {
|
|
7729
|
+
return BigInt(file.size);
|
|
7689
7730
|
}
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
async getBigUint64(offset) {
|
|
7695
|
-
const arrayBuffer = await this.file.read(offset, 8);
|
|
7696
|
-
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
7697
|
-
if (val === void 0) {
|
|
7698
|
-
throw new Error("something went wrong");
|
|
7731
|
+
if (file.stat) {
|
|
7732
|
+
const stats = await file.stat();
|
|
7733
|
+
if (stats?.bigsize !== void 0) {
|
|
7734
|
+
return stats.bigsize;
|
|
7699
7735
|
}
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
/**
|
|
7703
|
-
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
7704
|
-
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
7705
|
-
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
7706
|
-
*/
|
|
7707
|
-
async slice(startOffset, endOffset) {
|
|
7708
|
-
const bigLength = endOffset - startOffset;
|
|
7709
|
-
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
7710
|
-
throw new Error("too big slice");
|
|
7736
|
+
if (stats?.size !== void 0) {
|
|
7737
|
+
return BigInt(stats.size);
|
|
7711
7738
|
}
|
|
7712
|
-
const length = Number(bigLength);
|
|
7713
|
-
return await this.file.read(startOffset, length);
|
|
7714
7739
|
}
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
}
|
|
7728
|
-
return Number(bigint);
|
|
7729
|
-
};
|
|
7730
|
-
var DataViewFile = class {
|
|
7731
|
-
/** The DataView from which data is provided */
|
|
7732
|
-
file;
|
|
7733
|
-
constructor(file) {
|
|
7734
|
-
this.file = file;
|
|
7735
|
-
}
|
|
7736
|
-
async destroy() {
|
|
7737
|
-
}
|
|
7738
|
-
/**
|
|
7739
|
-
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
7740
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7741
|
-
*/
|
|
7742
|
-
async getUint8(offset) {
|
|
7743
|
-
return this.file.getUint8(toNumber(offset));
|
|
7744
|
-
}
|
|
7745
|
-
/**
|
|
7746
|
-
* Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
|
|
7747
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7748
|
-
*/
|
|
7749
|
-
async getUint16(offset) {
|
|
7750
|
-
return this.file.getUint16(toNumber(offset), true);
|
|
7751
|
-
}
|
|
7752
|
-
/**
|
|
7753
|
-
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
7754
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7755
|
-
*/
|
|
7756
|
-
async getUint32(offset) {
|
|
7757
|
-
return this.file.getUint32(toNumber(offset), true);
|
|
7740
|
+
return 0n;
|
|
7741
|
+
}
|
|
7742
|
+
var DataViewReadableFile = class {
|
|
7743
|
+
handle;
|
|
7744
|
+
size;
|
|
7745
|
+
bigsize;
|
|
7746
|
+
url;
|
|
7747
|
+
constructor(dataView, url = "") {
|
|
7748
|
+
this.handle = dataView;
|
|
7749
|
+
this.size = dataView.byteLength;
|
|
7750
|
+
this.bigsize = BigInt(dataView.byteLength);
|
|
7751
|
+
this.url = url;
|
|
7758
7752
|
}
|
|
7759
|
-
|
|
7760
|
-
* Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
|
|
7761
|
-
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7762
|
-
*/
|
|
7763
|
-
async getBigUint64(offset) {
|
|
7764
|
-
return this.file.getBigUint64(toNumber(offset), true);
|
|
7753
|
+
async close() {
|
|
7765
7754
|
}
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
7769
|
-
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
7770
|
-
*/
|
|
7771
|
-
async slice(startOffset, endOffset) {
|
|
7772
|
-
return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
|
|
7755
|
+
async stat() {
|
|
7756
|
+
return { size: this.size, bigsize: this.bigsize, isDirectory: false };
|
|
7773
7757
|
}
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7758
|
+
async read(start = 0, length) {
|
|
7759
|
+
const offset = toNumber(start);
|
|
7760
|
+
const end = length ? offset + length : this.size;
|
|
7761
|
+
const normalizedStart = normalizeOffset(offset, this.size);
|
|
7762
|
+
const normalizedEnd = normalizeOffset(end, this.size);
|
|
7763
|
+
const clampedEnd = Math.max(normalizedEnd, normalizedStart);
|
|
7764
|
+
const lengthToRead = clampedEnd - normalizedStart;
|
|
7765
|
+
if (lengthToRead <= 0) {
|
|
7766
|
+
return new ArrayBuffer(0);
|
|
7767
|
+
}
|
|
7768
|
+
return copyToArrayBuffer2(this.handle.buffer, normalizedStart, lengthToRead);
|
|
7777
7769
|
}
|
|
7778
7770
|
};
|
|
7779
7771
|
|
|
7780
7772
|
// src/parse-zip/search-from-the-end.ts
|
|
7781
7773
|
var buffLength = 1024;
|
|
7782
7774
|
var searchFromTheEnd = async (file, target) => {
|
|
7783
|
-
const
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
await file.getUint8(file.length - 3n),
|
|
7787
|
-
void 0
|
|
7788
|
-
];
|
|
7775
|
+
const fileLength = await getReadableFileSize(file);
|
|
7776
|
+
const lastBytes = new Uint8Array(await readRange(file, fileLength - 3n, fileLength + 1n));
|
|
7777
|
+
const searchWindow = [lastBytes[3], lastBytes[2], lastBytes[1], void 0];
|
|
7789
7778
|
let targetOffset = -1;
|
|
7790
|
-
let point =
|
|
7779
|
+
let point = fileLength - 4n;
|
|
7791
7780
|
do {
|
|
7792
7781
|
const prevPoint = point;
|
|
7793
7782
|
point -= BigInt(buffLength);
|
|
7794
7783
|
point = point >= 0n ? point : 0n;
|
|
7795
|
-
const buff = new Uint8Array(await file
|
|
7784
|
+
const buff = new Uint8Array(await readRange(file, point, prevPoint));
|
|
7796
7785
|
for (let i = buff.length - 1; i > -1; i--) {
|
|
7797
7786
|
searchWindow[3] = searchWindow[2];
|
|
7798
7787
|
searchWindow[2] = searchWindow[1];
|
|
@@ -7884,23 +7873,24 @@ var __exports__ = (() => {
|
|
|
7884
7873
|
var ZIP64_COMMENT_OFFSET = 56n;
|
|
7885
7874
|
var parseEoCDRecord = async (file) => {
|
|
7886
7875
|
const zipEoCDOffset = await searchFromTheEnd(file, eoCDSignature);
|
|
7887
|
-
let cdRecordsNumber = BigInt(await file
|
|
7888
|
-
let cdByteSize = BigInt(await file
|
|
7889
|
-
let cdStartOffset = BigInt(await file
|
|
7876
|
+
let cdRecordsNumber = BigInt(await readUint16(file, zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
|
|
7877
|
+
let cdByteSize = BigInt(await readUint32(file, zipEoCDOffset + CD_CD_BYTE_SIZE_OFFSET));
|
|
7878
|
+
let cdStartOffset = BigInt(await readUint32(file, zipEoCDOffset + CD_START_OFFSET_OFFSET));
|
|
7890
7879
|
let zip64EoCDLocatorOffset = zipEoCDOffset - 20n;
|
|
7891
7880
|
let zip64EoCDOffset = 0n;
|
|
7892
|
-
const magicBytes = await file
|
|
7893
|
-
if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature)) {
|
|
7894
|
-
zip64EoCDOffset = await
|
|
7881
|
+
const magicBytes = await readRange(file, zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
|
|
7882
|
+
if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature.buffer)) {
|
|
7883
|
+
zip64EoCDOffset = await readBigUint64(
|
|
7884
|
+
file,
|
|
7895
7885
|
zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
|
|
7896
7886
|
);
|
|
7897
|
-
const endOfCDMagicBytes = await file
|
|
7887
|
+
const endOfCDMagicBytes = await readRange(file, zip64EoCDOffset, zip64EoCDOffset + 4n);
|
|
7898
7888
|
if (!compareArrayBuffers(endOfCDMagicBytes, zip64EoCDSignature.buffer)) {
|
|
7899
7889
|
throw new Error("zip64 EoCD not found");
|
|
7900
7890
|
}
|
|
7901
|
-
cdRecordsNumber = await file
|
|
7902
|
-
cdByteSize = await file
|
|
7903
|
-
cdStartOffset = await file
|
|
7891
|
+
cdRecordsNumber = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET);
|
|
7892
|
+
cdByteSize = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_CD_BYTE_SIZE_OFFSET);
|
|
7893
|
+
cdStartOffset = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
|
|
7904
7894
|
} else {
|
|
7905
7895
|
zip64EoCDLocatorOffset = 0n;
|
|
7906
7896
|
}
|
|
@@ -8135,12 +8125,11 @@ var __exports__ = (() => {
|
|
|
8135
8125
|
var CD_FILE_NAME_OFFSET = 46n;
|
|
8136
8126
|
var signature2 = new Uint8Array([80, 75, 1, 2]);
|
|
8137
8127
|
var parseZipCDFileHeader = async (headerOffset, file) => {
|
|
8138
|
-
|
|
8128
|
+
const fileLength = await getReadableFileSize(file);
|
|
8129
|
+
if (headerOffset >= fileLength) {
|
|
8139
8130
|
return null;
|
|
8140
8131
|
}
|
|
8141
|
-
const mainHeader =
|
|
8142
|
-
await file.slice(headerOffset, headerOffset + CD_FILE_NAME_OFFSET)
|
|
8143
|
-
);
|
|
8132
|
+
const mainHeader = await readDataView(file, headerOffset, headerOffset + CD_FILE_NAME_OFFSET);
|
|
8144
8133
|
const magicBytes = mainHeader.buffer.slice(0, 4);
|
|
8145
8134
|
if (!compareArrayBuffers(magicBytes, signature2.buffer)) {
|
|
8146
8135
|
return null;
|
|
@@ -8150,7 +8139,8 @@ var __exports__ = (() => {
|
|
|
8150
8139
|
const extraFieldLength = mainHeader.getUint16(CD_EXTRA_FIELD_LENGTH_OFFSET, true);
|
|
8151
8140
|
const startDisk = BigInt(mainHeader.getUint16(CD_START_DISK_OFFSET, true));
|
|
8152
8141
|
const fileNameLength = mainHeader.getUint16(CD_FILE_NAME_LENGTH_OFFSET, true);
|
|
8153
|
-
const additionalHeader = await
|
|
8142
|
+
const additionalHeader = await readRange(
|
|
8143
|
+
file,
|
|
8154
8144
|
headerOffset + CD_FILE_NAME_OFFSET,
|
|
8155
8145
|
headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
|
|
8156
8146
|
);
|
|
@@ -8180,8 +8170,8 @@ var __exports__ = (() => {
|
|
|
8180
8170
|
};
|
|
8181
8171
|
async function* makeZipCDHeaderIterator(fileProvider) {
|
|
8182
8172
|
const { cdStartOffset, cdByteSize } = await parseEoCDRecord(fileProvider);
|
|
8183
|
-
const centralDirectory = new
|
|
8184
|
-
new DataView(await fileProvider
|
|
8173
|
+
const centralDirectory = new DataViewReadableFile(
|
|
8174
|
+
new DataView(await readRange(fileProvider, cdStartOffset, cdStartOffset + cdByteSize))
|
|
8185
8175
|
);
|
|
8186
8176
|
let cdHeader = await parseZipCDFileHeader(0n, centralDirectory);
|
|
8187
8177
|
while (cdHeader) {
|
|
@@ -8376,14 +8366,15 @@ var __exports__ = (() => {
|
|
|
8376
8366
|
var FILE_NAME_OFFSET = 30n;
|
|
8377
8367
|
var signature3 = new Uint8Array([80, 75, 3, 4]);
|
|
8378
8368
|
var parseZipLocalFileHeader = async (headerOffset, file) => {
|
|
8379
|
-
const mainHeader =
|
|
8369
|
+
const mainHeader = await readDataView(file, headerOffset, headerOffset + FILE_NAME_OFFSET);
|
|
8380
8370
|
const magicBytes = mainHeader.buffer.slice(0, 4);
|
|
8381
|
-
if (!compareArrayBuffers(magicBytes, signature3)) {
|
|
8371
|
+
if (!compareArrayBuffers(magicBytes, signature3.buffer)) {
|
|
8382
8372
|
return null;
|
|
8383
8373
|
}
|
|
8384
8374
|
const fileNameLength = mainHeader.getUint16(FILE_NAME_LENGTH_OFFSET, true);
|
|
8385
8375
|
const extraFieldLength = mainHeader.getUint16(EXTRA_FIELD_LENGTH_OFFSET, true);
|
|
8386
|
-
const additionalHeader = await
|
|
8376
|
+
const additionalHeader = await readRange(
|
|
8377
|
+
file,
|
|
8387
8378
|
headerOffset + FILE_NAME_OFFSET,
|
|
8388
8379
|
headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
|
|
8389
8380
|
);
|
|
@@ -8939,16 +8930,16 @@ var __exports__ = (() => {
|
|
|
8939
8930
|
};
|
|
8940
8931
|
|
|
8941
8932
|
// ../crypto/src/lib/algorithms/md5-wasm.ts
|
|
8942
|
-
var
|
|
8943
|
-
var
|
|
8933
|
+
var BASE64_LOOKUP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
8934
|
+
var wasmB64Bytes = decodeBase64Safely(
|
|
8944
8935
|
"AGFzbQEAAAABDANgAX8AYAAAYAABfwIeAgdpbXBvcnRzA2xvZwAAB2ltcG9ydHMDbWVtAgABAzIxAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAAAAAAAAAAAAAAAAAAAAAAgICAgIAAAAAAAaYARt/AUGBxpS6Bgt/AUGJ17b+fgt/AUH+uevFeQt/AUH2qMmBAQt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALB7oCJQhvbmVGdWxsQQAYCG9uZUZ1bGxCABkIb25lRnVsbEMAGghvbmVGdWxsRAAbBWxvb3BzAAEEbG9vcAACBXByaW1lAAMFbG9vcEEABAZsb29wQTEABQZsb29wQTIABgZsb29wQTMABwZsb29wQTQACAVsb29wQgAJBmxvb3BCMQAKBmxvb3BCMgALBmxvb3BCMwAMBmxvb3BCNAANBWxvb3BDAA4GbG9vcEMxAA8GbG9vcEMyABAGbG9vcEMzABEGbG9vcEM0ABIFbG9vcEQAEwZsb29wRDEAF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AEBbicCAAABAW4oACkAKgArACwALQEAAC4BAAAvAQAAMAEAADEBAAA="
|
|
8945
8936
|
);
|
|
8946
|
-
var wasm = WebAssembly
|
|
8937
|
+
var wasm = typeof WebAssembly !== "undefined" && wasmB64Bytes ? wasmB64Bytes.buffer : false;
|
|
8947
8938
|
var crypt = makeCrypt();
|
|
8948
8939
|
var biteSize = 240 * 16 * 16;
|
|
8949
8940
|
var bounder = Math.floor(biteSize * 16 * 1.066666667);
|
|
8950
8941
|
var upperLimit = 268435456 - 65536;
|
|
8951
|
-
var parmTypeErrStr = "Parameter must be
|
|
8942
|
+
var parmTypeErrStr = "Parameter must be ArrayBuffer, ArrayBufferView or string";
|
|
8952
8943
|
var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes";
|
|
8953
8944
|
if (!wasm) {
|
|
8954
8945
|
console.log(
|
|
@@ -8967,20 +8958,9 @@ var __exports__ = (() => {
|
|
|
8967
8958
|
catchFun = fun;
|
|
8968
8959
|
return returnObj;
|
|
8969
8960
|
};
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
buff = data;
|
|
8974
|
-
} else {
|
|
8975
|
-
if (data.constructor === Uint8Array || data.constructor === ArrayBuffer) {
|
|
8976
|
-
buff = data.constructor === ArrayBuffer ? new Uint8Array(data) : data;
|
|
8977
|
-
} else {
|
|
8978
|
-
getCatch(new TypeError(parmTypeErrStr));
|
|
8979
|
-
}
|
|
8980
|
-
}
|
|
8981
|
-
} else {
|
|
8982
|
-
getCatch(new TypeError(parmTypeErrStr));
|
|
8983
|
-
}
|
|
8961
|
+
buff = normalizeInput(data);
|
|
8962
|
+
if (!buff) {
|
|
8963
|
+
getCatch(new TypeError(parmTypeErrStr));
|
|
8984
8964
|
}
|
|
8985
8965
|
if (buff) {
|
|
8986
8966
|
len = buff.length;
|
|
@@ -9296,21 +9276,62 @@ var __exports__ = (() => {
|
|
|
9296
9276
|
return result;
|
|
9297
9277
|
};
|
|
9298
9278
|
}
|
|
9299
|
-
function
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
buffView[i] = str.charCodeAt(i);
|
|
9306
|
-
}
|
|
9307
|
-
return buffView;
|
|
9279
|
+
function decodeBase64Safely(str) {
|
|
9280
|
+
try {
|
|
9281
|
+
return decodeBase64ToUint8Array(str);
|
|
9282
|
+
} catch (error) {
|
|
9283
|
+
return null;
|
|
9284
|
+
}
|
|
9308
9285
|
}
|
|
9309
|
-
function
|
|
9310
|
-
|
|
9286
|
+
function decodeBase64ToUint8Array(base64) {
|
|
9287
|
+
var sanitized = base64.replace(/-/g, "+").replace(/_/g, "/");
|
|
9288
|
+
if (typeof atob === "function") {
|
|
9289
|
+
return binaryStringToUint8Array(atob(sanitized));
|
|
9290
|
+
}
|
|
9291
|
+
return decodeBase64WithoutAtob(sanitized);
|
|
9311
9292
|
}
|
|
9312
|
-
function
|
|
9313
|
-
|
|
9293
|
+
function decodeBase64WithoutAtob(base64) {
|
|
9294
|
+
var paddingLength = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0, byteLength = base64.length * 3 / 4 - paddingLength, bytes = new Uint8Array(byteLength), byteIndex = 0, i = 0, enc1, enc2, enc3, enc4;
|
|
9295
|
+
while (i < base64.length) {
|
|
9296
|
+
enc1 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
|
|
9297
|
+
enc2 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
|
|
9298
|
+
enc3 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
|
|
9299
|
+
enc4 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
|
|
9300
|
+
if (enc1 < 0 || enc2 < 0 || enc3 < 0 || enc4 < 0) {
|
|
9301
|
+
throw new TypeError("Invalid base64 input");
|
|
9302
|
+
}
|
|
9303
|
+
bytes[byteIndex++] = enc1 << 2 | enc2 >> 4;
|
|
9304
|
+
if (enc3 < 64 && byteIndex < byteLength) {
|
|
9305
|
+
bytes[byteIndex++] = (enc2 & 15) << 4 | enc3 >> 2;
|
|
9306
|
+
}
|
|
9307
|
+
if (enc4 < 64 && byteIndex < byteLength) {
|
|
9308
|
+
bytes[byteIndex++] = (enc3 & 3) << 6 | enc4;
|
|
9309
|
+
}
|
|
9310
|
+
}
|
|
9311
|
+
return bytes;
|
|
9312
|
+
}
|
|
9313
|
+
function binaryStringToUint8Array(str) {
|
|
9314
|
+
var length = str.length, view = new Uint8Array(length), i = 0;
|
|
9315
|
+
while (i < length) {
|
|
9316
|
+
view[i] = str.charCodeAt(i);
|
|
9317
|
+
i++;
|
|
9318
|
+
}
|
|
9319
|
+
return view;
|
|
9320
|
+
}
|
|
9321
|
+
function normalizeInput(data) {
|
|
9322
|
+
if (data instanceof Uint8Array) {
|
|
9323
|
+
return data;
|
|
9324
|
+
}
|
|
9325
|
+
if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) {
|
|
9326
|
+
return new Uint8Array(data);
|
|
9327
|
+
}
|
|
9328
|
+
if (data && typeof data === "object" && ArrayBuffer.isView(data)) {
|
|
9329
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
9330
|
+
}
|
|
9331
|
+
if (typeof data === "string") {
|
|
9332
|
+
return new TextEncoder().encode(data);
|
|
9333
|
+
}
|
|
9334
|
+
return null;
|
|
9314
9335
|
}
|
|
9315
9336
|
function makeCrypt() {
|
|
9316
9337
|
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -9375,10 +9396,11 @@ var __exports__ = (() => {
|
|
|
9375
9396
|
async function cutTheTailOff(provider) {
|
|
9376
9397
|
const oldEoCDinfo = await parseEoCDRecord(provider);
|
|
9377
9398
|
const oldCDStartOffset = oldEoCDinfo.cdStartOffset;
|
|
9399
|
+
const providerSize = (await provider.stat()).bigsize;
|
|
9378
9400
|
const oldCDLength = Number(
|
|
9379
9401
|
oldEoCDinfo.offsets.zip64EoCDOffset ? oldEoCDinfo.offsets.zip64EoCDOffset - oldCDStartOffset : oldEoCDinfo.offsets.zipEoCDOffset - oldCDStartOffset
|
|
9380
9402
|
);
|
|
9381
|
-
const zipEnding = await provider
|
|
9403
|
+
const zipEnding = await readRange(provider, oldCDStartOffset, providerSize);
|
|
9382
9404
|
await provider.truncate(Number(oldCDStartOffset));
|
|
9383
9405
|
const oldCDBody = zipEnding.slice(0, oldCDLength);
|
|
9384
9406
|
const eocdBody = zipEnding.slice(oldCDLength, zipEnding.byteLength);
|
|
@@ -9403,24 +9425,27 @@ var __exports__ = (() => {
|
|
|
9403
9425
|
];
|
|
9404
9426
|
}
|
|
9405
9427
|
async function addOneFile(zipUrl, fileToAdd, fileName) {
|
|
9406
|
-
const provider = new
|
|
9428
|
+
const provider = new NodeFileFacade(zipUrl, "a+");
|
|
9407
9429
|
const [oldCDBody, eocdBody, oldEoCDinfo] = await cutTheTailOff(provider);
|
|
9408
|
-
|
|
9430
|
+
let currentOffset = (await provider.stat()).bigsize;
|
|
9431
|
+
const newFileOffset = currentOffset;
|
|
9409
9432
|
const [localPart, cdHeaderPart] = await generateFileHeaders(fileName, fileToAdd, newFileOffset);
|
|
9410
9433
|
await provider.append(localPart);
|
|
9434
|
+
currentOffset += BigInt(localPart.byteLength);
|
|
9411
9435
|
const newCDBody = concatenateArrayBuffers(oldCDBody, cdHeaderPart);
|
|
9412
|
-
const newCDStartOffset =
|
|
9436
|
+
const newCDStartOffset = currentOffset;
|
|
9413
9437
|
await provider.append(new Uint8Array(newCDBody));
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
)
|
|
9438
|
+
currentOffset += BigInt(newCDBody.byteLength);
|
|
9439
|
+
const eocdOffset = currentOffset;
|
|
9440
|
+
const updatedEoCD = updateEoCD(
|
|
9441
|
+
eocdBody,
|
|
9442
|
+
oldEoCDinfo.offsets,
|
|
9443
|
+
newCDStartOffset,
|
|
9444
|
+
eocdOffset,
|
|
9445
|
+
oldEoCDinfo.cdRecordsNumber + 1n
|
|
9423
9446
|
);
|
|
9447
|
+
await provider.append(updatedEoCD);
|
|
9448
|
+
currentOffset += BigInt(updatedEoCD.byteLength);
|
|
9424
9449
|
}
|
|
9425
9450
|
async function createZip(inputPath, outputPath, createAdditionalData) {
|
|
9426
9451
|
const fileIterator = getFileIterator(inputPath);
|
|
@@ -9449,7 +9474,7 @@ var __exports__ = (() => {
|
|
|
9449
9474
|
fileList?.push({ fileName: file.path, localHeaderOffset: size });
|
|
9450
9475
|
const [localPart, cdHeaderPart] = await generateFileHeaders(file.path, file.file, size);
|
|
9451
9476
|
await resFile.append(localPart);
|
|
9452
|
-
cdArray.push(cdHeaderPart);
|
|
9477
|
+
cdArray.push(toArrayBuffer2(cdHeaderPart));
|
|
9453
9478
|
}
|
|
9454
9479
|
function getFileIterator(inputPath) {
|
|
9455
9480
|
async function* iterable() {
|
|
@@ -9568,7 +9593,7 @@ var __exports__ = (() => {
|
|
|
9568
9593
|
const pakoOptions = this.options?.deflate || {};
|
|
9569
9594
|
const inputArray = new Uint8Array(input);
|
|
9570
9595
|
const deflate = this.options?.raw ? import_pako.default.deflateRaw : import_pako.default.deflate;
|
|
9571
|
-
return deflate(inputArray, pakoOptions).buffer;
|
|
9596
|
+
return toArrayBuffer2(deflate(inputArray, pakoOptions).buffer);
|
|
9572
9597
|
}
|
|
9573
9598
|
decompressSync(input) {
|
|
9574
9599
|
if (!isBrowser && this.options.deflate?.useZlib) {
|
|
@@ -9578,7 +9603,7 @@ var __exports__ = (() => {
|
|
|
9578
9603
|
const pakoOptions = this.options?.deflate || {};
|
|
9579
9604
|
const inputArray = new Uint8Array(input);
|
|
9580
9605
|
const inflate = this.options?.raw ? import_pako.default.inflateRaw : import_pako.default.inflate;
|
|
9581
|
-
return inflate(inputArray, pakoOptions).buffer;
|
|
9606
|
+
return toArrayBuffer2(inflate(inputArray, pakoOptions).buffer);
|
|
9582
9607
|
}
|
|
9583
9608
|
async *compressBatches(asyncIterator) {
|
|
9584
9609
|
const pakoOptions = this.options?.deflate || {};
|
|
@@ -9660,34 +9685,35 @@ var __exports__ = (() => {
|
|
|
9660
9685
|
}
|
|
9661
9686
|
};
|
|
9662
9687
|
var ZipFileSystem = class {
|
|
9663
|
-
/**
|
|
9664
|
-
|
|
9688
|
+
/** File instance */
|
|
9689
|
+
file = null;
|
|
9665
9690
|
fileName;
|
|
9666
9691
|
archive = null;
|
|
9667
9692
|
/**
|
|
9668
9693
|
* Constructor
|
|
9669
|
-
* @param file - instance of
|
|
9694
|
+
* @param file - instance of ReadableFile or file path string
|
|
9670
9695
|
*/
|
|
9671
9696
|
constructor(file) {
|
|
9672
9697
|
if (typeof file === "string") {
|
|
9673
9698
|
this.fileName = file;
|
|
9674
|
-
if (
|
|
9675
|
-
|
|
9676
|
-
} else {
|
|
9677
|
-
throw new Error("Cannot open file for random access in a WEB browser");
|
|
9699
|
+
if (isBrowser) {
|
|
9700
|
+
throw new Error("ZipFileSystem cannot open file paths in browser environments");
|
|
9678
9701
|
}
|
|
9702
|
+
this.file = new NodeFileFacade(file);
|
|
9703
|
+
} else if (file instanceof Blob || file instanceof ArrayBuffer) {
|
|
9704
|
+
this.file = new BlobFile(file);
|
|
9679
9705
|
} else if (file instanceof IndexedArchive) {
|
|
9680
|
-
this.
|
|
9706
|
+
this.file = file.file;
|
|
9681
9707
|
this.archive = file;
|
|
9682
9708
|
this.fileName = file.fileName;
|
|
9683
|
-
} else
|
|
9684
|
-
this.
|
|
9709
|
+
} else {
|
|
9710
|
+
this.file = file;
|
|
9685
9711
|
}
|
|
9686
9712
|
}
|
|
9687
9713
|
/** Clean up resources */
|
|
9688
9714
|
async destroy() {
|
|
9689
|
-
if (this.
|
|
9690
|
-
await this.
|
|
9715
|
+
if (this.file) {
|
|
9716
|
+
await this.file.close();
|
|
9691
9717
|
}
|
|
9692
9718
|
}
|
|
9693
9719
|
/**
|
|
@@ -9695,11 +9721,11 @@ var __exports__ = (() => {
|
|
|
9695
9721
|
* @returns array of file names
|
|
9696
9722
|
*/
|
|
9697
9723
|
async readdir() {
|
|
9698
|
-
if (!this.
|
|
9724
|
+
if (!this.file) {
|
|
9699
9725
|
throw new Error("No data detected in the zip archive");
|
|
9700
9726
|
}
|
|
9701
9727
|
const fileNames = [];
|
|
9702
|
-
const zipCDIterator = makeZipCDHeaderIterator(this.
|
|
9728
|
+
const zipCDIterator = makeZipCDHeaderIterator(this.file);
|
|
9703
9729
|
for await (const cdHeader of zipCDIterator) {
|
|
9704
9730
|
fileNames.push(cdHeader.fileName);
|
|
9705
9731
|
}
|
|
@@ -9727,13 +9753,13 @@ var __exports__ = (() => {
|
|
|
9727
9753
|
if (this.archive) {
|
|
9728
9754
|
uncompressedFile = await this.archive.getFile(filename2, "http");
|
|
9729
9755
|
} else {
|
|
9730
|
-
if (!this.
|
|
9756
|
+
if (!this.file) {
|
|
9731
9757
|
throw new Error("No data detected in the zip archive");
|
|
9732
9758
|
}
|
|
9733
9759
|
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
9734
9760
|
const localFileHeader = await parseZipLocalFileHeader(
|
|
9735
9761
|
cdFileHeader.localHeaderOffset,
|
|
9736
|
-
this.
|
|
9762
|
+
this.file
|
|
9737
9763
|
);
|
|
9738
9764
|
if (!localFileHeader) {
|
|
9739
9765
|
throw new Error("Local file header has not been found in the zip archive`");
|
|
@@ -9742,7 +9768,8 @@ var __exports__ = (() => {
|
|
|
9742
9768
|
if (!compressionHandler) {
|
|
9743
9769
|
throw Error("Only Deflation compression is supported");
|
|
9744
9770
|
}
|
|
9745
|
-
const compressedFile = await
|
|
9771
|
+
const compressedFile = await readRange(
|
|
9772
|
+
this.file,
|
|
9746
9773
|
localFileHeader.fileDataOffset,
|
|
9747
9774
|
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
9748
9775
|
);
|
|
@@ -9760,10 +9787,10 @@ var __exports__ = (() => {
|
|
|
9760
9787
|
* @returns central directory file header
|
|
9761
9788
|
*/
|
|
9762
9789
|
async getCDFileHeader(filename2) {
|
|
9763
|
-
if (!this.
|
|
9790
|
+
if (!this.file) {
|
|
9764
9791
|
throw new Error("No data detected in the zip archive");
|
|
9765
9792
|
}
|
|
9766
|
-
const zipCDIterator = makeZipCDHeaderIterator(this.
|
|
9793
|
+
const zipCDIterator = makeZipCDHeaderIterator(this.file);
|
|
9767
9794
|
let result = null;
|
|
9768
9795
|
for await (const cdHeader of zipCDIterator) {
|
|
9769
9796
|
if (cdHeader.fileName === filename2) {
|
|
@@ -9780,16 +9807,16 @@ var __exports__ = (() => {
|
|
|
9780
9807
|
|
|
9781
9808
|
// src/filesystems/IndexedArchive.ts
|
|
9782
9809
|
var IndexedArchive = class {
|
|
9783
|
-
|
|
9810
|
+
file;
|
|
9784
9811
|
fileName;
|
|
9785
9812
|
/**
|
|
9786
9813
|
* Constructor
|
|
9787
|
-
* @param fileProvider -
|
|
9814
|
+
* @param fileProvider - readable file instance for random access
|
|
9788
9815
|
* @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
|
|
9789
9816
|
* @param fileName - name of the archive. It is used to add to an URL of a loader context
|
|
9790
9817
|
*/
|
|
9791
|
-
constructor(
|
|
9792
|
-
this.
|
|
9818
|
+
constructor(file, hashTable, fileName) {
|
|
9819
|
+
this.file = file;
|
|
9793
9820
|
this.fileName = fileName;
|
|
9794
9821
|
}
|
|
9795
9822
|
/**
|
|
@@ -9798,7 +9825,7 @@ var __exports__ = (() => {
|
|
|
9798
9825
|
* @returns
|
|
9799
9826
|
*/
|
|
9800
9827
|
async getFileWithoutHash(filename2) {
|
|
9801
|
-
const zipFS = new ZipFileSystem(this.
|
|
9828
|
+
const zipFS = new ZipFileSystem(this.file);
|
|
9802
9829
|
const response = await zipFS.fetch(filename2);
|
|
9803
9830
|
return await response.arrayBuffer();
|
|
9804
9831
|
}
|