@loaders.gl/zip 4.2.0-alpha.4 → 4.2.0-alpha.6
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 +919 -523
- package/dist/dist.min.js +25 -0
- package/dist/filesystems/IndexedArchive.js +26 -12
- package/dist/filesystems/zip-filesystem.d.ts +2 -2
- package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
- package/dist/filesystems/zip-filesystem.js +125 -88
- package/dist/hash-file-utility.d.ts +1 -1
- package/dist/hash-file-utility.d.ts.map +1 -1
- package/dist/hash-file-utility.js +85 -42
- package/dist/index.cjs +64 -128
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/tar/header.d.ts +1 -1
- package/dist/lib/tar/header.d.ts.map +1 -1
- package/dist/lib/tar/header.js +69 -33
- package/dist/lib/tar/tar.d.ts +1 -1
- package/dist/lib/tar/tar.d.ts.map +1 -1
- package/dist/lib/tar/tar.js +124 -106
- package/dist/lib/tar/types.js +3 -1
- package/dist/lib/tar/utils.js +45 -18
- package/dist/parse-zip/cd-file-header.d.ts +1 -1
- package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
- package/dist/parse-zip/cd-file-header.js +239 -177
- package/dist/parse-zip/end-of-central-directory.js +247 -158
- package/dist/parse-zip/local-file-header.d.ts +1 -1
- package/dist/parse-zip/local-file-header.d.ts.map +1 -1
- package/dist/parse-zip/local-file-header.js +143 -102
- package/dist/parse-zip/search-from-the-end.js +27 -13
- package/dist/parse-zip/zip-composition.js +142 -92
- package/dist/parse-zip/zip64-info-generation.js +64 -41
- package/dist/tar-builder.d.ts +1 -1
- package/dist/tar-builder.d.ts.map +1 -1
- package/dist/tar-builder.js +32 -29
- package/dist/zip-loader.js +52 -41
- package/dist/zip-writer.js +40 -40
- package/package.json +11 -7
- package/src/filesystems/zip-filesystem.ts +4 -0
- package/dist/filesystems/IndexedArchive.js.map +0 -1
- package/dist/filesystems/zip-filesystem.js.map +0 -1
- package/dist/hash-file-utility.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/tar/header.js.map +0 -1
- package/dist/lib/tar/tar.js.map +0 -1
- package/dist/lib/tar/types.js.map +0 -1
- package/dist/lib/tar/utils.js.map +0 -1
- package/dist/parse-zip/cd-file-header.js.map +0 -1
- package/dist/parse-zip/end-of-central-directory.js.map +0 -1
- package/dist/parse-zip/local-file-header.js.map +0 -1
- package/dist/parse-zip/search-from-the-end.js.map +0 -1
- package/dist/parse-zip/zip-composition.js.map +0 -1
- package/dist/parse-zip/zip64-info-generation.js.map +0 -1
- package/dist/tar-builder.js.map +0 -1
- package/dist/zip-loader.js.map +0 -1
- package/dist/zip-writer.js.map +0 -1
package/dist/dist.dev.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
3
|
module.exports = factory();
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
-
else if (typeof exports === 'object') exports['
|
|
6
|
-
else root['
|
|
5
|
+
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
|
+
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
7
|
"use strict";
|
|
8
8
|
var __exports__ = (() => {
|
|
9
9
|
var __create = Object.create;
|
|
@@ -34,6 +34,7 @@ var __exports__ = (() => {
|
|
|
34
34
|
}
|
|
35
35
|
return to;
|
|
36
36
|
};
|
|
37
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
37
38
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
39
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
40
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -44,6 +45,13 @@ var __exports__ = (() => {
|
|
|
44
45
|
));
|
|
45
46
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
47
|
|
|
48
|
+
// external-global-plugin:@loaders.gl/core
|
|
49
|
+
var require_core = __commonJS({
|
|
50
|
+
"external-global-plugin:@loaders.gl/core"(exports, module) {
|
|
51
|
+
module.exports = globalThis.loaders;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
47
55
|
// ../../node_modules/jszip/dist/jszip.min.js
|
|
48
56
|
var require_jszip_min = __commonJS({
|
|
49
57
|
"../../node_modules/jszip/dist/jszip.min.js"(exports, module) {
|
|
@@ -6948,9 +6956,9 @@ var __exports__ = (() => {
|
|
|
6948
6956
|
}
|
|
6949
6957
|
});
|
|
6950
6958
|
|
|
6951
|
-
//
|
|
6952
|
-
var
|
|
6953
|
-
__export(
|
|
6959
|
+
// bundle.ts
|
|
6960
|
+
var bundle_exports = {};
|
|
6961
|
+
__export(bundle_exports, {
|
|
6954
6962
|
CD_HEADER_SIGNATURE: () => signature2,
|
|
6955
6963
|
IndexedArchive: () => IndexedArchive,
|
|
6956
6964
|
TarBuilder: () => TarBuilder,
|
|
@@ -6972,10 +6980,11 @@ var __exports__ = (() => {
|
|
|
6972
6980
|
parseZipLocalFileHeader: () => parseZipLocalFileHeader,
|
|
6973
6981
|
searchFromTheEnd: () => searchFromTheEnd
|
|
6974
6982
|
});
|
|
6983
|
+
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
6975
6984
|
|
|
6976
6985
|
// src/zip-loader.ts
|
|
6977
6986
|
var import_jszip = __toESM(require_jszip_min(), 1);
|
|
6978
|
-
var VERSION =
|
|
6987
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
6979
6988
|
var ZipLoader = {
|
|
6980
6989
|
id: "zip",
|
|
6981
6990
|
module: "zip",
|
|
@@ -7020,7 +7029,7 @@ var __exports__ = (() => {
|
|
|
7020
7029
|
|
|
7021
7030
|
// src/zip-writer.ts
|
|
7022
7031
|
var import_jszip2 = __toESM(require_jszip_min(), 1);
|
|
7023
|
-
var VERSION2 =
|
|
7032
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
7024
7033
|
var ZipWriter = {
|
|
7025
7034
|
name: "Zip Archive",
|
|
7026
7035
|
id: "zip",
|
|
@@ -7044,19 +7053,14 @@ var __exports__ = (() => {
|
|
|
7044
7053
|
const subFileData = fileMap[subFileName];
|
|
7045
7054
|
jsZip.file(subFileName, subFileData, options?.jszip || {});
|
|
7046
7055
|
}
|
|
7047
|
-
const zipOptions = {
|
|
7048
|
-
|
|
7049
|
-
...options?.zip
|
|
7050
|
-
};
|
|
7051
|
-
const jszipOptions = {
|
|
7052
|
-
...ZipWriter.options?.jszip,
|
|
7053
|
-
...options.jszip
|
|
7054
|
-
};
|
|
7056
|
+
const zipOptions = { ...ZipWriter.options.zip, ...options?.zip };
|
|
7057
|
+
const jszipOptions = { ...ZipWriter.options?.jszip, ...options.jszip };
|
|
7055
7058
|
try {
|
|
7056
|
-
return await jsZip.generateAsync(
|
|
7057
|
-
...jszipOptions,
|
|
7058
|
-
|
|
7059
|
-
|
|
7059
|
+
return await jsZip.generateAsync(
|
|
7060
|
+
{ ...jszipOptions, type: "arraybuffer" },
|
|
7061
|
+
// generate an arraybuffer
|
|
7062
|
+
zipOptions.onUpdate
|
|
7063
|
+
);
|
|
7060
7064
|
} catch (error) {
|
|
7061
7065
|
options.log.error(`Unable to encode zip archive: ${error}`);
|
|
7062
7066
|
throw error;
|
|
@@ -7132,7 +7136,13 @@ var __exports__ = (() => {
|
|
|
7132
7136
|
var inputLength;
|
|
7133
7137
|
var recordSize = 512;
|
|
7134
7138
|
var Tar = class {
|
|
7139
|
+
written;
|
|
7140
|
+
out;
|
|
7135
7141
|
blocks = [];
|
|
7142
|
+
length;
|
|
7143
|
+
/**
|
|
7144
|
+
* @param [recordsPerBlock]
|
|
7145
|
+
*/
|
|
7136
7146
|
constructor(recordsPerBlock) {
|
|
7137
7147
|
this.written = 0;
|
|
7138
7148
|
blockSize = (recordsPerBlock || 20) * recordSize;
|
|
@@ -7143,12 +7153,21 @@ var __exports__ = (() => {
|
|
|
7143
7153
|
this.clear = this.clear.bind(this);
|
|
7144
7154
|
this.append = this.append.bind(this);
|
|
7145
7155
|
}
|
|
7156
|
+
/**
|
|
7157
|
+
* Append a file to the tar archive
|
|
7158
|
+
* @param filepath
|
|
7159
|
+
* @param input
|
|
7160
|
+
* @param [opts]
|
|
7161
|
+
*/
|
|
7162
|
+
// eslint-disable-next-line complexity
|
|
7146
7163
|
append(filepath, input, opts) {
|
|
7147
7164
|
let checksum;
|
|
7148
7165
|
if (typeof input === "string") {
|
|
7149
7166
|
input = stringToUint8(input);
|
|
7150
7167
|
} else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) {
|
|
7151
|
-
const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(
|
|
7168
|
+
const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(
|
|
7169
|
+
input.constructor.toString()
|
|
7170
|
+
);
|
|
7152
7171
|
const errorInput = errorInputMatch && errorInputMatch[1];
|
|
7153
7172
|
const errorMessage = `Invalid input type. You gave me: ${errorInput}`;
|
|
7154
7173
|
throw errorMessage;
|
|
@@ -7166,6 +7185,7 @@ var __exports__ = (() => {
|
|
|
7166
7185
|
fileSize: pad(input.length, 11),
|
|
7167
7186
|
mtime: pad(mtime, 11),
|
|
7168
7187
|
checksum: " ",
|
|
7188
|
+
// 0 = just a file
|
|
7169
7189
|
type: "0",
|
|
7170
7190
|
ustar: "ustar ",
|
|
7171
7191
|
owner: opts.owner || "",
|
|
@@ -7191,6 +7211,10 @@ var __exports__ = (() => {
|
|
|
7191
7211
|
inputLength
|
|
7192
7212
|
});
|
|
7193
7213
|
}
|
|
7214
|
+
/**
|
|
7215
|
+
* Compiling data to a Blob object
|
|
7216
|
+
* @returns {Blob}
|
|
7217
|
+
*/
|
|
7194
7218
|
save() {
|
|
7195
7219
|
const buffers = [];
|
|
7196
7220
|
const chunks = new Array();
|
|
@@ -7199,20 +7223,14 @@ var __exports__ = (() => {
|
|
|
7199
7223
|
let chunk = new Array();
|
|
7200
7224
|
this.blocks.forEach((b = []) => {
|
|
7201
7225
|
if (length + b.headerLength + b.inputLength > max) {
|
|
7202
|
-
chunks.push({
|
|
7203
|
-
blocks: chunk,
|
|
7204
|
-
length
|
|
7205
|
-
});
|
|
7226
|
+
chunks.push({ blocks: chunk, length });
|
|
7206
7227
|
chunk = [];
|
|
7207
7228
|
length = 0;
|
|
7208
7229
|
}
|
|
7209
7230
|
chunk.push(b);
|
|
7210
7231
|
length += b.headerLength + b.inputLength;
|
|
7211
7232
|
});
|
|
7212
|
-
chunks.push({
|
|
7213
|
-
blocks: chunk,
|
|
7214
|
-
length
|
|
7215
|
-
});
|
|
7233
|
+
chunks.push({ blocks: chunk, length });
|
|
7216
7234
|
chunks.forEach((c = []) => {
|
|
7217
7235
|
const buffer = new Uint8Array(c.length);
|
|
7218
7236
|
let written = 0;
|
|
@@ -7225,10 +7243,11 @@ var __exports__ = (() => {
|
|
|
7225
7243
|
buffers.push(buffer);
|
|
7226
7244
|
});
|
|
7227
7245
|
buffers.push(new Uint8Array(2 * recordSize));
|
|
7228
|
-
return new Blob(buffers, {
|
|
7229
|
-
type: "octet/stream"
|
|
7230
|
-
});
|
|
7246
|
+
return new Blob(buffers, { type: "octet/stream" });
|
|
7231
7247
|
}
|
|
7248
|
+
/**
|
|
7249
|
+
* Clear the data by its blocksize
|
|
7250
|
+
*/
|
|
7232
7251
|
clear() {
|
|
7233
7252
|
this.written = 0;
|
|
7234
7253
|
this.out = clean(blockSize);
|
|
@@ -7251,14 +7270,14 @@ var __exports__ = (() => {
|
|
|
7251
7270
|
options: TAR_BUILDER_OPTIONS
|
|
7252
7271
|
};
|
|
7253
7272
|
}
|
|
7273
|
+
options;
|
|
7274
|
+
tape;
|
|
7254
7275
|
count = 0;
|
|
7255
7276
|
constructor(options) {
|
|
7256
|
-
this.options = {
|
|
7257
|
-
...TAR_BUILDER_OPTIONS,
|
|
7258
|
-
...options
|
|
7259
|
-
};
|
|
7277
|
+
this.options = { ...TAR_BUILDER_OPTIONS, ...options };
|
|
7260
7278
|
this.tape = new tar_default(this.options.recordsPerBlock);
|
|
7261
7279
|
}
|
|
7280
|
+
/** Adds a file to the archive. */
|
|
7262
7281
|
addFile(filename2, buffer) {
|
|
7263
7282
|
this.tape.append(filename2, new Uint8Array(buffer));
|
|
7264
7283
|
this.count++;
|
|
@@ -7279,7 +7298,10 @@ var __exports__ = (() => {
|
|
|
7279
7298
|
var window_ = globals.window || globals.self || globals.global || {};
|
|
7280
7299
|
var global_ = globals.global || globals.self || globals.window || {};
|
|
7281
7300
|
var document_ = globals.document || {};
|
|
7282
|
-
var isBrowser =
|
|
7301
|
+
var isBrowser = (
|
|
7302
|
+
// @ts-ignore process does not exist on browser
|
|
7303
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
7304
|
+
);
|
|
7283
7305
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
7284
7306
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
7285
7307
|
|
|
@@ -7302,7 +7324,9 @@ var __exports__ = (() => {
|
|
|
7302
7324
|
return concatenateArrayBuffersFromArray(sources);
|
|
7303
7325
|
}
|
|
7304
7326
|
function concatenateArrayBuffersFromArray(sources) {
|
|
7305
|
-
const sourceArrays = sources.map(
|
|
7327
|
+
const sourceArrays = sources.map(
|
|
7328
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
7329
|
+
);
|
|
7306
7330
|
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
7307
7331
|
const result = new Uint8Array(byteLength);
|
|
7308
7332
|
let offset = 0;
|
|
@@ -7322,22 +7346,6 @@ var __exports__ = (() => {
|
|
|
7322
7346
|
return concatenateArrayBuffers(...arrayBuffers);
|
|
7323
7347
|
}
|
|
7324
7348
|
|
|
7325
|
-
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
7326
|
-
var pathPrefix = "";
|
|
7327
|
-
var fileAliases = {};
|
|
7328
|
-
function resolvePath(filename2) {
|
|
7329
|
-
for (const alias in fileAliases) {
|
|
7330
|
-
if (filename2.startsWith(alias)) {
|
|
7331
|
-
const replacement = fileAliases[alias];
|
|
7332
|
-
filename2 = filename2.replace(alias, replacement);
|
|
7333
|
-
}
|
|
7334
|
-
}
|
|
7335
|
-
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
7336
|
-
filename2 = `${pathPrefix}${filename2}`;
|
|
7337
|
-
}
|
|
7338
|
-
return filename2;
|
|
7339
|
-
}
|
|
7340
|
-
|
|
7341
7349
|
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
7342
7350
|
function toArrayBuffer(buffer) {
|
|
7343
7351
|
return buffer;
|
|
@@ -7373,7 +7381,9 @@ var __exports__ = (() => {
|
|
|
7373
7381
|
|
|
7374
7382
|
// ../loader-utils/src/lib/node/promisify.ts
|
|
7375
7383
|
function promisify1(fn) {
|
|
7376
|
-
return (args) => new Promise(
|
|
7384
|
+
return (args) => new Promise(
|
|
7385
|
+
(resolve2, reject) => fn(args, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs))
|
|
7386
|
+
);
|
|
7377
7387
|
}
|
|
7378
7388
|
|
|
7379
7389
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
@@ -7522,6 +7532,7 @@ var __exports__ = (() => {
|
|
|
7522
7532
|
// ../loader-utils/src/lib/files/node-file-facade.ts
|
|
7523
7533
|
var NOT_IMPLEMENTED = new Error("Not implemented");
|
|
7524
7534
|
var NodeFileFacade = class {
|
|
7535
|
+
handle;
|
|
7525
7536
|
size = 0;
|
|
7526
7537
|
bigsize = 0n;
|
|
7527
7538
|
url = "";
|
|
@@ -7534,21 +7545,27 @@ var __exports__ = (() => {
|
|
|
7534
7545
|
}
|
|
7535
7546
|
throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
|
|
7536
7547
|
}
|
|
7548
|
+
/** Read data */
|
|
7537
7549
|
async read(start, end) {
|
|
7538
7550
|
throw NOT_IMPLEMENTED;
|
|
7539
7551
|
}
|
|
7552
|
+
/** Write to file. The number of bytes written will be returned */
|
|
7540
7553
|
async write(arrayBuffer, offset, length) {
|
|
7541
7554
|
throw NOT_IMPLEMENTED;
|
|
7542
7555
|
}
|
|
7556
|
+
/** Get information about file */
|
|
7543
7557
|
async stat() {
|
|
7544
7558
|
throw NOT_IMPLEMENTED;
|
|
7545
7559
|
}
|
|
7560
|
+
/** Truncates the file descriptor. Only available on NodeFile. */
|
|
7546
7561
|
async truncate(length) {
|
|
7547
7562
|
throw NOT_IMPLEMENTED;
|
|
7548
7563
|
}
|
|
7564
|
+
/** Append data to a file. Only available on NodeFile. */
|
|
7549
7565
|
async append(data) {
|
|
7550
7566
|
throw NOT_IMPLEMENTED;
|
|
7551
7567
|
}
|
|
7568
|
+
/** Close the file */
|
|
7552
7569
|
async close() {
|
|
7553
7570
|
}
|
|
7554
7571
|
};
|
|
@@ -7556,6 +7573,7 @@ var __exports__ = (() => {
|
|
|
7556
7573
|
// ../loader-utils/src/lib/filesystems/node-filesystem-facade.ts
|
|
7557
7574
|
var NOT_IMPLEMENTED2 = new Error("Not implemented");
|
|
7558
7575
|
var NodeFileSystemFacade = class {
|
|
7576
|
+
// implements FileSystem
|
|
7559
7577
|
constructor(options) {
|
|
7560
7578
|
if (globalThis.loaders?.NodeFileSystem) {
|
|
7561
7579
|
return new globalThis.loaders.NodeFileSystem(options);
|
|
@@ -7563,16 +7581,22 @@ var __exports__ = (() => {
|
|
|
7563
7581
|
if (isBrowser) {
|
|
7564
7582
|
throw new Error("Can't instantiate NodeFileSystem in browser.");
|
|
7565
7583
|
}
|
|
7566
|
-
throw new Error(
|
|
7584
|
+
throw new Error(
|
|
7585
|
+
"Can't instantiate NodeFileSystem. Make sure to import @loaders.gl/polyfills first."
|
|
7586
|
+
);
|
|
7567
7587
|
}
|
|
7588
|
+
// DUMMY IMPLEMENTATION, not used (constructor returns a real NodeFileSystem instance)
|
|
7589
|
+
// implements RandomAccessReadFileSystem
|
|
7568
7590
|
readable = true;
|
|
7569
7591
|
writable = true;
|
|
7570
7592
|
async openReadableFile(path, flags) {
|
|
7571
7593
|
throw NOT_IMPLEMENTED2;
|
|
7572
7594
|
}
|
|
7595
|
+
// implements RandomAccessWriteFileSystem
|
|
7573
7596
|
async openWritableFile(path, flags, mode) {
|
|
7574
7597
|
throw NOT_IMPLEMENTED2;
|
|
7575
7598
|
}
|
|
7599
|
+
// Implements file system
|
|
7576
7600
|
async readdir(dirname2 = ".", options) {
|
|
7577
7601
|
throw NOT_IMPLEMENTED2;
|
|
7578
7602
|
}
|
|
@@ -7594,18 +7618,34 @@ var __exports__ = (() => {
|
|
|
7594
7618
|
|
|
7595
7619
|
// ../loader-utils/src/lib/file-provider/file-handle-file.ts
|
|
7596
7620
|
var FileHandleFile = class {
|
|
7621
|
+
/** The FileHandle from which data is provided */
|
|
7622
|
+
file;
|
|
7623
|
+
/** Create a new FileHandleFile */
|
|
7597
7624
|
constructor(path, append = false) {
|
|
7598
7625
|
this.file = new NodeFileFacade(path, append ? "a+" : "r");
|
|
7599
7626
|
}
|
|
7627
|
+
/**
|
|
7628
|
+
* Truncates the file descriptor.
|
|
7629
|
+
* @param length desired file lenght
|
|
7630
|
+
*/
|
|
7600
7631
|
async truncate(length) {
|
|
7601
7632
|
await this.file.truncate(length);
|
|
7602
7633
|
}
|
|
7634
|
+
/**
|
|
7635
|
+
* Append data to a file.
|
|
7636
|
+
* @param buffer data to append
|
|
7637
|
+
*/
|
|
7603
7638
|
async append(buffer) {
|
|
7604
7639
|
await this.file.append(buffer);
|
|
7605
7640
|
}
|
|
7641
|
+
/** Close file */
|
|
7606
7642
|
async destroy() {
|
|
7607
7643
|
await this.file.close();
|
|
7608
7644
|
}
|
|
7645
|
+
/**
|
|
7646
|
+
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
7647
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7648
|
+
*/
|
|
7609
7649
|
async getUint8(offset) {
|
|
7610
7650
|
const arrayBuffer = await this.file.read(offset, 1);
|
|
7611
7651
|
const val = new Uint8Array(arrayBuffer).at(0);
|
|
@@ -7614,6 +7654,10 @@ var __exports__ = (() => {
|
|
|
7614
7654
|
}
|
|
7615
7655
|
return val;
|
|
7616
7656
|
}
|
|
7657
|
+
/**
|
|
7658
|
+
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
7659
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7660
|
+
*/
|
|
7617
7661
|
async getUint16(offset) {
|
|
7618
7662
|
const arrayBuffer = await this.file.read(offset, 2);
|
|
7619
7663
|
const val = new Uint16Array(arrayBuffer).at(0);
|
|
@@ -7622,6 +7666,10 @@ var __exports__ = (() => {
|
|
|
7622
7666
|
}
|
|
7623
7667
|
return val;
|
|
7624
7668
|
}
|
|
7669
|
+
/**
|
|
7670
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
7671
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7672
|
+
*/
|
|
7625
7673
|
async getUint32(offset) {
|
|
7626
7674
|
const arrayBuffer = await this.file.read(offset, 4);
|
|
7627
7675
|
const val = new Uint32Array(arrayBuffer).at(0);
|
|
@@ -7630,6 +7678,10 @@ var __exports__ = (() => {
|
|
|
7630
7678
|
}
|
|
7631
7679
|
return val;
|
|
7632
7680
|
}
|
|
7681
|
+
/**
|
|
7682
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
7683
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7684
|
+
*/
|
|
7633
7685
|
async getBigUint64(offset) {
|
|
7634
7686
|
const arrayBuffer = await this.file.read(offset, 8);
|
|
7635
7687
|
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
@@ -7638,6 +7690,11 @@ var __exports__ = (() => {
|
|
|
7638
7690
|
}
|
|
7639
7691
|
return val;
|
|
7640
7692
|
}
|
|
7693
|
+
/**
|
|
7694
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
7695
|
+
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
7696
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
7697
|
+
*/
|
|
7641
7698
|
async slice(startOffset, endOffset) {
|
|
7642
7699
|
const bigLength = endOffset - startOffset;
|
|
7643
7700
|
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
@@ -7646,6 +7703,9 @@ var __exports__ = (() => {
|
|
|
7646
7703
|
const length = Number(bigLength);
|
|
7647
7704
|
return await this.file.read(startOffset, length);
|
|
7648
7705
|
}
|
|
7706
|
+
/**
|
|
7707
|
+
* the length (in bytes) of the data.
|
|
7708
|
+
*/
|
|
7649
7709
|
get length() {
|
|
7650
7710
|
return this.file.bigsize;
|
|
7651
7711
|
}
|
|
@@ -7653,7 +7713,12 @@ var __exports__ = (() => {
|
|
|
7653
7713
|
|
|
7654
7714
|
// src/parse-zip/search-from-the-end.ts
|
|
7655
7715
|
var searchFromTheEnd = async (file, target) => {
|
|
7656
|
-
const searchWindow = [
|
|
7716
|
+
const searchWindow = [
|
|
7717
|
+
await file.getUint8(file.length - 1n),
|
|
7718
|
+
await file.getUint8(file.length - 2n),
|
|
7719
|
+
await file.getUint8(file.length - 3n),
|
|
7720
|
+
void 0
|
|
7721
|
+
];
|
|
7657
7722
|
let targetOffset = 0n;
|
|
7658
7723
|
for (let i = file.length - 4n; i > -1; i--) {
|
|
7659
7724
|
searchWindow[3] = searchWindow[2];
|
|
@@ -7700,22 +7765,33 @@ var __exports__ = (() => {
|
|
|
7700
7765
|
header.setBigUint64(offset, BigInt(value), true);
|
|
7701
7766
|
}
|
|
7702
7767
|
};
|
|
7703
|
-
var ZIP64_FIELDS = [
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7768
|
+
var ZIP64_FIELDS = [
|
|
7769
|
+
// Header ID 0x0001
|
|
7770
|
+
{
|
|
7771
|
+
size: 2,
|
|
7772
|
+
default: new DataView(signature.buffer).getUint16(0, true)
|
|
7773
|
+
},
|
|
7774
|
+
// Size of the extra field chunk (8, 16, 24 or 28)
|
|
7775
|
+
{
|
|
7776
|
+
size: 2,
|
|
7777
|
+
name: "zip64Length"
|
|
7778
|
+
},
|
|
7779
|
+
// Original uncompressed file size
|
|
7780
|
+
{
|
|
7781
|
+
size: 8,
|
|
7782
|
+
name: "size"
|
|
7783
|
+
},
|
|
7784
|
+
// Size of compressed data
|
|
7785
|
+
{
|
|
7786
|
+
size: 8,
|
|
7787
|
+
name: "size"
|
|
7788
|
+
},
|
|
7789
|
+
// Offset of local header record
|
|
7790
|
+
{
|
|
7791
|
+
size: 8,
|
|
7792
|
+
name: "offset"
|
|
7793
|
+
}
|
|
7794
|
+
];
|
|
7719
7795
|
|
|
7720
7796
|
// src/parse-zip/end-of-central-directory.ts
|
|
7721
7797
|
var eoCDSignature = new Uint8Array([80, 75, 5, 6]);
|
|
@@ -7740,7 +7816,9 @@ var __exports__ = (() => {
|
|
|
7740
7816
|
let zip64EoCDOffset = 0n;
|
|
7741
7817
|
const magicBytes = await file.slice(zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
|
|
7742
7818
|
if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature)) {
|
|
7743
|
-
zip64EoCDOffset = await file.getBigUint64(
|
|
7819
|
+
zip64EoCDOffset = await file.getBigUint64(
|
|
7820
|
+
zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
|
|
7821
|
+
);
|
|
7744
7822
|
const endOfCDMagicBytes = await file.slice(zip64EoCDOffset, zip64EoCDOffset + 4n);
|
|
7745
7823
|
if (!compareArrayBuffers(endOfCDMagicBytes, zip64EoCDSignature.buffer)) {
|
|
7746
7824
|
throw new Error("zip64 EoCD not found");
|
|
@@ -7765,10 +7843,20 @@ var __exports__ = (() => {
|
|
|
7765
7843
|
const classicEoCDOffset = oldEoCDOffsets.zip64EoCDOffset ? oldEoCDOffsets.zipEoCDOffset - oldEoCDOffsets.zip64EoCDOffset : 0n;
|
|
7766
7844
|
if (Number(newCDRecordsNumber) <= 65535) {
|
|
7767
7845
|
setFieldToNumber(eocd, 2, classicEoCDOffset + CD_RECORDS_NUMBER_OFFSET, newCDRecordsNumber);
|
|
7768
|
-
setFieldToNumber(
|
|
7846
|
+
setFieldToNumber(
|
|
7847
|
+
eocd,
|
|
7848
|
+
2,
|
|
7849
|
+
classicEoCDOffset + CD_RECORDS_NUMBER_ON_DISC_OFFSET,
|
|
7850
|
+
newCDRecordsNumber
|
|
7851
|
+
);
|
|
7769
7852
|
}
|
|
7770
7853
|
if (eocdStartOffset - newCDStartOffset <= 4294967295) {
|
|
7771
|
-
setFieldToNumber(
|
|
7854
|
+
setFieldToNumber(
|
|
7855
|
+
eocd,
|
|
7856
|
+
4,
|
|
7857
|
+
classicEoCDOffset + CD_CD_BYTE_SIZE_OFFSET,
|
|
7858
|
+
eocdStartOffset - newCDStartOffset
|
|
7859
|
+
);
|
|
7772
7860
|
}
|
|
7773
7861
|
if (newCDStartOffset < 4294967295) {
|
|
7774
7862
|
setFieldToNumber(eocd, 4, classicEoCDOffset + CD_START_OFFSET_OFFSET, newCDStartOffset);
|
|
@@ -7786,117 +7874,179 @@ var __exports__ = (() => {
|
|
|
7786
7874
|
function generateEoCD(options) {
|
|
7787
7875
|
const header = new DataView(new ArrayBuffer(Number(CD_COMMENT_OFFSET)));
|
|
7788
7876
|
for (const field of EOCD_FIELDS) {
|
|
7789
|
-
setFieldToNumber(
|
|
7877
|
+
setFieldToNumber(
|
|
7878
|
+
header,
|
|
7879
|
+
field.size,
|
|
7880
|
+
field.offset,
|
|
7881
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7882
|
+
);
|
|
7790
7883
|
}
|
|
7791
7884
|
const locator = generateZip64InfoLocator(options);
|
|
7792
7885
|
const zip64Record = generateZip64Info(options);
|
|
7793
7886
|
return concatenateArrayBuffers(zip64Record, locator, header.buffer);
|
|
7794
7887
|
}
|
|
7795
|
-
var EOCD_FIELDS = [
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7888
|
+
var EOCD_FIELDS = [
|
|
7889
|
+
// End of central directory signature = 0x06054b50
|
|
7890
|
+
{
|
|
7891
|
+
offset: 0,
|
|
7892
|
+
size: 4,
|
|
7893
|
+
default: new DataView(eoCDSignature.buffer).getUint32(0, true)
|
|
7894
|
+
},
|
|
7895
|
+
// Number of this disk (or 0xffff for ZIP64)
|
|
7896
|
+
{
|
|
7897
|
+
offset: 4,
|
|
7898
|
+
size: 2,
|
|
7899
|
+
default: 0
|
|
7900
|
+
},
|
|
7901
|
+
// Disk where central directory starts (or 0xffff for ZIP64)
|
|
7902
|
+
{
|
|
7903
|
+
offset: 6,
|
|
7904
|
+
size: 2,
|
|
7905
|
+
default: 0
|
|
7906
|
+
},
|
|
7907
|
+
// Number of central directory records on this disk (or 0xffff for ZIP64)
|
|
7908
|
+
{
|
|
7909
|
+
offset: 8,
|
|
7910
|
+
size: 2,
|
|
7911
|
+
name: "recordsNumber"
|
|
7912
|
+
},
|
|
7913
|
+
// Total number of central directory records (or 0xffff for ZIP64)
|
|
7914
|
+
{
|
|
7915
|
+
offset: 10,
|
|
7916
|
+
size: 2,
|
|
7917
|
+
name: "recordsNumber"
|
|
7918
|
+
},
|
|
7919
|
+
// Size of central directory (bytes) (or 0xffffffff for ZIP64)
|
|
7920
|
+
{
|
|
7921
|
+
offset: 12,
|
|
7922
|
+
size: 4,
|
|
7923
|
+
name: "cdSize"
|
|
7924
|
+
},
|
|
7925
|
+
// Offset of start of central directory, relative to start of archive (or 0xffffffff for ZIP64)
|
|
7926
|
+
{
|
|
7927
|
+
offset: 16,
|
|
7928
|
+
size: 4,
|
|
7929
|
+
name: "cdOffset"
|
|
7930
|
+
},
|
|
7931
|
+
// Comment length (n)
|
|
7932
|
+
{
|
|
7933
|
+
offset: 20,
|
|
7934
|
+
size: 2,
|
|
7935
|
+
default: 0
|
|
7936
|
+
}
|
|
7937
|
+
];
|
|
7828
7938
|
function generateZip64Info(options) {
|
|
7829
7939
|
const record = new DataView(new ArrayBuffer(Number(ZIP64_COMMENT_OFFSET)));
|
|
7830
7940
|
for (const field of ZIP64_EOCD_FIELDS) {
|
|
7831
|
-
setFieldToNumber(
|
|
7941
|
+
setFieldToNumber(
|
|
7942
|
+
record,
|
|
7943
|
+
field.size,
|
|
7944
|
+
field.offset,
|
|
7945
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7946
|
+
);
|
|
7832
7947
|
}
|
|
7833
7948
|
return record.buffer;
|
|
7834
7949
|
}
|
|
7835
7950
|
function generateZip64InfoLocator(options) {
|
|
7836
7951
|
const locator = new DataView(new ArrayBuffer(Number(20)));
|
|
7837
7952
|
for (const field of ZIP64_EOCD_LOCATOR_FIELDS) {
|
|
7838
|
-
setFieldToNumber(
|
|
7953
|
+
setFieldToNumber(
|
|
7954
|
+
locator,
|
|
7955
|
+
field.size,
|
|
7956
|
+
field.offset,
|
|
7957
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7958
|
+
);
|
|
7839
7959
|
}
|
|
7840
7960
|
return locator.buffer;
|
|
7841
7961
|
}
|
|
7842
|
-
var ZIP64_EOCD_LOCATOR_FIELDS = [
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7962
|
+
var ZIP64_EOCD_LOCATOR_FIELDS = [
|
|
7963
|
+
// zip64 end of central dir locator signature
|
|
7964
|
+
{
|
|
7965
|
+
offset: 0,
|
|
7966
|
+
size: 4,
|
|
7967
|
+
default: new DataView(zip64EoCDLocatorSignature.buffer).getUint32(0, true)
|
|
7968
|
+
},
|
|
7969
|
+
// number of the disk with the start of the zip64 end of
|
|
7970
|
+
{
|
|
7971
|
+
offset: 4,
|
|
7972
|
+
size: 4,
|
|
7973
|
+
default: 0
|
|
7974
|
+
},
|
|
7975
|
+
// start of the zip64 end of central directory
|
|
7976
|
+
{
|
|
7977
|
+
offset: 8,
|
|
7978
|
+
size: 8,
|
|
7979
|
+
name: "eoCDStart"
|
|
7980
|
+
},
|
|
7981
|
+
// total number of disks
|
|
7982
|
+
{
|
|
7983
|
+
offset: 16,
|
|
7984
|
+
size: 4,
|
|
7985
|
+
default: 1
|
|
7986
|
+
}
|
|
7987
|
+
];
|
|
7988
|
+
var ZIP64_EOCD_FIELDS = [
|
|
7989
|
+
// End of central directory signature = 0x06064b50
|
|
7990
|
+
{
|
|
7991
|
+
offset: 0,
|
|
7992
|
+
size: 4,
|
|
7993
|
+
default: new DataView(zip64EoCDSignature.buffer).getUint32(0, true)
|
|
7994
|
+
},
|
|
7995
|
+
// Size of the EOCD64 minus 12
|
|
7996
|
+
{
|
|
7997
|
+
offset: 4,
|
|
7998
|
+
size: 8,
|
|
7999
|
+
default: 44
|
|
8000
|
+
},
|
|
8001
|
+
// Version made by
|
|
8002
|
+
{
|
|
8003
|
+
offset: 12,
|
|
8004
|
+
size: 2,
|
|
8005
|
+
default: 45
|
|
8006
|
+
},
|
|
8007
|
+
// Version needed to extract (minimum)
|
|
8008
|
+
{
|
|
8009
|
+
offset: 14,
|
|
8010
|
+
size: 2,
|
|
8011
|
+
default: 45
|
|
8012
|
+
},
|
|
8013
|
+
// Number of this disk
|
|
8014
|
+
{
|
|
8015
|
+
offset: 16,
|
|
8016
|
+
size: 4,
|
|
8017
|
+
default: 0
|
|
8018
|
+
},
|
|
8019
|
+
// Disk where central directory starts
|
|
8020
|
+
{
|
|
8021
|
+
offset: 20,
|
|
8022
|
+
size: 4,
|
|
8023
|
+
default: 0
|
|
8024
|
+
},
|
|
8025
|
+
// Number of central directory records on this disk
|
|
8026
|
+
{
|
|
8027
|
+
offset: 24,
|
|
8028
|
+
size: 8,
|
|
8029
|
+
name: "recordsNumber"
|
|
8030
|
+
},
|
|
8031
|
+
// Total number of central directory records
|
|
8032
|
+
{
|
|
8033
|
+
offset: 32,
|
|
8034
|
+
size: 8,
|
|
8035
|
+
name: "recordsNumber"
|
|
8036
|
+
},
|
|
8037
|
+
// Size of central directory (bytes)
|
|
8038
|
+
{
|
|
8039
|
+
offset: 40,
|
|
8040
|
+
size: 8,
|
|
8041
|
+
name: "cdSize"
|
|
8042
|
+
},
|
|
8043
|
+
// Offset of start of central directory, relative to start of archive
|
|
8044
|
+
{
|
|
8045
|
+
offset: 48,
|
|
8046
|
+
size: 8,
|
|
8047
|
+
name: "cdOffset"
|
|
8048
|
+
}
|
|
8049
|
+
];
|
|
7900
8050
|
|
|
7901
8051
|
// src/parse-zip/cd-file-header.ts
|
|
7902
8052
|
var CD_COMPRESSED_SIZE_OFFSET = 20n;
|
|
@@ -7917,12 +8067,17 @@ var __exports__ = (() => {
|
|
|
7917
8067
|
const extraFieldLength = await file.getUint16(headerOffset + CD_EXTRA_FIELD_LENGTH_OFFSET);
|
|
7918
8068
|
const startDisk = BigInt(await file.getUint16(headerOffset + CD_START_DISK_OFFSET));
|
|
7919
8069
|
const fileNameLength = await file.getUint16(headerOffset + CD_FILE_NAME_LENGTH_OFFSET);
|
|
7920
|
-
const filenameBytes = await file.slice(
|
|
8070
|
+
const filenameBytes = await file.slice(
|
|
8071
|
+
headerOffset + CD_FILE_NAME_OFFSET,
|
|
8072
|
+
headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength)
|
|
8073
|
+
);
|
|
7921
8074
|
const fileName = new TextDecoder().decode(filenameBytes);
|
|
7922
8075
|
const extraOffset = headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
|
|
7923
8076
|
const oldFormatOffset = await file.getUint32(headerOffset + CD_LOCAL_HEADER_OFFSET_OFFSET);
|
|
7924
8077
|
const localHeaderOffset = BigInt(oldFormatOffset);
|
|
7925
|
-
const extraField = new DataView(
|
|
8078
|
+
const extraField = new DataView(
|
|
8079
|
+
await file.slice(extraOffset, extraOffset + BigInt(extraFieldLength))
|
|
8080
|
+
);
|
|
7926
8081
|
const zip64data = {
|
|
7927
8082
|
uncompressedSize,
|
|
7928
8083
|
compressedSize,
|
|
@@ -7940,13 +8095,14 @@ var __exports__ = (() => {
|
|
|
7940
8095
|
};
|
|
7941
8096
|
};
|
|
7942
8097
|
async function* makeZipCDHeaderIterator(fileProvider) {
|
|
7943
|
-
const {
|
|
7944
|
-
cdStartOffset
|
|
7945
|
-
} = await parseEoCDRecord(fileProvider);
|
|
8098
|
+
const { cdStartOffset } = await parseEoCDRecord(fileProvider);
|
|
7946
8099
|
let cdHeader = await parseZipCDFileHeader(cdStartOffset, fileProvider);
|
|
7947
8100
|
while (cdHeader) {
|
|
7948
8101
|
yield cdHeader;
|
|
7949
|
-
cdHeader = await parseZipCDFileHeader(
|
|
8102
|
+
cdHeader = await parseZipCDFileHeader(
|
|
8103
|
+
cdHeader.extraOffset + BigInt(cdHeader.extraFieldLength),
|
|
8104
|
+
fileProvider
|
|
8105
|
+
);
|
|
7950
8106
|
}
|
|
7951
8107
|
}
|
|
7952
8108
|
var getUint16 = (...bytes) => {
|
|
@@ -7957,7 +8113,9 @@ var __exports__ = (() => {
|
|
|
7957
8113
|
const zip64DataRes = {};
|
|
7958
8114
|
if (zip64dataList.length > 0) {
|
|
7959
8115
|
const zip64chunkSize = zip64dataList.reduce((sum, curr) => sum + curr.length, 0);
|
|
7960
|
-
const offsetInExtraData = new Uint8Array(extraField.buffer).findIndex(
|
|
8116
|
+
const offsetInExtraData = new Uint8Array(extraField.buffer).findIndex(
|
|
8117
|
+
(_val, i, arr) => getUint16(arr[i], arr[i + 1]) === 1 && getUint16(arr[i + 2], arr[i + 3]) === zip64chunkSize
|
|
8118
|
+
);
|
|
7961
8119
|
let bytesRead = 0;
|
|
7962
8120
|
for (const note of zip64dataList) {
|
|
7963
8121
|
const offset = bytesRead;
|
|
@@ -7970,28 +8128,16 @@ var __exports__ = (() => {
|
|
|
7970
8128
|
var findExpectedData = (zip64data) => {
|
|
7971
8129
|
const zip64dataList = [];
|
|
7972
8130
|
if (zip64data.uncompressedSize === BigInt(4294967295)) {
|
|
7973
|
-
zip64dataList.push({
|
|
7974
|
-
name: "uncompressedSize",
|
|
7975
|
-
length: 8
|
|
7976
|
-
});
|
|
8131
|
+
zip64dataList.push({ name: "uncompressedSize", length: 8 });
|
|
7977
8132
|
}
|
|
7978
8133
|
if (zip64data.compressedSize === BigInt(4294967295)) {
|
|
7979
|
-
zip64dataList.push({
|
|
7980
|
-
name: "compressedSize",
|
|
7981
|
-
length: 8
|
|
7982
|
-
});
|
|
8134
|
+
zip64dataList.push({ name: "compressedSize", length: 8 });
|
|
7983
8135
|
}
|
|
7984
8136
|
if (zip64data.localHeaderOffset === BigInt(4294967295)) {
|
|
7985
|
-
zip64dataList.push({
|
|
7986
|
-
name: "localHeaderOffset",
|
|
7987
|
-
length: 8
|
|
7988
|
-
});
|
|
8137
|
+
zip64dataList.push({ name: "localHeaderOffset", length: 8 });
|
|
7989
8138
|
}
|
|
7990
8139
|
if (zip64data.startDisk === BigInt(4294967295)) {
|
|
7991
|
-
zip64dataList.push({
|
|
7992
|
-
name: "startDisk",
|
|
7993
|
-
length: 4
|
|
7994
|
-
});
|
|
8140
|
+
zip64dataList.push({ name: "startDisk", length: 4 });
|
|
7995
8141
|
}
|
|
7996
8142
|
return zip64dataList;
|
|
7997
8143
|
};
|
|
@@ -8017,82 +8163,122 @@ var __exports__ = (() => {
|
|
|
8017
8163
|
}
|
|
8018
8164
|
const header = new DataView(new ArrayBuffer(Number(CD_FILE_NAME_OFFSET)));
|
|
8019
8165
|
for (const field of ZIP_HEADER_FIELDS) {
|
|
8020
|
-
setFieldToNumber(
|
|
8166
|
+
setFieldToNumber(
|
|
8167
|
+
header,
|
|
8168
|
+
field.size,
|
|
8169
|
+
field.offset,
|
|
8170
|
+
optionsToUse[field.name ?? ""] ?? field.default ?? 0
|
|
8171
|
+
);
|
|
8021
8172
|
}
|
|
8022
8173
|
const encodedName = new TextEncoder().encode(optionsToUse.fileName);
|
|
8023
8174
|
const resHeader = concatenateArrayBuffers(header.buffer, encodedName, zip64header);
|
|
8024
8175
|
return resHeader;
|
|
8025
8176
|
}
|
|
8026
|
-
var ZIP_HEADER_FIELDS = [
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
size
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8177
|
+
var ZIP_HEADER_FIELDS = [
|
|
8178
|
+
// Central directory file header signature = 0x02014b50
|
|
8179
|
+
{
|
|
8180
|
+
offset: 0,
|
|
8181
|
+
size: 4,
|
|
8182
|
+
default: new DataView(signature2.buffer).getUint32(0, true)
|
|
8183
|
+
},
|
|
8184
|
+
// Version made by
|
|
8185
|
+
{
|
|
8186
|
+
offset: 4,
|
|
8187
|
+
size: 2,
|
|
8188
|
+
default: 45
|
|
8189
|
+
},
|
|
8190
|
+
// Version needed to extract (minimum)
|
|
8191
|
+
{
|
|
8192
|
+
offset: 6,
|
|
8193
|
+
size: 2,
|
|
8194
|
+
default: 45
|
|
8195
|
+
},
|
|
8196
|
+
// General purpose bit flag
|
|
8197
|
+
{
|
|
8198
|
+
offset: 8,
|
|
8199
|
+
size: 2,
|
|
8200
|
+
default: 0
|
|
8201
|
+
},
|
|
8202
|
+
// Compression method
|
|
8203
|
+
{
|
|
8204
|
+
offset: 10,
|
|
8205
|
+
size: 2,
|
|
8206
|
+
default: 0
|
|
8207
|
+
},
|
|
8208
|
+
// File last modification time
|
|
8209
|
+
{
|
|
8210
|
+
offset: 12,
|
|
8211
|
+
size: 2,
|
|
8212
|
+
default: 0
|
|
8213
|
+
},
|
|
8214
|
+
// File last modification date
|
|
8215
|
+
{
|
|
8216
|
+
offset: 14,
|
|
8217
|
+
size: 2,
|
|
8218
|
+
default: 0
|
|
8219
|
+
},
|
|
8220
|
+
// CRC-32 of uncompressed data
|
|
8221
|
+
{
|
|
8222
|
+
offset: 16,
|
|
8223
|
+
size: 4,
|
|
8224
|
+
name: "crc32"
|
|
8225
|
+
},
|
|
8226
|
+
// Compressed size (or 0xffffffff for ZIP64)
|
|
8227
|
+
{
|
|
8228
|
+
offset: 20,
|
|
8229
|
+
size: 4,
|
|
8230
|
+
name: "length"
|
|
8231
|
+
},
|
|
8232
|
+
// Uncompressed size (or 0xffffffff for ZIP64)
|
|
8233
|
+
{
|
|
8234
|
+
offset: 24,
|
|
8235
|
+
size: 4,
|
|
8236
|
+
name: "length"
|
|
8237
|
+
},
|
|
8238
|
+
// File name length (n)
|
|
8239
|
+
{
|
|
8240
|
+
offset: 28,
|
|
8241
|
+
size: 2,
|
|
8242
|
+
name: "fnlength"
|
|
8243
|
+
},
|
|
8244
|
+
// Extra field length (m)
|
|
8245
|
+
{
|
|
8246
|
+
offset: 30,
|
|
8247
|
+
size: 2,
|
|
8248
|
+
default: 0,
|
|
8249
|
+
name: "extraLength"
|
|
8250
|
+
},
|
|
8251
|
+
// File comment length (k)
|
|
8252
|
+
{
|
|
8253
|
+
offset: 32,
|
|
8254
|
+
size: 2,
|
|
8255
|
+
default: 0
|
|
8256
|
+
},
|
|
8257
|
+
// Disk number where file starts (or 0xffff for ZIP64)
|
|
8258
|
+
{
|
|
8259
|
+
offset: 34,
|
|
8260
|
+
size: 2,
|
|
8261
|
+
default: 0
|
|
8262
|
+
},
|
|
8263
|
+
// Internal file attributes
|
|
8264
|
+
{
|
|
8265
|
+
offset: 36,
|
|
8266
|
+
size: 2,
|
|
8267
|
+
default: 0
|
|
8268
|
+
},
|
|
8269
|
+
// External file attributes
|
|
8270
|
+
{
|
|
8271
|
+
offset: 38,
|
|
8272
|
+
size: 4,
|
|
8273
|
+
default: 0
|
|
8274
|
+
},
|
|
8275
|
+
// Relative offset of local file header
|
|
8276
|
+
{
|
|
8277
|
+
offset: 42,
|
|
8278
|
+
size: 4,
|
|
8279
|
+
name: "offset"
|
|
8280
|
+
}
|
|
8281
|
+
];
|
|
8096
8282
|
|
|
8097
8283
|
// src/parse-zip/local-file-header.ts
|
|
8098
8284
|
var COMPRESSION_METHOD_OFFSET = 8n;
|
|
@@ -8108,7 +8294,12 @@ var __exports__ = (() => {
|
|
|
8108
8294
|
return null;
|
|
8109
8295
|
}
|
|
8110
8296
|
const fileNameLength = await buffer.getUint16(headerOffset + FILE_NAME_LENGTH_OFFSET);
|
|
8111
|
-
const fileName = new TextDecoder().decode(
|
|
8297
|
+
const fileName = new TextDecoder().decode(
|
|
8298
|
+
await buffer.slice(
|
|
8299
|
+
headerOffset + FILE_NAME_OFFSET,
|
|
8300
|
+
headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength)
|
|
8301
|
+
)
|
|
8302
|
+
).split("\\").join("/");
|
|
8112
8303
|
const extraFieldLength = await buffer.getUint16(headerOffset + EXTRA_FIELD_LENGTH_OFFSET);
|
|
8113
8304
|
let fileDataOffset = headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength);
|
|
8114
8305
|
const compressionMethod = await buffer.getUint16(headerOffset + COMPRESSION_METHOD_OFFSET);
|
|
@@ -8154,58 +8345,86 @@ var __exports__ = (() => {
|
|
|
8154
8345
|
}
|
|
8155
8346
|
const header = new DataView(new ArrayBuffer(Number(FILE_NAME_OFFSET)));
|
|
8156
8347
|
for (const field of ZIP_HEADER_FIELDS2) {
|
|
8157
|
-
setFieldToNumber(
|
|
8348
|
+
setFieldToNumber(
|
|
8349
|
+
header,
|
|
8350
|
+
field.size,
|
|
8351
|
+
field.offset,
|
|
8352
|
+
optionsToUse[field.name ?? ""] ?? field.default ?? 0
|
|
8353
|
+
);
|
|
8158
8354
|
}
|
|
8159
8355
|
const encodedName = new TextEncoder().encode(optionsToUse.fileName);
|
|
8160
8356
|
const resHeader = concatenateArrayBuffers(header.buffer, encodedName, zip64header);
|
|
8161
8357
|
return resHeader;
|
|
8162
8358
|
}
|
|
8163
|
-
var ZIP_HEADER_FIELDS2 = [
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8359
|
+
var ZIP_HEADER_FIELDS2 = [
|
|
8360
|
+
// Local file header signature = 0x04034b50
|
|
8361
|
+
{
|
|
8362
|
+
offset: 0,
|
|
8363
|
+
size: 4,
|
|
8364
|
+
default: new DataView(signature3.buffer).getUint32(0, true)
|
|
8365
|
+
},
|
|
8366
|
+
// Version needed to extract (minimum)
|
|
8367
|
+
{
|
|
8368
|
+
offset: 4,
|
|
8369
|
+
size: 2,
|
|
8370
|
+
default: 45
|
|
8371
|
+
},
|
|
8372
|
+
// General purpose bit flag
|
|
8373
|
+
{
|
|
8374
|
+
offset: 6,
|
|
8375
|
+
size: 2,
|
|
8376
|
+
default: 0
|
|
8377
|
+
},
|
|
8378
|
+
// Compression method
|
|
8379
|
+
{
|
|
8380
|
+
offset: 8,
|
|
8381
|
+
size: 2,
|
|
8382
|
+
default: 0
|
|
8383
|
+
},
|
|
8384
|
+
// File last modification time
|
|
8385
|
+
{
|
|
8386
|
+
offset: 10,
|
|
8387
|
+
size: 2,
|
|
8388
|
+
default: 0
|
|
8389
|
+
},
|
|
8390
|
+
// File last modification date
|
|
8391
|
+
{
|
|
8392
|
+
offset: 12,
|
|
8393
|
+
size: 2,
|
|
8394
|
+
default: 0
|
|
8395
|
+
},
|
|
8396
|
+
// CRC-32 of uncompressed data
|
|
8397
|
+
{
|
|
8398
|
+
offset: 14,
|
|
8399
|
+
size: 4,
|
|
8400
|
+
name: "crc32"
|
|
8401
|
+
},
|
|
8402
|
+
// Compressed size (or 0xffffffff for ZIP64)
|
|
8403
|
+
{
|
|
8404
|
+
offset: 18,
|
|
8405
|
+
size: 4,
|
|
8406
|
+
name: "length"
|
|
8407
|
+
},
|
|
8408
|
+
// Uncompressed size (or 0xffffffff for ZIP64)
|
|
8409
|
+
{
|
|
8410
|
+
offset: 22,
|
|
8411
|
+
size: 4,
|
|
8412
|
+
name: "length"
|
|
8413
|
+
},
|
|
8414
|
+
// File name length (n)
|
|
8415
|
+
{
|
|
8416
|
+
offset: 26,
|
|
8417
|
+
size: 2,
|
|
8418
|
+
name: "fnlength"
|
|
8419
|
+
},
|
|
8420
|
+
// Extra field length (m)
|
|
8421
|
+
{
|
|
8422
|
+
offset: 28,
|
|
8423
|
+
size: 2,
|
|
8424
|
+
default: 0,
|
|
8425
|
+
name: "extraLength"
|
|
8426
|
+
}
|
|
8427
|
+
];
|
|
8209
8428
|
|
|
8210
8429
|
// ../crypto/src/lib/hash.ts
|
|
8211
8430
|
var Hash = class {
|
|
@@ -8223,10 +8442,9 @@ var __exports__ = (() => {
|
|
|
8223
8442
|
}
|
|
8224
8443
|
const output = await this.concatenate(arrayBuffers);
|
|
8225
8444
|
const hash = await this.hash(output, encoding);
|
|
8226
|
-
this.options.crypto?.onEnd?.({
|
|
8227
|
-
hash
|
|
8228
|
-
});
|
|
8445
|
+
this.options.crypto?.onEnd?.({ hash });
|
|
8229
8446
|
}
|
|
8447
|
+
// HELPERS
|
|
8230
8448
|
async concatenate(asyncIterator) {
|
|
8231
8449
|
return await concatenateArrayBuffersAsync(asyncIterator);
|
|
8232
8450
|
}
|
|
@@ -8234,6 +8452,7 @@ var __exports__ = (() => {
|
|
|
8234
8452
|
|
|
8235
8453
|
// ../crypto/src/lib/algorithms/crc32.ts
|
|
8236
8454
|
var CRC32 = class {
|
|
8455
|
+
crc;
|
|
8237
8456
|
constructor() {
|
|
8238
8457
|
this.crc = ~0;
|
|
8239
8458
|
}
|
|
@@ -8250,7 +8469,264 @@ var __exports__ = (() => {
|
|
|
8250
8469
|
return this.crc;
|
|
8251
8470
|
}
|
|
8252
8471
|
};
|
|
8253
|
-
var CRC32TAB = Uint32Array.of(
|
|
8472
|
+
var CRC32TAB = Uint32Array.of(
|
|
8473
|
+
0,
|
|
8474
|
+
1996959894,
|
|
8475
|
+
3993919788,
|
|
8476
|
+
2567524794,
|
|
8477
|
+
124634137,
|
|
8478
|
+
1886057615,
|
|
8479
|
+
3915621685,
|
|
8480
|
+
2657392035,
|
|
8481
|
+
249268274,
|
|
8482
|
+
2044508324,
|
|
8483
|
+
3772115230,
|
|
8484
|
+
2547177864,
|
|
8485
|
+
162941995,
|
|
8486
|
+
2125561021,
|
|
8487
|
+
3887607047,
|
|
8488
|
+
2428444049,
|
|
8489
|
+
498536548,
|
|
8490
|
+
1789927666,
|
|
8491
|
+
4089016648,
|
|
8492
|
+
2227061214,
|
|
8493
|
+
450548861,
|
|
8494
|
+
1843258603,
|
|
8495
|
+
4107580753,
|
|
8496
|
+
2211677639,
|
|
8497
|
+
325883990,
|
|
8498
|
+
1684777152,
|
|
8499
|
+
4251122042,
|
|
8500
|
+
2321926636,
|
|
8501
|
+
335633487,
|
|
8502
|
+
1661365465,
|
|
8503
|
+
4195302755,
|
|
8504
|
+
2366115317,
|
|
8505
|
+
997073096,
|
|
8506
|
+
1281953886,
|
|
8507
|
+
3579855332,
|
|
8508
|
+
2724688242,
|
|
8509
|
+
1006888145,
|
|
8510
|
+
1258607687,
|
|
8511
|
+
3524101629,
|
|
8512
|
+
2768942443,
|
|
8513
|
+
901097722,
|
|
8514
|
+
1119000684,
|
|
8515
|
+
3686517206,
|
|
8516
|
+
2898065728,
|
|
8517
|
+
853044451,
|
|
8518
|
+
1172266101,
|
|
8519
|
+
3705015759,
|
|
8520
|
+
2882616665,
|
|
8521
|
+
651767980,
|
|
8522
|
+
1373503546,
|
|
8523
|
+
3369554304,
|
|
8524
|
+
3218104598,
|
|
8525
|
+
565507253,
|
|
8526
|
+
1454621731,
|
|
8527
|
+
3485111705,
|
|
8528
|
+
3099436303,
|
|
8529
|
+
671266974,
|
|
8530
|
+
1594198024,
|
|
8531
|
+
3322730930,
|
|
8532
|
+
2970347812,
|
|
8533
|
+
795835527,
|
|
8534
|
+
1483230225,
|
|
8535
|
+
3244367275,
|
|
8536
|
+
3060149565,
|
|
8537
|
+
1994146192,
|
|
8538
|
+
31158534,
|
|
8539
|
+
2563907772,
|
|
8540
|
+
4023717930,
|
|
8541
|
+
1907459465,
|
|
8542
|
+
112637215,
|
|
8543
|
+
2680153253,
|
|
8544
|
+
3904427059,
|
|
8545
|
+
2013776290,
|
|
8546
|
+
251722036,
|
|
8547
|
+
2517215374,
|
|
8548
|
+
3775830040,
|
|
8549
|
+
2137656763,
|
|
8550
|
+
141376813,
|
|
8551
|
+
2439277719,
|
|
8552
|
+
3865271297,
|
|
8553
|
+
1802195444,
|
|
8554
|
+
476864866,
|
|
8555
|
+
2238001368,
|
|
8556
|
+
4066508878,
|
|
8557
|
+
1812370925,
|
|
8558
|
+
453092731,
|
|
8559
|
+
2181625025,
|
|
8560
|
+
4111451223,
|
|
8561
|
+
1706088902,
|
|
8562
|
+
314042704,
|
|
8563
|
+
2344532202,
|
|
8564
|
+
4240017532,
|
|
8565
|
+
1658658271,
|
|
8566
|
+
366619977,
|
|
8567
|
+
2362670323,
|
|
8568
|
+
4224994405,
|
|
8569
|
+
1303535960,
|
|
8570
|
+
984961486,
|
|
8571
|
+
2747007092,
|
|
8572
|
+
3569037538,
|
|
8573
|
+
1256170817,
|
|
8574
|
+
1037604311,
|
|
8575
|
+
2765210733,
|
|
8576
|
+
3554079995,
|
|
8577
|
+
1131014506,
|
|
8578
|
+
879679996,
|
|
8579
|
+
2909243462,
|
|
8580
|
+
3663771856,
|
|
8581
|
+
1141124467,
|
|
8582
|
+
855842277,
|
|
8583
|
+
2852801631,
|
|
8584
|
+
3708648649,
|
|
8585
|
+
1342533948,
|
|
8586
|
+
654459306,
|
|
8587
|
+
3188396048,
|
|
8588
|
+
3373015174,
|
|
8589
|
+
1466479909,
|
|
8590
|
+
544179635,
|
|
8591
|
+
3110523913,
|
|
8592
|
+
3462522015,
|
|
8593
|
+
1591671054,
|
|
8594
|
+
702138776,
|
|
8595
|
+
2966460450,
|
|
8596
|
+
3352799412,
|
|
8597
|
+
1504918807,
|
|
8598
|
+
783551873,
|
|
8599
|
+
3082640443,
|
|
8600
|
+
3233442989,
|
|
8601
|
+
3988292384,
|
|
8602
|
+
2596254646,
|
|
8603
|
+
62317068,
|
|
8604
|
+
1957810842,
|
|
8605
|
+
3939845945,
|
|
8606
|
+
2647816111,
|
|
8607
|
+
81470997,
|
|
8608
|
+
1943803523,
|
|
8609
|
+
3814918930,
|
|
8610
|
+
2489596804,
|
|
8611
|
+
225274430,
|
|
8612
|
+
2053790376,
|
|
8613
|
+
3826175755,
|
|
8614
|
+
2466906013,
|
|
8615
|
+
167816743,
|
|
8616
|
+
2097651377,
|
|
8617
|
+
4027552580,
|
|
8618
|
+
2265490386,
|
|
8619
|
+
503444072,
|
|
8620
|
+
1762050814,
|
|
8621
|
+
4150417245,
|
|
8622
|
+
2154129355,
|
|
8623
|
+
426522225,
|
|
8624
|
+
1852507879,
|
|
8625
|
+
4275313526,
|
|
8626
|
+
2312317920,
|
|
8627
|
+
282753626,
|
|
8628
|
+
1742555852,
|
|
8629
|
+
4189708143,
|
|
8630
|
+
2394877945,
|
|
8631
|
+
397917763,
|
|
8632
|
+
1622183637,
|
|
8633
|
+
3604390888,
|
|
8634
|
+
2714866558,
|
|
8635
|
+
953729732,
|
|
8636
|
+
1340076626,
|
|
8637
|
+
3518719985,
|
|
8638
|
+
2797360999,
|
|
8639
|
+
1068828381,
|
|
8640
|
+
1219638859,
|
|
8641
|
+
3624741850,
|
|
8642
|
+
2936675148,
|
|
8643
|
+
906185462,
|
|
8644
|
+
1090812512,
|
|
8645
|
+
3747672003,
|
|
8646
|
+
2825379669,
|
|
8647
|
+
829329135,
|
|
8648
|
+
1181335161,
|
|
8649
|
+
3412177804,
|
|
8650
|
+
3160834842,
|
|
8651
|
+
628085408,
|
|
8652
|
+
1382605366,
|
|
8653
|
+
3423369109,
|
|
8654
|
+
3138078467,
|
|
8655
|
+
570562233,
|
|
8656
|
+
1426400815,
|
|
8657
|
+
3317316542,
|
|
8658
|
+
2998733608,
|
|
8659
|
+
733239954,
|
|
8660
|
+
1555261956,
|
|
8661
|
+
3268935591,
|
|
8662
|
+
3050360625,
|
|
8663
|
+
752459403,
|
|
8664
|
+
1541320221,
|
|
8665
|
+
2607071920,
|
|
8666
|
+
3965973030,
|
|
8667
|
+
1969922972,
|
|
8668
|
+
40735498,
|
|
8669
|
+
2617837225,
|
|
8670
|
+
3943577151,
|
|
8671
|
+
1913087877,
|
|
8672
|
+
83908371,
|
|
8673
|
+
2512341634,
|
|
8674
|
+
3803740692,
|
|
8675
|
+
2075208622,
|
|
8676
|
+
213261112,
|
|
8677
|
+
2463272603,
|
|
8678
|
+
3855990285,
|
|
8679
|
+
2094854071,
|
|
8680
|
+
198958881,
|
|
8681
|
+
2262029012,
|
|
8682
|
+
4057260610,
|
|
8683
|
+
1759359992,
|
|
8684
|
+
534414190,
|
|
8685
|
+
2176718541,
|
|
8686
|
+
4139329115,
|
|
8687
|
+
1873836001,
|
|
8688
|
+
414664567,
|
|
8689
|
+
2282248934,
|
|
8690
|
+
4279200368,
|
|
8691
|
+
1711684554,
|
|
8692
|
+
285281116,
|
|
8693
|
+
2405801727,
|
|
8694
|
+
4167216745,
|
|
8695
|
+
1634467795,
|
|
8696
|
+
376229701,
|
|
8697
|
+
2685067896,
|
|
8698
|
+
3608007406,
|
|
8699
|
+
1308918612,
|
|
8700
|
+
956543938,
|
|
8701
|
+
2808555105,
|
|
8702
|
+
3495958263,
|
|
8703
|
+
1231636301,
|
|
8704
|
+
1047427035,
|
|
8705
|
+
2932959818,
|
|
8706
|
+
3654703836,
|
|
8707
|
+
1088359270,
|
|
8708
|
+
936918e3,
|
|
8709
|
+
2847714899,
|
|
8710
|
+
3736837829,
|
|
8711
|
+
1202900863,
|
|
8712
|
+
817233897,
|
|
8713
|
+
3183342108,
|
|
8714
|
+
3401237130,
|
|
8715
|
+
1404277552,
|
|
8716
|
+
615818150,
|
|
8717
|
+
3134207493,
|
|
8718
|
+
3453421203,
|
|
8719
|
+
1423857449,
|
|
8720
|
+
601450431,
|
|
8721
|
+
3009837614,
|
|
8722
|
+
3294710456,
|
|
8723
|
+
1567103746,
|
|
8724
|
+
711928724,
|
|
8725
|
+
3020668471,
|
|
8726
|
+
3272380065,
|
|
8727
|
+
1510334235,
|
|
8728
|
+
755167117
|
|
8729
|
+
);
|
|
8254
8730
|
function getCRC32Table() {
|
|
8255
8731
|
return CRC32TAB;
|
|
8256
8732
|
}
|
|
@@ -8342,14 +8818,16 @@ var __exports__ = (() => {
|
|
|
8342
8818
|
// ../crypto/src/lib/crc32-hash.ts
|
|
8343
8819
|
var CRC32Hash = class extends Hash {
|
|
8344
8820
|
name = "crc32";
|
|
8821
|
+
options;
|
|
8345
8822
|
constructor(options = {}) {
|
|
8346
8823
|
super();
|
|
8347
|
-
this.options = {
|
|
8348
|
-
crypto: {},
|
|
8349
|
-
...options
|
|
8350
|
-
};
|
|
8824
|
+
this.options = { crypto: {}, ...options };
|
|
8351
8825
|
this.hashBatches = this.hashBatches.bind(this);
|
|
8352
8826
|
}
|
|
8827
|
+
/**
|
|
8828
|
+
* Atomic hash calculation
|
|
8829
|
+
* @returns base64 encoded hash
|
|
8830
|
+
*/
|
|
8353
8831
|
async hash(input, encoding) {
|
|
8354
8832
|
return this.hashSync(input, encoding);
|
|
8355
8833
|
}
|
|
@@ -8366,15 +8844,15 @@ var __exports__ = (() => {
|
|
|
8366
8844
|
yield chunk;
|
|
8367
8845
|
}
|
|
8368
8846
|
const digest = hash.finalize();
|
|
8369
|
-
this.options.crypto?.onEnd?.({
|
|
8370
|
-
hash: encodeNumber(digest, encoding)
|
|
8371
|
-
});
|
|
8847
|
+
this.options.crypto?.onEnd?.({ hash: encodeNumber(digest, encoding) });
|
|
8372
8848
|
}
|
|
8373
8849
|
};
|
|
8374
8850
|
|
|
8375
8851
|
// ../crypto/src/lib/algorithms/md5-wasm.ts
|
|
8376
8852
|
var atb = typeof atob === "function" ? atob : typeof Buffer === "function" ? nodeATOB : identity;
|
|
8377
|
-
var wasmB64 = atb(
|
|
8853
|
+
var wasmB64 = atb(
|
|
8854
|
+
"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"
|
|
8855
|
+
);
|
|
8378
8856
|
var wasm = WebAssembly && atb !== identity ? str2AB(wasmB64).buffer : false;
|
|
8379
8857
|
var crypt = makeCrypt();
|
|
8380
8858
|
var biteSize = 240 * 16 * 16;
|
|
@@ -8383,7 +8861,9 @@ var __exports__ = (() => {
|
|
|
8383
8861
|
var parmTypeErrStr = "Parameter must be Buffer, ArrayBuffer or Uint8Array";
|
|
8384
8862
|
var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes";
|
|
8385
8863
|
if (!wasm) {
|
|
8386
|
-
console.log(
|
|
8864
|
+
console.log(
|
|
8865
|
+
"WebAssembly not available or WASM module could not be decoded; md5WASM will fall back to JavaScript"
|
|
8866
|
+
);
|
|
8387
8867
|
}
|
|
8388
8868
|
function md5WASM(data) {
|
|
8389
8869
|
var mem, memView, importObj, imports, len, buff, thenFun, catchFun, result, endTime;
|
|
@@ -8422,13 +8902,8 @@ var __exports__ = (() => {
|
|
|
8422
8902
|
initial: len > 32e6 ? len > 64e6 ? len > 128e6 ? 4096 : 2048 : 1024 : 512
|
|
8423
8903
|
});
|
|
8424
8904
|
memView = new Uint32Array(mem.buffer);
|
|
8425
|
-
imports = {
|
|
8426
|
-
|
|
8427
|
-
log: console.log
|
|
8428
|
-
};
|
|
8429
|
-
importObj = {
|
|
8430
|
-
imports
|
|
8431
|
-
};
|
|
8905
|
+
imports = { mem, log: console.log };
|
|
8906
|
+
importObj = { imports };
|
|
8432
8907
|
WebAssembly.instantiate(wasm, importObj).then(giterdone);
|
|
8433
8908
|
}
|
|
8434
8909
|
} else {
|
|
@@ -8784,184 +9259,35 @@ var __exports__ = (() => {
|
|
|
8784
9259
|
// ../crypto/src/lib/md5-hash.ts
|
|
8785
9260
|
var MD5Hash = class extends Hash {
|
|
8786
9261
|
name = "md5";
|
|
9262
|
+
options;
|
|
8787
9263
|
constructor(options = {}) {
|
|
8788
9264
|
super();
|
|
8789
9265
|
this.options = options;
|
|
8790
9266
|
}
|
|
9267
|
+
/**
|
|
9268
|
+
* Atomic hash calculation
|
|
9269
|
+
* @returns base64 encoded hash
|
|
9270
|
+
*/
|
|
8791
9271
|
async hash(input, encoding) {
|
|
8792
|
-
const md5Promise = new Promise(
|
|
9272
|
+
const md5Promise = new Promise(
|
|
9273
|
+
(resolve2, reject) => (
|
|
9274
|
+
// @ts-expect-error
|
|
9275
|
+
md5WASM(input).then(resolve2).catch(reject)
|
|
9276
|
+
)
|
|
9277
|
+
);
|
|
8793
9278
|
const hex = await md5Promise;
|
|
8794
9279
|
return encodeHex(hex, encoding);
|
|
8795
9280
|
}
|
|
8796
9281
|
};
|
|
8797
9282
|
|
|
8798
|
-
// ../core/src/javascript-utils/is-type.ts
|
|
8799
|
-
var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
8800
|
-
var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
8801
|
-
|
|
8802
|
-
// ../core/src/lib/utils/mime-type-utils.ts
|
|
8803
|
-
var DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
|
|
8804
|
-
var MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
|
|
8805
|
-
function parseMIMEType(mimeString) {
|
|
8806
|
-
const matches2 = MIME_TYPE_PATTERN.exec(mimeString);
|
|
8807
|
-
if (matches2) {
|
|
8808
|
-
return matches2[1];
|
|
8809
|
-
}
|
|
8810
|
-
return mimeString;
|
|
8811
|
-
}
|
|
8812
|
-
function parseMIMETypeFromURL(url) {
|
|
8813
|
-
const matches2 = DATA_URL_PATTERN.exec(url);
|
|
8814
|
-
if (matches2) {
|
|
8815
|
-
return matches2[1];
|
|
8816
|
-
}
|
|
8817
|
-
return "";
|
|
8818
|
-
}
|
|
8819
|
-
|
|
8820
|
-
// ../core/src/lib/utils/url-utils.ts
|
|
8821
|
-
var QUERY_STRING_PATTERN = /\?.*/;
|
|
8822
|
-
function stripQueryString(url) {
|
|
8823
|
-
return url.replace(QUERY_STRING_PATTERN, "");
|
|
8824
|
-
}
|
|
8825
|
-
|
|
8826
|
-
// ../core/src/lib/utils/resource-utils.ts
|
|
8827
|
-
function getResourceUrl(resource) {
|
|
8828
|
-
if (isResponse(resource)) {
|
|
8829
|
-
const response = resource;
|
|
8830
|
-
return response.url;
|
|
8831
|
-
}
|
|
8832
|
-
if (isBlob(resource)) {
|
|
8833
|
-
const blob = resource;
|
|
8834
|
-
return blob.name || "";
|
|
8835
|
-
}
|
|
8836
|
-
if (typeof resource === "string") {
|
|
8837
|
-
return resource;
|
|
8838
|
-
}
|
|
8839
|
-
return "";
|
|
8840
|
-
}
|
|
8841
|
-
function getResourceMIMEType(resource) {
|
|
8842
|
-
if (isResponse(resource)) {
|
|
8843
|
-
const response = resource;
|
|
8844
|
-
const contentTypeHeader = response.headers.get("content-type") || "";
|
|
8845
|
-
const noQueryUrl = stripQueryString(response.url);
|
|
8846
|
-
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
8847
|
-
}
|
|
8848
|
-
if (isBlob(resource)) {
|
|
8849
|
-
const blob = resource;
|
|
8850
|
-
return blob.type || "";
|
|
8851
|
-
}
|
|
8852
|
-
if (typeof resource === "string") {
|
|
8853
|
-
return parseMIMETypeFromURL(resource);
|
|
8854
|
-
}
|
|
8855
|
-
return "";
|
|
8856
|
-
}
|
|
8857
|
-
function getResourceContentLength(resource) {
|
|
8858
|
-
if (isResponse(resource)) {
|
|
8859
|
-
const response = resource;
|
|
8860
|
-
return response.headers["content-length"] || -1;
|
|
8861
|
-
}
|
|
8862
|
-
if (isBlob(resource)) {
|
|
8863
|
-
const blob = resource;
|
|
8864
|
-
return blob.size;
|
|
8865
|
-
}
|
|
8866
|
-
if (typeof resource === "string") {
|
|
8867
|
-
return resource.length;
|
|
8868
|
-
}
|
|
8869
|
-
if (resource instanceof ArrayBuffer) {
|
|
8870
|
-
return resource.byteLength;
|
|
8871
|
-
}
|
|
8872
|
-
if (ArrayBuffer.isView(resource)) {
|
|
8873
|
-
return resource.byteLength;
|
|
8874
|
-
}
|
|
8875
|
-
return -1;
|
|
8876
|
-
}
|
|
8877
|
-
|
|
8878
|
-
// ../core/src/lib/utils/response-utils.ts
|
|
8879
|
-
async function makeResponse(resource) {
|
|
8880
|
-
if (isResponse(resource)) {
|
|
8881
|
-
return resource;
|
|
8882
|
-
}
|
|
8883
|
-
const headers = {};
|
|
8884
|
-
const contentLength = getResourceContentLength(resource);
|
|
8885
|
-
if (contentLength >= 0) {
|
|
8886
|
-
headers["content-length"] = String(contentLength);
|
|
8887
|
-
}
|
|
8888
|
-
const url = getResourceUrl(resource);
|
|
8889
|
-
const type = getResourceMIMEType(resource);
|
|
8890
|
-
if (type) {
|
|
8891
|
-
headers["content-type"] = type;
|
|
8892
|
-
}
|
|
8893
|
-
const initialDataUrl = await getInitialDataUrl(resource);
|
|
8894
|
-
if (initialDataUrl) {
|
|
8895
|
-
headers["x-first-bytes"] = initialDataUrl;
|
|
8896
|
-
}
|
|
8897
|
-
if (typeof resource === "string") {
|
|
8898
|
-
resource = new TextEncoder().encode(resource);
|
|
8899
|
-
}
|
|
8900
|
-
const response = new Response(resource, {
|
|
8901
|
-
headers
|
|
8902
|
-
});
|
|
8903
|
-
Object.defineProperty(response, "url", {
|
|
8904
|
-
value: url
|
|
8905
|
-
});
|
|
8906
|
-
return response;
|
|
8907
|
-
}
|
|
8908
|
-
async function getInitialDataUrl(resource) {
|
|
8909
|
-
const INITIAL_DATA_LENGTH = 5;
|
|
8910
|
-
if (typeof resource === "string") {
|
|
8911
|
-
return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;
|
|
8912
|
-
}
|
|
8913
|
-
if (resource instanceof Blob) {
|
|
8914
|
-
const blobSlice = resource.slice(0, 5);
|
|
8915
|
-
return await new Promise((resolve2) => {
|
|
8916
|
-
const reader = new FileReader();
|
|
8917
|
-
reader.onload = (event) => resolve2(event?.target?.result);
|
|
8918
|
-
reader.readAsDataURL(blobSlice);
|
|
8919
|
-
});
|
|
8920
|
-
}
|
|
8921
|
-
if (resource instanceof ArrayBuffer) {
|
|
8922
|
-
const slice = resource.slice(0, INITIAL_DATA_LENGTH);
|
|
8923
|
-
const base64 = arrayBufferToBase64(slice);
|
|
8924
|
-
return `data:base64,${base64}`;
|
|
8925
|
-
}
|
|
8926
|
-
return null;
|
|
8927
|
-
}
|
|
8928
|
-
function arrayBufferToBase64(buffer) {
|
|
8929
|
-
let binary = "";
|
|
8930
|
-
const bytes = new Uint8Array(buffer);
|
|
8931
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
8932
|
-
binary += String.fromCharCode(bytes[i]);
|
|
8933
|
-
}
|
|
8934
|
-
return btoa(binary);
|
|
8935
|
-
}
|
|
8936
|
-
|
|
8937
|
-
// ../core/src/lib/fetch/fetch-file.ts
|
|
8938
|
-
function isNodePath(url) {
|
|
8939
|
-
return !isRequestURL(url) && !isDataURL(url);
|
|
8940
|
-
}
|
|
8941
|
-
function isRequestURL(url) {
|
|
8942
|
-
return url.startsWith("http:") || url.startsWith("https:");
|
|
8943
|
-
}
|
|
8944
|
-
function isDataURL(url) {
|
|
8945
|
-
return url.startsWith("data:");
|
|
8946
|
-
}
|
|
8947
|
-
async function fetchFile(urlOrData, fetchOptions) {
|
|
8948
|
-
if (typeof urlOrData === "string") {
|
|
8949
|
-
const url = resolvePath(urlOrData);
|
|
8950
|
-
if (isNodePath(url)) {
|
|
8951
|
-
if (globalThis.loaders?.fetchNode) {
|
|
8952
|
-
return globalThis.loaders?.fetchNode(url, fetchOptions);
|
|
8953
|
-
}
|
|
8954
|
-
}
|
|
8955
|
-
return await fetch(url, fetchOptions);
|
|
8956
|
-
}
|
|
8957
|
-
return await makeResponse(urlOrData);
|
|
8958
|
-
}
|
|
8959
|
-
|
|
8960
9283
|
// src/parse-zip/zip-composition.ts
|
|
9284
|
+
var import_core = __toESM(require_core(), 1);
|
|
8961
9285
|
async function cutTheTailOff(provider) {
|
|
8962
9286
|
const oldEoCDinfo = await parseEoCDRecord(provider);
|
|
8963
9287
|
const oldCDStartOffset = oldEoCDinfo.cdStartOffset;
|
|
8964
|
-
const oldCDLength = Number(
|
|
9288
|
+
const oldCDLength = Number(
|
|
9289
|
+
oldEoCDinfo.offsets.zip64EoCDOffset ? oldEoCDinfo.offsets.zip64EoCDOffset - oldCDStartOffset : oldEoCDinfo.offsets.zipEoCDOffset - oldCDStartOffset
|
|
9290
|
+
);
|
|
8965
9291
|
const zipEnding = await provider.slice(oldCDStartOffset, provider.length);
|
|
8966
9292
|
await provider.truncate(Number(oldCDStartOffset));
|
|
8967
9293
|
const oldCDBody = zipEnding.slice(0, oldCDLength);
|
|
@@ -8981,7 +9307,10 @@ var __exports__ = (() => {
|
|
|
8981
9307
|
offset: localFileHeaderOffset,
|
|
8982
9308
|
length: fileToAdd.byteLength
|
|
8983
9309
|
});
|
|
8984
|
-
return [
|
|
9310
|
+
return [
|
|
9311
|
+
new Uint8Array(concatenateArrayBuffers(newFileLocalHeader, fileToAdd)),
|
|
9312
|
+
new Uint8Array(newFileCDHeader)
|
|
9313
|
+
];
|
|
8985
9314
|
}
|
|
8986
9315
|
async function addOneFile(zipUrl, fileToAdd, fileName) {
|
|
8987
9316
|
const provider = new FileHandleFile(zipUrl, true);
|
|
@@ -8993,7 +9322,15 @@ var __exports__ = (() => {
|
|
|
8993
9322
|
const newCDStartOffset = provider.length;
|
|
8994
9323
|
await provider.append(new Uint8Array(newCDBody));
|
|
8995
9324
|
const eocdOffset = provider.length;
|
|
8996
|
-
await provider.append(
|
|
9325
|
+
await provider.append(
|
|
9326
|
+
updateEoCD(
|
|
9327
|
+
eocdBody,
|
|
9328
|
+
oldEoCDinfo.offsets,
|
|
9329
|
+
newCDStartOffset,
|
|
9330
|
+
eocdOffset,
|
|
9331
|
+
oldEoCDinfo.cdRecordsNumber + 1n
|
|
9332
|
+
)
|
|
9333
|
+
);
|
|
8997
9334
|
}
|
|
8998
9335
|
async function createZip(inputPath, outputPath, createAdditionalData) {
|
|
8999
9336
|
const fileIterator = getFileIterator(inputPath);
|
|
@@ -9011,19 +9348,15 @@ var __exports__ = (() => {
|
|
|
9011
9348
|
const cd = concatenateArrayBuffers(...cdArray);
|
|
9012
9349
|
await resFile.append(new Uint8Array(cd));
|
|
9013
9350
|
const eoCDStart = (await resFile.stat()).bigsize;
|
|
9014
|
-
await resFile.append(
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
})));
|
|
9351
|
+
await resFile.append(
|
|
9352
|
+
new Uint8Array(
|
|
9353
|
+
generateEoCD({ recordsNumber: cdArray.length, cdSize: cd.byteLength, cdOffset, eoCDStart })
|
|
9354
|
+
)
|
|
9355
|
+
);
|
|
9020
9356
|
}
|
|
9021
9357
|
async function addFile(file, resFile, cdArray, fileList) {
|
|
9022
9358
|
const size = (await resFile.stat()).bigsize;
|
|
9023
|
-
fileList?.push({
|
|
9024
|
-
fileName: file.path,
|
|
9025
|
-
localHeaderOffset: size
|
|
9026
|
-
});
|
|
9359
|
+
fileList?.push({ fileName: file.path, localHeaderOffset: size });
|
|
9027
9360
|
const [localPart, cdHeaderPart] = await generateFileHeaders(file.path, file.file, size);
|
|
9028
9361
|
await resFile.append(localPart);
|
|
9029
9362
|
cdArray.push(cdHeaderPart);
|
|
@@ -9032,11 +9365,8 @@ var __exports__ = (() => {
|
|
|
9032
9365
|
async function* iterable() {
|
|
9033
9366
|
const fileList = await getAllFiles(inputPath);
|
|
9034
9367
|
for (const filePath of fileList) {
|
|
9035
|
-
const file = await (await fetchFile(path_exports.join(inputPath, filePath))).arrayBuffer();
|
|
9036
|
-
yield {
|
|
9037
|
-
path: filePath,
|
|
9038
|
-
file
|
|
9039
|
-
};
|
|
9368
|
+
const file = await (await (0, import_core.fetchFile)(path_exports.join(inputPath, filePath))).arrayBuffer();
|
|
9369
|
+
yield { path: filePath, file };
|
|
9040
9370
|
}
|
|
9041
9371
|
}
|
|
9042
9372
|
return iterable();
|
|
@@ -9067,31 +9397,39 @@ var __exports__ = (() => {
|
|
|
9067
9397
|
this.compressBatches = this.compressBatches.bind(this);
|
|
9068
9398
|
this.decompressBatches = this.decompressBatches.bind(this);
|
|
9069
9399
|
}
|
|
9400
|
+
/** Preloads any dynamic libraries. May enable sync functions */
|
|
9070
9401
|
async preload() {
|
|
9071
9402
|
return;
|
|
9072
9403
|
}
|
|
9404
|
+
/** Asynchronously compress data */
|
|
9073
9405
|
async compress(input) {
|
|
9074
9406
|
await this.preload();
|
|
9075
9407
|
return this.compressSync(input);
|
|
9076
9408
|
}
|
|
9409
|
+
/** Asynchronously decompress data */
|
|
9077
9410
|
async decompress(input, size) {
|
|
9078
9411
|
await this.preload();
|
|
9079
9412
|
return this.decompressSync(input, size);
|
|
9080
9413
|
}
|
|
9414
|
+
/** Synchronously compress data */
|
|
9081
9415
|
compressSync(input) {
|
|
9082
9416
|
throw new Error(`${this.name}: sync compression not supported`);
|
|
9083
9417
|
}
|
|
9418
|
+
/** Synchronously compress data */
|
|
9084
9419
|
decompressSync(input, size) {
|
|
9085
9420
|
throw new Error(`${this.name}: sync decompression not supported`);
|
|
9086
9421
|
}
|
|
9422
|
+
/** Compress batches */
|
|
9087
9423
|
async *compressBatches(asyncIterator) {
|
|
9088
9424
|
const input = await this.concatenate(asyncIterator);
|
|
9089
9425
|
yield this.compress(input);
|
|
9090
9426
|
}
|
|
9427
|
+
/** Decompress batches */
|
|
9091
9428
|
async *decompressBatches(asyncIterator) {
|
|
9092
9429
|
const input = await this.concatenate(asyncIterator);
|
|
9093
9430
|
yield this.decompress(input);
|
|
9094
9431
|
}
|
|
9432
|
+
// HELPERS
|
|
9095
9433
|
concatenate(asyncIterator) {
|
|
9096
9434
|
return concatenateArrayBuffersAsync(asyncIterator);
|
|
9097
9435
|
}
|
|
@@ -9111,6 +9449,7 @@ var __exports__ = (() => {
|
|
|
9111
9449
|
extensions = [];
|
|
9112
9450
|
contentEncodings = ["deflate"];
|
|
9113
9451
|
isSupported = true;
|
|
9452
|
+
options;
|
|
9114
9453
|
_chunks = [];
|
|
9115
9454
|
constructor(options = {}) {
|
|
9116
9455
|
super(options);
|
|
@@ -9192,16 +9531,26 @@ var __exports__ = (() => {
|
|
|
9192
9531
|
this._chunks = [];
|
|
9193
9532
|
return chunks;
|
|
9194
9533
|
}
|
|
9534
|
+
// TODO - For some reason we don't get the error message from pako in _onEnd?
|
|
9195
9535
|
_getError(code = 0) {
|
|
9196
9536
|
const MESSAGES = {
|
|
9537
|
+
/* Z_NEED_DICT 2 */
|
|
9197
9538
|
2: "need dictionary",
|
|
9539
|
+
/* Z_STREAM_END 1 */
|
|
9198
9540
|
1: "stream end",
|
|
9541
|
+
/* Z_OK 0 */
|
|
9199
9542
|
0: "",
|
|
9543
|
+
/* Z_ERRNO (-1) */
|
|
9200
9544
|
"-1": "file error",
|
|
9545
|
+
/* Z_STREAM_ERROR (-2) */
|
|
9201
9546
|
"-2": "stream error",
|
|
9547
|
+
/* Z_DATA_ERROR (-3) */
|
|
9202
9548
|
"-3": "data error",
|
|
9549
|
+
/* Z_MEM_ERROR (-4) */
|
|
9203
9550
|
"-4": "insufficient memory",
|
|
9551
|
+
/* Z_BUF_ERROR (-5) */
|
|
9204
9552
|
"-5": "buffer error",
|
|
9553
|
+
/* Z_VERSION_ERROR (-6) */
|
|
9205
9554
|
"-6": "incompatible version"
|
|
9206
9555
|
};
|
|
9207
9556
|
return `${this.name}: ${MESSAGES[code]}`;
|
|
@@ -9210,18 +9559,24 @@ var __exports__ = (() => {
|
|
|
9210
9559
|
|
|
9211
9560
|
// src/filesystems/zip-filesystem.ts
|
|
9212
9561
|
var ZIP_COMPRESSION_HANDLERS = {
|
|
9562
|
+
/** No compression */
|
|
9213
9563
|
0: async (compressedFile) => compressedFile,
|
|
9564
|
+
/** Deflation */
|
|
9214
9565
|
8: async (compressedFile) => {
|
|
9215
|
-
const compression = new DeflateCompression({
|
|
9216
|
-
raw: true
|
|
9217
|
-
});
|
|
9566
|
+
const compression = new DeflateCompression({ raw: true });
|
|
9218
9567
|
const decompressedData = await compression.decompress(compressedFile);
|
|
9219
9568
|
return decompressedData;
|
|
9220
9569
|
}
|
|
9221
9570
|
};
|
|
9222
9571
|
var ZipFileSystem = class {
|
|
9572
|
+
/** FileProvider instance promise */
|
|
9223
9573
|
fileProvider = null;
|
|
9574
|
+
fileName;
|
|
9224
9575
|
archive = null;
|
|
9576
|
+
/**
|
|
9577
|
+
* Constructor
|
|
9578
|
+
* @param file - instance of FileProvider or file path string
|
|
9579
|
+
*/
|
|
9225
9580
|
constructor(file) {
|
|
9226
9581
|
if (typeof file === "string") {
|
|
9227
9582
|
this.fileName = file;
|
|
@@ -9238,11 +9593,16 @@ var __exports__ = (() => {
|
|
|
9238
9593
|
this.fileProvider = file;
|
|
9239
9594
|
}
|
|
9240
9595
|
}
|
|
9596
|
+
/** Clean up resources */
|
|
9241
9597
|
async destroy() {
|
|
9242
9598
|
if (this.fileProvider) {
|
|
9243
9599
|
await this.fileProvider.destroy();
|
|
9244
9600
|
}
|
|
9245
9601
|
}
|
|
9602
|
+
/**
|
|
9603
|
+
* Get file names list from zip archive
|
|
9604
|
+
* @returns array of file names
|
|
9605
|
+
*/
|
|
9246
9606
|
async readdir() {
|
|
9247
9607
|
if (!this.fileProvider) {
|
|
9248
9608
|
throw new Error("No data detected in the zip archive");
|
|
@@ -9254,14 +9614,24 @@ var __exports__ = (() => {
|
|
|
9254
9614
|
}
|
|
9255
9615
|
return fileNames;
|
|
9256
9616
|
}
|
|
9617
|
+
/**
|
|
9618
|
+
* Get file metadata
|
|
9619
|
+
* @param filename - name of a file
|
|
9620
|
+
* @returns central directory data
|
|
9621
|
+
*/
|
|
9257
9622
|
async stat(filename2) {
|
|
9258
9623
|
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
9259
|
-
return {
|
|
9260
|
-
...cdFileHeader,
|
|
9261
|
-
size: Number(cdFileHeader.uncompressedSize)
|
|
9262
|
-
};
|
|
9624
|
+
return { ...cdFileHeader, size: Number(cdFileHeader.uncompressedSize) };
|
|
9263
9625
|
}
|
|
9626
|
+
/**
|
|
9627
|
+
* Implementation of fetch against this file system
|
|
9628
|
+
* @param filename - name of a file
|
|
9629
|
+
* @returns - Response with file data
|
|
9630
|
+
*/
|
|
9264
9631
|
async fetch(filename2) {
|
|
9632
|
+
if (this.fileName && filename2.indexOf(this.fileName) === 0) {
|
|
9633
|
+
filename2 = filename2.substring(this.fileName.length + 1);
|
|
9634
|
+
}
|
|
9265
9635
|
let uncompressedFile;
|
|
9266
9636
|
if (this.archive) {
|
|
9267
9637
|
uncompressedFile = await this.archive.getFile(filename2, "http");
|
|
@@ -9270,7 +9640,10 @@ var __exports__ = (() => {
|
|
|
9270
9640
|
throw new Error("No data detected in the zip archive");
|
|
9271
9641
|
}
|
|
9272
9642
|
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
9273
|
-
const localFileHeader = await parseZipLocalFileHeader(
|
|
9643
|
+
const localFileHeader = await parseZipLocalFileHeader(
|
|
9644
|
+
cdFileHeader.localHeaderOffset,
|
|
9645
|
+
this.fileProvider
|
|
9646
|
+
);
|
|
9274
9647
|
if (!localFileHeader) {
|
|
9275
9648
|
throw new Error("Local file header has not been found in the zip archive`");
|
|
9276
9649
|
}
|
|
@@ -9278,7 +9651,10 @@ var __exports__ = (() => {
|
|
|
9278
9651
|
if (!compressionHandler) {
|
|
9279
9652
|
throw Error("Only Deflation compression is supported");
|
|
9280
9653
|
}
|
|
9281
|
-
const compressedFile = await this.fileProvider.slice(
|
|
9654
|
+
const compressedFile = await this.fileProvider.slice(
|
|
9655
|
+
localFileHeader.fileDataOffset,
|
|
9656
|
+
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
9657
|
+
);
|
|
9282
9658
|
uncompressedFile = await compressionHandler(compressedFile);
|
|
9283
9659
|
}
|
|
9284
9660
|
const response = new Response(uncompressedFile);
|
|
@@ -9287,6 +9663,11 @@ var __exports__ = (() => {
|
|
|
9287
9663
|
});
|
|
9288
9664
|
return response;
|
|
9289
9665
|
}
|
|
9666
|
+
/**
|
|
9667
|
+
* Get central directory file header
|
|
9668
|
+
* @param filename - name of a file
|
|
9669
|
+
* @returns central directory file header
|
|
9670
|
+
*/
|
|
9290
9671
|
async getCDFileHeader(filename2) {
|
|
9291
9672
|
if (!this.fileProvider) {
|
|
9292
9673
|
throw new Error("No data detected in the zip archive");
|
|
@@ -9308,10 +9689,23 @@ var __exports__ = (() => {
|
|
|
9308
9689
|
|
|
9309
9690
|
// src/filesystems/IndexedArchive.ts
|
|
9310
9691
|
var IndexedArchive = class {
|
|
9692
|
+
fileProvider;
|
|
9693
|
+
fileName;
|
|
9694
|
+
/**
|
|
9695
|
+
* Constructor
|
|
9696
|
+
* @param fileProvider - instance of a binary data reader
|
|
9697
|
+
* @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
|
|
9698
|
+
* @param fileName - name of the archive. It is used to add to an URL of a loader context
|
|
9699
|
+
*/
|
|
9311
9700
|
constructor(fileProvider, hashTable, fileName) {
|
|
9312
9701
|
this.fileProvider = fileProvider;
|
|
9313
9702
|
this.fileName = fileName;
|
|
9314
9703
|
}
|
|
9704
|
+
/**
|
|
9705
|
+
* Get file as from order ZIP arhive without using the hash file
|
|
9706
|
+
* @param filename - path to the internal file
|
|
9707
|
+
* @returns
|
|
9708
|
+
*/
|
|
9315
9709
|
async getFileWithoutHash(filename2) {
|
|
9316
9710
|
const zipFS = new ZipFileSystem(this.fileProvider);
|
|
9317
9711
|
const response = await zipFS.fetch(filename2);
|
|
@@ -9360,7 +9754,9 @@ var __exports__ = (() => {
|
|
|
9360
9754
|
}
|
|
9361
9755
|
const arrayBuffer = textEncoder.encode(filename2).buffer;
|
|
9362
9756
|
const md5 = await md5Hash.hash(arrayBuffer, "hex");
|
|
9363
|
-
hashArray.push(
|
|
9757
|
+
hashArray.push(
|
|
9758
|
+
concatenateArrayBuffers(hexStringToBuffer(md5), bigintToBuffer(cdHeader.localHeaderOffset))
|
|
9759
|
+
);
|
|
9364
9760
|
}
|
|
9365
9761
|
const bufferArray = hashArray.sort(compareHashes);
|
|
9366
9762
|
return concatenateArrayBuffersFromArray(bufferArray);
|
|
@@ -9377,7 +9773,7 @@ var __exports__ = (() => {
|
|
|
9377
9773
|
function bigintToBuffer(n) {
|
|
9378
9774
|
return new BigUint64Array([n]).buffer;
|
|
9379
9775
|
}
|
|
9380
|
-
return __toCommonJS(
|
|
9776
|
+
return __toCommonJS(bundle_exports);
|
|
9381
9777
|
})();
|
|
9382
9778
|
/*! Bundled license information:
|
|
9383
9779
|
|