@donezone/cli 0.1.49 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/cw_js.wasm +0 -0
- package/artifacts/done_auth_router.wasm +0 -0
- package/artifacts/done_sock_puppet.wasm +0 -0
- package/dist/index.js +1709 -1730
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22578,256 +22578,588 @@ var require_fast_decode_uri_component = __commonJS((exports, module) => {
|
|
|
22578
22578
|
module.exports = decodeURIComponent2;
|
|
22579
22579
|
});
|
|
22580
22580
|
|
|
22581
|
-
// ../../node_modules/
|
|
22582
|
-
var
|
|
22583
|
-
|
|
22584
|
-
EndOfStreamError = class EndOfStreamError extends Error {
|
|
22585
|
-
constructor() {
|
|
22586
|
-
super(defaultMessages);
|
|
22587
|
-
this.name = "EndOfStreamError";
|
|
22588
|
-
}
|
|
22589
|
-
};
|
|
22590
|
-
AbortError = class AbortError extends Error {
|
|
22591
|
-
constructor(message = "The operation was aborted") {
|
|
22592
|
-
super(message);
|
|
22593
|
-
this.name = "AbortError";
|
|
22594
|
-
}
|
|
22595
|
-
};
|
|
22581
|
+
// ../../node_modules/ieee754/index.js
|
|
22582
|
+
var init_ieee754 = __esm(() => {
|
|
22583
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
22596
22584
|
});
|
|
22597
22585
|
|
|
22598
|
-
// ../../node_modules/
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22586
|
+
// ../../node_modules/@borewit/text-codec/lib/index.js
|
|
22587
|
+
function utf8Decoder() {
|
|
22588
|
+
if (typeof globalThis.TextDecoder === "undefined")
|
|
22589
|
+
return;
|
|
22590
|
+
return _utf8Decoder !== null && _utf8Decoder !== undefined ? _utf8Decoder : _utf8Decoder = new globalThis.TextDecoder("utf-8");
|
|
22591
|
+
}
|
|
22592
|
+
function textDecode(bytes2, encoding = "utf-8") {
|
|
22593
|
+
switch (encoding.toLowerCase()) {
|
|
22594
|
+
case "utf-8":
|
|
22595
|
+
case "utf8": {
|
|
22596
|
+
const dec = utf8Decoder();
|
|
22597
|
+
return dec ? dec.decode(bytes2) : decodeUTF8(bytes2);
|
|
22598
|
+
}
|
|
22599
|
+
case "utf-16le":
|
|
22600
|
+
return decodeUTF16LE(bytes2);
|
|
22601
|
+
case "us-ascii":
|
|
22602
|
+
case "ascii":
|
|
22603
|
+
return decodeASCII(bytes2);
|
|
22604
|
+
case "latin1":
|
|
22605
|
+
case "iso-8859-1":
|
|
22606
|
+
return decodeLatin1(bytes2);
|
|
22607
|
+
case "windows-1252":
|
|
22608
|
+
return decodeWindows1252(bytes2);
|
|
22609
|
+
default:
|
|
22610
|
+
throw new RangeError(`Encoding '${encoding}' not supported`);
|
|
22607
22611
|
}
|
|
22608
22612
|
}
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22613
|
+
function flushChunk(parts, chunk) {
|
|
22614
|
+
if (chunk.length === 0)
|
|
22615
|
+
return;
|
|
22616
|
+
parts.push(String.fromCharCode.apply(null, chunk));
|
|
22617
|
+
chunk.length = 0;
|
|
22618
|
+
}
|
|
22619
|
+
function pushCodeUnit(parts, chunk, codeUnit) {
|
|
22620
|
+
chunk.push(codeUnit);
|
|
22621
|
+
if (chunk.length >= CHUNK)
|
|
22622
|
+
flushChunk(parts, chunk);
|
|
22623
|
+
}
|
|
22624
|
+
function pushCodePoint(parts, chunk, cp) {
|
|
22625
|
+
if (cp <= 65535) {
|
|
22626
|
+
pushCodeUnit(parts, chunk, cp);
|
|
22627
|
+
return;
|
|
22616
22628
|
}
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22629
|
+
cp -= 65536;
|
|
22630
|
+
pushCodeUnit(parts, chunk, 55296 + (cp >> 10));
|
|
22631
|
+
pushCodeUnit(parts, chunk, 56320 + (cp & 1023));
|
|
22632
|
+
}
|
|
22633
|
+
function decodeUTF8(bytes2) {
|
|
22634
|
+
const parts = [];
|
|
22635
|
+
const chunk = [];
|
|
22636
|
+
let i = 0;
|
|
22637
|
+
if (bytes2.length >= 3 && bytes2[0] === 239 && bytes2[1] === 187 && bytes2[2] === 191) {
|
|
22638
|
+
i = 3;
|
|
22621
22639
|
}
|
|
22622
|
-
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
|
|
22640
|
+
while (i < bytes2.length) {
|
|
22641
|
+
const b1 = bytes2[i];
|
|
22642
|
+
if (b1 <= 127) {
|
|
22643
|
+
pushCodeUnit(parts, chunk, b1);
|
|
22644
|
+
i++;
|
|
22645
|
+
continue;
|
|
22629
22646
|
}
|
|
22630
|
-
if (
|
|
22631
|
-
|
|
22647
|
+
if (b1 < 194 || b1 > 244) {
|
|
22648
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22649
|
+
i++;
|
|
22650
|
+
continue;
|
|
22632
22651
|
}
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
|
|
22639
|
-
const
|
|
22640
|
-
if (
|
|
22641
|
-
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
bytesRead += lenCopy;
|
|
22645
|
-
remaining -= lenCopy;
|
|
22646
|
-
if (lenCopy < peekData.length) {
|
|
22647
|
-
this.peekQueue.push(peekData.subarray(lenCopy));
|
|
22652
|
+
if (b1 <= 223) {
|
|
22653
|
+
if (i + 1 >= bytes2.length) {
|
|
22654
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22655
|
+
i++;
|
|
22656
|
+
continue;
|
|
22657
|
+
}
|
|
22658
|
+
const b22 = bytes2[i + 1];
|
|
22659
|
+
if ((b22 & 192) !== 128) {
|
|
22660
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22661
|
+
i++;
|
|
22662
|
+
continue;
|
|
22648
22663
|
}
|
|
22664
|
+
const cp2 = (b1 & 31) << 6 | b22 & 63;
|
|
22665
|
+
pushCodeUnit(parts, chunk, cp2);
|
|
22666
|
+
i += 2;
|
|
22667
|
+
continue;
|
|
22649
22668
|
}
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
if (this.interrupted) {
|
|
22656
|
-
throw new AbortError;
|
|
22669
|
+
if (b1 <= 239) {
|
|
22670
|
+
if (i + 2 >= bytes2.length) {
|
|
22671
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22672
|
+
i++;
|
|
22673
|
+
continue;
|
|
22657
22674
|
}
|
|
22658
|
-
const
|
|
22659
|
-
|
|
22660
|
-
|
|
22661
|
-
|
|
22675
|
+
const b22 = bytes2[i + 1];
|
|
22676
|
+
const b32 = bytes2[i + 2];
|
|
22677
|
+
const valid2 = (b22 & 192) === 128 && (b32 & 192) === 128 && !(b1 === 224 && b22 < 160) && !(b1 === 237 && b22 >= 160);
|
|
22678
|
+
if (!valid2) {
|
|
22679
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22680
|
+
i++;
|
|
22681
|
+
continue;
|
|
22682
|
+
}
|
|
22683
|
+
const cp2 = (b1 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
22684
|
+
pushCodeUnit(parts, chunk, cp2);
|
|
22685
|
+
i += 3;
|
|
22686
|
+
continue;
|
|
22662
22687
|
}
|
|
22663
|
-
if (
|
|
22664
|
-
|
|
22688
|
+
if (i + 3 >= bytes2.length) {
|
|
22689
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22690
|
+
i++;
|
|
22691
|
+
continue;
|
|
22665
22692
|
}
|
|
22666
|
-
|
|
22693
|
+
const b2 = bytes2[i + 1];
|
|
22694
|
+
const b3 = bytes2[i + 2];
|
|
22695
|
+
const b4 = bytes2[i + 3];
|
|
22696
|
+
const valid = (b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128 && !(b1 === 240 && b2 < 144) && !(b1 === 244 && b2 > 143);
|
|
22697
|
+
if (!valid) {
|
|
22698
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22699
|
+
i++;
|
|
22700
|
+
continue;
|
|
22701
|
+
}
|
|
22702
|
+
const cp = (b1 & 7) << 18 | (b2 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
|
|
22703
|
+
pushCodePoint(parts, chunk, cp);
|
|
22704
|
+
i += 4;
|
|
22667
22705
|
}
|
|
22706
|
+
flushChunk(parts, chunk);
|
|
22707
|
+
return parts.join("");
|
|
22668
22708
|
}
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
this.s.once("end", () => {
|
|
22687
|
-
this.endOfStream = true;
|
|
22688
|
-
if (this.deferred) {
|
|
22689
|
-
this.deferred.resolve(0);
|
|
22709
|
+
function decodeUTF16LE(bytes2) {
|
|
22710
|
+
const parts = [];
|
|
22711
|
+
const chunk = [];
|
|
22712
|
+
const len = bytes2.length;
|
|
22713
|
+
let i = 0;
|
|
22714
|
+
while (i + 1 < len) {
|
|
22715
|
+
const u1 = bytes2[i] | bytes2[i + 1] << 8;
|
|
22716
|
+
i += 2;
|
|
22717
|
+
if (u1 >= 55296 && u1 <= 56319) {
|
|
22718
|
+
if (i + 1 < len) {
|
|
22719
|
+
const u2 = bytes2[i] | bytes2[i + 1] << 8;
|
|
22720
|
+
if (u2 >= 56320 && u2 <= 57343) {
|
|
22721
|
+
pushCodeUnit(parts, chunk, u1);
|
|
22722
|
+
pushCodeUnit(parts, chunk, u2);
|
|
22723
|
+
i += 2;
|
|
22724
|
+
} else {
|
|
22725
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22690
22726
|
}
|
|
22691
|
-
}
|
|
22692
|
-
|
|
22693
|
-
this.s.once("close", () => this.abort());
|
|
22694
|
-
}
|
|
22695
|
-
async readFromStream(buffer, mayBeLess) {
|
|
22696
|
-
if (buffer.length === 0)
|
|
22697
|
-
return 0;
|
|
22698
|
-
const readBuffer = this.s.read(buffer.length);
|
|
22699
|
-
if (readBuffer) {
|
|
22700
|
-
buffer.set(readBuffer);
|
|
22701
|
-
return readBuffer.length;
|
|
22727
|
+
} else {
|
|
22728
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22702
22729
|
}
|
|
22703
|
-
|
|
22704
|
-
buffer,
|
|
22705
|
-
mayBeLess,
|
|
22706
|
-
deferred: new Deferred
|
|
22707
|
-
};
|
|
22708
|
-
this.deferred = request.deferred;
|
|
22709
|
-
this.s.once("readable", () => {
|
|
22710
|
-
this.readDeferred(request);
|
|
22711
|
-
});
|
|
22712
|
-
return request.deferred.promise;
|
|
22730
|
+
continue;
|
|
22713
22731
|
}
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
request.buffer.set(readBuffer);
|
|
22718
|
-
request.deferred.resolve(readBuffer.length);
|
|
22719
|
-
this.deferred = null;
|
|
22720
|
-
} else {
|
|
22721
|
-
this.s.once("readable", () => {
|
|
22722
|
-
this.readDeferred(request);
|
|
22723
|
-
});
|
|
22724
|
-
}
|
|
22732
|
+
if (u1 >= 56320 && u1 <= 57343) {
|
|
22733
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22734
|
+
continue;
|
|
22725
22735
|
}
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
|
|
22731
|
-
|
|
22736
|
+
pushCodeUnit(parts, chunk, u1);
|
|
22737
|
+
}
|
|
22738
|
+
if (i < len) {
|
|
22739
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22740
|
+
}
|
|
22741
|
+
flushChunk(parts, chunk);
|
|
22742
|
+
return parts.join("");
|
|
22743
|
+
}
|
|
22744
|
+
function decodeASCII(bytes2) {
|
|
22745
|
+
const parts = [];
|
|
22746
|
+
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
22747
|
+
const end = Math.min(bytes2.length, i + CHUNK);
|
|
22748
|
+
const codes = new Array(end - i);
|
|
22749
|
+
for (let j = i, k = 0;j < end; j++, k++) {
|
|
22750
|
+
codes[k] = bytes2[j] & 127;
|
|
22732
22751
|
}
|
|
22733
|
-
|
|
22734
|
-
|
|
22752
|
+
parts.push(String.fromCharCode.apply(null, codes));
|
|
22753
|
+
}
|
|
22754
|
+
return parts.join("");
|
|
22755
|
+
}
|
|
22756
|
+
function decodeLatin1(bytes2) {
|
|
22757
|
+
const parts = [];
|
|
22758
|
+
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
22759
|
+
const end = Math.min(bytes2.length, i + CHUNK);
|
|
22760
|
+
const codes = new Array(end - i);
|
|
22761
|
+
for (let j = i, k = 0;j < end; j++, k++) {
|
|
22762
|
+
codes[k] = bytes2[j];
|
|
22735
22763
|
}
|
|
22736
|
-
|
|
22737
|
-
|
|
22764
|
+
parts.push(String.fromCharCode.apply(null, codes));
|
|
22765
|
+
}
|
|
22766
|
+
return parts.join("");
|
|
22767
|
+
}
|
|
22768
|
+
function decodeWindows1252(bytes2) {
|
|
22769
|
+
const parts = [];
|
|
22770
|
+
let out = "";
|
|
22771
|
+
for (let i = 0;i < bytes2.length; i++) {
|
|
22772
|
+
const b = bytes2[i];
|
|
22773
|
+
const extra = b >= 128 && b <= 159 ? WINDOWS_1252_EXTRA[b] : undefined;
|
|
22774
|
+
out += extra !== null && extra !== undefined ? extra : String.fromCharCode(b);
|
|
22775
|
+
if (out.length >= CHUNK) {
|
|
22776
|
+
parts.push(out);
|
|
22777
|
+
out = "";
|
|
22738
22778
|
}
|
|
22779
|
+
}
|
|
22780
|
+
if (out)
|
|
22781
|
+
parts.push(out);
|
|
22782
|
+
return parts.join("");
|
|
22783
|
+
}
|
|
22784
|
+
var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK, REPLACEMENT = 65533;
|
|
22785
|
+
var init_lib = __esm(() => {
|
|
22786
|
+
WINDOWS_1252_EXTRA = {
|
|
22787
|
+
128: "\u20AC",
|
|
22788
|
+
130: "\u201A",
|
|
22789
|
+
131: "\u0192",
|
|
22790
|
+
132: "\u201E",
|
|
22791
|
+
133: "\u2026",
|
|
22792
|
+
134: "\u2020",
|
|
22793
|
+
135: "\u2021",
|
|
22794
|
+
136: "\u02C6",
|
|
22795
|
+
137: "\u2030",
|
|
22796
|
+
138: "\u0160",
|
|
22797
|
+
139: "\u2039",
|
|
22798
|
+
140: "\u0152",
|
|
22799
|
+
142: "\u017D",
|
|
22800
|
+
145: "\u2018",
|
|
22801
|
+
146: "\u2019",
|
|
22802
|
+
147: "\u201C",
|
|
22803
|
+
148: "\u201D",
|
|
22804
|
+
149: "\u2022",
|
|
22805
|
+
150: "\u2013",
|
|
22806
|
+
151: "\u2014",
|
|
22807
|
+
152: "\u02DC",
|
|
22808
|
+
153: "\u2122",
|
|
22809
|
+
154: "\u0161",
|
|
22810
|
+
155: "\u203A",
|
|
22811
|
+
156: "\u0153",
|
|
22812
|
+
158: "\u017E",
|
|
22813
|
+
159: "\u0178"
|
|
22739
22814
|
};
|
|
22815
|
+
WINDOWS_1252_REVERSE = {};
|
|
22816
|
+
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
|
22817
|
+
WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
|
|
22818
|
+
}
|
|
22819
|
+
CHUNK = 32 * 1024;
|
|
22740
22820
|
});
|
|
22741
22821
|
|
|
22742
|
-
// ../../node_modules/
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
|
|
22755
|
-
|
|
22822
|
+
// ../../node_modules/token-types/lib/index.js
|
|
22823
|
+
function dv(array) {
|
|
22824
|
+
return new DataView(array.buffer, array.byteOffset);
|
|
22825
|
+
}
|
|
22826
|
+
|
|
22827
|
+
class StringType2 {
|
|
22828
|
+
constructor(len, encoding) {
|
|
22829
|
+
this.len = len;
|
|
22830
|
+
this.encoding = encoding;
|
|
22831
|
+
}
|
|
22832
|
+
get(data, offset = 0) {
|
|
22833
|
+
const bytes2 = data.subarray(offset, offset + this.len);
|
|
22834
|
+
return textDecode(bytes2, this.encoding);
|
|
22835
|
+
}
|
|
22836
|
+
}
|
|
22837
|
+
var UINT8, UINT16_LE, UINT16_BE, UINT32_LE, UINT32_BE, INT32_BE, UINT64_LE;
|
|
22838
|
+
var init_lib2 = __esm(() => {
|
|
22839
|
+
init_ieee754();
|
|
22840
|
+
init_lib();
|
|
22841
|
+
UINT8 = {
|
|
22842
|
+
len: 1,
|
|
22843
|
+
get(array, offset) {
|
|
22844
|
+
return dv(array).getUint8(offset);
|
|
22845
|
+
},
|
|
22846
|
+
put(array, offset, value) {
|
|
22847
|
+
dv(array).setUint8(offset, value);
|
|
22848
|
+
return offset + 1;
|
|
22756
22849
|
}
|
|
22757
22850
|
};
|
|
22758
|
-
|
|
22759
|
-
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
22763
|
-
|
|
22764
|
-
|
|
22765
|
-
|
|
22766
|
-
if (buffer.length === 0)
|
|
22767
|
-
return 0;
|
|
22768
|
-
const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? undefined : buffer.length });
|
|
22769
|
-
if (result.done) {
|
|
22770
|
-
this.endOfStream = result.done;
|
|
22771
|
-
}
|
|
22772
|
-
if (result.value) {
|
|
22773
|
-
buffer.set(result.value);
|
|
22774
|
-
return result.value.length;
|
|
22775
|
-
}
|
|
22776
|
-
return 0;
|
|
22851
|
+
UINT16_LE = {
|
|
22852
|
+
len: 2,
|
|
22853
|
+
get(array, offset) {
|
|
22854
|
+
return dv(array).getUint16(offset, true);
|
|
22855
|
+
},
|
|
22856
|
+
put(array, offset, value) {
|
|
22857
|
+
dv(array).setUint16(offset, value, true);
|
|
22858
|
+
return offset + 2;
|
|
22777
22859
|
}
|
|
22778
22860
|
};
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
constructor(reader) {
|
|
22788
|
-
super();
|
|
22789
|
-
this.reader = reader;
|
|
22790
|
-
this.buffer = null;
|
|
22861
|
+
UINT16_BE = {
|
|
22862
|
+
len: 2,
|
|
22863
|
+
get(array, offset) {
|
|
22864
|
+
return dv(array).getUint16(offset);
|
|
22865
|
+
},
|
|
22866
|
+
put(array, offset, value) {
|
|
22867
|
+
dv(array).setUint16(offset, value);
|
|
22868
|
+
return offset + 2;
|
|
22791
22869
|
}
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22800
|
-
return
|
|
22870
|
+
};
|
|
22871
|
+
UINT32_LE = {
|
|
22872
|
+
len: 4,
|
|
22873
|
+
get(array, offset) {
|
|
22874
|
+
return dv(array).getUint32(offset, true);
|
|
22875
|
+
},
|
|
22876
|
+
put(array, offset, value) {
|
|
22877
|
+
dv(array).setUint32(offset, value, true);
|
|
22878
|
+
return offset + 4;
|
|
22801
22879
|
}
|
|
22802
|
-
|
|
22803
|
-
|
|
22804
|
-
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
if (result.done) {
|
|
22812
|
-
this.endOfStream = true;
|
|
22813
|
-
break;
|
|
22814
|
-
}
|
|
22815
|
-
if (result.value) {
|
|
22816
|
-
totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
|
|
22817
|
-
}
|
|
22818
|
-
}
|
|
22819
|
-
if (!mayBeLess && totalBytesRead === 0 && this.endOfStream) {
|
|
22820
|
-
throw new EndOfStreamError;
|
|
22821
|
-
}
|
|
22822
|
-
return totalBytesRead;
|
|
22880
|
+
};
|
|
22881
|
+
UINT32_BE = {
|
|
22882
|
+
len: 4,
|
|
22883
|
+
get(array, offset) {
|
|
22884
|
+
return dv(array).getUint32(offset);
|
|
22885
|
+
},
|
|
22886
|
+
put(array, offset, value) {
|
|
22887
|
+
dv(array).setUint32(offset, value);
|
|
22888
|
+
return offset + 4;
|
|
22823
22889
|
}
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
-
|
|
22890
|
+
};
|
|
22891
|
+
INT32_BE = {
|
|
22892
|
+
len: 4,
|
|
22893
|
+
get(array, offset) {
|
|
22894
|
+
return dv(array).getInt32(offset);
|
|
22895
|
+
},
|
|
22896
|
+
put(array, offset, value) {
|
|
22897
|
+
dv(array).setInt32(offset, value);
|
|
22898
|
+
return offset + 4;
|
|
22827
22899
|
}
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
|
|
22900
|
+
};
|
|
22901
|
+
UINT64_LE = {
|
|
22902
|
+
len: 8,
|
|
22903
|
+
get(array, offset) {
|
|
22904
|
+
return dv(array).getBigUint64(offset, true);
|
|
22905
|
+
},
|
|
22906
|
+
put(array, offset, value) {
|
|
22907
|
+
dv(array).setBigUint64(offset, value, true);
|
|
22908
|
+
return offset + 8;
|
|
22909
|
+
}
|
|
22910
|
+
};
|
|
22911
|
+
});
|
|
22912
|
+
|
|
22913
|
+
// ../../node_modules/strtok3/lib/stream/Errors.js
|
|
22914
|
+
var defaultMessages = "End-Of-Stream", EndOfStreamError, AbortError;
|
|
22915
|
+
var init_Errors = __esm(() => {
|
|
22916
|
+
EndOfStreamError = class EndOfStreamError extends Error {
|
|
22917
|
+
constructor() {
|
|
22918
|
+
super(defaultMessages);
|
|
22919
|
+
this.name = "EndOfStreamError";
|
|
22920
|
+
}
|
|
22921
|
+
};
|
|
22922
|
+
AbortError = class AbortError extends Error {
|
|
22923
|
+
constructor(message = "The operation was aborted") {
|
|
22924
|
+
super(message);
|
|
22925
|
+
this.name = "AbortError";
|
|
22926
|
+
}
|
|
22927
|
+
};
|
|
22928
|
+
});
|
|
22929
|
+
|
|
22930
|
+
// ../../node_modules/strtok3/lib/stream/Deferred.js
|
|
22931
|
+
class Deferred {
|
|
22932
|
+
constructor() {
|
|
22933
|
+
this.resolve = () => null;
|
|
22934
|
+
this.reject = () => null;
|
|
22935
|
+
this.promise = new Promise((resolve3, reject) => {
|
|
22936
|
+
this.reject = reject;
|
|
22937
|
+
this.resolve = resolve3;
|
|
22938
|
+
});
|
|
22939
|
+
}
|
|
22940
|
+
}
|
|
22941
|
+
|
|
22942
|
+
// ../../node_modules/strtok3/lib/stream/AbstractStreamReader.js
|
|
22943
|
+
class AbstractStreamReader {
|
|
22944
|
+
constructor() {
|
|
22945
|
+
this.endOfStream = false;
|
|
22946
|
+
this.interrupted = false;
|
|
22947
|
+
this.peekQueue = [];
|
|
22948
|
+
}
|
|
22949
|
+
async peek(uint8Array, mayBeLess = false) {
|
|
22950
|
+
const bytesRead = await this.read(uint8Array, mayBeLess);
|
|
22951
|
+
this.peekQueue.push(uint8Array.subarray(0, bytesRead));
|
|
22952
|
+
return bytesRead;
|
|
22953
|
+
}
|
|
22954
|
+
async read(buffer, mayBeLess = false) {
|
|
22955
|
+
if (buffer.length === 0) {
|
|
22956
|
+
return 0;
|
|
22957
|
+
}
|
|
22958
|
+
let bytesRead = this.readFromPeekBuffer(buffer);
|
|
22959
|
+
if (!this.endOfStream) {
|
|
22960
|
+
bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
|
|
22961
|
+
}
|
|
22962
|
+
if (bytesRead === 0 && !mayBeLess) {
|
|
22963
|
+
throw new EndOfStreamError;
|
|
22964
|
+
}
|
|
22965
|
+
return bytesRead;
|
|
22966
|
+
}
|
|
22967
|
+
readFromPeekBuffer(buffer) {
|
|
22968
|
+
let remaining = buffer.length;
|
|
22969
|
+
let bytesRead = 0;
|
|
22970
|
+
while (this.peekQueue.length > 0 && remaining > 0) {
|
|
22971
|
+
const peekData = this.peekQueue.pop();
|
|
22972
|
+
if (!peekData)
|
|
22973
|
+
throw new Error("peekData should be defined");
|
|
22974
|
+
const lenCopy = Math.min(peekData.length, remaining);
|
|
22975
|
+
buffer.set(peekData.subarray(0, lenCopy), bytesRead);
|
|
22976
|
+
bytesRead += lenCopy;
|
|
22977
|
+
remaining -= lenCopy;
|
|
22978
|
+
if (lenCopy < peekData.length) {
|
|
22979
|
+
this.peekQueue.push(peekData.subarray(lenCopy));
|
|
22980
|
+
}
|
|
22981
|
+
}
|
|
22982
|
+
return bytesRead;
|
|
22983
|
+
}
|
|
22984
|
+
async readRemainderFromStream(buffer, mayBeLess) {
|
|
22985
|
+
let bytesRead = 0;
|
|
22986
|
+
while (bytesRead < buffer.length && !this.endOfStream) {
|
|
22987
|
+
if (this.interrupted) {
|
|
22988
|
+
throw new AbortError;
|
|
22989
|
+
}
|
|
22990
|
+
const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);
|
|
22991
|
+
if (chunkLen === 0)
|
|
22992
|
+
break;
|
|
22993
|
+
bytesRead += chunkLen;
|
|
22994
|
+
}
|
|
22995
|
+
if (!mayBeLess && bytesRead < buffer.length) {
|
|
22996
|
+
throw new EndOfStreamError;
|
|
22997
|
+
}
|
|
22998
|
+
return bytesRead;
|
|
22999
|
+
}
|
|
23000
|
+
}
|
|
23001
|
+
var init_AbstractStreamReader = __esm(() => {
|
|
23002
|
+
init_Errors();
|
|
23003
|
+
});
|
|
23004
|
+
|
|
23005
|
+
// ../../node_modules/strtok3/lib/stream/StreamReader.js
|
|
23006
|
+
var StreamReader;
|
|
23007
|
+
var init_StreamReader = __esm(() => {
|
|
23008
|
+
init_Errors();
|
|
23009
|
+
init_AbstractStreamReader();
|
|
23010
|
+
StreamReader = class StreamReader extends AbstractStreamReader {
|
|
23011
|
+
constructor(s) {
|
|
23012
|
+
super();
|
|
23013
|
+
this.s = s;
|
|
23014
|
+
this.deferred = null;
|
|
23015
|
+
if (!s.read || !s.once) {
|
|
23016
|
+
throw new Error("Expected an instance of stream.Readable");
|
|
23017
|
+
}
|
|
23018
|
+
this.s.once("end", () => {
|
|
23019
|
+
this.endOfStream = true;
|
|
23020
|
+
if (this.deferred) {
|
|
23021
|
+
this.deferred.resolve(0);
|
|
23022
|
+
}
|
|
23023
|
+
});
|
|
23024
|
+
this.s.once("error", (err) => this.reject(err));
|
|
23025
|
+
this.s.once("close", () => this.abort());
|
|
23026
|
+
}
|
|
23027
|
+
async readFromStream(buffer, mayBeLess) {
|
|
23028
|
+
if (buffer.length === 0)
|
|
23029
|
+
return 0;
|
|
23030
|
+
const readBuffer = this.s.read(buffer.length);
|
|
23031
|
+
if (readBuffer) {
|
|
23032
|
+
buffer.set(readBuffer);
|
|
23033
|
+
return readBuffer.length;
|
|
23034
|
+
}
|
|
23035
|
+
const request = {
|
|
23036
|
+
buffer,
|
|
23037
|
+
mayBeLess,
|
|
23038
|
+
deferred: new Deferred
|
|
23039
|
+
};
|
|
23040
|
+
this.deferred = request.deferred;
|
|
23041
|
+
this.s.once("readable", () => {
|
|
23042
|
+
this.readDeferred(request);
|
|
23043
|
+
});
|
|
23044
|
+
return request.deferred.promise;
|
|
23045
|
+
}
|
|
23046
|
+
readDeferred(request) {
|
|
23047
|
+
const readBuffer = this.s.read(request.buffer.length);
|
|
23048
|
+
if (readBuffer) {
|
|
23049
|
+
request.buffer.set(readBuffer);
|
|
23050
|
+
request.deferred.resolve(readBuffer.length);
|
|
23051
|
+
this.deferred = null;
|
|
23052
|
+
} else {
|
|
23053
|
+
this.s.once("readable", () => {
|
|
23054
|
+
this.readDeferred(request);
|
|
23055
|
+
});
|
|
23056
|
+
}
|
|
23057
|
+
}
|
|
23058
|
+
reject(err) {
|
|
23059
|
+
this.interrupted = true;
|
|
23060
|
+
if (this.deferred) {
|
|
23061
|
+
this.deferred.reject(err);
|
|
23062
|
+
this.deferred = null;
|
|
23063
|
+
}
|
|
23064
|
+
}
|
|
23065
|
+
async abort() {
|
|
23066
|
+
this.reject(new AbortError);
|
|
23067
|
+
}
|
|
23068
|
+
async close() {
|
|
23069
|
+
return this.abort();
|
|
23070
|
+
}
|
|
23071
|
+
};
|
|
23072
|
+
});
|
|
23073
|
+
|
|
23074
|
+
// ../../node_modules/strtok3/lib/stream/WebStreamReader.js
|
|
23075
|
+
var WebStreamReader;
|
|
23076
|
+
var init_WebStreamReader = __esm(() => {
|
|
23077
|
+
init_AbstractStreamReader();
|
|
23078
|
+
WebStreamReader = class WebStreamReader extends AbstractStreamReader {
|
|
23079
|
+
constructor(reader) {
|
|
23080
|
+
super();
|
|
23081
|
+
this.reader = reader;
|
|
23082
|
+
}
|
|
23083
|
+
async abort() {
|
|
23084
|
+
return this.close();
|
|
23085
|
+
}
|
|
23086
|
+
async close() {
|
|
23087
|
+
this.reader.releaseLock();
|
|
23088
|
+
}
|
|
23089
|
+
};
|
|
23090
|
+
});
|
|
23091
|
+
|
|
23092
|
+
// ../../node_modules/strtok3/lib/stream/WebStreamByobReader.js
|
|
23093
|
+
var WebStreamByobReader;
|
|
23094
|
+
var init_WebStreamByobReader = __esm(() => {
|
|
23095
|
+
init_WebStreamReader();
|
|
23096
|
+
WebStreamByobReader = class WebStreamByobReader extends WebStreamReader {
|
|
23097
|
+
async readFromStream(buffer, mayBeLess) {
|
|
23098
|
+
if (buffer.length === 0)
|
|
23099
|
+
return 0;
|
|
23100
|
+
const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? undefined : buffer.length });
|
|
23101
|
+
if (result.done) {
|
|
23102
|
+
this.endOfStream = result.done;
|
|
23103
|
+
}
|
|
23104
|
+
if (result.value) {
|
|
23105
|
+
buffer.set(result.value);
|
|
23106
|
+
return result.value.length;
|
|
23107
|
+
}
|
|
23108
|
+
return 0;
|
|
23109
|
+
}
|
|
23110
|
+
};
|
|
23111
|
+
});
|
|
23112
|
+
|
|
23113
|
+
// ../../node_modules/strtok3/lib/stream/WebStreamDefaultReader.js
|
|
23114
|
+
var WebStreamDefaultReader;
|
|
23115
|
+
var init_WebStreamDefaultReader = __esm(() => {
|
|
23116
|
+
init_Errors();
|
|
23117
|
+
init_AbstractStreamReader();
|
|
23118
|
+
WebStreamDefaultReader = class WebStreamDefaultReader extends AbstractStreamReader {
|
|
23119
|
+
constructor(reader) {
|
|
23120
|
+
super();
|
|
23121
|
+
this.reader = reader;
|
|
23122
|
+
this.buffer = null;
|
|
23123
|
+
}
|
|
23124
|
+
writeChunk(target, chunk) {
|
|
23125
|
+
const written = Math.min(chunk.length, target.length);
|
|
23126
|
+
target.set(chunk.subarray(0, written));
|
|
23127
|
+
if (written < chunk.length) {
|
|
23128
|
+
this.buffer = chunk.subarray(written);
|
|
23129
|
+
} else {
|
|
23130
|
+
this.buffer = null;
|
|
23131
|
+
}
|
|
23132
|
+
return written;
|
|
23133
|
+
}
|
|
23134
|
+
async readFromStream(buffer, mayBeLess) {
|
|
23135
|
+
if (buffer.length === 0)
|
|
23136
|
+
return 0;
|
|
23137
|
+
let totalBytesRead = 0;
|
|
23138
|
+
if (this.buffer) {
|
|
23139
|
+
totalBytesRead += this.writeChunk(buffer, this.buffer);
|
|
23140
|
+
}
|
|
23141
|
+
while (totalBytesRead < buffer.length && !this.endOfStream) {
|
|
23142
|
+
const result = await this.reader.read();
|
|
23143
|
+
if (result.done) {
|
|
23144
|
+
this.endOfStream = true;
|
|
23145
|
+
break;
|
|
23146
|
+
}
|
|
23147
|
+
if (result.value) {
|
|
23148
|
+
totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
|
|
23149
|
+
}
|
|
23150
|
+
}
|
|
23151
|
+
if (!mayBeLess && totalBytesRead === 0 && this.endOfStream) {
|
|
23152
|
+
throw new EndOfStreamError;
|
|
23153
|
+
}
|
|
23154
|
+
return totalBytesRead;
|
|
23155
|
+
}
|
|
23156
|
+
abort() {
|
|
23157
|
+
this.interrupted = true;
|
|
23158
|
+
return this.reader.cancel();
|
|
23159
|
+
}
|
|
23160
|
+
async close() {
|
|
23161
|
+
await this.abort();
|
|
23162
|
+
this.reader.releaseLock();
|
|
22831
23163
|
}
|
|
22832
23164
|
};
|
|
22833
23165
|
});
|
|
@@ -23150,495 +23482,93 @@ var init_core = __esm(() => {
|
|
|
23150
23482
|
init_AbstractTokenizer();
|
|
23151
23483
|
});
|
|
23152
23484
|
|
|
23153
|
-
// ../../node_modules/
|
|
23154
|
-
|
|
23155
|
-
|
|
23156
|
-
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
FileTokenizer = class FileTokenizer extends AbstractTokenizer {
|
|
23160
|
-
static async fromFile(sourceFilePath) {
|
|
23161
|
-
const fileHandle = await fsOpen(sourceFilePath, "r");
|
|
23162
|
-
const stat2 = await fileHandle.stat();
|
|
23163
|
-
return new FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size: stat2.size } });
|
|
23164
|
-
}
|
|
23165
|
-
constructor(fileHandle, options) {
|
|
23166
|
-
super(options);
|
|
23167
|
-
this.fileHandle = fileHandle;
|
|
23168
|
-
this.fileInfo = options.fileInfo;
|
|
23485
|
+
// ../../node_modules/ms/index.js
|
|
23486
|
+
var require_ms = __commonJS((exports, module) => {
|
|
23487
|
+
function parse2(str) {
|
|
23488
|
+
str = String(str);
|
|
23489
|
+
if (str.length > 100) {
|
|
23490
|
+
return;
|
|
23169
23491
|
}
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
23173
|
-
if (normOptions.length === 0)
|
|
23174
|
-
return 0;
|
|
23175
|
-
const res = await this.fileHandle.read(uint8Array, 0, normOptions.length, normOptions.position);
|
|
23176
|
-
this.position += res.bytesRead;
|
|
23177
|
-
if (res.bytesRead < normOptions.length && (!options || !options.mayBeLess)) {
|
|
23178
|
-
throw new EndOfStreamError;
|
|
23179
|
-
}
|
|
23180
|
-
return res.bytesRead;
|
|
23492
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
23493
|
+
if (!match) {
|
|
23494
|
+
return;
|
|
23181
23495
|
}
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23496
|
+
var n = parseFloat(match[1]);
|
|
23497
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
23498
|
+
switch (type) {
|
|
23499
|
+
case "years":
|
|
23500
|
+
case "year":
|
|
23501
|
+
case "yrs":
|
|
23502
|
+
case "yr":
|
|
23503
|
+
case "y":
|
|
23504
|
+
return n * y;
|
|
23505
|
+
case "weeks":
|
|
23506
|
+
case "week":
|
|
23507
|
+
case "w":
|
|
23508
|
+
return n * w;
|
|
23509
|
+
case "days":
|
|
23510
|
+
case "day":
|
|
23511
|
+
case "d":
|
|
23512
|
+
return n * d;
|
|
23513
|
+
case "hours":
|
|
23514
|
+
case "hour":
|
|
23515
|
+
case "hrs":
|
|
23516
|
+
case "hr":
|
|
23517
|
+
case "h":
|
|
23518
|
+
return n * h;
|
|
23519
|
+
case "minutes":
|
|
23520
|
+
case "minute":
|
|
23521
|
+
case "mins":
|
|
23522
|
+
case "min":
|
|
23523
|
+
case "m":
|
|
23524
|
+
return n * m;
|
|
23525
|
+
case "seconds":
|
|
23526
|
+
case "second":
|
|
23527
|
+
case "secs":
|
|
23528
|
+
case "sec":
|
|
23529
|
+
case "s":
|
|
23530
|
+
return n * s;
|
|
23531
|
+
case "milliseconds":
|
|
23532
|
+
case "millisecond":
|
|
23533
|
+
case "msecs":
|
|
23534
|
+
case "msec":
|
|
23535
|
+
case "ms":
|
|
23536
|
+
return n;
|
|
23537
|
+
default:
|
|
23538
|
+
return;
|
|
23189
23539
|
}
|
|
23190
|
-
|
|
23191
|
-
|
|
23192
|
-
|
|
23540
|
+
}
|
|
23541
|
+
function fmtShort(ms) {
|
|
23542
|
+
var msAbs = Math.abs(ms);
|
|
23543
|
+
if (msAbs >= d) {
|
|
23544
|
+
return Math.round(ms / d) + "d";
|
|
23193
23545
|
}
|
|
23194
|
-
|
|
23195
|
-
|
|
23546
|
+
if (msAbs >= h) {
|
|
23547
|
+
return Math.round(ms / h) + "h";
|
|
23196
23548
|
}
|
|
23197
|
-
|
|
23198
|
-
return
|
|
23549
|
+
if (msAbs >= m) {
|
|
23550
|
+
return Math.round(ms / m) + "m";
|
|
23199
23551
|
}
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
// ../../node_modules/strtok3/lib/index.js
|
|
23204
|
-
import { stat as fsStat } from "node:fs/promises";
|
|
23205
|
-
async function fromStream2(stream, options) {
|
|
23206
|
-
const rst = fromStream(stream, options);
|
|
23207
|
-
if (stream.path) {
|
|
23208
|
-
const stat2 = await fsStat(stream.path);
|
|
23209
|
-
rst.fileInfo.path = stream.path;
|
|
23210
|
-
rst.fileInfo.size = stat2.size;
|
|
23211
|
-
}
|
|
23212
|
-
return rst;
|
|
23213
|
-
}
|
|
23214
|
-
var fromFile;
|
|
23215
|
-
var init_lib = __esm(() => {
|
|
23216
|
-
init_core();
|
|
23217
|
-
init_FileTokenizer();
|
|
23218
|
-
init_FileTokenizer();
|
|
23219
|
-
init_core();
|
|
23220
|
-
fromFile = FileTokenizer.fromFile;
|
|
23221
|
-
});
|
|
23222
|
-
|
|
23223
|
-
// ../../node_modules/ieee754/index.js
|
|
23224
|
-
var init_ieee754 = __esm(() => {
|
|
23225
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
23226
|
-
});
|
|
23227
|
-
|
|
23228
|
-
// ../../node_modules/@borewit/text-codec/lib/index.js
|
|
23229
|
-
function utf8Decoder() {
|
|
23230
|
-
if (typeof globalThis.TextDecoder === "undefined")
|
|
23231
|
-
return;
|
|
23232
|
-
return _utf8Decoder !== null && _utf8Decoder !== undefined ? _utf8Decoder : _utf8Decoder = new globalThis.TextDecoder("utf-8");
|
|
23233
|
-
}
|
|
23234
|
-
function textDecode(bytes2, encoding = "utf-8") {
|
|
23235
|
-
switch (encoding.toLowerCase()) {
|
|
23236
|
-
case "utf-8":
|
|
23237
|
-
case "utf8": {
|
|
23238
|
-
const dec = utf8Decoder();
|
|
23239
|
-
return dec ? dec.decode(bytes2) : decodeUTF8(bytes2);
|
|
23552
|
+
if (msAbs >= s) {
|
|
23553
|
+
return Math.round(ms / s) + "s";
|
|
23240
23554
|
}
|
|
23241
|
-
|
|
23242
|
-
return decodeUTF16LE(bytes2);
|
|
23243
|
-
case "us-ascii":
|
|
23244
|
-
case "ascii":
|
|
23245
|
-
return decodeASCII(bytes2);
|
|
23246
|
-
case "latin1":
|
|
23247
|
-
case "iso-8859-1":
|
|
23248
|
-
return decodeLatin1(bytes2);
|
|
23249
|
-
case "windows-1252":
|
|
23250
|
-
return decodeWindows1252(bytes2);
|
|
23251
|
-
default:
|
|
23252
|
-
throw new RangeError(`Encoding '${encoding}' not supported`);
|
|
23253
|
-
}
|
|
23254
|
-
}
|
|
23255
|
-
function flushChunk(parts, chunk) {
|
|
23256
|
-
if (chunk.length === 0)
|
|
23257
|
-
return;
|
|
23258
|
-
parts.push(String.fromCharCode.apply(null, chunk));
|
|
23259
|
-
chunk.length = 0;
|
|
23260
|
-
}
|
|
23261
|
-
function pushCodeUnit(parts, chunk, codeUnit) {
|
|
23262
|
-
chunk.push(codeUnit);
|
|
23263
|
-
if (chunk.length >= CHUNK)
|
|
23264
|
-
flushChunk(parts, chunk);
|
|
23265
|
-
}
|
|
23266
|
-
function pushCodePoint(parts, chunk, cp) {
|
|
23267
|
-
if (cp <= 65535) {
|
|
23268
|
-
pushCodeUnit(parts, chunk, cp);
|
|
23269
|
-
return;
|
|
23270
|
-
}
|
|
23271
|
-
cp -= 65536;
|
|
23272
|
-
pushCodeUnit(parts, chunk, 55296 + (cp >> 10));
|
|
23273
|
-
pushCodeUnit(parts, chunk, 56320 + (cp & 1023));
|
|
23274
|
-
}
|
|
23275
|
-
function decodeUTF8(bytes2) {
|
|
23276
|
-
const parts = [];
|
|
23277
|
-
const chunk = [];
|
|
23278
|
-
let i = 0;
|
|
23279
|
-
if (bytes2.length >= 3 && bytes2[0] === 239 && bytes2[1] === 187 && bytes2[2] === 191) {
|
|
23280
|
-
i = 3;
|
|
23555
|
+
return ms + "ms";
|
|
23281
23556
|
}
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
if (
|
|
23285
|
-
|
|
23286
|
-
i++;
|
|
23287
|
-
continue;
|
|
23288
|
-
}
|
|
23289
|
-
if (b1 < 194 || b1 > 244) {
|
|
23290
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23291
|
-
i++;
|
|
23292
|
-
continue;
|
|
23293
|
-
}
|
|
23294
|
-
if (b1 <= 223) {
|
|
23295
|
-
if (i + 1 >= bytes2.length) {
|
|
23296
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23297
|
-
i++;
|
|
23298
|
-
continue;
|
|
23299
|
-
}
|
|
23300
|
-
const b22 = bytes2[i + 1];
|
|
23301
|
-
if ((b22 & 192) !== 128) {
|
|
23302
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23303
|
-
i++;
|
|
23304
|
-
continue;
|
|
23305
|
-
}
|
|
23306
|
-
const cp2 = (b1 & 31) << 6 | b22 & 63;
|
|
23307
|
-
pushCodeUnit(parts, chunk, cp2);
|
|
23308
|
-
i += 2;
|
|
23309
|
-
continue;
|
|
23557
|
+
function fmtLong(ms) {
|
|
23558
|
+
var msAbs = Math.abs(ms);
|
|
23559
|
+
if (msAbs >= d) {
|
|
23560
|
+
return plural(ms, msAbs, d, "day");
|
|
23310
23561
|
}
|
|
23311
|
-
if (
|
|
23312
|
-
|
|
23313
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23314
|
-
i++;
|
|
23315
|
-
continue;
|
|
23316
|
-
}
|
|
23317
|
-
const b22 = bytes2[i + 1];
|
|
23318
|
-
const b32 = bytes2[i + 2];
|
|
23319
|
-
const valid2 = (b22 & 192) === 128 && (b32 & 192) === 128 && !(b1 === 224 && b22 < 160) && !(b1 === 237 && b22 >= 160);
|
|
23320
|
-
if (!valid2) {
|
|
23321
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23322
|
-
i++;
|
|
23323
|
-
continue;
|
|
23324
|
-
}
|
|
23325
|
-
const cp2 = (b1 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
23326
|
-
pushCodeUnit(parts, chunk, cp2);
|
|
23327
|
-
i += 3;
|
|
23328
|
-
continue;
|
|
23562
|
+
if (msAbs >= h) {
|
|
23563
|
+
return plural(ms, msAbs, h, "hour");
|
|
23329
23564
|
}
|
|
23330
|
-
if (
|
|
23331
|
-
|
|
23332
|
-
i++;
|
|
23333
|
-
continue;
|
|
23565
|
+
if (msAbs >= m) {
|
|
23566
|
+
return plural(ms, msAbs, m, "minute");
|
|
23334
23567
|
}
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
const b4 = bytes2[i + 3];
|
|
23338
|
-
const valid = (b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128 && !(b1 === 240 && b2 < 144) && !(b1 === 244 && b2 > 143);
|
|
23339
|
-
if (!valid) {
|
|
23340
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23341
|
-
i++;
|
|
23342
|
-
continue;
|
|
23568
|
+
if (msAbs >= s) {
|
|
23569
|
+
return plural(ms, msAbs, s, "second");
|
|
23343
23570
|
}
|
|
23344
|
-
|
|
23345
|
-
pushCodePoint(parts, chunk, cp);
|
|
23346
|
-
i += 4;
|
|
23347
|
-
}
|
|
23348
|
-
flushChunk(parts, chunk);
|
|
23349
|
-
return parts.join("");
|
|
23350
|
-
}
|
|
23351
|
-
function decodeUTF16LE(bytes2) {
|
|
23352
|
-
const parts = [];
|
|
23353
|
-
const chunk = [];
|
|
23354
|
-
const len = bytes2.length;
|
|
23355
|
-
let i = 0;
|
|
23356
|
-
while (i + 1 < len) {
|
|
23357
|
-
const u1 = bytes2[i] | bytes2[i + 1] << 8;
|
|
23358
|
-
i += 2;
|
|
23359
|
-
if (u1 >= 55296 && u1 <= 56319) {
|
|
23360
|
-
if (i + 1 < len) {
|
|
23361
|
-
const u2 = bytes2[i] | bytes2[i + 1] << 8;
|
|
23362
|
-
if (u2 >= 56320 && u2 <= 57343) {
|
|
23363
|
-
pushCodeUnit(parts, chunk, u1);
|
|
23364
|
-
pushCodeUnit(parts, chunk, u2);
|
|
23365
|
-
i += 2;
|
|
23366
|
-
} else {
|
|
23367
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23368
|
-
}
|
|
23369
|
-
} else {
|
|
23370
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23371
|
-
}
|
|
23372
|
-
continue;
|
|
23373
|
-
}
|
|
23374
|
-
if (u1 >= 56320 && u1 <= 57343) {
|
|
23375
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23376
|
-
continue;
|
|
23377
|
-
}
|
|
23378
|
-
pushCodeUnit(parts, chunk, u1);
|
|
23379
|
-
}
|
|
23380
|
-
if (i < len) {
|
|
23381
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23382
|
-
}
|
|
23383
|
-
flushChunk(parts, chunk);
|
|
23384
|
-
return parts.join("");
|
|
23385
|
-
}
|
|
23386
|
-
function decodeASCII(bytes2) {
|
|
23387
|
-
const parts = [];
|
|
23388
|
-
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
23389
|
-
const end = Math.min(bytes2.length, i + CHUNK);
|
|
23390
|
-
const codes = new Array(end - i);
|
|
23391
|
-
for (let j = i, k = 0;j < end; j++, k++) {
|
|
23392
|
-
codes[k] = bytes2[j] & 127;
|
|
23393
|
-
}
|
|
23394
|
-
parts.push(String.fromCharCode.apply(null, codes));
|
|
23395
|
-
}
|
|
23396
|
-
return parts.join("");
|
|
23397
|
-
}
|
|
23398
|
-
function decodeLatin1(bytes2) {
|
|
23399
|
-
const parts = [];
|
|
23400
|
-
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
23401
|
-
const end = Math.min(bytes2.length, i + CHUNK);
|
|
23402
|
-
const codes = new Array(end - i);
|
|
23403
|
-
for (let j = i, k = 0;j < end; j++, k++) {
|
|
23404
|
-
codes[k] = bytes2[j];
|
|
23405
|
-
}
|
|
23406
|
-
parts.push(String.fromCharCode.apply(null, codes));
|
|
23407
|
-
}
|
|
23408
|
-
return parts.join("");
|
|
23409
|
-
}
|
|
23410
|
-
function decodeWindows1252(bytes2) {
|
|
23411
|
-
const parts = [];
|
|
23412
|
-
let out = "";
|
|
23413
|
-
for (let i = 0;i < bytes2.length; i++) {
|
|
23414
|
-
const b = bytes2[i];
|
|
23415
|
-
const extra = b >= 128 && b <= 159 ? WINDOWS_1252_EXTRA[b] : undefined;
|
|
23416
|
-
out += extra !== null && extra !== undefined ? extra : String.fromCharCode(b);
|
|
23417
|
-
if (out.length >= CHUNK) {
|
|
23418
|
-
parts.push(out);
|
|
23419
|
-
out = "";
|
|
23420
|
-
}
|
|
23421
|
-
}
|
|
23422
|
-
if (out)
|
|
23423
|
-
parts.push(out);
|
|
23424
|
-
return parts.join("");
|
|
23425
|
-
}
|
|
23426
|
-
var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK, REPLACEMENT = 65533;
|
|
23427
|
-
var init_lib2 = __esm(() => {
|
|
23428
|
-
WINDOWS_1252_EXTRA = {
|
|
23429
|
-
128: "\u20AC",
|
|
23430
|
-
130: "\u201A",
|
|
23431
|
-
131: "\u0192",
|
|
23432
|
-
132: "\u201E",
|
|
23433
|
-
133: "\u2026",
|
|
23434
|
-
134: "\u2020",
|
|
23435
|
-
135: "\u2021",
|
|
23436
|
-
136: "\u02C6",
|
|
23437
|
-
137: "\u2030",
|
|
23438
|
-
138: "\u0160",
|
|
23439
|
-
139: "\u2039",
|
|
23440
|
-
140: "\u0152",
|
|
23441
|
-
142: "\u017D",
|
|
23442
|
-
145: "\u2018",
|
|
23443
|
-
146: "\u2019",
|
|
23444
|
-
147: "\u201C",
|
|
23445
|
-
148: "\u201D",
|
|
23446
|
-
149: "\u2022",
|
|
23447
|
-
150: "\u2013",
|
|
23448
|
-
151: "\u2014",
|
|
23449
|
-
152: "\u02DC",
|
|
23450
|
-
153: "\u2122",
|
|
23451
|
-
154: "\u0161",
|
|
23452
|
-
155: "\u203A",
|
|
23453
|
-
156: "\u0153",
|
|
23454
|
-
158: "\u017E",
|
|
23455
|
-
159: "\u0178"
|
|
23456
|
-
};
|
|
23457
|
-
WINDOWS_1252_REVERSE = {};
|
|
23458
|
-
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
|
23459
|
-
WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
|
|
23460
|
-
}
|
|
23461
|
-
CHUNK = 32 * 1024;
|
|
23462
|
-
});
|
|
23463
|
-
|
|
23464
|
-
// ../../node_modules/token-types/lib/index.js
|
|
23465
|
-
function dv(array) {
|
|
23466
|
-
return new DataView(array.buffer, array.byteOffset);
|
|
23467
|
-
}
|
|
23468
|
-
|
|
23469
|
-
class StringType2 {
|
|
23470
|
-
constructor(len, encoding) {
|
|
23471
|
-
this.len = len;
|
|
23472
|
-
this.encoding = encoding;
|
|
23473
|
-
}
|
|
23474
|
-
get(data, offset = 0) {
|
|
23475
|
-
const bytes2 = data.subarray(offset, offset + this.len);
|
|
23476
|
-
return textDecode(bytes2, this.encoding);
|
|
23477
|
-
}
|
|
23478
|
-
}
|
|
23479
|
-
var UINT8, UINT16_LE, UINT16_BE, UINT32_LE, UINT32_BE, INT32_BE, UINT64_LE;
|
|
23480
|
-
var init_lib3 = __esm(() => {
|
|
23481
|
-
init_ieee754();
|
|
23482
|
-
init_lib2();
|
|
23483
|
-
UINT8 = {
|
|
23484
|
-
len: 1,
|
|
23485
|
-
get(array, offset) {
|
|
23486
|
-
return dv(array).getUint8(offset);
|
|
23487
|
-
},
|
|
23488
|
-
put(array, offset, value) {
|
|
23489
|
-
dv(array).setUint8(offset, value);
|
|
23490
|
-
return offset + 1;
|
|
23491
|
-
}
|
|
23492
|
-
};
|
|
23493
|
-
UINT16_LE = {
|
|
23494
|
-
len: 2,
|
|
23495
|
-
get(array, offset) {
|
|
23496
|
-
return dv(array).getUint16(offset, true);
|
|
23497
|
-
},
|
|
23498
|
-
put(array, offset, value) {
|
|
23499
|
-
dv(array).setUint16(offset, value, true);
|
|
23500
|
-
return offset + 2;
|
|
23501
|
-
}
|
|
23502
|
-
};
|
|
23503
|
-
UINT16_BE = {
|
|
23504
|
-
len: 2,
|
|
23505
|
-
get(array, offset) {
|
|
23506
|
-
return dv(array).getUint16(offset);
|
|
23507
|
-
},
|
|
23508
|
-
put(array, offset, value) {
|
|
23509
|
-
dv(array).setUint16(offset, value);
|
|
23510
|
-
return offset + 2;
|
|
23511
|
-
}
|
|
23512
|
-
};
|
|
23513
|
-
UINT32_LE = {
|
|
23514
|
-
len: 4,
|
|
23515
|
-
get(array, offset) {
|
|
23516
|
-
return dv(array).getUint32(offset, true);
|
|
23517
|
-
},
|
|
23518
|
-
put(array, offset, value) {
|
|
23519
|
-
dv(array).setUint32(offset, value, true);
|
|
23520
|
-
return offset + 4;
|
|
23521
|
-
}
|
|
23522
|
-
};
|
|
23523
|
-
UINT32_BE = {
|
|
23524
|
-
len: 4,
|
|
23525
|
-
get(array, offset) {
|
|
23526
|
-
return dv(array).getUint32(offset);
|
|
23527
|
-
},
|
|
23528
|
-
put(array, offset, value) {
|
|
23529
|
-
dv(array).setUint32(offset, value);
|
|
23530
|
-
return offset + 4;
|
|
23531
|
-
}
|
|
23532
|
-
};
|
|
23533
|
-
INT32_BE = {
|
|
23534
|
-
len: 4,
|
|
23535
|
-
get(array, offset) {
|
|
23536
|
-
return dv(array).getInt32(offset);
|
|
23537
|
-
},
|
|
23538
|
-
put(array, offset, value) {
|
|
23539
|
-
dv(array).setInt32(offset, value);
|
|
23540
|
-
return offset + 4;
|
|
23541
|
-
}
|
|
23542
|
-
};
|
|
23543
|
-
UINT64_LE = {
|
|
23544
|
-
len: 8,
|
|
23545
|
-
get(array, offset) {
|
|
23546
|
-
return dv(array).getBigUint64(offset, true);
|
|
23547
|
-
},
|
|
23548
|
-
put(array, offset, value) {
|
|
23549
|
-
dv(array).setBigUint64(offset, value, true);
|
|
23550
|
-
return offset + 8;
|
|
23551
|
-
}
|
|
23552
|
-
};
|
|
23553
|
-
});
|
|
23554
|
-
|
|
23555
|
-
// ../../node_modules/ms/index.js
|
|
23556
|
-
var require_ms = __commonJS((exports, module) => {
|
|
23557
|
-
function parse2(str) {
|
|
23558
|
-
str = String(str);
|
|
23559
|
-
if (str.length > 100) {
|
|
23560
|
-
return;
|
|
23561
|
-
}
|
|
23562
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
23563
|
-
if (!match) {
|
|
23564
|
-
return;
|
|
23565
|
-
}
|
|
23566
|
-
var n = parseFloat(match[1]);
|
|
23567
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
23568
|
-
switch (type) {
|
|
23569
|
-
case "years":
|
|
23570
|
-
case "year":
|
|
23571
|
-
case "yrs":
|
|
23572
|
-
case "yr":
|
|
23573
|
-
case "y":
|
|
23574
|
-
return n * y;
|
|
23575
|
-
case "weeks":
|
|
23576
|
-
case "week":
|
|
23577
|
-
case "w":
|
|
23578
|
-
return n * w;
|
|
23579
|
-
case "days":
|
|
23580
|
-
case "day":
|
|
23581
|
-
case "d":
|
|
23582
|
-
return n * d;
|
|
23583
|
-
case "hours":
|
|
23584
|
-
case "hour":
|
|
23585
|
-
case "hrs":
|
|
23586
|
-
case "hr":
|
|
23587
|
-
case "h":
|
|
23588
|
-
return n * h;
|
|
23589
|
-
case "minutes":
|
|
23590
|
-
case "minute":
|
|
23591
|
-
case "mins":
|
|
23592
|
-
case "min":
|
|
23593
|
-
case "m":
|
|
23594
|
-
return n * m;
|
|
23595
|
-
case "seconds":
|
|
23596
|
-
case "second":
|
|
23597
|
-
case "secs":
|
|
23598
|
-
case "sec":
|
|
23599
|
-
case "s":
|
|
23600
|
-
return n * s;
|
|
23601
|
-
case "milliseconds":
|
|
23602
|
-
case "millisecond":
|
|
23603
|
-
case "msecs":
|
|
23604
|
-
case "msec":
|
|
23605
|
-
case "ms":
|
|
23606
|
-
return n;
|
|
23607
|
-
default:
|
|
23608
|
-
return;
|
|
23609
|
-
}
|
|
23610
|
-
}
|
|
23611
|
-
function fmtShort(ms) {
|
|
23612
|
-
var msAbs = Math.abs(ms);
|
|
23613
|
-
if (msAbs >= d) {
|
|
23614
|
-
return Math.round(ms / d) + "d";
|
|
23615
|
-
}
|
|
23616
|
-
if (msAbs >= h) {
|
|
23617
|
-
return Math.round(ms / h) + "h";
|
|
23618
|
-
}
|
|
23619
|
-
if (msAbs >= m) {
|
|
23620
|
-
return Math.round(ms / m) + "m";
|
|
23621
|
-
}
|
|
23622
|
-
if (msAbs >= s) {
|
|
23623
|
-
return Math.round(ms / s) + "s";
|
|
23624
|
-
}
|
|
23625
|
-
return ms + "ms";
|
|
23626
|
-
}
|
|
23627
|
-
function fmtLong(ms) {
|
|
23628
|
-
var msAbs = Math.abs(ms);
|
|
23629
|
-
if (msAbs >= d) {
|
|
23630
|
-
return plural(ms, msAbs, d, "day");
|
|
23631
|
-
}
|
|
23632
|
-
if (msAbs >= h) {
|
|
23633
|
-
return plural(ms, msAbs, h, "hour");
|
|
23634
|
-
}
|
|
23635
|
-
if (msAbs >= m) {
|
|
23636
|
-
return plural(ms, msAbs, m, "minute");
|
|
23637
|
-
}
|
|
23638
|
-
if (msAbs >= s) {
|
|
23639
|
-
return plural(ms, msAbs, s, "second");
|
|
23640
|
-
}
|
|
23641
|
-
return ms + " ms";
|
|
23571
|
+
return ms + " ms";
|
|
23642
23572
|
}
|
|
23643
23573
|
function plural(ms, msAbs, n, name) {
|
|
23644
23574
|
var isPlural = msAbs >= n * 1.5;
|
|
@@ -24182,7 +24112,7 @@ var require_src = __commonJS((exports, module) => {
|
|
|
24182
24112
|
// ../../node_modules/@tokenizer/inflate/lib/ZipToken.js
|
|
24183
24113
|
var Signature, DataDescriptor, LocalFileHeaderToken, EndOfCentralDirectoryRecordToken, FileHeader;
|
|
24184
24114
|
var init_ZipToken = __esm(() => {
|
|
24185
|
-
|
|
24115
|
+
init_lib2();
|
|
24186
24116
|
Signature = {
|
|
24187
24117
|
LocalFileHeader: 67324752,
|
|
24188
24118
|
DataDescriptor: 134695760,
|
|
@@ -24459,7 +24389,7 @@ class ZipHandler {
|
|
|
24459
24389
|
}
|
|
24460
24390
|
var import_debug, debug, syncBufferSize, ddSignatureArray, eocdSignatureBytes;
|
|
24461
24391
|
var init_ZipHandler = __esm(() => {
|
|
24462
|
-
|
|
24392
|
+
init_lib2();
|
|
24463
24393
|
import_debug = __toESM(require_src(), 1);
|
|
24464
24394
|
init_ZipToken();
|
|
24465
24395
|
debug = import_debug.default("tokenizer:inflate");
|
|
@@ -24490,11 +24420,42 @@ class GzipHandler {
|
|
|
24490
24420
|
}
|
|
24491
24421
|
|
|
24492
24422
|
// ../../node_modules/@tokenizer/inflate/lib/index.js
|
|
24493
|
-
var
|
|
24423
|
+
var init_lib3 = __esm(() => {
|
|
24494
24424
|
init_ZipHandler();
|
|
24495
24425
|
});
|
|
24496
24426
|
|
|
24497
24427
|
// ../../node_modules/uint8array-extras/index.js
|
|
24428
|
+
function isType(value, typeConstructor, typeStringified) {
|
|
24429
|
+
if (!value) {
|
|
24430
|
+
return false;
|
|
24431
|
+
}
|
|
24432
|
+
if (value.constructor === typeConstructor) {
|
|
24433
|
+
return true;
|
|
24434
|
+
}
|
|
24435
|
+
return objectToString.call(value) === typeStringified;
|
|
24436
|
+
}
|
|
24437
|
+
function isUint8Array(value) {
|
|
24438
|
+
return isType(value, Uint8Array, uint8ArrayStringified);
|
|
24439
|
+
}
|
|
24440
|
+
function assertUint8Array(value) {
|
|
24441
|
+
if (!isUint8Array(value)) {
|
|
24442
|
+
throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof value}\``);
|
|
24443
|
+
}
|
|
24444
|
+
}
|
|
24445
|
+
function concatUint8Arrays(arrays, totalLength) {
|
|
24446
|
+
if (arrays.length === 0) {
|
|
24447
|
+
return new Uint8Array(0);
|
|
24448
|
+
}
|
|
24449
|
+
totalLength ??= arrays.reduce((accumulator, currentValue) => accumulator + currentValue.length, 0);
|
|
24450
|
+
const returnValue = new Uint8Array(totalLength);
|
|
24451
|
+
let offset = 0;
|
|
24452
|
+
for (const array of arrays) {
|
|
24453
|
+
assertUint8Array(array);
|
|
24454
|
+
returnValue.set(array, offset);
|
|
24455
|
+
offset += array.length;
|
|
24456
|
+
}
|
|
24457
|
+
return returnValue;
|
|
24458
|
+
}
|
|
24498
24459
|
function getUintBE(view) {
|
|
24499
24460
|
const { byteLength } = view;
|
|
24500
24461
|
if (byteLength === 6) {
|
|
@@ -24516,8 +24477,9 @@ function getUintBE(view) {
|
|
|
24516
24477
|
return view.getUint8(0);
|
|
24517
24478
|
}
|
|
24518
24479
|
}
|
|
24519
|
-
var cachedDecoders, cachedEncoder, byteToHexLookupTable;
|
|
24480
|
+
var objectToString, uint8ArrayStringified = "[object Uint8Array]", cachedDecoders, cachedEncoder, byteToHexLookupTable;
|
|
24520
24481
|
var init_uint8array_extras = __esm(() => {
|
|
24482
|
+
objectToString = Object.prototype.toString;
|
|
24521
24483
|
cachedDecoders = {
|
|
24522
24484
|
utf8: new globalThis.TextDecoder("utf8")
|
|
24523
24485
|
};
|
|
@@ -24525,7 +24487,7 @@ var init_uint8array_extras = __esm(() => {
|
|
|
24525
24487
|
byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
|
|
24526
24488
|
});
|
|
24527
24489
|
|
|
24528
|
-
// ../../node_modules/file-type/
|
|
24490
|
+
// ../../node_modules/file-type/source/tokens.js
|
|
24529
24491
|
function stringToBytes(string, encoding) {
|
|
24530
24492
|
if (encoding === "utf-16le") {
|
|
24531
24493
|
const bytes2 = [];
|
|
@@ -24546,7 +24508,7 @@ function stringToBytes(string, encoding) {
|
|
|
24546
24508
|
return [...string].map((character) => character.charCodeAt(0));
|
|
24547
24509
|
}
|
|
24548
24510
|
function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
24549
|
-
const readSum = Number.parseInt(new StringType2(6).get(arrayBuffer, 148).replace(/\0
|
|
24511
|
+
const readSum = Number.parseInt(new StringType2(6).get(arrayBuffer, 148).replace(/\0.*$/v, "").trim(), 8);
|
|
24550
24512
|
if (Number.isNaN(readSum)) {
|
|
24551
24513
|
return false;
|
|
24552
24514
|
}
|
|
@@ -24560,15 +24522,15 @@ function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
|
24560
24522
|
return readSum === sum;
|
|
24561
24523
|
}
|
|
24562
24524
|
var uint32SyncSafeToken;
|
|
24563
|
-
var
|
|
24564
|
-
|
|
24525
|
+
var init_tokens = __esm(() => {
|
|
24526
|
+
init_lib2();
|
|
24565
24527
|
uint32SyncSafeToken = {
|
|
24566
|
-
get: (buffer, offset) => buffer[offset + 3] & 127 | buffer[offset + 2] << 7 | buffer[offset + 1] << 14 | buffer[offset] << 21,
|
|
24528
|
+
get: (buffer, offset) => buffer[offset + 3] & 127 | (buffer[offset + 2] & 127) << 7 | (buffer[offset + 1] & 127) << 14 | (buffer[offset] & 127) << 21,
|
|
24567
24529
|
len: 4
|
|
24568
24530
|
};
|
|
24569
24531
|
});
|
|
24570
24532
|
|
|
24571
|
-
// ../../node_modules/file-type/supported.js
|
|
24533
|
+
// ../../node_modules/file-type/source/supported.js
|
|
24572
24534
|
var extensions, mimeTypes;
|
|
24573
24535
|
var init_supported = __esm(() => {
|
|
24574
24536
|
extensions = [
|
|
@@ -24751,7 +24713,10 @@ var init_supported = __esm(() => {
|
|
|
24751
24713
|
"ppsx",
|
|
24752
24714
|
"tar.gz",
|
|
24753
24715
|
"reg",
|
|
24754
|
-
"dat"
|
|
24716
|
+
"dat",
|
|
24717
|
+
"key",
|
|
24718
|
+
"numbers",
|
|
24719
|
+
"pages"
|
|
24755
24720
|
];
|
|
24756
24721
|
mimeTypes = [
|
|
24757
24722
|
"image/jpeg",
|
|
@@ -24834,7 +24799,7 @@ var init_supported = __esm(() => {
|
|
|
24834
24799
|
"application/x-unix-archive",
|
|
24835
24800
|
"application/x-rpm",
|
|
24836
24801
|
"application/x-compress",
|
|
24837
|
-
"application/
|
|
24802
|
+
"application/lzip",
|
|
24838
24803
|
"application/x-cfb",
|
|
24839
24804
|
"application/x-mie",
|
|
24840
24805
|
"application/mxf",
|
|
@@ -24863,8 +24828,8 @@ var init_supported = __esm(() => {
|
|
|
24863
24828
|
"model/gltf-binary",
|
|
24864
24829
|
"application/vnd.tcpdump.pcap",
|
|
24865
24830
|
"audio/x-dsf",
|
|
24866
|
-
"application/x
|
|
24867
|
-
"application/x
|
|
24831
|
+
"application/x-ms-shortcut",
|
|
24832
|
+
"application/x-ft-apple.alias",
|
|
24868
24833
|
"audio/x-voc",
|
|
24869
24834
|
"audio/vnd.dolby.dd-raw",
|
|
24870
24835
|
"audio/x-m4a",
|
|
@@ -24904,10 +24869,10 @@ var init_supported = __esm(() => {
|
|
|
24904
24869
|
"application/x-ace-compressed",
|
|
24905
24870
|
"application/avro",
|
|
24906
24871
|
"application/vnd.iccprofile",
|
|
24907
|
-
"application/x
|
|
24872
|
+
"application/x-ft-fbx",
|
|
24908
24873
|
"application/vnd.visio",
|
|
24909
24874
|
"application/vnd.android.package-archive",
|
|
24910
|
-
"application/
|
|
24875
|
+
"application/x-ft-draco",
|
|
24911
24876
|
"application/x-lz4",
|
|
24912
24877
|
"application/vnd.openxmlformats-officedocument.presentationml.template",
|
|
24913
24878
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
@@ -24928,168 +24893,953 @@ var init_supported = __esm(() => {
|
|
|
24928
24893
|
"application/x-spss-sav",
|
|
24929
24894
|
"application/x-ms-regedit",
|
|
24930
24895
|
"application/x-ft-windows-registry-hive",
|
|
24931
|
-
"application/x-jmp-data"
|
|
24896
|
+
"application/x-jmp-data",
|
|
24897
|
+
"application/vnd.apple.keynote",
|
|
24898
|
+
"application/vnd.apple.numbers",
|
|
24899
|
+
"application/vnd.apple.pages"
|
|
24932
24900
|
];
|
|
24933
24901
|
});
|
|
24934
24902
|
|
|
24935
|
-
// ../../node_modules/file-type/
|
|
24936
|
-
function
|
|
24937
|
-
|
|
24938
|
-
|
|
24939
|
-
|
|
24903
|
+
// ../../node_modules/file-type/source/parser.js
|
|
24904
|
+
function getSafeBound(value, maximum, reason) {
|
|
24905
|
+
if (!Number.isFinite(value) || value < 0 || value > maximum) {
|
|
24906
|
+
throw new ParserHardLimitError(`${reason} has invalid size ${value} (maximum ${maximum} bytes)`);
|
|
24907
|
+
}
|
|
24908
|
+
return value;
|
|
24909
|
+
}
|
|
24910
|
+
async function safeIgnore(tokenizer, length, { maximumLength = maximumUntrustedSkipSizeInBytes, reason = "skip" } = {}) {
|
|
24911
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
24912
|
+
await tokenizer.ignore(safeLength);
|
|
24913
|
+
}
|
|
24914
|
+
async function safeReadBuffer(tokenizer, buffer, options, { maximumLength = buffer.length, reason = "read" } = {}) {
|
|
24915
|
+
const length = options?.length ?? buffer.length;
|
|
24916
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
24917
|
+
return tokenizer.readBuffer(buffer, {
|
|
24918
|
+
...options,
|
|
24919
|
+
length: safeLength
|
|
24920
|
+
});
|
|
24921
|
+
}
|
|
24922
|
+
function checkBytes(buffer, headers, options) {
|
|
24923
|
+
options = {
|
|
24924
|
+
offset: 0,
|
|
24925
|
+
...options
|
|
24926
|
+
};
|
|
24927
|
+
for (const [index, header] of headers.entries()) {
|
|
24928
|
+
if (options.mask) {
|
|
24929
|
+
if (header !== (options.mask[index] & buffer[index + options.offset])) {
|
|
24930
|
+
return false;
|
|
24931
|
+
}
|
|
24932
|
+
} else if (header !== buffer[index + options.offset]) {
|
|
24933
|
+
return false;
|
|
24934
|
+
}
|
|
24940
24935
|
}
|
|
24941
|
-
|
|
24942
|
-
|
|
24943
|
-
|
|
24936
|
+
return true;
|
|
24937
|
+
}
|
|
24938
|
+
function hasUnknownFileSize(tokenizer) {
|
|
24939
|
+
const fileSize = tokenizer.fileInfo.size;
|
|
24940
|
+
return !Number.isFinite(fileSize) || fileSize === Number.MAX_SAFE_INTEGER;
|
|
24941
|
+
}
|
|
24942
|
+
function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
|
|
24943
|
+
return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
|
|
24944
|
+
}
|
|
24945
|
+
var maximumUntrustedSkipSizeInBytes, ParserHardLimitError;
|
|
24946
|
+
var init_parser = __esm(() => {
|
|
24947
|
+
maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
|
|
24948
|
+
ParserHardLimitError = class ParserHardLimitError extends Error {
|
|
24949
|
+
};
|
|
24950
|
+
});
|
|
24951
|
+
|
|
24952
|
+
// ../../node_modules/file-type/source/detectors/zip.js
|
|
24953
|
+
async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipEntrySizeInBytes } = {}) {
|
|
24954
|
+
const input = new ReadableStream({
|
|
24955
|
+
start(controller) {
|
|
24956
|
+
controller.enqueue(data);
|
|
24957
|
+
controller.close();
|
|
24958
|
+
}
|
|
24959
|
+
});
|
|
24960
|
+
const output2 = input.pipeThrough(new DecompressionStream("deflate-raw"));
|
|
24961
|
+
const reader = output2.getReader();
|
|
24962
|
+
const chunks = [];
|
|
24963
|
+
let totalLength = 0;
|
|
24964
|
+
try {
|
|
24965
|
+
for (;; ) {
|
|
24966
|
+
const { done, value } = await reader.read();
|
|
24967
|
+
if (done) {
|
|
24968
|
+
break;
|
|
24969
|
+
}
|
|
24970
|
+
totalLength += value.length;
|
|
24971
|
+
if (totalLength > maximumLength) {
|
|
24972
|
+
await reader.cancel();
|
|
24973
|
+
throw new Error(`ZIP entry decompressed data exceeds ${maximumLength} bytes`);
|
|
24974
|
+
}
|
|
24975
|
+
chunks.push(value);
|
|
24976
|
+
}
|
|
24977
|
+
} finally {
|
|
24944
24978
|
reader.releaseLock();
|
|
24979
|
+
}
|
|
24980
|
+
const uncompressedData = new Uint8Array(totalLength);
|
|
24981
|
+
let offset = 0;
|
|
24982
|
+
for (const chunk of chunks) {
|
|
24983
|
+
uncompressedData.set(chunk, offset);
|
|
24984
|
+
offset += chunk.length;
|
|
24985
|
+
}
|
|
24986
|
+
return uncompressedData;
|
|
24987
|
+
}
|
|
24988
|
+
function mergeByteChunks(chunks, totalLength) {
|
|
24989
|
+
const merged = new Uint8Array(totalLength);
|
|
24990
|
+
let offset = 0;
|
|
24991
|
+
for (const chunk of chunks) {
|
|
24992
|
+
merged.set(chunk, offset);
|
|
24993
|
+
offset += chunk.length;
|
|
24994
|
+
}
|
|
24995
|
+
return merged;
|
|
24996
|
+
}
|
|
24997
|
+
function getMaximumZipBufferedReadLength(tokenizer) {
|
|
24998
|
+
const fileSize = tokenizer.fileInfo.size;
|
|
24999
|
+
const remainingBytes = Number.isFinite(fileSize) ? Math.max(0, fileSize - tokenizer.position) : Number.MAX_SAFE_INTEGER;
|
|
25000
|
+
return Math.min(remainingBytes, maximumZipBufferedReadSizeInBytes);
|
|
25001
|
+
}
|
|
25002
|
+
function isRecoverableZipError(error) {
|
|
25003
|
+
if (error instanceof EndOfStreamError) {
|
|
25004
|
+
return true;
|
|
25005
|
+
}
|
|
25006
|
+
if (error instanceof ParserHardLimitError) {
|
|
25007
|
+
return true;
|
|
25008
|
+
}
|
|
25009
|
+
if (!(error instanceof Error)) {
|
|
25010
|
+
return false;
|
|
25011
|
+
}
|
|
25012
|
+
if (recoverableZipErrorMessages.has(error.message)) {
|
|
25013
|
+
return true;
|
|
25014
|
+
}
|
|
25015
|
+
if (recoverableZipErrorCodes.has(error.code)) {
|
|
25016
|
+
return true;
|
|
25017
|
+
}
|
|
25018
|
+
for (const prefix of recoverableZipErrorMessagePrefixes) {
|
|
25019
|
+
if (error.message.startsWith(prefix)) {
|
|
25020
|
+
return true;
|
|
25021
|
+
}
|
|
25022
|
+
}
|
|
25023
|
+
return false;
|
|
25024
|
+
}
|
|
25025
|
+
function canReadZipEntryForDetection(zipHeader, maximumSize = maximumZipEntrySizeInBytes) {
|
|
25026
|
+
const sizes = [zipHeader.compressedSize, zipHeader.uncompressedSize];
|
|
25027
|
+
for (const size of sizes) {
|
|
25028
|
+
if (!Number.isFinite(size) || size < 0 || size > maximumSize) {
|
|
25029
|
+
return false;
|
|
25030
|
+
}
|
|
25031
|
+
}
|
|
25032
|
+
return true;
|
|
25033
|
+
}
|
|
25034
|
+
function createIWorkZipDetectionState() {
|
|
25035
|
+
return {
|
|
25036
|
+
hasDocumentEntry: false,
|
|
25037
|
+
hasMasterSlideEntry: false,
|
|
25038
|
+
hasTablesEntry: false,
|
|
25039
|
+
hasCalculationEngineEntry: false
|
|
24945
25040
|
};
|
|
24946
|
-
|
|
24947
|
-
|
|
24948
|
-
|
|
24949
|
-
|
|
25041
|
+
}
|
|
25042
|
+
function updateIWorkZipDetectionStateFromFilename(iWorkState, filename) {
|
|
25043
|
+
if (filename === "Index/Document.iwa") {
|
|
25044
|
+
iWorkState.hasDocumentEntry = true;
|
|
25045
|
+
}
|
|
25046
|
+
if (filename.startsWith("Index/MasterSlide")) {
|
|
25047
|
+
iWorkState.hasMasterSlideEntry = true;
|
|
25048
|
+
}
|
|
25049
|
+
if (filename.startsWith("Index/Tables/")) {
|
|
25050
|
+
iWorkState.hasTablesEntry = true;
|
|
25051
|
+
}
|
|
25052
|
+
if (filename === "Index/CalculationEngine.iwa") {
|
|
25053
|
+
iWorkState.hasCalculationEngineEntry = true;
|
|
25054
|
+
}
|
|
25055
|
+
}
|
|
25056
|
+
function getIWorkFileTypeFromZipEntries(iWorkState) {
|
|
25057
|
+
if (!iWorkState.hasDocumentEntry) {
|
|
25058
|
+
return;
|
|
25059
|
+
}
|
|
25060
|
+
if (iWorkState.hasMasterSlideEntry) {
|
|
25061
|
+
return { ext: "key", mime: "application/vnd.apple.keynote" };
|
|
25062
|
+
}
|
|
25063
|
+
if (iWorkState.hasTablesEntry) {
|
|
25064
|
+
return { ext: "numbers", mime: "application/vnd.apple.numbers" };
|
|
25065
|
+
}
|
|
25066
|
+
return { ext: "pages", mime: "application/vnd.apple.pages" };
|
|
25067
|
+
}
|
|
25068
|
+
function getFileTypeFromMimeType(mimeType) {
|
|
25069
|
+
mimeType = mimeType.toLowerCase();
|
|
25070
|
+
switch (mimeType) {
|
|
25071
|
+
case "application/epub+zip":
|
|
25072
|
+
return { ext: "epub", mime: mimeType };
|
|
25073
|
+
case "application/vnd.oasis.opendocument.text":
|
|
25074
|
+
return { ext: "odt", mime: mimeType };
|
|
25075
|
+
case "application/vnd.oasis.opendocument.text-template":
|
|
25076
|
+
return { ext: "ott", mime: mimeType };
|
|
25077
|
+
case "application/vnd.oasis.opendocument.spreadsheet":
|
|
25078
|
+
return { ext: "ods", mime: mimeType };
|
|
25079
|
+
case "application/vnd.oasis.opendocument.spreadsheet-template":
|
|
25080
|
+
return { ext: "ots", mime: mimeType };
|
|
25081
|
+
case "application/vnd.oasis.opendocument.presentation":
|
|
25082
|
+
return { ext: "odp", mime: mimeType };
|
|
25083
|
+
case "application/vnd.oasis.opendocument.presentation-template":
|
|
25084
|
+
return { ext: "otp", mime: mimeType };
|
|
25085
|
+
case "application/vnd.oasis.opendocument.graphics":
|
|
25086
|
+
return { ext: "odg", mime: mimeType };
|
|
25087
|
+
case "application/vnd.oasis.opendocument.graphics-template":
|
|
25088
|
+
return { ext: "otg", mime: mimeType };
|
|
25089
|
+
case "application/vnd.openxmlformats-officedocument.presentationml.slideshow":
|
|
25090
|
+
return { ext: "ppsx", mime: mimeType };
|
|
25091
|
+
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
25092
|
+
return { ext: "xlsx", mime: mimeType };
|
|
25093
|
+
case "application/vnd.ms-excel.sheet.macroenabled":
|
|
25094
|
+
return { ext: "xlsm", mime: "application/vnd.ms-excel.sheet.macroenabled.12" };
|
|
25095
|
+
case "application/vnd.openxmlformats-officedocument.spreadsheetml.template":
|
|
25096
|
+
return { ext: "xltx", mime: mimeType };
|
|
25097
|
+
case "application/vnd.ms-excel.template.macroenabled":
|
|
25098
|
+
return { ext: "xltm", mime: "application/vnd.ms-excel.template.macroenabled.12" };
|
|
25099
|
+
case "application/vnd.ms-powerpoint.slideshow.macroenabled":
|
|
25100
|
+
return { ext: "ppsm", mime: "application/vnd.ms-powerpoint.slideshow.macroenabled.12" };
|
|
25101
|
+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
25102
|
+
return { ext: "docx", mime: mimeType };
|
|
25103
|
+
case "application/vnd.ms-word.document.macroenabled":
|
|
25104
|
+
return { ext: "docm", mime: "application/vnd.ms-word.document.macroenabled.12" };
|
|
25105
|
+
case "application/vnd.openxmlformats-officedocument.wordprocessingml.template":
|
|
25106
|
+
return { ext: "dotx", mime: mimeType };
|
|
25107
|
+
case "application/vnd.ms-word.template.macroenabledtemplate":
|
|
25108
|
+
return { ext: "dotm", mime: "application/vnd.ms-word.template.macroenabled.12" };
|
|
25109
|
+
case "application/vnd.openxmlformats-officedocument.presentationml.template":
|
|
25110
|
+
return { ext: "potx", mime: mimeType };
|
|
25111
|
+
case "application/vnd.ms-powerpoint.template.macroenabled":
|
|
25112
|
+
return { ext: "potm", mime: "application/vnd.ms-powerpoint.template.macroenabled.12" };
|
|
25113
|
+
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
25114
|
+
return { ext: "pptx", mime: mimeType };
|
|
25115
|
+
case "application/vnd.ms-powerpoint.presentation.macroenabled":
|
|
25116
|
+
return { ext: "pptm", mime: "application/vnd.ms-powerpoint.presentation.macroenabled.12" };
|
|
25117
|
+
case "application/vnd.ms-visio.drawing":
|
|
25118
|
+
return { ext: "vsdx", mime: "application/vnd.visio" };
|
|
25119
|
+
case "application/vnd.ms-package.3dmanufacturing-3dmodel+xml":
|
|
25120
|
+
return { ext: "3mf", mime: "model/3mf" };
|
|
25121
|
+
default:
|
|
25122
|
+
}
|
|
25123
|
+
}
|
|
25124
|
+
function createOpenXmlZipDetectionState() {
|
|
25125
|
+
return {
|
|
25126
|
+
hasContentTypesEntry: false,
|
|
25127
|
+
hasParsedContentTypesEntry: false,
|
|
25128
|
+
isParsingContentTypes: false,
|
|
25129
|
+
hasUnparseableContentTypes: false,
|
|
25130
|
+
hasWordDirectory: false,
|
|
25131
|
+
hasPresentationDirectory: false,
|
|
25132
|
+
hasSpreadsheetDirectory: false,
|
|
25133
|
+
hasThreeDimensionalModelEntry: false
|
|
24950
25134
|
};
|
|
24951
|
-
return tokenizer;
|
|
24952
25135
|
}
|
|
24953
|
-
function
|
|
24954
|
-
if (
|
|
24955
|
-
|
|
25136
|
+
function updateOpenXmlZipDetectionStateFromFilename(openXmlState, filename) {
|
|
25137
|
+
if (filename.startsWith("word/")) {
|
|
25138
|
+
openXmlState.hasWordDirectory = true;
|
|
25139
|
+
}
|
|
25140
|
+
if (filename.startsWith("ppt/")) {
|
|
25141
|
+
openXmlState.hasPresentationDirectory = true;
|
|
25142
|
+
}
|
|
25143
|
+
if (filename.startsWith("xl/")) {
|
|
25144
|
+
openXmlState.hasSpreadsheetDirectory = true;
|
|
25145
|
+
}
|
|
25146
|
+
if (filename.startsWith("3D/") && filename.endsWith(".model")) {
|
|
25147
|
+
openXmlState.hasThreeDimensionalModelEntry = true;
|
|
25148
|
+
}
|
|
25149
|
+
}
|
|
25150
|
+
function getOpenXmlFileTypeFromDirectoryNames(openXmlState) {
|
|
25151
|
+
if (openXmlState.hasWordDirectory) {
|
|
25152
|
+
return {
|
|
25153
|
+
ext: "docx",
|
|
25154
|
+
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
25155
|
+
};
|
|
25156
|
+
}
|
|
25157
|
+
if (openXmlState.hasPresentationDirectory) {
|
|
25158
|
+
return {
|
|
25159
|
+
ext: "pptx",
|
|
25160
|
+
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
25161
|
+
};
|
|
25162
|
+
}
|
|
25163
|
+
if (openXmlState.hasSpreadsheetDirectory) {
|
|
25164
|
+
return {
|
|
25165
|
+
ext: "xlsx",
|
|
25166
|
+
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
25167
|
+
};
|
|
25168
|
+
}
|
|
25169
|
+
if (openXmlState.hasThreeDimensionalModelEntry) {
|
|
25170
|
+
return {
|
|
25171
|
+
ext: "3mf",
|
|
25172
|
+
mime: "model/3mf"
|
|
25173
|
+
};
|
|
24956
25174
|
}
|
|
24957
|
-
return value;
|
|
24958
25175
|
}
|
|
24959
|
-
|
|
24960
|
-
|
|
24961
|
-
|
|
25176
|
+
function getOpenXmlFileTypeFromZipEntries(openXmlState) {
|
|
25177
|
+
if (!openXmlState.hasContentTypesEntry || openXmlState.hasUnparseableContentTypes || openXmlState.isParsingContentTypes || openXmlState.hasParsedContentTypesEntry) {
|
|
25178
|
+
return;
|
|
25179
|
+
}
|
|
25180
|
+
return getOpenXmlFileTypeFromDirectoryNames(openXmlState);
|
|
24962
25181
|
}
|
|
24963
|
-
|
|
24964
|
-
const
|
|
24965
|
-
|
|
24966
|
-
|
|
24967
|
-
|
|
24968
|
-
|
|
24969
|
-
|
|
25182
|
+
function getOpenXmlMimeTypeFromContentTypesXml(xmlContent) {
|
|
25183
|
+
const endPosition = xmlContent.indexOf('.main+xml"');
|
|
25184
|
+
if (endPosition === -1) {
|
|
25185
|
+
const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
|
|
25186
|
+
if (xmlContent.includes(`ContentType="${mimeType}"`)) {
|
|
25187
|
+
return mimeType;
|
|
25188
|
+
}
|
|
25189
|
+
return;
|
|
25190
|
+
}
|
|
25191
|
+
const truncatedContent = xmlContent.slice(0, endPosition);
|
|
25192
|
+
const firstQuotePosition = truncatedContent.lastIndexOf('"');
|
|
25193
|
+
return truncatedContent.slice(firstQuotePosition + 1);
|
|
24970
25194
|
}
|
|
24971
|
-
|
|
24972
|
-
|
|
24973
|
-
|
|
24974
|
-
|
|
24975
|
-
|
|
25195
|
+
function findZipDataDescriptorOffset(buffer, bytesConsumed) {
|
|
25196
|
+
if (buffer.length < zipDataDescriptorLengthInBytes) {
|
|
25197
|
+
return -1;
|
|
25198
|
+
}
|
|
25199
|
+
const lastPossibleDescriptorOffset = buffer.length - zipDataDescriptorLengthInBytes;
|
|
25200
|
+
for (let index = 0;index <= lastPossibleDescriptorOffset; index++) {
|
|
25201
|
+
if (UINT32_LE.get(buffer, index) === zipDataDescriptorSignature && UINT32_LE.get(buffer, index + 8) === bytesConsumed + index) {
|
|
25202
|
+
return index;
|
|
24976
25203
|
}
|
|
24977
|
-
}
|
|
24978
|
-
|
|
24979
|
-
|
|
25204
|
+
}
|
|
25205
|
+
return -1;
|
|
25206
|
+
}
|
|
25207
|
+
async function readZipDataDescriptorEntryWithLimit(zipHandler, { shouldBuffer, maximumLength = maximumZipEntrySizeInBytes } = {}) {
|
|
25208
|
+
const { syncBuffer } = zipHandler;
|
|
25209
|
+
const { length: syncBufferLength } = syncBuffer;
|
|
24980
25210
|
const chunks = [];
|
|
24981
|
-
let
|
|
25211
|
+
let bytesConsumed = 0;
|
|
25212
|
+
for (;; ) {
|
|
25213
|
+
const length = await zipHandler.tokenizer.peekBuffer(syncBuffer, { mayBeLess: true });
|
|
25214
|
+
const dataDescriptorOffset = findZipDataDescriptorOffset(syncBuffer.subarray(0, length), bytesConsumed);
|
|
25215
|
+
const retainedLength = dataDescriptorOffset >= 0 ? 0 : length === syncBufferLength ? Math.min(zipDataDescriptorOverlapLengthInBytes, length - 1) : 0;
|
|
25216
|
+
const chunkLength = dataDescriptorOffset >= 0 ? dataDescriptorOffset : length - retainedLength;
|
|
25217
|
+
if (chunkLength === 0) {
|
|
25218
|
+
break;
|
|
25219
|
+
}
|
|
25220
|
+
bytesConsumed += chunkLength;
|
|
25221
|
+
if (bytesConsumed > maximumLength) {
|
|
25222
|
+
throw new Error(`ZIP entry compressed data exceeds ${maximumLength} bytes`);
|
|
25223
|
+
}
|
|
25224
|
+
if (shouldBuffer) {
|
|
25225
|
+
const data = new Uint8Array(chunkLength);
|
|
25226
|
+
await zipHandler.tokenizer.readBuffer(data);
|
|
25227
|
+
chunks.push(data);
|
|
25228
|
+
} else {
|
|
25229
|
+
await zipHandler.tokenizer.ignore(chunkLength);
|
|
25230
|
+
}
|
|
25231
|
+
if (dataDescriptorOffset >= 0) {
|
|
25232
|
+
break;
|
|
25233
|
+
}
|
|
25234
|
+
}
|
|
25235
|
+
if (!hasUnknownFileSize(zipHandler.tokenizer)) {
|
|
25236
|
+
zipHandler.knownSizeDescriptorScannedBytes += bytesConsumed;
|
|
25237
|
+
}
|
|
25238
|
+
if (!shouldBuffer) {
|
|
25239
|
+
return;
|
|
25240
|
+
}
|
|
25241
|
+
return mergeByteChunks(chunks, bytesConsumed);
|
|
25242
|
+
}
|
|
25243
|
+
function getRemainingZipScanBudget(zipHandler, startOffset) {
|
|
25244
|
+
if (hasUnknownFileSize(zipHandler.tokenizer)) {
|
|
25245
|
+
return Math.max(0, maximumUntrustedSkipSizeInBytes - (zipHandler.tokenizer.position - startOffset));
|
|
25246
|
+
}
|
|
25247
|
+
return Math.max(0, maximumZipEntrySizeInBytes - zipHandler.knownSizeDescriptorScannedBytes);
|
|
25248
|
+
}
|
|
25249
|
+
async function readZipEntryData(zipHandler, zipHeader, { shouldBuffer, maximumDescriptorLength = maximumZipEntrySizeInBytes } = {}) {
|
|
25250
|
+
if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
|
|
25251
|
+
return readZipDataDescriptorEntryWithLimit(zipHandler, {
|
|
25252
|
+
shouldBuffer,
|
|
25253
|
+
maximumLength: maximumDescriptorLength
|
|
25254
|
+
});
|
|
25255
|
+
}
|
|
25256
|
+
if (!shouldBuffer) {
|
|
25257
|
+
await safeIgnore(zipHandler.tokenizer, zipHeader.compressedSize, {
|
|
25258
|
+
maximumLength: hasUnknownFileSize(zipHandler.tokenizer) ? maximumZipEntrySizeInBytes : zipHandler.tokenizer.fileInfo.size,
|
|
25259
|
+
reason: "ZIP entry compressed data"
|
|
25260
|
+
});
|
|
25261
|
+
return;
|
|
25262
|
+
}
|
|
25263
|
+
const maximumLength = getMaximumZipBufferedReadLength(zipHandler.tokenizer);
|
|
25264
|
+
if (!Number.isFinite(zipHeader.compressedSize) || zipHeader.compressedSize < 0 || zipHeader.compressedSize > maximumLength) {
|
|
25265
|
+
throw new Error(`ZIP entry compressed data exceeds ${maximumLength} bytes`);
|
|
25266
|
+
}
|
|
25267
|
+
const fileData = new Uint8Array(zipHeader.compressedSize);
|
|
25268
|
+
await zipHandler.tokenizer.readBuffer(fileData);
|
|
25269
|
+
return fileData;
|
|
25270
|
+
}
|
|
25271
|
+
async function detectZip(tokenizer) {
|
|
25272
|
+
let fileType;
|
|
25273
|
+
const openXmlState = createOpenXmlZipDetectionState();
|
|
25274
|
+
const iWorkState = createIWorkZipDetectionState();
|
|
24982
25275
|
try {
|
|
24983
|
-
|
|
24984
|
-
|
|
24985
|
-
|
|
25276
|
+
await new ZipHandler(tokenizer).unzip((zipHeader) => {
|
|
25277
|
+
updateOpenXmlZipDetectionStateFromFilename(openXmlState, zipHeader.filename);
|
|
25278
|
+
updateIWorkZipDetectionStateFromFilename(iWorkState, zipHeader.filename);
|
|
25279
|
+
if (iWorkState.hasDocumentEntry && (iWorkState.hasMasterSlideEntry || iWorkState.hasTablesEntry)) {
|
|
25280
|
+
fileType = getIWorkFileTypeFromZipEntries(iWorkState);
|
|
25281
|
+
return { stop: true };
|
|
25282
|
+
}
|
|
25283
|
+
const isOpenXmlContentTypesEntry = zipHeader.filename === "[Content_Types].xml";
|
|
25284
|
+
const openXmlFileTypeFromEntries = getOpenXmlFileTypeFromZipEntries(openXmlState);
|
|
25285
|
+
if (!isOpenXmlContentTypesEntry && openXmlFileTypeFromEntries) {
|
|
25286
|
+
fileType = openXmlFileTypeFromEntries;
|
|
25287
|
+
return {
|
|
25288
|
+
stop: true
|
|
25289
|
+
};
|
|
25290
|
+
}
|
|
25291
|
+
switch (zipHeader.filename) {
|
|
25292
|
+
case "META-INF/mozilla.rsa":
|
|
25293
|
+
fileType = {
|
|
25294
|
+
ext: "xpi",
|
|
25295
|
+
mime: "application/x-xpinstall"
|
|
25296
|
+
};
|
|
25297
|
+
return {
|
|
25298
|
+
stop: true
|
|
25299
|
+
};
|
|
25300
|
+
case "META-INF/MANIFEST.MF":
|
|
25301
|
+
fileType = {
|
|
25302
|
+
ext: "jar",
|
|
25303
|
+
mime: "application/java-archive"
|
|
25304
|
+
};
|
|
25305
|
+
return {
|
|
25306
|
+
stop: true
|
|
25307
|
+
};
|
|
25308
|
+
case "mimetype":
|
|
25309
|
+
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25310
|
+
return {};
|
|
25311
|
+
}
|
|
25312
|
+
return {
|
|
25313
|
+
async handler(fileData) {
|
|
25314
|
+
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
25315
|
+
fileType = getFileTypeFromMimeType(mimeType);
|
|
25316
|
+
},
|
|
25317
|
+
stop: true
|
|
25318
|
+
};
|
|
25319
|
+
case "[Content_Types].xml": {
|
|
25320
|
+
openXmlState.hasContentTypesEntry = true;
|
|
25321
|
+
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25322
|
+
openXmlState.hasUnparseableContentTypes = true;
|
|
25323
|
+
return {};
|
|
25324
|
+
}
|
|
25325
|
+
openXmlState.isParsingContentTypes = true;
|
|
25326
|
+
return {
|
|
25327
|
+
async handler(fileData) {
|
|
25328
|
+
const xmlContent = new TextDecoder("utf-8").decode(fileData);
|
|
25329
|
+
const mimeType = getOpenXmlMimeTypeFromContentTypesXml(xmlContent);
|
|
25330
|
+
if (mimeType) {
|
|
25331
|
+
fileType = getFileTypeFromMimeType(mimeType);
|
|
25332
|
+
}
|
|
25333
|
+
openXmlState.hasParsedContentTypesEntry = true;
|
|
25334
|
+
openXmlState.isParsingContentTypes = false;
|
|
25335
|
+
},
|
|
25336
|
+
stop: true
|
|
25337
|
+
};
|
|
25338
|
+
}
|
|
25339
|
+
default:
|
|
25340
|
+
if (/classes\d*\.dex/v.test(zipHeader.filename)) {
|
|
25341
|
+
fileType = {
|
|
25342
|
+
ext: "apk",
|
|
25343
|
+
mime: "application/vnd.android.package-archive"
|
|
25344
|
+
};
|
|
25345
|
+
return { stop: true };
|
|
25346
|
+
}
|
|
25347
|
+
return {};
|
|
25348
|
+
}
|
|
25349
|
+
});
|
|
25350
|
+
} catch (error) {
|
|
25351
|
+
if (!isRecoverableZipError(error)) {
|
|
25352
|
+
throw error;
|
|
25353
|
+
}
|
|
25354
|
+
if (openXmlState.isParsingContentTypes) {
|
|
25355
|
+
openXmlState.isParsingContentTypes = false;
|
|
25356
|
+
openXmlState.hasUnparseableContentTypes = true;
|
|
25357
|
+
}
|
|
25358
|
+
if (!fileType && error instanceof EndOfStreamError && !openXmlState.hasContentTypesEntry) {
|
|
25359
|
+
fileType = getOpenXmlFileTypeFromDirectoryNames(openXmlState);
|
|
25360
|
+
}
|
|
25361
|
+
}
|
|
25362
|
+
const iWorkFileType = hasUnknownFileSize(tokenizer) && iWorkState.hasDocumentEntry && !iWorkState.hasMasterSlideEntry && !iWorkState.hasTablesEntry && !iWorkState.hasCalculationEngineEntry ? undefined : getIWorkFileTypeFromZipEntries(iWorkState);
|
|
25363
|
+
return fileType ?? getOpenXmlFileTypeFromZipEntries(openXmlState) ?? iWorkFileType ?? {
|
|
25364
|
+
ext: "zip",
|
|
25365
|
+
mime: "application/zip"
|
|
25366
|
+
};
|
|
25367
|
+
}
|
|
25368
|
+
var maximumZipEntrySizeInBytes, maximumZipEntryCount = 1024, maximumZipBufferedReadSizeInBytes, maximumZipTextEntrySizeInBytes, recoverableZipErrorMessages, recoverableZipErrorMessagePrefixes, recoverableZipErrorCodes, zipDataDescriptorSignature = 134695760, zipDataDescriptorLengthInBytes = 16, zipDataDescriptorOverlapLengthInBytes;
|
|
25369
|
+
var init_zip = __esm(() => {
|
|
25370
|
+
init_lib2();
|
|
25371
|
+
init_core();
|
|
25372
|
+
init_lib3();
|
|
25373
|
+
init_parser();
|
|
25374
|
+
maximumZipEntrySizeInBytes = 1024 * 1024;
|
|
25375
|
+
maximumZipBufferedReadSizeInBytes = 2 ** 31 - 1;
|
|
25376
|
+
maximumZipTextEntrySizeInBytes = maximumZipEntrySizeInBytes;
|
|
25377
|
+
recoverableZipErrorMessages = new Set([
|
|
25378
|
+
"Unexpected signature",
|
|
25379
|
+
"Encrypted ZIP",
|
|
25380
|
+
"Expected Central-File-Header signature"
|
|
25381
|
+
]);
|
|
25382
|
+
recoverableZipErrorMessagePrefixes = [
|
|
25383
|
+
"ZIP entry count exceeds ",
|
|
25384
|
+
"Unsupported ZIP compression method:",
|
|
25385
|
+
"ZIP entry compressed data exceeds ",
|
|
25386
|
+
"ZIP entry decompressed data exceeds ",
|
|
25387
|
+
"Expected data-descriptor-signature at position "
|
|
25388
|
+
];
|
|
25389
|
+
recoverableZipErrorCodes = new Set([
|
|
25390
|
+
"Z_BUF_ERROR",
|
|
25391
|
+
"Z_DATA_ERROR",
|
|
25392
|
+
"ERR_INVALID_STATE"
|
|
25393
|
+
]);
|
|
25394
|
+
zipDataDescriptorOverlapLengthInBytes = zipDataDescriptorLengthInBytes - 1;
|
|
25395
|
+
ZipHandler.prototype.inflate = async function(zipHeader, fileData, callback) {
|
|
25396
|
+
if (zipHeader.compressedMethod === 0) {
|
|
25397
|
+
return callback(fileData);
|
|
25398
|
+
}
|
|
25399
|
+
if (zipHeader.compressedMethod !== 8) {
|
|
25400
|
+
throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
|
|
25401
|
+
}
|
|
25402
|
+
const uncompressedData = await decompressDeflateRawWithLimit(fileData, { maximumLength: maximumZipEntrySizeInBytes });
|
|
25403
|
+
return callback(uncompressedData);
|
|
25404
|
+
};
|
|
25405
|
+
ZipHandler.prototype.unzip = async function(fileCallback) {
|
|
25406
|
+
let stop = false;
|
|
25407
|
+
let zipEntryCount = 0;
|
|
25408
|
+
const zipScanStart = this.tokenizer.position;
|
|
25409
|
+
this.knownSizeDescriptorScannedBytes = 0;
|
|
25410
|
+
do {
|
|
25411
|
+
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
25412
|
+
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
25413
|
+
}
|
|
25414
|
+
const zipHeader = await this.readLocalFileHeader();
|
|
25415
|
+
if (!zipHeader) {
|
|
24986
25416
|
break;
|
|
24987
25417
|
}
|
|
24988
|
-
|
|
24989
|
-
if (
|
|
24990
|
-
|
|
24991
|
-
|
|
25418
|
+
zipEntryCount++;
|
|
25419
|
+
if (zipEntryCount > maximumZipEntryCount) {
|
|
25420
|
+
throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
|
|
25421
|
+
}
|
|
25422
|
+
const next = fileCallback(zipHeader);
|
|
25423
|
+
stop = Boolean(next.stop);
|
|
25424
|
+
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
25425
|
+
const fileData = await readZipEntryData(this, zipHeader, {
|
|
25426
|
+
shouldBuffer: Boolean(next.handler),
|
|
25427
|
+
maximumDescriptorLength: Math.min(maximumZipEntrySizeInBytes, getRemainingZipScanBudget(this, zipScanStart))
|
|
25428
|
+
});
|
|
25429
|
+
if (next.handler) {
|
|
25430
|
+
await this.inflate(zipHeader, fileData, next.handler);
|
|
25431
|
+
}
|
|
25432
|
+
if (zipHeader.dataDescriptor) {
|
|
25433
|
+
const dataDescriptor = new Uint8Array(zipDataDescriptorLengthInBytes);
|
|
25434
|
+
await this.tokenizer.readBuffer(dataDescriptor);
|
|
25435
|
+
if (UINT32_LE.get(dataDescriptor, 0) !== zipDataDescriptorSignature) {
|
|
25436
|
+
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - dataDescriptor.length}`);
|
|
25437
|
+
}
|
|
25438
|
+
}
|
|
25439
|
+
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
25440
|
+
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
25441
|
+
}
|
|
25442
|
+
} while (!stop);
|
|
25443
|
+
};
|
|
25444
|
+
});
|
|
25445
|
+
|
|
25446
|
+
// ../../node_modules/file-type/source/detectors/ebml.js
|
|
25447
|
+
async function detectEbml(tokenizer) {
|
|
25448
|
+
async function readField() {
|
|
25449
|
+
const msb = await tokenizer.peekNumber(UINT8);
|
|
25450
|
+
let mask = 128;
|
|
25451
|
+
let ic = 0;
|
|
25452
|
+
while ((msb & mask) === 0 && mask !== 0) {
|
|
25453
|
+
++ic;
|
|
25454
|
+
mask >>= 1;
|
|
25455
|
+
}
|
|
25456
|
+
const id = new Uint8Array(ic + 1);
|
|
25457
|
+
await safeReadBuffer(tokenizer, id, undefined, {
|
|
25458
|
+
maximumLength: id.length,
|
|
25459
|
+
reason: "EBML field"
|
|
25460
|
+
});
|
|
25461
|
+
return id;
|
|
25462
|
+
}
|
|
25463
|
+
async function readElement() {
|
|
25464
|
+
const idField = await readField();
|
|
25465
|
+
const lengthField = await readField();
|
|
25466
|
+
lengthField[0] ^= 128 >> lengthField.length - 1;
|
|
25467
|
+
const nrLength = Math.min(6, lengthField.length);
|
|
25468
|
+
const idView = new DataView(idField.buffer);
|
|
25469
|
+
const lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);
|
|
25470
|
+
return {
|
|
25471
|
+
id: getUintBE(idView),
|
|
25472
|
+
len: getUintBE(lengthView)
|
|
25473
|
+
};
|
|
25474
|
+
}
|
|
25475
|
+
async function readChildren(children) {
|
|
25476
|
+
let ebmlElementCount = 0;
|
|
25477
|
+
while (children > 0) {
|
|
25478
|
+
ebmlElementCount++;
|
|
25479
|
+
if (ebmlElementCount > maximumEbmlElementCount) {
|
|
25480
|
+
return;
|
|
25481
|
+
}
|
|
25482
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, ebmlScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
25483
|
+
return;
|
|
25484
|
+
}
|
|
25485
|
+
const previousPosition = tokenizer.position;
|
|
25486
|
+
const element = await readElement();
|
|
25487
|
+
if (element.id === 17026) {
|
|
25488
|
+
if (element.len > maximumEbmlDocumentTypeSizeInBytes) {
|
|
25489
|
+
return;
|
|
25490
|
+
}
|
|
25491
|
+
const documentTypeLength = getSafeBound(element.len, maximumEbmlDocumentTypeSizeInBytes, "EBML DocType");
|
|
25492
|
+
const rawValue = await tokenizer.readToken(new StringType2(documentTypeLength));
|
|
25493
|
+
return rawValue.replaceAll(/\0.*$/gv, "");
|
|
25494
|
+
}
|
|
25495
|
+
if (hasUnknownFileSize(tokenizer) && (!Number.isFinite(element.len) || element.len < 0 || element.len > maximumEbmlElementPayloadSizeInBytes)) {
|
|
25496
|
+
return;
|
|
25497
|
+
}
|
|
25498
|
+
await safeIgnore(tokenizer, element.len, {
|
|
25499
|
+
maximumLength: hasUnknownFileSize(tokenizer) ? maximumEbmlElementPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
25500
|
+
reason: "EBML payload"
|
|
25501
|
+
});
|
|
25502
|
+
--children;
|
|
25503
|
+
if (tokenizer.position <= previousPosition) {
|
|
25504
|
+
return;
|
|
24992
25505
|
}
|
|
24993
|
-
chunks.push(value);
|
|
24994
25506
|
}
|
|
24995
|
-
} finally {
|
|
24996
|
-
reader.releaseLock();
|
|
24997
|
-
}
|
|
24998
|
-
const uncompressedData = new Uint8Array(totalLength);
|
|
24999
|
-
let offset = 0;
|
|
25000
|
-
for (const chunk of chunks) {
|
|
25001
|
-
uncompressedData.set(chunk, offset);
|
|
25002
|
-
offset += chunk.length;
|
|
25003
|
-
}
|
|
25004
|
-
return uncompressedData;
|
|
25005
|
-
}
|
|
25006
|
-
function findZipDataDescriptorOffset(buffer, bytesConsumed) {
|
|
25007
|
-
if (buffer.length < zipDataDescriptorLengthInBytes) {
|
|
25008
|
-
return -1;
|
|
25009
25507
|
}
|
|
25010
|
-
const
|
|
25011
|
-
|
|
25012
|
-
|
|
25013
|
-
|
|
25014
|
-
|
|
25508
|
+
const rootElement = await readElement();
|
|
25509
|
+
const ebmlScanStart = tokenizer.position;
|
|
25510
|
+
const documentType = await readChildren(rootElement.len);
|
|
25511
|
+
switch (documentType) {
|
|
25512
|
+
case "webm":
|
|
25513
|
+
return {
|
|
25514
|
+
ext: "webm",
|
|
25515
|
+
mime: "video/webm"
|
|
25516
|
+
};
|
|
25517
|
+
case "matroska":
|
|
25518
|
+
return {
|
|
25519
|
+
ext: "mkv",
|
|
25520
|
+
mime: "video/matroska"
|
|
25521
|
+
};
|
|
25522
|
+
default:
|
|
25015
25523
|
}
|
|
25016
|
-
return -1;
|
|
25017
25524
|
}
|
|
25525
|
+
var maximumEbmlDocumentTypeSizeInBytes = 64, maximumEbmlElementPayloadSizeInBytes, maximumEbmlElementCount = 256;
|
|
25526
|
+
var init_ebml = __esm(() => {
|
|
25527
|
+
init_lib2();
|
|
25528
|
+
init_uint8array_extras();
|
|
25529
|
+
init_parser();
|
|
25530
|
+
maximumEbmlElementPayloadSizeInBytes = 1024 * 1024;
|
|
25531
|
+
});
|
|
25532
|
+
|
|
25533
|
+
// ../../node_modules/file-type/source/detectors/png.js
|
|
25018
25534
|
function isPngAncillaryChunk(type) {
|
|
25019
25535
|
return (type.codePointAt(0) & 32) !== 0;
|
|
25020
25536
|
}
|
|
25021
|
-
function
|
|
25022
|
-
const
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25537
|
+
async function detectPng(tokenizer) {
|
|
25538
|
+
const pngFileType = {
|
|
25539
|
+
ext: "png",
|
|
25540
|
+
mime: "image/png"
|
|
25541
|
+
};
|
|
25542
|
+
const apngFileType = {
|
|
25543
|
+
ext: "apng",
|
|
25544
|
+
mime: "image/apng"
|
|
25545
|
+
};
|
|
25546
|
+
await tokenizer.ignore(8);
|
|
25547
|
+
async function readChunkHeader() {
|
|
25548
|
+
return {
|
|
25549
|
+
length: await tokenizer.readToken(INT32_BE),
|
|
25550
|
+
type: await tokenizer.readToken(new StringType2(4, "latin1"))
|
|
25551
|
+
};
|
|
25027
25552
|
}
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
for (;; ) {
|
|
25036
|
-
const length = await zipHandler.tokenizer.peekBuffer(syncBuffer, { mayBeLess: true });
|
|
25037
|
-
const dataDescriptorOffset = findZipDataDescriptorOffset(syncBuffer.subarray(0, length), bytesConsumed);
|
|
25038
|
-
const retainedLength = dataDescriptorOffset >= 0 ? 0 : length === syncBufferLength ? Math.min(zipDataDescriptorOverlapLengthInBytes, length - 1) : 0;
|
|
25039
|
-
const chunkLength = dataDescriptorOffset >= 0 ? dataDescriptorOffset : length - retainedLength;
|
|
25040
|
-
if (chunkLength === 0) {
|
|
25553
|
+
const isUnknownPngStream = hasUnknownFileSize(tokenizer);
|
|
25554
|
+
const pngScanStart = tokenizer.position;
|
|
25555
|
+
let pngChunkCount = 0;
|
|
25556
|
+
let hasSeenImageHeader = false;
|
|
25557
|
+
do {
|
|
25558
|
+
pngChunkCount++;
|
|
25559
|
+
if (pngChunkCount > maximumPngChunkCount) {
|
|
25041
25560
|
break;
|
|
25042
25561
|
}
|
|
25043
|
-
|
|
25044
|
-
|
|
25045
|
-
throw new Error(`ZIP entry compressed data exceeds ${maximumLength} bytes`);
|
|
25562
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngStreamScanBudgetInBytes)) {
|
|
25563
|
+
break;
|
|
25046
25564
|
}
|
|
25047
|
-
|
|
25048
|
-
|
|
25049
|
-
|
|
25050
|
-
|
|
25051
|
-
} else {
|
|
25052
|
-
await zipHandler.tokenizer.ignore(chunkLength);
|
|
25565
|
+
const previousPosition = tokenizer.position;
|
|
25566
|
+
const chunk = await readChunkHeader();
|
|
25567
|
+
if (chunk.length < 0) {
|
|
25568
|
+
return;
|
|
25053
25569
|
}
|
|
25054
|
-
if (
|
|
25570
|
+
if (chunk.type === "IHDR") {
|
|
25571
|
+
if (chunk.length !== 13) {
|
|
25572
|
+
return;
|
|
25573
|
+
}
|
|
25574
|
+
hasSeenImageHeader = true;
|
|
25575
|
+
}
|
|
25576
|
+
switch (chunk.type) {
|
|
25577
|
+
case "IDAT":
|
|
25578
|
+
return pngFileType;
|
|
25579
|
+
case "acTL":
|
|
25580
|
+
return apngFileType;
|
|
25581
|
+
default:
|
|
25582
|
+
if (!hasSeenImageHeader && chunk.type !== "CgBI") {
|
|
25583
|
+
return;
|
|
25584
|
+
}
|
|
25585
|
+
if (isUnknownPngStream && chunk.length > maximumPngChunkSizeInBytes) {
|
|
25586
|
+
return hasSeenImageHeader && isPngAncillaryChunk(chunk.type) ? pngFileType : undefined;
|
|
25587
|
+
}
|
|
25588
|
+
try {
|
|
25589
|
+
await safeIgnore(tokenizer, chunk.length + 4, {
|
|
25590
|
+
maximumLength: isUnknownPngStream ? maximumPngChunkSizeInBytes + 4 : tokenizer.fileInfo.size,
|
|
25591
|
+
reason: "PNG chunk payload"
|
|
25592
|
+
});
|
|
25593
|
+
} catch (error) {
|
|
25594
|
+
if (!isUnknownPngStream && (error instanceof ParserHardLimitError || error instanceof EndOfStreamError)) {
|
|
25595
|
+
return pngFileType;
|
|
25596
|
+
}
|
|
25597
|
+
throw error;
|
|
25598
|
+
}
|
|
25599
|
+
}
|
|
25600
|
+
if (tokenizer.position <= previousPosition) {
|
|
25055
25601
|
break;
|
|
25056
25602
|
}
|
|
25603
|
+
} while (tokenizer.position + 8 < tokenizer.fileInfo.size);
|
|
25604
|
+
return pngFileType;
|
|
25605
|
+
}
|
|
25606
|
+
var maximumPngChunkCount = 512, maximumPngStreamScanBudgetInBytes, maximumPngChunkSizeInBytes;
|
|
25607
|
+
var init_png = __esm(() => {
|
|
25608
|
+
init_lib2();
|
|
25609
|
+
init_core();
|
|
25610
|
+
init_parser();
|
|
25611
|
+
maximumPngStreamScanBudgetInBytes = 16 * 1024 * 1024;
|
|
25612
|
+
maximumPngChunkSizeInBytes = 1024 * 1024;
|
|
25613
|
+
});
|
|
25614
|
+
|
|
25615
|
+
// ../../node_modules/file-type/source/detectors/asf.js
|
|
25616
|
+
async function detectAsf(tokenizer) {
|
|
25617
|
+
let isMalformedAsf = false;
|
|
25618
|
+
try {
|
|
25619
|
+
async function readHeader() {
|
|
25620
|
+
const guid = new Uint8Array(16);
|
|
25621
|
+
await safeReadBuffer(tokenizer, guid, undefined, {
|
|
25622
|
+
maximumLength: guid.length,
|
|
25623
|
+
reason: "ASF header GUID"
|
|
25624
|
+
});
|
|
25625
|
+
return {
|
|
25626
|
+
id: guid,
|
|
25627
|
+
size: Number(await tokenizer.readToken(UINT64_LE))
|
|
25628
|
+
};
|
|
25629
|
+
}
|
|
25630
|
+
await safeIgnore(tokenizer, 30, {
|
|
25631
|
+
maximumLength: 30,
|
|
25632
|
+
reason: "ASF header prelude"
|
|
25633
|
+
});
|
|
25634
|
+
const isUnknownFileSize = hasUnknownFileSize(tokenizer);
|
|
25635
|
+
const asfHeaderScanStart = tokenizer.position;
|
|
25636
|
+
let asfHeaderObjectCount = 0;
|
|
25637
|
+
while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
|
|
25638
|
+
asfHeaderObjectCount++;
|
|
25639
|
+
if (asfHeaderObjectCount > maximumAsfHeaderObjectCount) {
|
|
25640
|
+
break;
|
|
25641
|
+
}
|
|
25642
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, asfHeaderScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
25643
|
+
break;
|
|
25644
|
+
}
|
|
25645
|
+
const previousPosition = tokenizer.position;
|
|
25646
|
+
const header = await readHeader();
|
|
25647
|
+
let payload = header.size - 24;
|
|
25648
|
+
if (!Number.isFinite(payload) || payload < 0) {
|
|
25649
|
+
isMalformedAsf = true;
|
|
25650
|
+
break;
|
|
25651
|
+
}
|
|
25652
|
+
if (checkBytes(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
25653
|
+
const typeId = new Uint8Array(16);
|
|
25654
|
+
payload -= await safeReadBuffer(tokenizer, typeId, undefined, {
|
|
25655
|
+
maximumLength: typeId.length,
|
|
25656
|
+
reason: "ASF stream type GUID"
|
|
25657
|
+
});
|
|
25658
|
+
if (checkBytes(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
25659
|
+
return {
|
|
25660
|
+
ext: "asf",
|
|
25661
|
+
mime: "audio/x-ms-asf"
|
|
25662
|
+
};
|
|
25663
|
+
}
|
|
25664
|
+
if (checkBytes(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
25665
|
+
return {
|
|
25666
|
+
ext: "asf",
|
|
25667
|
+
mime: "video/x-ms-asf"
|
|
25668
|
+
};
|
|
25669
|
+
}
|
|
25670
|
+
break;
|
|
25671
|
+
}
|
|
25672
|
+
if (isUnknownFileSize && payload > maximumAsfHeaderPayloadSizeInBytes) {
|
|
25673
|
+
isMalformedAsf = true;
|
|
25674
|
+
break;
|
|
25675
|
+
}
|
|
25676
|
+
await safeIgnore(tokenizer, payload, {
|
|
25677
|
+
maximumLength: isUnknownFileSize ? maximumAsfHeaderPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
25678
|
+
reason: "ASF header payload"
|
|
25679
|
+
});
|
|
25680
|
+
if (tokenizer.position <= previousPosition) {
|
|
25681
|
+
isMalformedAsf = true;
|
|
25682
|
+
break;
|
|
25683
|
+
}
|
|
25684
|
+
}
|
|
25685
|
+
} catch (error) {
|
|
25686
|
+
if (error instanceof EndOfStreamError || error instanceof ParserHardLimitError) {
|
|
25687
|
+
if (hasUnknownFileSize(tokenizer)) {
|
|
25688
|
+
isMalformedAsf = true;
|
|
25689
|
+
}
|
|
25690
|
+
} else {
|
|
25691
|
+
throw error;
|
|
25692
|
+
}
|
|
25057
25693
|
}
|
|
25058
|
-
if (
|
|
25059
|
-
zipHandler.knownSizeDescriptorScannedBytes += bytesConsumed;
|
|
25060
|
-
}
|
|
25061
|
-
if (!shouldBuffer) {
|
|
25694
|
+
if (isMalformedAsf) {
|
|
25062
25695
|
return;
|
|
25063
25696
|
}
|
|
25064
|
-
return
|
|
25697
|
+
return {
|
|
25698
|
+
ext: "asf",
|
|
25699
|
+
mime: "application/vnd.ms-asf"
|
|
25700
|
+
};
|
|
25065
25701
|
}
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
|
|
25702
|
+
var maximumAsfHeaderObjectCount = 512, maximumAsfHeaderPayloadSizeInBytes;
|
|
25703
|
+
var init_asf = __esm(() => {
|
|
25704
|
+
init_lib2();
|
|
25705
|
+
init_core();
|
|
25706
|
+
init_parser();
|
|
25707
|
+
maximumAsfHeaderPayloadSizeInBytes = 1024 * 1024;
|
|
25708
|
+
});
|
|
25709
|
+
|
|
25710
|
+
// ../../node_modules/strtok3/lib/FileTokenizer.js
|
|
25711
|
+
import { open as fsOpen } from "node:fs/promises";
|
|
25712
|
+
var FileTokenizer;
|
|
25713
|
+
var init_FileTokenizer = __esm(() => {
|
|
25714
|
+
init_AbstractTokenizer();
|
|
25715
|
+
init_stream();
|
|
25716
|
+
FileTokenizer = class FileTokenizer extends AbstractTokenizer {
|
|
25717
|
+
static async fromFile(sourceFilePath) {
|
|
25718
|
+
const fileHandle = await fsOpen(sourceFilePath, "r");
|
|
25719
|
+
const stat2 = await fileHandle.stat();
|
|
25720
|
+
return new FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size: stat2.size } });
|
|
25721
|
+
}
|
|
25722
|
+
constructor(fileHandle, options) {
|
|
25723
|
+
super(options);
|
|
25724
|
+
this.fileHandle = fileHandle;
|
|
25725
|
+
this.fileInfo = options.fileInfo;
|
|
25726
|
+
}
|
|
25727
|
+
async readBuffer(uint8Array, options) {
|
|
25728
|
+
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
25729
|
+
this.position = normOptions.position;
|
|
25730
|
+
if (normOptions.length === 0)
|
|
25731
|
+
return 0;
|
|
25732
|
+
const res = await this.fileHandle.read(uint8Array, 0, normOptions.length, normOptions.position);
|
|
25733
|
+
this.position += res.bytesRead;
|
|
25734
|
+
if (res.bytesRead < normOptions.length && (!options || !options.mayBeLess)) {
|
|
25735
|
+
throw new EndOfStreamError;
|
|
25736
|
+
}
|
|
25737
|
+
return res.bytesRead;
|
|
25738
|
+
}
|
|
25739
|
+
async peekBuffer(uint8Array, options) {
|
|
25740
|
+
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
25741
|
+
const res = await this.fileHandle.read(uint8Array, 0, normOptions.length, normOptions.position);
|
|
25742
|
+
if (!normOptions.mayBeLess && res.bytesRead < normOptions.length) {
|
|
25743
|
+
throw new EndOfStreamError;
|
|
25744
|
+
}
|
|
25745
|
+
return res.bytesRead;
|
|
25746
|
+
}
|
|
25747
|
+
async close() {
|
|
25748
|
+
await this.fileHandle.close();
|
|
25749
|
+
return super.close();
|
|
25750
|
+
}
|
|
25751
|
+
setPosition(position) {
|
|
25752
|
+
this.position = position;
|
|
25753
|
+
}
|
|
25754
|
+
supportsRandomAccess() {
|
|
25755
|
+
return true;
|
|
25756
|
+
}
|
|
25757
|
+
};
|
|
25758
|
+
});
|
|
25759
|
+
|
|
25760
|
+
// ../../node_modules/strtok3/lib/index.js
|
|
25761
|
+
var exports_lib2 = {};
|
|
25762
|
+
__export(exports_lib2, {
|
|
25763
|
+
fromWebStream: () => fromWebStream,
|
|
25764
|
+
fromStream: () => fromStream2,
|
|
25765
|
+
fromFile: () => fromFile,
|
|
25766
|
+
fromBuffer: () => fromBuffer,
|
|
25767
|
+
fromBlob: () => fromBlob,
|
|
25768
|
+
FileTokenizer: () => FileTokenizer,
|
|
25769
|
+
EndOfStreamError: () => EndOfStreamError,
|
|
25770
|
+
AbstractTokenizer: () => AbstractTokenizer,
|
|
25771
|
+
AbortError: () => AbortError
|
|
25772
|
+
});
|
|
25773
|
+
import { stat as fsStat } from "node:fs/promises";
|
|
25774
|
+
async function fromStream2(stream, options) {
|
|
25775
|
+
const rst = fromStream(stream, options);
|
|
25776
|
+
if (stream.path) {
|
|
25777
|
+
const stat2 = await fsStat(stream.path);
|
|
25778
|
+
rst.fileInfo.path = stream.path;
|
|
25779
|
+
rst.fileInfo.size = stat2.size;
|
|
25069
25780
|
}
|
|
25070
|
-
return
|
|
25781
|
+
return rst;
|
|
25071
25782
|
}
|
|
25072
|
-
|
|
25073
|
-
|
|
25074
|
-
|
|
25075
|
-
|
|
25076
|
-
|
|
25077
|
-
|
|
25783
|
+
var fromFile;
|
|
25784
|
+
var init_lib4 = __esm(() => {
|
|
25785
|
+
init_core();
|
|
25786
|
+
init_FileTokenizer();
|
|
25787
|
+
init_FileTokenizer();
|
|
25788
|
+
init_core();
|
|
25789
|
+
fromFile = FileTokenizer.fromFile;
|
|
25790
|
+
});
|
|
25791
|
+
|
|
25792
|
+
// ../../node_modules/file-type/source/index.js
|
|
25793
|
+
var exports_source = {};
|
|
25794
|
+
__export(exports_source, {
|
|
25795
|
+
supportedMimeTypes: () => supportedMimeTypes,
|
|
25796
|
+
supportedExtensions: () => supportedExtensions,
|
|
25797
|
+
reasonableDetectionSizeInBytes: () => reasonableDetectionSizeInBytes,
|
|
25798
|
+
normalizeSampleSize: () => normalizeSampleSize,
|
|
25799
|
+
fileTypeStream: () => fileTypeStream,
|
|
25800
|
+
fileTypeFromTokenizer: () => fileTypeFromTokenizer,
|
|
25801
|
+
fileTypeFromStream: () => fileTypeFromStream,
|
|
25802
|
+
fileTypeFromFile: () => fileTypeFromFile,
|
|
25803
|
+
fileTypeFromBuffer: () => fileTypeFromBuffer,
|
|
25804
|
+
fileTypeFromBlob: () => fileTypeFromBlob,
|
|
25805
|
+
FileTypeParser: () => FileTypeParser
|
|
25806
|
+
});
|
|
25807
|
+
function normalizeSampleSize(sampleSize) {
|
|
25808
|
+
if (!Number.isFinite(sampleSize)) {
|
|
25809
|
+
return reasonableDetectionSizeInBytes;
|
|
25078
25810
|
}
|
|
25079
|
-
|
|
25080
|
-
|
|
25081
|
-
|
|
25082
|
-
|
|
25083
|
-
|
|
25084
|
-
return;
|
|
25811
|
+
return Math.max(1, Math.trunc(sampleSize));
|
|
25812
|
+
}
|
|
25813
|
+
function normalizeMpegOffsetTolerance(mpegOffsetTolerance) {
|
|
25814
|
+
if (!Number.isFinite(mpegOffsetTolerance)) {
|
|
25815
|
+
return 0;
|
|
25085
25816
|
}
|
|
25086
|
-
|
|
25087
|
-
|
|
25088
|
-
|
|
25817
|
+
return Math.max(0, Math.min(maximumMpegOffsetTolerance, Math.trunc(mpegOffsetTolerance)));
|
|
25818
|
+
}
|
|
25819
|
+
function getKnownFileSizeOrMaximum(fileSize) {
|
|
25820
|
+
if (!Number.isFinite(fileSize)) {
|
|
25821
|
+
return Number.MAX_SAFE_INTEGER;
|
|
25089
25822
|
}
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25823
|
+
return Math.max(0, fileSize);
|
|
25824
|
+
}
|
|
25825
|
+
function toDefaultStream(stream) {
|
|
25826
|
+
return stream.pipeThrough(new TransformStream);
|
|
25827
|
+
}
|
|
25828
|
+
function readWithSignal(reader, signal) {
|
|
25829
|
+
if (signal === undefined) {
|
|
25830
|
+
return reader.read();
|
|
25831
|
+
}
|
|
25832
|
+
signal.throwIfAborted();
|
|
25833
|
+
return Promise.race([
|
|
25834
|
+
reader.read(),
|
|
25835
|
+
new Promise((_resolve, reject) => {
|
|
25836
|
+
signal.addEventListener("abort", () => {
|
|
25837
|
+
reject(signal.reason);
|
|
25838
|
+
reader.cancel(signal.reason).catch(() => {
|
|
25839
|
+
});
|
|
25840
|
+
}, { once: true });
|
|
25841
|
+
})
|
|
25842
|
+
]);
|
|
25093
25843
|
}
|
|
25094
25844
|
function createByteLimitedReadableStream(stream, maximumBytes) {
|
|
25095
25845
|
const reader = stream.getReader();
|
|
@@ -25132,325 +25882,24 @@ function createByteLimitedReadableStream(stream, maximumBytes) {
|
|
|
25132
25882
|
}
|
|
25133
25883
|
});
|
|
25134
25884
|
}
|
|
25885
|
+
async function fileTypeFromStream(stream, options) {
|
|
25886
|
+
return new FileTypeParser(options).fromStream(stream);
|
|
25887
|
+
}
|
|
25135
25888
|
async function fileTypeFromBuffer(input, options) {
|
|
25136
25889
|
return new FileTypeParser(options).fromBuffer(input);
|
|
25137
25890
|
}
|
|
25138
25891
|
async function fileTypeFromBlob(blob, options) {
|
|
25139
25892
|
return new FileTypeParser(options).fromBlob(blob);
|
|
25140
25893
|
}
|
|
25141
|
-
function getFileTypeFromMimeType(mimeType) {
|
|
25142
|
-
mimeType = mimeType.toLowerCase();
|
|
25143
|
-
switch (mimeType) {
|
|
25144
|
-
case "application/epub+zip":
|
|
25145
|
-
return {
|
|
25146
|
-
ext: "epub",
|
|
25147
|
-
mime: mimeType
|
|
25148
|
-
};
|
|
25149
|
-
case "application/vnd.oasis.opendocument.text":
|
|
25150
|
-
return {
|
|
25151
|
-
ext: "odt",
|
|
25152
|
-
mime: mimeType
|
|
25153
|
-
};
|
|
25154
|
-
case "application/vnd.oasis.opendocument.text-template":
|
|
25155
|
-
return {
|
|
25156
|
-
ext: "ott",
|
|
25157
|
-
mime: mimeType
|
|
25158
|
-
};
|
|
25159
|
-
case "application/vnd.oasis.opendocument.spreadsheet":
|
|
25160
|
-
return {
|
|
25161
|
-
ext: "ods",
|
|
25162
|
-
mime: mimeType
|
|
25163
|
-
};
|
|
25164
|
-
case "application/vnd.oasis.opendocument.spreadsheet-template":
|
|
25165
|
-
return {
|
|
25166
|
-
ext: "ots",
|
|
25167
|
-
mime: mimeType
|
|
25168
|
-
};
|
|
25169
|
-
case "application/vnd.oasis.opendocument.presentation":
|
|
25170
|
-
return {
|
|
25171
|
-
ext: "odp",
|
|
25172
|
-
mime: mimeType
|
|
25173
|
-
};
|
|
25174
|
-
case "application/vnd.oasis.opendocument.presentation-template":
|
|
25175
|
-
return {
|
|
25176
|
-
ext: "otp",
|
|
25177
|
-
mime: mimeType
|
|
25178
|
-
};
|
|
25179
|
-
case "application/vnd.oasis.opendocument.graphics":
|
|
25180
|
-
return {
|
|
25181
|
-
ext: "odg",
|
|
25182
|
-
mime: mimeType
|
|
25183
|
-
};
|
|
25184
|
-
case "application/vnd.oasis.opendocument.graphics-template":
|
|
25185
|
-
return {
|
|
25186
|
-
ext: "otg",
|
|
25187
|
-
mime: mimeType
|
|
25188
|
-
};
|
|
25189
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.slideshow":
|
|
25190
|
-
return {
|
|
25191
|
-
ext: "ppsx",
|
|
25192
|
-
mime: mimeType
|
|
25193
|
-
};
|
|
25194
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
25195
|
-
return {
|
|
25196
|
-
ext: "xlsx",
|
|
25197
|
-
mime: mimeType
|
|
25198
|
-
};
|
|
25199
|
-
case "application/vnd.ms-excel.sheet.macroenabled":
|
|
25200
|
-
return {
|
|
25201
|
-
ext: "xlsm",
|
|
25202
|
-
mime: "application/vnd.ms-excel.sheet.macroenabled.12"
|
|
25203
|
-
};
|
|
25204
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.template":
|
|
25205
|
-
return {
|
|
25206
|
-
ext: "xltx",
|
|
25207
|
-
mime: mimeType
|
|
25208
|
-
};
|
|
25209
|
-
case "application/vnd.ms-excel.template.macroenabled":
|
|
25210
|
-
return {
|
|
25211
|
-
ext: "xltm",
|
|
25212
|
-
mime: "application/vnd.ms-excel.template.macroenabled.12"
|
|
25213
|
-
};
|
|
25214
|
-
case "application/vnd.ms-powerpoint.slideshow.macroenabled":
|
|
25215
|
-
return {
|
|
25216
|
-
ext: "ppsm",
|
|
25217
|
-
mime: "application/vnd.ms-powerpoint.slideshow.macroenabled.12"
|
|
25218
|
-
};
|
|
25219
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
25220
|
-
return {
|
|
25221
|
-
ext: "docx",
|
|
25222
|
-
mime: mimeType
|
|
25223
|
-
};
|
|
25224
|
-
case "application/vnd.ms-word.document.macroenabled":
|
|
25225
|
-
return {
|
|
25226
|
-
ext: "docm",
|
|
25227
|
-
mime: "application/vnd.ms-word.document.macroenabled.12"
|
|
25228
|
-
};
|
|
25229
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.template":
|
|
25230
|
-
return {
|
|
25231
|
-
ext: "dotx",
|
|
25232
|
-
mime: mimeType
|
|
25233
|
-
};
|
|
25234
|
-
case "application/vnd.ms-word.template.macroenabledtemplate":
|
|
25235
|
-
return {
|
|
25236
|
-
ext: "dotm",
|
|
25237
|
-
mime: "application/vnd.ms-word.template.macroenabled.12"
|
|
25238
|
-
};
|
|
25239
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.template":
|
|
25240
|
-
return {
|
|
25241
|
-
ext: "potx",
|
|
25242
|
-
mime: mimeType
|
|
25243
|
-
};
|
|
25244
|
-
case "application/vnd.ms-powerpoint.template.macroenabled":
|
|
25245
|
-
return {
|
|
25246
|
-
ext: "potm",
|
|
25247
|
-
mime: "application/vnd.ms-powerpoint.template.macroenabled.12"
|
|
25248
|
-
};
|
|
25249
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
25250
|
-
return {
|
|
25251
|
-
ext: "pptx",
|
|
25252
|
-
mime: mimeType
|
|
25253
|
-
};
|
|
25254
|
-
case "application/vnd.ms-powerpoint.presentation.macroenabled":
|
|
25255
|
-
return {
|
|
25256
|
-
ext: "pptm",
|
|
25257
|
-
mime: "application/vnd.ms-powerpoint.presentation.macroenabled.12"
|
|
25258
|
-
};
|
|
25259
|
-
case "application/vnd.ms-visio.drawing":
|
|
25260
|
-
return {
|
|
25261
|
-
ext: "vsdx",
|
|
25262
|
-
mime: "application/vnd.visio"
|
|
25263
|
-
};
|
|
25264
|
-
case "application/vnd.ms-package.3dmanufacturing-3dmodel+xml":
|
|
25265
|
-
return {
|
|
25266
|
-
ext: "3mf",
|
|
25267
|
-
mime: "model/3mf"
|
|
25268
|
-
};
|
|
25269
|
-
default:
|
|
25270
|
-
}
|
|
25271
|
-
}
|
|
25272
|
-
function _check(buffer, headers, options) {
|
|
25273
|
-
options = {
|
|
25274
|
-
offset: 0,
|
|
25275
|
-
...options
|
|
25276
|
-
};
|
|
25277
|
-
for (const [index, header] of headers.entries()) {
|
|
25278
|
-
if (options.mask) {
|
|
25279
|
-
if (header !== (options.mask[index] & buffer[index + options.offset])) {
|
|
25280
|
-
return false;
|
|
25281
|
-
}
|
|
25282
|
-
} else if (header !== buffer[index + options.offset]) {
|
|
25283
|
-
return false;
|
|
25284
|
-
}
|
|
25285
|
-
}
|
|
25286
|
-
return true;
|
|
25287
|
-
}
|
|
25288
|
-
function normalizeSampleSize(sampleSize) {
|
|
25289
|
-
if (!Number.isFinite(sampleSize)) {
|
|
25290
|
-
return reasonableDetectionSizeInBytes;
|
|
25291
|
-
}
|
|
25292
|
-
return Math.max(1, Math.trunc(sampleSize));
|
|
25293
|
-
}
|
|
25294
|
-
function readByobReaderWithSignal(reader, buffer, signal) {
|
|
25295
|
-
if (signal === undefined) {
|
|
25296
|
-
return reader.read(buffer);
|
|
25297
|
-
}
|
|
25298
|
-
signal.throwIfAborted();
|
|
25299
|
-
return new Promise((resolve3, reject) => {
|
|
25300
|
-
const cleanup = () => {
|
|
25301
|
-
signal.removeEventListener("abort", onAbort);
|
|
25302
|
-
};
|
|
25303
|
-
const onAbort = () => {
|
|
25304
|
-
const abortReason = signal.reason;
|
|
25305
|
-
cleanup();
|
|
25306
|
-
(async () => {
|
|
25307
|
-
try {
|
|
25308
|
-
await reader.cancel(abortReason);
|
|
25309
|
-
} catch {
|
|
25310
|
-
}
|
|
25311
|
-
})();
|
|
25312
|
-
reject(abortReason);
|
|
25313
|
-
};
|
|
25314
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
25315
|
-
(async () => {
|
|
25316
|
-
try {
|
|
25317
|
-
const result = await reader.read(buffer);
|
|
25318
|
-
cleanup();
|
|
25319
|
-
resolve3(result);
|
|
25320
|
-
} catch (error) {
|
|
25321
|
-
cleanup();
|
|
25322
|
-
reject(error);
|
|
25323
|
-
}
|
|
25324
|
-
})();
|
|
25325
|
-
});
|
|
25326
|
-
}
|
|
25327
|
-
function normalizeMpegOffsetTolerance(mpegOffsetTolerance) {
|
|
25328
|
-
if (!Number.isFinite(mpegOffsetTolerance)) {
|
|
25329
|
-
return 0;
|
|
25330
|
-
}
|
|
25331
|
-
return Math.max(0, Math.min(maximumMpegOffsetTolerance, Math.trunc(mpegOffsetTolerance)));
|
|
25332
|
-
}
|
|
25333
|
-
function getKnownFileSizeOrMaximum(fileSize) {
|
|
25334
|
-
if (!Number.isFinite(fileSize)) {
|
|
25335
|
-
return Number.MAX_SAFE_INTEGER;
|
|
25336
|
-
}
|
|
25337
|
-
return Math.max(0, fileSize);
|
|
25338
|
-
}
|
|
25339
|
-
function hasUnknownFileSize(tokenizer) {
|
|
25340
|
-
const fileSize = tokenizer.fileInfo.size;
|
|
25341
|
-
return !Number.isFinite(fileSize) || fileSize === Number.MAX_SAFE_INTEGER;
|
|
25342
|
-
}
|
|
25343
|
-
function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
|
|
25344
|
-
return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
|
|
25345
|
-
}
|
|
25346
|
-
function getMaximumZipBufferedReadLength(tokenizer) {
|
|
25347
|
-
const fileSize = tokenizer.fileInfo.size;
|
|
25348
|
-
const remainingBytes = Number.isFinite(fileSize) ? Math.max(0, fileSize - tokenizer.position) : Number.MAX_SAFE_INTEGER;
|
|
25349
|
-
return Math.min(remainingBytes, maximumZipBufferedReadSizeInBytes);
|
|
25350
|
-
}
|
|
25351
|
-
function isRecoverableZipError(error) {
|
|
25352
|
-
if (error instanceof EndOfStreamError) {
|
|
25353
|
-
return true;
|
|
25354
|
-
}
|
|
25355
|
-
if (error instanceof ParserHardLimitError) {
|
|
25356
|
-
return true;
|
|
25357
|
-
}
|
|
25358
|
-
if (!(error instanceof Error)) {
|
|
25359
|
-
return false;
|
|
25360
|
-
}
|
|
25361
|
-
if (recoverableZipErrorMessages.has(error.message)) {
|
|
25362
|
-
return true;
|
|
25363
|
-
}
|
|
25364
|
-
if (recoverableZipErrorCodes.has(error.code)) {
|
|
25365
|
-
return true;
|
|
25366
|
-
}
|
|
25367
|
-
for (const prefix of recoverableZipErrorMessagePrefixes) {
|
|
25368
|
-
if (error.message.startsWith(prefix)) {
|
|
25369
|
-
return true;
|
|
25370
|
-
}
|
|
25371
|
-
}
|
|
25372
|
-
return false;
|
|
25373
|
-
}
|
|
25374
|
-
function canReadZipEntryForDetection(zipHeader, maximumSize = maximumZipEntrySizeInBytes) {
|
|
25375
|
-
const sizes = [zipHeader.compressedSize, zipHeader.uncompressedSize];
|
|
25376
|
-
for (const size of sizes) {
|
|
25377
|
-
if (!Number.isFinite(size) || size < 0 || size > maximumSize) {
|
|
25378
|
-
return false;
|
|
25379
|
-
}
|
|
25380
|
-
}
|
|
25381
|
-
return true;
|
|
25382
|
-
}
|
|
25383
|
-
function createOpenXmlZipDetectionState() {
|
|
25384
|
-
return {
|
|
25385
|
-
hasContentTypesEntry: false,
|
|
25386
|
-
hasParsedContentTypesEntry: false,
|
|
25387
|
-
isParsingContentTypes: false,
|
|
25388
|
-
hasUnparseableContentTypes: false,
|
|
25389
|
-
hasWordDirectory: false,
|
|
25390
|
-
hasPresentationDirectory: false,
|
|
25391
|
-
hasSpreadsheetDirectory: false,
|
|
25392
|
-
hasThreeDimensionalModelEntry: false
|
|
25393
|
-
};
|
|
25394
|
-
}
|
|
25395
|
-
function updateOpenXmlZipDetectionStateFromFilename(openXmlState, filename) {
|
|
25396
|
-
if (filename.startsWith("word/")) {
|
|
25397
|
-
openXmlState.hasWordDirectory = true;
|
|
25398
|
-
}
|
|
25399
|
-
if (filename.startsWith("ppt/")) {
|
|
25400
|
-
openXmlState.hasPresentationDirectory = true;
|
|
25401
|
-
}
|
|
25402
|
-
if (filename.startsWith("xl/")) {
|
|
25403
|
-
openXmlState.hasSpreadsheetDirectory = true;
|
|
25404
|
-
}
|
|
25405
|
-
if (filename.startsWith("3D/") && filename.endsWith(".model")) {
|
|
25406
|
-
openXmlState.hasThreeDimensionalModelEntry = true;
|
|
25407
|
-
}
|
|
25408
|
-
}
|
|
25409
|
-
function getOpenXmlFileTypeFromZipEntries(openXmlState) {
|
|
25410
|
-
if (!openXmlState.hasContentTypesEntry || openXmlState.hasUnparseableContentTypes || openXmlState.isParsingContentTypes || openXmlState.hasParsedContentTypesEntry) {
|
|
25411
|
-
return;
|
|
25412
|
-
}
|
|
25413
|
-
if (openXmlState.hasWordDirectory) {
|
|
25414
|
-
return {
|
|
25415
|
-
ext: "docx",
|
|
25416
|
-
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
25417
|
-
};
|
|
25418
|
-
}
|
|
25419
|
-
if (openXmlState.hasPresentationDirectory) {
|
|
25420
|
-
return {
|
|
25421
|
-
ext: "pptx",
|
|
25422
|
-
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
25423
|
-
};
|
|
25424
|
-
}
|
|
25425
|
-
if (openXmlState.hasSpreadsheetDirectory) {
|
|
25426
|
-
return {
|
|
25427
|
-
ext: "xlsx",
|
|
25428
|
-
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
25429
|
-
};
|
|
25430
|
-
}
|
|
25431
|
-
if (openXmlState.hasThreeDimensionalModelEntry) {
|
|
25432
|
-
return {
|
|
25433
|
-
ext: "3mf",
|
|
25434
|
-
mime: "model/3mf"
|
|
25435
|
-
};
|
|
25436
|
-
}
|
|
25437
|
-
}
|
|
25438
|
-
function getOpenXmlMimeTypeFromContentTypesXml(xmlContent) {
|
|
25439
|
-
const endPosition = xmlContent.indexOf('.main+xml"');
|
|
25440
|
-
if (endPosition === -1) {
|
|
25441
|
-
const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
|
|
25442
|
-
if (xmlContent.includes(`ContentType="${mimeType}"`)) {
|
|
25443
|
-
return mimeType;
|
|
25444
|
-
}
|
|
25445
|
-
return;
|
|
25446
|
-
}
|
|
25447
|
-
const truncatedContent = xmlContent.slice(0, endPosition);
|
|
25448
|
-
const firstQuotePosition = truncatedContent.lastIndexOf('"');
|
|
25449
|
-
return truncatedContent.slice(firstQuotePosition + 1);
|
|
25450
|
-
}
|
|
25451
25894
|
async function fileTypeFromTokenizer(tokenizer, options) {
|
|
25452
25895
|
return new FileTypeParser(options).fromTokenizer(tokenizer);
|
|
25453
25896
|
}
|
|
25897
|
+
async function fileTypeStream(webStream, options) {
|
|
25898
|
+
return new FileTypeParser(options).toDetectionStream(webStream, options);
|
|
25899
|
+
}
|
|
25900
|
+
async function fileTypeFromFile(path, options) {
|
|
25901
|
+
return new FileTypeParser(options).fromFile(path);
|
|
25902
|
+
}
|
|
25454
25903
|
|
|
25455
25904
|
class FileTypeParser {
|
|
25456
25905
|
constructor(options) {
|
|
@@ -25475,7 +25924,7 @@ class FileTypeParser {
|
|
|
25475
25924
|
};
|
|
25476
25925
|
}
|
|
25477
25926
|
createTokenizerFromWebStream(stream) {
|
|
25478
|
-
return
|
|
25927
|
+
return fromWebStream(toDefaultStream(stream), this.getTokenizerOptions());
|
|
25479
25928
|
}
|
|
25480
25929
|
async parseTokenizer(tokenizer, detectionReentryCount = 0) {
|
|
25481
25930
|
this.detectionReentryCount = detectionReentryCount;
|
|
@@ -25528,31 +25977,76 @@ class FileTypeParser {
|
|
|
25528
25977
|
const tokenizer = this.createTokenizerFromWebStream(stream);
|
|
25529
25978
|
return this.fromTokenizer(tokenizer);
|
|
25530
25979
|
}
|
|
25980
|
+
async fromFile(path) {
|
|
25981
|
+
this.options.signal?.throwIfAborted();
|
|
25982
|
+
const [{ default: fsPromises }, { FileTokenizer: FileTokenizer2 }] = await Promise.all([
|
|
25983
|
+
import("node:fs/promises"),
|
|
25984
|
+
Promise.resolve().then(() => (init_lib4(), exports_lib2))
|
|
25985
|
+
]);
|
|
25986
|
+
const fileHandle = await fsPromises.open(path, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
|
|
25987
|
+
const fileStat = await fileHandle.stat();
|
|
25988
|
+
if (!fileStat.isFile()) {
|
|
25989
|
+
await fileHandle.close();
|
|
25990
|
+
return;
|
|
25991
|
+
}
|
|
25992
|
+
const tokenizer = new FileTokenizer2(fileHandle, {
|
|
25993
|
+
...this.getTokenizerOptions(),
|
|
25994
|
+
fileInfo: { path, size: fileStat.size }
|
|
25995
|
+
});
|
|
25996
|
+
return this.fromTokenizer(tokenizer);
|
|
25997
|
+
}
|
|
25531
25998
|
async toDetectionStream(stream, options) {
|
|
25999
|
+
this.options.signal?.throwIfAborted();
|
|
25532
26000
|
const sampleSize = normalizeSampleSize(options?.sampleSize ?? reasonableDetectionSizeInBytes);
|
|
25533
26001
|
let detectedFileType;
|
|
25534
|
-
let
|
|
25535
|
-
const reader = stream.getReader(
|
|
26002
|
+
let streamEnded = false;
|
|
26003
|
+
const reader = stream.getReader();
|
|
26004
|
+
const chunks = [];
|
|
26005
|
+
let totalSize = 0;
|
|
25536
26006
|
try {
|
|
25537
|
-
|
|
25538
|
-
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
}
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
26007
|
+
while (totalSize < sampleSize) {
|
|
26008
|
+
const { value, done } = await readWithSignal(reader, this.options.signal);
|
|
26009
|
+
if (done || !value) {
|
|
26010
|
+
streamEnded = true;
|
|
26011
|
+
break;
|
|
26012
|
+
}
|
|
26013
|
+
chunks.push(value);
|
|
26014
|
+
totalSize += value.length;
|
|
26015
|
+
}
|
|
26016
|
+
if (!streamEnded && totalSize === sampleSize) {
|
|
26017
|
+
const { value, done } = await readWithSignal(reader, this.options.signal);
|
|
26018
|
+
if (done || !value) {
|
|
26019
|
+
streamEnded = true;
|
|
26020
|
+
} else {
|
|
26021
|
+
chunks.push(value);
|
|
26022
|
+
totalSize += value.length;
|
|
25547
26023
|
}
|
|
25548
26024
|
}
|
|
25549
|
-
firstChunk = chunk;
|
|
25550
26025
|
} finally {
|
|
25551
26026
|
reader.releaseLock();
|
|
25552
26027
|
}
|
|
26028
|
+
if (totalSize > 0) {
|
|
26029
|
+
const sample = chunks.length === 1 ? chunks[0] : concatUint8Arrays(chunks);
|
|
26030
|
+
try {
|
|
26031
|
+
detectedFileType = await this.fromBuffer(sample.subarray(0, sampleSize));
|
|
26032
|
+
} catch (error) {
|
|
26033
|
+
if (!(error instanceof EndOfStreamError)) {
|
|
26034
|
+
throw error;
|
|
26035
|
+
}
|
|
26036
|
+
detectedFileType = undefined;
|
|
26037
|
+
}
|
|
26038
|
+
if (!streamEnded && detectedFileType?.ext === "pages") {
|
|
26039
|
+
detectedFileType = {
|
|
26040
|
+
ext: "zip",
|
|
26041
|
+
mime: "application/zip"
|
|
26042
|
+
};
|
|
26043
|
+
}
|
|
26044
|
+
}
|
|
25553
26045
|
const transformStream = new TransformStream({
|
|
25554
|
-
|
|
25555
|
-
|
|
26046
|
+
start(controller) {
|
|
26047
|
+
for (const chunk of chunks) {
|
|
26048
|
+
controller.enqueue(chunk);
|
|
26049
|
+
}
|
|
25556
26050
|
},
|
|
25557
26051
|
transform(chunk, controller) {
|
|
25558
26052
|
controller.enqueue(chunk);
|
|
@@ -25614,7 +26108,7 @@ class FileTypeParser {
|
|
|
25614
26108
|
};
|
|
25615
26109
|
}
|
|
25616
26110
|
check(header, options) {
|
|
25617
|
-
return
|
|
26111
|
+
return checkBytes(this.buffer, header, options);
|
|
25618
26112
|
}
|
|
25619
26113
|
checkString(header, options) {
|
|
25620
26114
|
return this.check(stringToBytes(header, options?.encoding), options);
|
|
@@ -25813,127 +26307,43 @@ class FileTypeParser {
|
|
|
25813
26307
|
};
|
|
25814
26308
|
}
|
|
25815
26309
|
if (this.check([80, 75, 3, 4])) {
|
|
25816
|
-
|
|
25817
|
-
const openXmlState = createOpenXmlZipDetectionState();
|
|
25818
|
-
try {
|
|
25819
|
-
await new ZipHandler(tokenizer).unzip((zipHeader) => {
|
|
25820
|
-
updateOpenXmlZipDetectionStateFromFilename(openXmlState, zipHeader.filename);
|
|
25821
|
-
const isOpenXmlContentTypesEntry = zipHeader.filename === "[Content_Types].xml";
|
|
25822
|
-
const openXmlFileTypeFromEntries = getOpenXmlFileTypeFromZipEntries(openXmlState);
|
|
25823
|
-
if (!isOpenXmlContentTypesEntry && openXmlFileTypeFromEntries) {
|
|
25824
|
-
fileType = openXmlFileTypeFromEntries;
|
|
25825
|
-
return {
|
|
25826
|
-
stop: true
|
|
25827
|
-
};
|
|
25828
|
-
}
|
|
25829
|
-
switch (zipHeader.filename) {
|
|
25830
|
-
case "META-INF/mozilla.rsa":
|
|
25831
|
-
fileType = {
|
|
25832
|
-
ext: "xpi",
|
|
25833
|
-
mime: "application/x-xpinstall"
|
|
25834
|
-
};
|
|
25835
|
-
return {
|
|
25836
|
-
stop: true
|
|
25837
|
-
};
|
|
25838
|
-
case "META-INF/MANIFEST.MF":
|
|
25839
|
-
fileType = {
|
|
25840
|
-
ext: "jar",
|
|
25841
|
-
mime: "application/java-archive"
|
|
25842
|
-
};
|
|
25843
|
-
return {
|
|
25844
|
-
stop: true
|
|
25845
|
-
};
|
|
25846
|
-
case "mimetype":
|
|
25847
|
-
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25848
|
-
return {};
|
|
25849
|
-
}
|
|
25850
|
-
return {
|
|
25851
|
-
async handler(fileData) {
|
|
25852
|
-
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
25853
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
25854
|
-
},
|
|
25855
|
-
stop: true
|
|
25856
|
-
};
|
|
25857
|
-
case "[Content_Types].xml": {
|
|
25858
|
-
openXmlState.hasContentTypesEntry = true;
|
|
25859
|
-
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25860
|
-
openXmlState.hasUnparseableContentTypes = true;
|
|
25861
|
-
return {};
|
|
25862
|
-
}
|
|
25863
|
-
openXmlState.isParsingContentTypes = true;
|
|
25864
|
-
return {
|
|
25865
|
-
async handler(fileData) {
|
|
25866
|
-
const xmlContent = new TextDecoder("utf-8").decode(fileData);
|
|
25867
|
-
const mimeType = getOpenXmlMimeTypeFromContentTypesXml(xmlContent);
|
|
25868
|
-
if (mimeType) {
|
|
25869
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
25870
|
-
}
|
|
25871
|
-
openXmlState.hasParsedContentTypesEntry = true;
|
|
25872
|
-
openXmlState.isParsingContentTypes = false;
|
|
25873
|
-
},
|
|
25874
|
-
stop: true
|
|
25875
|
-
};
|
|
25876
|
-
}
|
|
25877
|
-
default:
|
|
25878
|
-
if (/classes\d*\.dex/.test(zipHeader.filename)) {
|
|
25879
|
-
fileType = {
|
|
25880
|
-
ext: "apk",
|
|
25881
|
-
mime: "application/vnd.android.package-archive"
|
|
25882
|
-
};
|
|
25883
|
-
return { stop: true };
|
|
25884
|
-
}
|
|
25885
|
-
return {};
|
|
25886
|
-
}
|
|
25887
|
-
});
|
|
25888
|
-
} catch (error) {
|
|
25889
|
-
if (!isRecoverableZipError(error)) {
|
|
25890
|
-
throw error;
|
|
25891
|
-
}
|
|
25892
|
-
if (openXmlState.isParsingContentTypes) {
|
|
25893
|
-
openXmlState.isParsingContentTypes = false;
|
|
25894
|
-
openXmlState.hasUnparseableContentTypes = true;
|
|
25895
|
-
}
|
|
25896
|
-
}
|
|
25897
|
-
return fileType ?? getOpenXmlFileTypeFromZipEntries(openXmlState) ?? {
|
|
25898
|
-
ext: "zip",
|
|
25899
|
-
mime: "application/zip"
|
|
25900
|
-
};
|
|
26310
|
+
return detectZip(tokenizer);
|
|
25901
26311
|
}
|
|
25902
26312
|
if (this.checkString("OggS")) {
|
|
25903
26313
|
await tokenizer.ignore(28);
|
|
25904
26314
|
const type = new Uint8Array(8);
|
|
25905
26315
|
await tokenizer.readBuffer(type);
|
|
25906
|
-
if (
|
|
26316
|
+
if (checkBytes(type, [79, 112, 117, 115, 72, 101, 97, 100])) {
|
|
25907
26317
|
return {
|
|
25908
26318
|
ext: "opus",
|
|
25909
26319
|
mime: "audio/ogg; codecs=opus"
|
|
25910
26320
|
};
|
|
25911
26321
|
}
|
|
25912
|
-
if (
|
|
26322
|
+
if (checkBytes(type, [128, 116, 104, 101, 111, 114, 97])) {
|
|
25913
26323
|
return {
|
|
25914
26324
|
ext: "ogv",
|
|
25915
26325
|
mime: "video/ogg"
|
|
25916
26326
|
};
|
|
25917
26327
|
}
|
|
25918
|
-
if (
|
|
26328
|
+
if (checkBytes(type, [1, 118, 105, 100, 101, 111, 0])) {
|
|
25919
26329
|
return {
|
|
25920
26330
|
ext: "ogm",
|
|
25921
26331
|
mime: "video/ogg"
|
|
25922
26332
|
};
|
|
25923
26333
|
}
|
|
25924
|
-
if (
|
|
26334
|
+
if (checkBytes(type, [127, 70, 76, 65, 67])) {
|
|
25925
26335
|
return {
|
|
25926
26336
|
ext: "oga",
|
|
25927
26337
|
mime: "audio/ogg"
|
|
25928
26338
|
};
|
|
25929
26339
|
}
|
|
25930
|
-
if (
|
|
26340
|
+
if (checkBytes(type, [83, 112, 101, 101, 120, 32, 32])) {
|
|
25931
26341
|
return {
|
|
25932
26342
|
ext: "spx",
|
|
25933
26343
|
mime: "audio/ogg"
|
|
25934
26344
|
};
|
|
25935
26345
|
}
|
|
25936
|
-
if (
|
|
26346
|
+
if (checkBytes(type, [1, 118, 111, 114, 98, 105, 115])) {
|
|
25937
26347
|
return {
|
|
25938
26348
|
ext: "ogg",
|
|
25939
26349
|
mime: "audio/ogg"
|
|
@@ -25983,7 +26393,7 @@ class FileTypeParser {
|
|
|
25983
26393
|
if (this.checkString("LZIP")) {
|
|
25984
26394
|
return {
|
|
25985
26395
|
ext: "lz",
|
|
25986
|
-
mime: "application/
|
|
26396
|
+
mime: "application/lzip"
|
|
25987
26397
|
};
|
|
25988
26398
|
}
|
|
25989
26399
|
if (this.checkString("fLaC")) {
|
|
@@ -26035,83 +26445,7 @@ class FileTypeParser {
|
|
|
26035
26445
|
};
|
|
26036
26446
|
}
|
|
26037
26447
|
if (this.check([26, 69, 223, 163])) {
|
|
26038
|
-
|
|
26039
|
-
const msb = await tokenizer.peekNumber(UINT8);
|
|
26040
|
-
let mask = 128;
|
|
26041
|
-
let ic = 0;
|
|
26042
|
-
while ((msb & mask) === 0 && mask !== 0) {
|
|
26043
|
-
++ic;
|
|
26044
|
-
mask >>= 1;
|
|
26045
|
-
}
|
|
26046
|
-
const id = new Uint8Array(ic + 1);
|
|
26047
|
-
await safeReadBuffer(tokenizer, id, undefined, {
|
|
26048
|
-
maximumLength: id.length,
|
|
26049
|
-
reason: "EBML field"
|
|
26050
|
-
});
|
|
26051
|
-
return id;
|
|
26052
|
-
}
|
|
26053
|
-
async function readElement() {
|
|
26054
|
-
const idField = await readField();
|
|
26055
|
-
const lengthField = await readField();
|
|
26056
|
-
lengthField[0] ^= 128 >> lengthField.length - 1;
|
|
26057
|
-
const nrLength = Math.min(6, lengthField.length);
|
|
26058
|
-
const idView = new DataView(idField.buffer);
|
|
26059
|
-
const lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);
|
|
26060
|
-
return {
|
|
26061
|
-
id: getUintBE(idView),
|
|
26062
|
-
len: getUintBE(lengthView)
|
|
26063
|
-
};
|
|
26064
|
-
}
|
|
26065
|
-
async function readChildren(children) {
|
|
26066
|
-
let ebmlElementCount = 0;
|
|
26067
|
-
while (children > 0) {
|
|
26068
|
-
ebmlElementCount++;
|
|
26069
|
-
if (ebmlElementCount > maximumEbmlElementCount) {
|
|
26070
|
-
return;
|
|
26071
|
-
}
|
|
26072
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, ebmlScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
26073
|
-
return;
|
|
26074
|
-
}
|
|
26075
|
-
const previousPosition = tokenizer.position;
|
|
26076
|
-
const element = await readElement();
|
|
26077
|
-
if (element.id === 17026) {
|
|
26078
|
-
if (element.len > maximumEbmlDocumentTypeSizeInBytes) {
|
|
26079
|
-
return;
|
|
26080
|
-
}
|
|
26081
|
-
const documentTypeLength = getSafeBound(element.len, maximumEbmlDocumentTypeSizeInBytes, "EBML DocType");
|
|
26082
|
-
const rawValue = await tokenizer.readToken(new StringType2(documentTypeLength));
|
|
26083
|
-
return rawValue.replaceAll(/\00.*$/g, "");
|
|
26084
|
-
}
|
|
26085
|
-
if (hasUnknownFileSize(tokenizer) && (!Number.isFinite(element.len) || element.len < 0 || element.len > maximumEbmlElementPayloadSizeInBytes)) {
|
|
26086
|
-
return;
|
|
26087
|
-
}
|
|
26088
|
-
await safeIgnore(tokenizer, element.len, {
|
|
26089
|
-
maximumLength: hasUnknownFileSize(tokenizer) ? maximumEbmlElementPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
26090
|
-
reason: "EBML payload"
|
|
26091
|
-
});
|
|
26092
|
-
--children;
|
|
26093
|
-
if (tokenizer.position <= previousPosition) {
|
|
26094
|
-
return;
|
|
26095
|
-
}
|
|
26096
|
-
}
|
|
26097
|
-
}
|
|
26098
|
-
const rootElement = await readElement();
|
|
26099
|
-
const ebmlScanStart = tokenizer.position;
|
|
26100
|
-
const documentType = await readChildren(rootElement.len);
|
|
26101
|
-
switch (documentType) {
|
|
26102
|
-
case "webm":
|
|
26103
|
-
return {
|
|
26104
|
-
ext: "webm",
|
|
26105
|
-
mime: "video/webm"
|
|
26106
|
-
};
|
|
26107
|
-
case "matroska":
|
|
26108
|
-
return {
|
|
26109
|
-
ext: "mkv",
|
|
26110
|
-
mime: "video/matroska"
|
|
26111
|
-
};
|
|
26112
|
-
default:
|
|
26113
|
-
return;
|
|
26114
|
-
}
|
|
26448
|
+
return detectEbml(tokenizer);
|
|
26115
26449
|
}
|
|
26116
26450
|
if (this.checkString("SQLi")) {
|
|
26117
26451
|
return {
|
|
@@ -26215,7 +26549,7 @@ class FileTypeParser {
|
|
|
26215
26549
|
mime: "audio/amr"
|
|
26216
26550
|
};
|
|
26217
26551
|
}
|
|
26218
|
-
if (this.checkString(
|
|
26552
|
+
if (this.checkString(String.raw`{\rtf`)) {
|
|
26219
26553
|
return {
|
|
26220
26554
|
ext: "rtf",
|
|
26221
26555
|
mime: "application/rtf"
|
|
@@ -26284,7 +26618,7 @@ class FileTypeParser {
|
|
|
26284
26618
|
if (this.checkString("DRACO")) {
|
|
26285
26619
|
return {
|
|
26286
26620
|
ext: "drc",
|
|
26287
|
-
mime: "application/
|
|
26621
|
+
mime: "application/x-ft-draco"
|
|
26288
26622
|
};
|
|
26289
26623
|
}
|
|
26290
26624
|
if (this.check([253, 55, 122, 88, 90, 0])) {
|
|
@@ -26319,7 +26653,7 @@ class FileTypeParser {
|
|
|
26319
26653
|
}
|
|
26320
26654
|
if (this.checkString("AC")) {
|
|
26321
26655
|
const version = new StringType2(4, "latin1").get(this.buffer, 2);
|
|
26322
|
-
if (
|
|
26656
|
+
if (/^\d+$/v.test(version) && version >= 1000 && version <= 1050) {
|
|
26323
26657
|
return {
|
|
26324
26658
|
ext: "dwg",
|
|
26325
26659
|
mime: "image/vnd.dwg"
|
|
@@ -26359,73 +26693,7 @@ class FileTypeParser {
|
|
|
26359
26693
|
};
|
|
26360
26694
|
}
|
|
26361
26695
|
if (this.check([137, 80, 78, 71, 13, 10, 26, 10])) {
|
|
26362
|
-
|
|
26363
|
-
ext: "png",
|
|
26364
|
-
mime: "image/png"
|
|
26365
|
-
};
|
|
26366
|
-
const apngFileType = {
|
|
26367
|
-
ext: "apng",
|
|
26368
|
-
mime: "image/apng"
|
|
26369
|
-
};
|
|
26370
|
-
await tokenizer.ignore(8);
|
|
26371
|
-
async function readChunkHeader() {
|
|
26372
|
-
return {
|
|
26373
|
-
length: await tokenizer.readToken(INT32_BE),
|
|
26374
|
-
type: await tokenizer.readToken(new StringType2(4, "latin1"))
|
|
26375
|
-
};
|
|
26376
|
-
}
|
|
26377
|
-
const isUnknownPngStream = hasUnknownFileSize(tokenizer);
|
|
26378
|
-
const pngScanStart = tokenizer.position;
|
|
26379
|
-
let pngChunkCount = 0;
|
|
26380
|
-
let hasSeenImageHeader = false;
|
|
26381
|
-
do {
|
|
26382
|
-
pngChunkCount++;
|
|
26383
|
-
if (pngChunkCount > maximumPngChunkCount) {
|
|
26384
|
-
break;
|
|
26385
|
-
}
|
|
26386
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngStreamScanBudgetInBytes)) {
|
|
26387
|
-
break;
|
|
26388
|
-
}
|
|
26389
|
-
const previousPosition = tokenizer.position;
|
|
26390
|
-
const chunk = await readChunkHeader();
|
|
26391
|
-
if (chunk.length < 0) {
|
|
26392
|
-
return;
|
|
26393
|
-
}
|
|
26394
|
-
if (chunk.type === "IHDR") {
|
|
26395
|
-
if (chunk.length !== 13) {
|
|
26396
|
-
return;
|
|
26397
|
-
}
|
|
26398
|
-
hasSeenImageHeader = true;
|
|
26399
|
-
}
|
|
26400
|
-
switch (chunk.type) {
|
|
26401
|
-
case "IDAT":
|
|
26402
|
-
return pngFileType;
|
|
26403
|
-
case "acTL":
|
|
26404
|
-
return apngFileType;
|
|
26405
|
-
default:
|
|
26406
|
-
if (!hasSeenImageHeader && chunk.type !== "CgBI") {
|
|
26407
|
-
return;
|
|
26408
|
-
}
|
|
26409
|
-
if (isUnknownPngStream && chunk.length > maximumPngChunkSizeInBytes) {
|
|
26410
|
-
return hasSeenImageHeader && isPngAncillaryChunk(chunk.type) ? pngFileType : undefined;
|
|
26411
|
-
}
|
|
26412
|
-
try {
|
|
26413
|
-
await safeIgnore(tokenizer, chunk.length + 4, {
|
|
26414
|
-
maximumLength: isUnknownPngStream ? maximumPngChunkSizeInBytes + 4 : tokenizer.fileInfo.size,
|
|
26415
|
-
reason: "PNG chunk payload"
|
|
26416
|
-
});
|
|
26417
|
-
} catch (error) {
|
|
26418
|
-
if (!isUnknownPngStream && (error instanceof ParserHardLimitError || error instanceof EndOfStreamError)) {
|
|
26419
|
-
return pngFileType;
|
|
26420
|
-
}
|
|
26421
|
-
throw error;
|
|
26422
|
-
}
|
|
26423
|
-
}
|
|
26424
|
-
if (tokenizer.position <= previousPosition) {
|
|
26425
|
-
break;
|
|
26426
|
-
}
|
|
26427
|
-
} while (tokenizer.position + 8 < tokenizer.fileInfo.size);
|
|
26428
|
-
return pngFileType;
|
|
26696
|
+
return detectPng(tokenizer);
|
|
26429
26697
|
}
|
|
26430
26698
|
if (this.check([65, 82, 82, 79, 87, 49, 0, 0])) {
|
|
26431
26699
|
return {
|
|
@@ -26544,90 +26812,7 @@ class FileTypeParser {
|
|
|
26544
26812
|
};
|
|
26545
26813
|
}
|
|
26546
26814
|
if (this.check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) {
|
|
26547
|
-
|
|
26548
|
-
try {
|
|
26549
|
-
async function readHeader() {
|
|
26550
|
-
const guid = new Uint8Array(16);
|
|
26551
|
-
await safeReadBuffer(tokenizer, guid, undefined, {
|
|
26552
|
-
maximumLength: guid.length,
|
|
26553
|
-
reason: "ASF header GUID"
|
|
26554
|
-
});
|
|
26555
|
-
return {
|
|
26556
|
-
id: guid,
|
|
26557
|
-
size: Number(await tokenizer.readToken(UINT64_LE))
|
|
26558
|
-
};
|
|
26559
|
-
}
|
|
26560
|
-
await safeIgnore(tokenizer, 30, {
|
|
26561
|
-
maximumLength: 30,
|
|
26562
|
-
reason: "ASF header prelude"
|
|
26563
|
-
});
|
|
26564
|
-
const isUnknownFileSize = hasUnknownFileSize(tokenizer);
|
|
26565
|
-
const asfHeaderScanStart = tokenizer.position;
|
|
26566
|
-
let asfHeaderObjectCount = 0;
|
|
26567
|
-
while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
|
|
26568
|
-
asfHeaderObjectCount++;
|
|
26569
|
-
if (asfHeaderObjectCount > maximumAsfHeaderObjectCount) {
|
|
26570
|
-
break;
|
|
26571
|
-
}
|
|
26572
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, asfHeaderScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
26573
|
-
break;
|
|
26574
|
-
}
|
|
26575
|
-
const previousPosition = tokenizer.position;
|
|
26576
|
-
const header = await readHeader();
|
|
26577
|
-
let payload = header.size - 24;
|
|
26578
|
-
if (!Number.isFinite(payload) || payload < 0) {
|
|
26579
|
-
isMalformedAsf = true;
|
|
26580
|
-
break;
|
|
26581
|
-
}
|
|
26582
|
-
if (_check(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
26583
|
-
const typeId = new Uint8Array(16);
|
|
26584
|
-
payload -= await safeReadBuffer(tokenizer, typeId, undefined, {
|
|
26585
|
-
maximumLength: typeId.length,
|
|
26586
|
-
reason: "ASF stream type GUID"
|
|
26587
|
-
});
|
|
26588
|
-
if (_check(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
26589
|
-
return {
|
|
26590
|
-
ext: "asf",
|
|
26591
|
-
mime: "audio/x-ms-asf"
|
|
26592
|
-
};
|
|
26593
|
-
}
|
|
26594
|
-
if (_check(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
26595
|
-
return {
|
|
26596
|
-
ext: "asf",
|
|
26597
|
-
mime: "video/x-ms-asf"
|
|
26598
|
-
};
|
|
26599
|
-
}
|
|
26600
|
-
break;
|
|
26601
|
-
}
|
|
26602
|
-
if (isUnknownFileSize && payload > maximumAsfHeaderPayloadSizeInBytes) {
|
|
26603
|
-
isMalformedAsf = true;
|
|
26604
|
-
break;
|
|
26605
|
-
}
|
|
26606
|
-
await safeIgnore(tokenizer, payload, {
|
|
26607
|
-
maximumLength: isUnknownFileSize ? maximumAsfHeaderPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
26608
|
-
reason: "ASF header payload"
|
|
26609
|
-
});
|
|
26610
|
-
if (tokenizer.position <= previousPosition) {
|
|
26611
|
-
isMalformedAsf = true;
|
|
26612
|
-
break;
|
|
26613
|
-
}
|
|
26614
|
-
}
|
|
26615
|
-
} catch (error) {
|
|
26616
|
-
if (error instanceof EndOfStreamError || error instanceof ParserHardLimitError) {
|
|
26617
|
-
if (hasUnknownFileSize(tokenizer)) {
|
|
26618
|
-
isMalformedAsf = true;
|
|
26619
|
-
}
|
|
26620
|
-
} else {
|
|
26621
|
-
throw error;
|
|
26622
|
-
}
|
|
26623
|
-
}
|
|
26624
|
-
if (isMalformedAsf) {
|
|
26625
|
-
return;
|
|
26626
|
-
}
|
|
26627
|
-
return {
|
|
26628
|
-
ext: "asf",
|
|
26629
|
-
mime: "application/vnd.ms-asf"
|
|
26630
|
-
};
|
|
26815
|
+
return detectAsf(tokenizer);
|
|
26631
26816
|
}
|
|
26632
26817
|
if (this.check([171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10])) {
|
|
26633
26818
|
return {
|
|
@@ -26802,19 +26987,19 @@ class FileTypeParser {
|
|
|
26802
26987
|
if (this.check([76, 0, 0, 0, 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70])) {
|
|
26803
26988
|
return {
|
|
26804
26989
|
ext: "lnk",
|
|
26805
|
-
mime: "application/x
|
|
26990
|
+
mime: "application/x-ms-shortcut"
|
|
26806
26991
|
};
|
|
26807
26992
|
}
|
|
26808
26993
|
if (this.check([98, 111, 111, 107, 0, 0, 0, 0, 109, 97, 114, 107, 0, 0, 0, 0])) {
|
|
26809
26994
|
return {
|
|
26810
26995
|
ext: "alias",
|
|
26811
|
-
mime: "application/x
|
|
26996
|
+
mime: "application/x-ft-apple.alias"
|
|
26812
26997
|
};
|
|
26813
26998
|
}
|
|
26814
26999
|
if (this.checkString("Kaydara FBX Binary \0")) {
|
|
26815
27000
|
return {
|
|
26816
27001
|
ext: "fbx",
|
|
26817
|
-
mime: "application/x
|
|
27002
|
+
mime: "application/x-ft-fbx"
|
|
26818
27003
|
};
|
|
26819
27004
|
}
|
|
26820
27005
|
if (this.check([76, 80], { offset: 34 }) && (this.check([0, 0, 1], { offset: 8 }) || this.check([1, 0, 2], { offset: 8 }) || this.check([2, 0, 2], { offset: 8 }))) {
|
|
@@ -27032,234 +27217,28 @@ class FileTypeParser {
|
|
|
27032
27217
|
}
|
|
27033
27218
|
}
|
|
27034
27219
|
}
|
|
27035
|
-
var reasonableDetectionSizeInBytes = 4100, maximumMpegOffsetTolerance,
|
|
27036
|
-
var
|
|
27037
|
-
|
|
27220
|
+
var reasonableDetectionSizeInBytes = 4100, maximumMpegOffsetTolerance, maximumNestedGzipDetectionSizeInBytes, maximumNestedGzipProbeDepth = 1, unknownSizeGzipProbeTimeoutInMilliseconds = 100, maximumId3HeaderSizeInBytes, maximumTiffTagCount = 512, maximumDetectionReentryCount = 256, maximumTiffStreamIfdOffsetInBytes, maximumTiffIfdOffsetInBytes, supportedExtensions, supportedMimeTypes;
|
|
27221
|
+
var init_source = __esm(() => {
|
|
27222
|
+
init_lib2();
|
|
27038
27223
|
init_core();
|
|
27039
|
-
|
|
27224
|
+
init_lib3();
|
|
27040
27225
|
init_uint8array_extras();
|
|
27041
|
-
|
|
27226
|
+
init_tokens();
|
|
27042
27227
|
init_supported();
|
|
27228
|
+
init_parser();
|
|
27229
|
+
init_zip();
|
|
27230
|
+
init_ebml();
|
|
27231
|
+
init_png();
|
|
27232
|
+
init_asf();
|
|
27043
27233
|
maximumMpegOffsetTolerance = reasonableDetectionSizeInBytes - 2;
|
|
27044
|
-
maximumZipEntrySizeInBytes = 1024 * 1024;
|
|
27045
|
-
maximumZipBufferedReadSizeInBytes = 2 ** 31 - 1;
|
|
27046
|
-
maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
|
|
27047
|
-
maximumUnknownSizePayloadProbeSizeInBytes = maximumZipEntrySizeInBytes;
|
|
27048
|
-
maximumZipTextEntrySizeInBytes = maximumZipEntrySizeInBytes;
|
|
27049
27234
|
maximumNestedGzipDetectionSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
27050
27235
|
maximumId3HeaderSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
27051
|
-
|
|
27052
|
-
maximumPngStreamScanBudgetInBytes = maximumUntrustedSkipSizeInBytes;
|
|
27053
|
-
maximumPngChunkSizeInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
27054
|
-
maximumAsfHeaderPayloadSizeInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
27055
|
-
maximumTiffStreamIfdOffsetInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
27236
|
+
maximumTiffStreamIfdOffsetInBytes = 1024 * 1024;
|
|
27056
27237
|
maximumTiffIfdOffsetInBytes = maximumUntrustedSkipSizeInBytes;
|
|
27057
|
-
recoverableZipErrorMessages = new Set([
|
|
27058
|
-
"Unexpected signature",
|
|
27059
|
-
"Encrypted ZIP",
|
|
27060
|
-
"Expected Central-File-Header signature"
|
|
27061
|
-
]);
|
|
27062
|
-
recoverableZipErrorMessagePrefixes = [
|
|
27063
|
-
"ZIP entry count exceeds ",
|
|
27064
|
-
"Unsupported ZIP compression method:",
|
|
27065
|
-
"ZIP entry compressed data exceeds ",
|
|
27066
|
-
"ZIP entry decompressed data exceeds ",
|
|
27067
|
-
"Expected data-descriptor-signature at position "
|
|
27068
|
-
];
|
|
27069
|
-
recoverableZipErrorCodes = new Set([
|
|
27070
|
-
"Z_BUF_ERROR",
|
|
27071
|
-
"Z_DATA_ERROR",
|
|
27072
|
-
"ERR_INVALID_STATE"
|
|
27073
|
-
]);
|
|
27074
|
-
ParserHardLimitError = class ParserHardLimitError extends Error {
|
|
27075
|
-
};
|
|
27076
|
-
zipDataDescriptorOverlapLengthInBytes = zipDataDescriptorLengthInBytes - 1;
|
|
27077
|
-
ZipHandler.prototype.inflate = async function(zipHeader, fileData, callback) {
|
|
27078
|
-
if (zipHeader.compressedMethod === 0) {
|
|
27079
|
-
return callback(fileData);
|
|
27080
|
-
}
|
|
27081
|
-
if (zipHeader.compressedMethod !== 8) {
|
|
27082
|
-
throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
|
|
27083
|
-
}
|
|
27084
|
-
const uncompressedData = await decompressDeflateRawWithLimit(fileData, { maximumLength: maximumZipEntrySizeInBytes });
|
|
27085
|
-
return callback(uncompressedData);
|
|
27086
|
-
};
|
|
27087
|
-
ZipHandler.prototype.unzip = async function(fileCallback) {
|
|
27088
|
-
let stop = false;
|
|
27089
|
-
let zipEntryCount = 0;
|
|
27090
|
-
const zipScanStart = this.tokenizer.position;
|
|
27091
|
-
this.knownSizeDescriptorScannedBytes = 0;
|
|
27092
|
-
do {
|
|
27093
|
-
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
27094
|
-
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
27095
|
-
}
|
|
27096
|
-
const zipHeader = await this.readLocalFileHeader();
|
|
27097
|
-
if (!zipHeader) {
|
|
27098
|
-
break;
|
|
27099
|
-
}
|
|
27100
|
-
zipEntryCount++;
|
|
27101
|
-
if (zipEntryCount > maximumZipEntryCount) {
|
|
27102
|
-
throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
|
|
27103
|
-
}
|
|
27104
|
-
const next = fileCallback(zipHeader);
|
|
27105
|
-
stop = Boolean(next.stop);
|
|
27106
|
-
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
27107
|
-
const fileData = await readZipEntryData(this, zipHeader, {
|
|
27108
|
-
shouldBuffer: Boolean(next.handler),
|
|
27109
|
-
maximumDescriptorLength: Math.min(maximumZipEntrySizeInBytes, getRemainingZipScanBudget(this, zipScanStart))
|
|
27110
|
-
});
|
|
27111
|
-
if (next.handler) {
|
|
27112
|
-
await this.inflate(zipHeader, fileData, next.handler);
|
|
27113
|
-
}
|
|
27114
|
-
if (zipHeader.dataDescriptor) {
|
|
27115
|
-
const dataDescriptor = new Uint8Array(zipDataDescriptorLengthInBytes);
|
|
27116
|
-
await this.tokenizer.readBuffer(dataDescriptor);
|
|
27117
|
-
if (UINT32_LE.get(dataDescriptor, 0) !== zipDataDescriptorSignature) {
|
|
27118
|
-
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - dataDescriptor.length}`);
|
|
27119
|
-
}
|
|
27120
|
-
}
|
|
27121
|
-
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
27122
|
-
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
27123
|
-
}
|
|
27124
|
-
} while (!stop);
|
|
27125
|
-
};
|
|
27126
27238
|
supportedExtensions = new Set(extensions);
|
|
27127
27239
|
supportedMimeTypes = new Set(mimeTypes);
|
|
27128
27240
|
});
|
|
27129
27241
|
|
|
27130
|
-
// ../../node_modules/file-type/index.js
|
|
27131
|
-
var exports_file_type = {};
|
|
27132
|
-
__export(exports_file_type, {
|
|
27133
|
-
supportedMimeTypes: () => supportedMimeTypes,
|
|
27134
|
-
supportedExtensions: () => supportedExtensions,
|
|
27135
|
-
fileTypeStream: () => fileTypeStream,
|
|
27136
|
-
fileTypeFromTokenizer: () => fileTypeFromTokenizer,
|
|
27137
|
-
fileTypeFromStream: () => fileTypeFromStream,
|
|
27138
|
-
fileTypeFromFile: () => fileTypeFromFile,
|
|
27139
|
-
fileTypeFromBuffer: () => fileTypeFromBuffer,
|
|
27140
|
-
fileTypeFromBlob: () => fileTypeFromBlob,
|
|
27141
|
-
FileTypeParser: () => FileTypeParser2
|
|
27142
|
-
});
|
|
27143
|
-
import { ReadableStream as WebReadableStream } from "node:stream/web";
|
|
27144
|
-
import { pipeline, PassThrough, Readable } from "node:stream";
|
|
27145
|
-
import fs from "node:fs/promises";
|
|
27146
|
-
import { constants as fileSystemConstants } from "node:fs";
|
|
27147
|
-
function isTokenizerStreamBoundsError(error) {
|
|
27148
|
-
if (!(error instanceof RangeError) || error.message !== "offset is out of bounds" || typeof error.stack !== "string") {
|
|
27149
|
-
return false;
|
|
27150
|
-
}
|
|
27151
|
-
return /strtok3[/\\]lib[/\\]stream[/\\]/.test(error.stack);
|
|
27152
|
-
}
|
|
27153
|
-
async function fileTypeFromFile(path, options) {
|
|
27154
|
-
return new FileTypeParser2(options).fromFile(path, options);
|
|
27155
|
-
}
|
|
27156
|
-
async function fileTypeFromStream(stream, options) {
|
|
27157
|
-
return new FileTypeParser2(options).fromStream(stream);
|
|
27158
|
-
}
|
|
27159
|
-
async function fileTypeStream(readableStream, options = {}) {
|
|
27160
|
-
return new FileTypeParser2(options).toDetectionStream(readableStream, options);
|
|
27161
|
-
}
|
|
27162
|
-
var FileTypeParser2;
|
|
27163
|
-
var init_file_type = __esm(() => {
|
|
27164
|
-
init_lib();
|
|
27165
|
-
init_core2();
|
|
27166
|
-
init_core2();
|
|
27167
|
-
FileTypeParser2 = class FileTypeParser2 extends FileTypeParser {
|
|
27168
|
-
async fromStream(stream) {
|
|
27169
|
-
this.options.signal?.throwIfAborted();
|
|
27170
|
-
const tokenizer = await (stream instanceof WebReadableStream ? this.createTokenizerFromWebStream(stream) : fromStream2(stream, this.getTokenizerOptions()));
|
|
27171
|
-
try {
|
|
27172
|
-
return await super.fromTokenizer(tokenizer);
|
|
27173
|
-
} catch (error) {
|
|
27174
|
-
if (isTokenizerStreamBoundsError(error)) {
|
|
27175
|
-
return;
|
|
27176
|
-
}
|
|
27177
|
-
throw error;
|
|
27178
|
-
} finally {
|
|
27179
|
-
if (stream instanceof Readable && !stream.destroyed) {
|
|
27180
|
-
stream.destroy();
|
|
27181
|
-
}
|
|
27182
|
-
}
|
|
27183
|
-
}
|
|
27184
|
-
async fromFile(path) {
|
|
27185
|
-
this.options.signal?.throwIfAborted();
|
|
27186
|
-
const fileHandle = await fs.open(path, fileSystemConstants.O_RDONLY | fileSystemConstants.O_NONBLOCK);
|
|
27187
|
-
const fileStat = await fileHandle.stat();
|
|
27188
|
-
if (!fileStat.isFile()) {
|
|
27189
|
-
await fileHandle.close();
|
|
27190
|
-
return;
|
|
27191
|
-
}
|
|
27192
|
-
const tokenizer = new FileTokenizer(fileHandle, {
|
|
27193
|
-
...this.getTokenizerOptions(),
|
|
27194
|
-
fileInfo: {
|
|
27195
|
-
path,
|
|
27196
|
-
size: fileStat.size
|
|
27197
|
-
}
|
|
27198
|
-
});
|
|
27199
|
-
return super.fromTokenizer(tokenizer);
|
|
27200
|
-
}
|
|
27201
|
-
async toDetectionStream(readableStream, options = {}) {
|
|
27202
|
-
if (!(readableStream instanceof Readable)) {
|
|
27203
|
-
return super.toDetectionStream(readableStream, options);
|
|
27204
|
-
}
|
|
27205
|
-
const { sampleSize = reasonableDetectionSizeInBytes } = options;
|
|
27206
|
-
const { signal } = this.options;
|
|
27207
|
-
const normalizedSampleSize = normalizeSampleSize(sampleSize);
|
|
27208
|
-
signal?.throwIfAborted();
|
|
27209
|
-
return new Promise((resolve3, reject) => {
|
|
27210
|
-
let isSettled = false;
|
|
27211
|
-
const cleanup = () => {
|
|
27212
|
-
readableStream.off("error", onError);
|
|
27213
|
-
readableStream.off("readable", onReadable);
|
|
27214
|
-
signal?.removeEventListener("abort", onAbort);
|
|
27215
|
-
};
|
|
27216
|
-
const settle = (callback, value) => {
|
|
27217
|
-
if (isSettled) {
|
|
27218
|
-
return;
|
|
27219
|
-
}
|
|
27220
|
-
isSettled = true;
|
|
27221
|
-
cleanup();
|
|
27222
|
-
callback(value);
|
|
27223
|
-
};
|
|
27224
|
-
const onError = (error) => {
|
|
27225
|
-
settle(reject, error);
|
|
27226
|
-
};
|
|
27227
|
-
const onAbort = () => {
|
|
27228
|
-
if (!readableStream.destroyed) {
|
|
27229
|
-
readableStream.destroy();
|
|
27230
|
-
}
|
|
27231
|
-
settle(reject, signal.reason);
|
|
27232
|
-
};
|
|
27233
|
-
const onReadable = () => {
|
|
27234
|
-
(async () => {
|
|
27235
|
-
try {
|
|
27236
|
-
const pass = new PassThrough;
|
|
27237
|
-
const outputStream = pipeline ? pipeline(readableStream, pass, () => {
|
|
27238
|
-
}) : readableStream.pipe(pass);
|
|
27239
|
-
const chunk = readableStream.read(normalizedSampleSize) ?? readableStream.read() ?? new Uint8Array(0);
|
|
27240
|
-
try {
|
|
27241
|
-
pass.fileType = await this.fromBuffer(chunk);
|
|
27242
|
-
} catch (error) {
|
|
27243
|
-
if (error instanceof EndOfStreamError) {
|
|
27244
|
-
pass.fileType = undefined;
|
|
27245
|
-
} else {
|
|
27246
|
-
settle(reject, error);
|
|
27247
|
-
}
|
|
27248
|
-
}
|
|
27249
|
-
settle(resolve3, outputStream);
|
|
27250
|
-
} catch (error) {
|
|
27251
|
-
settle(reject, error);
|
|
27252
|
-
}
|
|
27253
|
-
})();
|
|
27254
|
-
};
|
|
27255
|
-
readableStream.on("error", onError);
|
|
27256
|
-
readableStream.once("readable", onReadable);
|
|
27257
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
27258
|
-
});
|
|
27259
|
-
}
|
|
27260
|
-
};
|
|
27261
|
-
});
|
|
27262
|
-
|
|
27263
27242
|
// ../../node_modules/cookie/dist/index.js
|
|
27264
27243
|
var require_dist3 = __commonJS((exports) => {
|
|
27265
27244
|
function parseCookie(str, options) {
|
|
@@ -27511,7 +27490,7 @@ var import_chokidar = __toESM(require_chokidar(), 1);
|
|
|
27511
27490
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
27512
27491
|
import { spawn, spawnSync } from "node:child_process";
|
|
27513
27492
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
27514
|
-
import * as
|
|
27493
|
+
import * as fs from "node:fs/promises";
|
|
27515
27494
|
import path from "node:path";
|
|
27516
27495
|
import { TextDecoder as TextDecoder2 } from "node:util";
|
|
27517
27496
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -37016,7 +36995,7 @@ var _fileTypeFromBlobWarn = false;
|
|
|
37016
36995
|
var warnIfFileTypeIsNotInstalled = () => {
|
|
37017
36996
|
_fileTypeFromBlobWarn || (console.warn("[Elysia] Attempt to validate file type without 'file-type'. This may lead to security risks. We recommend installing 'file-type' to properly validate file extension."), _fileTypeFromBlobWarn = true);
|
|
37018
36997
|
};
|
|
37019
|
-
var loadFileType = async () => Promise.resolve().then(() => (
|
|
36998
|
+
var loadFileType = async () => Promise.resolve().then(() => (init_source(), exports_source)).then((x) => (_fileTypeFromBlob = x.fileTypeFromBlob, _fileTypeFromBlob)).catch(warnIfFileTypeIsNotInstalled);
|
|
37020
36999
|
var _fileTypeFromBlob;
|
|
37021
37000
|
var fileTypeFromBlob2 = (file) => _fileTypeFromBlob ? _fileTypeFromBlob(file) : loadFileType().then((mod) => {
|
|
37022
37001
|
if (mod)
|
|
@@ -44294,7 +44273,7 @@ async function handleBuild(options) {
|
|
|
44294
44273
|
const entryPath = path.resolve(manifestInfo.manifestDir, contract.entry);
|
|
44295
44274
|
const outFilePath = path.resolve(manifestInfo.manifestDir, contract.outFile);
|
|
44296
44275
|
await ensureEntryExists(entryPath, contract.name);
|
|
44297
|
-
await
|
|
44276
|
+
await fs.mkdir(path.dirname(outFilePath), { recursive: true });
|
|
44298
44277
|
const relEntry = path.relative(process.cwd(), entryPath) || entryPath;
|
|
44299
44278
|
const relOutFile = path.relative(process.cwd(), outFilePath) || outFilePath;
|
|
44300
44279
|
console.log(`- bundling ${contract.name} (${relEntry})`);
|
|
@@ -44312,7 +44291,7 @@ async function handleBuild(options) {
|
|
|
44312
44291
|
async function handlePublish(options) {
|
|
44313
44292
|
const scriptPath = path.resolve(process.cwd(), options.script);
|
|
44314
44293
|
await ensureFileExists(scriptPath, "script");
|
|
44315
|
-
const script = await
|
|
44294
|
+
const script = await fs.readFile(scriptPath, "utf8");
|
|
44316
44295
|
const msg = options.msg ? await loadMsgPayload(options.msg) : undefined;
|
|
44317
44296
|
const baseUrl = resolveDoneHttpBase(options.http);
|
|
44318
44297
|
const backend = new DoneBackendClient({ baseUrl });
|
|
@@ -44336,7 +44315,7 @@ async function detectWorkspace(root) {
|
|
|
44336
44315
|
if (!existsSync2(configPath)) {
|
|
44337
44316
|
return null;
|
|
44338
44317
|
}
|
|
44339
|
-
const configRaw = await
|
|
44318
|
+
const configRaw = await fs.readFile(configPath, "utf8");
|
|
44340
44319
|
const config2 = JSON.parse(configRaw);
|
|
44341
44320
|
const configuredManifestPath = config2.contractsFile ? path.isAbsolute(config2.contractsFile) ? config2.contractsFile : path.resolve(root, config2.contractsFile) : path.join(root, "done.json");
|
|
44342
44321
|
const fallbackManifestPath = path.join(root, "done.json");
|
|
@@ -44344,7 +44323,7 @@ async function detectWorkspace(root) {
|
|
|
44344
44323
|
if (!manifestPath) {
|
|
44345
44324
|
return null;
|
|
44346
44325
|
}
|
|
44347
|
-
const manifestRaw = await
|
|
44326
|
+
const manifestRaw = await fs.readFile(manifestPath, "utf8");
|
|
44348
44327
|
const manifest = JSON.parse(manifestRaw);
|
|
44349
44328
|
return { root, manifestPath, configPath, manifest, config: config2 };
|
|
44350
44329
|
}
|
|
@@ -44377,7 +44356,7 @@ async function findWorkspace(startDir) {
|
|
|
44377
44356
|
async function readManifest(manifestPath) {
|
|
44378
44357
|
let raw;
|
|
44379
44358
|
try {
|
|
44380
|
-
raw = await
|
|
44359
|
+
raw = await fs.readFile(manifestPath, "utf8");
|
|
44381
44360
|
} catch (error) {
|
|
44382
44361
|
if (error.code === "ENOENT") {
|
|
44383
44362
|
throw new Error(`Could not find ${manifestPath}. Pass a valid --contracts path or run from a Done workspace.`);
|
|
@@ -44401,7 +44380,7 @@ async function scaffoldWorkspace(rawName, options) {
|
|
|
44401
44380
|
await prepareTargetDir(targetDir, options.force === true);
|
|
44402
44381
|
const localTemplatePath = await resolveLocalTemplate(templateRef);
|
|
44403
44382
|
if (localTemplatePath) {
|
|
44404
|
-
await
|
|
44383
|
+
await fs.cp(localTemplatePath, targetDir, { recursive: true });
|
|
44405
44384
|
} else {
|
|
44406
44385
|
await runCommand("git", ["clone", "--depth", "1", templateRef, targetDir]);
|
|
44407
44386
|
}
|
|
@@ -44433,7 +44412,7 @@ async function scaffoldContract(workspace, rawName, options) {
|
|
|
44433
44412
|
const contractsDir = resolveContractsDir(workspace.root, workspace.config.contractsDir);
|
|
44434
44413
|
const contractDir = path.join(contractsDir, slug);
|
|
44435
44414
|
await ensureDirAvailable(contractDir, options.force === true);
|
|
44436
|
-
await
|
|
44415
|
+
await fs.mkdir(path.join(contractDir, "src"), { recursive: true });
|
|
44437
44416
|
const pkgJsonPath = path.join(contractDir, "package.json");
|
|
44438
44417
|
const pkgJson = {
|
|
44439
44418
|
name: slug,
|
|
@@ -44506,7 +44485,7 @@ export default Done.serve()
|
|
|
44506
44485
|
},
|
|
44507
44486
|
);
|
|
44508
44487
|
`;
|
|
44509
|
-
await
|
|
44488
|
+
await fs.writeFile(path.join(contractDir, "src", "index.ts"), contractSource, "utf8");
|
|
44510
44489
|
workspace.manifest.contracts ??= [];
|
|
44511
44490
|
const contractDirRel = normalizeJsonPath(path.relative(workspace.root, contractDir));
|
|
44512
44491
|
const entry = ensureDotSlash(`${contractDirRel}/src/index.ts`);
|
|
@@ -44537,7 +44516,7 @@ export default Done.serve()
|
|
|
44537
44516
|
async function resolveLocalTemplate(reference) {
|
|
44538
44517
|
const potentialPath = path.isAbsolute(reference) ? reference : path.resolve(process.cwd(), reference);
|
|
44539
44518
|
try {
|
|
44540
|
-
const stats = await
|
|
44519
|
+
const stats = await fs.stat(potentialPath);
|
|
44541
44520
|
if (stats.isDirectory()) {
|
|
44542
44521
|
return potentialPath;
|
|
44543
44522
|
}
|
|
@@ -44552,7 +44531,7 @@ async function prepareTargetDir(targetDir, force) {
|
|
|
44552
44531
|
if (!force) {
|
|
44553
44532
|
throw new Error(`Directory '${path.relative(process.cwd(), targetDir) || targetDir}' already exists. Use --force to overwrite.`);
|
|
44554
44533
|
}
|
|
44555
|
-
await
|
|
44534
|
+
await fs.rm(targetDir, { recursive: true, force: true });
|
|
44556
44535
|
}
|
|
44557
44536
|
async function ensureDirAvailable(targetDir, force) {
|
|
44558
44537
|
if (!existsSync2(targetDir)) {
|
|
@@ -44561,10 +44540,10 @@ async function ensureDirAvailable(targetDir, force) {
|
|
|
44561
44540
|
if (!force) {
|
|
44562
44541
|
throw new Error(`Directory '${path.relative(process.cwd(), targetDir) || targetDir}' already exists. Use --force to overwrite.`);
|
|
44563
44542
|
}
|
|
44564
|
-
await
|
|
44543
|
+
await fs.rm(targetDir, { recursive: true, force: true });
|
|
44565
44544
|
}
|
|
44566
44545
|
async function removeGitFolder(targetDir) {
|
|
44567
|
-
await
|
|
44546
|
+
await fs.rm(path.join(targetDir, ".git"), { recursive: true, force: true });
|
|
44568
44547
|
}
|
|
44569
44548
|
function resolveContractsDir(root, configured) {
|
|
44570
44549
|
if (!configured) {
|
|
@@ -44577,7 +44556,7 @@ function resolveContractsDir(root, configured) {
|
|
|
44577
44556
|
}
|
|
44578
44557
|
async function updatePackageJson(file2, mutator) {
|
|
44579
44558
|
try {
|
|
44580
|
-
const current = JSON.parse(await
|
|
44559
|
+
const current = JSON.parse(await fs.readFile(file2, "utf8"));
|
|
44581
44560
|
mutator(current);
|
|
44582
44561
|
await writeJson(file2, current);
|
|
44583
44562
|
} catch (error) {
|
|
@@ -44625,7 +44604,7 @@ async function syncWorkspaceDependencyVersions(targetDir) {
|
|
|
44625
44604
|
async function updateContractDependencyVersions(contractsDir) {
|
|
44626
44605
|
let entries;
|
|
44627
44606
|
try {
|
|
44628
|
-
entries = await
|
|
44607
|
+
entries = await fs.readdir(contractsDir, { withFileTypes: true });
|
|
44629
44608
|
} catch {
|
|
44630
44609
|
return;
|
|
44631
44610
|
}
|
|
@@ -44678,7 +44657,7 @@ function escapeRegExp(value) {
|
|
|
44678
44657
|
}
|
|
44679
44658
|
async function ensureEntryExists(entryPath, contractName) {
|
|
44680
44659
|
try {
|
|
44681
|
-
const stats = await
|
|
44660
|
+
const stats = await fs.stat(entryPath);
|
|
44682
44661
|
if (!stats.isFile()) {
|
|
44683
44662
|
const relPath = path.relative(process.cwd(), entryPath) || entryPath;
|
|
44684
44663
|
throw new Error(`Entry path for contract '${contractName}' is not a file (${relPath})`);
|
|
@@ -44693,7 +44672,7 @@ async function ensureEntryExists(entryPath, contractName) {
|
|
|
44693
44672
|
}
|
|
44694
44673
|
async function ensureFileExists(filePath, label) {
|
|
44695
44674
|
try {
|
|
44696
|
-
const stats = await
|
|
44675
|
+
const stats = await fs.stat(filePath);
|
|
44697
44676
|
if (!stats.isFile()) {
|
|
44698
44677
|
throw new Error(`The ${label} path is not a file (${filePath})`);
|
|
44699
44678
|
}
|
|
@@ -44707,7 +44686,7 @@ async function ensureFileExists(filePath, label) {
|
|
|
44707
44686
|
async function loadMsgPayload(input) {
|
|
44708
44687
|
const potentialPath = path.resolve(process.cwd(), input);
|
|
44709
44688
|
if (await pathExists(potentialPath)) {
|
|
44710
|
-
const raw = await
|
|
44689
|
+
const raw = await fs.readFile(potentialPath, "utf8");
|
|
44711
44690
|
return JSON.parse(raw);
|
|
44712
44691
|
}
|
|
44713
44692
|
return JSON.parse(input);
|
|
@@ -44717,7 +44696,7 @@ function resolveDoneHttpBase(override) {
|
|
|
44717
44696
|
}
|
|
44718
44697
|
async function pathExists(candidate) {
|
|
44719
44698
|
try {
|
|
44720
|
-
await
|
|
44699
|
+
await fs.access(candidate);
|
|
44721
44700
|
return true;
|
|
44722
44701
|
} catch {
|
|
44723
44702
|
return false;
|
|
@@ -44746,7 +44725,7 @@ async function runBunBuild(entryPath, outFilePath) {
|
|
|
44746
44725
|
throw new Error("Bun.build did not emit an output file");
|
|
44747
44726
|
}
|
|
44748
44727
|
const bundledSource = await output2.text();
|
|
44749
|
-
await
|
|
44728
|
+
await fs.writeFile(outFilePath, bundledSource);
|
|
44750
44729
|
return;
|
|
44751
44730
|
}
|
|
44752
44731
|
await runBunCliBuild(entryPath, outFilePath);
|
|
@@ -44807,7 +44786,7 @@ function toContractName(slug) {
|
|
|
44807
44786
|
}
|
|
44808
44787
|
async function writeJson(file2, data) {
|
|
44809
44788
|
const json = JSON.stringify(data, null, 2);
|
|
44810
|
-
await
|
|
44789
|
+
await fs.writeFile(file2, `${json}\n`, "utf8");
|
|
44811
44790
|
}
|
|
44812
44791
|
function describeStorageEntry(entry) {
|
|
44813
44792
|
const valueBase64 = entry.value ?? "";
|
|
@@ -44914,15 +44893,15 @@ function resolveDevConfig(workspace) {
|
|
|
44914
44893
|
};
|
|
44915
44894
|
}
|
|
44916
44895
|
async function writeDevEnvFile(file2, entries) {
|
|
44917
|
-
await
|
|
44896
|
+
await fs.mkdir(path.dirname(file2), { recursive: true });
|
|
44918
44897
|
const lines = ["# generated by done dev", `# ${new Date().toISOString()}`];
|
|
44919
44898
|
for (const key of Object.keys(entries).sort()) {
|
|
44920
44899
|
lines.push(`${key}=${entries[key]}`);
|
|
44921
44900
|
}
|
|
44922
|
-
await
|
|
44901
|
+
await fs.writeFile(file2, `${lines.join("\n")}\n`, "utf8");
|
|
44923
44902
|
}
|
|
44924
44903
|
async function readDevEnvFile(file2) {
|
|
44925
|
-
const data = await
|
|
44904
|
+
const data = await fs.readFile(file2, "utf8");
|
|
44926
44905
|
const entries = {};
|
|
44927
44906
|
for (const line of data.split(/\r?\n/)) {
|
|
44928
44907
|
if (!line || line.startsWith("#"))
|
|
@@ -44936,7 +44915,7 @@ async function readDevEnvFile(file2) {
|
|
|
44936
44915
|
}
|
|
44937
44916
|
async function readStorageSnapshot(file2) {
|
|
44938
44917
|
try {
|
|
44939
|
-
const raw = await
|
|
44918
|
+
const raw = await fs.readFile(file2, "utf8");
|
|
44940
44919
|
return JSON.parse(raw);
|
|
44941
44920
|
} catch (error) {
|
|
44942
44921
|
if (error.code === "ENOENT") {
|
|
@@ -45188,7 +45167,7 @@ class DoneDevOrchestrator {
|
|
|
45188
45167
|
}
|
|
45189
45168
|
async buildBundle(contract, initial, reason) {
|
|
45190
45169
|
await ensureEntryExists(contract.entryPath, contract.name);
|
|
45191
|
-
await
|
|
45170
|
+
await fs.mkdir(path.dirname(contract.outFilePath), { recursive: true });
|
|
45192
45171
|
const startedAt = Date.now();
|
|
45193
45172
|
const label = initial ? "Building" : "Rebuilding";
|
|
45194
45173
|
this.logInfo(`${label} ${contract.name}${reason ? ` (${reason})` : ""}`);
|
|
@@ -45272,7 +45251,7 @@ class DoneDevOrchestrator {
|
|
|
45272
45251
|
async publishContract(contract) {
|
|
45273
45252
|
if (!this.chain || !contract.address)
|
|
45274
45253
|
return;
|
|
45275
|
-
const script = await
|
|
45254
|
+
const script = await fs.readFile(contract.outFilePath, "utf8");
|
|
45276
45255
|
const execResult = this.chain.execute(contract.address, {
|
|
45277
45256
|
publish_code: {
|
|
45278
45257
|
script,
|
|
@@ -45308,7 +45287,7 @@ class DoneDevOrchestrator {
|
|
|
45308
45287
|
entries: entries.map(describeStorageEntry)
|
|
45309
45288
|
};
|
|
45310
45289
|
const storageDir = path.join(this.options.workspace.root, ".done", "storage");
|
|
45311
|
-
await
|
|
45290
|
+
await fs.mkdir(storageDir, { recursive: true });
|
|
45312
45291
|
const filePath = path.join(storageDir, `${contract.slug}.json`);
|
|
45313
45292
|
await writeJson(filePath, snapshot);
|
|
45314
45293
|
}
|