@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.
Files changed (59) hide show
  1. package/dist/image-ast/index.browser.js +87 -24
  2. package/dist/image-ast/index.js +87 -24
  3. package/dist/pdf-ast/ast.d.ts +3 -0
  4. package/dist/pdf-ast/index.js +103 -41
  5. package/dist/safe-bash/chunks/{chunk-WNWIBBJZ.js → chunk-AYPUGSOV.js} +7 -1
  6. package/dist/safe-bash/command-chunks/{chunk-F3J5ZLKF.js → chunk-522TDVLS.js} +1 -1
  7. package/dist/safe-bash/command-chunks/{chunk-VFS2MDAB.js → chunk-6YLD37NH.js} +2 -2
  8. package/dist/safe-bash/command-chunks/{chunk-YI3GKJ7Q.js → chunk-766IWMTB.js} +2 -2
  9. package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-7JA44PVV.js} +1 -1
  10. package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-BAUGDXLZ.js} +87 -25
  11. package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
  12. package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-HVEAK3OS.js} +2 -2
  13. package/dist/safe-bash/command-chunks/{chunk-S4MLIYSN.js → chunk-J2NPH7DO.js} +4 -0
  14. package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
  15. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  16. package/dist/safe-bash/commands/python/shell-capability.js +10 -2
  17. package/dist/safe-bash/core.browser.js +1 -1
  18. package/dist/safe-bash-command-column/column.js +3 -3
  19. package/dist/safe-bash-command-column/index.js +3 -3
  20. package/dist/safe-bash-command-column/layout.js +2 -2
  21. package/dist/safe-bash-command-factor/command.js +2 -2
  22. package/dist/safe-bash-command-factor/index.js +2 -2
  23. package/dist/safe-bash-command-ffmpeg/index.js +6300 -6265
  24. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  25. package/dist/safe-bash-command-pandoc/command.js +3 -3
  26. package/dist/safe-bash-command-pandoc/index.js +3 -3
  27. package/dist/safe-bash-command-pdfimages/index.js +87 -24
  28. package/dist/safe-bash-command-pdfinfo/index.js +103 -41
  29. package/dist/safe-bash-command-pdftk/index.js +87 -24
  30. package/dist/safe-bash-command-pdftoppm/index.js +103 -41
  31. package/dist/safe-bash-command-pdftotext/index.js +87 -24
  32. package/dist/safe-bash-command-qpdf/index.js +87 -24
  33. package/dist/safe-bash-command-sips/index.js +2 -2
  34. package/dist/safe-bash-command-soffice/index.js +2 -2
  35. package/dist/safe-bash-command-ssconvert/command-bindings.d.ts +18 -0
  36. package/dist/safe-bash-command-ssconvert/command.d.ts +5 -14
  37. package/dist/safe-bash-command-ssconvert/commands.d.ts +6 -0
  38. package/dist/safe-bash-command-ssconvert/commands.js +871 -0
  39. package/dist/safe-bash-command-ssconvert/core.js +1 -1
  40. package/dist/safe-bash-command-ssconvert/index.js +306 -236
  41. package/dist/safe-bash-command-wkhtmltopdf/index.js +88 -24
  42. package/dist/safe-bash-command-yq/index.js +4 -4
  43. package/dist/safe-bash-compression-engine/files.js +2 -2
  44. package/dist/safe-bash-compression-engine/operand.js +4 -4
  45. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  46. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  47. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  48. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  49. package/dist/safe-bash-markdown-engine/index.js +7 -7
  50. package/dist/safe-bash-query-engine/index.js +5 -5
  51. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  52. package/dist/safe-bash-query-engine/query-core.js +5 -5
  53. package/package.json +6 -2
  54. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +30 -0
  55. package/dist/safe-bash/command-chunks/{chunk-OQVIJMBY.js → chunk-7HINP7ZK.js} +4 -4
  56. package/dist/safe-bash/command-chunks/{chunk-XAYEDOV5.js → chunk-CG4JSOK2.js} +3 -3
  57. package/dist/safe-bash/command-chunks/{chunk-YIK4ZYQ4.js → chunk-DC52GWRK.js} +9 -9
  58. package/dist/safe-bash/command-chunks/{chunk-TOTZFBDT.js → chunk-TKACIO4X.js} +4 -4
  59. package/dist/safe-bash/command-chunks/{chunk-VTWKS4RM.js → chunk-WF2LSKMI.js} +3 -3
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-WI35236J.js";
32
- import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
31
+ } from "../safe-bash/command-chunks/chunk-7JA44PVV.js";
32
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
5
+ } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-WI35236J.js";
9
- import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
8
+ import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
9
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
24
+ } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-WI35236J.js";
28
- import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
27
+ import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
28
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22547,22 +22548,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22547
22548
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22548
22549
  } catch (error) {
22549
22550
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22551
+ 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;
22550
22552
  const decoder = new Inflate({
22551
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22553
+ raw: !wrapped,
22552
22554
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22553
22555
  });
22556
+ const chunks = [];
22554
22557
  let length = 0;
22555
22558
  decoder.onData = (chunk) => {
22556
22559
  length += chunk.length;
22557
22560
  if (length > maxDecodedBytes) {
22558
22561
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22559
22562
  }
22560
- decoder.chunks.push(chunk);
22563
+ chunks.push(chunk);
22561
22564
  };
22562
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22565
+ const complete = decoder.push(bytes, true);
22566
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22567
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22563
22568
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22564
22569
  }
