@poe-platform/safe-bash 0.1.760 → 0.1.762

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 (33) hide show
  1. package/dist/image-ast/index.browser.js +117 -13
  2. package/dist/image-ast/index.js +117 -13
  3. package/dist/pdf-ast/index.js +121 -13
  4. package/dist/safe-bash/command-chunks/{chunk-MC4XXPQJ.js → chunk-D4GXXV65.js} +2 -2
  5. package/dist/safe-bash/command-chunks/{chunk-UCI6ZQFB.js → chunk-F7MJRXQ2.js} +1 -1
  6. package/dist/safe-bash/command-chunks/{chunk-S3SCPBHC.js → chunk-P3Q2QSCA.js} +125 -13
  7. package/dist/safe-bash/commands/csvcut/index.d.ts +1 -1
  8. package/dist/safe-bash/commands/csvcut/index.js +3 -1
  9. package/dist/safe-bash/commands/csvgrep/index.d.ts +1 -1
  10. package/dist/safe-bash/commands/csvgrep/index.js +3 -1
  11. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
  12. package/dist/safe-bash/commands/htmlq/index.js +4 -1
  13. package/dist/safe-bash/core.browser.js +10 -7
  14. package/dist/safe-bash/shell/runtime.js +5 -5
  15. package/dist/safe-bash-command-ffmpeg/index.js +1457 -1390
  16. package/dist/safe-bash-command-git/LICENSE +21 -0
  17. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  18. package/dist/safe-bash-command-pandoc/command.js +3 -3
  19. package/dist/safe-bash-command-pandoc/index.js +3 -3
  20. package/dist/safe-bash-command-pdfimages/index.js +117 -13
  21. package/dist/safe-bash-command-pdfinfo/index.js +117 -13
  22. package/dist/safe-bash-command-pdftk/index.js +117 -13
  23. package/dist/safe-bash-command-pdftoppm/index.js +117 -13
  24. package/dist/safe-bash-command-pdftotext/index.js +117 -13
  25. package/dist/safe-bash-command-qpdf/index.js +117 -13
  26. package/dist/safe-bash-command-sips/index.js +2 -2
  27. package/dist/safe-bash-command-soffice/index.js +1 -1
  28. package/dist/safe-bash-command-ssconvert/index.js +117 -13
  29. package/dist/safe-bash-command-wkhtmltopdf/index.js +117 -13
  30. package/package.json +2 -2
  31. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +32 -0
  32. package/third-party/pdf-ast/licenses/AGG-2.3.txt +7 -0
  33. package/third-party/pdf-ast/licenses/MIT.txt +21 -0
@@ -46674,6 +46674,80 @@ function createTrueTypeFontHandle(truetype) {
46674
46674
  }
46675
46675
  };
46676
46676
  }
