@loaders.gl/zip 4.2.0-alpha.4 → 4.2.0-alpha.5
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 +920 -542
- package/dist/dist.min.js +25 -0
- package/dist/filesystems/IndexedArchive.js +24 -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 +121 -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 +49 -125
- 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 +121 -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 +30 -29
- package/dist/zip-loader.js +51 -40
- package/dist/zip-writer.js +39 -39
- package/package.json +11 -7
- 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,8 +7136,11 @@ var __exports__ = (() => {
|
|
|
7132
7136
|
var inputLength;
|
|
7133
7137
|
var recordSize = 512;
|
|
7134
7138
|
var Tar = class {
|
|
7135
|
-
|
|
7139
|
+
/**
|
|
7140
|
+
* @param [recordsPerBlock]
|
|
7141
|
+
*/
|
|
7136
7142
|
constructor(recordsPerBlock) {
|
|
7143
|
+
this.blocks = [];
|
|
7137
7144
|
this.written = 0;
|
|
7138
7145
|
blockSize = (recordsPerBlock || 20) * recordSize;
|
|
7139
7146
|
this.out = clean(blockSize);
|
|
@@ -7143,12 +7150,21 @@ var __exports__ = (() => {
|
|
|
7143
7150
|
this.clear = this.clear.bind(this);
|
|
7144
7151
|
this.append = this.append.bind(this);
|
|
7145
7152
|
}
|
|
7153
|
+
/**
|
|
7154
|
+
* Append a file to the tar archive
|
|
7155
|
+
* @param filepath
|
|
7156
|
+
* @param input
|
|
7157
|
+
* @param [opts]
|
|
7158
|
+
*/
|
|
7159
|
+
// eslint-disable-next-line complexity
|
|
7146
7160
|
append(filepath, input, opts) {
|
|
7147
7161
|
let checksum;
|
|
7148
7162
|
if (typeof input === "string") {
|
|
7149
7163
|
input = stringToUint8(input);
|
|
7150
7164
|
} else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) {
|
|
7151
|
-
const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(
|
|
7165
|
+
const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(
|
|
7166
|
+
input.constructor.toString()
|
|
7167
|
+
);
|
|
7152
7168
|
const errorInput = errorInputMatch && errorInputMatch[1];
|
|
7153
7169
|
const errorMessage = `Invalid input type. You gave me: ${errorInput}`;
|
|
7154
7170
|
throw errorMessage;
|
|
@@ -7166,6 +7182,7 @@ var __exports__ = (() => {
|
|
|
7166
7182
|
fileSize: pad(input.length, 11),
|
|
7167
7183
|
mtime: pad(mtime, 11),
|
|
7168
7184
|
checksum: " ",
|
|
7185
|
+
// 0 = just a file
|
|
7169
7186
|
type: "0",
|
|
7170
7187
|
ustar: "ustar ",
|
|
7171
7188
|
owner: opts.owner || "",
|
|
@@ -7191,6 +7208,10 @@ var __exports__ = (() => {
|
|
|
7191
7208
|
inputLength
|
|
7192
7209
|
});
|
|
7193
7210
|
}
|
|
7211
|
+
/**
|
|
7212
|
+
* Compiling data to a Blob object
|
|
7213
|
+
* @returns {Blob}
|
|
7214
|
+
*/
|
|
7194
7215
|
save() {
|
|
7195
7216
|
const buffers = [];
|
|
7196
7217
|
const chunks = new Array();
|
|
@@ -7199,20 +7220,14 @@ var __exports__ = (() => {
|
|
|
7199
7220
|
let chunk = new Array();
|
|
7200
7221
|
this.blocks.forEach((b = []) => {
|
|
7201
7222
|
if (length + b.headerLength + b.inputLength > max) {
|
|
7202
|
-
chunks.push({
|
|
7203
|
-
blocks: chunk,
|
|
7204
|
-
length
|
|
7205
|
-
});
|
|
7223
|
+
chunks.push({ blocks: chunk, length });
|
|
7206
7224
|
chunk = [];
|
|
7207
7225
|
length = 0;
|
|
7208
7226
|
}
|
|
7209
7227
|
chunk.push(b);
|
|
7210
7228
|
length += b.headerLength + b.inputLength;
|
|
7211
7229
|
});
|
|
7212
|
-
chunks.push({
|
|
7213
|
-
blocks: chunk,
|
|
7214
|
-
length
|
|
7215
|
-
});
|
|
7230
|
+
chunks.push({ blocks: chunk, length });
|
|
7216
7231
|
chunks.forEach((c = []) => {
|
|
7217
7232
|
const buffer = new Uint8Array(c.length);
|
|
7218
7233
|
let written = 0;
|
|
@@ -7225,10 +7240,11 @@ var __exports__ = (() => {
|
|
|
7225
7240
|
buffers.push(buffer);
|
|
7226
7241
|
});
|
|
7227
7242
|
buffers.push(new Uint8Array(2 * recordSize));
|
|
7228
|
-
return new Blob(buffers, {
|
|
7229
|
-
type: "octet/stream"
|
|
7230
|
-
});
|
|
7243
|
+
return new Blob(buffers, { type: "octet/stream" });
|
|
7231
7244
|
}
|
|
7245
|
+
/**
|
|
7246
|
+
* Clear the data by its blocksize
|
|
7247
|
+
*/
|
|
7232
7248
|
clear() {
|
|
7233
7249
|
this.written = 0;
|
|
7234
7250
|
this.out = clean(blockSize);
|
|
@@ -7241,6 +7257,11 @@ var __exports__ = (() => {
|
|
|
7241
7257
|
recordsPerBlock: 20
|
|
7242
7258
|
};
|
|
7243
7259
|
var TarBuilder = class {
|
|
7260
|
+
constructor(options) {
|
|
7261
|
+
this.count = 0;
|
|
7262
|
+
this.options = { ...TAR_BUILDER_OPTIONS, ...options };
|
|
7263
|
+
this.tape = new tar_default(this.options.recordsPerBlock);
|
|
7264
|
+
}
|
|
7244
7265
|
static get properties() {
|
|
7245
7266
|
return {
|
|
7246
7267
|
id: "tar",
|
|
@@ -7251,14 +7272,7 @@ var __exports__ = (() => {
|
|
|
7251
7272
|
options: TAR_BUILDER_OPTIONS
|
|
7252
7273
|
};
|
|
7253
7274
|
}
|
|
7254
|
-
|
|
7255
|
-
constructor(options) {
|
|
7256
|
-
this.options = {
|
|
7257
|
-
...TAR_BUILDER_OPTIONS,
|
|
7258
|
-
...options
|
|
7259
|
-
};
|
|
7260
|
-
this.tape = new tar_default(this.options.recordsPerBlock);
|
|
7261
|
-
}
|
|
7275
|
+
/** Adds a file to the archive. */
|
|
7262
7276
|
addFile(filename2, buffer) {
|
|
7263
7277
|
this.tape.append(filename2, new Uint8Array(buffer));
|
|
7264
7278
|
this.count++;
|
|
@@ -7279,7 +7293,10 @@ var __exports__ = (() => {
|
|
|
7279
7293
|
var window_ = globals.window || globals.self || globals.global || {};
|
|
7280
7294
|
var global_ = globals.global || globals.self || globals.window || {};
|
|
7281
7295
|
var document_ = globals.document || {};
|
|
7282
|
-
var isBrowser =
|
|
7296
|
+
var isBrowser = (
|
|
7297
|
+
// @ts-ignore process does not exist on browser
|
|
7298
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
7299
|
+
);
|
|
7283
7300
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
7284
7301
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
7285
7302
|
|
|
@@ -7302,7 +7319,9 @@ var __exports__ = (() => {
|
|
|
7302
7319
|
return concatenateArrayBuffersFromArray(sources);
|
|
7303
7320
|
}
|
|
7304
7321
|
function concatenateArrayBuffersFromArray(sources) {
|
|
7305
|
-
const sourceArrays = sources.map(
|
|
7322
|
+
const sourceArrays = sources.map(
|
|
7323
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
7324
|
+
);
|
|
7306
7325
|
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
7307
7326
|
const result = new Uint8Array(byteLength);
|
|
7308
7327
|
let offset = 0;
|
|
@@ -7322,22 +7341,6 @@ var __exports__ = (() => {
|
|
|
7322
7341
|
return concatenateArrayBuffers(...arrayBuffers);
|
|
7323
7342
|
}
|
|
7324
7343
|
|
|
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
7344
|
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
7342
7345
|
function toArrayBuffer(buffer) {
|
|
7343
7346
|
return buffer;
|
|
@@ -7373,7 +7376,9 @@ var __exports__ = (() => {
|
|
|
7373
7376
|
|
|
7374
7377
|
// ../loader-utils/src/lib/node/promisify.ts
|
|
7375
7378
|
function promisify1(fn) {
|
|
7376
|
-
return (args) => new Promise(
|
|
7379
|
+
return (args) => new Promise(
|
|
7380
|
+
(resolve2, reject) => fn(args, (error, callbackArgs) => error ? reject(error) : resolve2(callbackArgs))
|
|
7381
|
+
);
|
|
7377
7382
|
}
|
|
7378
7383
|
|
|
7379
7384
|
// ../loader-utils/src/lib/path-utils/path.ts
|
|
@@ -7522,10 +7527,10 @@ var __exports__ = (() => {
|
|
|
7522
7527
|
// ../loader-utils/src/lib/files/node-file-facade.ts
|
|
7523
7528
|
var NOT_IMPLEMENTED = new Error("Not implemented");
|
|
7524
7529
|
var NodeFileFacade = class {
|
|
7525
|
-
size = 0;
|
|
7526
|
-
bigsize = 0n;
|
|
7527
|
-
url = "";
|
|
7528
7530
|
constructor(url, flags, mode) {
|
|
7531
|
+
this.size = 0;
|
|
7532
|
+
this.bigsize = 0n;
|
|
7533
|
+
this.url = "";
|
|
7529
7534
|
if (globalThis.loaders?.NodeFile) {
|
|
7530
7535
|
return new globalThis.loaders.NodeFile(url, flags, mode);
|
|
7531
7536
|
}
|
|
@@ -7534,21 +7539,27 @@ var __exports__ = (() => {
|
|
|
7534
7539
|
}
|
|
7535
7540
|
throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
|
|
7536
7541
|
}
|
|
7542
|
+
/** Read data */
|
|
7537
7543
|
async read(start, end) {
|
|
7538
7544
|
throw NOT_IMPLEMENTED;
|
|
7539
7545
|
}
|
|
7546
|
+
/** Write to file. The number of bytes written will be returned */
|
|
7540
7547
|
async write(arrayBuffer, offset, length) {
|
|
7541
7548
|
throw NOT_IMPLEMENTED;
|
|
7542
7549
|
}
|
|
7550
|
+
/** Get information about file */
|
|
7543
7551
|
async stat() {
|
|
7544
7552
|
throw NOT_IMPLEMENTED;
|
|
7545
7553
|
}
|
|
7554
|
+
/** Truncates the file descriptor. Only available on NodeFile. */
|
|
7546
7555
|
async truncate(length) {
|
|
7547
7556
|
throw NOT_IMPLEMENTED;
|
|
7548
7557
|
}
|
|
7558
|
+
/** Append data to a file. Only available on NodeFile. */
|
|
7549
7559
|
async append(data) {
|
|
7550
7560
|
throw NOT_IMPLEMENTED;
|
|
7551
7561
|
}
|
|
7562
|
+
/** Close the file */
|
|
7552
7563
|
async close() {
|
|
7553
7564
|
}
|
|
7554
7565
|
};
|
|
@@ -7556,23 +7567,30 @@ var __exports__ = (() => {
|
|
|
7556
7567
|
// ../loader-utils/src/lib/filesystems/node-filesystem-facade.ts
|
|
7557
7568
|
var NOT_IMPLEMENTED2 = new Error("Not implemented");
|
|
7558
7569
|
var NodeFileSystemFacade = class {
|
|
7570
|
+
// implements FileSystem
|
|
7559
7571
|
constructor(options) {
|
|
7572
|
+
// DUMMY IMPLEMENTATION, not used (constructor returns a real NodeFileSystem instance)
|
|
7573
|
+
// implements RandomAccessReadFileSystem
|
|
7574
|
+
this.readable = true;
|
|
7575
|
+
this.writable = true;
|
|
7560
7576
|
if (globalThis.loaders?.NodeFileSystem) {
|
|
7561
7577
|
return new globalThis.loaders.NodeFileSystem(options);
|
|
7562
7578
|
}
|
|
7563
7579
|
if (isBrowser) {
|
|
7564
7580
|
throw new Error("Can't instantiate NodeFileSystem in browser.");
|
|
7565
7581
|
}
|
|
7566
|
-
throw new Error(
|
|
7582
|
+
throw new Error(
|
|
7583
|
+
"Can't instantiate NodeFileSystem. Make sure to import @loaders.gl/polyfills first."
|
|
7584
|
+
);
|
|
7567
7585
|
}
|
|
7568
|
-
readable = true;
|
|
7569
|
-
writable = true;
|
|
7570
7586
|
async openReadableFile(path, flags) {
|
|
7571
7587
|
throw NOT_IMPLEMENTED2;
|
|
7572
7588
|
}
|
|
7589
|
+
// implements RandomAccessWriteFileSystem
|
|
7573
7590
|
async openWritableFile(path, flags, mode) {
|
|
7574
7591
|
throw NOT_IMPLEMENTED2;
|
|
7575
7592
|
}
|
|
7593
|
+
// Implements file system
|
|
7576
7594
|
async readdir(dirname2 = ".", options) {
|
|
7577
7595
|
throw NOT_IMPLEMENTED2;
|
|
7578
7596
|
}
|
|
@@ -7594,18 +7612,32 @@ var __exports__ = (() => {
|
|
|
7594
7612
|
|
|
7595
7613
|
// ../loader-utils/src/lib/file-provider/file-handle-file.ts
|
|
7596
7614
|
var FileHandleFile = class {
|
|
7615
|
+
/** Create a new FileHandleFile */
|
|
7597
7616
|
constructor(path, append = false) {
|
|
7598
7617
|
this.file = new NodeFileFacade(path, append ? "a+" : "r");
|
|
7599
7618
|
}
|
|
7619
|
+
/**
|
|
7620
|
+
* Truncates the file descriptor.
|
|
7621
|
+
* @param length desired file lenght
|
|
7622
|
+
*/
|
|
7600
7623
|
async truncate(length) {
|
|
7601
7624
|
await this.file.truncate(length);
|
|
7602
7625
|
}
|
|
7626
|
+
/**
|
|
7627
|
+
* Append data to a file.
|
|
7628
|
+
* @param buffer data to append
|
|
7629
|
+
*/
|
|
7603
7630
|
async append(buffer) {
|
|
7604
7631
|
await this.file.append(buffer);
|
|
7605
7632
|
}
|
|
7633
|
+
/** Close file */
|
|
7606
7634
|
async destroy() {
|
|
7607
7635
|
await this.file.close();
|
|
7608
7636
|
}
|
|
7637
|
+
/**
|
|
7638
|
+
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
7639
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7640
|
+
*/
|
|
7609
7641
|
async getUint8(offset) {
|
|
7610
7642
|
const arrayBuffer = await this.file.read(offset, 1);
|
|
7611
7643
|
const val = new Uint8Array(arrayBuffer).at(0);
|
|
@@ -7614,6 +7646,10 @@ var __exports__ = (() => {
|
|
|
7614
7646
|
}
|
|
7615
7647
|
return val;
|
|
7616
7648
|
}
|
|
7649
|
+
/**
|
|
7650
|
+
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
7651
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7652
|
+
*/
|
|
7617
7653
|
async getUint16(offset) {
|
|
7618
7654
|
const arrayBuffer = await this.file.read(offset, 2);
|
|
7619
7655
|
const val = new Uint16Array(arrayBuffer).at(0);
|
|
@@ -7622,6 +7658,10 @@ var __exports__ = (() => {
|
|
|
7622
7658
|
}
|
|
7623
7659
|
return val;
|
|
7624
7660
|
}
|
|
7661
|
+
/**
|
|
7662
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
7663
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7664
|
+
*/
|
|
7625
7665
|
async getUint32(offset) {
|
|
7626
7666
|
const arrayBuffer = await this.file.read(offset, 4);
|
|
7627
7667
|
const val = new Uint32Array(arrayBuffer).at(0);
|
|
@@ -7630,6 +7670,10 @@ var __exports__ = (() => {
|
|
|
7630
7670
|
}
|
|
7631
7671
|
return val;
|
|
7632
7672
|
}
|
|
7673
|
+
/**
|
|
7674
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
7675
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
7676
|
+
*/
|
|
7633
7677
|
async getBigUint64(offset) {
|
|
7634
7678
|
const arrayBuffer = await this.file.read(offset, 8);
|
|
7635
7679
|
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
@@ -7638,6 +7682,11 @@ var __exports__ = (() => {
|
|
|
7638
7682
|
}
|
|
7639
7683
|
return val;
|
|
7640
7684
|
}
|
|
7685
|
+
/**
|
|
7686
|
+
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
7687
|
+
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
7688
|
+
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
7689
|
+
*/
|
|
7641
7690
|
async slice(startOffset, endOffset) {
|
|
7642
7691
|
const bigLength = endOffset - startOffset;
|
|
7643
7692
|
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
@@ -7646,6 +7695,9 @@ var __exports__ = (() => {
|
|
|
7646
7695
|
const length = Number(bigLength);
|
|
7647
7696
|
return await this.file.read(startOffset, length);
|
|
7648
7697
|
}
|
|
7698
|
+
/**
|
|
7699
|
+
* the length (in bytes) of the data.
|
|
7700
|
+
*/
|
|
7649
7701
|
get length() {
|
|
7650
7702
|
return this.file.bigsize;
|
|
7651
7703
|
}
|
|
@@ -7653,7 +7705,12 @@ var __exports__ = (() => {
|
|
|
7653
7705
|
|
|
7654
7706
|
// src/parse-zip/search-from-the-end.ts
|
|
7655
7707
|
var searchFromTheEnd = async (file, target) => {
|
|
7656
|
-
const searchWindow = [
|
|
7708
|
+
const searchWindow = [
|
|
7709
|
+
await file.getUint8(file.length - 1n),
|
|
7710
|
+
await file.getUint8(file.length - 2n),
|
|
7711
|
+
await file.getUint8(file.length - 3n),
|
|
7712
|
+
void 0
|
|
7713
|
+
];
|
|
7657
7714
|
let targetOffset = 0n;
|
|
7658
7715
|
for (let i = file.length - 4n; i > -1; i--) {
|
|
7659
7716
|
searchWindow[3] = searchWindow[2];
|
|
@@ -7700,22 +7757,33 @@ var __exports__ = (() => {
|
|
|
7700
7757
|
header.setBigUint64(offset, BigInt(value), true);
|
|
7701
7758
|
}
|
|
7702
7759
|
};
|
|
7703
|
-
var ZIP64_FIELDS = [
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7760
|
+
var ZIP64_FIELDS = [
|
|
7761
|
+
// Header ID 0x0001
|
|
7762
|
+
{
|
|
7763
|
+
size: 2,
|
|
7764
|
+
default: new DataView(signature.buffer).getUint16(0, true)
|
|
7765
|
+
},
|
|
7766
|
+
// Size of the extra field chunk (8, 16, 24 or 28)
|
|
7767
|
+
{
|
|
7768
|
+
size: 2,
|
|
7769
|
+
name: "zip64Length"
|
|
7770
|
+
},
|
|
7771
|
+
// Original uncompressed file size
|
|
7772
|
+
{
|
|
7773
|
+
size: 8,
|
|
7774
|
+
name: "size"
|
|
7775
|
+
},
|
|
7776
|
+
// Size of compressed data
|
|
7777
|
+
{
|
|
7778
|
+
size: 8,
|
|
7779
|
+
name: "size"
|
|
7780
|
+
},
|
|
7781
|
+
// Offset of local header record
|
|
7782
|
+
{
|
|
7783
|
+
size: 8,
|
|
7784
|
+
name: "offset"
|
|
7785
|
+
}
|
|
7786
|
+
];
|
|
7719
7787
|
|
|
7720
7788
|
// src/parse-zip/end-of-central-directory.ts
|
|
7721
7789
|
var eoCDSignature = new Uint8Array([80, 75, 5, 6]);
|
|
@@ -7740,7 +7808,9 @@ var __exports__ = (() => {
|
|
|
7740
7808
|
let zip64EoCDOffset = 0n;
|
|
7741
7809
|
const magicBytes = await file.slice(zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
|
|
7742
7810
|
if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature)) {
|
|
7743
|
-
zip64EoCDOffset = await file.getBigUint64(
|
|
7811
|
+
zip64EoCDOffset = await file.getBigUint64(
|
|
7812
|
+
zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
|
|
7813
|
+
);
|
|
7744
7814
|
const endOfCDMagicBytes = await file.slice(zip64EoCDOffset, zip64EoCDOffset + 4n);
|
|
7745
7815
|
if (!compareArrayBuffers(endOfCDMagicBytes, zip64EoCDSignature.buffer)) {
|
|
7746
7816
|
throw new Error("zip64 EoCD not found");
|
|
@@ -7765,10 +7835,20 @@ var __exports__ = (() => {
|
|
|
7765
7835
|
const classicEoCDOffset = oldEoCDOffsets.zip64EoCDOffset ? oldEoCDOffsets.zipEoCDOffset - oldEoCDOffsets.zip64EoCDOffset : 0n;
|
|
7766
7836
|
if (Number(newCDRecordsNumber) <= 65535) {
|
|
7767
7837
|
setFieldToNumber(eocd, 2, classicEoCDOffset + CD_RECORDS_NUMBER_OFFSET, newCDRecordsNumber);
|
|
7768
|
-
setFieldToNumber(
|
|
7838
|
+
setFieldToNumber(
|
|
7839
|
+
eocd,
|
|
7840
|
+
2,
|
|
7841
|
+
classicEoCDOffset + CD_RECORDS_NUMBER_ON_DISC_OFFSET,
|
|
7842
|
+
newCDRecordsNumber
|
|
7843
|
+
);
|
|
7769
7844
|
}
|
|
7770
7845
|
if (eocdStartOffset - newCDStartOffset <= 4294967295) {
|
|
7771
|
-
setFieldToNumber(
|
|
7846
|
+
setFieldToNumber(
|
|
7847
|
+
eocd,
|
|
7848
|
+
4,
|
|
7849
|
+
classicEoCDOffset + CD_CD_BYTE_SIZE_OFFSET,
|
|
7850
|
+
eocdStartOffset - newCDStartOffset
|
|
7851
|
+
);
|
|
7772
7852
|
}
|
|
7773
7853
|
if (newCDStartOffset < 4294967295) {
|
|
7774
7854
|
setFieldToNumber(eocd, 4, classicEoCDOffset + CD_START_OFFSET_OFFSET, newCDStartOffset);
|
|
@@ -7786,117 +7866,179 @@ var __exports__ = (() => {
|
|
|
7786
7866
|
function generateEoCD(options) {
|
|
7787
7867
|
const header = new DataView(new ArrayBuffer(Number(CD_COMMENT_OFFSET)));
|
|
7788
7868
|
for (const field of EOCD_FIELDS) {
|
|
7789
|
-
setFieldToNumber(
|
|
7869
|
+
setFieldToNumber(
|
|
7870
|
+
header,
|
|
7871
|
+
field.size,
|
|
7872
|
+
field.offset,
|
|
7873
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7874
|
+
);
|
|
7790
7875
|
}
|
|
7791
7876
|
const locator = generateZip64InfoLocator(options);
|
|
7792
7877
|
const zip64Record = generateZip64Info(options);
|
|
7793
7878
|
return concatenateArrayBuffers(zip64Record, locator, header.buffer);
|
|
7794
7879
|
}
|
|
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
|
-
|
|
7880
|
+
var EOCD_FIELDS = [
|
|
7881
|
+
// End of central directory signature = 0x06054b50
|
|
7882
|
+
{
|
|
7883
|
+
offset: 0,
|
|
7884
|
+
size: 4,
|
|
7885
|
+
default: new DataView(eoCDSignature.buffer).getUint32(0, true)
|
|
7886
|
+
},
|
|
7887
|
+
// Number of this disk (or 0xffff for ZIP64)
|
|
7888
|
+
{
|
|
7889
|
+
offset: 4,
|
|
7890
|
+
size: 2,
|
|
7891
|
+
default: 0
|
|
7892
|
+
},
|
|
7893
|
+
// Disk where central directory starts (or 0xffff for ZIP64)
|
|
7894
|
+
{
|
|
7895
|
+
offset: 6,
|
|
7896
|
+
size: 2,
|
|
7897
|
+
default: 0
|
|
7898
|
+
},
|
|
7899
|
+
// Number of central directory records on this disk (or 0xffff for ZIP64)
|
|
7900
|
+
{
|
|
7901
|
+
offset: 8,
|
|
7902
|
+
size: 2,
|
|
7903
|
+
name: "recordsNumber"
|
|
7904
|
+
},
|
|
7905
|
+
// Total number of central directory records (or 0xffff for ZIP64)
|
|
7906
|
+
{
|
|
7907
|
+
offset: 10,
|
|
7908
|
+
size: 2,
|
|
7909
|
+
name: "recordsNumber"
|
|
7910
|
+
},
|
|
7911
|
+
// Size of central directory (bytes) (or 0xffffffff for ZIP64)
|
|
7912
|
+
{
|
|
7913
|
+
offset: 12,
|
|
7914
|
+
size: 4,
|
|
7915
|
+
name: "cdSize"
|
|
7916
|
+
},
|
|
7917
|
+
// Offset of start of central directory, relative to start of archive (or 0xffffffff for ZIP64)
|
|
7918
|
+
{
|
|
7919
|
+
offset: 16,
|
|
7920
|
+
size: 4,
|
|
7921
|
+
name: "cdOffset"
|
|
7922
|
+
},
|
|
7923
|
+
// Comment length (n)
|
|
7924
|
+
{
|
|
7925
|
+
offset: 20,
|
|
7926
|
+
size: 2,
|
|
7927
|
+
default: 0
|
|
7928
|
+
}
|
|
7929
|
+
];
|
|
7828
7930
|
function generateZip64Info(options) {
|
|
7829
7931
|
const record = new DataView(new ArrayBuffer(Number(ZIP64_COMMENT_OFFSET)));
|
|
7830
7932
|
for (const field of ZIP64_EOCD_FIELDS) {
|
|
7831
|
-
setFieldToNumber(
|
|
7933
|
+
setFieldToNumber(
|
|
7934
|
+
record,
|
|
7935
|
+
field.size,
|
|
7936
|
+
field.offset,
|
|
7937
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7938
|
+
);
|
|
7832
7939
|
}
|
|
7833
7940
|
return record.buffer;
|
|
7834
7941
|
}
|
|
7835
7942
|
function generateZip64InfoLocator(options) {
|
|
7836
7943
|
const locator = new DataView(new ArrayBuffer(Number(20)));
|
|
7837
7944
|
for (const field of ZIP64_EOCD_LOCATOR_FIELDS) {
|
|
7838
|
-
setFieldToNumber(
|
|
7945
|
+
setFieldToNumber(
|
|
7946
|
+
locator,
|
|
7947
|
+
field.size,
|
|
7948
|
+
field.offset,
|
|
7949
|
+
options[field.name ?? ""] ?? field.default ?? 0
|
|
7950
|
+
);
|
|
7839
7951
|
}
|
|
7840
7952
|
return locator.buffer;
|
|
7841
7953
|
}
|
|
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
|
-
|
|
7954
|
+
var ZIP64_EOCD_LOCATOR_FIELDS = [
|
|
7955
|
+
// zip64 end of central dir locator signature
|
|
7956
|
+
{
|
|
7957
|
+
offset: 0,
|
|
7958
|
+
size: 4,
|
|
7959
|
+
default: new DataView(zip64EoCDLocatorSignature.buffer).getUint32(0, true)
|
|
7960
|
+
},
|
|
7961
|
+
// number of the disk with the start of the zip64 end of
|
|
7962
|
+
{
|
|
7963
|
+
offset: 4,
|
|
7964
|
+
size: 4,
|
|
7965
|
+
default: 0
|
|
7966
|
+
},
|
|
7967
|
+
// start of the zip64 end of central directory
|
|
7968
|
+
{
|
|
7969
|
+
offset: 8,
|
|
7970
|
+
size: 8,
|
|
7971
|
+
name: "eoCDStart"
|
|
7972
|
+
},
|
|
7973
|
+
// total number of disks
|
|
7974
|
+
{
|
|
7975
|
+
offset: 16,
|
|
7976
|
+
size: 4,
|
|
7977
|
+
default: 1
|
|
7978
|
+
}
|
|
7979
|
+
];
|
|
7980
|
+
var ZIP64_EOCD_FIELDS = [
|
|
7981
|
+
// End of central directory signature = 0x06064b50
|
|
7982
|
+
{
|
|
7983
|
+
offset: 0,
|
|
7984
|
+
size: 4,
|
|
7985
|
+
default: new DataView(zip64EoCDSignature.buffer).getUint32(0, true)
|
|
7986
|
+
},
|
|
7987
|
+
// Size of the EOCD64 minus 12
|
|
7988
|
+
{
|
|
7989
|
+
offset: 4,
|
|
7990
|
+
size: 8,
|
|
7991
|
+
default: 44
|
|
7992
|
+
},
|
|
7993
|
+
// Version made by
|
|
7994
|
+
{
|
|
7995
|
+
offset: 12,
|
|
7996
|
+
size: 2,
|
|
7997
|
+
default: 45
|
|
7998
|
+
},
|
|
7999
|
+
// Version needed to extract (minimum)
|
|
8000
|
+
{
|
|
8001
|
+
offset: 14,
|
|
8002
|
+
size: 2,
|
|
8003
|
+
default: 45
|
|
8004
|
+
},
|
|
8005
|
+
// Number of this disk
|
|
8006
|
+
{
|
|
8007
|
+
offset: 16,
|
|
8008
|
+
size: 4,
|
|
8009
|
+
default: 0
|
|
8010
|
+
},
|
|
8011
|
+
// Disk where central directory starts
|
|
8012
|
+
{
|
|
8013
|
+
offset: 20,
|
|
8014
|
+
size: 4,
|
|
8015
|
+
default: 0
|
|
8016
|
+
},
|
|
8017
|
+
// Number of central directory records on this disk
|
|
8018
|
+
{
|
|
8019
|
+
offset: 24,
|
|
8020
|
+
size: 8,
|
|
8021
|
+
name: "recordsNumber"
|
|
8022
|
+
},
|
|
8023
|
+
// Total number of central directory records
|
|
8024
|
+
{
|
|
8025
|
+
offset: 32,
|
|
8026
|
+
size: 8,
|
|
8027
|
+
name: "recordsNumber"
|
|
8028
|
+
},
|
|
8029
|
+
// Size of central directory (bytes)
|
|
8030
|
+
{
|
|
8031
|
+
offset: 40,
|
|
8032
|
+
size: 8,
|
|
8033
|
+
name: "cdSize"
|
|
8034
|
+
},
|
|
8035
|
+
// Offset of start of central directory, relative to start of archive
|
|
8036
|
+
{
|
|
8037
|
+
offset: 48,
|
|
8038
|
+
size: 8,
|
|
8039
|
+
name: "cdOffset"
|
|
8040
|
+
}
|
|
8041
|
+
];
|
|
7900
8042
|
|
|
7901
8043
|
// src/parse-zip/cd-file-header.ts
|
|
7902
8044
|
var CD_COMPRESSED_SIZE_OFFSET = 20n;
|
|
@@ -7917,12 +8059,17 @@ var __exports__ = (() => {
|
|
|
7917
8059
|
const extraFieldLength = await file.getUint16(headerOffset + CD_EXTRA_FIELD_LENGTH_OFFSET);
|
|
7918
8060
|
const startDisk = BigInt(await file.getUint16(headerOffset + CD_START_DISK_OFFSET));
|
|
7919
8061
|
const fileNameLength = await file.getUint16(headerOffset + CD_FILE_NAME_LENGTH_OFFSET);
|
|
7920
|
-
const filenameBytes = await file.slice(
|
|
8062
|
+
const filenameBytes = await file.slice(
|
|
8063
|
+
headerOffset + CD_FILE_NAME_OFFSET,
|
|
8064
|
+
headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength)
|
|
8065
|
+
);
|
|
7921
8066
|
const fileName = new TextDecoder().decode(filenameBytes);
|
|
7922
8067
|
const extraOffset = headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
|
|
7923
8068
|
const oldFormatOffset = await file.getUint32(headerOffset + CD_LOCAL_HEADER_OFFSET_OFFSET);
|
|
7924
8069
|
const localHeaderOffset = BigInt(oldFormatOffset);
|
|
7925
|
-
const extraField = new DataView(
|
|
8070
|
+
const extraField = new DataView(
|
|
8071
|
+
await file.slice(extraOffset, extraOffset + BigInt(extraFieldLength))
|
|
8072
|
+
);
|
|
7926
8073
|
const zip64data = {
|
|
7927
8074
|
uncompressedSize,
|
|
7928
8075
|
compressedSize,
|
|
@@ -7940,13 +8087,14 @@ var __exports__ = (() => {
|
|
|
7940
8087
|
};
|
|
7941
8088
|
};
|
|
7942
8089
|
async function* makeZipCDHeaderIterator(fileProvider) {
|
|
7943
|
-
const {
|
|
7944
|
-
cdStartOffset
|
|
7945
|
-
} = await parseEoCDRecord(fileProvider);
|
|
8090
|
+
const { cdStartOffset } = await parseEoCDRecord(fileProvider);
|
|
7946
8091
|
let cdHeader = await parseZipCDFileHeader(cdStartOffset, fileProvider);
|
|
7947
8092
|
while (cdHeader) {
|
|
7948
8093
|
yield cdHeader;
|
|
7949
|
-
cdHeader = await parseZipCDFileHeader(
|
|
8094
|
+
cdHeader = await parseZipCDFileHeader(
|
|
8095
|
+
cdHeader.extraOffset + BigInt(cdHeader.extraFieldLength),
|
|
8096
|
+
fileProvider
|
|
8097
|
+
);
|
|
7950
8098
|
}
|
|
7951
8099
|
}
|
|
7952
8100
|
var getUint16 = (...bytes) => {
|
|
@@ -7957,7 +8105,9 @@ var __exports__ = (() => {
|
|
|
7957
8105
|
const zip64DataRes = {};
|
|
7958
8106
|
if (zip64dataList.length > 0) {
|
|
7959
8107
|
const zip64chunkSize = zip64dataList.reduce((sum, curr) => sum + curr.length, 0);
|
|
7960
|
-
const offsetInExtraData = new Uint8Array(extraField.buffer).findIndex(
|
|
8108
|
+
const offsetInExtraData = new Uint8Array(extraField.buffer).findIndex(
|
|
8109
|
+
(_val, i, arr) => getUint16(arr[i], arr[i + 1]) === 1 && getUint16(arr[i + 2], arr[i + 3]) === zip64chunkSize
|
|
8110
|
+
);
|
|
7961
8111
|
let bytesRead = 0;
|
|
7962
8112
|
for (const note of zip64dataList) {
|
|
7963
8113
|
const offset = bytesRead;
|
|
@@ -7970,28 +8120,16 @@ var __exports__ = (() => {
|
|
|
7970
8120
|
var findExpectedData = (zip64data) => {
|
|
7971
8121
|
const zip64dataList = [];
|
|
7972
8122
|
if (zip64data.uncompressedSize === BigInt(4294967295)) {
|
|
7973
|
-
zip64dataList.push({
|
|
7974
|
-
name: "uncompressedSize",
|
|
7975
|
-
length: 8
|
|
7976
|
-
});
|
|
8123
|
+
zip64dataList.push({ name: "uncompressedSize", length: 8 });
|
|
7977
8124
|
}
|
|
7978
8125
|
if (zip64data.compressedSize === BigInt(4294967295)) {
|
|
7979
|
-
zip64dataList.push({
|
|
7980
|
-
name: "compressedSize",
|
|
7981
|
-
length: 8
|
|
7982
|
-
});
|
|
8126
|
+
zip64dataList.push({ name: "compressedSize", length: 8 });
|
|
7983
8127
|
}
|
|
7984
8128
|
if (zip64data.localHeaderOffset === BigInt(4294967295)) {
|
|
7985
|
-
zip64dataList.push({
|
|
7986
|
-
name: "localHeaderOffset",
|
|
7987
|
-
length: 8
|
|
7988
|
-
});
|
|
8129
|
+
zip64dataList.push({ name: "localHeaderOffset", length: 8 });
|
|
7989
8130
|
}
|
|
7990
8131
|
if (zip64data.startDisk === BigInt(4294967295)) {
|
|
7991
|
-
zip64dataList.push({
|
|
7992
|
-
name: "startDisk",
|
|
7993
|
-
length: 4
|
|
7994
|
-
});
|
|
8132
|
+
zip64dataList.push({ name: "startDisk", length: 4 });
|
|
7995
8133
|
}
|
|
7996
8134
|
return zip64dataList;
|
|
7997
8135
|
};
|
|
@@ -8017,82 +8155,122 @@ var __exports__ = (() => {
|
|
|
8017
8155
|
}
|
|
8018
8156
|
const header = new DataView(new ArrayBuffer(Number(CD_FILE_NAME_OFFSET)));
|
|
8019
8157
|
for (const field of ZIP_HEADER_FIELDS) {
|
|
8020
|
-
setFieldToNumber(
|
|
8158
|
+
setFieldToNumber(
|
|
8159
|
+
header,
|
|
8160
|
+
field.size,
|
|
8161
|
+
field.offset,
|
|
8162
|
+
optionsToUse[field.name ?? ""] ?? field.default ?? 0
|
|
8163
|
+
);
|
|
8021
8164
|
}
|
|
8022
8165
|
const encodedName = new TextEncoder().encode(optionsToUse.fileName);
|
|
8023
8166
|
const resHeader = concatenateArrayBuffers(header.buffer, encodedName, zip64header);
|
|
8024
8167
|
return resHeader;
|
|
8025
8168
|
}
|
|
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
|
-
|
|
8169
|
+
var ZIP_HEADER_FIELDS = [
|
|
8170
|
+
// Central directory file header signature = 0x02014b50
|
|
8171
|
+
{
|
|
8172
|
+
offset: 0,
|
|
8173
|
+
size: 4,
|
|
8174
|
+
default: new DataView(signature2.buffer).getUint32(0, true)
|
|
8175
|
+
},
|
|
8176
|
+
// Version made by
|
|
8177
|
+
{
|
|
8178
|
+
offset: 4,
|
|
8179
|
+
size: 2,
|
|
8180
|
+
default: 45
|
|
8181
|
+
},
|
|
8182
|
+
// Version needed to extract (minimum)
|
|
8183
|
+
{
|
|
8184
|
+
offset: 6,
|
|
8185
|
+
size: 2,
|
|
8186
|
+
default: 45
|
|
8187
|
+
},
|
|
8188
|
+
// General purpose bit flag
|
|
8189
|
+
{
|
|
8190
|
+
offset: 8,
|
|
8191
|
+
size: 2,
|
|
8192
|
+
default: 0
|
|
8193
|
+
},
|
|
8194
|
+
// Compression method
|
|
8195
|
+
{
|
|
8196
|
+
offset: 10,
|
|
8197
|
+
size: 2,
|
|
8198
|
+
default: 0
|
|
8199
|
+
},
|
|
8200
|
+
// File last modification time
|
|
8201
|
+
{
|
|
8202
|
+
offset: 12,
|
|
8203
|
+
size: 2,
|
|
8204
|
+
default: 0
|
|
8205
|
+
},
|
|
8206
|
+
// File last modification date
|
|
8207
|
+
{
|
|
8208
|
+
offset: 14,
|
|
8209
|
+
size: 2,
|
|
8210
|
+
default: 0
|
|
8211
|
+
},
|
|
8212
|
+
// CRC-32 of uncompressed data
|
|
8213
|
+
{
|
|
8214
|
+
offset: 16,
|
|
8215
|
+
size: 4,
|
|
8216
|
+
name: "crc32"
|
|
8217
|
+
},
|
|
8218
|
+
// Compressed size (or 0xffffffff for ZIP64)
|
|
8219
|
+
{
|
|
8220
|
+
offset: 20,
|
|
8221
|
+
size: 4,
|
|
8222
|
+
name: "length"
|
|
8223
|
+
},
|
|
8224
|
+
// Uncompressed size (or 0xffffffff for ZIP64)
|
|
8225
|
+
{
|
|
8226
|
+
offset: 24,
|
|
8227
|
+
size: 4,
|
|
8228
|
+
name: "length"
|
|
8229
|
+
},
|
|
8230
|
+
// File name length (n)
|
|
8231
|
+
{
|
|
8232
|
+
offset: 28,
|
|
8233
|
+
size: 2,
|
|
8234
|
+
name: "fnlength"
|
|
8235
|
+
},
|
|
8236
|
+
// Extra field length (m)
|
|
8237
|
+
{
|
|
8238
|
+
offset: 30,
|
|
8239
|
+
size: 2,
|
|
8240
|
+
default: 0,
|
|
8241
|
+
name: "extraLength"
|
|
8242
|
+
},
|
|
8243
|
+
// File comment length (k)
|
|
8244
|
+
{
|
|
8245
|
+
offset: 32,
|
|
8246
|
+
size: 2,
|
|
8247
|
+
default: 0
|
|
8248
|
+
},
|
|
8249
|
+
// Disk number where file starts (or 0xffff for ZIP64)
|
|
8250
|
+
{
|
|
8251
|
+
offset: 34,
|
|
8252
|
+
size: 2,
|
|
8253
|
+
default: 0
|
|
8254
|
+
},
|
|
8255
|
+
// Internal file attributes
|
|
8256
|
+
{
|
|
8257
|
+
offset: 36,
|
|
8258
|
+
size: 2,
|
|
8259
|
+
default: 0
|
|
8260
|
+
},
|
|
8261
|
+
// External file attributes
|
|
8262
|
+
{
|
|
8263
|
+
offset: 38,
|
|
8264
|
+
size: 4,
|
|
8265
|
+
default: 0
|
|
8266
|
+
},
|
|
8267
|
+
// Relative offset of local file header
|
|
8268
|
+
{
|
|
8269
|
+
offset: 42,
|
|
8270
|
+
size: 4,
|
|
8271
|
+
name: "offset"
|
|
8272
|
+
}
|
|
8273
|
+
];
|
|
8096
8274
|
|
|
8097
8275
|
// src/parse-zip/local-file-header.ts
|
|
8098
8276
|
var COMPRESSION_METHOD_OFFSET = 8n;
|
|
@@ -8108,7 +8286,12 @@ var __exports__ = (() => {
|
|
|
8108
8286
|
return null;
|
|
8109
8287
|
}
|
|
8110
8288
|
const fileNameLength = await buffer.getUint16(headerOffset + FILE_NAME_LENGTH_OFFSET);
|
|
8111
|
-
const fileName = new TextDecoder().decode(
|
|
8289
|
+
const fileName = new TextDecoder().decode(
|
|
8290
|
+
await buffer.slice(
|
|
8291
|
+
headerOffset + FILE_NAME_OFFSET,
|
|
8292
|
+
headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength)
|
|
8293
|
+
)
|
|
8294
|
+
).split("\\").join("/");
|
|
8112
8295
|
const extraFieldLength = await buffer.getUint16(headerOffset + EXTRA_FIELD_LENGTH_OFFSET);
|
|
8113
8296
|
let fileDataOffset = headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength);
|
|
8114
8297
|
const compressionMethod = await buffer.getUint16(headerOffset + COMPRESSION_METHOD_OFFSET);
|
|
@@ -8154,58 +8337,86 @@ var __exports__ = (() => {
|
|
|
8154
8337
|
}
|
|
8155
8338
|
const header = new DataView(new ArrayBuffer(Number(FILE_NAME_OFFSET)));
|
|
8156
8339
|
for (const field of ZIP_HEADER_FIELDS2) {
|
|
8157
|
-
setFieldToNumber(
|
|
8340
|
+
setFieldToNumber(
|
|
8341
|
+
header,
|
|
8342
|
+
field.size,
|
|
8343
|
+
field.offset,
|
|
8344
|
+
optionsToUse[field.name ?? ""] ?? field.default ?? 0
|
|
8345
|
+
);
|
|
8158
8346
|
}
|
|
8159
8347
|
const encodedName = new TextEncoder().encode(optionsToUse.fileName);
|
|
8160
8348
|
const resHeader = concatenateArrayBuffers(header.buffer, encodedName, zip64header);
|
|
8161
8349
|
return resHeader;
|
|
8162
8350
|
}
|
|
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
|
-
|
|
8351
|
+
var ZIP_HEADER_FIELDS2 = [
|
|
8352
|
+
// Local file header signature = 0x04034b50
|
|
8353
|
+
{
|
|
8354
|
+
offset: 0,
|
|
8355
|
+
size: 4,
|
|
8356
|
+
default: new DataView(signature3.buffer).getUint32(0, true)
|
|
8357
|
+
},
|
|
8358
|
+
// Version needed to extract (minimum)
|
|
8359
|
+
{
|
|
8360
|
+
offset: 4,
|
|
8361
|
+
size: 2,
|
|
8362
|
+
default: 45
|
|
8363
|
+
},
|
|
8364
|
+
// General purpose bit flag
|
|
8365
|
+
{
|
|
8366
|
+
offset: 6,
|
|
8367
|
+
size: 2,
|
|
8368
|
+
default: 0
|
|
8369
|
+
},
|
|
8370
|
+
// Compression method
|
|
8371
|
+
{
|
|
8372
|
+
offset: 8,
|
|
8373
|
+
size: 2,
|
|
8374
|
+
default: 0
|
|
8375
|
+
},
|
|
8376
|
+
// File last modification time
|
|
8377
|
+
{
|
|
8378
|
+
offset: 10,
|
|
8379
|
+
size: 2,
|
|
8380
|
+
default: 0
|
|
8381
|
+
},
|
|
8382
|
+
// File last modification date
|
|
8383
|
+
{
|
|
8384
|
+
offset: 12,
|
|
8385
|
+
size: 2,
|
|
8386
|
+
default: 0
|
|
8387
|
+
},
|
|
8388
|
+
// CRC-32 of uncompressed data
|
|
8389
|
+
{
|
|
8390
|
+
offset: 14,
|
|
8391
|
+
size: 4,
|
|
8392
|
+
name: "crc32"
|
|
8393
|
+
},
|
|
8394
|
+
// Compressed size (or 0xffffffff for ZIP64)
|
|
8395
|
+
{
|
|
8396
|
+
offset: 18,
|
|
8397
|
+
size: 4,
|
|
8398
|
+
name: "length"
|
|
8399
|
+
},
|
|
8400
|
+
// Uncompressed size (or 0xffffffff for ZIP64)
|
|
8401
|
+
{
|
|
8402
|
+
offset: 22,
|
|
8403
|
+
size: 4,
|
|
8404
|
+
name: "length"
|
|
8405
|
+
},
|
|
8406
|
+
// File name length (n)
|
|
8407
|
+
{
|
|
8408
|
+
offset: 26,
|
|
8409
|
+
size: 2,
|
|
8410
|
+
name: "fnlength"
|
|
8411
|
+
},
|
|
8412
|
+
// Extra field length (m)
|
|
8413
|
+
{
|
|
8414
|
+
offset: 28,
|
|
8415
|
+
size: 2,
|
|
8416
|
+
default: 0,
|
|
8417
|
+
name: "extraLength"
|
|
8418
|
+
}
|
|
8419
|
+
];
|
|
8209
8420
|
|
|
8210
8421
|
// ../crypto/src/lib/hash.ts
|
|
8211
8422
|
var Hash = class {
|
|
@@ -8223,10 +8434,9 @@ var __exports__ = (() => {
|
|
|
8223
8434
|
}
|
|
8224
8435
|
const output = await this.concatenate(arrayBuffers);
|
|
8225
8436
|
const hash = await this.hash(output, encoding);
|
|
8226
|
-
this.options.crypto?.onEnd?.({
|
|
8227
|
-
hash
|
|
8228
|
-
});
|
|
8437
|
+
this.options.crypto?.onEnd?.({ hash });
|
|
8229
8438
|
}
|
|
8439
|
+
// HELPERS
|
|
8230
8440
|
async concatenate(asyncIterator) {
|
|
8231
8441
|
return await concatenateArrayBuffersAsync(asyncIterator);
|
|
8232
8442
|
}
|
|
@@ -8250,7 +8460,264 @@ var __exports__ = (() => {
|
|
|
8250
8460
|
return this.crc;
|
|
8251
8461
|
}
|
|
8252
8462
|
};
|
|
8253
|
-
var CRC32TAB = Uint32Array.of(
|
|
8463
|
+
var CRC32TAB = Uint32Array.of(
|
|
8464
|
+
0,
|
|
8465
|
+
1996959894,
|
|
8466
|
+
3993919788,
|
|
8467
|
+
2567524794,
|
|
8468
|
+
124634137,
|
|
8469
|
+
1886057615,
|
|
8470
|
+
3915621685,
|
|
8471
|
+
2657392035,
|
|
8472
|
+
249268274,
|
|
8473
|
+
2044508324,
|
|
8474
|
+
3772115230,
|
|
8475
|
+
2547177864,
|
|
8476
|
+
162941995,
|
|
8477
|
+
2125561021,
|
|
8478
|
+
3887607047,
|
|
8479
|
+
2428444049,
|
|
8480
|
+
498536548,
|
|
8481
|
+
1789927666,
|
|
8482
|
+
4089016648,
|
|
8483
|
+
2227061214,
|
|
8484
|
+
450548861,
|
|
8485
|
+
1843258603,
|
|
8486
|
+
4107580753,
|
|
8487
|
+
2211677639,
|
|
8488
|
+
325883990,
|
|
8489
|
+
1684777152,
|
|
8490
|
+
4251122042,
|
|
8491
|
+
2321926636,
|
|
8492
|
+
335633487,
|
|
8493
|
+
1661365465,
|
|
8494
|
+
4195302755,
|
|
8495
|
+
2366115317,
|
|
8496
|
+
997073096,
|
|
8497
|
+
1281953886,
|
|
8498
|
+
3579855332,
|
|
8499
|
+
2724688242,
|
|
8500
|
+
1006888145,
|
|
8501
|
+
1258607687,
|
|
8502
|
+
3524101629,
|
|
8503
|
+
2768942443,
|
|
8504
|
+
901097722,
|
|
8505
|
+
1119000684,
|
|
8506
|
+
3686517206,
|
|
8507
|
+
2898065728,
|
|
8508
|
+
853044451,
|
|
8509
|
+
1172266101,
|
|
8510
|
+
3705015759,
|
|
8511
|
+
2882616665,
|
|
8512
|
+
651767980,
|
|
8513
|
+
1373503546,
|
|
8514
|
+
3369554304,
|
|
8515
|
+
3218104598,
|
|
8516
|
+
565507253,
|
|
8517
|
+
1454621731,
|
|
8518
|
+
3485111705,
|
|
8519
|
+
3099436303,
|
|
8520
|
+
671266974,
|
|
8521
|
+
1594198024,
|
|
8522
|
+
3322730930,
|
|
8523
|
+
2970347812,
|
|
8524
|
+
795835527,
|
|
8525
|
+
1483230225,
|
|
8526
|
+
3244367275,
|
|
8527
|
+
3060149565,
|
|
8528
|
+
1994146192,
|
|
8529
|
+
31158534,
|
|
8530
|
+
2563907772,
|
|
8531
|
+
4023717930,
|
|
8532
|
+
1907459465,
|
|
8533
|
+
112637215,
|
|
8534
|
+
2680153253,
|
|
8535
|
+
3904427059,
|
|
8536
|
+
2013776290,
|
|
8537
|
+
251722036,
|
|
8538
|
+
2517215374,
|
|
8539
|
+
3775830040,
|
|
8540
|
+
2137656763,
|
|
8541
|
+
141376813,
|
|
8542
|
+
2439277719,
|
|
8543
|
+
3865271297,
|
|
8544
|
+
1802195444,
|
|
8545
|
+
476864866,
|
|
8546
|
+
2238001368,
|
|
8547
|
+
4066508878,
|
|
8548
|
+
1812370925,
|
|
8549
|
+
453092731,
|
|
8550
|
+
2181625025,
|
|
8551
|
+
4111451223,
|
|
8552
|
+
1706088902,
|
|
8553
|
+
314042704,
|
|
8554
|
+
2344532202,
|
|
8555
|
+
4240017532,
|
|
8556
|
+
1658658271,
|
|
8557
|
+
366619977,
|
|
8558
|
+
2362670323,
|
|
8559
|
+
4224994405,
|
|
8560
|
+
1303535960,
|
|
8561
|
+
984961486,
|
|
8562
|
+
2747007092,
|
|
8563
|
+
3569037538,
|
|
8564
|
+
1256170817,
|
|
8565
|
+
1037604311,
|
|
8566
|
+
2765210733,
|
|
8567
|
+
3554079995,
|
|
8568
|
+
1131014506,
|
|
8569
|
+
879679996,
|
|
8570
|
+
2909243462,
|
|
8571
|
+
3663771856,
|
|
8572
|
+
1141124467,
|
|
8573
|
+
855842277,
|
|
8574
|
+
2852801631,
|
|
8575
|
+
3708648649,
|
|
8576
|
+
1342533948,
|
|
8577
|
+
654459306,
|
|
8578
|
+
3188396048,
|
|
8579
|
+
3373015174,
|
|
8580
|
+
1466479909,
|
|
8581
|
+
544179635,
|
|
8582
|
+
3110523913,
|
|
8583
|
+
3462522015,
|
|
8584
|
+
1591671054,
|
|
8585
|
+
702138776,
|
|
8586
|
+
2966460450,
|
|
8587
|
+
3352799412,
|
|
8588
|
+
1504918807,
|
|
8589
|
+
783551873,
|
|
8590
|
+
3082640443,
|
|
8591
|
+
3233442989,
|
|
8592
|
+
3988292384,
|
|
8593
|
+
2596254646,
|
|
8594
|
+
62317068,
|
|
8595
|
+
1957810842,
|
|
8596
|
+
3939845945,
|
|
8597
|
+
2647816111,
|
|
8598
|
+
81470997,
|
|
8599
|
+
1943803523,
|
|
8600
|
+
3814918930,
|
|
8601
|
+
2489596804,
|
|
8602
|
+
225274430,
|
|
8603
|
+
2053790376,
|
|
8604
|
+
3826175755,
|
|
8605
|
+
2466906013,
|
|
8606
|
+
167816743,
|
|
8607
|
+
2097651377,
|
|
8608
|
+
4027552580,
|
|
8609
|
+
2265490386,
|
|
8610
|
+
503444072,
|
|
8611
|
+
1762050814,
|
|
8612
|
+
4150417245,
|
|
8613
|
+
2154129355,
|
|
8614
|
+
426522225,
|
|
8615
|
+
1852507879,
|
|
8616
|
+
4275313526,
|
|
8617
|
+
2312317920,
|
|
8618
|
+
282753626,
|
|
8619
|
+
1742555852,
|
|
8620
|
+
4189708143,
|
|
8621
|
+
2394877945,
|
|
8622
|
+
397917763,
|
|
8623
|
+
1622183637,
|
|
8624
|
+
3604390888,
|
|
8625
|
+
2714866558,
|
|
8626
|
+
953729732,
|
|
8627
|
+
1340076626,
|
|
8628
|
+
3518719985,
|
|
8629
|
+
2797360999,
|
|
8630
|
+
1068828381,
|
|
8631
|
+
1219638859,
|
|
8632
|
+
3624741850,
|
|
8633
|
+
2936675148,
|
|
8634
|
+
906185462,
|
|
8635
|
+
1090812512,
|
|
8636
|
+
3747672003,
|
|
8637
|
+
2825379669,
|
|
8638
|
+
829329135,
|
|
8639
|
+
1181335161,
|
|
8640
|
+
3412177804,
|
|
8641
|
+
3160834842,
|
|
8642
|
+
628085408,
|
|
8643
|
+
1382605366,
|
|
8644
|
+
3423369109,
|
|
8645
|
+
3138078467,
|
|
8646
|
+
570562233,
|
|
8647
|
+
1426400815,
|
|
8648
|
+
3317316542,
|
|
8649
|
+
2998733608,
|
|
8650
|
+
733239954,
|
|
8651
|
+
1555261956,
|
|
8652
|
+
3268935591,
|
|
8653
|
+
3050360625,
|
|
8654
|
+
752459403,
|
|
8655
|
+
1541320221,
|
|
8656
|
+
2607071920,
|
|
8657
|
+
3965973030,
|
|
8658
|
+
1969922972,
|
|
8659
|
+
40735498,
|
|
8660
|
+
2617837225,
|
|
8661
|
+
3943577151,
|
|
8662
|
+
1913087877,
|
|
8663
|
+
83908371,
|
|
8664
|
+
2512341634,
|
|
8665
|
+
3803740692,
|
|
8666
|
+
2075208622,
|
|
8667
|
+
213261112,
|
|
8668
|
+
2463272603,
|
|
8669
|
+
3855990285,
|
|
8670
|
+
2094854071,
|
|
8671
|
+
198958881,
|
|
8672
|
+
2262029012,
|
|
8673
|
+
4057260610,
|
|
8674
|
+
1759359992,
|
|
8675
|
+
534414190,
|
|
8676
|
+
2176718541,
|
|
8677
|
+
4139329115,
|
|
8678
|
+
1873836001,
|
|
8679
|
+
414664567,
|
|
8680
|
+
2282248934,
|
|
8681
|
+
4279200368,
|
|
8682
|
+
1711684554,
|
|
8683
|
+
285281116,
|
|
8684
|
+
2405801727,
|
|
8685
|
+
4167216745,
|
|
8686
|
+
1634467795,
|
|
8687
|
+
376229701,
|
|
8688
|
+
2685067896,
|
|
8689
|
+
3608007406,
|
|
8690
|
+
1308918612,
|
|
8691
|
+
956543938,
|
|
8692
|
+
2808555105,
|
|
8693
|
+
3495958263,
|
|
8694
|
+
1231636301,
|
|
8695
|
+
1047427035,
|
|
8696
|
+
2932959818,
|
|
8697
|
+
3654703836,
|
|
8698
|
+
1088359270,
|
|
8699
|
+
936918e3,
|
|
8700
|
+
2847714899,
|
|
8701
|
+
3736837829,
|
|
8702
|
+
1202900863,
|
|
8703
|
+
817233897,
|
|
8704
|
+
3183342108,
|
|
8705
|
+
3401237130,
|
|
8706
|
+
1404277552,
|
|
8707
|
+
615818150,
|
|
8708
|
+
3134207493,
|
|
8709
|
+
3453421203,
|
|
8710
|
+
1423857449,
|
|
8711
|
+
601450431,
|
|
8712
|
+
3009837614,
|
|
8713
|
+
3294710456,
|
|
8714
|
+
1567103746,
|
|
8715
|
+
711928724,
|
|
8716
|
+
3020668471,
|
|
8717
|
+
3272380065,
|
|
8718
|
+
1510334235,
|
|
8719
|
+
755167117
|
|
8720
|
+
);
|
|
8254
8721
|
function getCRC32Table() {
|
|
8255
8722
|
return CRC32TAB;
|
|
8256
8723
|
}
|
|
@@ -8341,15 +8808,16 @@ var __exports__ = (() => {
|
|
|
8341
8808
|
|
|
8342
8809
|
// ../crypto/src/lib/crc32-hash.ts
|
|
8343
8810
|
var CRC32Hash = class extends Hash {
|
|
8344
|
-
name = "crc32";
|
|
8345
8811
|
constructor(options = {}) {
|
|
8346
8812
|
super();
|
|
8347
|
-
this.
|
|
8348
|
-
|
|
8349
|
-
...options
|
|
8350
|
-
};
|
|
8813
|
+
this.name = "crc32";
|
|
8814
|
+
this.options = { crypto: {}, ...options };
|
|
8351
8815
|
this.hashBatches = this.hashBatches.bind(this);
|
|
8352
8816
|
}
|
|
8817
|
+
/**
|
|
8818
|
+
* Atomic hash calculation
|
|
8819
|
+
* @returns base64 encoded hash
|
|
8820
|
+
*/
|
|
8353
8821
|
async hash(input, encoding) {
|
|
8354
8822
|
return this.hashSync(input, encoding);
|
|
8355
8823
|
}
|
|
@@ -8366,15 +8834,15 @@ var __exports__ = (() => {
|
|
|
8366
8834
|
yield chunk;
|
|
8367
8835
|
}
|
|
8368
8836
|
const digest = hash.finalize();
|
|
8369
|
-
this.options.crypto?.onEnd?.({
|
|
8370
|
-
hash: encodeNumber(digest, encoding)
|
|
8371
|
-
});
|
|
8837
|
+
this.options.crypto?.onEnd?.({ hash: encodeNumber(digest, encoding) });
|
|
8372
8838
|
}
|
|
8373
8839
|
};
|
|
8374
8840
|
|
|
8375
8841
|
// ../crypto/src/lib/algorithms/md5-wasm.ts
|
|
8376
8842
|
var atb = typeof atob === "function" ? atob : typeof Buffer === "function" ? nodeATOB : identity;
|
|
8377
|
-
var wasmB64 = atb(
|
|
8843
|
+
var wasmB64 = atb(
|
|
8844
|
+
"AGFzbQEAAAABDANgAX8AYAAAYAABfwIeAgdpbXBvcnRzA2xvZwAAB2ltcG9ydHMDbWVtAgABAzIxAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAAAAAAAAAAAAAAAAAAAAAAgICAgIAAAAAAAaYARt/AUGBxpS6Bgt/AUGJ17b+fgt/AUH+uevFeQt/AUH2qMmBAQt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALB7oCJQhvbmVGdWxsQQAYCG9uZUZ1bGxCABkIb25lRnVsbEMAGghvbmVGdWxsRAAbBWxvb3BzAAEEbG9vcAACBXByaW1lAAMFbG9vcEEABAZsb29wQTEABQZsb29wQTIABgZsb29wQTMABwZsb29wQTQACAVsb29wQgAJBmxvb3BCMQAKBmxvb3BCMgALBmxvb3BCMwAMBmxvb3BCNAANBWxvb3BDAA4GbG9vcEMxAA8GbG9vcEMyABAGbG9vcEMzABEGbG9vcEM0ABIFbG9vcEQAEwZsb29wRDEAFAZsb29wRDIAFQZsb29wRDMAFgZsb29wRDQAFwRnZXRBACgEZ2V0QgApBGdldEMAKgRnZXREACsEZ2V0WAAsBHNldEEALQRzZXRCAC4Ec2V0QwAvBHNldEQAMARzZXRYADEKzA0xWwEBf0EAJAggAEEGdCEBAkADQCMIIAFGDQEjACQEIwEkBSMCJAYjAyQHEAIjBCMAaiQAIwUjAWokASMGIwJqJAIjByMDaiQDIwhBwABqJAgMAAsLIwgjGmokGgsTACMIIxpqJAkQAxAEEAkQDhATC6IBAEEAIwlqKAIAJApBBCMJaigCACQLQQgjCWooAgAkDEEMIwlqKAIAJA1BECMJaigCACQOQRQjCWooAgAkD0EYIwlqKAIAJBBBHCMJaigCACQRQSAjCWooAgAkEkEkIwlqKAIAJBNBKCMJaigCACQUQSwjCWooAgAkFUEwIwlqKAIAJBZBNCMJaigCACQXQTgjCWooAgAkGEE8IwlqKAIAJBkLCgAQBRAGEAcQCAsuAEH4yKq7fSMKahAYQdbunsZ+IwtqEBtB2+GBoQIjDGoQGkHunfeNfCMNahAZCy0AQa+f8Kt/Iw5qEBhBqoyfvAQjD2oQG0GTjMHBeiMQahAaQYGqmmojEWoQGQssAEHYsYLMBiMSahAYQa/vk9p4IxNqEBtBsbd9IxRqEBpBvq/zyngjFWoQGQstAEGiosDcBiMWahAYQZPj4WwjF2oQG0GOh+WzeiMYahAaQaGQ0M0EIxlqEBkLCgAQChALEAwQDQsuAEHiyviwfyMLahAcQcDmgoJ8IxBqEB9B0bT5sgIjFWoQHkGqj9vNfiMKahAdCy0AQd2gvLF9Iw9qEBxB06iQEiMUahAfQYHNh8V9IxlqEB5ByPfPvn4jDmoQHQsuAEHmm4ePAiMTahAcQdaP3Jl8IxhqEB9Bh5vUpn8jDWoQHkHtqeiqBCMSahAdCy0AQYXSj896IxdqEBxB+Me+ZyMMahAfQdmFvLsGIxFqEB5Bipmp6XgjFmoQHQsKABAPEBAQERASCysAQcLyaCMPahAgQYHtx7t4IxJqECNBosL17AYjFWoQIkGM8JRvIxhqECELLgBBxNT7pXojC2oQIEGpn/veBCMOahAjQeCW7bV/IxFqECJB8Pj+9XsjFGoQIQstAEHG/e3EAiMXahAgQfrPhNV+IwpqECNBheG8p30jDWoQIkGFuqAkIxBqECELLgBBuaDTzn0jE2oQIEHls+62fiMWahAjQfj5if0BIxlqECJB5ayxpXwjDGoQIQsKABAUEBUQFhAXCy0AQcTEpKF/IwpqECRBl/+rmQQjEWoQJ0Gnx9DceiMYahAmQbnAzmQjD2oQJQstAEHDs+2qBiMWahAkQZKZs/h4Iw1qECdB/ei/fyMUahAmQdG7kax4IwtqECULLQBBz/yh/QYjEmoQJEHgzbNxIxlqECdBlIaFmHojEGoQJkGho6DwBCMXahAlCy4AQYL9zbp/Iw5qECRBteTr6XsjFWoQJ0G7pd/WAiMMahAmQZGnm9x+IxNqECULKAEBf0F/IwFzIwNxIwEjAnFyIwBqIABqIgFBB3QgAUEZdnIjAWokAAsoAQF/QX8jAnMjAHEjAiMDcXIjAWogAGoiAUEWdCABQQp2ciMCaiQBCygBAX9BfyMDcyMBcSMDIwBxciMCaiAAaiIBQRF0IAFBD3ZyIwNqJAILKAEBf0F/IwBzIwJxIwAjAXFyIwNqIABqIgFBDHQgAUEUdnIjAGokAwsoAQF/IwJBfyMDc3EjASMDcXIjAGogAGoiAUEFdCABQRt2ciMBaiQACygBAX8jA0F/IwBzcSMCIwBxciMBaiAAaiIBQRR0IAFBDHZyIwJqJAELKAEBfyMAQX8jAXNxIwMjAXFyIwJqIABqIgFBDnQgAUESdnIjA2okAgsoAQF/IwFBfyMCc3EjACMCcXIjA2ogAGoiAUEJdCABQRd2ciMAaiQDCyIBAX8jASMCcyMDcyMAaiAAaiIBQQR0IAFBHHZyIwFqJAALIgEBfyMCIwNzIwBzIwFqIABqIgFBF3QgAUEJdnIjAmokAQsiAQF/IwMjAHMjAXMjAmogAGoiAUEQdCABQRB2ciMDaiQCCyIBAX8jACMBcyMCcyMDaiAAaiIBQQt0IAFBFXZyIwBqJAMLJQEBf0F/IwNzIwFyIwJzIwBqIABqIgFBBnQgAUEadnIjAWokAAslAQF/QX8jAHMjAnIjA3MjAWogAGoiAUEVdCABQQt2ciMCaiQBCyUBAX9BfyMBcyMDciMAcyMCaiAAaiIBQQ90IAFBEXZyIwNqJAILJQEBf0F/IwJzIwByIwFzIwNqIABqIgFBCnQgAUEWdnIjAGokAwsEACMACwQAIwELBAAjAgsEACMDCwQAIxoLBgAgACQACwYAIAAkAQsGACAAJAILBgAgACQDCwYAIAAkGgsA6gQEbmFtZQGSAzIAA2xvZwEFbG9vcHMCBGxvb3ADBXByaW1lBAVsb29wQQUGbG9vcEExBgZsb29wQTIHBmxvb3BBMwgGbG9vcEE0CQVsb29wQgoGbG9vcEIxCwZsb29wQjIMBmxvb3BCMw0GbG9vcEI0DgVsb29wQw8GbG9vcEMxEAZsb29wQzIRBmxvb3BDMxIGbG9vcEM0EwVsb29wRBQGbG9vcEQxFQZsb29wRDIWBmxvb3BEMxcGbG9vcEQ0GAhvbmVGdWxsQRkIb25lRnVsbEIaCG9uZUZ1bGxDGwhvbmVGdWxsRBwIdHdvRnVsbEEdCHR3b0Z1bGxCHgh0d29GdWxsQx8IdHdvRnVsbEQgCHRyZUZ1bGxBIQh0cmVGdWxsQiIIdHJlRnVsbEMjCHRyZUZ1bGxEJAhxdWFGdWxsQSUIcXVhRnVsbEImCHF1YUZ1bGxDJwhxdWFGdWxsRCgEZ2V0QSkEZ2V0QioEZ2V0QysEZ2V0RCwEZ2V0WC0Ec2V0QS4Ec2V0Qi8Ec2V0QzAEc2V0RDEEc2V0WALNATIAAQAAAQIAAAEIbnVtbG9vcHMCAAMABAAFAAYABwAIAAkACgALAAwADQAOAA8AEAARABIAEwAUABUAFgAXABgCAAABAW4ZAgAAAQFuGgIAAAEBbhsCAAABAW4cAgAAAQFuHQIAAAEBbh4CAAABAW4fAgAAAQFuIAIAAAEBbiECAAABAW4iAgAAAQFuIwIAAAEBbiQCAAABAW4lAgAAAQFuJgIAAAEBbicCAAABAW4oACkAKgArACwALQEAAC4BAAAvAQAAMAEAADEBAAA="
|
|
8845
|
+
);
|
|
8378
8846
|
var wasm = WebAssembly && atb !== identity ? str2AB(wasmB64).buffer : false;
|
|
8379
8847
|
var crypt = makeCrypt();
|
|
8380
8848
|
var biteSize = 240 * 16 * 16;
|
|
@@ -8383,7 +8851,9 @@ var __exports__ = (() => {
|
|
|
8383
8851
|
var parmTypeErrStr = "Parameter must be Buffer, ArrayBuffer or Uint8Array";
|
|
8384
8852
|
var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes";
|
|
8385
8853
|
if (!wasm) {
|
|
8386
|
-
console.log(
|
|
8854
|
+
console.log(
|
|
8855
|
+
"WebAssembly not available or WASM module could not be decoded; md5WASM will fall back to JavaScript"
|
|
8856
|
+
);
|
|
8387
8857
|
}
|
|
8388
8858
|
function md5WASM(data) {
|
|
8389
8859
|
var mem, memView, importObj, imports, len, buff, thenFun, catchFun, result, endTime;
|
|
@@ -8422,13 +8892,8 @@ var __exports__ = (() => {
|
|
|
8422
8892
|
initial: len > 32e6 ? len > 64e6 ? len > 128e6 ? 4096 : 2048 : 1024 : 512
|
|
8423
8893
|
});
|
|
8424
8894
|
memView = new Uint32Array(mem.buffer);
|
|
8425
|
-
imports = {
|
|
8426
|
-
|
|
8427
|
-
log: console.log
|
|
8428
|
-
};
|
|
8429
|
-
importObj = {
|
|
8430
|
-
imports
|
|
8431
|
-
};
|
|
8895
|
+
imports = { mem, log: console.log };
|
|
8896
|
+
importObj = { imports };
|
|
8432
8897
|
WebAssembly.instantiate(wasm, importObj).then(giterdone);
|
|
8433
8898
|
}
|
|
8434
8899
|
} else {
|
|
@@ -8783,185 +9248,35 @@ var __exports__ = (() => {
|
|
|
8783
9248
|
|
|
8784
9249
|
// ../crypto/src/lib/md5-hash.ts
|
|
8785
9250
|
var MD5Hash = class extends Hash {
|
|
8786
|
-
name = "md5";
|
|
8787
9251
|
constructor(options = {}) {
|
|
8788
9252
|
super();
|
|
9253
|
+
this.name = "md5";
|
|
8789
9254
|
this.options = options;
|
|
8790
9255
|
}
|
|
9256
|
+
/**
|
|
9257
|
+
* Atomic hash calculation
|
|
9258
|
+
* @returns base64 encoded hash
|
|
9259
|
+
*/
|
|
8791
9260
|
async hash(input, encoding) {
|
|
8792
|
-
const md5Promise = new Promise(
|
|
9261
|
+
const md5Promise = new Promise(
|
|
9262
|
+
(resolve2, reject) => (
|
|
9263
|
+
// @ts-expect-error
|
|
9264
|
+
md5WASM(input).then(resolve2).catch(reject)
|
|
9265
|
+
)
|
|
9266
|
+
);
|
|
8793
9267
|
const hex = await md5Promise;
|
|
8794
9268
|
return encodeHex(hex, encoding);
|
|
8795
9269
|
}
|
|
8796
9270
|
};
|
|
8797
9271
|
|
|
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
9272
|
// src/parse-zip/zip-composition.ts
|
|
9273
|
+
var import_core = __toESM(require_core(), 1);
|
|
8961
9274
|
async function cutTheTailOff(provider) {
|
|
8962
9275
|
const oldEoCDinfo = await parseEoCDRecord(provider);
|
|
8963
9276
|
const oldCDStartOffset = oldEoCDinfo.cdStartOffset;
|
|
8964
|
-
const oldCDLength = Number(
|
|
9277
|
+
const oldCDLength = Number(
|
|
9278
|
+
oldEoCDinfo.offsets.zip64EoCDOffset ? oldEoCDinfo.offsets.zip64EoCDOffset - oldCDStartOffset : oldEoCDinfo.offsets.zipEoCDOffset - oldCDStartOffset
|
|
9279
|
+
);
|
|
8965
9280
|
const zipEnding = await provider.slice(oldCDStartOffset, provider.length);
|
|
8966
9281
|
await provider.truncate(Number(oldCDStartOffset));
|
|
8967
9282
|
const oldCDBody = zipEnding.slice(0, oldCDLength);
|
|
@@ -8981,7 +9296,10 @@ var __exports__ = (() => {
|
|
|
8981
9296
|
offset: localFileHeaderOffset,
|
|
8982
9297
|
length: fileToAdd.byteLength
|
|
8983
9298
|
});
|
|
8984
|
-
return [
|
|
9299
|
+
return [
|
|
9300
|
+
new Uint8Array(concatenateArrayBuffers(newFileLocalHeader, fileToAdd)),
|
|
9301
|
+
new Uint8Array(newFileCDHeader)
|
|
9302
|
+
];
|
|
8985
9303
|
}
|
|
8986
9304
|
async function addOneFile(zipUrl, fileToAdd, fileName) {
|
|
8987
9305
|
const provider = new FileHandleFile(zipUrl, true);
|
|
@@ -8993,7 +9311,15 @@ var __exports__ = (() => {
|
|
|
8993
9311
|
const newCDStartOffset = provider.length;
|
|
8994
9312
|
await provider.append(new Uint8Array(newCDBody));
|
|
8995
9313
|
const eocdOffset = provider.length;
|
|
8996
|
-
await provider.append(
|
|
9314
|
+
await provider.append(
|
|
9315
|
+
updateEoCD(
|
|
9316
|
+
eocdBody,
|
|
9317
|
+
oldEoCDinfo.offsets,
|
|
9318
|
+
newCDStartOffset,
|
|
9319
|
+
eocdOffset,
|
|
9320
|
+
oldEoCDinfo.cdRecordsNumber + 1n
|
|
9321
|
+
)
|
|
9322
|
+
);
|
|
8997
9323
|
}
|
|
8998
9324
|
async function createZip(inputPath, outputPath, createAdditionalData) {
|
|
8999
9325
|
const fileIterator = getFileIterator(inputPath);
|
|
@@ -9011,19 +9337,15 @@ var __exports__ = (() => {
|
|
|
9011
9337
|
const cd = concatenateArrayBuffers(...cdArray);
|
|
9012
9338
|
await resFile.append(new Uint8Array(cd));
|
|
9013
9339
|
const eoCDStart = (await resFile.stat()).bigsize;
|
|
9014
|
-
await resFile.append(
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
})));
|
|
9340
|
+
await resFile.append(
|
|
9341
|
+
new Uint8Array(
|
|
9342
|
+
generateEoCD({ recordsNumber: cdArray.length, cdSize: cd.byteLength, cdOffset, eoCDStart })
|
|
9343
|
+
)
|
|
9344
|
+
);
|
|
9020
9345
|
}
|
|
9021
9346
|
async function addFile(file, resFile, cdArray, fileList) {
|
|
9022
9347
|
const size = (await resFile.stat()).bigsize;
|
|
9023
|
-
fileList?.push({
|
|
9024
|
-
fileName: file.path,
|
|
9025
|
-
localHeaderOffset: size
|
|
9026
|
-
});
|
|
9348
|
+
fileList?.push({ fileName: file.path, localHeaderOffset: size });
|
|
9027
9349
|
const [localPart, cdHeaderPart] = await generateFileHeaders(file.path, file.file, size);
|
|
9028
9350
|
await resFile.append(localPart);
|
|
9029
9351
|
cdArray.push(cdHeaderPart);
|
|
@@ -9032,11 +9354,8 @@ var __exports__ = (() => {
|
|
|
9032
9354
|
async function* iterable() {
|
|
9033
9355
|
const fileList = await getAllFiles(inputPath);
|
|
9034
9356
|
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
|
-
};
|
|
9357
|
+
const file = await (await (0, import_core.fetchFile)(path_exports.join(inputPath, filePath))).arrayBuffer();
|
|
9358
|
+
yield { path: filePath, file };
|
|
9040
9359
|
}
|
|
9041
9360
|
}
|
|
9042
9361
|
return iterable();
|
|
@@ -9067,31 +9386,39 @@ var __exports__ = (() => {
|
|
|
9067
9386
|
this.compressBatches = this.compressBatches.bind(this);
|
|
9068
9387
|
this.decompressBatches = this.decompressBatches.bind(this);
|
|
9069
9388
|
}
|
|
9389
|
+
/** Preloads any dynamic libraries. May enable sync functions */
|
|
9070
9390
|
async preload() {
|
|
9071
9391
|
return;
|
|
9072
9392
|
}
|
|
9393
|
+
/** Asynchronously compress data */
|
|
9073
9394
|
async compress(input) {
|
|
9074
9395
|
await this.preload();
|
|
9075
9396
|
return this.compressSync(input);
|
|
9076
9397
|
}
|
|
9398
|
+
/** Asynchronously decompress data */
|
|
9077
9399
|
async decompress(input, size) {
|
|
9078
9400
|
await this.preload();
|
|
9079
9401
|
return this.decompressSync(input, size);
|
|
9080
9402
|
}
|
|
9403
|
+
/** Synchronously compress data */
|
|
9081
9404
|
compressSync(input) {
|
|
9082
9405
|
throw new Error(`${this.name}: sync compression not supported`);
|
|
9083
9406
|
}
|
|
9407
|
+
/** Synchronously compress data */
|
|
9084
9408
|
decompressSync(input, size) {
|
|
9085
9409
|
throw new Error(`${this.name}: sync decompression not supported`);
|
|
9086
9410
|
}
|
|
9411
|
+
/** Compress batches */
|
|
9087
9412
|
async *compressBatches(asyncIterator) {
|
|
9088
9413
|
const input = await this.concatenate(asyncIterator);
|
|
9089
9414
|
yield this.compress(input);
|
|
9090
9415
|
}
|
|
9416
|
+
/** Decompress batches */
|
|
9091
9417
|
async *decompressBatches(asyncIterator) {
|
|
9092
9418
|
const input = await this.concatenate(asyncIterator);
|
|
9093
9419
|
yield this.decompress(input);
|
|
9094
9420
|
}
|
|
9421
|
+
// HELPERS
|
|
9095
9422
|
concatenate(asyncIterator) {
|
|
9096
9423
|
return concatenateArrayBuffersAsync(asyncIterator);
|
|
9097
9424
|
}
|
|
@@ -9107,13 +9434,13 @@ var __exports__ = (() => {
|
|
|
9107
9434
|
var import_pako = __toESM(require_pako(), 1);
|
|
9108
9435
|
var import_zlib = __toESM(require_zlib(), 1);
|
|
9109
9436
|
var DeflateCompression = class extends Compression {
|
|
9110
|
-
name = "deflate";
|
|
9111
|
-
extensions = [];
|
|
9112
|
-
contentEncodings = ["deflate"];
|
|
9113
|
-
isSupported = true;
|
|
9114
|
-
_chunks = [];
|
|
9115
9437
|
constructor(options = {}) {
|
|
9116
9438
|
super(options);
|
|
9439
|
+
this.name = "deflate";
|
|
9440
|
+
this.extensions = [];
|
|
9441
|
+
this.contentEncodings = ["deflate"];
|
|
9442
|
+
this.isSupported = true;
|
|
9443
|
+
this._chunks = [];
|
|
9117
9444
|
this.options = options;
|
|
9118
9445
|
}
|
|
9119
9446
|
async compress(input) {
|
|
@@ -9192,16 +9519,26 @@ var __exports__ = (() => {
|
|
|
9192
9519
|
this._chunks = [];
|
|
9193
9520
|
return chunks;
|
|
9194
9521
|
}
|
|
9522
|
+
// TODO - For some reason we don't get the error message from pako in _onEnd?
|
|
9195
9523
|
_getError(code = 0) {
|
|
9196
9524
|
const MESSAGES = {
|
|
9525
|
+
/* Z_NEED_DICT 2 */
|
|
9197
9526
|
2: "need dictionary",
|
|
9527
|
+
/* Z_STREAM_END 1 */
|
|
9198
9528
|
1: "stream end",
|
|
9529
|
+
/* Z_OK 0 */
|
|
9199
9530
|
0: "",
|
|
9531
|
+
/* Z_ERRNO (-1) */
|
|
9200
9532
|
"-1": "file error",
|
|
9533
|
+
/* Z_STREAM_ERROR (-2) */
|
|
9201
9534
|
"-2": "stream error",
|
|
9535
|
+
/* Z_DATA_ERROR (-3) */
|
|
9202
9536
|
"-3": "data error",
|
|
9537
|
+
/* Z_MEM_ERROR (-4) */
|
|
9203
9538
|
"-4": "insufficient memory",
|
|
9539
|
+
/* Z_BUF_ERROR (-5) */
|
|
9204
9540
|
"-5": "buffer error",
|
|
9541
|
+
/* Z_VERSION_ERROR (-6) */
|
|
9205
9542
|
"-6": "incompatible version"
|
|
9206
9543
|
};
|
|
9207
9544
|
return `${this.name}: ${MESSAGES[code]}`;
|
|
@@ -9210,19 +9547,24 @@ var __exports__ = (() => {
|
|
|
9210
9547
|
|
|
9211
9548
|
// src/filesystems/zip-filesystem.ts
|
|
9212
9549
|
var ZIP_COMPRESSION_HANDLERS = {
|
|
9550
|
+
/** No compression */
|
|
9213
9551
|
0: async (compressedFile) => compressedFile,
|
|
9552
|
+
/** Deflation */
|
|
9214
9553
|
8: async (compressedFile) => {
|
|
9215
|
-
const compression = new DeflateCompression({
|
|
9216
|
-
raw: true
|
|
9217
|
-
});
|
|
9554
|
+
const compression = new DeflateCompression({ raw: true });
|
|
9218
9555
|
const decompressedData = await compression.decompress(compressedFile);
|
|
9219
9556
|
return decompressedData;
|
|
9220
9557
|
}
|
|
9221
9558
|
};
|
|
9222
9559
|
var ZipFileSystem = class {
|
|
9223
|
-
|
|
9224
|
-
|
|
9560
|
+
/**
|
|
9561
|
+
* Constructor
|
|
9562
|
+
* @param file - instance of FileProvider or file path string
|
|
9563
|
+
*/
|
|
9225
9564
|
constructor(file) {
|
|
9565
|
+
/** FileProvider instance promise */
|
|
9566
|
+
this.fileProvider = null;
|
|
9567
|
+
this.archive = null;
|
|
9226
9568
|
if (typeof file === "string") {
|
|
9227
9569
|
this.fileName = file;
|
|
9228
9570
|
if (!isBrowser) {
|
|
@@ -9238,11 +9580,16 @@ var __exports__ = (() => {
|
|
|
9238
9580
|
this.fileProvider = file;
|
|
9239
9581
|
}
|
|
9240
9582
|
}
|
|
9583
|
+
/** Clean up resources */
|
|
9241
9584
|
async destroy() {
|
|
9242
9585
|
if (this.fileProvider) {
|
|
9243
9586
|
await this.fileProvider.destroy();
|
|
9244
9587
|
}
|
|
9245
9588
|
}
|
|
9589
|
+
/**
|
|
9590
|
+
* Get file names list from zip archive
|
|
9591
|
+
* @returns array of file names
|
|
9592
|
+
*/
|
|
9246
9593
|
async readdir() {
|
|
9247
9594
|
if (!this.fileProvider) {
|
|
9248
9595
|
throw new Error("No data detected in the zip archive");
|
|
@@ -9254,13 +9601,20 @@ var __exports__ = (() => {
|
|
|
9254
9601
|
}
|
|
9255
9602
|
return fileNames;
|
|
9256
9603
|
}
|
|
9604
|
+
/**
|
|
9605
|
+
* Get file metadata
|
|
9606
|
+
* @param filename - name of a file
|
|
9607
|
+
* @returns central directory data
|
|
9608
|
+
*/
|
|
9257
9609
|
async stat(filename2) {
|
|
9258
9610
|
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
9259
|
-
return {
|
|
9260
|
-
...cdFileHeader,
|
|
9261
|
-
size: Number(cdFileHeader.uncompressedSize)
|
|
9262
|
-
};
|
|
9611
|
+
return { ...cdFileHeader, size: Number(cdFileHeader.uncompressedSize) };
|
|
9263
9612
|
}
|
|
9613
|
+
/**
|
|
9614
|
+
* Implementation of fetch against this file system
|
|
9615
|
+
* @param filename - name of a file
|
|
9616
|
+
* @returns - Response with file data
|
|
9617
|
+
*/
|
|
9264
9618
|
async fetch(filename2) {
|
|
9265
9619
|
let uncompressedFile;
|
|
9266
9620
|
if (this.archive) {
|
|
@@ -9270,7 +9624,10 @@ var __exports__ = (() => {
|
|
|
9270
9624
|
throw new Error("No data detected in the zip archive");
|
|
9271
9625
|
}
|
|
9272
9626
|
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
9273
|
-
const localFileHeader = await parseZipLocalFileHeader(
|
|
9627
|
+
const localFileHeader = await parseZipLocalFileHeader(
|
|
9628
|
+
cdFileHeader.localHeaderOffset,
|
|
9629
|
+
this.fileProvider
|
|
9630
|
+
);
|
|
9274
9631
|
if (!localFileHeader) {
|
|
9275
9632
|
throw new Error("Local file header has not been found in the zip archive`");
|
|
9276
9633
|
}
|
|
@@ -9278,7 +9635,10 @@ var __exports__ = (() => {
|
|
|
9278
9635
|
if (!compressionHandler) {
|
|
9279
9636
|
throw Error("Only Deflation compression is supported");
|
|
9280
9637
|
}
|
|
9281
|
-
const compressedFile = await this.fileProvider.slice(
|
|
9638
|
+
const compressedFile = await this.fileProvider.slice(
|
|
9639
|
+
localFileHeader.fileDataOffset,
|
|
9640
|
+
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
9641
|
+
);
|
|
9282
9642
|
uncompressedFile = await compressionHandler(compressedFile);
|
|
9283
9643
|
}
|
|
9284
9644
|
const response = new Response(uncompressedFile);
|
|
@@ -9287,6 +9647,11 @@ var __exports__ = (() => {
|
|
|
9287
9647
|
});
|
|
9288
9648
|
return response;
|
|
9289
9649
|
}
|
|
9650
|
+
/**
|
|
9651
|
+
* Get central directory file header
|
|
9652
|
+
* @param filename - name of a file
|
|
9653
|
+
* @returns central directory file header
|
|
9654
|
+
*/
|
|
9290
9655
|
async getCDFileHeader(filename2) {
|
|
9291
9656
|
if (!this.fileProvider) {
|
|
9292
9657
|
throw new Error("No data detected in the zip archive");
|
|
@@ -9308,10 +9673,21 @@ var __exports__ = (() => {
|
|
|
9308
9673
|
|
|
9309
9674
|
// src/filesystems/IndexedArchive.ts
|
|
9310
9675
|
var IndexedArchive = class {
|
|
9676
|
+
/**
|
|
9677
|
+
* Constructor
|
|
9678
|
+
* @param fileProvider - instance of a binary data reader
|
|
9679
|
+
* @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
|
|
9680
|
+
* @param fileName - name of the archive. It is used to add to an URL of a loader context
|
|
9681
|
+
*/
|
|
9311
9682
|
constructor(fileProvider, hashTable, fileName) {
|
|
9312
9683
|
this.fileProvider = fileProvider;
|
|
9313
9684
|
this.fileName = fileName;
|
|
9314
9685
|
}
|
|
9686
|
+
/**
|
|
9687
|
+
* Get file as from order ZIP arhive without using the hash file
|
|
9688
|
+
* @param filename - path to the internal file
|
|
9689
|
+
* @returns
|
|
9690
|
+
*/
|
|
9315
9691
|
async getFileWithoutHash(filename2) {
|
|
9316
9692
|
const zipFS = new ZipFileSystem(this.fileProvider);
|
|
9317
9693
|
const response = await zipFS.fetch(filename2);
|
|
@@ -9360,7 +9736,9 @@ var __exports__ = (() => {
|
|
|
9360
9736
|
}
|
|
9361
9737
|
const arrayBuffer = textEncoder.encode(filename2).buffer;
|
|
9362
9738
|
const md5 = await md5Hash.hash(arrayBuffer, "hex");
|
|
9363
|
-
hashArray.push(
|
|
9739
|
+
hashArray.push(
|
|
9740
|
+
concatenateArrayBuffers(hexStringToBuffer(md5), bigintToBuffer(cdHeader.localHeaderOffset))
|
|
9741
|
+
);
|
|
9364
9742
|
}
|
|
9365
9743
|
const bufferArray = hashArray.sort(compareHashes);
|
|
9366
9744
|
return concatenateArrayBuffersFromArray(bufferArray);
|
|
@@ -9377,7 +9755,7 @@ var __exports__ = (() => {
|
|
|
9377
9755
|
function bigintToBuffer(n) {
|
|
9378
9756
|
return new BigUint64Array([n]).buffer;
|
|
9379
9757
|
}
|
|
9380
|
-
return __toCommonJS(
|
|
9758
|
+
return __toCommonJS(bundle_exports);
|
|
9381
9759
|
})();
|
|
9382
9760
|
/*! Bundled license information:
|
|
9383
9761
|
|