22565
- inflated = decoder.result;
22570
+ inflated = new Uint8Array(length);
22571
+ let offset = 0;
22572
+ for (const chunk of chunks) {
22573
+ inflated.set(chunk, offset);
22574
+ offset += chunk.length;
22575
+ }
22566
22576
  }
22567
22577
  return applyPredictor(inflated, parms);
22568
22578
  }
@@ -25274,7 +25284,7 @@ var ParsedCosDocument = class {
25274
25284
  return void 0;
25275
25285
  }
25276
25286
  };
25277
- function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false) {
25287
+ function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
25278
25288
  const stack = [];
25279
25289
  while (true) {
25280
25290
  const tok = lexer.nextToken();
@@ -25283,7 +25293,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
25283
25293
  if (!parent) return void 0;
25284
25294
  throw new PdfError("E_PARSE", parent.kind === "array" ? "Unterminated PDF array" : "Unterminated PDF dictionary");
25285
25295
  }
25286
- if (!parent && recoverEmptyObject && tok.kind === "keyword" && tok.value === "endobj") {
25296
+ if (!parent && repair && tok.kind === "keyword" && tok.value === "endobj") {
25287
25297
  return { kind: "null", span: tok.span };
25288
25298
  }
25289
25299
  let node;
@@ -25298,6 +25308,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
25298
25308
  parent.key = { kind: "name", rawBytes: tok.rawBytes, decoded: tok.decoded, span: tok.span };
25299
25309
  continue;
25300
25310
  } else {
25311
+ if (repair) continue;
25301
25312
  throw new PdfError("E_PARSE", `Expected dictionary key /Name, got ${tok.kind}`);
25302
25313
  }
25303
25314
  } else {
@@ -25466,7 +25477,7 @@ function parseHeaderVersion(bytes) {
25466
25477
  }
25467
25478
  return head.slice(idx + 5, idx + 8);
25468
25479
  }
25469
- function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObject = false) {
25480
+ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
25470
25481
  const lexer = new CosByteLexer(bytes, offset);
25471
25482
  const objNumTok = lexer.nextToken();
25472
25483
  const genNumTok = lexer.nextToken();
@@ -25474,7 +25485,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObjec
25474
25485
  if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
25475
25486
  throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
25476
25487
  }
25477
- const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, recoverEmptyObject);
25488
+ const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
25478
25489
  if (!value) {
25479
25490
  throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
25480
25491
  }