46677
+ function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
46678
+ const points = [[x1, y1]];
46679
+ const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
46680
+ if (level > 16) return;
46681
+ const abx = (ax + bx) / 2, aby = (ay + by) / 2;
46682
+ const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
46683
+ const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
46684
+ const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
46685
+ const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
46686
+ const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
46687
+ const chordX = dx - ax, chordY = dy - ay;
46688
+ const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
46689
+ const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
46690
+ const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
46691
+ if (!significant2 && !significant3) {
46692
+ if (Math.abs(ax + cx - 2 * bx) + Math.abs(ay + cy - 2 * by) + Math.abs(bx + dx - 2 * cx) + Math.abs(by + dy - 2 * cy) <= 4) {
46693
+ points.push([midx, midy]);
46694
+ return;
46695
+ }
46696
+ } else {
46697
+ const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
46698
+ if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
46699
+ points.push([bcx, bcy]);
46700
+ return;
46701
+ }
46702
+ }
46703
+ subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
46704
+ subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
46705
+ };
46706
+ subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
46707
+ points.push([x4, y4]);
46708
+ return points;
46709
+ }
46710
+ function sampleImageLinear(image, x, y, out) {
46711
+ x = Math.max(0, Math.min(image.width - 1, x));
46712
+ y = Math.max(0, Math.min(image.height - 1, y));
46713
+ const x0 = Math.floor(x), y0 = Math.floor(y);
46714
+ const fx = x - x0, fy = y - y0;
46715
+ out.fill(0);
46716
+ for (let j = 0; j < 2; j++) {
46717
+ for (let i = 0; i < 2; i++) {
46718
+ const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
46719
+ const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
46720
+ out[0] = out[0] + image.data[offset] * alpha;
46721
+ out[1] = out[1] + image.data[offset + 1] * alpha;
46722
+ out[2] = out[2] + image.data[offset + 2] * alpha;
46723
+ out[3] = out[3] + alpha;
46724
+ }
46725
+ }
46726
+ if (out[3] > 0) {
46727
+ out[0] = out[0] / out[3];
46728
+ out[1] = out[1] / out[3];
46729
+ out[2] = out[2] / out[3];
46730
+ }
46731
+ }
46732
+ function downscaleImage(image, widthScale, heightScale) {
46733
+ const sample = new Float64Array(4);
46734
+ while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
46735
+ const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
46736
+ const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
46737
+ const data = new Uint8Array(width * height * 4);
46738
+ for (let y = 0; y < height; y++) {
46739
+ for (let x = 0; x < width; x++) {
46740
+ sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
46741
+ const offset = (y * width + x) * 4;
46742
+ for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
46743
+ }
46744
+ }
46745
+ widthScale /= image.width / width;
46746
+ heightScale /= image.height / height;
46747
+ image = { width, height, data };
46748
+ }
46749
+ return image;
46750
+ }
46677
46751
  function decodePng(pngBytes) {
46678
46752
  if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
46679
46753
  throw new Error("Invalid PNG signature");
@@ -47437,14 +47511,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
47437
47511
  const [p1x, p1y] = toScreen(seg.x1, seg.y1);
47438
47512
  const [p2x, p2y] = toScreen(seg.x2, seg.y2);
47439
47513
  const [p3x, p3y] = toScreen(seg.x, seg.y);
47440
- const steps = 12;
47514
+ const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
47441
47515
  let px = curX;
47442
47516
  let py = curY;
47443
- for (let s = 1; s <= steps; s++) {
47444
- const t = s / steps;
47445
- const mt = 1 - t;
47446
- const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
47447
- const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
47517
+ for (let i = 1; i < points.length; i++) {
47518
+ const [qx, qy] = points[i];
47448
47519
  edges.push({ x0: px, y0: py, x1: qx, y1: qy });
47449
47520
  px = qx;
47450
47521
  py = qy;
@@ -47729,6 +47800,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47729
47800
  const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
47730
47801
  const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
47731
47802
  const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
47803
+ if (minPx > maxPx || minPy > maxPy) continue;
47804
+ const source = downscaleImage(
47805
+ { width: img.width, height: img.height, data: img.decodedRgba },
47806
+ Math.hypot(d, c) * img.width / Math.abs(det * scale),
47807
+ Math.hypot(b, a) * img.height / Math.abs(det * scale)
47808
+ );
47809
+ const ax = a * scale / img.width, ay = b * scale / img.width;
47810
+ const bx = c * scale / img.height, by = d * scale / img.height;
47811
+ const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
47812
+ const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
47813
+ const sample = new Float64Array(4);
47732
47814
  for (let py = minPy; py <= maxPy; py++) {
47733
47815
  const yPdf = displayList.height - (py + 0.5) / scale;
47734
47816
  if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
@@ -47740,9 +47822,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47740
47822
  const u = (d * dxPdf - c * dyPdf) / det;
47741
47823
  const v = (-b * dxPdf + a * dyPdf) / det;
47742
47824
  if (u < 0 || u > 1 || v < 0 || v > 1) continue;
47743
- const sx = Math.min(img.width - 1, Math.max(0, Math.floor(u * img.width)));
47744
- const sy = Math.min(img.height - 1, Math.max(0, Math.floor((1 - v) * img.height)));
47745
- const sIdx = (sy * img.width + sx) * 4;
47825
+ if (smooth) {
47826
+ sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
47827
+ } else {
47828
+ const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
47829
+ const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
47830
+ const sIdx = (sy * source.width + sx) * 4;
47831
+ for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
47832
+ }
47746
47833
  blendPixel(
47747
47834
  rgba,
47748
47835
  width,
@@ -47750,11 +47837,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47750
47837
  px,
47751
47838
  py,
47752
47839
  {
47753
- r: img.decodedRgba[sIdx] / 255,
47754
- g: img.decodedRgba[sIdx + 1] / 255,
47755
- b: img.decodedRgba[sIdx + 2] / 255
47840
+ r: sample[0] / 255,
47841
+ g: sample[1] / 255,
47842
+ b: sample[2] / 255
47756
47843
  },
47757
- img.decodedRgba[sIdx + 3] / 255,
47844
+ sample[3] / 255,
47758
47845
  img.blendMode,
47759
47846
  clipMask
47760
47847
  );
@@ -62466,3 +62553,20 @@ export {
62466
62553
  * Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
62467
62554
  * See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
62468
62555
  */
62556
+ /*!
62557
+ * Anti-Grain Geometry - Version 2.3
62558
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
62559
+ *
62560
+ * Permission to copy, use, modify, sell and distribute this software
62561
+ * is granted provided this copyright notice appears in all copies.
62562
+ * This software is provided "as is" without express or implied
62563
+ * warranty, and with no claim as to its suitability for any purpose.
62564
+ *
62565
+ * Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
62566
+ * See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
62567
+ */
62568
+ /*!
62569
+ * Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
62570
+ * Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
62571
+ * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
62572
+ */
@@ -46674,6 +46674,80 @@ function createTrueTypeFontHandle(truetype) {
46674
46674
  }
46675
46675
  };
46676
46676
  }
46677
+ function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
46678
+ const points = [[x1, y1]];
46679
+ const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
46680
+ if (level > 16) return;
46681
+ const abx = (ax + bx) / 2, aby = (ay + by) / 2;
46682
+ const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
46683
+ const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
46684
+ const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
46685
+ const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
46686
+ const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
46687
+ const chordX = dx - ax, chordY = dy - ay;
46688
+ const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
46689
+ const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
46690
+ const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
46691
+ if (!significant2 && !significant3) {
46692
+ if (Math.abs(ax + cx - 2 * bx) + Math.abs(ay + cy - 2 * by) + Math.abs(bx + dx - 2 * cx) + Math.abs(by + dy - 2 * cy) <= 4) {
46693
+ points.push([midx, midy]);
46694
+ return;
46695
+ }
46696
+ } else {
46697
+ const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
46698
+ if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
46699
+ points.push([bcx, bcy]);
46700
+ return;
46701
+ }
46702
+ }
46703
+ subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
46704
+ subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
46705
+ };
46706
+ subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
46707
+ points.push([x4, y4]);
46708
+ return points;
46709
+ }
46710
+ function sampleImageLinear(image, x, y, out) {
46711
+ x = Math.max(0, Math.min(image.width - 1, x));
46712
+ y = Math.max(0, Math.min(image.height - 1, y));
46713
+ const x0 = Math.floor(x), y0 = Math.floor(y);
46714
+ const fx = x - x0, fy = y - y0;
46715
+ out.fill(0);
46716
+ for (let j = 0; j < 2; j++) {
46717
+ for (let i = 0; i < 2; i++) {
46718
+ const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
46719
+ const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
46720
+ out[0] = out[0] + image.data[offset] * alpha;
46721
+ out[1] = out[1] + image.data[offset + 1] * alpha;
46722
+ out[2] = out[2] + image.data[offset + 2] * alpha;
46723
+ out[3] = out[3] + alpha;
46724
+ }
46725
+ }
46726
+ if (out[3] > 0) {
46727
+ out[0] = out[0] / out[3];
46728
+ out[1] = out[1] / out[3];
46729
+ out[2] = out[2] / out[3];
46730
+ }
46731
+ }
46732
+ function downscaleImage(image, widthScale, heightScale) {
46733
+ const sample = new Float64Array(4);
46734
+ while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
46735
+ const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
46736
+ const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
46737
+ const data = new Uint8Array(width * height * 4);
46738
+ for (let y = 0; y < height; y++) {
46739
+ for (let x = 0; x < width; x++) {
46740
+ sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
46741
+ const offset = (y * width + x) * 4;
46742
+ for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
46743
+ }
46744
+ }
46745
+ widthScale /= image.width / width;
46746
+ heightScale /= image.height / height;
46747
+ image = { width, height, data };
46748
+ }
46749
+ return image;
46750
+ }
46677
46751
  function decodePng(pngBytes) {
46678
46752
  if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
46679
46753
  throw new Error("Invalid PNG signature");
@@ -47437,14 +47511,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
47437
47511
  const [p1x, p1y] = toScreen(seg.x1, seg.y1);
47438
47512
  const [p2x, p2y] = toScreen(seg.x2, seg.y2);
47439
47513
  const [p3x, p3y] = toScreen(seg.x, seg.y);
47440
- const steps = 12;
47514
+ const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
47441
47515
  let px = curX;
47442
47516
  let py = curY;
47443
- for (let s = 1; s <= steps; s++) {
47444
- const t = s / steps;
47445
- const mt = 1 - t;
47446
- const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
47447
- const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
47517
+ for (let i = 1; i < points.length; i++) {
47518
+ const [qx, qy] = points[i];
47448
47519
  edges.push({ x0: px, y0: py, x1: qx, y1: qy });
47449
47520
  px = qx;
47450
47521
  py = qy;
@@ -47729,6 +47800,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47729
47800
  const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
47730
47801
  const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
47731
47802
  const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
47803
+ if (minPx > maxPx || minPy > maxPy) continue;
47804
+ const source = downscaleImage(
47805
+ { width: img.width, height: img.height, data: img.decodedRgba },
47806
+ Math.hypot(d, c) * img.width / Math.abs(det * scale),
47807
+ Math.hypot(b, a) * img.height / Math.abs(det * scale)
47808
+ );
47809
+ const ax = a * scale / img.width, ay = b * scale / img.width;
47810
+ const bx = c * scale / img.height, by = d * scale / img.height;
47811
+ const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
47812
+ const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
47813
+ const sample = new Float64Array(4);
47732
47814
  for (let py = minPy; py <= maxPy; py++) {
47733
47815
  const yPdf = displayList.height - (py + 0.5) / scale;
47734
47816
  if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
@@ -47740,9 +47822,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47740
47822
  const u = (d * dxPdf - c * dyPdf) / det;
47741
47823
  const v = (-b * dxPdf + a * dyPdf) / det;
47742
47824
  if (u < 0 || u > 1 || v < 0 || v > 1) continue;
47743
- const sx = Math.min(img.width - 1, Math.max(0, Math.floor(u * img.width)));
47744
- const sy = Math.min(img.height - 1, Math.max(0, Math.floor((1 - v) * img.height)));
47745
- const sIdx = (sy * img.width + sx) * 4;
47825
+ if (smooth) {
47826
+ sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
47827
+ } else {
47828
+ const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
47829
+ const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
47830
+ const sIdx = (sy * source.width + sx) * 4;
47831
+ for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
47832
+ }
47746
47833
  blendPixel(
47747
47834
  rgba,
47748
47835
  width,
@@ -47750,11 +47837,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
47750
47837
  px,
47751
47838
  py,
47752
47839
  {
47753
- r: img.decodedRgba[sIdx] / 255,
47754
- g: img.decodedRgba[sIdx + 1] / 255,
47755
- b: img.decodedRgba[sIdx + 2] / 255
47840
+ r: sample[0] / 255,
47841
+ g: sample[1] / 255,
47842
+ b: sample[2] / 255
47756
47843
  },
47757
- img.decodedRgba[sIdx + 3] / 255,
47844
+ sample[3] / 255,
47758
47845
  img.blendMode,
47759
47846
  clipMask
47760
47847
  );
@@ -62466,3 +62553,20 @@ export {
62466
62553
  * Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
62467
62554
  * See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
62468
62555
  */
62556
+ /*!
62557
+ * Anti-Grain Geometry - Version 2.3
62558
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
62559
+ *
62560
+ * Permission to copy, use, modify, sell and distribute this software
62561
+ * is granted provided this copyright notice appears in all copies.
62562
+ * This software is provided "as is" without express or implied
62563
+ * warranty, and with no claim as to its suitability for any purpose.
62564
+ *
62565
+ * Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
62566
+ * See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
62567
+ */
62568
+ /*!
62569
+ * Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
62570
+ * Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
62571
+ * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
62572
+ */
@@ -40078,6 +40078,84 @@ function createTrueTypeFontHandle(truetype) {
40078
40078
  };
40079
40079
  }
40080
40080
 
40081
+ // src/render/cubic.ts
40082
+ function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
40083
+ const points = [[x1, y1]];
40084
+ const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
40085
+ if (level > 16) return;
40086
+ const abx = (ax + bx) / 2, aby = (ay + by) / 2;
40087
+ const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
40088
+ const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
40089
+ const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
40090
+ const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
40091
+ const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
40092
+ const chordX = dx - ax, chordY = dy - ay;
40093
+ const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
40094
+ const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
40095
+ const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
40096
+ if (!significant2 && !significant3) {
40097
+ if (Math.abs(ax + cx - 2 * bx) + Math.abs(ay + cy - 2 * by) + Math.abs(bx + dx - 2 * cx) + Math.abs(by + dy - 2 * cy) <= 4) {
40098
+ points.push([midx, midy]);
40099
+ return;
40100
+ }
40101
+ } else {
40102
+ const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
40103
+ if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
40104
+ points.push([bcx, bcy]);
40105
+ return;
40106
+ }
40107
+ }
40108
+ subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
40109
+ subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
40110
+ };
40111
+ subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
40112
+ points.push([x4, y4]);
40113
+ return points;
40114
+ }
40115
+
40116
+ // src/render/image-sampling.ts
40117
+ function sampleImageLinear(image, x, y, out) {
40118
+ x = Math.max(0, Math.min(image.width - 1, x));
40119
+ y = Math.max(0, Math.min(image.height - 1, y));
40120
+ const x0 = Math.floor(x), y0 = Math.floor(y);
40121
+ const fx = x - x0, fy = y - y0;
40122
+ out.fill(0);
40123
+ for (let j = 0; j < 2; j++) {
40124
+ for (let i = 0; i < 2; i++) {
40125
+ const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
40126
+ const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
40127
+ out[0] = out[0] + image.data[offset] * alpha;
40128
+ out[1] = out[1] + image.data[offset + 1] * alpha;
40129
+ out[2] = out[2] + image.data[offset + 2] * alpha;
40130
+ out[3] = out[3] + alpha;
40131
+ }
40132
+ }
40133
+ if (out[3] > 0) {
40134
+ out[0] = out[0] / out[3];
40135
+ out[1] = out[1] / out[3];
40136
+ out[2] = out[2] / out[3];
40137
+ }
40138
+ }
40139
+ function downscaleImage(image, widthScale, heightScale) {
40140
+ const sample = new Float64Array(4);
40141
+ while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
40142
+ const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
40143
+ const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
40144
+ const data = new Uint8Array(width * height * 4);
40145
+ for (let y = 0; y < height; y++) {
40146
+ for (let x = 0; x < width; x++) {
40147
+ sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
40148
+ const offset = (y * width + x) * 4;
40149
+ for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
40150
+ }
40151
+ }
40152
+ widthScale /= image.width / width;
40153
+ heightScale /= image.height / height;
40154
+ image = { width, height, data };
40155
+ }
40156
+ return image;
40157
+ }
40158
+
40081
40159
  // src/render/raster.ts
