@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.
- package/dist/image-ast/index.browser.js +117 -13
- package/dist/image-ast/index.js +117 -13
- package/dist/pdf-ast/index.js +121 -13
- package/dist/safe-bash/command-chunks/{chunk-MC4XXPQJ.js → chunk-D4GXXV65.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-UCI6ZQFB.js → chunk-F7MJRXQ2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-S3SCPBHC.js → chunk-P3Q2QSCA.js} +125 -13
- package/dist/safe-bash/commands/csvcut/index.d.ts +1 -1
- package/dist/safe-bash/commands/csvcut/index.js +3 -1
- package/dist/safe-bash/commands/csvgrep/index.d.ts +1 -1
- package/dist/safe-bash/commands/csvgrep/index.js +3 -1
- package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
- package/dist/safe-bash/commands/htmlq/index.js +4 -1
- package/dist/safe-bash/core.browser.js +10 -7
- package/dist/safe-bash/shell/runtime.js +5 -5
- package/dist/safe-bash-command-ffmpeg/index.js +1457 -1390
- package/dist/safe-bash-command-git/LICENSE +21 -0
- 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 +117 -13
- package/dist/safe-bash-command-pdfinfo/index.js +117 -13
- package/dist/safe-bash-command-pdftk/index.js +117 -13
- package/dist/safe-bash-command-pdftoppm/index.js +117 -13
- package/dist/safe-bash-command-pdftotext/index.js +117 -13
- package/dist/safe-bash-command-qpdf/index.js +117 -13
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +117 -13
- package/dist/safe-bash-command-wkhtmltopdf/index.js +117 -13
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +32 -0
- package/third-party/pdf-ast/licenses/AGG-2.3.txt +7 -0
- package/third-party/pdf-ast/licenses/MIT.txt +21 -0
|
@@ -38869,6 +38869,80 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
38869
38869
|
}
|
|
38870
38870
|
};
|
|
38871
38871
|
}
|
|
38872
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
38873
|
+
const points = [[x1, y1]];
|
|
38874
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
38875
|
+
if (level > 16) return;
|
|
38876
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
38877
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
38878
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
38879
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
38880
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
38881
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
38882
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
38883
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
38884
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
38885
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
38886
|
+
if (!significant2 && !significant3) {
|
|
38887
|
+
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) {
|
|
38888
|
+
points.push([midx, midy]);
|
|
38889
|
+
return;
|
|
38890
|
+
}
|
|
38891
|
+
} else {
|
|
38892
|
+
const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
38893
|
+
if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
38894
|
+
points.push([bcx, bcy]);
|
|
38895
|
+
return;
|
|
38896
|
+
}
|
|
38897
|
+
}
|
|
38898
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
38899
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
38900
|
+
};
|
|
38901
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
38902
|
+
points.push([x4, y4]);
|
|
38903
|
+
return points;
|
|
38904
|
+
}
|
|
38905
|
+
function sampleImageLinear(image, x, y, out) {
|
|
38906
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
38907
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
38908
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
38909
|
+
const fx = x - x0, fy = y - y0;
|
|
38910
|
+
out.fill(0);
|
|
38911
|
+
for (let j = 0; j < 2; j++) {
|
|
38912
|
+
for (let i = 0; i < 2; i++) {
|
|
38913
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
38914
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
38915
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
38916
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
38917
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
38918
|
+
out[3] = out[3] + alpha;
|
|
38919
|
+
}
|
|
38920
|
+
}
|
|
38921
|
+
if (out[3] > 0) {
|
|
38922
|
+
out[0] = out[0] / out[3];
|
|
38923
|
+
out[1] = out[1] / out[3];
|
|
38924
|
+
out[2] = out[2] / out[3];
|
|
38925
|
+
}
|
|
38926
|
+
}
|
|
38927
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
38928
|
+
const sample = new Float64Array(4);
|
|
38929
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
38930
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
38931
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
38932
|
+
const data = new Uint8Array(width * height * 4);
|
|
38933
|
+
for (let y = 0; y < height; y++) {
|
|
38934
|
+
for (let x = 0; x < width; x++) {
|
|
38935
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
38936
|
+
const offset = (y * width + x) * 4;
|
|
38937
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
38938
|
+
}
|
|
38939
|
+
}
|
|
38940
|
+
widthScale /= image.width / width;
|
|
38941
|
+
heightScale /= image.height / height;
|
|
38942
|
+
image = { width, height, data };
|
|
38943
|
+
}
|
|
38944
|
+
return image;
|
|
38945
|
+
}
|
|
38872
38946
|
function encodePng(bitmap) {
|
|
38873
38947
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
38874
38948
|
}
|
|
@@ -40028,14 +40102,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
40028
40102
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
40029
40103
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
40030
40104
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
40031
|
-
const
|
|
40105
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
40032
40106
|
let px = curX;
|
|
40033
40107
|
let py = curY;
|
|
40034
|
-
for (let
|
|
40035
|
-
const
|
|
40036
|
-
const mt = 1 - t;
|
|
40037
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
40038
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40108
|
+
for (let i = 1; i < points.length; i++) {
|
|
40109
|
+
const [qx, qy] = points[i];
|
|
40039
40110
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
40040
40111
|
px = qx;
|
|
40041
40112
|
py = qy;
|
|
@@ -40320,6 +40391,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40320
40391
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
40321
40392
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
40322
40393
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
40394
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
40395
|
+
const source = downscaleImage(
|
|
40396
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
40397
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
40398
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
40399
|
+
);
|
|
40400
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
40401
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
40402
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
40403
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
40404
|
+
const sample = new Float64Array(4);
|
|
40323
40405
|
for (let py = minPy; py <= maxPy; py++) {
|
|
40324
40406
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
40325
40407
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -40331,9 +40413,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40331
40413
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
40332
40414
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
40333
40415
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
40334
|
-
|
|
40335
|
-
|
|
40336
|
-
|
|
40416
|
+
if (smooth) {
|
|
40417
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
40418
|
+
} else {
|
|
40419
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
40420
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
40421
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
40422
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
40423
|
+
}
|
|
40337
40424
|
blendPixel(
|
|
40338
40425
|
rgba,
|
|
40339
40426
|
width,
|
|
@@ -40341,11 +40428,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40341
40428
|
px,
|
|
40342
40429
|
py,
|
|
40343
40430
|
{
|
|
40344
|
-
r:
|
|
40345
|
-
g:
|
|
40346
|
-
b:
|
|
40431
|
+
r: sample[0] / 255,
|
|
40432
|
+
g: sample[1] / 255,
|
|
40433
|
+
b: sample[2] / 255
|
|
40347
40434
|
},
|
|
40348
|
-
|
|
40435
|
+
sample[3] / 255,
|
|
40349
40436
|
img.blendMode,
|
|
40350
40437
|
clipMask
|
|
40351
40438
|
);
|
|
@@ -42096,3 +42183,20 @@ export {
|
|
|
42096
42183
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42097
42184
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
42098
42185
|
*/
|
|
42186
|
+
/*!
|
|
42187
|
+
* Anti-Grain Geometry - Version 2.3
|
|
42188
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
42189
|
+
*
|
|
42190
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
42191
|
+
* is granted provided this copyright notice appears in all copies.
|
|
42192
|
+
* This software is provided "as is" without express or implied
|
|
42193
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
42194
|
+
*
|
|
42195
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
42196
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
42197
|
+
*/
|
|
42198
|
+
/*!
|
|
42199
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
42200
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42201
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
42202
|
+
*/
|
|
@@ -39020,6 +39020,80 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
39020
39020
|
}
|
|
39021
39021
|
};
|
|
39022
39022
|
}
|
|
39023
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
39024
|
+
const points = [[x1, y1]];
|
|
39025
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
39026
|
+
if (level > 16) return;
|
|
39027
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
39028
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
39029
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
39030
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
39031
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
39032
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
39033
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
39034
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
39035
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
39036
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
39037
|
+
if (!significant2 && !significant3) {
|
|
39038
|
+
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) {
|
|
39039
|
+
points.push([midx, midy]);
|
|
39040
|
+
return;
|
|
39041
|
+
}
|
|
39042
|
+
} else {
|
|
39043
|
+
const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
39044
|
+
if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
39045
|
+
points.push([bcx, bcy]);
|
|
39046
|
+
return;
|
|
39047
|
+
}
|
|
39048
|
+
}
|
|
39049
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
39050
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
39051
|
+
};
|
|
39052
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
39053
|
+
points.push([x4, y4]);
|
|
39054
|
+
return points;
|
|
39055
|
+
}
|
|
39056
|
+
function sampleImageLinear(image, x, y, out) {
|
|
39057
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
39058
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
39059
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
39060
|
+
const fx = x - x0, fy = y - y0;
|
|
39061
|
+
out.fill(0);
|
|
39062
|
+
for (let j = 0; j < 2; j++) {
|
|
39063
|
+
for (let i = 0; i < 2; i++) {
|
|
39064
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
39065
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
39066
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
39067
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
39068
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
39069
|
+
out[3] = out[3] + alpha;
|
|
39070
|
+
}
|
|
39071
|
+
}
|
|
39072
|
+
if (out[3] > 0) {
|
|
39073
|
+
out[0] = out[0] / out[3];
|
|
39074
|
+
out[1] = out[1] / out[3];
|
|
39075
|
+
out[2] = out[2] / out[3];
|
|
39076
|
+
}
|
|
39077
|
+
}
|
|
39078
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
39079
|
+
const sample = new Float64Array(4);
|
|
39080
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
39081
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
39082
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
39083
|
+
const data = new Uint8Array(width * height * 4);
|
|
39084
|
+
for (let y = 0; y < height; y++) {
|
|
39085
|
+
for (let x = 0; x < width; x++) {
|
|
39086
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
39087
|
+
const offset = (y * width + x) * 4;
|
|
39088
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
39089
|
+
}
|
|
39090
|
+
}
|
|
39091
|
+
widthScale /= image.width / width;
|
|
39092
|
+
heightScale /= image.height / height;
|
|
39093
|
+
image = { width, height, data };
|
|
39094
|
+
}
|
|
39095
|
+
return image;
|
|
39096
|
+
}
|
|
39023
39097
|
function encodePng(bitmap) {
|
|
39024
39098
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
39025
39099
|
}
|
|
@@ -40010,14 +40084,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
40010
40084
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
40011
40085
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
40012
40086
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
40013
|
-
const
|
|
40087
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
40014
40088
|
let px = curX;
|
|
40015
40089
|
let py = curY;
|
|
40016
|
-
for (let
|
|
40017
|
-
const
|
|
40018
|
-
const mt = 1 - t;
|
|
40019
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
40020
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40090
|
+
for (let i = 1; i < points.length; i++) {
|
|
40091
|
+
const [qx, qy] = points[i];
|
|
40021
40092
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
40022
40093
|
px = qx;
|
|
40023
40094
|
py = qy;
|
|
@@ -40302,6 +40373,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40302
40373
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
40303
40374
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
40304
40375
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
40376
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
40377
|
+
const source = downscaleImage(
|
|
40378
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
40379
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
40380
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
40381
|
+
);
|
|
40382
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
40383
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
40384
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
40385
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
40386
|
+
const sample = new Float64Array(4);
|
|
40305
40387
|
for (let py = minPy; py <= maxPy; py++) {
|
|
40306
40388
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
40307
40389
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -40313,9 +40395,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40313
40395
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
40314
40396
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
40315
40397
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
40316
|
-
|
|
40317
|
-
|
|
40318
|
-
|
|
40398
|
+
if (smooth) {
|
|
40399
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
40400
|
+
} else {
|
|
40401
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
40402
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
40403
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
40404
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
40405
|
+
}
|
|
40319
40406
|
blendPixel(
|
|
40320
40407
|
rgba,
|
|
40321
40408
|
width,
|
|
@@ -40323,11 +40410,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40323
40410
|
px,
|
|
40324
40411
|
py,
|
|
40325
40412
|
{
|
|
40326
|
-
r:
|
|
40327
|
-
g:
|
|
40328
|
-
b:
|
|
40413
|
+
r: sample[0] / 255,
|
|
40414
|
+
g: sample[1] / 255,
|
|
40415
|
+
b: sample[2] / 255
|
|
40329
40416
|
},
|
|
40330
|
-
|
|
40417
|
+
sample[3] / 255,
|
|
40331
40418
|
img.blendMode,
|
|
40332
40419
|
clipMask
|
|
40333
40420
|
);
|
|
@@ -42370,3 +42457,20 @@ export {
|
|
|
42370
42457
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42371
42458
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
42372
42459
|
*/
|
|
42460
|
+
/*!
|
|
42461
|
+
* Anti-Grain Geometry - Version 2.3
|
|
42462
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
42463
|
+
*
|
|
42464
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
42465
|
+
* is granted provided this copyright notice appears in all copies.
|
|
42466
|
+
* This software is provided "as is" without express or implied
|
|
42467
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
42468
|
+
*
|
|
42469
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
42470
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
42471
|
+
*/
|
|
42472
|
+
/*!
|
|
42473
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
42474
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42475
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
42476
|
+
*/
|
|
@@ -38785,6 +38785,80 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
38785
38785
|
}
|
|
38786
38786
|
};
|
|
38787
38787
|
}
|
|
38788
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
38789
|
+
const points = [[x1, y1]];
|
|
38790
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
38791
|
+
if (level > 16) return;
|
|
38792
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
38793
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
38794
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
38795
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
38796
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
38797
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
38798
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
38799
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
38800
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
38801
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
38802
|
+
if (!significant2 && !significant3) {
|
|
38803
|
+
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) {
|
|
38804
|
+
points.push([midx, midy]);
|
|
38805
|
+
return;
|
|
38806
|
+
}
|
|
38807
|
+
} else {
|
|
38808
|
+
const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
38809
|
+
if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
38810
|
+
points.push([bcx, bcy]);
|
|
38811
|
+
return;
|
|
38812
|
+
}
|
|
38813
|
+
}
|
|
38814
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
38815
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
38816
|
+
};
|
|
38817
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
38818
|
+
points.push([x4, y4]);
|
|
38819
|
+
return points;
|
|
38820
|
+
}
|
|
38821
|
+
function sampleImageLinear(image, x, y, out) {
|
|
38822
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
38823
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
38824
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
38825
|
+
const fx = x - x0, fy = y - y0;
|
|
38826
|
+
out.fill(0);
|
|
38827
|
+
for (let j = 0; j < 2; j++) {
|
|
38828
|
+
for (let i = 0; i < 2; i++) {
|
|
38829
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
38830
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
38831
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
38832
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
38833
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
38834
|
+
out[3] = out[3] + alpha;
|
|
38835
|
+
}
|
|
38836
|
+
}
|
|
38837
|
+
if (out[3] > 0) {
|
|
38838
|
+
out[0] = out[0] / out[3];
|
|
38839
|
+
out[1] = out[1] / out[3];
|
|
38840
|
+
out[2] = out[2] / out[3];
|
|
38841
|
+
}
|
|
38842
|
+
}
|
|
38843
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
38844
|
+
const sample = new Float64Array(4);
|
|
38845
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
38846
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
38847
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
38848
|
+
const data = new Uint8Array(width * height * 4);
|
|
38849
|
+
for (let y = 0; y < height; y++) {
|
|
38850
|
+
for (let x = 0; x < width; x++) {
|
|
38851
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
38852
|
+
const offset = (y * width + x) * 4;
|
|
38853
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
38854
|
+
}
|
|
38855
|
+
}
|
|
38856
|
+
widthScale /= image.width / width;
|
|
38857
|
+
heightScale /= image.height / height;
|
|
38858
|
+
image = { width, height, data };
|
|
38859
|
+
}
|
|
38860
|
+
return image;
|
|
38861
|
+
}
|
|
38788
38862
|
function decodePng(pngBytes) {
|
|
38789
38863
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
38790
38864
|
throw new Error("Invalid PNG signature");
|
|
@@ -39548,14 +39622,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
39548
39622
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
39549
39623
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
39550
39624
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
39551
|
-
const
|
|
39625
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
39552
39626
|
let px = curX;
|
|
39553
39627
|
let py = curY;
|
|
39554
|
-
for (let
|
|
39555
|
-
const
|
|
39556
|
-
const mt = 1 - t;
|
|
39557
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
39558
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
39628
|
+
for (let i = 1; i < points.length; i++) {
|
|
39629
|
+
const [qx, qy] = points[i];
|
|
39559
39630
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
39560
39631
|
px = qx;
|
|
39561
39632
|
py = qy;
|
|
@@ -39840,6 +39911,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
39840
39911
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
39841
39912
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
39842
39913
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
39914
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
39915
|
+
const source = downscaleImage(
|
|
39916
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
39917
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
39918
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
39919
|
+
);
|
|
39920
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
39921
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
39922
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
39923
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
39924
|
+
const sample = new Float64Array(4);
|
|
39843
39925
|
for (let py = minPy; py <= maxPy; py++) {
|
|
39844
39926
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
39845
39927
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -39851,9 +39933,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
39851
39933
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
39852
39934
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
39853
39935
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
39854
|
-
|
|
39855
|
-
|
|
39856
|
-
|
|
39936
|
+
if (smooth) {
|
|
39937
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
39938
|
+
} else {
|
|
39939
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
39940
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
39941
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
39942
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
39943
|
+
}
|
|
39857
39944
|
blendPixel(
|
|
39858
39945
|
rgba,
|
|
39859
39946
|
width,
|
|
@@ -39861,11 +39948,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
39861
39948
|
px,
|
|
39862
39949
|
py,
|
|
39863
39950
|
{
|
|
39864
|
-
r:
|
|
39865
|
-
g:
|
|
39866
|
-
b:
|
|
39951
|
+
r: sample[0] / 255,
|
|
39952
|
+
g: sample[1] / 255,
|
|
39953
|
+
b: sample[2] / 255
|
|
39867
39954
|
},
|
|
39868
|
-
|
|
39955
|
+
sample[3] / 255,
|
|
39869
39956
|
img.blendMode,
|
|
39870
39957
|
clipMask
|
|
39871
39958
|
);
|
|
@@ -43082,3 +43169,20 @@ export {
|
|
|
43082
43169
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
43083
43170
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
43084
43171
|
*/
|
|
43172
|
+
/*!
|
|
43173
|
+
* Anti-Grain Geometry - Version 2.3
|
|
43174
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
43175
|
+
*
|
|
43176
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
43177
|
+
* is granted provided this copyright notice appears in all copies.
|
|
43178
|
+
* This software is provided "as is" without express or implied
|
|
43179
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
43180
|
+
*
|
|
43181
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
43182
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
43183
|
+
*/
|
|
43184
|
+
/*!
|
|
43185
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
43186
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
43187
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
43188
|
+
*/
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
readImageMetadata,
|
|
12
12
|
resizeImage,
|
|
13
13
|
rotateImage
|
|
14
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
15
|
-
import "../safe-bash/command-chunks/chunk-
|
|
14
|
+
} from "../safe-bash/command-chunks/chunk-F7MJRXQ2.js";
|
|
15
|
+
import "../safe-bash/command-chunks/chunk-P3Q2QSCA.js";
|
|
16
16
|
import {
|
|
17
17
|
init_buffer
|
|
18
18
|
} from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
|