@poe-platform/safe-bash 0.1.757 → 0.1.759
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/image-ast/index.browser.js +87 -24
- package/dist/image-ast/index.js +87 -24
- package/dist/pdf-ast/ast.d.ts +3 -0
- package/dist/pdf-ast/index.js +103 -41
- package/dist/safe-bash/chunks/{chunk-WNWIBBJZ.js → chunk-AYPUGSOV.js} +7 -1
- package/dist/safe-bash/command-chunks/{chunk-F3J5ZLKF.js → chunk-522TDVLS.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-VFS2MDAB.js → chunk-6YLD37NH.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YI3GKJ7Q.js → chunk-766IWMTB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-7JA44PVV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-BAUGDXLZ.js} +87 -25
- package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-HVEAK3OS.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-S4MLIYSN.js → chunk-J2NPH7DO.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
- package/dist/safe-bash/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/shell-capability.js +10 -2
- package/dist/safe-bash/core.browser.js +1 -1
- package/dist/safe-bash-command-column/column.js +3 -3
- package/dist/safe-bash-command-column/index.js +3 -3
- package/dist/safe-bash-command-column/layout.js +2 -2
- package/dist/safe-bash-command-factor/command.js +2 -2
- package/dist/safe-bash-command-factor/index.js +2 -2
- package/dist/safe-bash-command-ffmpeg/index.js +6300 -6265
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pdfimages/index.js +87 -24
- package/dist/safe-bash-command-pdfinfo/index.js +103 -41
- package/dist/safe-bash-command-pdftk/index.js +87 -24
- package/dist/safe-bash-command-pdftoppm/index.js +103 -41
- package/dist/safe-bash-command-pdftotext/index.js +87 -24
- package/dist/safe-bash-command-qpdf/index.js +87 -24
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +2 -2
- package/dist/safe-bash-command-ssconvert/command-bindings.d.ts +18 -0
- package/dist/safe-bash-command-ssconvert/command.d.ts +5 -14
- package/dist/safe-bash-command-ssconvert/commands.d.ts +6 -0
- package/dist/safe-bash-command-ssconvert/commands.js +871 -0
- package/dist/safe-bash-command-ssconvert/core.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +306 -236
- package/dist/safe-bash-command-wkhtmltopdf/index.js +88 -24
- package/dist/safe-bash-command-yq/index.js +4 -4
- package/dist/safe-bash-compression-engine/files.js +2 -2
- package/dist/safe-bash-compression-engine/operand.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
- package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
- package/dist/safe-bash-markdown-engine/index.js +7 -7
- package/dist/safe-bash-query-engine/index.js +5 -5
- package/dist/safe-bash-query-engine/interpreter.js +4 -4
- package/dist/safe-bash-query-engine/query-core.js +5 -5
- package/package.json +6 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/safe-bash/command-chunks/{chunk-OQVIJMBY.js → chunk-7HINP7ZK.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-XAYEDOV5.js → chunk-CG4JSOK2.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-YIK4ZYQ4.js → chunk-DC52GWRK.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-TOTZFBDT.js → chunk-TKACIO4X.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-VTWKS4RM.js → chunk-WF2LSKMI.js} +3 -3
|
@@ -1778,7 +1778,7 @@ var require_deflate = __commonJS({
|
|
|
1778
1778
|
var Z_STREAM_END2 = 1;
|
|
1779
1779
|
var Z_STREAM_ERROR = -2;
|
|
1780
1780
|
var Z_DATA_ERROR2 = -3;
|
|
1781
|
-
var
|
|
1781
|
+
var Z_BUF_ERROR3 = -5;
|
|
1782
1782
|
var Z_DEFAULT_COMPRESSION = -1;
|
|
1783
1783
|
var Z_FILTERED = 1;
|
|
1784
1784
|
var Z_HUFFMAN_ONLY = 2;
|
|
@@ -2476,7 +2476,7 @@ var require_deflate = __commonJS({
|
|
|
2476
2476
|
}
|
|
2477
2477
|
s = strm.state;
|
|
2478
2478
|
if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
|
|
2479
|
-
return err3(strm, strm.avail_out === 0 ?
|
|
2479
|
+
return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
|
|
2480
2480
|
}
|
|
2481
2481
|
s.strm = strm;
|
|
2482
2482
|
old_flush = s.last_flush;
|
|
@@ -2658,10 +2658,10 @@ var require_deflate = __commonJS({
|
|
|
2658
2658
|
return Z_OK2;
|
|
2659
2659
|
}
|
|
2660
2660
|
} else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
|
|
2661
|
-
return err3(strm,
|
|
2661
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
2662
2662
|
}
|
|
2663
2663
|
if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
|
|
2664
|
-
return err3(strm,
|
|
2664
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
2665
2665
|
}
|
|
2666
2666
|
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
|
|
2667
2667
|
var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
|
|
@@ -3688,7 +3688,7 @@ var require_inflate = __commonJS({
|
|
|
3688
3688
|
var Z_STREAM_ERROR = -2;
|
|
3689
3689
|
var Z_DATA_ERROR2 = -3;
|
|
3690
3690
|
var Z_MEM_ERROR = -4;
|
|
3691
|
-
var
|
|
3691
|
+
var Z_BUF_ERROR3 = -5;
|
|
3692
3692
|
var Z_DEFLATED = 8;
|
|
3693
3693
|
var HEAD3 = 1;
|
|
3694
3694
|
var FLAGS3 = 2;
|
|
@@ -4838,7 +4838,7 @@ var require_inflate = __commonJS({
|
|
|
4838
4838
|
}
|
|
4839
4839
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
|
|
4840
4840
|
if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
|
|
4841
|
-
ret =
|
|
4841
|
+
ret = Z_BUF_ERROR3;
|
|
4842
4842
|
}
|
|
4843
4843
|
return ret;
|
|
4844
4844
|
}
|
|
@@ -7049,7 +7049,7 @@ var require_deflate3 = __commonJS({
|
|
|
7049
7049
|
var Z_STREAM_END2 = 1;
|
|
7050
7050
|
var Z_STREAM_ERROR = -2;
|
|
7051
7051
|
var Z_DATA_ERROR2 = -3;
|
|
7052
|
-
var
|
|
7052
|
+
var Z_BUF_ERROR3 = -5;
|
|
7053
7053
|
var Z_DEFAULT_COMPRESSION = -1;
|
|
7054
7054
|
var Z_FILTERED = 1;
|
|
7055
7055
|
var Z_HUFFMAN_ONLY = 2;
|
|
@@ -7747,7 +7747,7 @@ var require_deflate3 = __commonJS({
|
|
|
7747
7747
|
}
|
|
7748
7748
|
s = strm.state;
|
|
7749
7749
|
if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
|
|
7750
|
-
return err3(strm, strm.avail_out === 0 ?
|
|
7750
|
+
return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
|
|
7751
7751
|
}
|
|
7752
7752
|
s.strm = strm;
|
|
7753
7753
|
old_flush = s.last_flush;
|
|
@@ -7929,10 +7929,10 @@ var require_deflate3 = __commonJS({
|
|
|
7929
7929
|
return Z_OK2;
|
|
7930
7930
|
}
|
|
7931
7931
|
} else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
|
|
7932
|
-
return err3(strm,
|
|
7932
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
7933
7933
|
}
|
|
7934
7934
|
if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
|
|
7935
|
-
return err3(strm,
|
|
7935
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
7936
7936
|
}
|
|
7937
7937
|
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
|
|
7938
7938
|
var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
|
|
@@ -8959,7 +8959,7 @@ var require_inflate3 = __commonJS({
|
|
|
8959
8959
|
var Z_STREAM_ERROR = -2;
|
|
8960
8960
|
var Z_DATA_ERROR2 = -3;
|
|
8961
8961
|
var Z_MEM_ERROR = -4;
|
|
8962
|
-
var
|
|
8962
|
+
var Z_BUF_ERROR3 = -5;
|
|
8963
8963
|
var Z_DEFLATED = 8;
|
|
8964
8964
|
var HEAD3 = 1;
|
|
8965
8965
|
var FLAGS3 = 2;
|
|
@@ -10109,7 +10109,7 @@ var require_inflate3 = __commonJS({
|
|
|
10109
10109
|
}
|
|
10110
10110
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
|
|
10111
10111
|
if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
|
|
10112
|
-
ret =
|
|
10112
|
+
ret = Z_BUF_ERROR3;
|
|
10113
10113
|
}
|
|
10114
10114
|
return ret;
|
|
10115
10115
|
}
|
|
@@ -14564,7 +14564,7 @@ var require_deflate5 = __commonJS({
|
|
|
14564
14564
|
var Z_STREAM_END2 = 1;
|
|
14565
14565
|
var Z_STREAM_ERROR = -2;
|
|
14566
14566
|
var Z_DATA_ERROR2 = -3;
|
|
14567
|
-
var
|
|
14567
|
+
var Z_BUF_ERROR3 = -5;
|
|
14568
14568
|
var Z_DEFAULT_COMPRESSION = -1;
|
|
14569
14569
|
var Z_FILTERED = 1;
|
|
14570
14570
|
var Z_HUFFMAN_ONLY = 2;
|
|
@@ -15262,7 +15262,7 @@ var require_deflate5 = __commonJS({
|
|
|
15262
15262
|
}
|
|
15263
15263
|
s = strm.state;
|
|
15264
15264
|
if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
|
|
15265
|
-
return err3(strm, strm.avail_out === 0 ?
|
|
15265
|
+
return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
|
|
15266
15266
|
}
|
|
15267
15267
|
s.strm = strm;
|
|
15268
15268
|
old_flush = s.last_flush;
|
|
@@ -15444,10 +15444,10 @@ var require_deflate5 = __commonJS({
|
|
|
15444
15444
|
return Z_OK2;
|
|
15445
15445
|
}
|
|
15446
15446
|
} else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
|
|
15447
|
-
return err3(strm,
|
|
15447
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
15448
15448
|
}
|
|
15449
15449
|
if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
|
|
15450
|
-
return err3(strm,
|
|
15450
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
15451
15451
|
}
|
|
15452
15452
|
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
|
|
15453
15453
|
var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
|
|
@@ -16474,7 +16474,7 @@ var require_inflate5 = __commonJS({
|
|
|
16474
16474
|
var Z_STREAM_ERROR = -2;
|
|
16475
16475
|
var Z_DATA_ERROR2 = -3;
|
|
16476
16476
|
var Z_MEM_ERROR = -4;
|
|
16477
|
-
var
|
|
16477
|
+
var Z_BUF_ERROR3 = -5;
|
|
16478
16478
|
var Z_DEFLATED = 8;
|
|
16479
16479
|
var HEAD3 = 1;
|
|
16480
16480
|
var FLAGS3 = 2;
|
|
@@ -17624,7 +17624,7 @@ var require_inflate5 = __commonJS({
|
|
|
17624
17624
|
}
|
|
17625
17625
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
|
|
17626
17626
|
if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
|
|
17627
|
-
ret =
|
|
17627
|
+
ret = Z_BUF_ERROR3;
|
|
17628
17628
|
}
|
|
17629
17629
|
return ret;
|
|
17630
17630
|
}
|
|
@@ -51584,7 +51584,7 @@ var require_fontkit_umd = __commonJS({
|
|
|
51584
51584
|
var Z_STREAM_END2 = 1;
|
|
51585
51585
|
var Z_STREAM_ERROR = -2;
|
|
51586
51586
|
var Z_DATA_ERROR2 = -3;
|
|
51587
|
-
var
|
|
51587
|
+
var Z_BUF_ERROR3 = -5;
|
|
51588
51588
|
var Z_DEFAULT_COMPRESSION = -1;
|
|
51589
51589
|
var Z_FILTERED = 1;
|
|
51590
51590
|
var Z_HUFFMAN_ONLY = 2;
|
|
@@ -52282,7 +52282,7 @@ var require_fontkit_umd = __commonJS({
|
|
|
52282
52282
|
}
|
|
52283
52283
|
s = strm.state;
|
|
52284
52284
|
if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
|
|
52285
|
-
return err3(strm, strm.avail_out === 0 ?
|
|
52285
|
+
return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
|
|
52286
52286
|
}
|
|
52287
52287
|
s.strm = strm;
|
|
52288
52288
|
old_flush = s.last_flush;
|
|
@@ -52461,10 +52461,10 @@ var require_fontkit_umd = __commonJS({
|
|
|
52461
52461
|
return Z_OK2;
|
|
52462
52462
|
}
|
|
52463
52463
|
} else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
|
|
52464
|
-
return err3(strm,
|
|
52464
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
52465
52465
|
}
|
|
52466
52466
|
if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
|
|
52467
|
-
return err3(strm,
|
|
52467
|
+
return err3(strm, Z_BUF_ERROR3);
|
|
52468
52468
|
}
|
|
52469
52469
|
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
|
|
52470
52470
|
var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
|
|
@@ -174163,6 +174163,7 @@ var messages_default22 = {
|
|
|
174163
174163
|
"-5": "buffer error",
|
|
174164
174164
|
"-6": "incompatible version"
|
|
174165
174165
|
};
|
|
174166
|
+
var Z_BUF_ERROR2 = -5;
|
|
174166
174167
|
var MAX_MEM_LEVEL22 = 9;
|
|
174167
174168
|
var HEAP_SIZE22 = 573;
|
|
174168
174169
|
var MIN_MATCH22 = 3;
|
|
@@ -196054,22 +196055,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
|
|
|
196054
196055
|
inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
|
|
196055
196056
|
} catch (error2) {
|
|
196056
196057
|
if (error2 instanceof PdfError2 && error2.code === "E_LIMIT") throw error2;
|
|
196058
|
+
const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
|
|
196057
196059
|
const decoder2 = new Inflate22({
|
|
196058
|
-
raw: !
|
|
196060
|
+
raw: !wrapped,
|
|
196059
196061
|
chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
|
|
196060
196062
|
});
|
|
196063
|
+
const chunks = [];
|
|
196061
196064
|
let length = 0;
|
|
196062
196065
|
decoder2.onData = (chunk) => {
|
|
196063
196066
|
length += chunk.length;
|
|
196064
196067
|
if (length > maxDecodedBytes) {
|
|
196065
196068
|
throw new PdfError2("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
|
|
196066
196069
|
}
|
|
196067
|
-
|
|
196070
|
+
chunks.push(chunk);
|
|
196068
196071
|
};
|
|
196069
|
-
|
|
196072
|
+
const complete2 = decoder2.push(bytes, true);
|
|
196073
|
+
const truncated = wrapped && decoder2.err === Z_BUF_ERROR2 && length > 0;
|
|
196074
|
+
if ((!complete2 || decoder2.err || !decoder2.ended) && !truncated) {
|
|
196070
196075
|
throw new PdfError2("E_CAPABILITY", "Invalid FlateDecode compressed stream");
|
|
196071
196076
|
}
|
|
196072
|
-
inflated =
|
|
196077
|
+
inflated = new Uint8Array(length);
|
|
196078
|
+
let offset = 0;
|
|
196079
|
+
for (const chunk of chunks) {
|
|
196080
|
+
inflated.set(chunk, offset);
|
|
196081
|
+
offset += chunk.length;
|
|
196082
|
+
}
|
|
196073
196083
|
}
|
|
196074
196084
|
return applyPredictor(inflated, parms);
|
|
196075
196085
|
}
|
|
@@ -198781,7 +198791,7 @@ var ParsedCosDocument = class {
|
|
|
198781
198791
|
return void 0;
|
|
198782
198792
|
}
|
|
198783
198793
|
};
|
|
198784
|
-
function parseNodeFromLexer(lexer, bytes, maxDepth,
|
|
198794
|
+
function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
|
|
198785
198795
|
const stack = [];
|
|
198786
198796
|
while (true) {
|
|
198787
198797
|
const tok = lexer.nextToken();
|
|
@@ -198790,7 +198800,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
198790
198800
|
if (!parent) return void 0;
|
|
198791
198801
|
throw new PdfError2("E_PARSE", parent.kind === "array" ? "Unterminated PDF array" : "Unterminated PDF dictionary");
|
|
198792
198802
|
}
|
|
198793
|
-
if (!parent &&
|
|
198803
|
+
if (!parent && repair && tok.kind === "keyword" && tok.value === "endobj") {
|
|
198794
198804
|
return { kind: "null", span: tok.span };
|
|
198795
198805
|
}
|
|
198796
198806
|
let node3;
|
|
@@ -198805,6 +198815,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
198805
198815
|
parent.key = { kind: "name", rawBytes: tok.rawBytes, decoded: tok.decoded, span: tok.span };
|
|
198806
198816
|
continue;
|
|
198807
198817
|
} else {
|
|
198818
|
+
if (repair) continue;
|
|
198808
198819
|
throw new PdfError2("E_PARSE", `Expected dictionary key /Name, got ${tok.kind}`);
|
|
198809
198820
|
}
|
|
198810
198821
|
} else {
|
|
@@ -198973,7 +198984,7 @@ function parseHeaderVersion(bytes) {
|
|
|
198973
198984
|
}
|
|
198974
198985
|
return head.slice(idx + 5, idx + 8);
|
|
198975
198986
|
}
|
|
198976
|
-
function parseObjectAtOffset(bytes, offset, maxRecursionDepth,
|
|
198987
|
+
function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
198977
198988
|
const lexer = new CosByteLexer(bytes, offset);
|
|
198978
198989
|
const objNumTok = lexer.nextToken();
|
|
198979
198990
|
const genNumTok = lexer.nextToken();
|
|
@@ -198981,7 +198992,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObjec
|
|
|
198981
198992
|
if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
|
|
198982
198993
|
throw new PdfError2("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
|
|
198983
198994
|
}
|
|
198984
|
-
const value3 = parseNodeFromLexer(lexer, bytes, maxRecursionDepth,
|
|
198995
|
+
const value3 = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
|
|
198985
198996
|
if (!value3) {
|
|
198986
198997
|
throw new PdfError2("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
|
|
198987
198998
|
}
|
|
@@ -199170,7 +199181,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
199170
199181
|
try {
|
|
199171
199182
|
const token = lexer.nextToken();
|
|
199172
199183
|
if (token?.kind === "keyword" && token.value === "trailer") {
|
|
199173
|
-
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
|
|
199184
|
+
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
|
|
199174
199185
|
if (trailer?.kind === "dict") trailers.push(trailer);
|
|
199175
199186
|
pos = lexer.offset;
|
|
199176
199187
|
continue;
|
|
@@ -199226,7 +199237,7 @@ function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRe
|
|
|
199226
199237
|
const t = dictGet(obj.value.dict, "Type");
|
|
199227
199238
|
if (t?.kind === "name" && t.decoded === "ObjStm") {
|
|
199228
199239
|
try {
|
|
199229
|
-
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth).entries()) {
|
|
199240
|
+
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
|
|
199230
199241
|
if (!objects.has(unpackedNum)) {
|
|
199231
199242
|
objects.set(unpackedNum, {
|
|
199232
199243
|
objectNumber: unpackedNum,
|
|
@@ -199262,7 +199273,7 @@ function recoveredReferences(objects) {
|
|
|
199262
199273
|
}
|
|
199263
199274
|
return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
|
|
199264
199275
|
}
|
|
199265
|
-
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth) {
|
|
199276
|
+
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
|
|
199266
199277
|
const nNode = dictGet(streamObj.dict, "N");
|
|
199267
199278
|
const firstNode = dictGet(streamObj.dict, "First");
|
|
199268
199279
|
if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
|
|
@@ -199282,7 +199293,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth)
|
|
|
199282
199293
|
for (const pair of pairs) {
|
|
199283
199294
|
try {
|
|
199284
199295
|
const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
|
|
199285
|
-
const node3 = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth);
|
|
199296
|
+
const node3 = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
|
|
199286
199297
|
if (node3) {
|
|
199287
199298
|
result2.set(pair.objectNumber, node3);
|
|
199288
199299
|
}
|
|
@@ -199465,7 +199476,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
199465
199476
|
if (!unpacked) {
|
|
199466
199477
|
const stmObj = objects.get(entry2.objectStreamNumber)?.value;
|
|
199467
199478
|
if (stmObj?.kind === "stream") {
|
|
199468
|
-
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth);
|
|
199479
|
+
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
|
|
199469
199480
|
objStmCache.set(entry2.objectStreamNumber, unpacked);
|
|
199470
199481
|
}
|
|
199471
199482
|
}
|
|
@@ -207937,7 +207948,11 @@ function resolvePageFonts(doc, resourcesDict) {
|
|
|
207937
207948
|
let cmap;
|
|
207938
207949
|
const toUniNode = doc.resolve(dictGet(fObj, "ToUnicode"));
|
|
207939
207950
|
if (toUniNode?.kind === "stream") {
|
|
207940
|
-
|
|
207951
|
+
try {
|
|
207952
|
+
cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
|
|
207953
|
+
} catch (error2) {
|
|
207954
|
+
if (error2 instanceof PdfError2 && error2.code === "E_LIMIT") throw error2;
|
|
207955
|
+
}
|
|
207941
207956
|
}
|
|
207942
207957
|
const encNode = doc.resolve(dictGet(fObj, "Encoding"));
|
|
207943
207958
|
if (encNode?.kind === "dict") {
|
|
@@ -207953,7 +207968,7 @@ function resolvePageFonts(doc, resourcesDict) {
|
|
|
207953
207968
|
const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
|
|
207954
207969
|
const widths = /* @__PURE__ */ new Map();
|
|
207955
207970
|
let defaultWidth = 556;
|
|
207956
|
-
const isTwoByteCid = subtype === "Type0"
|
|
207971
|
+
const isTwoByteCid = subtype === "Type0";
|
|
207957
207972
|
let fontMatrix;
|
|
207958
207973
|
let charProcs;
|
|
207959
207974
|
let fontResources;
|
|
@@ -209061,8 +209076,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209061
209076
|
const images = [];
|
|
209062
209077
|
const operations = [];
|
|
209063
209078
|
const emit = (operation) => {
|
|
209064
|
-
const clipPaths = curState()
|
|
209065
|
-
if (clipPaths) operation = { ...operation, value: {
|
|
209079
|
+
const { clipPaths, clipImages } = curState();
|
|
209080
|
+
if (clipPaths || clipImages) operation = { ...operation, value: {
|
|
209081
|
+
...operation.value,
|
|
209082
|
+
...clipPaths ? { clipPaths } : {},
|
|
209083
|
+
...clipImages ? { clipImages } : {}
|
|
209084
|
+
} };
|
|
209066
209085
|
operations.push(operation);
|
|
209067
209086
|
switch (operation.kind) {
|
|
209068
209087
|
case "path":
|
|
@@ -209326,6 +209345,18 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209326
209345
|
let hasTextClip = false;
|
|
209327
209346
|
let activeTm = [1, 0, 0, 1, 0, 0];
|
|
209328
209347
|
let activeTlm = [1, 0, 0, 1, 0, 0];
|
|
209348
|
+
const paintImage = (image, patternMask, resources, activeFonts, depth) => {
|
|
209349
|
+
if (!patternMask) {
|
|
209350
|
+
emit({ kind: "image", value: image });
|
|
209351
|
+
return;
|
|
209352
|
+
}
|
|
209353
|
+
const st = curState();
|
|
209354
|
+
stateStack.push({ ...st, clipImages: [...st.clipImages ?? [], image] });
|
|
209355
|
+
walkNodes([{ kind: "path-op", paint: "f", segments: [
|
|
209356
|
+
{ kind: "rect", x: 0, y: 0, width: 1, height: 1 }
|
|
209357
|
+
] }], void 0, void 0, resources, activeFonts, depth);
|
|
209358
|
+
stateStack.pop();
|
|
209359
|
+
};
|
|
209329
209360
|
const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
|
|
209330
209361
|
for (const node3 of nodes) {
|
|
209331
209362
|
switch (node3.kind) {
|
|
@@ -209509,7 +209540,8 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209509
209540
|
st.fillAlpha,
|
|
209510
209541
|
"PatternShading_" + st.fillPatternName,
|
|
209511
209542
|
patClip,
|
|
209512
|
-
shading?.kind === "stream" ? shading : void 0
|
|
209543
|
+
shading?.kind === "stream" ? shading : void 0,
|
|
209544
|
+
st.blendMode
|
|
209513
209545
|
);
|
|
209514
209546
|
if (shImg) {
|
|
209515
209547
|
emit({ kind: "image", value: shImg });
|
|
@@ -209618,18 +209650,20 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209618
209650
|
const subNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "Subtype"));
|
|
209619
209651
|
const sub = subNode?.kind === "name" ? subNode.decoded : "";
|
|
209620
209652
|
if (sub === "Image") {
|
|
209653
|
+
const maskNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "ImageMask"));
|
|
209654
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
209621
209655
|
const decoded = decodeXObjectImageToRgba(
|
|
209622
209656
|
params.cosDoc,
|
|
209623
209657
|
xobjNode,
|
|
209624
209658
|
activeResources,
|
|
209625
|
-
{
|
|
209659
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
209626
209660
|
r: st.fillColor.r,
|
|
209627
209661
|
g: st.fillColor.g,
|
|
209628
209662
|
b: st.fillColor.b,
|
|
209629
209663
|
alpha: st.fillAlpha
|
|
209630
209664
|
}
|
|
209631
209665
|
);
|
|
209632
|
-
|
|
209666
|
+
paintImage({
|
|
209633
209667
|
name: node3.name,
|
|
209634
209668
|
matrix: [...st.ctm],
|
|
209635
209669
|
width: decoded.width,
|
|
@@ -209639,7 +209673,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209639
209673
|
decodedRgba: decoded.rgba,
|
|
209640
209674
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
209641
209675
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
209642
|
-
}
|
|
209676
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
209643
209677
|
} else if (sub === "Form" && depth < 8) {
|
|
209644
209678
|
const formStreamBytes = params.cosDoc.decodeStream(xobjNode);
|
|
209645
209679
|
const formNodes = parseContentStream(formStreamBytes);
|
|
@@ -209695,19 +209729,22 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209695
209729
|
}
|
|
209696
209730
|
case "inline-image": {
|
|
209697
209731
|
const st = curState();
|
|
209732
|
+
const maskEntry = dictGet(node3.dict, "ImageMask") ?? dictGet(node3.dict, "IM");
|
|
209733
|
+
const maskNode = params.cosDoc ? params.cosDoc.resolve(maskEntry) : maskEntry;
|
|
209734
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
209698
209735
|
const decoded = decodeInlineImageNodeToRgba(
|
|
209699
209736
|
params.cosDoc,
|
|
209700
209737
|
node3.dict,
|
|
209701
209738
|
node3.data,
|
|
209702
209739
|
activeResources,
|
|
209703
|
-
{
|
|
209740
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
209704
209741
|
r: st.fillColor.r,
|
|
209705
209742
|
g: st.fillColor.g,
|
|
209706
209743
|
b: st.fillColor.b,
|
|
209707
209744
|
alpha: st.fillAlpha
|
|
209708
209745
|
}
|
|
209709
209746
|
);
|
|
209710
|
-
|
|
209747
|
+
paintImage({
|
|
209711
209748
|
name: "InlineImage",
|
|
209712
209749
|
matrix: [...st.ctm],
|
|
209713
209750
|
width: decoded.width,
|
|
@@ -209717,7 +209754,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209717
209754
|
decodedRgba: decoded.rgba,
|
|
209718
209755
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
209719
209756
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
209720
|
-
}
|
|
209757
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
209721
209758
|
break;
|
|
209722
209759
|
}
|
|
209723
209760
|
case "text-object": {
|
|
@@ -213067,6 +213104,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213067
213104
|
const aaVec = options.antialiasVector !== false;
|
|
213068
213105
|
const aaTxt = options.antialiasText !== false;
|
|
213069
213106
|
const clipMasks = /* @__PURE__ */ new Map();
|
|
213107
|
+
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
213070
213108
|
for (const original of paintOperations(displayList)) {
|
|
213071
213109
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
213072
213110
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
@@ -213081,6 +213119,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213081
213119
|
}
|
|
213082
213120
|
clipMasks.set(clips, clipMask);
|
|
213083
213121
|
}
|
|
213122
|
+
const imageClips = original.value.clipImages;
|
|
213123
|
+
if (imageClips) {
|
|
213124
|
+
let imageMask = imageClipMasks.get(imageClips);
|
|
213125
|
+
if (!imageMask) {
|
|
213126
|
+
imageMask = new Uint8Array(width2 * height * 4).fill(255);
|
|
213127
|
+
for (const image of imageClips) {
|
|
213128
|
+
const layer = renderDisplayListToBitmap({
|
|
213129
|
+
...displayList,
|
|
213130
|
+
rotation: 0,
|
|
213131
|
+
paths: [],
|
|
213132
|
+
glyphs: [],
|
|
213133
|
+
images: [image],
|
|
213134
|
+
operations: [{ kind: "image", value: image }]
|
|
213135
|
+
}, { scale: scale2, transparent: true }).data;
|
|
213136
|
+
for (let i = 3; i < layer.length; i += 4) imageMask[i] = Math.round(imageMask[i] * layer[i] / 255);
|
|
213137
|
+
}
|
|
213138
|
+
imageClipMasks.set(imageClips, imageMask);
|
|
213139
|
+
}
|
|
213140
|
+
if (clipMask) {
|
|
213141
|
+
clipMask = clipMask.slice();
|
|
213142
|
+
for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * imageMask[i] / 255);
|
|
213143
|
+
} else {
|
|
213144
|
+
clipMask = imageMask;
|
|
213145
|
+
}
|
|
213146
|
+
}
|
|
213084
213147
|
if (operation.kind === "path") {
|
|
213085
213148
|
const path2 = operation.value;
|
|
213086
213149
|
if (path2.fillColor) {
|
|
@@ -233295,209 +233358,216 @@ function createDatabaseFunctions(query) {
|
|
|
233295
233358
|
}
|
|
233296
233359
|
}])));
|
|
233297
233360
|
}
|
|
233298
|
-
function
|
|
233299
|
-
|
|
233300
|
-
|
|
233301
|
-
|
|
233302
|
-
|
|
233303
|
-
|
|
233304
|
-
|
|
233305
|
-
...configured.io
|
|
233306
|
-
|
|
233307
|
-
|
|
233308
|
-
|
|
233309
|
-
|
|
233310
|
-
|
|
233311
|
-
|
|
233312
|
-
|
|
233313
|
-
|
|
233314
|
-
|
|
233315
|
-
|
|
233316
|
-
|
|
233317
|
-
...configured.profile
|
|
233318
|
-
|
|
233319
|
-
|
|
233320
|
-
|
|
233321
|
-
|
|
233322
|
-
|
|
233323
|
-
|
|
233324
|
-
|
|
233325
|
-
|
|
233326
|
-
|
|
233327
|
-
|
|
233328
|
-
|
|
233329
|
-
|
|
233330
|
-
|
|
233331
|
-
|
|
233332
|
-
|
|
233333
|
-
|
|
233334
|
-
|
|
233335
|
-
|
|
233336
|
-
|
|
233337
|
-
context
|
|
233338
|
-
|
|
233339
|
-
|
|
233340
|
-
|
|
233341
|
-
|
|
233342
|
-
|
|
233343
|
-
|
|
233344
|
-
|
|
233345
|
-
|
|
233346
|
-
|
|
233347
|
-
|
|
233348
|
-
|
|
233349
|
-
|
|
233350
|
-
|
|
233351
|
-
|
|
233352
|
-
|
|
233353
|
-
|
|
233354
|
-
|
|
233355
|
-
|
|
233356
|
-
|
|
233357
|
-
|
|
233358
|
-
|
|
233359
|
-
|
|
233360
|
-
|
|
233361
|
-
|
|
233362
|
-
|
|
233363
|
-
|
|
233364
|
-
|
|
233365
|
-
|
|
233366
|
-
|
|
233367
|
-
|
|
233368
|
-
|
|
233369
|
-
|
|
233370
|
-
|
|
233371
|
-
|
|
233372
|
-
|
|
233373
|
-
|
|
233374
|
-
|
|
233375
|
-
|
|
233376
|
-
|
|
233377
|
-
|
|
233378
|
-
|
|
233379
|
-
|
|
233380
|
-
|
|
233381
|
-
|
|
233382
|
-
|
|
233383
|
-
|
|
233384
|
-
|
|
233385
|
-
limits: { ...binding.limits, inputBytes },
|
|
233386
|
-
filesystem: createResourceIO({
|
|
233387
|
-
...binding.io,
|
|
233388
|
-
cwd,
|
|
233389
|
-
descriptors: {
|
|
233390
|
-
...binding.io?.descriptors,
|
|
233391
|
-
0: { source: context.stdin },
|
|
233392
|
-
1: { sink: standardOutput }
|
|
233361
|
+
function createCommandBindings(createEngine3, compatibilityDefaults = false) {
|
|
233362
|
+
function createSsconvertCommand2(options = {}) {
|
|
233363
|
+
const configured = { ...options };
|
|
233364
|
+
if (configured.replace !== void 0 && typeof configured.replace !== "boolean")
|
|
233365
|
+
throw new TypeError("ssconvert replace must be boolean");
|
|
233366
|
+
const binding = {
|
|
233367
|
+
...configured,
|
|
233368
|
+
...configured.io === void 0 ? {} : { io: Object.freeze({
|
|
233369
|
+
...configured.io.descriptors === void 0 ? {} : { descriptors: Object.freeze(Object.fromEntries(
|
|
233370
|
+
Object.entries(configured.io.descriptors).map(([key, descriptor3]) => [key, Object.freeze({ ...descriptor3 })])
|
|
233371
|
+
)) },
|
|
233372
|
+
...configured.io.adapters === void 0 ? {} : { adapters: Object.freeze({ ...configured.io.adapters }) },
|
|
233373
|
+
...configured.io.transport === void 0 ? {} : { transport: Object.freeze({
|
|
233374
|
+
authorize: configured.io.transport.authorize.bind(configured.io.transport),
|
|
233375
|
+
request: configured.io.transport.request.bind(configured.io.transport),
|
|
233376
|
+
redirects: configured.io.transport.redirects
|
|
233377
|
+
}) }
|
|
233378
|
+
}) },
|
|
233379
|
+
...configured.runtimeFunctions === void 0 ? {} : { runtimeFunctions: snapshotRuntimeFunctions(configured.runtimeFunctions) },
|
|
233380
|
+
...configured.profile === void 0 ? {} : { profile: Object.freeze({
|
|
233381
|
+
...configured.profile,
|
|
233382
|
+
...configured.profile.groups === void 0 ? {} : { groups: Object.freeze({ ...configured.profile.groups }) },
|
|
233383
|
+
...configured.profile.configurationRoots === void 0 ? {} : {
|
|
233384
|
+
configurationRoots: Object.freeze({ ...configured.profile.configurationRoots })
|
|
233385
|
+
}
|
|
233386
|
+
}) },
|
|
233387
|
+
codecs: Object.freeze([...configured.codecs ?? []]),
|
|
233388
|
+
...configured.formats === void 0 ? {} : { formats: snapshotFormats(configured.formats) },
|
|
233389
|
+
limits: Object.freeze({ ...defaultSsconvertLimits, ...configured.limits }),
|
|
233390
|
+
environment: Object.freeze({
|
|
233391
|
+
locale: "C",
|
|
233392
|
+
timezone: "UTC",
|
|
233393
|
+
...configured.environment,
|
|
233394
|
+
env: Object.freeze({ ...configured.environment?.env })
|
|
233395
|
+
})
|
|
233396
|
+
};
|
|
233397
|
+
const command = {
|
|
233398
|
+
name: "ssconvert",
|
|
233399
|
+
description: "Explicitly bound TypeScript spreadsheet conversion engine",
|
|
233400
|
+
async execute(context) {
|
|
233401
|
+
context.signal.throwIfAborted();
|
|
233402
|
+
const owner = createOutputOperation(context, { async write() {
|
|
233403
|
+
} });
|
|
233404
|
+
const inputBytes = Math.min(
|
|
233405
|
+
binding.limits.inputBytes,
|
|
233406
|
+
context.inputBudget?.maxBytes ?? Infinity
|
|
233407
|
+
);
|
|
233408
|
+
let stdout;
|
|
233409
|
+
const standardOutput = { async write(bytes) {
|
|
233410
|
+
stdout ??= owner.child(context.stdout);
|
|
233411
|
+
await stdout.output.write(bytes);
|
|
233412
|
+
} };
|
|
233413
|
+
let stderr;
|
|
233414
|
+
const standardError = { async write(bytes) {
|
|
233415
|
+
stderr ??= owner.child(context.stderr);
|
|
233416
|
+
await stderr.output.write(bytes);
|
|
233417
|
+
} };
|
|
233418
|
+
const openOutput = createVfsOutput(context.fs, async (path2, bytes, signal) => {
|
|
233419
|
+
await owner.acquire(() => writeFileOutput(
|
|
233420
|
+
context,
|
|
233421
|
+
bytes,
|
|
233422
|
+
async (data3) => {
|
|
233423
|
+
const capabilities = await context.fs.capabilitiesFor?.(path2, { signal }) ?? context.fs.capabilities;
|
|
233424
|
+
signal.throwIfAborted();
|
|
233425
|
+
if (context.fs.writeStream && capabilities.streamingWrite !== false)
|
|
233426
|
+
await context.fs.writeStream(path2, (async function* () {
|
|
233427
|
+
yield data3;
|
|
233428
|
+
})(), { signal });
|
|
233429
|
+
else await context.fs.writeFile(path2, data3, { signal });
|
|
233430
|
+
}
|
|
233431
|
+
), () => {
|
|
233432
|
+
});
|
|
233433
|
+
}, (cleanup) => retainFileSystemCleanup(
|
|
233434
|
+
context.fs,
|
|
233435
|
+
(view2) => cleanup((path2) => view2.rm(path2)),
|
|
233436
|
+
{ maxOperations: 1 }
|
|
233437
|
+
));
|
|
233438
|
+
let engine;
|
|
233439
|
+
try {
|
|
233440
|
+
const cwd = await owner.acquire(() => resolveVfsCwd(context.cwd, context.env.PWD, context.fs, owner.signal), () => {
|
|
233441
|
+
});
|
|
233442
|
+
engine = createEngine3({
|
|
233443
|
+
...binding,
|
|
233444
|
+
environment: {
|
|
233445
|
+
...binding.environment,
|
|
233446
|
+
cwd,
|
|
233447
|
+
env: Object.freeze({ ...context.env })
|
|
233393
233448
|
},
|
|
233394
|
-
|
|
233395
|
-
|
|
233396
|
-
|
|
233397
|
-
|
|
233398
|
-
|
|
233399
|
-
|
|
233400
|
-
|
|
233401
|
-
|
|
233402
|
-
const bytes = await owner.acquire(
|
|
233403
|
-
() => context.fs.readFile(uri, {
|
|
233404
|
-
signal,
|
|
233405
|
-
...inputBytes === Infinity ? {} : { maxBytes: inputBytes }
|
|
233406
|
-
}),
|
|
233407
|
-
() => {
|
|
233408
|
-
}
|
|
233409
|
-
);
|
|
233410
|
-
context.inputBudget?.check(bytes.byteLength);
|
|
233411
|
-
return [bytes];
|
|
233412
|
-
} catch (error2) {
|
|
233413
|
-
signal.throwIfAborted();
|
|
233414
|
-
throw error2;
|
|
233415
|
-
}
|
|
233449
|
+
limits: { ...binding.limits, inputBytes },
|
|
233450
|
+
filesystem: createResourceIO({
|
|
233451
|
+
...binding.io,
|
|
233452
|
+
cwd,
|
|
233453
|
+
descriptors: {
|
|
233454
|
+
...binding.io?.descriptors,
|
|
233455
|
+
0: { source: context.stdin },
|
|
233456
|
+
1: { sink: standardOutput }
|
|
233416
233457
|
},
|
|
233417
|
-
|
|
233418
|
-
|
|
233419
|
-
|
|
233420
|
-
|
|
233421
|
-
|
|
233422
|
-
|
|
233423
|
-
|
|
233424
|
-
|
|
233425
|
-
|
|
233426
|
-
|
|
233427
|
-
|
|
233428
|
-
|
|
233429
|
-
|
|
233430
|
-
|
|
233431
|
-
|
|
233432
|
-
|
|
233433
|
-
|
|
233434
|
-
|
|
233458
|
+
filesystem: {
|
|
233459
|
+
openOutput,
|
|
233460
|
+
async read(uri, signal) {
|
|
233461
|
+
try {
|
|
233462
|
+
const capabilities = await context.fs.capabilitiesFor?.(uri, { signal }) ?? context.fs.capabilities;
|
|
233463
|
+
signal.throwIfAborted();
|
|
233464
|
+
if (context.fs.readStream && capabilities.streamingRead !== false)
|
|
233465
|
+
return context.fs.readStream(uri, { signal });
|
|
233466
|
+
const bytes = await owner.acquire(
|
|
233467
|
+
() => context.fs.readFile(uri, {
|
|
233468
|
+
signal,
|
|
233469
|
+
...inputBytes === Infinity ? {} : { maxBytes: inputBytes }
|
|
233470
|
+
}),
|
|
233471
|
+
() => {
|
|
233472
|
+
}
|
|
233473
|
+
);
|
|
233474
|
+
context.inputBudget?.check(bytes.byteLength);
|
|
233475
|
+
return [bytes];
|
|
233476
|
+
} catch (error2) {
|
|
233477
|
+
signal.throwIfAborted();
|
|
233478
|
+
throw error2;
|
|
233479
|
+
}
|
|
233480
|
+
},
|
|
233481
|
+
async write(uri, bytes, signal) {
|
|
233482
|
+
try {
|
|
233483
|
+
await owner.acquire(
|
|
233484
|
+
() => writeFileOutput(context, bytes, async (data3) => {
|
|
233485
|
+
const capabilities = await context.fs.capabilitiesFor?.(uri, { signal }) ?? context.fs.capabilities;
|
|
233486
|
+
signal.throwIfAborted();
|
|
233487
|
+
if (context.fs.writeStream && capabilities.streamingWrite !== false)
|
|
233488
|
+
await context.fs.writeStream(uri, (async function* () {
|
|
233489
|
+
yield data3;
|
|
233490
|
+
})(), { signal });
|
|
233491
|
+
else await context.fs.writeFile(uri, data3, { signal });
|
|
233492
|
+
}),
|
|
233493
|
+
() => {
|
|
233494
|
+
}
|
|
233495
|
+
);
|
|
233496
|
+
} catch (error2) {
|
|
233497
|
+
signal.throwIfAborted();
|
|
233498
|
+
throw error2;
|
|
233499
|
+
}
|
|
233435
233500
|
}
|
|
233436
233501
|
}
|
|
233502
|
+
})
|
|
233503
|
+
});
|
|
233504
|
+
const maximumArguments = binding.limits.argumentBytes ?? Infinity;
|
|
233505
|
+
const values2 = context.argumentValues?.values ?? context.args;
|
|
233506
|
+
let argumentBytes = 0;
|
|
233507
|
+
let refusal;
|
|
233508
|
+
if (values2.length > maximumArguments) refusal = "ssconvert arguments limit exceeded";
|
|
233509
|
+
for (const value3 of values2) {
|
|
233510
|
+
if (refusal) break;
|
|
233511
|
+
if (typeof value3 === "string" && value3.length > maximumArguments - argumentBytes) {
|
|
233512
|
+
refusal = "ssconvert argument bytes limit exceeded";
|
|
233513
|
+
break;
|
|
233437
233514
|
}
|
|
233438
|
-
|
|
233439
|
-
|
|
233440
|
-
const maximumArguments = binding.limits.argumentBytes ?? Infinity;
|
|
233441
|
-
const values2 = context.argumentValues?.values ?? context.args;
|
|
233442
|
-
let argumentBytes = 0;
|
|
233443
|
-
let refusal;
|
|
233444
|
-
if (values2.length > maximumArguments) refusal = "ssconvert arguments limit exceeded";
|
|
233445
|
-
for (const value3 of values2) {
|
|
233446
|
-
if (refusal) break;
|
|
233447
|
-
if (typeof value3 === "string" && value3.length > maximumArguments - argumentBytes) {
|
|
233448
|
-
refusal = "ssconvert argument bytes limit exceeded";
|
|
233449
|
-
break;
|
|
233515
|
+
argumentBytes += shellValueByteLength(value3);
|
|
233516
|
+
if (argumentBytes > maximumArguments) refusal = "ssconvert argument bytes limit exceeded";
|
|
233450
233517
|
}
|
|
233451
|
-
|
|
233452
|
-
|
|
233453
|
-
}
|
|
233454
|
-
if (refusal) {
|
|
233455
|
-
await standardError.write(new TextEncoder().encode(`${refusal}
|
|
233518
|
+
if (refusal) {
|
|
233519
|
+
await standardError.write(new TextEncoder().encode(`${refusal}
|
|
233456
233520
|
`));
|
|
233457
|
-
|
|
233458
|
-
|
|
233459
|
-
|
|
233460
|
-
|
|
233461
|
-
|
|
233462
|
-
|
|
233463
|
-
|
|
233464
|
-
|
|
233465
|
-
|
|
233466
|
-
|
|
233467
|
-
|
|
233468
|
-
|
|
233469
|
-
|
|
233470
|
-
|
|
233471
|
-
|
|
233472
|
-
|
|
233473
|
-
} finally {
|
|
233474
|
-
try {
|
|
233475
|
-
await engine?.dispose();
|
|
233521
|
+
owner.signal.throwIfAborted();
|
|
233522
|
+
return { exitCode: 1 };
|
|
233523
|
+
}
|
|
233524
|
+
const carrier = getCommandArguments(context);
|
|
233525
|
+
return await runCommand(
|
|
233526
|
+
carrier.args.map((_, index2) => carrier.bytes(index2)),
|
|
233527
|
+
engine,
|
|
233528
|
+
{
|
|
233529
|
+
signal: owner.signal,
|
|
233530
|
+
...context.stdinIsDefault === void 0 ? {} : { stdinIsDefault: context.stdinIsDefault },
|
|
233531
|
+
stdout: standardOutput,
|
|
233532
|
+
stderr: standardError,
|
|
233533
|
+
registerCleanup: (cleanup) => owner.registerCleanup(cleanup)
|
|
233534
|
+
},
|
|
233535
|
+
binding.profile
|
|
233536
|
+
);
|
|
233476
233537
|
} finally {
|
|
233477
|
-
|
|
233538
|
+
try {
|
|
233539
|
+
await engine?.dispose();
|
|
233540
|
+
} finally {
|
|
233541
|
+
await owner.close();
|
|
233542
|
+
}
|
|
233478
233543
|
}
|
|
233479
233544
|
}
|
|
233545
|
+
};
|
|
233546
|
+
if (compatibilityDefaults && Object.entries(configured).every(([key, value3]) => key === "replace" || value3 === void 0)) {
|
|
233547
|
+
builtInDirectContextExecutors.add(command.execute);
|
|
233480
233548
|
}
|
|
233481
|
-
|
|
233482
|
-
if (Object.entries(configured).every(([key, value3]) => key === "replace" || value3 === void 0)) {
|
|
233483
|
-
builtInDirectContextExecutors.add(command.execute);
|
|
233549
|
+
return command;
|
|
233484
233550
|
}
|
|
233485
|
-
|
|
233486
|
-
|
|
233487
|
-
|
|
233488
|
-
|
|
233489
|
-
|
|
233490
|
-
|
|
233491
|
-
|
|
233492
|
-
|
|
233493
|
-
|
|
233494
|
-
|
|
233495
|
-
|
|
233496
|
-
}
|
|
233497
|
-
|
|
233498
|
-
|
|
233499
|
-
return
|
|
233551
|
+
function ssconvertCommands2(options = {}) {
|
|
233552
|
+
const commands = createSsconvertCommands2(options), replace = options.replace ?? false;
|
|
233553
|
+
return {
|
|
233554
|
+
name: "ssconvert-commands",
|
|
233555
|
+
setup(host) {
|
|
233556
|
+
if (!replace && commands.some((command) => host.commands.has(command.name)))
|
|
233557
|
+
throw new Error("Command already registered: ssconvert");
|
|
233558
|
+
for (const command of commands) host.commands.register(command, { replace });
|
|
233559
|
+
}
|
|
233560
|
+
};
|
|
233561
|
+
}
|
|
233562
|
+
function createSsconvertCommands2(options = {}) {
|
|
233563
|
+
return Object.freeze([createSsconvertCommand2(options)]);
|
|
233564
|
+
}
|
|
233565
|
+
return { createSsconvertCommand: createSsconvertCommand2, createSsconvertCommands: createSsconvertCommands2, ssconvertCommands: ssconvertCommands2 };
|
|
233500
233566
|
}
|
|
233567
|
+
var bindings = createCommandBindings(createEngine2, true);
|
|
233568
|
+
var createSsconvertCommand = bindings.createSsconvertCommand;
|
|
233569
|
+
var createSsconvertCommands = bindings.createSsconvertCommands;
|
|
233570
|
+
var ssconvertCommands = bindings.ssconvertCommands;
|
|
233501
233571
|
function parseSimpleSeparatedRows(text2, sep) {
|
|
233502
233572
|
const rows = [];
|
|
233503
233573
|
let row = [];
|