40082
40160
  function encodePng(bitmap) {
40083
40161
  return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
@@ -41238,14 +41316,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
41238
41316
  const [p1x, p1y] = toScreen(seg.x1, seg.y1);
41239
41317
  const [p2x, p2y] = toScreen(seg.x2, seg.y2);
41240
41318
  const [p3x, p3y] = toScreen(seg.x, seg.y);
41241
- const steps = 12;
41319
+ const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
41242
41320
  let px = curX;
41243
41321
  let py = curY;
41244
- for (let s = 1; s <= steps; s++) {
41245
- const t = s / steps;
41246
- const mt = 1 - t;
41247
- const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
41248
- const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
41322
+ for (let i = 1; i < points.length; i++) {
41323
+ const [qx, qy] = points[i];
41249
41324
  edges.push({ x0: px, y0: py, x1: qx, y1: qy });
41250
41325
  px = qx;
41251
41326
  py = qy;
@@ -41530,6 +41605,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
41530
41605
  const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
41531
41606
  const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
41532
41607
  const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
41608
+ if (minPx > maxPx || minPy > maxPy) continue;
41609
+ const source = downscaleImage(
41610
+ { width: img.width, height: img.height, data: img.decodedRgba },
41611
+ Math.hypot(d, c) * img.width / Math.abs(det * scale),
41612
+ Math.hypot(b, a) * img.height / Math.abs(det * scale)
41613
+ );
41614
+ const ax = a * scale / img.width, ay = b * scale / img.width;
41615
+ const bx = c * scale / img.height, by = d * scale / img.height;
41616
+ const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
41617
+ const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
41618
+ const sample = new Float64Array(4);
41533
41619
  for (let py = minPy; py <= maxPy; py++) {
41534
41620
  const yPdf = displayList.height - (py + 0.5) / scale;
41535
41621
  if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
@@ -41541,9 +41627,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
41541
41627
  const u = (d * dxPdf - c * dyPdf) / det;
41542
41628
  const v = (-b * dxPdf + a * dyPdf) / det;
41543
41629
  if (u < 0 || u > 1 || v < 0 || v > 1) continue;
41544
- const sx = Math.min(img.width - 1, Math.max(0, Math.floor(u * img.width)));
41545
- const sy = Math.min(img.height - 1, Math.max(0, Math.floor((1 - v) * img.height)));
41546
- const sIdx = (sy * img.width + sx) * 4;
41630
+ if (smooth) {
41631
+ sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
41632
+ } else {
41633
+ const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
41634
+ const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
41635
+ const sIdx = (sy * source.width + sx) * 4;
41636
+ for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
41637
+ }
41547
41638
  blendPixel(
41548
41639
  rgba,
41549
41640
  width,
@@ -41551,11 +41642,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
41551
41642
  px,
41552
41643
  py,
41553
41644
  {
41554
- r: img.decodedRgba[sIdx] / 255,
41555
- g: img.decodedRgba[sIdx + 1] / 255,
41556
- b: img.decodedRgba[sIdx + 2] / 255
41645
+ r: sample[0] / 255,
41646
+ g: sample[1] / 255,
41647
+ b: sample[2] / 255
41557
41648
  },
41558
- img.decodedRgba[sIdx + 3] / 255,
41649
+ sample[3] / 255,
41559
41650
  img.blendMode,
41560
41651
  clipMask
41561
41652
  );
@@ -42638,3 +42729,20 @@ export {
42638
42729
  * Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
42639
42730
  * See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
42640
42731
  */
42732
+ /*!
42733
+ * Anti-Grain Geometry - Version 2.3
42734
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
42735
+ *
42736
+ * Permission to copy, use, modify, sell and distribute this software
42737
+ * is granted provided this copyright notice appears in all copies.
42738
+ * This software is provided "as is" without express or implied
42739
+ * warranty, and with no claim as to its suitability for any purpose.
42740
+ *
42741
+ * Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
42742
+ * See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
42743
+ */
42744
+ /*!
42745
+ * Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
42746
+ * Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
42747
+ * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
42748
+ */
@@ -48,11 +48,11 @@ import {
48
48
  trimImage,
49
49
  unflattenImage,
50
50
  unpremultiplyRgbaImage
51
- } from "./chunk-UCI6ZQFB.js";
51
+ } from "./chunk-F7MJRXQ2.js";
52
52
  import {
53
53
  PdfDocument,
54
54
  encodePng
55
- } from "./chunk-S3SCPBHC.js";
55
+ } from "./chunk-P3Q2QSCA.js";
56
56
  import {
57
57
  createLuaFilterCapability
58
58
  } from "./chunk-Y2KHC6TZ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  renderPdfPageToPng
4
- } from "./chunk-S3SCPBHC.js";
4
+ } from "./chunk-P3Q2QSCA.js";
5
5
  import {
6
6
  init_buffer
7
7
  } from "./chunk-HX3SHTCE.js";