@donezone/cli 0.1.48 → 0.1.50
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 +1561 -1349
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
34
34
|
var path = __require("path");
|
|
35
35
|
var WIN_SLASH = "\\\\/";
|
|
36
36
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
37
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
37
38
|
var DOT_LITERAL = "\\.";
|
|
38
39
|
var PLUS_LITERAL = "\\+";
|
|
39
40
|
var QMARK_LITERAL = "\\?";
|
|
@@ -81,6 +82,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
81
82
|
END_ANCHOR: `(?:[${WIN_SLASH}]|\$)`
|
|
82
83
|
};
|
|
83
84
|
var POSIX_REGEX_SOURCE = {
|
|
85
|
+
__proto__: null,
|
|
84
86
|
alnum: "a-zA-Z0-9",
|
|
85
87
|
alpha: "a-zA-Z",
|
|
86
88
|
ascii: "\\x00-\\x7F",
|
|
@@ -97,6 +99,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
97
99
|
xdigit: "A-Fa-f0-9"
|
|
98
100
|
};
|
|
99
101
|
module.exports = {
|
|
102
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
100
103
|
MAX_LENGTH: 1024 * 64,
|
|
101
104
|
POSIX_REGEX_SOURCE,
|
|
102
105
|
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
@@ -106,6 +109,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
106
109
|
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
107
110
|
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
108
111
|
REPLACEMENTS: {
|
|
112
|
+
__proto__: null,
|
|
109
113
|
"***": "*",
|
|
110
114
|
"**/**": "**",
|
|
111
115
|
"**/**/**": "**"
|
|
@@ -571,6 +575,213 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
571
575
|
var syntaxError = (type, char) => {
|
|
572
576
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
573
577
|
};
|
|
578
|
+
var splitTopLevel = (input) => {
|
|
579
|
+
const parts = [];
|
|
580
|
+
let bracket = 0;
|
|
581
|
+
let paren = 0;
|
|
582
|
+
let quote = 0;
|
|
583
|
+
let value = "";
|
|
584
|
+
let escaped = false;
|
|
585
|
+
for (const ch of input) {
|
|
586
|
+
if (escaped === true) {
|
|
587
|
+
value += ch;
|
|
588
|
+
escaped = false;
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (ch === "\\") {
|
|
592
|
+
value += ch;
|
|
593
|
+
escaped = true;
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
if (ch === '"') {
|
|
597
|
+
quote = quote === 1 ? 0 : 1;
|
|
598
|
+
value += ch;
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (quote === 0) {
|
|
602
|
+
if (ch === "[") {
|
|
603
|
+
bracket++;
|
|
604
|
+
} else if (ch === "]" && bracket > 0) {
|
|
605
|
+
bracket--;
|
|
606
|
+
} else if (bracket === 0) {
|
|
607
|
+
if (ch === "(") {
|
|
608
|
+
paren++;
|
|
609
|
+
} else if (ch === ")" && paren > 0) {
|
|
610
|
+
paren--;
|
|
611
|
+
} else if (ch === "|" && paren === 0) {
|
|
612
|
+
parts.push(value);
|
|
613
|
+
value = "";
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
value += ch;
|
|
619
|
+
}
|
|
620
|
+
parts.push(value);
|
|
621
|
+
return parts;
|
|
622
|
+
};
|
|
623
|
+
var isPlainBranch = (branch) => {
|
|
624
|
+
let escaped = false;
|
|
625
|
+
for (const ch of branch) {
|
|
626
|
+
if (escaped === true) {
|
|
627
|
+
escaped = false;
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (ch === "\\") {
|
|
631
|
+
escaped = true;
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return true;
|
|
639
|
+
};
|
|
640
|
+
var normalizeSimpleBranch = (branch) => {
|
|
641
|
+
let value = branch.trim();
|
|
642
|
+
let changed = true;
|
|
643
|
+
while (changed === true) {
|
|
644
|
+
changed = false;
|
|
645
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
646
|
+
value = value.slice(2, -1);
|
|
647
|
+
changed = true;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (!isPlainBranch(value)) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
return value.replace(/\\(.)/g, "$1");
|
|
654
|
+
};
|
|
655
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
656
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
657
|
+
for (let i = 0;i < values.length; i++) {
|
|
658
|
+
for (let j = i + 1;j < values.length; j++) {
|
|
659
|
+
const a = values[i];
|
|
660
|
+
const b = values[j];
|
|
661
|
+
const char = a[0];
|
|
662
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return false;
|
|
671
|
+
};
|
|
672
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
673
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
let bracket = 0;
|
|
677
|
+
let paren = 0;
|
|
678
|
+
let quote = 0;
|
|
679
|
+
let escaped = false;
|
|
680
|
+
for (let i = 1;i < pattern.length; i++) {
|
|
681
|
+
const ch = pattern[i];
|
|
682
|
+
if (escaped === true) {
|
|
683
|
+
escaped = false;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (ch === "\\") {
|
|
687
|
+
escaped = true;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (ch === '"') {
|
|
691
|
+
quote = quote === 1 ? 0 : 1;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (quote === 1) {
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (ch === "[") {
|
|
698
|
+
bracket++;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (ch === "]" && bracket > 0) {
|
|
702
|
+
bracket--;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (bracket > 0) {
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (ch === "(") {
|
|
709
|
+
paren++;
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
if (ch === ")") {
|
|
713
|
+
paren--;
|
|
714
|
+
if (paren === 0) {
|
|
715
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
type: pattern[0],
|
|
720
|
+
body: pattern.slice(2, i),
|
|
721
|
+
end: i
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
728
|
+
let index = 0;
|
|
729
|
+
const chars = [];
|
|
730
|
+
while (index < pattern.length) {
|
|
731
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
732
|
+
if (!match || match.type !== "*") {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
736
|
+
if (branches.length !== 1) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
740
|
+
if (!branch || branch.length !== 1) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
chars.push(branch);
|
|
744
|
+
index += match.end + 1;
|
|
745
|
+
}
|
|
746
|
+
if (chars.length < 1) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
750
|
+
return `${source}*`;
|
|
751
|
+
};
|
|
752
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
753
|
+
let depth = 0;
|
|
754
|
+
let value = pattern.trim();
|
|
755
|
+
let match = parseRepeatedExtglob(value);
|
|
756
|
+
while (match) {
|
|
757
|
+
depth++;
|
|
758
|
+
value = match.body.trim();
|
|
759
|
+
match = parseRepeatedExtglob(value);
|
|
760
|
+
}
|
|
761
|
+
return depth;
|
|
762
|
+
};
|
|
763
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
764
|
+
if (options.maxExtglobRecursion === false) {
|
|
765
|
+
return { risky: false };
|
|
766
|
+
}
|
|
767
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
768
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
769
|
+
if (branches.length > 1) {
|
|
770
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
771
|
+
return { risky: true };
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
for (const branch of branches) {
|
|
775
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
776
|
+
if (safeOutput) {
|
|
777
|
+
return { risky: true, safeOutput };
|
|
778
|
+
}
|
|
779
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
780
|
+
return { risky: true };
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return { risky: false };
|
|
784
|
+
};
|
|
574
785
|
var parse = (input, options) => {
|
|
575
786
|
if (typeof input !== "string") {
|
|
576
787
|
throw new TypeError("Expected a string");
|
|
@@ -703,6 +914,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
703
914
|
token.prev = prev;
|
|
704
915
|
token.parens = state.parens;
|
|
705
916
|
token.output = state.output;
|
|
917
|
+
token.startIndex = state.index;
|
|
918
|
+
token.tokensIndex = tokens.length;
|
|
706
919
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
707
920
|
increment("parens");
|
|
708
921
|
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
@@ -710,6 +923,26 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
710
923
|
extglobs.push(token);
|
|
711
924
|
};
|
|
712
925
|
const extglobClose = (token) => {
|
|
926
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
927
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
928
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
929
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
930
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
931
|
+
const open = tokens[token.tokensIndex];
|
|
932
|
+
open.type = "text";
|
|
933
|
+
open.value = literal;
|
|
934
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
935
|
+
for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
|
|
936
|
+
tokens[i].value = "";
|
|
937
|
+
tokens[i].output = "";
|
|
938
|
+
delete tokens[i].suffix;
|
|
939
|
+
}
|
|
940
|
+
state.output = token.output + open.output;
|
|
941
|
+
state.backtrack = true;
|
|
942
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
943
|
+
decrement("parens");
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
713
946
|
let output = token.close + (opts.capture ? ")" : "");
|
|
714
947
|
let rest;
|
|
715
948
|
if (token.type === "negate") {
|
|
@@ -22345,6 +22578,338 @@ var require_fast_decode_uri_component = __commonJS((exports, module) => {
|
|
|
22345
22578
|
module.exports = decodeURIComponent2;
|
|
22346
22579
|
});
|
|
22347
22580
|
|
|
22581
|
+
// ../../node_modules/ieee754/index.js
|
|
22582
|
+
var init_ieee754 = __esm(() => {
|
|
22583
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
22584
|
+
});
|
|
22585
|
+
|
|
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`);
|
|
22611
|
+
}
|
|
22612
|
+
}
|
|
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;
|
|
22628
|
+
}
|
|
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;
|
|
22639
|
+
}
|
|
22640
|
+
while (i < bytes2.length) {
|
|
22641
|
+
const b1 = bytes2[i];
|
|
22642
|
+
if (b1 <= 127) {
|
|
22643
|
+
pushCodeUnit(parts, chunk, b1);
|
|
22644
|
+
i++;
|
|
22645
|
+
continue;
|
|
22646
|
+
}
|
|
22647
|
+
if (b1 < 194 || b1 > 244) {
|
|
22648
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22649
|
+
i++;
|
|
22650
|
+
continue;
|
|
22651
|
+
}
|
|
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;
|
|
22663
|
+
}
|
|
22664
|
+
const cp2 = (b1 & 31) << 6 | b22 & 63;
|
|
22665
|
+
pushCodeUnit(parts, chunk, cp2);
|
|
22666
|
+
i += 2;
|
|
22667
|
+
continue;
|
|
22668
|
+
}
|
|
22669
|
+
if (b1 <= 239) {
|
|
22670
|
+
if (i + 2 >= bytes2.length) {
|
|
22671
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22672
|
+
i++;
|
|
22673
|
+
continue;
|
|
22674
|
+
}
|
|
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;
|
|
22687
|
+
}
|
|
22688
|
+
if (i + 3 >= bytes2.length) {
|
|
22689
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22690
|
+
i++;
|
|
22691
|
+
continue;
|
|
22692
|
+
}
|
|
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;
|
|
22705
|
+
}
|
|
22706
|
+
flushChunk(parts, chunk);
|
|
22707
|
+
return parts.join("");
|
|
22708
|
+
}
|
|
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);
|
|
22726
|
+
}
|
|
22727
|
+
} else {
|
|
22728
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22729
|
+
}
|
|
22730
|
+
continue;
|
|
22731
|
+
}
|
|
22732
|
+
if (u1 >= 56320 && u1 <= 57343) {
|
|
22733
|
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
22734
|
+
continue;
|
|
22735
|
+
}
|
|
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;
|
|
22751
|
+
}
|
|
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];
|
|
22763
|
+
}
|
|
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 = "";
|
|
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"
|
|
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;
|
|
22820
|
+
});
|
|
22821
|
+
|
|
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;
|
|
22849
|
+
}
|
|
22850
|
+
};
|
|
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;
|
|
22859
|
+
}
|
|
22860
|
+
};
|
|
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;
|
|
22869
|
+
}
|
|
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;
|
|
22879
|
+
}
|
|
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;
|
|
22889
|
+
}
|
|
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;
|
|
22899
|
+
}
|
|
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
|
+
|
|
22348
22913
|
// ../../node_modules/strtok3/lib/stream/Errors.js
|
|
22349
22914
|
var defaultMessages = "End-Of-Stream", EndOfStreamError, AbortError;
|
|
22350
22915
|
var init_Errors = __esm(() => {
|
|
@@ -22917,408 +23482,6 @@ var init_core = __esm(() => {
|
|
|
22917
23482
|
init_AbstractTokenizer();
|
|
22918
23483
|
});
|
|
22919
23484
|
|
|
22920
|
-
// ../../node_modules/strtok3/lib/FileTokenizer.js
|
|
22921
|
-
import { open as fsOpen } from "node:fs/promises";
|
|
22922
|
-
var FileTokenizer;
|
|
22923
|
-
var init_FileTokenizer = __esm(() => {
|
|
22924
|
-
init_AbstractTokenizer();
|
|
22925
|
-
init_stream();
|
|
22926
|
-
FileTokenizer = class FileTokenizer extends AbstractTokenizer {
|
|
22927
|
-
static async fromFile(sourceFilePath) {
|
|
22928
|
-
const fileHandle = await fsOpen(sourceFilePath, "r");
|
|
22929
|
-
const stat2 = await fileHandle.stat();
|
|
22930
|
-
return new FileTokenizer(fileHandle, { fileInfo: { path: sourceFilePath, size: stat2.size } });
|
|
22931
|
-
}
|
|
22932
|
-
constructor(fileHandle, options) {
|
|
22933
|
-
super(options);
|
|
22934
|
-
this.fileHandle = fileHandle;
|
|
22935
|
-
this.fileInfo = options.fileInfo;
|
|
22936
|
-
}
|
|
22937
|
-
async readBuffer(uint8Array, options) {
|
|
22938
|
-
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
22939
|
-
this.position = normOptions.position;
|
|
22940
|
-
if (normOptions.length === 0)
|
|
22941
|
-
return 0;
|
|
22942
|
-
const res = await this.fileHandle.read(uint8Array, 0, normOptions.length, normOptions.position);
|
|
22943
|
-
this.position += res.bytesRead;
|
|
22944
|
-
if (res.bytesRead < normOptions.length && (!options || !options.mayBeLess)) {
|
|
22945
|
-
throw new EndOfStreamError;
|
|
22946
|
-
}
|
|
22947
|
-
return res.bytesRead;
|
|
22948
|
-
}
|
|
22949
|
-
async peekBuffer(uint8Array, options) {
|
|
22950
|
-
const normOptions = this.normalizeOptions(uint8Array, options);
|
|
22951
|
-
const res = await this.fileHandle.read(uint8Array, 0, normOptions.length, normOptions.position);
|
|
22952
|
-
if (!normOptions.mayBeLess && res.bytesRead < normOptions.length) {
|
|
22953
|
-
throw new EndOfStreamError;
|
|
22954
|
-
}
|
|
22955
|
-
return res.bytesRead;
|
|
22956
|
-
}
|
|
22957
|
-
async close() {
|
|
22958
|
-
await this.fileHandle.close();
|
|
22959
|
-
return super.close();
|
|
22960
|
-
}
|
|
22961
|
-
setPosition(position) {
|
|
22962
|
-
this.position = position;
|
|
22963
|
-
}
|
|
22964
|
-
supportsRandomAccess() {
|
|
22965
|
-
return true;
|
|
22966
|
-
}
|
|
22967
|
-
};
|
|
22968
|
-
});
|
|
22969
|
-
|
|
22970
|
-
// ../../node_modules/strtok3/lib/index.js
|
|
22971
|
-
import { stat as fsStat } from "node:fs/promises";
|
|
22972
|
-
async function fromStream2(stream, options) {
|
|
22973
|
-
const rst = fromStream(stream, options);
|
|
22974
|
-
if (stream.path) {
|
|
22975
|
-
const stat2 = await fsStat(stream.path);
|
|
22976
|
-
rst.fileInfo.path = stream.path;
|
|
22977
|
-
rst.fileInfo.size = stat2.size;
|
|
22978
|
-
}
|
|
22979
|
-
return rst;
|
|
22980
|
-
}
|
|
22981
|
-
var fromFile;
|
|
22982
|
-
var init_lib = __esm(() => {
|
|
22983
|
-
init_core();
|
|
22984
|
-
init_FileTokenizer();
|
|
22985
|
-
init_FileTokenizer();
|
|
22986
|
-
init_core();
|
|
22987
|
-
fromFile = FileTokenizer.fromFile;
|
|
22988
|
-
});
|
|
22989
|
-
|
|
22990
|
-
// ../../node_modules/ieee754/index.js
|
|
22991
|
-
var init_ieee754 = __esm(() => {
|
|
22992
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
22993
|
-
});
|
|
22994
|
-
|
|
22995
|
-
// ../../node_modules/@borewit/text-codec/lib/index.js
|
|
22996
|
-
function utf8Decoder() {
|
|
22997
|
-
if (typeof globalThis.TextDecoder === "undefined")
|
|
22998
|
-
return;
|
|
22999
|
-
return _utf8Decoder !== null && _utf8Decoder !== undefined ? _utf8Decoder : _utf8Decoder = new globalThis.TextDecoder("utf-8");
|
|
23000
|
-
}
|
|
23001
|
-
function textDecode(bytes2, encoding = "utf-8") {
|
|
23002
|
-
switch (encoding.toLowerCase()) {
|
|
23003
|
-
case "utf-8":
|
|
23004
|
-
case "utf8": {
|
|
23005
|
-
const dec = utf8Decoder();
|
|
23006
|
-
return dec ? dec.decode(bytes2) : decodeUTF8(bytes2);
|
|
23007
|
-
}
|
|
23008
|
-
case "utf-16le":
|
|
23009
|
-
return decodeUTF16LE(bytes2);
|
|
23010
|
-
case "us-ascii":
|
|
23011
|
-
case "ascii":
|
|
23012
|
-
return decodeASCII(bytes2);
|
|
23013
|
-
case "latin1":
|
|
23014
|
-
case "iso-8859-1":
|
|
23015
|
-
return decodeLatin1(bytes2);
|
|
23016
|
-
case "windows-1252":
|
|
23017
|
-
return decodeWindows1252(bytes2);
|
|
23018
|
-
default:
|
|
23019
|
-
throw new RangeError(`Encoding '${encoding}' not supported`);
|
|
23020
|
-
}
|
|
23021
|
-
}
|
|
23022
|
-
function flushChunk(parts, chunk) {
|
|
23023
|
-
if (chunk.length === 0)
|
|
23024
|
-
return;
|
|
23025
|
-
parts.push(String.fromCharCode.apply(null, chunk));
|
|
23026
|
-
chunk.length = 0;
|
|
23027
|
-
}
|
|
23028
|
-
function pushCodeUnit(parts, chunk, codeUnit) {
|
|
23029
|
-
chunk.push(codeUnit);
|
|
23030
|
-
if (chunk.length >= CHUNK)
|
|
23031
|
-
flushChunk(parts, chunk);
|
|
23032
|
-
}
|
|
23033
|
-
function pushCodePoint(parts, chunk, cp) {
|
|
23034
|
-
if (cp <= 65535) {
|
|
23035
|
-
pushCodeUnit(parts, chunk, cp);
|
|
23036
|
-
return;
|
|
23037
|
-
}
|
|
23038
|
-
cp -= 65536;
|
|
23039
|
-
pushCodeUnit(parts, chunk, 55296 + (cp >> 10));
|
|
23040
|
-
pushCodeUnit(parts, chunk, 56320 + (cp & 1023));
|
|
23041
|
-
}
|
|
23042
|
-
function decodeUTF8(bytes2) {
|
|
23043
|
-
const parts = [];
|
|
23044
|
-
const chunk = [];
|
|
23045
|
-
let i = 0;
|
|
23046
|
-
if (bytes2.length >= 3 && bytes2[0] === 239 && bytes2[1] === 187 && bytes2[2] === 191) {
|
|
23047
|
-
i = 3;
|
|
23048
|
-
}
|
|
23049
|
-
while (i < bytes2.length) {
|
|
23050
|
-
const b1 = bytes2[i];
|
|
23051
|
-
if (b1 <= 127) {
|
|
23052
|
-
pushCodeUnit(parts, chunk, b1);
|
|
23053
|
-
i++;
|
|
23054
|
-
continue;
|
|
23055
|
-
}
|
|
23056
|
-
if (b1 < 194 || b1 > 244) {
|
|
23057
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23058
|
-
i++;
|
|
23059
|
-
continue;
|
|
23060
|
-
}
|
|
23061
|
-
if (b1 <= 223) {
|
|
23062
|
-
if (i + 1 >= bytes2.length) {
|
|
23063
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23064
|
-
i++;
|
|
23065
|
-
continue;
|
|
23066
|
-
}
|
|
23067
|
-
const b22 = bytes2[i + 1];
|
|
23068
|
-
if ((b22 & 192) !== 128) {
|
|
23069
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23070
|
-
i++;
|
|
23071
|
-
continue;
|
|
23072
|
-
}
|
|
23073
|
-
const cp2 = (b1 & 31) << 6 | b22 & 63;
|
|
23074
|
-
pushCodeUnit(parts, chunk, cp2);
|
|
23075
|
-
i += 2;
|
|
23076
|
-
continue;
|
|
23077
|
-
}
|
|
23078
|
-
if (b1 <= 239) {
|
|
23079
|
-
if (i + 2 >= bytes2.length) {
|
|
23080
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23081
|
-
i++;
|
|
23082
|
-
continue;
|
|
23083
|
-
}
|
|
23084
|
-
const b22 = bytes2[i + 1];
|
|
23085
|
-
const b32 = bytes2[i + 2];
|
|
23086
|
-
const valid2 = (b22 & 192) === 128 && (b32 & 192) === 128 && !(b1 === 224 && b22 < 160) && !(b1 === 237 && b22 >= 160);
|
|
23087
|
-
if (!valid2) {
|
|
23088
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23089
|
-
i++;
|
|
23090
|
-
continue;
|
|
23091
|
-
}
|
|
23092
|
-
const cp2 = (b1 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
23093
|
-
pushCodeUnit(parts, chunk, cp2);
|
|
23094
|
-
i += 3;
|
|
23095
|
-
continue;
|
|
23096
|
-
}
|
|
23097
|
-
if (i + 3 >= bytes2.length) {
|
|
23098
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23099
|
-
i++;
|
|
23100
|
-
continue;
|
|
23101
|
-
}
|
|
23102
|
-
const b2 = bytes2[i + 1];
|
|
23103
|
-
const b3 = bytes2[i + 2];
|
|
23104
|
-
const b4 = bytes2[i + 3];
|
|
23105
|
-
const valid = (b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128 && !(b1 === 240 && b2 < 144) && !(b1 === 244 && b2 > 143);
|
|
23106
|
-
if (!valid) {
|
|
23107
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23108
|
-
i++;
|
|
23109
|
-
continue;
|
|
23110
|
-
}
|
|
23111
|
-
const cp = (b1 & 7) << 18 | (b2 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
|
|
23112
|
-
pushCodePoint(parts, chunk, cp);
|
|
23113
|
-
i += 4;
|
|
23114
|
-
}
|
|
23115
|
-
flushChunk(parts, chunk);
|
|
23116
|
-
return parts.join("");
|
|
23117
|
-
}
|
|
23118
|
-
function decodeUTF16LE(bytes2) {
|
|
23119
|
-
const parts = [];
|
|
23120
|
-
const chunk = [];
|
|
23121
|
-
const len = bytes2.length;
|
|
23122
|
-
let i = 0;
|
|
23123
|
-
while (i + 1 < len) {
|
|
23124
|
-
const u1 = bytes2[i] | bytes2[i + 1] << 8;
|
|
23125
|
-
i += 2;
|
|
23126
|
-
if (u1 >= 55296 && u1 <= 56319) {
|
|
23127
|
-
if (i + 1 < len) {
|
|
23128
|
-
const u2 = bytes2[i] | bytes2[i + 1] << 8;
|
|
23129
|
-
if (u2 >= 56320 && u2 <= 57343) {
|
|
23130
|
-
pushCodeUnit(parts, chunk, u1);
|
|
23131
|
-
pushCodeUnit(parts, chunk, u2);
|
|
23132
|
-
i += 2;
|
|
23133
|
-
} else {
|
|
23134
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23135
|
-
}
|
|
23136
|
-
} else {
|
|
23137
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23138
|
-
}
|
|
23139
|
-
continue;
|
|
23140
|
-
}
|
|
23141
|
-
if (u1 >= 56320 && u1 <= 57343) {
|
|
23142
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23143
|
-
continue;
|
|
23144
|
-
}
|
|
23145
|
-
pushCodeUnit(parts, chunk, u1);
|
|
23146
|
-
}
|
|
23147
|
-
if (i < len) {
|
|
23148
|
-
pushCodeUnit(parts, chunk, REPLACEMENT);
|
|
23149
|
-
}
|
|
23150
|
-
flushChunk(parts, chunk);
|
|
23151
|
-
return parts.join("");
|
|
23152
|
-
}
|
|
23153
|
-
function decodeASCII(bytes2) {
|
|
23154
|
-
const parts = [];
|
|
23155
|
-
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
23156
|
-
const end = Math.min(bytes2.length, i + CHUNK);
|
|
23157
|
-
const codes = new Array(end - i);
|
|
23158
|
-
for (let j = i, k = 0;j < end; j++, k++) {
|
|
23159
|
-
codes[k] = bytes2[j] & 127;
|
|
23160
|
-
}
|
|
23161
|
-
parts.push(String.fromCharCode.apply(null, codes));
|
|
23162
|
-
}
|
|
23163
|
-
return parts.join("");
|
|
23164
|
-
}
|
|
23165
|
-
function decodeLatin1(bytes2) {
|
|
23166
|
-
const parts = [];
|
|
23167
|
-
for (let i = 0;i < bytes2.length; i += CHUNK) {
|
|
23168
|
-
const end = Math.min(bytes2.length, i + CHUNK);
|
|
23169
|
-
const codes = new Array(end - i);
|
|
23170
|
-
for (let j = i, k = 0;j < end; j++, k++) {
|
|
23171
|
-
codes[k] = bytes2[j];
|
|
23172
|
-
}
|
|
23173
|
-
parts.push(String.fromCharCode.apply(null, codes));
|
|
23174
|
-
}
|
|
23175
|
-
return parts.join("");
|
|
23176
|
-
}
|
|
23177
|
-
function decodeWindows1252(bytes2) {
|
|
23178
|
-
const parts = [];
|
|
23179
|
-
let out = "";
|
|
23180
|
-
for (let i = 0;i < bytes2.length; i++) {
|
|
23181
|
-
const b = bytes2[i];
|
|
23182
|
-
const extra = b >= 128 && b <= 159 ? WINDOWS_1252_EXTRA[b] : undefined;
|
|
23183
|
-
out += extra !== null && extra !== undefined ? extra : String.fromCharCode(b);
|
|
23184
|
-
if (out.length >= CHUNK) {
|
|
23185
|
-
parts.push(out);
|
|
23186
|
-
out = "";
|
|
23187
|
-
}
|
|
23188
|
-
}
|
|
23189
|
-
if (out)
|
|
23190
|
-
parts.push(out);
|
|
23191
|
-
return parts.join("");
|
|
23192
|
-
}
|
|
23193
|
-
var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK, REPLACEMENT = 65533;
|
|
23194
|
-
var init_lib2 = __esm(() => {
|
|
23195
|
-
WINDOWS_1252_EXTRA = {
|
|
23196
|
-
128: "\u20AC",
|
|
23197
|
-
130: "\u201A",
|
|
23198
|
-
131: "\u0192",
|
|
23199
|
-
132: "\u201E",
|
|
23200
|
-
133: "\u2026",
|
|
23201
|
-
134: "\u2020",
|
|
23202
|
-
135: "\u2021",
|
|
23203
|
-
136: "\u02C6",
|
|
23204
|
-
137: "\u2030",
|
|
23205
|
-
138: "\u0160",
|
|
23206
|
-
139: "\u2039",
|
|
23207
|
-
140: "\u0152",
|
|
23208
|
-
142: "\u017D",
|
|
23209
|
-
145: "\u2018",
|
|
23210
|
-
146: "\u2019",
|
|
23211
|
-
147: "\u201C",
|
|
23212
|
-
148: "\u201D",
|
|
23213
|
-
149: "\u2022",
|
|
23214
|
-
150: "\u2013",
|
|
23215
|
-
151: "\u2014",
|
|
23216
|
-
152: "\u02DC",
|
|
23217
|
-
153: "\u2122",
|
|
23218
|
-
154: "\u0161",
|
|
23219
|
-
155: "\u203A",
|
|
23220
|
-
156: "\u0153",
|
|
23221
|
-
158: "\u017E",
|
|
23222
|
-
159: "\u0178"
|
|
23223
|
-
};
|
|
23224
|
-
WINDOWS_1252_REVERSE = {};
|
|
23225
|
-
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
|
23226
|
-
WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
|
|
23227
|
-
}
|
|
23228
|
-
CHUNK = 32 * 1024;
|
|
23229
|
-
});
|
|
23230
|
-
|
|
23231
|
-
// ../../node_modules/token-types/lib/index.js
|
|
23232
|
-
function dv(array) {
|
|
23233
|
-
return new DataView(array.buffer, array.byteOffset);
|
|
23234
|
-
}
|
|
23235
|
-
|
|
23236
|
-
class StringType2 {
|
|
23237
|
-
constructor(len, encoding) {
|
|
23238
|
-
this.len = len;
|
|
23239
|
-
this.encoding = encoding;
|
|
23240
|
-
}
|
|
23241
|
-
get(data, offset = 0) {
|
|
23242
|
-
const bytes2 = data.subarray(offset, offset + this.len);
|
|
23243
|
-
return textDecode(bytes2, this.encoding);
|
|
23244
|
-
}
|
|
23245
|
-
}
|
|
23246
|
-
var UINT8, UINT16_LE, UINT16_BE, UINT32_LE, UINT32_BE, INT32_BE, UINT64_LE;
|
|
23247
|
-
var init_lib3 = __esm(() => {
|
|
23248
|
-
init_ieee754();
|
|
23249
|
-
init_lib2();
|
|
23250
|
-
UINT8 = {
|
|
23251
|
-
len: 1,
|
|
23252
|
-
get(array, offset) {
|
|
23253
|
-
return dv(array).getUint8(offset);
|
|
23254
|
-
},
|
|
23255
|
-
put(array, offset, value) {
|
|
23256
|
-
dv(array).setUint8(offset, value);
|
|
23257
|
-
return offset + 1;
|
|
23258
|
-
}
|
|
23259
|
-
};
|
|
23260
|
-
UINT16_LE = {
|
|
23261
|
-
len: 2,
|
|
23262
|
-
get(array, offset) {
|
|
23263
|
-
return dv(array).getUint16(offset, true);
|
|
23264
|
-
},
|
|
23265
|
-
put(array, offset, value) {
|
|
23266
|
-
dv(array).setUint16(offset, value, true);
|
|
23267
|
-
return offset + 2;
|
|
23268
|
-
}
|
|
23269
|
-
};
|
|
23270
|
-
UINT16_BE = {
|
|
23271
|
-
len: 2,
|
|
23272
|
-
get(array, offset) {
|
|
23273
|
-
return dv(array).getUint16(offset);
|
|
23274
|
-
},
|
|
23275
|
-
put(array, offset, value) {
|
|
23276
|
-
dv(array).setUint16(offset, value);
|
|
23277
|
-
return offset + 2;
|
|
23278
|
-
}
|
|
23279
|
-
};
|
|
23280
|
-
UINT32_LE = {
|
|
23281
|
-
len: 4,
|
|
23282
|
-
get(array, offset) {
|
|
23283
|
-
return dv(array).getUint32(offset, true);
|
|
23284
|
-
},
|
|
23285
|
-
put(array, offset, value) {
|
|
23286
|
-
dv(array).setUint32(offset, value, true);
|
|
23287
|
-
return offset + 4;
|
|
23288
|
-
}
|
|
23289
|
-
};
|
|
23290
|
-
UINT32_BE = {
|
|
23291
|
-
len: 4,
|
|
23292
|
-
get(array, offset) {
|
|
23293
|
-
return dv(array).getUint32(offset);
|
|
23294
|
-
},
|
|
23295
|
-
put(array, offset, value) {
|
|
23296
|
-
dv(array).setUint32(offset, value);
|
|
23297
|
-
return offset + 4;
|
|
23298
|
-
}
|
|
23299
|
-
};
|
|
23300
|
-
INT32_BE = {
|
|
23301
|
-
len: 4,
|
|
23302
|
-
get(array, offset) {
|
|
23303
|
-
return dv(array).getInt32(offset);
|
|
23304
|
-
},
|
|
23305
|
-
put(array, offset, value) {
|
|
23306
|
-
dv(array).setInt32(offset, value);
|
|
23307
|
-
return offset + 4;
|
|
23308
|
-
}
|
|
23309
|
-
};
|
|
23310
|
-
UINT64_LE = {
|
|
23311
|
-
len: 8,
|
|
23312
|
-
get(array, offset) {
|
|
23313
|
-
return dv(array).getBigUint64(offset, true);
|
|
23314
|
-
},
|
|
23315
|
-
put(array, offset, value) {
|
|
23316
|
-
dv(array).setBigUint64(offset, value, true);
|
|
23317
|
-
return offset + 8;
|
|
23318
|
-
}
|
|
23319
|
-
};
|
|
23320
|
-
});
|
|
23321
|
-
|
|
23322
23485
|
// ../../node_modules/ms/index.js
|
|
23323
23486
|
var require_ms = __commonJS((exports, module) => {
|
|
23324
23487
|
function parse2(str) {
|
|
@@ -23949,7 +24112,7 @@ var require_src = __commonJS((exports, module) => {
|
|
|
23949
24112
|
// ../../node_modules/@tokenizer/inflate/lib/ZipToken.js
|
|
23950
24113
|
var Signature, DataDescriptor, LocalFileHeaderToken, EndOfCentralDirectoryRecordToken, FileHeader;
|
|
23951
24114
|
var init_ZipToken = __esm(() => {
|
|
23952
|
-
|
|
24115
|
+
init_lib2();
|
|
23953
24116
|
Signature = {
|
|
23954
24117
|
LocalFileHeader: 67324752,
|
|
23955
24118
|
DataDescriptor: 134695760,
|
|
@@ -24226,7 +24389,7 @@ class ZipHandler {
|
|
|
24226
24389
|
}
|
|
24227
24390
|
var import_debug, debug, syncBufferSize, ddSignatureArray, eocdSignatureBytes;
|
|
24228
24391
|
var init_ZipHandler = __esm(() => {
|
|
24229
|
-
|
|
24392
|
+
init_lib2();
|
|
24230
24393
|
import_debug = __toESM(require_src(), 1);
|
|
24231
24394
|
init_ZipToken();
|
|
24232
24395
|
debug = import_debug.default("tokenizer:inflate");
|
|
@@ -24257,11 +24420,42 @@ class GzipHandler {
|
|
|
24257
24420
|
}
|
|
24258
24421
|
|
|
24259
24422
|
// ../../node_modules/@tokenizer/inflate/lib/index.js
|
|
24260
|
-
var
|
|
24423
|
+
var init_lib3 = __esm(() => {
|
|
24261
24424
|
init_ZipHandler();
|
|
24262
24425
|
});
|
|
24263
24426
|
|
|
24264
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
|
+
}
|
|
24265
24459
|
function getUintBE(view) {
|
|
24266
24460
|
const { byteLength } = view;
|
|
24267
24461
|
if (byteLength === 6) {
|
|
@@ -24283,8 +24477,9 @@ function getUintBE(view) {
|
|
|
24283
24477
|
return view.getUint8(0);
|
|
24284
24478
|
}
|
|
24285
24479
|
}
|
|
24286
|
-
var cachedDecoders, cachedEncoder, byteToHexLookupTable;
|
|
24480
|
+
var objectToString, uint8ArrayStringified = "[object Uint8Array]", cachedDecoders, cachedEncoder, byteToHexLookupTable;
|
|
24287
24481
|
var init_uint8array_extras = __esm(() => {
|
|
24482
|
+
objectToString = Object.prototype.toString;
|
|
24288
24483
|
cachedDecoders = {
|
|
24289
24484
|
utf8: new globalThis.TextDecoder("utf8")
|
|
24290
24485
|
};
|
|
@@ -24292,7 +24487,7 @@ var init_uint8array_extras = __esm(() => {
|
|
|
24292
24487
|
byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
|
|
24293
24488
|
});
|
|
24294
24489
|
|
|
24295
|
-
// ../../node_modules/file-type/
|
|
24490
|
+
// ../../node_modules/file-type/source/tokens.js
|
|
24296
24491
|
function stringToBytes(string, encoding) {
|
|
24297
24492
|
if (encoding === "utf-16le") {
|
|
24298
24493
|
const bytes2 = [];
|
|
@@ -24313,7 +24508,7 @@ function stringToBytes(string, encoding) {
|
|
|
24313
24508
|
return [...string].map((character) => character.charCodeAt(0));
|
|
24314
24509
|
}
|
|
24315
24510
|
function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
24316
|
-
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);
|
|
24317
24512
|
if (Number.isNaN(readSum)) {
|
|
24318
24513
|
return false;
|
|
24319
24514
|
}
|
|
@@ -24327,15 +24522,15 @@ function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
|
24327
24522
|
return readSum === sum;
|
|
24328
24523
|
}
|
|
24329
24524
|
var uint32SyncSafeToken;
|
|
24330
|
-
var
|
|
24331
|
-
|
|
24525
|
+
var init_tokens = __esm(() => {
|
|
24526
|
+
init_lib2();
|
|
24332
24527
|
uint32SyncSafeToken = {
|
|
24333
|
-
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,
|
|
24334
24529
|
len: 4
|
|
24335
24530
|
};
|
|
24336
24531
|
});
|
|
24337
24532
|
|
|
24338
|
-
// ../../node_modules/file-type/supported.js
|
|
24533
|
+
// ../../node_modules/file-type/source/supported.js
|
|
24339
24534
|
var extensions, mimeTypes;
|
|
24340
24535
|
var init_supported = __esm(() => {
|
|
24341
24536
|
extensions = [
|
|
@@ -24518,7 +24713,10 @@ var init_supported = __esm(() => {
|
|
|
24518
24713
|
"ppsx",
|
|
24519
24714
|
"tar.gz",
|
|
24520
24715
|
"reg",
|
|
24521
|
-
"dat"
|
|
24716
|
+
"dat",
|
|
24717
|
+
"key",
|
|
24718
|
+
"numbers",
|
|
24719
|
+
"pages"
|
|
24522
24720
|
];
|
|
24523
24721
|
mimeTypes = [
|
|
24524
24722
|
"image/jpeg",
|
|
@@ -24601,7 +24799,7 @@ var init_supported = __esm(() => {
|
|
|
24601
24799
|
"application/x-unix-archive",
|
|
24602
24800
|
"application/x-rpm",
|
|
24603
24801
|
"application/x-compress",
|
|
24604
|
-
"application/
|
|
24802
|
+
"application/lzip",
|
|
24605
24803
|
"application/x-cfb",
|
|
24606
24804
|
"application/x-mie",
|
|
24607
24805
|
"application/mxf",
|
|
@@ -24630,8 +24828,8 @@ var init_supported = __esm(() => {
|
|
|
24630
24828
|
"model/gltf-binary",
|
|
24631
24829
|
"application/vnd.tcpdump.pcap",
|
|
24632
24830
|
"audio/x-dsf",
|
|
24633
|
-
"application/x
|
|
24634
|
-
"application/x
|
|
24831
|
+
"application/x-ms-shortcut",
|
|
24832
|
+
"application/x-ft-apple.alias",
|
|
24635
24833
|
"audio/x-voc",
|
|
24636
24834
|
"audio/vnd.dolby.dd-raw",
|
|
24637
24835
|
"audio/x-m4a",
|
|
@@ -24671,10 +24869,10 @@ var init_supported = __esm(() => {
|
|
|
24671
24869
|
"application/x-ace-compressed",
|
|
24672
24870
|
"application/avro",
|
|
24673
24871
|
"application/vnd.iccprofile",
|
|
24674
|
-
"application/x
|
|
24872
|
+
"application/x-ft-fbx",
|
|
24675
24873
|
"application/vnd.visio",
|
|
24676
24874
|
"application/vnd.android.package-archive",
|
|
24677
|
-
"application/
|
|
24875
|
+
"application/x-ft-draco",
|
|
24678
24876
|
"application/x-lz4",
|
|
24679
24877
|
"application/vnd.openxmlformats-officedocument.presentationml.template",
|
|
24680
24878
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
@@ -24695,28 +24893,14 @@ var init_supported = __esm(() => {
|
|
|
24695
24893
|
"application/x-spss-sav",
|
|
24696
24894
|
"application/x-ms-regedit",
|
|
24697
24895
|
"application/x-ft-windows-registry-hive",
|
|
24698
|
-
"application/x-jmp-data"
|
|
24896
|
+
"application/x-jmp-data",
|
|
24897
|
+
"application/vnd.apple.keynote",
|
|
24898
|
+
"application/vnd.apple.numbers",
|
|
24899
|
+
"application/vnd.apple.pages"
|
|
24699
24900
|
];
|
|
24700
24901
|
});
|
|
24701
24902
|
|
|
24702
|
-
// ../../node_modules/file-type/
|
|
24703
|
-
function patchWebByobTokenizerClose(tokenizer) {
|
|
24704
|
-
const streamReader = tokenizer?.streamReader;
|
|
24705
|
-
if (streamReader?.constructor?.name !== "WebStreamByobReader") {
|
|
24706
|
-
return tokenizer;
|
|
24707
|
-
}
|
|
24708
|
-
const { reader } = streamReader;
|
|
24709
|
-
const cancelAndRelease = async () => {
|
|
24710
|
-
await reader.cancel();
|
|
24711
|
-
reader.releaseLock();
|
|
24712
|
-
};
|
|
24713
|
-
streamReader.close = cancelAndRelease;
|
|
24714
|
-
streamReader.abort = async () => {
|
|
24715
|
-
streamReader.interrupted = true;
|
|
24716
|
-
await cancelAndRelease();
|
|
24717
|
-
};
|
|
24718
|
-
return tokenizer;
|
|
24719
|
-
}
|
|
24903
|
+
// ../../node_modules/file-type/source/parser.js
|
|
24720
24904
|
function getSafeBound(value, maximum, reason) {
|
|
24721
24905
|
if (!Number.isFinite(value) || value < 0 || value > maximum) {
|
|
24722
24906
|
throw new ParserHardLimitError(`${reason} has invalid size ${value} (maximum ${maximum} bytes)`);
|
|
@@ -24735,6 +24919,37 @@ async function safeReadBuffer(tokenizer, buffer, options, { maximumLength = buff
|
|
|
24735
24919
|
length: safeLength
|
|
24736
24920
|
});
|
|
24737
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
|
+
}
|
|
24935
|
+
}
|
|
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
|
|
24738
24953
|
async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipEntrySizeInBytes } = {}) {
|
|
24739
24954
|
const input = new ReadableStream({
|
|
24740
24955
|
start(controller) {
|
|
@@ -24770,6 +24985,213 @@ async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipE
|
|
|
24770
24985
|
}
|
|
24771
24986
|
return uncompressedData;
|
|
24772
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
|
|
25040
|
+
};
|
|
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
|
|
25134
|
+
};
|
|
25135
|
+
}
|
|
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
|
+
};
|
|
25174
|
+
}
|
|
25175
|
+
}
|
|
25176
|
+
function getOpenXmlFileTypeFromZipEntries(openXmlState) {
|
|
25177
|
+
if (!openXmlState.hasContentTypesEntry || openXmlState.hasUnparseableContentTypes || openXmlState.isParsingContentTypes || openXmlState.hasParsedContentTypesEntry) {
|
|
25178
|
+
return;
|
|
25179
|
+
}
|
|
25180
|
+
return getOpenXmlFileTypeFromDirectoryNames(openXmlState);
|
|
25181
|
+
}
|
|
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);
|
|
25194
|
+
}
|
|
24773
25195
|
function findZipDataDescriptorOffset(buffer, bytesConsumed) {
|
|
24774
25196
|
if (buffer.length < zipDataDescriptorLengthInBytes) {
|
|
24775
25197
|
return -1;
|
|
@@ -24782,18 +25204,6 @@ function findZipDataDescriptorOffset(buffer, bytesConsumed) {
|
|
|
24782
25204
|
}
|
|
24783
25205
|
return -1;
|
|
24784
25206
|
}
|
|
24785
|
-
function isPngAncillaryChunk(type) {
|
|
24786
|
-
return (type.codePointAt(0) & 32) !== 0;
|
|
24787
|
-
}
|
|
24788
|
-
function mergeByteChunks(chunks, totalLength) {
|
|
24789
|
-
const merged = new Uint8Array(totalLength);
|
|
24790
|
-
let offset = 0;
|
|
24791
|
-
for (const chunk of chunks) {
|
|
24792
|
-
merged.set(chunk, offset);
|
|
24793
|
-
offset += chunk.length;
|
|
24794
|
-
}
|
|
24795
|
-
return merged;
|
|
24796
|
-
}
|
|
24797
25207
|
async function readZipDataDescriptorEntryWithLimit(zipHandler, { shouldBuffer, maximumLength = maximumZipEntrySizeInBytes } = {}) {
|
|
24798
25208
|
const { syncBuffer } = zipHandler;
|
|
24799
25209
|
const { length: syncBufferLength } = syncBuffer;
|
|
@@ -24858,239 +25268,548 @@ async function readZipEntryData(zipHandler, zipHeader, { shouldBuffer, maximumDe
|
|
|
24858
25268
|
await zipHandler.tokenizer.readBuffer(fileData);
|
|
24859
25269
|
return fileData;
|
|
24860
25270
|
}
|
|
24861
|
-
function
|
|
24862
|
-
|
|
24863
|
-
|
|
24864
|
-
|
|
24865
|
-
|
|
24866
|
-
|
|
24867
|
-
|
|
24868
|
-
|
|
25271
|
+
async function detectZip(tokenizer) {
|
|
25272
|
+
let fileType;
|
|
25273
|
+
const openXmlState = createOpenXmlZipDetectionState();
|
|
25274
|
+
const iWorkState = createIWorkZipDetectionState();
|
|
25275
|
+
try {
|
|
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;
|
|
24869
25353
|
}
|
|
24870
|
-
|
|
24871
|
-
|
|
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"
|
|
24872
25366
|
};
|
|
24873
|
-
|
|
24874
|
-
|
|
24875
|
-
|
|
24876
|
-
|
|
24877
|
-
|
|
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) {
|
|
25416
|
+
break;
|
|
25417
|
+
}
|
|
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) {
|
|
24878
25480
|
return;
|
|
24879
25481
|
}
|
|
24880
|
-
|
|
24881
|
-
if (done || !value) {
|
|
24882
|
-
sourceDone = true;
|
|
24883
|
-
controller.close();
|
|
25482
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, ebmlScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
24884
25483
|
return;
|
|
24885
25484
|
}
|
|
24886
|
-
const
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
|
|
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) {
|
|
24892
25504
|
return;
|
|
24893
25505
|
}
|
|
24894
|
-
controller.enqueue(value);
|
|
24895
|
-
emittedBytes += value.length;
|
|
24896
|
-
},
|
|
24897
|
-
async cancel(reason) {
|
|
24898
|
-
await cancelSource(reason);
|
|
24899
25506
|
}
|
|
24900
|
-
}
|
|
24901
|
-
|
|
24902
|
-
|
|
24903
|
-
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
return new FileTypeParser(options).fromBlob(blob);
|
|
24907
|
-
}
|
|
24908
|
-
function getFileTypeFromMimeType(mimeType) {
|
|
24909
|
-
mimeType = mimeType.toLowerCase();
|
|
24910
|
-
switch (mimeType) {
|
|
24911
|
-
case "application/epub+zip":
|
|
24912
|
-
return {
|
|
24913
|
-
ext: "epub",
|
|
24914
|
-
mime: mimeType
|
|
24915
|
-
};
|
|
24916
|
-
case "application/vnd.oasis.opendocument.text":
|
|
24917
|
-
return {
|
|
24918
|
-
ext: "odt",
|
|
24919
|
-
mime: mimeType
|
|
24920
|
-
};
|
|
24921
|
-
case "application/vnd.oasis.opendocument.text-template":
|
|
24922
|
-
return {
|
|
24923
|
-
ext: "ott",
|
|
24924
|
-
mime: mimeType
|
|
24925
|
-
};
|
|
24926
|
-
case "application/vnd.oasis.opendocument.spreadsheet":
|
|
24927
|
-
return {
|
|
24928
|
-
ext: "ods",
|
|
24929
|
-
mime: mimeType
|
|
24930
|
-
};
|
|
24931
|
-
case "application/vnd.oasis.opendocument.spreadsheet-template":
|
|
24932
|
-
return {
|
|
24933
|
-
ext: "ots",
|
|
24934
|
-
mime: mimeType
|
|
24935
|
-
};
|
|
24936
|
-
case "application/vnd.oasis.opendocument.presentation":
|
|
24937
|
-
return {
|
|
24938
|
-
ext: "odp",
|
|
24939
|
-
mime: mimeType
|
|
24940
|
-
};
|
|
24941
|
-
case "application/vnd.oasis.opendocument.presentation-template":
|
|
24942
|
-
return {
|
|
24943
|
-
ext: "otp",
|
|
24944
|
-
mime: mimeType
|
|
24945
|
-
};
|
|
24946
|
-
case "application/vnd.oasis.opendocument.graphics":
|
|
24947
|
-
return {
|
|
24948
|
-
ext: "odg",
|
|
24949
|
-
mime: mimeType
|
|
24950
|
-
};
|
|
24951
|
-
case "application/vnd.oasis.opendocument.graphics-template":
|
|
24952
|
-
return {
|
|
24953
|
-
ext: "otg",
|
|
24954
|
-
mime: mimeType
|
|
24955
|
-
};
|
|
24956
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.slideshow":
|
|
24957
|
-
return {
|
|
24958
|
-
ext: "ppsx",
|
|
24959
|
-
mime: mimeType
|
|
24960
|
-
};
|
|
24961
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
|
24962
|
-
return {
|
|
24963
|
-
ext: "xlsx",
|
|
24964
|
-
mime: mimeType
|
|
24965
|
-
};
|
|
24966
|
-
case "application/vnd.ms-excel.sheet.macroenabled":
|
|
24967
|
-
return {
|
|
24968
|
-
ext: "xlsm",
|
|
24969
|
-
mime: "application/vnd.ms-excel.sheet.macroenabled.12"
|
|
24970
|
-
};
|
|
24971
|
-
case "application/vnd.openxmlformats-officedocument.spreadsheetml.template":
|
|
24972
|
-
return {
|
|
24973
|
-
ext: "xltx",
|
|
24974
|
-
mime: mimeType
|
|
24975
|
-
};
|
|
24976
|
-
case "application/vnd.ms-excel.template.macroenabled":
|
|
24977
|
-
return {
|
|
24978
|
-
ext: "xltm",
|
|
24979
|
-
mime: "application/vnd.ms-excel.template.macroenabled.12"
|
|
24980
|
-
};
|
|
24981
|
-
case "application/vnd.ms-powerpoint.slideshow.macroenabled":
|
|
24982
|
-
return {
|
|
24983
|
-
ext: "ppsm",
|
|
24984
|
-
mime: "application/vnd.ms-powerpoint.slideshow.macroenabled.12"
|
|
24985
|
-
};
|
|
24986
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
|
24987
|
-
return {
|
|
24988
|
-
ext: "docx",
|
|
24989
|
-
mime: mimeType
|
|
24990
|
-
};
|
|
24991
|
-
case "application/vnd.ms-word.document.macroenabled":
|
|
24992
|
-
return {
|
|
24993
|
-
ext: "docm",
|
|
24994
|
-
mime: "application/vnd.ms-word.document.macroenabled.12"
|
|
24995
|
-
};
|
|
24996
|
-
case "application/vnd.openxmlformats-officedocument.wordprocessingml.template":
|
|
24997
|
-
return {
|
|
24998
|
-
ext: "dotx",
|
|
24999
|
-
mime: mimeType
|
|
25000
|
-
};
|
|
25001
|
-
case "application/vnd.ms-word.template.macroenabledtemplate":
|
|
25002
|
-
return {
|
|
25003
|
-
ext: "dotm",
|
|
25004
|
-
mime: "application/vnd.ms-word.template.macroenabled.12"
|
|
25005
|
-
};
|
|
25006
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.template":
|
|
25007
|
-
return {
|
|
25008
|
-
ext: "potx",
|
|
25009
|
-
mime: mimeType
|
|
25010
|
-
};
|
|
25011
|
-
case "application/vnd.ms-powerpoint.template.macroenabled":
|
|
25012
|
-
return {
|
|
25013
|
-
ext: "potm",
|
|
25014
|
-
mime: "application/vnd.ms-powerpoint.template.macroenabled.12"
|
|
25015
|
-
};
|
|
25016
|
-
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
25017
|
-
return {
|
|
25018
|
-
ext: "pptx",
|
|
25019
|
-
mime: mimeType
|
|
25020
|
-
};
|
|
25021
|
-
case "application/vnd.ms-powerpoint.presentation.macroenabled":
|
|
25022
|
-
return {
|
|
25023
|
-
ext: "pptm",
|
|
25024
|
-
mime: "application/vnd.ms-powerpoint.presentation.macroenabled.12"
|
|
25025
|
-
};
|
|
25026
|
-
case "application/vnd.ms-visio.drawing":
|
|
25507
|
+
}
|
|
25508
|
+
const rootElement = await readElement();
|
|
25509
|
+
const ebmlScanStart = tokenizer.position;
|
|
25510
|
+
const documentType = await readChildren(rootElement.len);
|
|
25511
|
+
switch (documentType) {
|
|
25512
|
+
case "webm":
|
|
25027
25513
|
return {
|
|
25028
|
-
ext: "
|
|
25029
|
-
mime: "
|
|
25514
|
+
ext: "webm",
|
|
25515
|
+
mime: "video/webm"
|
|
25030
25516
|
};
|
|
25031
|
-
case "
|
|
25517
|
+
case "matroska":
|
|
25032
25518
|
return {
|
|
25033
|
-
ext: "
|
|
25034
|
-
mime: "
|
|
25519
|
+
ext: "mkv",
|
|
25520
|
+
mime: "video/matroska"
|
|
25035
25521
|
};
|
|
25036
25522
|
default:
|
|
25037
25523
|
}
|
|
25038
25524
|
}
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
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
|
|
25534
|
+
function isPngAncillaryChunk(type) {
|
|
25535
|
+
return (type.codePointAt(0) & 32) !== 0;
|
|
25536
|
+
}
|
|
25537
|
+
async function detectPng(tokenizer) {
|
|
25538
|
+
const pngFileType = {
|
|
25539
|
+
ext: "png",
|
|
25540
|
+
mime: "image/png"
|
|
25043
25541
|
};
|
|
25044
|
-
|
|
25045
|
-
|
|
25046
|
-
|
|
25047
|
-
|
|
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
|
+
};
|
|
25552
|
+
}
|
|
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) {
|
|
25560
|
+
break;
|
|
25561
|
+
}
|
|
25562
|
+
if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngStreamScanBudgetInBytes)) {
|
|
25563
|
+
break;
|
|
25564
|
+
}
|
|
25565
|
+
const previousPosition = tokenizer.position;
|
|
25566
|
+
const chunk = await readChunkHeader();
|
|
25567
|
+
if (chunk.length < 0) {
|
|
25568
|
+
return;
|
|
25569
|
+
}
|
|
25570
|
+
if (chunk.type === "IHDR") {
|
|
25571
|
+
if (chunk.length !== 13) {
|
|
25572
|
+
return;
|
|
25048
25573
|
}
|
|
25049
|
-
|
|
25050
|
-
|
|
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) {
|
|
25601
|
+
break;
|
|
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;
|
|
25051
25692
|
}
|
|
25052
25693
|
}
|
|
25053
|
-
|
|
25694
|
+
if (isMalformedAsf) {
|
|
25695
|
+
return;
|
|
25696
|
+
}
|
|
25697
|
+
return {
|
|
25698
|
+
ext: "asf",
|
|
25699
|
+
mime: "application/vnd.ms-asf"
|
|
25700
|
+
};
|
|
25054
25701
|
}
|
|
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;
|
|
25780
|
+
}
|
|
25781
|
+
return rst;
|
|
25782
|
+
}
|
|
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
|
+
});
|
|
25055
25807
|
function normalizeSampleSize(sampleSize) {
|
|
25056
25808
|
if (!Number.isFinite(sampleSize)) {
|
|
25057
25809
|
return reasonableDetectionSizeInBytes;
|
|
25058
25810
|
}
|
|
25059
25811
|
return Math.max(1, Math.trunc(sampleSize));
|
|
25060
25812
|
}
|
|
25061
|
-
function readByobReaderWithSignal(reader, buffer, signal) {
|
|
25062
|
-
if (signal === undefined) {
|
|
25063
|
-
return reader.read(buffer);
|
|
25064
|
-
}
|
|
25065
|
-
signal.throwIfAborted();
|
|
25066
|
-
return new Promise((resolve3, reject) => {
|
|
25067
|
-
const cleanup = () => {
|
|
25068
|
-
signal.removeEventListener("abort", onAbort);
|
|
25069
|
-
};
|
|
25070
|
-
const onAbort = () => {
|
|
25071
|
-
const abortReason = signal.reason;
|
|
25072
|
-
cleanup();
|
|
25073
|
-
(async () => {
|
|
25074
|
-
try {
|
|
25075
|
-
await reader.cancel(abortReason);
|
|
25076
|
-
} catch {
|
|
25077
|
-
}
|
|
25078
|
-
})();
|
|
25079
|
-
reject(abortReason);
|
|
25080
|
-
};
|
|
25081
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
25082
|
-
(async () => {
|
|
25083
|
-
try {
|
|
25084
|
-
const result = await reader.read(buffer);
|
|
25085
|
-
cleanup();
|
|
25086
|
-
resolve3(result);
|
|
25087
|
-
} catch (error) {
|
|
25088
|
-
cleanup();
|
|
25089
|
-
reject(error);
|
|
25090
|
-
}
|
|
25091
|
-
})();
|
|
25092
|
-
});
|
|
25093
|
-
}
|
|
25094
25813
|
function normalizeMpegOffsetTolerance(mpegOffsetTolerance) {
|
|
25095
25814
|
if (!Number.isFinite(mpegOffsetTolerance)) {
|
|
25096
25815
|
return 0;
|
|
@@ -25103,121 +25822,84 @@ function getKnownFileSizeOrMaximum(fileSize) {
|
|
|
25103
25822
|
}
|
|
25104
25823
|
return Math.max(0, fileSize);
|
|
25105
25824
|
}
|
|
25106
|
-
function
|
|
25107
|
-
|
|
25108
|
-
return !Number.isFinite(fileSize) || fileSize === Number.MAX_SAFE_INTEGER;
|
|
25109
|
-
}
|
|
25110
|
-
function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
|
|
25111
|
-
return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
|
|
25825
|
+
function toDefaultStream(stream) {
|
|
25826
|
+
return stream.pipeThrough(new TransformStream);
|
|
25112
25827
|
}
|
|
25113
|
-
function
|
|
25114
|
-
|
|
25115
|
-
|
|
25116
|
-
return Math.min(remainingBytes, maximumZipBufferedReadSizeInBytes);
|
|
25117
|
-
}
|
|
25118
|
-
function isRecoverableZipError(error) {
|
|
25119
|
-
if (error instanceof EndOfStreamError) {
|
|
25120
|
-
return true;
|
|
25121
|
-
}
|
|
25122
|
-
if (error instanceof ParserHardLimitError) {
|
|
25123
|
-
return true;
|
|
25124
|
-
}
|
|
25125
|
-
if (!(error instanceof Error)) {
|
|
25126
|
-
return false;
|
|
25127
|
-
}
|
|
25128
|
-
if (recoverableZipErrorMessages.has(error.message)) {
|
|
25129
|
-
return true;
|
|
25130
|
-
}
|
|
25131
|
-
if (recoverableZipErrorCodes.has(error.code)) {
|
|
25132
|
-
return true;
|
|
25133
|
-
}
|
|
25134
|
-
for (const prefix of recoverableZipErrorMessagePrefixes) {
|
|
25135
|
-
if (error.message.startsWith(prefix)) {
|
|
25136
|
-
return true;
|
|
25137
|
-
}
|
|
25828
|
+
function readWithSignal(reader, signal) {
|
|
25829
|
+
if (signal === undefined) {
|
|
25830
|
+
return reader.read();
|
|
25138
25831
|
}
|
|
25139
|
-
|
|
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
|
+
]);
|
|
25140
25843
|
}
|
|
25141
|
-
function
|
|
25142
|
-
const
|
|
25143
|
-
|
|
25144
|
-
|
|
25145
|
-
|
|
25844
|
+
function createByteLimitedReadableStream(stream, maximumBytes) {
|
|
25845
|
+
const reader = stream.getReader();
|
|
25846
|
+
let emittedBytes = 0;
|
|
25847
|
+
let sourceDone = false;
|
|
25848
|
+
let sourceCanceled = false;
|
|
25849
|
+
const cancelSource = async (reason) => {
|
|
25850
|
+
if (sourceDone || sourceCanceled) {
|
|
25851
|
+
return;
|
|
25146
25852
|
}
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
}
|
|
25150
|
-
function createOpenXmlZipDetectionState() {
|
|
25151
|
-
return {
|
|
25152
|
-
hasContentTypesEntry: false,
|
|
25153
|
-
hasParsedContentTypesEntry: false,
|
|
25154
|
-
isParsingContentTypes: false,
|
|
25155
|
-
hasUnparseableContentTypes: false,
|
|
25156
|
-
hasWordDirectory: false,
|
|
25157
|
-
hasPresentationDirectory: false,
|
|
25158
|
-
hasSpreadsheetDirectory: false,
|
|
25159
|
-
hasThreeDimensionalModelEntry: false
|
|
25853
|
+
sourceCanceled = true;
|
|
25854
|
+
await reader.cancel(reason);
|
|
25160
25855
|
};
|
|
25856
|
+
return new ReadableStream({
|
|
25857
|
+
async pull(controller) {
|
|
25858
|
+
if (emittedBytes >= maximumBytes) {
|
|
25859
|
+
controller.close();
|
|
25860
|
+
await cancelSource();
|
|
25861
|
+
return;
|
|
25862
|
+
}
|
|
25863
|
+
const { done, value } = await reader.read();
|
|
25864
|
+
if (done || !value) {
|
|
25865
|
+
sourceDone = true;
|
|
25866
|
+
controller.close();
|
|
25867
|
+
return;
|
|
25868
|
+
}
|
|
25869
|
+
const remainingBytes = maximumBytes - emittedBytes;
|
|
25870
|
+
if (value.length > remainingBytes) {
|
|
25871
|
+
controller.enqueue(value.subarray(0, remainingBytes));
|
|
25872
|
+
emittedBytes += remainingBytes;
|
|
25873
|
+
controller.close();
|
|
25874
|
+
await cancelSource();
|
|
25875
|
+
return;
|
|
25876
|
+
}
|
|
25877
|
+
controller.enqueue(value);
|
|
25878
|
+
emittedBytes += value.length;
|
|
25879
|
+
},
|
|
25880
|
+
async cancel(reason) {
|
|
25881
|
+
await cancelSource(reason);
|
|
25882
|
+
}
|
|
25883
|
+
});
|
|
25161
25884
|
}
|
|
25162
|
-
function
|
|
25163
|
-
|
|
25164
|
-
openXmlState.hasWordDirectory = true;
|
|
25165
|
-
}
|
|
25166
|
-
if (filename.startsWith("ppt/")) {
|
|
25167
|
-
openXmlState.hasPresentationDirectory = true;
|
|
25168
|
-
}
|
|
25169
|
-
if (filename.startsWith("xl/")) {
|
|
25170
|
-
openXmlState.hasSpreadsheetDirectory = true;
|
|
25171
|
-
}
|
|
25172
|
-
if (filename.startsWith("3D/") && filename.endsWith(".model")) {
|
|
25173
|
-
openXmlState.hasThreeDimensionalModelEntry = true;
|
|
25174
|
-
}
|
|
25885
|
+
async function fileTypeFromStream(stream, options) {
|
|
25886
|
+
return new FileTypeParser(options).fromStream(stream);
|
|
25175
25887
|
}
|
|
25176
|
-
function
|
|
25177
|
-
|
|
25178
|
-
return;
|
|
25179
|
-
}
|
|
25180
|
-
if (openXmlState.hasWordDirectory) {
|
|
25181
|
-
return {
|
|
25182
|
-
ext: "docx",
|
|
25183
|
-
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
25184
|
-
};
|
|
25185
|
-
}
|
|
25186
|
-
if (openXmlState.hasPresentationDirectory) {
|
|
25187
|
-
return {
|
|
25188
|
-
ext: "pptx",
|
|
25189
|
-
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
25190
|
-
};
|
|
25191
|
-
}
|
|
25192
|
-
if (openXmlState.hasSpreadsheetDirectory) {
|
|
25193
|
-
return {
|
|
25194
|
-
ext: "xlsx",
|
|
25195
|
-
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
25196
|
-
};
|
|
25197
|
-
}
|
|
25198
|
-
if (openXmlState.hasThreeDimensionalModelEntry) {
|
|
25199
|
-
return {
|
|
25200
|
-
ext: "3mf",
|
|
25201
|
-
mime: "model/3mf"
|
|
25202
|
-
};
|
|
25203
|
-
}
|
|
25888
|
+
async function fileTypeFromBuffer(input, options) {
|
|
25889
|
+
return new FileTypeParser(options).fromBuffer(input);
|
|
25204
25890
|
}
|
|
25205
|
-
function
|
|
25206
|
-
|
|
25207
|
-
if (endPosition === -1) {
|
|
25208
|
-
const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
|
|
25209
|
-
if (xmlContent.includes(`ContentType="${mimeType}"`)) {
|
|
25210
|
-
return mimeType;
|
|
25211
|
-
}
|
|
25212
|
-
return;
|
|
25213
|
-
}
|
|
25214
|
-
const truncatedContent = xmlContent.slice(0, endPosition);
|
|
25215
|
-
const firstQuotePosition = truncatedContent.lastIndexOf('"');
|
|
25216
|
-
return truncatedContent.slice(firstQuotePosition + 1);
|
|
25891
|
+
async function fileTypeFromBlob(blob, options) {
|
|
25892
|
+
return new FileTypeParser(options).fromBlob(blob);
|
|
25217
25893
|
}
|
|
25218
25894
|
async function fileTypeFromTokenizer(tokenizer, options) {
|
|
25219
25895
|
return new FileTypeParser(options).fromTokenizer(tokenizer);
|
|
25220
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
|
+
}
|
|
25221
25903
|
|
|
25222
25904
|
class FileTypeParser {
|
|
25223
25905
|
constructor(options) {
|
|
@@ -25242,7 +25924,7 @@ class FileTypeParser {
|
|
|
25242
25924
|
};
|
|
25243
25925
|
}
|
|
25244
25926
|
createTokenizerFromWebStream(stream) {
|
|
25245
|
-
return
|
|
25927
|
+
return fromWebStream(toDefaultStream(stream), this.getTokenizerOptions());
|
|
25246
25928
|
}
|
|
25247
25929
|
async parseTokenizer(tokenizer, detectionReentryCount = 0) {
|
|
25248
25930
|
this.detectionReentryCount = detectionReentryCount;
|
|
@@ -25295,31 +25977,76 @@ class FileTypeParser {
|
|
|
25295
25977
|
const tokenizer = this.createTokenizerFromWebStream(stream);
|
|
25296
25978
|
return this.fromTokenizer(tokenizer);
|
|
25297
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
|
+
}
|
|
25298
25998
|
async toDetectionStream(stream, options) {
|
|
25999
|
+
this.options.signal?.throwIfAborted();
|
|
25299
26000
|
const sampleSize = normalizeSampleSize(options?.sampleSize ?? reasonableDetectionSizeInBytes);
|
|
25300
26001
|
let detectedFileType;
|
|
25301
|
-
let
|
|
25302
|
-
const reader = stream.getReader(
|
|
26002
|
+
let streamEnded = false;
|
|
26003
|
+
const reader = stream.getReader();
|
|
26004
|
+
const chunks = [];
|
|
26005
|
+
let totalSize = 0;
|
|
25303
26006
|
try {
|
|
25304
|
-
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
}
|
|
25310
|
-
|
|
25311
|
-
|
|
25312
|
-
|
|
25313
|
-
|
|
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;
|
|
25314
26023
|
}
|
|
25315
26024
|
}
|
|
25316
|
-
firstChunk = chunk;
|
|
25317
26025
|
} finally {
|
|
25318
26026
|
reader.releaseLock();
|
|
25319
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
|
+
}
|
|
25320
26045
|
const transformStream = new TransformStream({
|
|
25321
|
-
|
|
25322
|
-
|
|
26046
|
+
start(controller) {
|
|
26047
|
+
for (const chunk of chunks) {
|
|
26048
|
+
controller.enqueue(chunk);
|
|
26049
|
+
}
|
|
25323
26050
|
},
|
|
25324
26051
|
transform(chunk, controller) {
|
|
25325
26052
|
controller.enqueue(chunk);
|
|
@@ -25381,7 +26108,7 @@ class FileTypeParser {
|
|
|
25381
26108
|
};
|
|
25382
26109
|
}
|
|
25383
26110
|
check(header, options) {
|
|
25384
|
-
return
|
|
26111
|
+
return checkBytes(this.buffer, header, options);
|
|
25385
26112
|
}
|
|
25386
26113
|
checkString(header, options) {
|
|
25387
26114
|
return this.check(stringToBytes(header, options?.encoding), options);
|
|
@@ -25580,127 +26307,43 @@ class FileTypeParser {
|
|
|
25580
26307
|
};
|
|
25581
26308
|
}
|
|
25582
26309
|
if (this.check([80, 75, 3, 4])) {
|
|
25583
|
-
|
|
25584
|
-
const openXmlState = createOpenXmlZipDetectionState();
|
|
25585
|
-
try {
|
|
25586
|
-
await new ZipHandler(tokenizer).unzip((zipHeader) => {
|
|
25587
|
-
updateOpenXmlZipDetectionStateFromFilename(openXmlState, zipHeader.filename);
|
|
25588
|
-
const isOpenXmlContentTypesEntry = zipHeader.filename === "[Content_Types].xml";
|
|
25589
|
-
const openXmlFileTypeFromEntries = getOpenXmlFileTypeFromZipEntries(openXmlState);
|
|
25590
|
-
if (!isOpenXmlContentTypesEntry && openXmlFileTypeFromEntries) {
|
|
25591
|
-
fileType = openXmlFileTypeFromEntries;
|
|
25592
|
-
return {
|
|
25593
|
-
stop: true
|
|
25594
|
-
};
|
|
25595
|
-
}
|
|
25596
|
-
switch (zipHeader.filename) {
|
|
25597
|
-
case "META-INF/mozilla.rsa":
|
|
25598
|
-
fileType = {
|
|
25599
|
-
ext: "xpi",
|
|
25600
|
-
mime: "application/x-xpinstall"
|
|
25601
|
-
};
|
|
25602
|
-
return {
|
|
25603
|
-
stop: true
|
|
25604
|
-
};
|
|
25605
|
-
case "META-INF/MANIFEST.MF":
|
|
25606
|
-
fileType = {
|
|
25607
|
-
ext: "jar",
|
|
25608
|
-
mime: "application/java-archive"
|
|
25609
|
-
};
|
|
25610
|
-
return {
|
|
25611
|
-
stop: true
|
|
25612
|
-
};
|
|
25613
|
-
case "mimetype":
|
|
25614
|
-
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25615
|
-
return {};
|
|
25616
|
-
}
|
|
25617
|
-
return {
|
|
25618
|
-
async handler(fileData) {
|
|
25619
|
-
const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
|
|
25620
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
25621
|
-
},
|
|
25622
|
-
stop: true
|
|
25623
|
-
};
|
|
25624
|
-
case "[Content_Types].xml": {
|
|
25625
|
-
openXmlState.hasContentTypesEntry = true;
|
|
25626
|
-
if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
|
|
25627
|
-
openXmlState.hasUnparseableContentTypes = true;
|
|
25628
|
-
return {};
|
|
25629
|
-
}
|
|
25630
|
-
openXmlState.isParsingContentTypes = true;
|
|
25631
|
-
return {
|
|
25632
|
-
async handler(fileData) {
|
|
25633
|
-
const xmlContent = new TextDecoder("utf-8").decode(fileData);
|
|
25634
|
-
const mimeType = getOpenXmlMimeTypeFromContentTypesXml(xmlContent);
|
|
25635
|
-
if (mimeType) {
|
|
25636
|
-
fileType = getFileTypeFromMimeType(mimeType);
|
|
25637
|
-
}
|
|
25638
|
-
openXmlState.hasParsedContentTypesEntry = true;
|
|
25639
|
-
openXmlState.isParsingContentTypes = false;
|
|
25640
|
-
},
|
|
25641
|
-
stop: true
|
|
25642
|
-
};
|
|
25643
|
-
}
|
|
25644
|
-
default:
|
|
25645
|
-
if (/classes\d*\.dex/.test(zipHeader.filename)) {
|
|
25646
|
-
fileType = {
|
|
25647
|
-
ext: "apk",
|
|
25648
|
-
mime: "application/vnd.android.package-archive"
|
|
25649
|
-
};
|
|
25650
|
-
return { stop: true };
|
|
25651
|
-
}
|
|
25652
|
-
return {};
|
|
25653
|
-
}
|
|
25654
|
-
});
|
|
25655
|
-
} catch (error) {
|
|
25656
|
-
if (!isRecoverableZipError(error)) {
|
|
25657
|
-
throw error;
|
|
25658
|
-
}
|
|
25659
|
-
if (openXmlState.isParsingContentTypes) {
|
|
25660
|
-
openXmlState.isParsingContentTypes = false;
|
|
25661
|
-
openXmlState.hasUnparseableContentTypes = true;
|
|
25662
|
-
}
|
|
25663
|
-
}
|
|
25664
|
-
return fileType ?? getOpenXmlFileTypeFromZipEntries(openXmlState) ?? {
|
|
25665
|
-
ext: "zip",
|
|
25666
|
-
mime: "application/zip"
|
|
25667
|
-
};
|
|
26310
|
+
return detectZip(tokenizer);
|
|
25668
26311
|
}
|
|
25669
26312
|
if (this.checkString("OggS")) {
|
|
25670
26313
|
await tokenizer.ignore(28);
|
|
25671
26314
|
const type = new Uint8Array(8);
|
|
25672
26315
|
await tokenizer.readBuffer(type);
|
|
25673
|
-
if (
|
|
26316
|
+
if (checkBytes(type, [79, 112, 117, 115, 72, 101, 97, 100])) {
|
|
25674
26317
|
return {
|
|
25675
26318
|
ext: "opus",
|
|
25676
26319
|
mime: "audio/ogg; codecs=opus"
|
|
25677
26320
|
};
|
|
25678
26321
|
}
|
|
25679
|
-
if (
|
|
26322
|
+
if (checkBytes(type, [128, 116, 104, 101, 111, 114, 97])) {
|
|
25680
26323
|
return {
|
|
25681
26324
|
ext: "ogv",
|
|
25682
26325
|
mime: "video/ogg"
|
|
25683
26326
|
};
|
|
25684
26327
|
}
|
|
25685
|
-
if (
|
|
26328
|
+
if (checkBytes(type, [1, 118, 105, 100, 101, 111, 0])) {
|
|
25686
26329
|
return {
|
|
25687
26330
|
ext: "ogm",
|
|
25688
26331
|
mime: "video/ogg"
|
|
25689
26332
|
};
|
|
25690
26333
|
}
|
|
25691
|
-
if (
|
|
26334
|
+
if (checkBytes(type, [127, 70, 76, 65, 67])) {
|
|
25692
26335
|
return {
|
|
25693
26336
|
ext: "oga",
|
|
25694
26337
|
mime: "audio/ogg"
|
|
25695
26338
|
};
|
|
25696
26339
|
}
|
|
25697
|
-
if (
|
|
26340
|
+
if (checkBytes(type, [83, 112, 101, 101, 120, 32, 32])) {
|
|
25698
26341
|
return {
|
|
25699
26342
|
ext: "spx",
|
|
25700
26343
|
mime: "audio/ogg"
|
|
25701
26344
|
};
|
|
25702
26345
|
}
|
|
25703
|
-
if (
|
|
26346
|
+
if (checkBytes(type, [1, 118, 111, 114, 98, 105, 115])) {
|
|
25704
26347
|
return {
|
|
25705
26348
|
ext: "ogg",
|
|
25706
26349
|
mime: "audio/ogg"
|
|
@@ -25750,7 +26393,7 @@ class FileTypeParser {
|
|
|
25750
26393
|
if (this.checkString("LZIP")) {
|
|
25751
26394
|
return {
|
|
25752
26395
|
ext: "lz",
|
|
25753
|
-
mime: "application/
|
|
26396
|
+
mime: "application/lzip"
|
|
25754
26397
|
};
|
|
25755
26398
|
}
|
|
25756
26399
|
if (this.checkString("fLaC")) {
|
|
@@ -25802,83 +26445,7 @@ class FileTypeParser {
|
|
|
25802
26445
|
};
|
|
25803
26446
|
}
|
|
25804
26447
|
if (this.check([26, 69, 223, 163])) {
|
|
25805
|
-
|
|
25806
|
-
const msb = await tokenizer.peekNumber(UINT8);
|
|
25807
|
-
let mask = 128;
|
|
25808
|
-
let ic = 0;
|
|
25809
|
-
while ((msb & mask) === 0 && mask !== 0) {
|
|
25810
|
-
++ic;
|
|
25811
|
-
mask >>= 1;
|
|
25812
|
-
}
|
|
25813
|
-
const id = new Uint8Array(ic + 1);
|
|
25814
|
-
await safeReadBuffer(tokenizer, id, undefined, {
|
|
25815
|
-
maximumLength: id.length,
|
|
25816
|
-
reason: "EBML field"
|
|
25817
|
-
});
|
|
25818
|
-
return id;
|
|
25819
|
-
}
|
|
25820
|
-
async function readElement() {
|
|
25821
|
-
const idField = await readField();
|
|
25822
|
-
const lengthField = await readField();
|
|
25823
|
-
lengthField[0] ^= 128 >> lengthField.length - 1;
|
|
25824
|
-
const nrLength = Math.min(6, lengthField.length);
|
|
25825
|
-
const idView = new DataView(idField.buffer);
|
|
25826
|
-
const lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);
|
|
25827
|
-
return {
|
|
25828
|
-
id: getUintBE(idView),
|
|
25829
|
-
len: getUintBE(lengthView)
|
|
25830
|
-
};
|
|
25831
|
-
}
|
|
25832
|
-
async function readChildren(children) {
|
|
25833
|
-
let ebmlElementCount = 0;
|
|
25834
|
-
while (children > 0) {
|
|
25835
|
-
ebmlElementCount++;
|
|
25836
|
-
if (ebmlElementCount > maximumEbmlElementCount) {
|
|
25837
|
-
return;
|
|
25838
|
-
}
|
|
25839
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, ebmlScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
25840
|
-
return;
|
|
25841
|
-
}
|
|
25842
|
-
const previousPosition = tokenizer.position;
|
|
25843
|
-
const element = await readElement();
|
|
25844
|
-
if (element.id === 17026) {
|
|
25845
|
-
if (element.len > maximumEbmlDocumentTypeSizeInBytes) {
|
|
25846
|
-
return;
|
|
25847
|
-
}
|
|
25848
|
-
const documentTypeLength = getSafeBound(element.len, maximumEbmlDocumentTypeSizeInBytes, "EBML DocType");
|
|
25849
|
-
const rawValue = await tokenizer.readToken(new StringType2(documentTypeLength));
|
|
25850
|
-
return rawValue.replaceAll(/\00.*$/g, "");
|
|
25851
|
-
}
|
|
25852
|
-
if (hasUnknownFileSize(tokenizer) && (!Number.isFinite(element.len) || element.len < 0 || element.len > maximumEbmlElementPayloadSizeInBytes)) {
|
|
25853
|
-
return;
|
|
25854
|
-
}
|
|
25855
|
-
await safeIgnore(tokenizer, element.len, {
|
|
25856
|
-
maximumLength: hasUnknownFileSize(tokenizer) ? maximumEbmlElementPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
25857
|
-
reason: "EBML payload"
|
|
25858
|
-
});
|
|
25859
|
-
--children;
|
|
25860
|
-
if (tokenizer.position <= previousPosition) {
|
|
25861
|
-
return;
|
|
25862
|
-
}
|
|
25863
|
-
}
|
|
25864
|
-
}
|
|
25865
|
-
const rootElement = await readElement();
|
|
25866
|
-
const ebmlScanStart = tokenizer.position;
|
|
25867
|
-
const documentType = await readChildren(rootElement.len);
|
|
25868
|
-
switch (documentType) {
|
|
25869
|
-
case "webm":
|
|
25870
|
-
return {
|
|
25871
|
-
ext: "webm",
|
|
25872
|
-
mime: "video/webm"
|
|
25873
|
-
};
|
|
25874
|
-
case "matroska":
|
|
25875
|
-
return {
|
|
25876
|
-
ext: "mkv",
|
|
25877
|
-
mime: "video/matroska"
|
|
25878
|
-
};
|
|
25879
|
-
default:
|
|
25880
|
-
return;
|
|
25881
|
-
}
|
|
26448
|
+
return detectEbml(tokenizer);
|
|
25882
26449
|
}
|
|
25883
26450
|
if (this.checkString("SQLi")) {
|
|
25884
26451
|
return {
|
|
@@ -25982,7 +26549,7 @@ class FileTypeParser {
|
|
|
25982
26549
|
mime: "audio/amr"
|
|
25983
26550
|
};
|
|
25984
26551
|
}
|
|
25985
|
-
if (this.checkString(
|
|
26552
|
+
if (this.checkString(String.raw`{\rtf`)) {
|
|
25986
26553
|
return {
|
|
25987
26554
|
ext: "rtf",
|
|
25988
26555
|
mime: "application/rtf"
|
|
@@ -26051,7 +26618,7 @@ class FileTypeParser {
|
|
|
26051
26618
|
if (this.checkString("DRACO")) {
|
|
26052
26619
|
return {
|
|
26053
26620
|
ext: "drc",
|
|
26054
|
-
mime: "application/
|
|
26621
|
+
mime: "application/x-ft-draco"
|
|
26055
26622
|
};
|
|
26056
26623
|
}
|
|
26057
26624
|
if (this.check([253, 55, 122, 88, 90, 0])) {
|
|
@@ -26086,7 +26653,7 @@ class FileTypeParser {
|
|
|
26086
26653
|
}
|
|
26087
26654
|
if (this.checkString("AC")) {
|
|
26088
26655
|
const version = new StringType2(4, "latin1").get(this.buffer, 2);
|
|
26089
|
-
if (
|
|
26656
|
+
if (/^\d+$/v.test(version) && version >= 1000 && version <= 1050) {
|
|
26090
26657
|
return {
|
|
26091
26658
|
ext: "dwg",
|
|
26092
26659
|
mime: "image/vnd.dwg"
|
|
@@ -26126,73 +26693,7 @@ class FileTypeParser {
|
|
|
26126
26693
|
};
|
|
26127
26694
|
}
|
|
26128
26695
|
if (this.check([137, 80, 78, 71, 13, 10, 26, 10])) {
|
|
26129
|
-
|
|
26130
|
-
ext: "png",
|
|
26131
|
-
mime: "image/png"
|
|
26132
|
-
};
|
|
26133
|
-
const apngFileType = {
|
|
26134
|
-
ext: "apng",
|
|
26135
|
-
mime: "image/apng"
|
|
26136
|
-
};
|
|
26137
|
-
await tokenizer.ignore(8);
|
|
26138
|
-
async function readChunkHeader() {
|
|
26139
|
-
return {
|
|
26140
|
-
length: await tokenizer.readToken(INT32_BE),
|
|
26141
|
-
type: await tokenizer.readToken(new StringType2(4, "latin1"))
|
|
26142
|
-
};
|
|
26143
|
-
}
|
|
26144
|
-
const isUnknownPngStream = hasUnknownFileSize(tokenizer);
|
|
26145
|
-
const pngScanStart = tokenizer.position;
|
|
26146
|
-
let pngChunkCount = 0;
|
|
26147
|
-
let hasSeenImageHeader = false;
|
|
26148
|
-
do {
|
|
26149
|
-
pngChunkCount++;
|
|
26150
|
-
if (pngChunkCount > maximumPngChunkCount) {
|
|
26151
|
-
break;
|
|
26152
|
-
}
|
|
26153
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngStreamScanBudgetInBytes)) {
|
|
26154
|
-
break;
|
|
26155
|
-
}
|
|
26156
|
-
const previousPosition = tokenizer.position;
|
|
26157
|
-
const chunk = await readChunkHeader();
|
|
26158
|
-
if (chunk.length < 0) {
|
|
26159
|
-
return;
|
|
26160
|
-
}
|
|
26161
|
-
if (chunk.type === "IHDR") {
|
|
26162
|
-
if (chunk.length !== 13) {
|
|
26163
|
-
return;
|
|
26164
|
-
}
|
|
26165
|
-
hasSeenImageHeader = true;
|
|
26166
|
-
}
|
|
26167
|
-
switch (chunk.type) {
|
|
26168
|
-
case "IDAT":
|
|
26169
|
-
return pngFileType;
|
|
26170
|
-
case "acTL":
|
|
26171
|
-
return apngFileType;
|
|
26172
|
-
default:
|
|
26173
|
-
if (!hasSeenImageHeader && chunk.type !== "CgBI") {
|
|
26174
|
-
return;
|
|
26175
|
-
}
|
|
26176
|
-
if (isUnknownPngStream && chunk.length > maximumPngChunkSizeInBytes) {
|
|
26177
|
-
return hasSeenImageHeader && isPngAncillaryChunk(chunk.type) ? pngFileType : undefined;
|
|
26178
|
-
}
|
|
26179
|
-
try {
|
|
26180
|
-
await safeIgnore(tokenizer, chunk.length + 4, {
|
|
26181
|
-
maximumLength: isUnknownPngStream ? maximumPngChunkSizeInBytes + 4 : tokenizer.fileInfo.size,
|
|
26182
|
-
reason: "PNG chunk payload"
|
|
26183
|
-
});
|
|
26184
|
-
} catch (error) {
|
|
26185
|
-
if (!isUnknownPngStream && (error instanceof ParserHardLimitError || error instanceof EndOfStreamError)) {
|
|
26186
|
-
return pngFileType;
|
|
26187
|
-
}
|
|
26188
|
-
throw error;
|
|
26189
|
-
}
|
|
26190
|
-
}
|
|
26191
|
-
if (tokenizer.position <= previousPosition) {
|
|
26192
|
-
break;
|
|
26193
|
-
}
|
|
26194
|
-
} while (tokenizer.position + 8 < tokenizer.fileInfo.size);
|
|
26195
|
-
return pngFileType;
|
|
26696
|
+
return detectPng(tokenizer);
|
|
26196
26697
|
}
|
|
26197
26698
|
if (this.check([65, 82, 82, 79, 87, 49, 0, 0])) {
|
|
26198
26699
|
return {
|
|
@@ -26311,90 +26812,7 @@ class FileTypeParser {
|
|
|
26311
26812
|
};
|
|
26312
26813
|
}
|
|
26313
26814
|
if (this.check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) {
|
|
26314
|
-
|
|
26315
|
-
try {
|
|
26316
|
-
async function readHeader() {
|
|
26317
|
-
const guid = new Uint8Array(16);
|
|
26318
|
-
await safeReadBuffer(tokenizer, guid, undefined, {
|
|
26319
|
-
maximumLength: guid.length,
|
|
26320
|
-
reason: "ASF header GUID"
|
|
26321
|
-
});
|
|
26322
|
-
return {
|
|
26323
|
-
id: guid,
|
|
26324
|
-
size: Number(await tokenizer.readToken(UINT64_LE))
|
|
26325
|
-
};
|
|
26326
|
-
}
|
|
26327
|
-
await safeIgnore(tokenizer, 30, {
|
|
26328
|
-
maximumLength: 30,
|
|
26329
|
-
reason: "ASF header prelude"
|
|
26330
|
-
});
|
|
26331
|
-
const isUnknownFileSize = hasUnknownFileSize(tokenizer);
|
|
26332
|
-
const asfHeaderScanStart = tokenizer.position;
|
|
26333
|
-
let asfHeaderObjectCount = 0;
|
|
26334
|
-
while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
|
|
26335
|
-
asfHeaderObjectCount++;
|
|
26336
|
-
if (asfHeaderObjectCount > maximumAsfHeaderObjectCount) {
|
|
26337
|
-
break;
|
|
26338
|
-
}
|
|
26339
|
-
if (hasExceededUnknownSizeScanBudget(tokenizer, asfHeaderScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
26340
|
-
break;
|
|
26341
|
-
}
|
|
26342
|
-
const previousPosition = tokenizer.position;
|
|
26343
|
-
const header = await readHeader();
|
|
26344
|
-
let payload = header.size - 24;
|
|
26345
|
-
if (!Number.isFinite(payload) || payload < 0) {
|
|
26346
|
-
isMalformedAsf = true;
|
|
26347
|
-
break;
|
|
26348
|
-
}
|
|
26349
|
-
if (_check(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
|
|
26350
|
-
const typeId = new Uint8Array(16);
|
|
26351
|
-
payload -= await safeReadBuffer(tokenizer, typeId, undefined, {
|
|
26352
|
-
maximumLength: typeId.length,
|
|
26353
|
-
reason: "ASF stream type GUID"
|
|
26354
|
-
});
|
|
26355
|
-
if (_check(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
26356
|
-
return {
|
|
26357
|
-
ext: "asf",
|
|
26358
|
-
mime: "audio/x-ms-asf"
|
|
26359
|
-
};
|
|
26360
|
-
}
|
|
26361
|
-
if (_check(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
|
|
26362
|
-
return {
|
|
26363
|
-
ext: "asf",
|
|
26364
|
-
mime: "video/x-ms-asf"
|
|
26365
|
-
};
|
|
26366
|
-
}
|
|
26367
|
-
break;
|
|
26368
|
-
}
|
|
26369
|
-
if (isUnknownFileSize && payload > maximumAsfHeaderPayloadSizeInBytes) {
|
|
26370
|
-
isMalformedAsf = true;
|
|
26371
|
-
break;
|
|
26372
|
-
}
|
|
26373
|
-
await safeIgnore(tokenizer, payload, {
|
|
26374
|
-
maximumLength: isUnknownFileSize ? maximumAsfHeaderPayloadSizeInBytes : tokenizer.fileInfo.size,
|
|
26375
|
-
reason: "ASF header payload"
|
|
26376
|
-
});
|
|
26377
|
-
if (tokenizer.position <= previousPosition) {
|
|
26378
|
-
isMalformedAsf = true;
|
|
26379
|
-
break;
|
|
26380
|
-
}
|
|
26381
|
-
}
|
|
26382
|
-
} catch (error) {
|
|
26383
|
-
if (error instanceof EndOfStreamError || error instanceof ParserHardLimitError) {
|
|
26384
|
-
if (hasUnknownFileSize(tokenizer)) {
|
|
26385
|
-
isMalformedAsf = true;
|
|
26386
|
-
}
|
|
26387
|
-
} else {
|
|
26388
|
-
throw error;
|
|
26389
|
-
}
|
|
26390
|
-
}
|
|
26391
|
-
if (isMalformedAsf) {
|
|
26392
|
-
return;
|
|
26393
|
-
}
|
|
26394
|
-
return {
|
|
26395
|
-
ext: "asf",
|
|
26396
|
-
mime: "application/vnd.ms-asf"
|
|
26397
|
-
};
|
|
26815
|
+
return detectAsf(tokenizer);
|
|
26398
26816
|
}
|
|
26399
26817
|
if (this.check([171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10])) {
|
|
26400
26818
|
return {
|
|
@@ -26569,19 +26987,19 @@ class FileTypeParser {
|
|
|
26569
26987
|
if (this.check([76, 0, 0, 0, 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70])) {
|
|
26570
26988
|
return {
|
|
26571
26989
|
ext: "lnk",
|
|
26572
|
-
mime: "application/x
|
|
26990
|
+
mime: "application/x-ms-shortcut"
|
|
26573
26991
|
};
|
|
26574
26992
|
}
|
|
26575
26993
|
if (this.check([98, 111, 111, 107, 0, 0, 0, 0, 109, 97, 114, 107, 0, 0, 0, 0])) {
|
|
26576
26994
|
return {
|
|
26577
26995
|
ext: "alias",
|
|
26578
|
-
mime: "application/x
|
|
26996
|
+
mime: "application/x-ft-apple.alias"
|
|
26579
26997
|
};
|
|
26580
26998
|
}
|
|
26581
26999
|
if (this.checkString("Kaydara FBX Binary \0")) {
|
|
26582
27000
|
return {
|
|
26583
27001
|
ext: "fbx",
|
|
26584
|
-
mime: "application/x
|
|
27002
|
+
mime: "application/x-ft-fbx"
|
|
26585
27003
|
};
|
|
26586
27004
|
}
|
|
26587
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 }))) {
|
|
@@ -26799,234 +27217,28 @@ class FileTypeParser {
|
|
|
26799
27217
|
}
|
|
26800
27218
|
}
|
|
26801
27219
|
}
|
|
26802
|
-
var reasonableDetectionSizeInBytes = 4100, maximumMpegOffsetTolerance,
|
|
26803
|
-
var
|
|
26804
|
-
|
|
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();
|
|
26805
27223
|
init_core();
|
|
26806
|
-
|
|
27224
|
+
init_lib3();
|
|
26807
27225
|
init_uint8array_extras();
|
|
26808
|
-
|
|
27226
|
+
init_tokens();
|
|
26809
27227
|
init_supported();
|
|
27228
|
+
init_parser();
|
|
27229
|
+
init_zip();
|
|
27230
|
+
init_ebml();
|
|
27231
|
+
init_png();
|
|
27232
|
+
init_asf();
|
|
26810
27233
|
maximumMpegOffsetTolerance = reasonableDetectionSizeInBytes - 2;
|
|
26811
|
-
maximumZipEntrySizeInBytes = 1024 * 1024;
|
|
26812
|
-
maximumZipBufferedReadSizeInBytes = 2 ** 31 - 1;
|
|
26813
|
-
maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
|
|
26814
|
-
maximumUnknownSizePayloadProbeSizeInBytes = maximumZipEntrySizeInBytes;
|
|
26815
|
-
maximumZipTextEntrySizeInBytes = maximumZipEntrySizeInBytes;
|
|
26816
27234
|
maximumNestedGzipDetectionSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
26817
27235
|
maximumId3HeaderSizeInBytes = maximumUntrustedSkipSizeInBytes;
|
|
26818
|
-
|
|
26819
|
-
maximumPngStreamScanBudgetInBytes = maximumUntrustedSkipSizeInBytes;
|
|
26820
|
-
maximumPngChunkSizeInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
26821
|
-
maximumAsfHeaderPayloadSizeInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
26822
|
-
maximumTiffStreamIfdOffsetInBytes = maximumUnknownSizePayloadProbeSizeInBytes;
|
|
27236
|
+
maximumTiffStreamIfdOffsetInBytes = 1024 * 1024;
|
|
26823
27237
|
maximumTiffIfdOffsetInBytes = maximumUntrustedSkipSizeInBytes;
|
|
26824
|
-
recoverableZipErrorMessages = new Set([
|
|
26825
|
-
"Unexpected signature",
|
|
26826
|
-
"Encrypted ZIP",
|
|
26827
|
-
"Expected Central-File-Header signature"
|
|
26828
|
-
]);
|
|
26829
|
-
recoverableZipErrorMessagePrefixes = [
|
|
26830
|
-
"ZIP entry count exceeds ",
|
|
26831
|
-
"Unsupported ZIP compression method:",
|
|
26832
|
-
"ZIP entry compressed data exceeds ",
|
|
26833
|
-
"ZIP entry decompressed data exceeds ",
|
|
26834
|
-
"Expected data-descriptor-signature at position "
|
|
26835
|
-
];
|
|
26836
|
-
recoverableZipErrorCodes = new Set([
|
|
26837
|
-
"Z_BUF_ERROR",
|
|
26838
|
-
"Z_DATA_ERROR",
|
|
26839
|
-
"ERR_INVALID_STATE"
|
|
26840
|
-
]);
|
|
26841
|
-
ParserHardLimitError = class ParserHardLimitError extends Error {
|
|
26842
|
-
};
|
|
26843
|
-
zipDataDescriptorOverlapLengthInBytes = zipDataDescriptorLengthInBytes - 1;
|
|
26844
|
-
ZipHandler.prototype.inflate = async function(zipHeader, fileData, callback) {
|
|
26845
|
-
if (zipHeader.compressedMethod === 0) {
|
|
26846
|
-
return callback(fileData);
|
|
26847
|
-
}
|
|
26848
|
-
if (zipHeader.compressedMethod !== 8) {
|
|
26849
|
-
throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
|
|
26850
|
-
}
|
|
26851
|
-
const uncompressedData = await decompressDeflateRawWithLimit(fileData, { maximumLength: maximumZipEntrySizeInBytes });
|
|
26852
|
-
return callback(uncompressedData);
|
|
26853
|
-
};
|
|
26854
|
-
ZipHandler.prototype.unzip = async function(fileCallback) {
|
|
26855
|
-
let stop = false;
|
|
26856
|
-
let zipEntryCount = 0;
|
|
26857
|
-
const zipScanStart = this.tokenizer.position;
|
|
26858
|
-
this.knownSizeDescriptorScannedBytes = 0;
|
|
26859
|
-
do {
|
|
26860
|
-
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
26861
|
-
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
26862
|
-
}
|
|
26863
|
-
const zipHeader = await this.readLocalFileHeader();
|
|
26864
|
-
if (!zipHeader) {
|
|
26865
|
-
break;
|
|
26866
|
-
}
|
|
26867
|
-
zipEntryCount++;
|
|
26868
|
-
if (zipEntryCount > maximumZipEntryCount) {
|
|
26869
|
-
throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
|
|
26870
|
-
}
|
|
26871
|
-
const next = fileCallback(zipHeader);
|
|
26872
|
-
stop = Boolean(next.stop);
|
|
26873
|
-
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
26874
|
-
const fileData = await readZipEntryData(this, zipHeader, {
|
|
26875
|
-
shouldBuffer: Boolean(next.handler),
|
|
26876
|
-
maximumDescriptorLength: Math.min(maximumZipEntrySizeInBytes, getRemainingZipScanBudget(this, zipScanStart))
|
|
26877
|
-
});
|
|
26878
|
-
if (next.handler) {
|
|
26879
|
-
await this.inflate(zipHeader, fileData, next.handler);
|
|
26880
|
-
}
|
|
26881
|
-
if (zipHeader.dataDescriptor) {
|
|
26882
|
-
const dataDescriptor = new Uint8Array(zipDataDescriptorLengthInBytes);
|
|
26883
|
-
await this.tokenizer.readBuffer(dataDescriptor);
|
|
26884
|
-
if (UINT32_LE.get(dataDescriptor, 0) !== zipDataDescriptorSignature) {
|
|
26885
|
-
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - dataDescriptor.length}`);
|
|
26886
|
-
}
|
|
26887
|
-
}
|
|
26888
|
-
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
26889
|
-
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
26890
|
-
}
|
|
26891
|
-
} while (!stop);
|
|
26892
|
-
};
|
|
26893
27238
|
supportedExtensions = new Set(extensions);
|
|
26894
27239
|
supportedMimeTypes = new Set(mimeTypes);
|
|
26895
27240
|
});
|
|
26896
27241
|
|
|
26897
|
-
// ../../node_modules/file-type/index.js
|
|
26898
|
-
var exports_file_type = {};
|
|
26899
|
-
__export(exports_file_type, {
|
|
26900
|
-
supportedMimeTypes: () => supportedMimeTypes,
|
|
26901
|
-
supportedExtensions: () => supportedExtensions,
|
|
26902
|
-
fileTypeStream: () => fileTypeStream,
|
|
26903
|
-
fileTypeFromTokenizer: () => fileTypeFromTokenizer,
|
|
26904
|
-
fileTypeFromStream: () => fileTypeFromStream,
|
|
26905
|
-
fileTypeFromFile: () => fileTypeFromFile,
|
|
26906
|
-
fileTypeFromBuffer: () => fileTypeFromBuffer,
|
|
26907
|
-
fileTypeFromBlob: () => fileTypeFromBlob,
|
|
26908
|
-
FileTypeParser: () => FileTypeParser2
|
|
26909
|
-
});
|
|
26910
|
-
import { ReadableStream as WebReadableStream } from "node:stream/web";
|
|
26911
|
-
import { pipeline, PassThrough, Readable } from "node:stream";
|
|
26912
|
-
import fs from "node:fs/promises";
|
|
26913
|
-
import { constants as fileSystemConstants } from "node:fs";
|
|
26914
|
-
function isTokenizerStreamBoundsError(error) {
|
|
26915
|
-
if (!(error instanceof RangeError) || error.message !== "offset is out of bounds" || typeof error.stack !== "string") {
|
|
26916
|
-
return false;
|
|
26917
|
-
}
|
|
26918
|
-
return /strtok3[/\\]lib[/\\]stream[/\\]/.test(error.stack);
|
|
26919
|
-
}
|
|
26920
|
-
async function fileTypeFromFile(path, options) {
|
|
26921
|
-
return new FileTypeParser2(options).fromFile(path, options);
|
|
26922
|
-
}
|
|
26923
|
-
async function fileTypeFromStream(stream, options) {
|
|
26924
|
-
return new FileTypeParser2(options).fromStream(stream);
|
|
26925
|
-
}
|
|
26926
|
-
async function fileTypeStream(readableStream, options = {}) {
|
|
26927
|
-
return new FileTypeParser2(options).toDetectionStream(readableStream, options);
|
|
26928
|
-
}
|
|
26929
|
-
var FileTypeParser2;
|
|
26930
|
-
var init_file_type = __esm(() => {
|
|
26931
|
-
init_lib();
|
|
26932
|
-
init_core2();
|
|
26933
|
-
init_core2();
|
|
26934
|
-
FileTypeParser2 = class FileTypeParser2 extends FileTypeParser {
|
|
26935
|
-
async fromStream(stream) {
|
|
26936
|
-
this.options.signal?.throwIfAborted();
|
|
26937
|
-
const tokenizer = await (stream instanceof WebReadableStream ? this.createTokenizerFromWebStream(stream) : fromStream2(stream, this.getTokenizerOptions()));
|
|
26938
|
-
try {
|
|
26939
|
-
return await super.fromTokenizer(tokenizer);
|
|
26940
|
-
} catch (error) {
|
|
26941
|
-
if (isTokenizerStreamBoundsError(error)) {
|
|
26942
|
-
return;
|
|
26943
|
-
}
|
|
26944
|
-
throw error;
|
|
26945
|
-
} finally {
|
|
26946
|
-
if (stream instanceof Readable && !stream.destroyed) {
|
|
26947
|
-
stream.destroy();
|
|
26948
|
-
}
|
|
26949
|
-
}
|
|
26950
|
-
}
|
|
26951
|
-
async fromFile(path) {
|
|
26952
|
-
this.options.signal?.throwIfAborted();
|
|
26953
|
-
const fileHandle = await fs.open(path, fileSystemConstants.O_RDONLY | fileSystemConstants.O_NONBLOCK);
|
|
26954
|
-
const fileStat = await fileHandle.stat();
|
|
26955
|
-
if (!fileStat.isFile()) {
|
|
26956
|
-
await fileHandle.close();
|
|
26957
|
-
return;
|
|
26958
|
-
}
|
|
26959
|
-
const tokenizer = new FileTokenizer(fileHandle, {
|
|
26960
|
-
...this.getTokenizerOptions(),
|
|
26961
|
-
fileInfo: {
|
|
26962
|
-
path,
|
|
26963
|
-
size: fileStat.size
|
|
26964
|
-
}
|
|
26965
|
-
});
|
|
26966
|
-
return super.fromTokenizer(tokenizer);
|
|
26967
|
-
}
|
|
26968
|
-
async toDetectionStream(readableStream, options = {}) {
|
|
26969
|
-
if (!(readableStream instanceof Readable)) {
|
|
26970
|
-
return super.toDetectionStream(readableStream, options);
|
|
26971
|
-
}
|
|
26972
|
-
const { sampleSize = reasonableDetectionSizeInBytes } = options;
|
|
26973
|
-
const { signal } = this.options;
|
|
26974
|
-
const normalizedSampleSize = normalizeSampleSize(sampleSize);
|
|
26975
|
-
signal?.throwIfAborted();
|
|
26976
|
-
return new Promise((resolve3, reject) => {
|
|
26977
|
-
let isSettled = false;
|
|
26978
|
-
const cleanup = () => {
|
|
26979
|
-
readableStream.off("error", onError);
|
|
26980
|
-
readableStream.off("readable", onReadable);
|
|
26981
|
-
signal?.removeEventListener("abort", onAbort);
|
|
26982
|
-
};
|
|
26983
|
-
const settle = (callback, value) => {
|
|
26984
|
-
if (isSettled) {
|
|
26985
|
-
return;
|
|
26986
|
-
}
|
|
26987
|
-
isSettled = true;
|
|
26988
|
-
cleanup();
|
|
26989
|
-
callback(value);
|
|
26990
|
-
};
|
|
26991
|
-
const onError = (error) => {
|
|
26992
|
-
settle(reject, error);
|
|
26993
|
-
};
|
|
26994
|
-
const onAbort = () => {
|
|
26995
|
-
if (!readableStream.destroyed) {
|
|
26996
|
-
readableStream.destroy();
|
|
26997
|
-
}
|
|
26998
|
-
settle(reject, signal.reason);
|
|
26999
|
-
};
|
|
27000
|
-
const onReadable = () => {
|
|
27001
|
-
(async () => {
|
|
27002
|
-
try {
|
|
27003
|
-
const pass = new PassThrough;
|
|
27004
|
-
const outputStream = pipeline ? pipeline(readableStream, pass, () => {
|
|
27005
|
-
}) : readableStream.pipe(pass);
|
|
27006
|
-
const chunk = readableStream.read(normalizedSampleSize) ?? readableStream.read() ?? new Uint8Array(0);
|
|
27007
|
-
try {
|
|
27008
|
-
pass.fileType = await this.fromBuffer(chunk);
|
|
27009
|
-
} catch (error) {
|
|
27010
|
-
if (error instanceof EndOfStreamError) {
|
|
27011
|
-
pass.fileType = undefined;
|
|
27012
|
-
} else {
|
|
27013
|
-
settle(reject, error);
|
|
27014
|
-
}
|
|
27015
|
-
}
|
|
27016
|
-
settle(resolve3, outputStream);
|
|
27017
|
-
} catch (error) {
|
|
27018
|
-
settle(reject, error);
|
|
27019
|
-
}
|
|
27020
|
-
})();
|
|
27021
|
-
};
|
|
27022
|
-
readableStream.on("error", onError);
|
|
27023
|
-
readableStream.once("readable", onReadable);
|
|
27024
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
27025
|
-
});
|
|
27026
|
-
}
|
|
27027
|
-
};
|
|
27028
|
-
});
|
|
27029
|
-
|
|
27030
27242
|
// ../../node_modules/cookie/dist/index.js
|
|
27031
27243
|
var require_dist3 = __commonJS((exports) => {
|
|
27032
27244
|
function parseCookie(str, options) {
|
|
@@ -27278,7 +27490,7 @@ var import_chokidar = __toESM(require_chokidar(), 1);
|
|
|
27278
27490
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
27279
27491
|
import { spawn, spawnSync } from "node:child_process";
|
|
27280
27492
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
27281
|
-
import * as
|
|
27493
|
+
import * as fs from "node:fs/promises";
|
|
27282
27494
|
import path from "node:path";
|
|
27283
27495
|
import { TextDecoder as TextDecoder2 } from "node:util";
|
|
27284
27496
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -28864,7 +29076,7 @@ class DoneLocalChain {
|
|
|
28864
29076
|
buildEnv(address, override) {
|
|
28865
29077
|
const block = {
|
|
28866
29078
|
height: this.blockHeight,
|
|
28867
|
-
time: this.blockTime.toString(),
|
|
29079
|
+
time: (BigInt(this.blockTime) * 1000000000n).toString(),
|
|
28868
29080
|
chain_id: this.chainId
|
|
28869
29081
|
};
|
|
28870
29082
|
if (override?.block) {
|
|
@@ -36783,7 +36995,7 @@ var _fileTypeFromBlobWarn = false;
|
|
|
36783
36995
|
var warnIfFileTypeIsNotInstalled = () => {
|
|
36784
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);
|
|
36785
36997
|
};
|
|
36786
|
-
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);
|
|
36787
36999
|
var _fileTypeFromBlob;
|
|
36788
37000
|
var fileTypeFromBlob2 = (file) => _fileTypeFromBlob ? _fileTypeFromBlob(file) : loadFileType().then((mod) => {
|
|
36789
37001
|
if (mod)
|
|
@@ -43545,7 +43757,7 @@ var sharedRouteSchemas = {
|
|
|
43545
43757
|
};
|
|
43546
43758
|
// ../done-http-local/src/server.ts
|
|
43547
43759
|
async function createDoneHttpLocalServer(config, chain) {
|
|
43548
|
-
const runtime = chain ??
|
|
43760
|
+
const runtime = chain ?? new DoneLocalChain;
|
|
43549
43761
|
if (config.scriptPath) {
|
|
43550
43762
|
await deployJsContract({
|
|
43551
43763
|
chain: runtime,
|
|
@@ -44061,7 +44273,7 @@ async function handleBuild(options) {
|
|
|
44061
44273
|
const entryPath = path.resolve(manifestInfo.manifestDir, contract.entry);
|
|
44062
44274
|
const outFilePath = path.resolve(manifestInfo.manifestDir, contract.outFile);
|
|
44063
44275
|
await ensureEntryExists(entryPath, contract.name);
|
|
44064
|
-
await
|
|
44276
|
+
await fs.mkdir(path.dirname(outFilePath), { recursive: true });
|
|
44065
44277
|
const relEntry = path.relative(process.cwd(), entryPath) || entryPath;
|
|
44066
44278
|
const relOutFile = path.relative(process.cwd(), outFilePath) || outFilePath;
|
|
44067
44279
|
console.log(`- bundling ${contract.name} (${relEntry})`);
|
|
@@ -44079,7 +44291,7 @@ async function handleBuild(options) {
|
|
|
44079
44291
|
async function handlePublish(options) {
|
|
44080
44292
|
const scriptPath = path.resolve(process.cwd(), options.script);
|
|
44081
44293
|
await ensureFileExists(scriptPath, "script");
|
|
44082
|
-
const script = await
|
|
44294
|
+
const script = await fs.readFile(scriptPath, "utf8");
|
|
44083
44295
|
const msg = options.msg ? await loadMsgPayload(options.msg) : undefined;
|
|
44084
44296
|
const baseUrl = resolveDoneHttpBase(options.http);
|
|
44085
44297
|
const backend = new DoneBackendClient({ baseUrl });
|
|
@@ -44103,7 +44315,7 @@ async function detectWorkspace(root) {
|
|
|
44103
44315
|
if (!existsSync2(configPath)) {
|
|
44104
44316
|
return null;
|
|
44105
44317
|
}
|
|
44106
|
-
const configRaw = await
|
|
44318
|
+
const configRaw = await fs.readFile(configPath, "utf8");
|
|
44107
44319
|
const config2 = JSON.parse(configRaw);
|
|
44108
44320
|
const configuredManifestPath = config2.contractsFile ? path.isAbsolute(config2.contractsFile) ? config2.contractsFile : path.resolve(root, config2.contractsFile) : path.join(root, "done.json");
|
|
44109
44321
|
const fallbackManifestPath = path.join(root, "done.json");
|
|
@@ -44111,7 +44323,7 @@ async function detectWorkspace(root) {
|
|
|
44111
44323
|
if (!manifestPath) {
|
|
44112
44324
|
return null;
|
|
44113
44325
|
}
|
|
44114
|
-
const manifestRaw = await
|
|
44326
|
+
const manifestRaw = await fs.readFile(manifestPath, "utf8");
|
|
44115
44327
|
const manifest = JSON.parse(manifestRaw);
|
|
44116
44328
|
return { root, manifestPath, configPath, manifest, config: config2 };
|
|
44117
44329
|
}
|
|
@@ -44144,7 +44356,7 @@ async function findWorkspace(startDir) {
|
|
|
44144
44356
|
async function readManifest(manifestPath) {
|
|
44145
44357
|
let raw;
|
|
44146
44358
|
try {
|
|
44147
|
-
raw = await
|
|
44359
|
+
raw = await fs.readFile(manifestPath, "utf8");
|
|
44148
44360
|
} catch (error) {
|
|
44149
44361
|
if (error.code === "ENOENT") {
|
|
44150
44362
|
throw new Error(`Could not find ${manifestPath}. Pass a valid --contracts path or run from a Done workspace.`);
|
|
@@ -44168,7 +44380,7 @@ async function scaffoldWorkspace(rawName, options) {
|
|
|
44168
44380
|
await prepareTargetDir(targetDir, options.force === true);
|
|
44169
44381
|
const localTemplatePath = await resolveLocalTemplate(templateRef);
|
|
44170
44382
|
if (localTemplatePath) {
|
|
44171
|
-
await
|
|
44383
|
+
await fs.cp(localTemplatePath, targetDir, { recursive: true });
|
|
44172
44384
|
} else {
|
|
44173
44385
|
await runCommand("git", ["clone", "--depth", "1", templateRef, targetDir]);
|
|
44174
44386
|
}
|
|
@@ -44200,7 +44412,7 @@ async function scaffoldContract(workspace, rawName, options) {
|
|
|
44200
44412
|
const contractsDir = resolveContractsDir(workspace.root, workspace.config.contractsDir);
|
|
44201
44413
|
const contractDir = path.join(contractsDir, slug);
|
|
44202
44414
|
await ensureDirAvailable(contractDir, options.force === true);
|
|
44203
|
-
await
|
|
44415
|
+
await fs.mkdir(path.join(contractDir, "src"), { recursive: true });
|
|
44204
44416
|
const pkgJsonPath = path.join(contractDir, "package.json");
|
|
44205
44417
|
const pkgJson = {
|
|
44206
44418
|
name: slug,
|
|
@@ -44273,7 +44485,7 @@ export default Done.serve()
|
|
|
44273
44485
|
},
|
|
44274
44486
|
);
|
|
44275
44487
|
`;
|
|
44276
|
-
await
|
|
44488
|
+
await fs.writeFile(path.join(contractDir, "src", "index.ts"), contractSource, "utf8");
|
|
44277
44489
|
workspace.manifest.contracts ??= [];
|
|
44278
44490
|
const contractDirRel = normalizeJsonPath(path.relative(workspace.root, contractDir));
|
|
44279
44491
|
const entry = ensureDotSlash(`${contractDirRel}/src/index.ts`);
|
|
@@ -44304,7 +44516,7 @@ export default Done.serve()
|
|
|
44304
44516
|
async function resolveLocalTemplate(reference) {
|
|
44305
44517
|
const potentialPath = path.isAbsolute(reference) ? reference : path.resolve(process.cwd(), reference);
|
|
44306
44518
|
try {
|
|
44307
|
-
const stats = await
|
|
44519
|
+
const stats = await fs.stat(potentialPath);
|
|
44308
44520
|
if (stats.isDirectory()) {
|
|
44309
44521
|
return potentialPath;
|
|
44310
44522
|
}
|
|
@@ -44319,7 +44531,7 @@ async function prepareTargetDir(targetDir, force) {
|
|
|
44319
44531
|
if (!force) {
|
|
44320
44532
|
throw new Error(`Directory '${path.relative(process.cwd(), targetDir) || targetDir}' already exists. Use --force to overwrite.`);
|
|
44321
44533
|
}
|
|
44322
|
-
await
|
|
44534
|
+
await fs.rm(targetDir, { recursive: true, force: true });
|
|
44323
44535
|
}
|
|
44324
44536
|
async function ensureDirAvailable(targetDir, force) {
|
|
44325
44537
|
if (!existsSync2(targetDir)) {
|
|
@@ -44328,10 +44540,10 @@ async function ensureDirAvailable(targetDir, force) {
|
|
|
44328
44540
|
if (!force) {
|
|
44329
44541
|
throw new Error(`Directory '${path.relative(process.cwd(), targetDir) || targetDir}' already exists. Use --force to overwrite.`);
|
|
44330
44542
|
}
|
|
44331
|
-
await
|
|
44543
|
+
await fs.rm(targetDir, { recursive: true, force: true });
|
|
44332
44544
|
}
|
|
44333
44545
|
async function removeGitFolder(targetDir) {
|
|
44334
|
-
await
|
|
44546
|
+
await fs.rm(path.join(targetDir, ".git"), { recursive: true, force: true });
|
|
44335
44547
|
}
|
|
44336
44548
|
function resolveContractsDir(root, configured) {
|
|
44337
44549
|
if (!configured) {
|
|
@@ -44344,7 +44556,7 @@ function resolveContractsDir(root, configured) {
|
|
|
44344
44556
|
}
|
|
44345
44557
|
async function updatePackageJson(file2, mutator) {
|
|
44346
44558
|
try {
|
|
44347
|
-
const current = JSON.parse(await
|
|
44559
|
+
const current = JSON.parse(await fs.readFile(file2, "utf8"));
|
|
44348
44560
|
mutator(current);
|
|
44349
44561
|
await writeJson(file2, current);
|
|
44350
44562
|
} catch (error) {
|
|
@@ -44392,7 +44604,7 @@ async function syncWorkspaceDependencyVersions(targetDir) {
|
|
|
44392
44604
|
async function updateContractDependencyVersions(contractsDir) {
|
|
44393
44605
|
let entries;
|
|
44394
44606
|
try {
|
|
44395
|
-
entries = await
|
|
44607
|
+
entries = await fs.readdir(contractsDir, { withFileTypes: true });
|
|
44396
44608
|
} catch {
|
|
44397
44609
|
return;
|
|
44398
44610
|
}
|
|
@@ -44445,7 +44657,7 @@ function escapeRegExp(value) {
|
|
|
44445
44657
|
}
|
|
44446
44658
|
async function ensureEntryExists(entryPath, contractName) {
|
|
44447
44659
|
try {
|
|
44448
|
-
const stats = await
|
|
44660
|
+
const stats = await fs.stat(entryPath);
|
|
44449
44661
|
if (!stats.isFile()) {
|
|
44450
44662
|
const relPath = path.relative(process.cwd(), entryPath) || entryPath;
|
|
44451
44663
|
throw new Error(`Entry path for contract '${contractName}' is not a file (${relPath})`);
|
|
@@ -44460,7 +44672,7 @@ async function ensureEntryExists(entryPath, contractName) {
|
|
|
44460
44672
|
}
|
|
44461
44673
|
async function ensureFileExists(filePath, label) {
|
|
44462
44674
|
try {
|
|
44463
|
-
const stats = await
|
|
44675
|
+
const stats = await fs.stat(filePath);
|
|
44464
44676
|
if (!stats.isFile()) {
|
|
44465
44677
|
throw new Error(`The ${label} path is not a file (${filePath})`);
|
|
44466
44678
|
}
|
|
@@ -44474,7 +44686,7 @@ async function ensureFileExists(filePath, label) {
|
|
|
44474
44686
|
async function loadMsgPayload(input) {
|
|
44475
44687
|
const potentialPath = path.resolve(process.cwd(), input);
|
|
44476
44688
|
if (await pathExists(potentialPath)) {
|
|
44477
|
-
const raw = await
|
|
44689
|
+
const raw = await fs.readFile(potentialPath, "utf8");
|
|
44478
44690
|
return JSON.parse(raw);
|
|
44479
44691
|
}
|
|
44480
44692
|
return JSON.parse(input);
|
|
@@ -44484,7 +44696,7 @@ function resolveDoneHttpBase(override) {
|
|
|
44484
44696
|
}
|
|
44485
44697
|
async function pathExists(candidate) {
|
|
44486
44698
|
try {
|
|
44487
|
-
await
|
|
44699
|
+
await fs.access(candidate);
|
|
44488
44700
|
return true;
|
|
44489
44701
|
} catch {
|
|
44490
44702
|
return false;
|
|
@@ -44513,7 +44725,7 @@ async function runBunBuild(entryPath, outFilePath) {
|
|
|
44513
44725
|
throw new Error("Bun.build did not emit an output file");
|
|
44514
44726
|
}
|
|
44515
44727
|
const bundledSource = await output2.text();
|
|
44516
|
-
await
|
|
44728
|
+
await fs.writeFile(outFilePath, bundledSource);
|
|
44517
44729
|
return;
|
|
44518
44730
|
}
|
|
44519
44731
|
await runBunCliBuild(entryPath, outFilePath);
|
|
@@ -44574,7 +44786,7 @@ function toContractName(slug) {
|
|
|
44574
44786
|
}
|
|
44575
44787
|
async function writeJson(file2, data) {
|
|
44576
44788
|
const json = JSON.stringify(data, null, 2);
|
|
44577
|
-
await
|
|
44789
|
+
await fs.writeFile(file2, `${json}\n`, "utf8");
|
|
44578
44790
|
}
|
|
44579
44791
|
function describeStorageEntry(entry) {
|
|
44580
44792
|
const valueBase64 = entry.value ?? "";
|
|
@@ -44681,15 +44893,15 @@ function resolveDevConfig(workspace) {
|
|
|
44681
44893
|
};
|
|
44682
44894
|
}
|
|
44683
44895
|
async function writeDevEnvFile(file2, entries) {
|
|
44684
|
-
await
|
|
44896
|
+
await fs.mkdir(path.dirname(file2), { recursive: true });
|
|
44685
44897
|
const lines = ["# generated by done dev", `# ${new Date().toISOString()}`];
|
|
44686
44898
|
for (const key of Object.keys(entries).sort()) {
|
|
44687
44899
|
lines.push(`${key}=${entries[key]}`);
|
|
44688
44900
|
}
|
|
44689
|
-
await
|
|
44901
|
+
await fs.writeFile(file2, `${lines.join("\n")}\n`, "utf8");
|
|
44690
44902
|
}
|
|
44691
44903
|
async function readDevEnvFile(file2) {
|
|
44692
|
-
const data = await
|
|
44904
|
+
const data = await fs.readFile(file2, "utf8");
|
|
44693
44905
|
const entries = {};
|
|
44694
44906
|
for (const line of data.split(/\r?\n/)) {
|
|
44695
44907
|
if (!line || line.startsWith("#"))
|
|
@@ -44703,7 +44915,7 @@ async function readDevEnvFile(file2) {
|
|
|
44703
44915
|
}
|
|
44704
44916
|
async function readStorageSnapshot(file2) {
|
|
44705
44917
|
try {
|
|
44706
|
-
const raw = await
|
|
44918
|
+
const raw = await fs.readFile(file2, "utf8");
|
|
44707
44919
|
return JSON.parse(raw);
|
|
44708
44920
|
} catch (error) {
|
|
44709
44921
|
if (error.code === "ENOENT") {
|
|
@@ -44955,7 +45167,7 @@ class DoneDevOrchestrator {
|
|
|
44955
45167
|
}
|
|
44956
45168
|
async buildBundle(contract, initial, reason) {
|
|
44957
45169
|
await ensureEntryExists(contract.entryPath, contract.name);
|
|
44958
|
-
await
|
|
45170
|
+
await fs.mkdir(path.dirname(contract.outFilePath), { recursive: true });
|
|
44959
45171
|
const startedAt = Date.now();
|
|
44960
45172
|
const label = initial ? "Building" : "Rebuilding";
|
|
44961
45173
|
this.logInfo(`${label} ${contract.name}${reason ? ` (${reason})` : ""}`);
|
|
@@ -45039,7 +45251,7 @@ class DoneDevOrchestrator {
|
|
|
45039
45251
|
async publishContract(contract) {
|
|
45040
45252
|
if (!this.chain || !contract.address)
|
|
45041
45253
|
return;
|
|
45042
|
-
const script = await
|
|
45254
|
+
const script = await fs.readFile(contract.outFilePath, "utf8");
|
|
45043
45255
|
const execResult = this.chain.execute(contract.address, {
|
|
45044
45256
|
publish_code: {
|
|
45045
45257
|
script,
|
|
@@ -45075,7 +45287,7 @@ class DoneDevOrchestrator {
|
|
|
45075
45287
|
entries: entries.map(describeStorageEntry)
|
|
45076
45288
|
};
|
|
45077
45289
|
const storageDir = path.join(this.options.workspace.root, ".done", "storage");
|
|
45078
|
-
await
|
|
45290
|
+
await fs.mkdir(storageDir, { recursive: true });
|
|
45079
45291
|
const filePath = path.join(storageDir, `${contract.slug}.json`);
|
|
45080
45292
|
await writeJson(filePath, snapshot);
|
|
45081
45293
|
}
|