@poe-platform/safe-bash 0.1.756 → 0.1.758
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 +76 -23
- package/dist/image-ast/index.js +76 -23
- package/dist/pdf-ast/ast.d.ts +3 -0
- package/dist/pdf-ast/index.js +88 -36
- package/dist/safe-bash/chunks/{chunk-LESPJ3OG.js → chunk-WNWIBBJZ.js} +15 -2
- package/dist/safe-bash/command-chunks/{chunk-S4J6MSLY.js → chunk-444OTXM7.js} +3 -3
- 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-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
- package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-J2NPH7DO.js} +11 -7
- package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-L2C5TIII.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
- package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-TCAGGM44.js} +72 -19
- package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
- package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-XYCWDGOG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
- package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
- package/dist/safe-bash/commands/pandoc/index.js +5 -3
- package/dist/safe-bash/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/index.js +6 -0
- package/dist/safe-bash/commands/python/jspi.js +11 -2
- package/dist/safe-bash/core.browser.js +6 -4
- 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-csvkit/index.js +8 -8
- 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 +5923 -5893
- 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 +72 -19
- package/dist/safe-bash-command-pdfinfo/index.js +88 -36
- package/dist/safe-bash-command-pdftk/index.js +72 -19
- package/dist/safe-bash-command-pdftoppm/index.js +88 -36
- package/dist/safe-bash-command-pdftotext/index.js +72 -19
- package/dist/safe-bash-command-qpdf/index.js +72 -19
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +17 -17
- 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 +8 -8
- package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
- package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
- package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
- package/dist/safe-bash-command-ssconvert/index.js +376 -236
- package/dist/safe-bash-command-wkhtmltopdf/index.js +72 -19
- 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-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +1 -1
- 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-mcp/index.js +4 -4
- 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/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
- package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
- package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
- package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
- package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
- package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
- package/dist/spreadsheet-engine/formulas/parser.js +34 -0
- package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
- package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
- package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
- package/dist/xlsx-ast/formula-semantics.js +2 -0
- package/package.json +6 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +16 -0
- package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
- package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
- package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
- package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
- package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
- package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
- package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
- package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
- package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
- package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
- package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
- package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
- package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
- package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
- package/dist/safe-bash/chunks/chunk-CBVANNKK.js +0 -174814
- package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
- package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
- package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
- package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
- package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
- package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
- package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
- package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
- package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
- package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
- package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
- package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
- package/dist/safe-bash/chunks/chunk-JCN3FXLP.js +0 -38983
- package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
- package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
- package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
- package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
- package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
- package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
- package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
- package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
- package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
- package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
- package/dist/safe-bash/chunks/chunk-OSUXMC43.js +0 -2317
- package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
- package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
- package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
- package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
- package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
- package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
- package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
- package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
- package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
- package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
- package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
- package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
- package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
- package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
- package/dist/safe-bash/chunks/pdf-renderer-CMF3CSVU.js +0 -22
- package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
- package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
- package/dist/safe-bash/chunks/src-MXIKQCIC.js +0 -187
- package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
- package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
- package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
- package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
- package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -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
|
@@ -33272,7 +33272,7 @@ var ParsedCosDocument = class {
|
|
|
33272
33272
|
return void 0;
|
|
33273
33273
|
}
|
|
33274
33274
|
};
|
|
33275
|
-
function parseNodeFromLexer(lexer, bytes, maxDepth,
|
|
33275
|
+
function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
|
|
33276
33276
|
const stack = [];
|
|
33277
33277
|
while (true) {
|
|
33278
33278
|
const tok = lexer.nextToken();
|
|
@@ -33281,7 +33281,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
33281
33281
|
if (!parent) return void 0;
|
|
33282
33282
|
throw new PdfError("E_PARSE", parent.kind === "array" ? "Unterminated PDF array" : "Unterminated PDF dictionary");
|
|
33283
33283
|
}
|
|
33284
|
-
if (!parent &&
|
|
33284
|
+
if (!parent && repair && tok.kind === "keyword" && tok.value === "endobj") {
|
|
33285
33285
|
return { kind: "null", span: tok.span };
|
|
33286
33286
|
}
|
|
33287
33287
|
let node;
|
|
@@ -33296,6 +33296,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
33296
33296
|
parent.key = { kind: "name", rawBytes: tok.rawBytes, decoded: tok.decoded, span: tok.span };
|
|
33297
33297
|
continue;
|
|
33298
33298
|
} else {
|
|
33299
|
+
if (repair) continue;
|
|
33299
33300
|
throw new PdfError("E_PARSE", `Expected dictionary key /Name, got ${tok.kind}`);
|
|
33300
33301
|
}
|
|
33301
33302
|
} else {
|
|
@@ -33464,7 +33465,7 @@ function parseHeaderVersion(bytes) {
|
|
|
33464
33465
|
}
|
|
33465
33466
|
return head.slice(idx + 5, idx + 8);
|
|
33466
33467
|
}
|
|
33467
|
-
function parseObjectAtOffset(bytes, offset, maxRecursionDepth,
|
|
33468
|
+
function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
33468
33469
|
const lexer = new CosByteLexer(bytes, offset);
|
|
33469
33470
|
const objNumTok = lexer.nextToken();
|
|
33470
33471
|
const genNumTok = lexer.nextToken();
|
|
@@ -33472,7 +33473,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObjec
|
|
|
33472
33473
|
if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
|
|
33473
33474
|
throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
|
|
33474
33475
|
}
|
|
33475
|
-
const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth,
|
|
33476
|
+
const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
|
|
33476
33477
|
if (!value) {
|
|
33477
33478
|
throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
|
|
33478
33479
|
}
|
|
@@ -33661,7 +33662,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
33661
33662
|
try {
|
|
33662
33663
|
const token = lexer.nextToken();
|
|
33663
33664
|
if (token?.kind === "keyword" && token.value === "trailer") {
|
|
33664
|
-
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
|
|
33665
|
+
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
|
|
33665
33666
|
if (trailer?.kind === "dict") trailers.push(trailer);
|
|
33666
33667
|
pos = lexer.offset;
|
|
33667
33668
|
continue;
|
|
@@ -33717,7 +33718,7 @@ function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRe
|
|
|
33717
33718
|
const t = dictGet(obj.value.dict, "Type");
|
|
33718
33719
|
if (t?.kind === "name" && t.decoded === "ObjStm") {
|
|
33719
33720
|
try {
|
|
33720
|
-
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth).entries()) {
|
|
33721
|
+
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
|
|
33721
33722
|
if (!objects.has(unpackedNum)) {
|
|
33722
33723
|
objects.set(unpackedNum, {
|
|
33723
33724
|
objectNumber: unpackedNum,
|
|
@@ -33753,7 +33754,7 @@ function recoveredReferences(objects) {
|
|
|
33753
33754
|
}
|
|
33754
33755
|
return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
|
|
33755
33756
|
}
|
|
33756
|
-
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth) {
|
|
33757
|
+
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
|
|
33757
33758
|
const nNode = dictGet(streamObj.dict, "N");
|
|
33758
33759
|
const firstNode = dictGet(streamObj.dict, "First");
|
|
33759
33760
|
if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
|
|
@@ -33773,7 +33774,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth)
|
|
|
33773
33774
|
for (const pair of pairs) {
|
|
33774
33775
|
try {
|
|
33775
33776
|
const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
|
|
33776
|
-
const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth);
|
|
33777
|
+
const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
|
|
33777
33778
|
if (node) {
|
|
33778
33779
|
result.set(pair.objectNumber, node);
|
|
33779
33780
|
}
|
|
@@ -33956,7 +33957,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
33956
33957
|
if (!unpacked) {
|
|
33957
33958
|
const stmObj = objects.get(entry.objectStreamNumber)?.value;
|
|
33958
33959
|
if (stmObj?.kind === "stream") {
|
|
33959
|
-
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth);
|
|
33960
|
+
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
|
|
33960
33961
|
objStmCache.set(entry.objectStreamNumber, unpacked);
|
|
33961
33962
|
}
|
|
33962
33963
|
}
|
|
@@ -42429,7 +42430,11 @@ function resolvePageFonts(doc, resourcesDict) {
|
|
|
42429
42430
|
let cmap;
|
|
42430
42431
|
const toUniNode = doc.resolve(dictGet(fObj, "ToUnicode"));
|
|
42431
42432
|
if (toUniNode?.kind === "stream") {
|
|
42432
|
-
|
|
42433
|
+
try {
|
|
42434
|
+
cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
|
|
42435
|
+
} catch (error) {
|
|
42436
|
+
if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
|
|
42437
|
+
}
|
|
42433
42438
|
}
|
|
42434
42439
|
const encNode = doc.resolve(dictGet(fObj, "Encoding"));
|
|
42435
42440
|
if (encNode?.kind === "dict") {
|
|
@@ -43553,8 +43558,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
43553
43558
|
const images = [];
|
|
43554
43559
|
const operations = [];
|
|
43555
43560
|
const emit = (operation) => {
|
|
43556
|
-
const clipPaths = curState()
|
|
43557
|
-
if (clipPaths) operation = { ...operation, value: {
|
|
43561
|
+
const { clipPaths, clipImages } = curState();
|
|
43562
|
+
if (clipPaths || clipImages) operation = { ...operation, value: {
|
|
43563
|
+
...operation.value,
|
|
43564
|
+
...clipPaths ? { clipPaths } : {},
|
|
43565
|
+
...clipImages ? { clipImages } : {}
|
|
43566
|
+
} };
|
|
43558
43567
|
operations.push(operation);
|
|
43559
43568
|
switch (operation.kind) {
|
|
43560
43569
|
case "path":
|
|
@@ -43818,6 +43827,18 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
43818
43827
|
let hasTextClip = false;
|
|
43819
43828
|
let activeTm = [1, 0, 0, 1, 0, 0];
|
|
43820
43829
|
let activeTlm = [1, 0, 0, 1, 0, 0];
|
|
43830
|
+
const paintImage = (image, patternMask, resources, activeFonts, depth) => {
|
|
43831
|
+
if (!patternMask) {
|
|
43832
|
+
emit({ kind: "image", value: image });
|
|
43833
|
+
return;
|
|
43834
|
+
}
|
|
43835
|
+
const st = curState();
|
|
43836
|
+
stateStack.push({ ...st, clipImages: [...st.clipImages ?? [], image] });
|
|
43837
|
+
walkNodes([{ kind: "path-op", paint: "f", segments: [
|
|
43838
|
+
{ kind: "rect", x: 0, y: 0, width: 1, height: 1 }
|
|
43839
|
+
] }], void 0, void 0, resources, activeFonts, depth);
|
|
43840
|
+
stateStack.pop();
|
|
43841
|
+
};
|
|
43821
43842
|
const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
|
|
43822
43843
|
for (const node of nodes) {
|
|
43823
43844
|
switch (node.kind) {
|
|
@@ -44001,7 +44022,8 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44001
44022
|
st.fillAlpha,
|
|
44002
44023
|
"PatternShading_" + st.fillPatternName,
|
|
44003
44024
|
patClip,
|
|
44004
|
-
shading?.kind === "stream" ? shading : void 0
|
|
44025
|
+
shading?.kind === "stream" ? shading : void 0,
|
|
44026
|
+
st.blendMode
|
|
44005
44027
|
);
|
|
44006
44028
|
if (shImg) {
|
|
44007
44029
|
emit({ kind: "image", value: shImg });
|
|
@@ -44110,18 +44132,20 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44110
44132
|
const subNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "Subtype"));
|
|
44111
44133
|
const sub = subNode?.kind === "name" ? subNode.decoded : "";
|
|
44112
44134
|
if (sub === "Image") {
|
|
44135
|
+
const maskNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "ImageMask"));
|
|
44136
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
44113
44137
|
const decoded = decodeXObjectImageToRgba(
|
|
44114
44138
|
params.cosDoc,
|
|
44115
44139
|
xobjNode,
|
|
44116
44140
|
activeResources,
|
|
44117
|
-
{
|
|
44141
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
44118
44142
|
r: st.fillColor.r,
|
|
44119
44143
|
g: st.fillColor.g,
|
|
44120
44144
|
b: st.fillColor.b,
|
|
44121
44145
|
alpha: st.fillAlpha
|
|
44122
44146
|
}
|
|
44123
44147
|
);
|
|
44124
|
-
|
|
44148
|
+
paintImage({
|
|
44125
44149
|
name: node.name,
|
|
44126
44150
|
matrix: [...st.ctm],
|
|
44127
44151
|
width: decoded.width,
|
|
@@ -44131,7 +44155,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44131
44155
|
decodedRgba: decoded.rgba,
|
|
44132
44156
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
44133
44157
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
44134
|
-
}
|
|
44158
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
44135
44159
|
} else if (sub === "Form" && depth < 8) {
|
|
44136
44160
|
const formStreamBytes = params.cosDoc.decodeStream(xobjNode);
|
|
44137
44161
|
const formNodes = parseContentStream(formStreamBytes);
|
|
@@ -44187,19 +44211,22 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44187
44211
|
}
|
|
44188
44212
|
case "inline-image": {
|
|
44189
44213
|
const st = curState();
|
|
44214
|
+
const maskEntry = dictGet(node.dict, "ImageMask") ?? dictGet(node.dict, "IM");
|
|
44215
|
+
const maskNode = params.cosDoc ? params.cosDoc.resolve(maskEntry) : maskEntry;
|
|
44216
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
44190
44217
|
const decoded = decodeInlineImageNodeToRgba(
|
|
44191
44218
|
params.cosDoc,
|
|
44192
44219
|
node.dict,
|
|
44193
44220
|
node.data,
|
|
44194
44221
|
activeResources,
|
|
44195
|
-
{
|
|
44222
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
44196
44223
|
r: st.fillColor.r,
|
|
44197
44224
|
g: st.fillColor.g,
|
|
44198
44225
|
b: st.fillColor.b,
|
|
44199
44226
|
alpha: st.fillAlpha
|
|
44200
44227
|
}
|
|
44201
44228
|
);
|
|
44202
|
-
|
|
44229
|
+
paintImage({
|
|
44203
44230
|
name: "InlineImage",
|
|
44204
44231
|
matrix: [...st.ctm],
|
|
44205
44232
|
width: decoded.width,
|
|
@@ -44209,7 +44236,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44209
44236
|
decodedRgba: decoded.rgba,
|
|
44210
44237
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
44211
44238
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
44212
|
-
}
|
|
44239
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
44213
44240
|
break;
|
|
44214
44241
|
}
|
|
44215
44242
|
case "text-object": {
|
|
@@ -47559,6 +47586,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47559
47586
|
const aaVec = options.antialiasVector !== false;
|
|
47560
47587
|
const aaTxt = options.antialiasText !== false;
|
|
47561
47588
|
const clipMasks = /* @__PURE__ */ new Map();
|
|
47589
|
+
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
47562
47590
|
for (const original of paintOperations(displayList)) {
|
|
47563
47591
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
47564
47592
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
@@ -47573,6 +47601,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47573
47601
|
}
|
|
47574
47602
|
clipMasks.set(clips, clipMask);
|
|
47575
47603
|
}
|
|
47604
|
+
const imageClips = original.value.clipImages;
|
|
47605
|
+
if (imageClips) {
|
|
47606
|
+
let imageMask = imageClipMasks.get(imageClips);
|
|
47607
|
+
if (!imageMask) {
|
|
47608
|
+
imageMask = new Uint8Array(width * height * 4).fill(255);
|
|
47609
|
+
for (const image of imageClips) {
|
|
47610
|
+
const layer = renderDisplayListToBitmap({
|
|
47611
|
+
...displayList,
|
|
47612
|
+
rotation: 0,
|
|
47613
|
+
paths: [],
|
|
47614
|
+
glyphs: [],
|
|
47615
|
+
images: [image],
|
|
47616
|
+
operations: [{ kind: "image", value: image }]
|
|
47617
|
+
}, { scale, transparent: true }).data;
|
|
47618
|
+
for (let i = 3; i < layer.length; i += 4) imageMask[i] = Math.round(imageMask[i] * layer[i] / 255);
|
|
47619
|
+
}
|
|
47620
|
+
imageClipMasks.set(imageClips, imageMask);
|
|
47621
|
+
}
|
|
47622
|
+
if (clipMask) {
|
|
47623
|
+
clipMask = clipMask.slice();
|
|
47624
|
+
for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * imageMask[i] / 255);
|
|
47625
|
+
} else {
|
|
47626
|
+
clipMask = imageMask;
|
|
47627
|
+
}
|
|
47628
|
+
}
|
|
47576
47629
|
if (operation.kind === "path") {
|
|
47577
47630
|
const path = operation.value;
|
|
47578
47631
|
if (path.fillColor) {
|
|
@@ -53213,7 +53266,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
|
|
|
53213
53266
|
write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
|
|
53214
53267
|
truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
|
|
53215
53268
|
sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
|
|
53216
|
-
close: (retained) => operation("close", {}, () => retained.close())
|
|
53269
|
+
close: (retained, options) => operation("close", {}, () => retained.close(options))
|
|
53217
53270
|
};
|
|
53218
53271
|
}
|
|
53219
53272
|
function integer(value, syscall, path) {
|
|
@@ -53381,10 +53434,10 @@ var ManagedFileDescriptor = class {
|
|
|
53381
53434
|
await backend.sync(backend.resource, dataOnly, forwarded);
|
|
53382
53435
|
});
|
|
53383
53436
|
}
|
|
53384
|
-
close() {
|
|
53437
|
+
close(options = {}) {
|
|
53385
53438
|
this.#closing ??= this.#pending.then(async () => {
|
|
53386
53439
|
try {
|
|
53387
|
-
await this.#backend.close(this.#backend.resource);
|
|
53440
|
+
await this.#backend.close(this.#backend.resource, options);
|
|
53388
53441
|
} finally {
|
|
53389
53442
|
this.#backend = void 0;
|
|
53390
53443
|
this.#getPosition = void 0;
|
|
@@ -53442,7 +53495,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
|
|
|
53442
53495
|
signal?.throwIfAborted();
|
|
53443
53496
|
return descriptor;
|
|
53444
53497
|
} catch (error) {
|
|
53445
|
-
await finishCleanup(() => backend.close(backend.resource), true);
|
|
53498
|
+
await finishCleanup(() => backend.close(backend.resource, {}), true);
|
|
53446
53499
|
signal?.throwIfAborted();
|
|
53447
53500
|
throw error;
|
|
53448
53501
|
}
|
package/dist/image-ast/index.js
CHANGED
|
@@ -33272,7 +33272,7 @@ var ParsedCosDocument = class {
|
|
|
33272
33272
|
return void 0;
|
|
33273
33273
|
}
|
|
33274
33274
|
};
|
|
33275
|
-
function parseNodeFromLexer(lexer, bytes, maxDepth,
|
|
33275
|
+
function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
|
|
33276
33276
|
const stack = [];
|
|
33277
33277
|
while (true) {
|
|
33278
33278
|
const tok = lexer.nextToken();
|
|
@@ -33281,7 +33281,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
33281
33281
|
if (!parent) return void 0;
|
|
33282
33282
|
throw new PdfError("E_PARSE", parent.kind === "array" ? "Unterminated PDF array" : "Unterminated PDF dictionary");
|
|
33283
33283
|
}
|
|
33284
|
-
if (!parent &&
|
|
33284
|
+
if (!parent && repair && tok.kind === "keyword" && tok.value === "endobj") {
|
|
33285
33285
|
return { kind: "null", span: tok.span };
|
|
33286
33286
|
}
|
|
33287
33287
|
let node;
|
|
@@ -33296,6 +33296,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
|
|
|
33296
33296
|
parent.key = { kind: "name", rawBytes: tok.rawBytes, decoded: tok.decoded, span: tok.span };
|
|
33297
33297
|
continue;
|
|
33298
33298
|
} else {
|
|
33299
|
+
if (repair) continue;
|
|
33299
33300
|
throw new PdfError("E_PARSE", `Expected dictionary key /Name, got ${tok.kind}`);
|
|
33300
33301
|
}
|
|
33301
33302
|
} else {
|
|
@@ -33464,7 +33465,7 @@ function parseHeaderVersion(bytes) {
|
|
|
33464
33465
|
}
|
|
33465
33466
|
return head.slice(idx + 5, idx + 8);
|
|
33466
33467
|
}
|
|
33467
|
-
function parseObjectAtOffset(bytes, offset, maxRecursionDepth,
|
|
33468
|
+
function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
33468
33469
|
const lexer = new CosByteLexer(bytes, offset);
|
|
33469
33470
|
const objNumTok = lexer.nextToken();
|
|
33470
33471
|
const genNumTok = lexer.nextToken();
|
|
@@ -33472,7 +33473,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObjec
|
|
|
33472
33473
|
if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
|
|
33473
33474
|
throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
|
|
33474
33475
|
}
|
|
33475
|
-
const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth,
|
|
33476
|
+
const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
|
|
33476
33477
|
if (!value) {
|
|
33477
33478
|
throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
|
|
33478
33479
|
}
|
|
@@ -33661,7 +33662,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
33661
33662
|
try {
|
|
33662
33663
|
const token = lexer.nextToken();
|
|
33663
33664
|
if (token?.kind === "keyword" && token.value === "trailer") {
|
|
33664
|
-
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
|
|
33665
|
+
const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
|
|
33665
33666
|
if (trailer?.kind === "dict") trailers.push(trailer);
|
|
33666
33667
|
pos = lexer.offset;
|
|
33667
33668
|
continue;
|
|
@@ -33717,7 +33718,7 @@ function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRe
|
|
|
33717
33718
|
const t = dictGet(obj.value.dict, "Type");
|
|
33718
33719
|
if (t?.kind === "name" && t.decoded === "ObjStm") {
|
|
33719
33720
|
try {
|
|
33720
|
-
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth).entries()) {
|
|
33721
|
+
for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
|
|
33721
33722
|
if (!objects.has(unpackedNum)) {
|
|
33722
33723
|
objects.set(unpackedNum, {
|
|
33723
33724
|
objectNumber: unpackedNum,
|
|
@@ -33753,7 +33754,7 @@ function recoveredReferences(objects) {
|
|
|
33753
33754
|
}
|
|
33754
33755
|
return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
|
|
33755
33756
|
}
|
|
33756
|
-
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth) {
|
|
33757
|
+
function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
|
|
33757
33758
|
const nNode = dictGet(streamObj.dict, "N");
|
|
33758
33759
|
const firstNode = dictGet(streamObj.dict, "First");
|
|
33759
33760
|
if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
|
|
@@ -33773,7 +33774,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth)
|
|
|
33773
33774
|
for (const pair of pairs) {
|
|
33774
33775
|
try {
|
|
33775
33776
|
const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
|
|
33776
|
-
const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth);
|
|
33777
|
+
const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
|
|
33777
33778
|
if (node) {
|
|
33778
33779
|
result.set(pair.objectNumber, node);
|
|
33779
33780
|
}
|
|
@@ -33956,7 +33957,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
33956
33957
|
if (!unpacked) {
|
|
33957
33958
|
const stmObj = objects.get(entry.objectStreamNumber)?.value;
|
|
33958
33959
|
if (stmObj?.kind === "stream") {
|
|
33959
|
-
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth);
|
|
33960
|
+
unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
|
|
33960
33961
|
objStmCache.set(entry.objectStreamNumber, unpacked);
|
|
33961
33962
|
}
|
|
33962
33963
|
}
|
|
@@ -42429,7 +42430,11 @@ function resolvePageFonts(doc, resourcesDict) {
|
|
|
42429
42430
|
let cmap;
|
|
42430
42431
|
const toUniNode = doc.resolve(dictGet(fObj, "ToUnicode"));
|
|
42431
42432
|
if (toUniNode?.kind === "stream") {
|
|
42432
|
-
|
|
42433
|
+
try {
|
|
42434
|
+
cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
|
|
42435
|
+
} catch (error) {
|
|
42436
|
+
if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
|
|
42437
|
+
}
|
|
42433
42438
|
}
|
|
42434
42439
|
const encNode = doc.resolve(dictGet(fObj, "Encoding"));
|
|
42435
42440
|
if (encNode?.kind === "dict") {
|
|
@@ -43553,8 +43558,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
43553
43558
|
const images = [];
|
|
43554
43559
|
const operations = [];
|
|
43555
43560
|
const emit = (operation) => {
|
|
43556
|
-
const clipPaths = curState()
|
|
43557
|
-
if (clipPaths) operation = { ...operation, value: {
|
|
43561
|
+
const { clipPaths, clipImages } = curState();
|
|
43562
|
+
if (clipPaths || clipImages) operation = { ...operation, value: {
|
|
43563
|
+
...operation.value,
|
|
43564
|
+
...clipPaths ? { clipPaths } : {},
|
|
43565
|
+
...clipImages ? { clipImages } : {}
|
|
43566
|
+
} };
|
|
43558
43567
|
operations.push(operation);
|
|
43559
43568
|
switch (operation.kind) {
|
|
43560
43569
|
case "path":
|
|
@@ -43818,6 +43827,18 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
43818
43827
|
let hasTextClip = false;
|
|
43819
43828
|
let activeTm = [1, 0, 0, 1, 0, 0];
|
|
43820
43829
|
let activeTlm = [1, 0, 0, 1, 0, 0];
|
|
43830
|
+
const paintImage = (image, patternMask, resources, activeFonts, depth) => {
|
|
43831
|
+
if (!patternMask) {
|
|
43832
|
+
emit({ kind: "image", value: image });
|
|
43833
|
+
return;
|
|
43834
|
+
}
|
|
43835
|
+
const st = curState();
|
|
43836
|
+
stateStack.push({ ...st, clipImages: [...st.clipImages ?? [], image] });
|
|
43837
|
+
walkNodes([{ kind: "path-op", paint: "f", segments: [
|
|
43838
|
+
{ kind: "rect", x: 0, y: 0, width: 1, height: 1 }
|
|
43839
|
+
] }], void 0, void 0, resources, activeFonts, depth);
|
|
43840
|
+
stateStack.pop();
|
|
43841
|
+
};
|
|
43821
43842
|
const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
|
|
43822
43843
|
for (const node of nodes) {
|
|
43823
43844
|
switch (node.kind) {
|
|
@@ -44001,7 +44022,8 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44001
44022
|
st.fillAlpha,
|
|
44002
44023
|
"PatternShading_" + st.fillPatternName,
|
|
44003
44024
|
patClip,
|
|
44004
|
-
shading?.kind === "stream" ? shading : void 0
|
|
44025
|
+
shading?.kind === "stream" ? shading : void 0,
|
|
44026
|
+
st.blendMode
|
|
44005
44027
|
);
|
|
44006
44028
|
if (shImg) {
|
|
44007
44029
|
emit({ kind: "image", value: shImg });
|
|
@@ -44110,18 +44132,20 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44110
44132
|
const subNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "Subtype"));
|
|
44111
44133
|
const sub = subNode?.kind === "name" ? subNode.decoded : "";
|
|
44112
44134
|
if (sub === "Image") {
|
|
44135
|
+
const maskNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "ImageMask"));
|
|
44136
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
44113
44137
|
const decoded = decodeXObjectImageToRgba(
|
|
44114
44138
|
params.cosDoc,
|
|
44115
44139
|
xobjNode,
|
|
44116
44140
|
activeResources,
|
|
44117
|
-
{
|
|
44141
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
44118
44142
|
r: st.fillColor.r,
|
|
44119
44143
|
g: st.fillColor.g,
|
|
44120
44144
|
b: st.fillColor.b,
|
|
44121
44145
|
alpha: st.fillAlpha
|
|
44122
44146
|
}
|
|
44123
44147
|
);
|
|
44124
|
-
|
|
44148
|
+
paintImage({
|
|
44125
44149
|
name: node.name,
|
|
44126
44150
|
matrix: [...st.ctm],
|
|
44127
44151
|
width: decoded.width,
|
|
@@ -44131,7 +44155,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44131
44155
|
decodedRgba: decoded.rgba,
|
|
44132
44156
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
44133
44157
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
44134
|
-
}
|
|
44158
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
44135
44159
|
} else if (sub === "Form" && depth < 8) {
|
|
44136
44160
|
const formStreamBytes = params.cosDoc.decodeStream(xobjNode);
|
|
44137
44161
|
const formNodes = parseContentStream(formStreamBytes);
|
|
@@ -44187,19 +44211,22 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44187
44211
|
}
|
|
44188
44212
|
case "inline-image": {
|
|
44189
44213
|
const st = curState();
|
|
44214
|
+
const maskEntry = dictGet(node.dict, "ImageMask") ?? dictGet(node.dict, "IM");
|
|
44215
|
+
const maskNode = params.cosDoc ? params.cosDoc.resolve(maskEntry) : maskEntry;
|
|
44216
|
+
const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
|
|
44190
44217
|
const decoded = decodeInlineImageNodeToRgba(
|
|
44191
44218
|
params.cosDoc,
|
|
44192
44219
|
node.dict,
|
|
44193
44220
|
node.data,
|
|
44194
44221
|
activeResources,
|
|
44195
|
-
{
|
|
44222
|
+
patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
|
|
44196
44223
|
r: st.fillColor.r,
|
|
44197
44224
|
g: st.fillColor.g,
|
|
44198
44225
|
b: st.fillColor.b,
|
|
44199
44226
|
alpha: st.fillAlpha
|
|
44200
44227
|
}
|
|
44201
44228
|
);
|
|
44202
|
-
|
|
44229
|
+
paintImage({
|
|
44203
44230
|
name: "InlineImage",
|
|
44204
44231
|
matrix: [...st.ctm],
|
|
44205
44232
|
width: decoded.width,
|
|
@@ -44209,7 +44236,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
44209
44236
|
decodedRgba: decoded.rgba,
|
|
44210
44237
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
44211
44238
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
44212
|
-
}
|
|
44239
|
+
}, patternMask, activeResources, activeFonts, depth);
|
|
44213
44240
|
break;
|
|
44214
44241
|
}
|
|
44215
44242
|
case "text-object": {
|
|
@@ -47559,6 +47586,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47559
47586
|
const aaVec = options.antialiasVector !== false;
|
|
47560
47587
|
const aaTxt = options.antialiasText !== false;
|
|
47561
47588
|
const clipMasks = /* @__PURE__ */ new Map();
|
|
47589
|
+
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
47562
47590
|
for (const original of paintOperations(displayList)) {
|
|
47563
47591
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
47564
47592
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
@@ -47573,6 +47601,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47573
47601
|
}
|
|
47574
47602
|
clipMasks.set(clips, clipMask);
|
|
47575
47603
|
}
|
|
47604
|
+
const imageClips = original.value.clipImages;
|
|
47605
|
+
if (imageClips) {
|
|
47606
|
+
let imageMask = imageClipMasks.get(imageClips);
|
|
47607
|
+
if (!imageMask) {
|
|
47608
|
+
imageMask = new Uint8Array(width * height * 4).fill(255);
|
|
47609
|
+
for (const image of imageClips) {
|
|
47610
|
+
const layer = renderDisplayListToBitmap({
|
|
47611
|
+
...displayList,
|
|
47612
|
+
rotation: 0,
|
|
47613
|
+
paths: [],
|
|
47614
|
+
glyphs: [],
|
|
47615
|
+
images: [image],
|
|
47616
|
+
operations: [{ kind: "image", value: image }]
|
|
47617
|
+
}, { scale, transparent: true }).data;
|
|
47618
|
+
for (let i = 3; i < layer.length; i += 4) imageMask[i] = Math.round(imageMask[i] * layer[i] / 255);
|
|
47619
|
+
}
|
|
47620
|
+
imageClipMasks.set(imageClips, imageMask);
|
|
47621
|
+
}
|
|
47622
|
+
if (clipMask) {
|
|
47623
|
+
clipMask = clipMask.slice();
|
|
47624
|
+
for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * imageMask[i] / 255);
|
|
47625
|
+
} else {
|
|
47626
|
+
clipMask = imageMask;
|
|
47627
|
+
}
|
|
47628
|
+
}
|
|
47576
47629
|
if (operation.kind === "path") {
|
|
47577
47630
|
const path = operation.value;
|
|
47578
47631
|
if (path.fillColor) {
|
|
@@ -53213,7 +53266,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
|
|
|
53213
53266
|
write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
|
|
53214
53267
|
truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
|
|
53215
53268
|
sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
|
|
53216
|
-
close: (retained) => operation("close", {}, () => retained.close())
|
|
53269
|
+
close: (retained, options) => operation("close", {}, () => retained.close(options))
|
|
53217
53270
|
};
|
|
53218
53271
|
}
|
|
53219
53272
|
function integer(value, syscall, path) {
|
|
@@ -53381,10 +53434,10 @@ var ManagedFileDescriptor = class {
|
|
|
53381
53434
|
await backend.sync(backend.resource, dataOnly, forwarded);
|
|
53382
53435
|
});
|
|
53383
53436
|
}
|
|
53384
|
-
close() {
|
|
53437
|
+
close(options = {}) {
|
|
53385
53438
|
this.#closing ??= this.#pending.then(async () => {
|
|
53386
53439
|
try {
|
|
53387
|
-
await this.#backend.close(this.#backend.resource);
|
|
53440
|
+
await this.#backend.close(this.#backend.resource, options);
|
|
53388
53441
|
} finally {
|
|
53389
53442
|
this.#backend = void 0;
|
|
53390
53443
|
this.#getPosition = void 0;
|
|
@@ -53442,7 +53495,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
|
|
|
53442
53495
|
signal?.throwIfAborted();
|
|
53443
53496
|
return descriptor;
|
|
53444
53497
|
} catch (error) {
|
|
53445
|
-
await finishCleanup(() => backend.close(backend.resource), true);
|
|
53498
|
+
await finishCleanup(() => backend.close(backend.resource, {}), true);
|
|
53446
53499
|
signal?.throwIfAborted();
|
|
53447
53500
|
throw error;
|
|
53448
53501
|
}
|
package/dist/pdf-ast/ast.d.ts
CHANGED
|
@@ -223,6 +223,7 @@ export interface PdfPlacedGlyph {
|
|
|
223
223
|
readonly actualText?: string | undefined;
|
|
224
224
|
readonly blendMode?: string | undefined;
|
|
225
225
|
readonly clipPaths?: readonly (readonly PdfPathSegment[])[] | undefined;
|
|
226
|
+
readonly clipImages?: readonly PdfEvaluatedImage[] | undefined;
|
|
226
227
|
readonly clipRect?: readonly [number, number, number, number] | undefined;
|
|
227
228
|
}
|
|
228
229
|
export interface PdfEvaluatedPath {
|
|
@@ -241,6 +242,7 @@ export interface PdfEvaluatedPath {
|
|
|
241
242
|
readonly blendMode?: string | undefined;
|
|
242
243
|
readonly isClip?: boolean | undefined;
|
|
243
244
|
readonly clipPaths?: readonly (readonly PdfPathSegment[])[] | undefined;
|
|
245
|
+
readonly clipImages?: readonly PdfEvaluatedImage[] | undefined;
|
|
244
246
|
readonly clipRect?: readonly [number, number, number, number] | undefined;
|
|
245
247
|
}
|
|
246
248
|
export interface PdfEvaluatedImage {
|
|
@@ -253,6 +255,7 @@ export interface PdfEvaluatedImage {
|
|
|
253
255
|
readonly decodedRgba?: Uint8Array | undefined;
|
|
254
256
|
readonly blendMode?: string | undefined;
|
|
255
257
|
readonly clipPaths?: readonly (readonly PdfPathSegment[])[] | undefined;
|
|
258
|
+
readonly clipImages?: readonly PdfEvaluatedImage[] | undefined;
|
|
256
259
|
readonly clipRect?: readonly [number, number, number, number] | undefined;
|
|
257
260
|
}
|
|
258
261
|
export interface PdfLinkAnnotation {
|