@@ -25663,7 +25674,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
25663
25674
  try {
25664
25675
  const token = lexer.nextToken();
25665
25676
  if (token?.kind === "keyword" && token.value === "trailer") {
25666
- const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
25677
+ const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
25667
25678
  if (trailer?.kind === "dict") trailers.push(trailer);
25668
25679
  pos = lexer.offset;
25669
25680
  continue;
@@ -25719,7 +25730,7 @@ function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRe
25719
25730
  const t = dictGet(obj.value.dict, "Type");
25720
25731
  if (t?.kind === "name" && t.decoded === "ObjStm") {
25721
25732
  try {
25722
- for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth).entries()) {
25733
+ for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
25723
25734
  if (!objects.has(unpackedNum)) {
25724
25735
  objects.set(unpackedNum, {
25725
25736
  objectNumber: unpackedNum,
@@ -25755,7 +25766,7 @@ function recoveredReferences(objects) {
25755
25766
  }
25756
25767
  return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
25757
25768
  }
25758
- function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth) {
25769
+ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
25759
25770
  const nNode = dictGet(streamObj.dict, "N");
25760
25771
  const firstNode = dictGet(streamObj.dict, "First");
25761
25772
  if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
@@ -25775,7 +25786,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth)
25775
25786
  for (const pair of pairs) {
25776
25787
  try {
25777
25788
  const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
25778
- const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth);
25789
+ const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
25779
25790
  if (node) {
25780
25791
  result.set(pair.objectNumber, node);
25781
25792
  }
@@ -25958,7 +25969,7 @@ function parseCosDocument(bytes, options = {}) {
25958
25969
  if (!unpacked) {
25959
25970
  const stmObj = objects.get(entry.objectStreamNumber)?.value;
25960
25971
  if (stmObj?.kind === "stream") {
25961
- unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth);
25972
+ unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
25962
25973
  objStmCache.set(entry.objectStreamNumber, unpacked);
25963
25974
  }
25964
25975
  }
@@ -34775,7 +34786,11 @@ function resolvePageFonts(doc, resourcesDict) {
34775
34786
  let cmap;
34776
34787
  const toUniNode = doc.resolve(dictGet(fObj, "ToUnicode"));
34777
34788
  if (toUniNode?.kind === "stream") {
34778
- cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
34789
+ try {
34790
+ cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
34791
+ } catch (error) {
34792
+ if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
34793
+ }
34779
34794
  }
34780
34795
  const encNode = doc.resolve(dictGet(fObj, "Encoding"));
34781
34796
  if (encNode?.kind === "dict") {
@@ -34791,7 +34806,7 @@ function resolvePageFonts(doc, resourcesDict) {
34791
34806
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34792
34807
  const widths = /* @__PURE__ */ new Map();
34793
34808
  let defaultWidth = 556;
34794
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34809
+ const isTwoByteCid = subtype === "Type0";
34795
34810
  let fontMatrix;
34796
34811
  let charProcs;
34797
34812
  let fontResources;
@@ -35899,8 +35914,12 @@ function evaluateContentStreamToDisplayList(params) {
35899
35914
  const images = [];
35900
35915
  const operations = [];
35901
35916
  const emit = (operation) => {
35902
- const clipPaths = curState().clipPaths;
35903
- if (clipPaths) operation = { ...operation, value: { ...operation.value, clipPaths } };
35917
+ const { clipPaths, clipImages } = curState();
35918
+ if (clipPaths || clipImages) operation = { ...operation, value: {
35919
+ ...operation.value,
35920
+ ...clipPaths ? { clipPaths } : {},
35921
+ ...clipImages ? { clipImages } : {}
35922
+ } };
35904
35923
  operations.push(operation);
35905
35924
  switch (operation.kind) {
35906
35925
  case "path":
@@ -36164,6 +36183,18 @@ function evaluateContentStreamToDisplayList(params) {
36164
36183
  let hasTextClip = false;
36165
36184
  let activeTm = [1, 0, 0, 1, 0, 0];
36166
36185
  let activeTlm = [1, 0, 0, 1, 0, 0];
36186
+ const paintImage = (image, patternMask, resources, activeFonts, depth) => {
36187
+ if (!patternMask) {
36188
+ emit({ kind: "image", value: image });
36189
+ return;
36190
+ }
36191
+ const st = curState();
36192
+ stateStack.push({ ...st, clipImages: [...st.clipImages ?? [], image] });
36193
+ walkNodes([{ kind: "path-op", paint: "f", segments: [
36194
+ { kind: "rect", x: 0, y: 0, width: 1, height: 1 }
36195
+ ] }], void 0, void 0, resources, activeFonts, depth);
36196
+ stateStack.pop();
36197
+ };
36167
36198
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
36168
36199
  for (const node of nodes) {
36169
36200
  switch (node.kind) {
@@ -36347,7 +36378,8 @@ function evaluateContentStreamToDisplayList(params) {
36347
36378
  st.fillAlpha,
36348
36379
  "PatternShading_" + st.fillPatternName,
36349
36380
  patClip,
36350
- shading?.kind === "stream" ? shading : void 0
36381
+ shading?.kind === "stream" ? shading : void 0,
36382
+ st.blendMode
36351
36383
  );
36352
36384
  if (shImg) {
36353
36385
  emit({ kind: "image", value: shImg });
@@ -36456,18 +36488,20 @@ function evaluateContentStreamToDisplayList(params) {
36456
36488
  const subNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "Subtype"));
36457
36489
  const sub = subNode?.kind === "name" ? subNode.decoded : "";
36458
36490
  if (sub === "Image") {
36491
+ const maskNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "ImageMask"));
36492
+ const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
36459
36493
  const decoded = decodeXObjectImageToRgba(
36460
36494
  params.cosDoc,
36461
36495
  xobjNode,
36462
36496
  activeResources,
36463
- {
36497
+ patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
36464
36498
  r: st.fillColor.r,
36465
36499
  g: st.fillColor.g,
36466
36500
  b: st.fillColor.b,
36467
36501
  alpha: st.fillAlpha
36468
36502
  }
36469
36503
  );
36470
- emit({ kind: "image", value: {
36504
+ paintImage({
36471
36505
  name: node.name,
36472
36506
  matrix: [...st.ctm],
36473
36507
  width: decoded.width,
@@ -36477,7 +36511,7 @@ function evaluateContentStreamToDisplayList(params) {
36477
36511
  decodedRgba: decoded.rgba,
36478
36512
  ...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
36479
36513
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
36480
- } });
36514
+ }, patternMask, activeResources, activeFonts, depth);
36481
36515
  } else if (sub === "Form" && depth < 8) {
36482
36516
  const formStreamBytes = params.cosDoc.decodeStream(xobjNode);
36483
36517
  const formNodes = parseContentStream(formStreamBytes);
@@ -36533,19 +36567,22 @@ function evaluateContentStreamToDisplayList(params) {
36533
36567
  }
36534
36568
  case "inline-image": {
36535
36569
  const st = curState();
36570
+ const maskEntry = dictGet(node.dict, "ImageMask") ?? dictGet(node.dict, "IM");
36571
+ const maskNode = params.cosDoc ? params.cosDoc.resolve(maskEntry) : maskEntry;
36572
+ const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
36536
36573
  const decoded = decodeInlineImageNodeToRgba(
36537
36574
  params.cosDoc,
36538
36575
  node.dict,
36539
36576
  node.data,
36540
36577
  activeResources,
36541
- {
36578
+ patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
36542
36579
  r: st.fillColor.r,
36543
36580
  g: st.fillColor.g,
36544
36581
  b: st.fillColor.b,
36545
36582
  alpha: st.fillAlpha
36546
36583
  }
36547
36584
  );
36548
- emit({ kind: "image", value: {
36585
+ paintImage({
36549
36586
  name: "InlineImage",
36550
36587
  matrix: [...st.ctm],
36551
36588
  width: decoded.width,
@@ -36555,7 +36592,7 @@ function evaluateContentStreamToDisplayList(params) {
36555
36592
  decodedRgba: decoded.rgba,
36556
36593
  ...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
36557
36594
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
36558
- } });
36595
+ }, patternMask, activeResources, activeFonts, depth);
36559
36596
  break;
36560
36597
  }
36561
36598
  case "text-object": {
@@ -40059,6 +40096,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40059
40096
  const aaVec = options.antialiasVector !== false;
40060
40097
  const aaTxt = options.antialiasText !== false;
40061
40098
  const clipMasks = /* @__PURE__ */ new Map();
40099
+ const imageClipMasks = /* @__PURE__ */ new Map();
40062
40100
  for (const original of paintOperations(displayList)) {
40063
40101
  if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
40064
40102
  const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
@@ -40073,6 +40111,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40073
40111
  }
40074
40112
  clipMasks.set(clips, clipMask);
40075
40113
  }
40114
+ const imageClips = original.value.clipImages;
40115
+ if (imageClips) {
40116
+ let imageMask = imageClipMasks.get(imageClips);
40117
+ if (!imageMask) {
40118
+ imageMask = new Uint8Array(width * height * 4).fill(255);
40119
+ for (const image of imageClips) {
40120
+ const layer = renderDisplayListToBitmap({
40121
+ ...displayList,
40122
+ rotation: 0,
40123
+ paths: [],
40124
+ glyphs: [],
40125
+ images: [image],
40126
+ operations: [{ kind: "image", value: image }]
40127
+ }, { scale, transparent: true }).data;
40128
+ for (let i = 3; i < layer.length; i += 4) imageMask[i] = Math.round(imageMask[i] * layer[i] / 255);
40129
+ }
40130
+ imageClipMasks.set(imageClips, imageMask);
40131
+ }
40132
+ if (clipMask) {
40133
+ clipMask = clipMask.slice();
40134
+ for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * imageMask[i] / 255);
40135
+ } else {
40136
+ clipMask = imageMask;
40137
+ }
40138
+ }
40076
40139
  if (operation.kind === "path") {
40077
40140
  const path = operation.value;
40078
40141
  if (path.fillColor) {