@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Poe Platform
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
thresholdImage,
|
|
29
29
|
tintImage,
|
|
30
30
|
trimImage
|
|
31
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
32
|
-
import "../safe-bash/command-chunks/chunk-
|
|
31
|
+
} from "../safe-bash/command-chunks/chunk-F7MJRXQ2.js";
|
|
32
|
+
import "../safe-bash/command-chunks/chunk-P3Q2QSCA.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-
|
|
5
|
+
} from "../safe-bash/command-chunks/chunk-D4GXXV65.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-
|
|
9
|
-
import "../safe-bash/command-chunks/chunk-
|
|
8
|
+
import "../safe-bash/command-chunks/chunk-F7MJRXQ2.js";
|
|
9
|
+
import "../safe-bash/command-chunks/chunk-P3Q2QSCA.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-
|
|
24
|
+
} from "../safe-bash/command-chunks/chunk-D4GXXV65.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-
|
|
28
|
-
import "../safe-bash/command-chunks/chunk-
|
|
27
|
+
import "../safe-bash/command-chunks/chunk-F7MJRXQ2.js";
|
|
28
|
+
import "../safe-bash/command-chunks/chunk-P3Q2QSCA.js";
|
|
29
29
|
import {
|
|
30
30
|
createLuaFilterCapability
|
|
31
31
|
} from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
|
|
@@ -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
|
}
|
|
@@ -39937,14 +40011,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
39937
40011
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
39938
40012
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
39939
40013
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
39940
|
-
const
|
|
40014
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
39941
40015
|
let px = curX;
|
|
39942
40016
|
let py = curY;
|
|
39943
|
-
for (let
|
|
39944
|
-
const
|
|
39945
|
-
const mt = 1 - t;
|
|
39946
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
39947
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40017
|
+
for (let i = 1; i < points.length; i++) {
|
|
40018
|
+
const [qx, qy] = points[i];
|
|
39948
40019
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
39949
40020
|
px = qx;
|
|
39950
40021
|
py = qy;
|
|
@@ -40229,6 +40300,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40229
40300
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
40230
40301
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
40231
40302
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
40303
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
40304
|
+
const source = downscaleImage(
|
|
40305
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
40306
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
40307
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
40308
|
+
);
|
|
40309
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
40310
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
40311
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
40312
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
40313
|
+
const sample = new Float64Array(4);
|
|
40232
40314
|
for (let py = minPy; py <= maxPy; py++) {
|
|
40233
40315
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
40234
40316
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -40240,9 +40322,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40240
40322
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
40241
40323
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
40242
40324
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
40243
|
-
|
|
40244
|
-
|
|
40245
|
-
|
|
40325
|
+
if (smooth) {
|
|
40326
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
40327
|
+
} else {
|
|
40328
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
40329
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
40330
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
40331
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
40332
|
+
}
|
|
40246
40333
|
blendPixel(
|
|
40247
40334
|
rgba,
|
|
40248
40335
|
width,
|
|
@@ -40250,11 +40337,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40250
40337
|
px,
|
|
40251
40338
|
py,
|
|
40252
40339
|
{
|
|
40253
|
-
r:
|
|
40254
|
-
g:
|
|
40255
|
-
b:
|
|
40340
|
+
r: sample[0] / 255,
|
|
40341
|
+
g: sample[1] / 255,
|
|
40342
|
+
b: sample[2] / 255
|
|
40256
40343
|
},
|
|
40257
|
-
|
|
40344
|
+
sample[3] / 255,
|
|
40258
40345
|
img.blendMode,
|
|
40259
40346
|
clipMask
|
|
40260
40347
|
);
|
|
@@ -41273,3 +41360,20 @@ export {
|
|
|
41273
41360
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
41274
41361
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
41275
41362
|
*/
|
|
41363
|
+
/*!
|
|
41364
|
+
* Anti-Grain Geometry - Version 2.3
|
|
41365
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
41366
|
+
*
|
|
41367
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
41368
|
+
* is granted provided this copyright notice appears in all copies.
|
|
41369
|
+
* This software is provided "as is" without express or implied
|
|
41370
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
41371
|
+
*
|
|
41372
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
41373
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
41374
|
+
*/
|
|
41375
|
+
/*!
|
|
41376
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
41377
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
41378
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
41379
|
+
*/
|
|
@@ -39214,6 +39214,80 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
39214
39214
|
}
|
|
39215
39215
|
};
|
|
39216
39216
|
}
|
|
39217
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
39218
|
+
const points = [[x1, y1]];
|
|
39219
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
39220
|
+
if (level > 16) return;
|
|
39221
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
39222
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
39223
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
39224
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
39225
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
39226
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
39227
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
39228
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
39229
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
39230
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
39231
|
+
if (!significant2 && !significant3) {
|
|
39232
|
+
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) {
|
|
39233
|
+
points.push([midx, midy]);
|
|
39234
|
+
return;
|
|
39235
|
+
}
|
|
39236
|
+
} else {
|
|
39237
|
+
const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
39238
|
+
if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
39239
|
+
points.push([bcx, bcy]);
|
|
39240
|
+
return;
|
|
39241
|
+
}
|
|
39242
|
+
}
|
|
39243
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
39244
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
39245
|
+
};
|
|
39246
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
39247
|
+
points.push([x4, y4]);
|
|
39248
|
+
return points;
|
|
39249
|
+
}
|
|
39250
|
+
function sampleImageLinear(image, x, y, out) {
|
|
39251
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
39252
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
39253
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
39254
|
+
const fx = x - x0, fy = y - y0;
|
|
39255
|
+
out.fill(0);
|
|
39256
|
+
for (let j = 0; j < 2; j++) {
|
|
39257
|
+
for (let i = 0; i < 2; i++) {
|
|
39258
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
39259
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
39260
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
39261
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
39262
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
39263
|
+
out[3] = out[3] + alpha;
|
|
39264
|
+
}
|
|
39265
|
+
}
|
|
39266
|
+
if (out[3] > 0) {
|
|
39267
|
+
out[0] = out[0] / out[3];
|
|
39268
|
+
out[1] = out[1] / out[3];
|
|
39269
|
+
out[2] = out[2] / out[3];
|
|
39270
|
+
}
|
|
39271
|
+
}
|
|
39272
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
39273
|
+
const sample = new Float64Array(4);
|
|
39274
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
39275
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
39276
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
39277
|
+
const data = new Uint8Array(width * height * 4);
|
|
39278
|
+
for (let y = 0; y < height; y++) {
|
|
39279
|
+
for (let x = 0; x < width; x++) {
|
|
39280
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
39281
|
+
const offset = (y * width + x) * 4;
|
|
39282
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
39283
|
+
}
|
|
39284
|
+
}
|
|
39285
|
+
widthScale /= image.width / width;
|
|
39286
|
+
heightScale /= image.height / height;
|
|
39287
|
+
image = { width, height, data };
|
|
39288
|
+
}
|
|
39289
|
+
return image;
|
|
39290
|
+
}
|
|
39217
39291
|
function encodePng(bitmap) {
|
|
39218
39292
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
39219
39293
|
}
|
|
@@ -40373,14 +40447,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
40373
40447
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
40374
40448
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
40375
40449
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
40376
|
-
const
|
|
40450
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
40377
40451
|
let px = curX;
|
|
40378
40452
|
let py = curY;
|
|
40379
|
-
for (let
|
|
40380
|
-
const
|
|
40381
|
-
const mt = 1 - t;
|
|
40382
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
40383
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40453
|
+
for (let i = 1; i < points.length; i++) {
|
|
40454
|
+
const [qx, qy] = points[i];
|
|
40384
40455
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
40385
40456
|
px = qx;
|
|
40386
40457
|
py = qy;
|
|
@@ -40665,6 +40736,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40665
40736
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
40666
40737
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
40667
40738
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
40739
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
40740
|
+
const source = downscaleImage(
|
|
40741
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
40742
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
40743
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
40744
|
+
);
|
|
40745
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
40746
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
40747
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
40748
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
40749
|
+
const sample = new Float64Array(4);
|
|
40668
40750
|
for (let py = minPy; py <= maxPy; py++) {
|
|
40669
40751
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
40670
40752
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -40676,9 +40758,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40676
40758
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
40677
40759
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
40678
40760
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40761
|
+
if (smooth) {
|
|
40762
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
40763
|
+
} else {
|
|
40764
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
40765
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
40766
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
40767
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
40768
|
+
}
|
|
40682
40769
|
blendPixel(
|
|
40683
40770
|
rgba,
|
|
40684
40771
|
width,
|
|
@@ -40686,11 +40773,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40686
40773
|
px,
|
|
40687
40774
|
py,
|
|
40688
40775
|
{
|
|
40689
|
-
r:
|
|
40690
|
-
g:
|
|
40691
|
-
b:
|
|
40776
|
+
r: sample[0] / 255,
|
|
40777
|
+
g: sample[1] / 255,
|
|
40778
|
+
b: sample[2] / 255
|
|
40692
40779
|
},
|
|
40693
|
-
|
|
40780
|
+
sample[3] / 255,
|
|
40694
40781
|
img.blendMode,
|
|
40695
40782
|
clipMask
|
|
40696
40783
|
);
|
|
@@ -44226,3 +44313,20 @@ export {
|
|
|
44226
44313
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
44227
44314
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
44228
44315
|
*/
|
|
44316
|
+
/*!
|
|
44317
|
+
* Anti-Grain Geometry - Version 2.3
|
|
44318
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
44319
|
+
*
|
|
44320
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
44321
|
+
* is granted provided this copyright notice appears in all copies.
|
|
44322
|
+
* This software is provided "as is" without express or implied
|
|
44323
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
44324
|
+
*
|
|
44325
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
44326
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
44327
|
+
*/
|
|
44328
|
+
/*!
|
|
44329
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
44330
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
44331
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
44332
|
+
*/
|
|
@@ -39239,6 +39239,80 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
39239
39239
|
}
|
|
39240
39240
|
};
|
|
39241
39241
|
}
|
|
39242
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
39243
|
+
const points = [[x1, y1]];
|
|
39244
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
39245
|
+
if (level > 16) return;
|
|
39246
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
39247
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
39248
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
39249
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
39250
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
39251
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
39252
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
39253
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
39254
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
39255
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
39256
|
+
if (!significant2 && !significant3) {
|
|
39257
|
+
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) {
|
|
39258
|
+
points.push([midx, midy]);
|
|
39259
|
+
return;
|
|
39260
|
+
}
|
|
39261
|
+
} else {
|
|
39262
|
+
const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
39263
|
+
if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
39264
|
+
points.push([bcx, bcy]);
|
|
39265
|
+
return;
|
|
39266
|
+
}
|
|
39267
|
+
}
|
|
39268
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
39269
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
39270
|
+
};
|
|
39271
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
39272
|
+
points.push([x4, y4]);
|
|
39273
|
+
return points;
|
|
39274
|
+
}
|
|
39275
|
+
function sampleImageLinear(image, x, y, out) {
|
|
39276
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
39277
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
39278
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
39279
|
+
const fx = x - x0, fy = y - y0;
|
|
39280
|
+
out.fill(0);
|
|
39281
|
+
for (let j = 0; j < 2; j++) {
|
|
39282
|
+
for (let i = 0; i < 2; i++) {
|
|
39283
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
39284
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
39285
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
39286
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
39287
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
39288
|
+
out[3] = out[3] + alpha;
|
|
39289
|
+
}
|
|
39290
|
+
}
|
|
39291
|
+
if (out[3] > 0) {
|
|
39292
|
+
out[0] = out[0] / out[3];
|
|
39293
|
+
out[1] = out[1] / out[3];
|
|
39294
|
+
out[2] = out[2] / out[3];
|
|
39295
|
+
}
|
|
39296
|
+
}
|
|
39297
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
39298
|
+
const sample = new Float64Array(4);
|
|
39299
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
39300
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
39301
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
39302
|
+
const data = new Uint8Array(width * height * 4);
|
|
39303
|
+
for (let y = 0; y < height; y++) {
|
|
39304
|
+
for (let x = 0; x < width; x++) {
|
|
39305
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
39306
|
+
const offset = (y * width + x) * 4;
|
|
39307
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
39308
|
+
}
|
|
39309
|
+
}
|
|
39310
|
+
widthScale /= image.width / width;
|
|
39311
|
+
heightScale /= image.height / height;
|
|
39312
|
+
image = { width, height, data };
|
|
39313
|
+
}
|
|
39314
|
+
return image;
|
|
39315
|
+
}
|
|
39242
39316
|
function decodePng(pngBytes) {
|
|
39243
39317
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
39244
39318
|
throw new Error("Invalid PNG signature");
|
|
@@ -40002,14 +40076,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
40002
40076
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
40003
40077
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
40004
40078
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
40005
|
-
const
|
|
40079
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
40006
40080
|
let px = curX;
|
|
40007
40081
|
let py = curY;
|
|
40008
|
-
for (let
|
|
40009
|
-
const
|
|
40010
|
-
const mt = 1 - t;
|
|
40011
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
40012
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40082
|
+
for (let i = 1; i < points.length; i++) {
|
|
40083
|
+
const [qx, qy] = points[i];
|
|
40013
40084
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
40014
40085
|
px = qx;
|
|
40015
40086
|
py = qy;
|
|
@@ -40294,6 +40365,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40294
40365
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
40295
40366
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
40296
40367
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
40368
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
40369
|
+
const source = downscaleImage(
|
|
40370
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
40371
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
40372
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
40373
|
+
);
|
|
40374
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
40375
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
40376
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
40377
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
40378
|
+
const sample = new Float64Array(4);
|
|
40297
40379
|
for (let py = minPy; py <= maxPy; py++) {
|
|
40298
40380
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
40299
40381
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -40305,9 +40387,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40305
40387
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
40306
40388
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
40307
40389
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
40308
|
-
|
|
40309
|
-
|
|
40310
|
-
|
|
40390
|
+
if (smooth) {
|
|
40391
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
40392
|
+
} else {
|
|
40393
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
40394
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
40395
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
40396
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
40397
|
+
}
|
|
40311
40398
|
blendPixel(
|
|
40312
40399
|
rgba,
|
|
40313
40400
|
width,
|
|
@@ -40315,11 +40402,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40315
40402
|
px,
|
|
40316
40403
|
py,
|
|
40317
40404
|
{
|
|
40318
|
-
r:
|
|
40319
|
-
g:
|
|
40320
|
-
b:
|
|
40405
|
+
r: sample[0] / 255,
|
|
40406
|
+
g: sample[1] / 255,
|
|
40407
|
+
b: sample[2] / 255
|
|
40321
40408
|
},
|
|
40322
|
-
|
|
40409
|
+
sample[3] / 255,
|
|
40323
40410
|
img.blendMode,
|
|
40324
40411
|
clipMask
|
|
40325
40412
|
);
|
|
@@ -42914,3 +43001,20 @@ export {
|
|
|
42914
43001
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42915
43002
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
42916
43003
|
*/
|
|
43004
|
+
/*!
|
|
43005
|
+
* Anti-Grain Geometry - Version 2.3
|
|
43006
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
43007
|
+
*
|
|
43008
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
43009
|
+
* is granted provided this copyright notice appears in all copies.
|
|
43010
|
+
* This software is provided "as is" without express or implied
|
|
43011
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
43012
|
+
*
|
|
43013
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
43014
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
43015
|
+
*/
|
|
43016
|
+
/*!
|
|
43017
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
43018
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
43019
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
43020
|
+
*/
|