@poe-platform/safe-bash 0.1.759 → 0.1.761
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 +74 -17
- package/dist/image-ast/index.js +74 -17
- package/dist/pdf-ast/ast.d.ts +8 -3
- package/dist/pdf-ast/index.js +80 -20
- package/dist/safe-bash/chunks/{chunk-AYPUGSOV.js → chunk-CRQDMBQA.js} +123 -8
- package/dist/safe-bash/command-chunks/{chunk-HVEAK3OS.js → chunk-6VX5ZQL5.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-7JA44PVV.js → chunk-GR725WRX.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-BAUGDXLZ.js → chunk-OSMLVM7P.js} +79 -17
- 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/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/index.d.ts +1 -1
- package/dist/safe-bash/commands/python/llm-capability.d.ts +7 -3
- package/dist/safe-bash/commands/python/llm-capability.js +149 -10
- package/dist/safe-bash/core.browser.js +4 -3
- package/dist/safe-bash/shell/runtime.js +1 -1
- package/dist/safe-bash-command-ffmpeg/index.js +3125 -3085
- package/dist/safe-bash-command-gh/index.js +128 -27
- 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 +74 -17
- package/dist/safe-bash-command-pdfinfo/index.js +78 -20
- package/dist/safe-bash-command-pdftk/index.js +74 -17
- package/dist/safe-bash-command-pdftoppm/index.js +78 -20
- package/dist/safe-bash-command-pdftotext/index.js +74 -17
- package/dist/safe-bash-command-qpdf/index.js +74 -17
- 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 +74 -17
- package/dist/safe-bash-command-wkhtmltopdf/index.js +74 -17
- package/dist/safe-bash-io-engine/internal.d.ts +2 -2
- package/dist/safe-bash-mcp/index.d.ts +1 -1
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +30 -0
- package/third-party/pdf-ast/licenses/AGG-2.3.txt +7 -0
- package/third-party/pdf-ast/licenses/MIT.txt +21 -0
|
@@ -36259,7 +36259,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36259
36259
|
const [x, y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
36260
36260
|
transformedSegments.push({ kind: "cubic", x1, y1, x2, y2, x, y });
|
|
36261
36261
|
} else if (seg.kind === "rect") {
|
|
36262
|
-
if (hasRotOrShear) {
|
|
36262
|
+
if (hasRotOrShear || seg.width * st.ctm[0] < 0 || seg.height * st.ctm[3] < 0) {
|
|
36263
36263
|
const [p0x, p0y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
36264
36264
|
const [p1x, p1y] = transformPoint(st.ctm, seg.x + seg.width, seg.y);
|
|
36265
36265
|
const [p2x, p2y] = transformPoint(st.ctm, seg.x + seg.width, seg.y + seg.height);
|
|
@@ -36292,7 +36292,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36292
36292
|
transformedSegments.push({ kind: "close" });
|
|
36293
36293
|
}
|
|
36294
36294
|
}
|
|
36295
|
-
|
|
36295
|
+
const applyClip = () => {
|
|
36296
|
+
if (!node.clip) return;
|
|
36297
|
+
st.clipPaths = [...st.clipPaths ?? [], {
|
|
36298
|
+
segments: transformedSegments,
|
|
36299
|
+
fillRule: node.clip === "W*" ? "evenodd" : "nonzero"
|
|
36300
|
+
}];
|
|
36296
36301
|
let cMinX = Infinity, cMinY = Infinity, cMaxX = -Infinity, cMaxY = -Infinity;
|
|
36297
36302
|
for (const s of transformedSegments) {
|
|
36298
36303
|
if (s.kind === "move" || s.kind === "line") {
|
|
@@ -36320,8 +36325,11 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36320
36325
|
Math.min(st.clipRect[3], cMaxY)
|
|
36321
36326
|
] : [cMinX, cMinY, cMaxX, cMaxY];
|
|
36322
36327
|
}
|
|
36328
|
+
};
|
|
36329
|
+
if (node.paint === "n") {
|
|
36330
|
+
applyClip();
|
|
36331
|
+
break;
|
|
36323
36332
|
}
|
|
36324
|
-
if (node.paint === "n") break;
|
|
36325
36333
|
const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node.paint);
|
|
36326
36334
|
const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node.paint);
|
|
36327
36335
|
let evaluatedFillPattern = false;
|
|
@@ -36454,7 +36462,10 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36454
36462
|
}
|
|
36455
36463
|
}
|
|
36456
36464
|
}
|
|
36457
|
-
if (evaluatedFillPattern && !isStroke)
|
|
36465
|
+
if (evaluatedFillPattern && !isStroke) {
|
|
36466
|
+
applyClip();
|
|
36467
|
+
break;
|
|
36468
|
+
}
|
|
36458
36469
|
const fillRule = node.paint.includes("*") ? "evenodd" : "nonzero";
|
|
36459
36470
|
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
36460
36471
|
const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
|
|
@@ -36474,6 +36485,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36474
36485
|
...st.dashPhase !== void 0 ? { dashPhase: st.dashPhase } : {},
|
|
36475
36486
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
36476
36487
|
} });
|
|
36488
|
+
applyClip();
|
|
36477
36489
|
break;
|
|
36478
36490
|
}
|
|
36479
36491
|
case "xobject": {
|
|
@@ -39008,6 +39020,39 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
39008
39020
|
}
|
|
39009
39021
|
};
|
|
39010
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
|
+
}
|
|
39011
39056
|
function encodePng(bitmap) {
|
|
39012
39057
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
39013
39058
|
}
|
|
@@ -39998,14 +40043,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
39998
40043
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
39999
40044
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
40000
40045
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
40001
|
-
const
|
|
40046
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
40002
40047
|
let px = curX;
|
|
40003
40048
|
let py = curY;
|
|
40004
|
-
for (let
|
|
40005
|
-
const
|
|
40006
|
-
const mt = 1 - t;
|
|
40007
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
40008
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
40049
|
+
for (let i = 1; i < points.length; i++) {
|
|
40050
|
+
const [qx, qy] = points[i];
|
|
40009
40051
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
40010
40052
|
px = qx;
|
|
40011
40053
|
py = qy;
|
|
@@ -40024,8 +40066,8 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
40024
40066
|
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
40025
40067
|
edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
40026
40068
|
}
|
|
40027
|
-
const [rx0, ry0] = toScreen(seg.x, seg.y
|
|
40028
|
-
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y);
|
|
40069
|
+
const [rx0, ry0] = toScreen(seg.x, seg.y);
|
|
40070
|
+
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
|
|
40029
40071
|
edges.push(
|
|
40030
40072
|
{ x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
|
|
40031
40073
|
{ x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
|
|
@@ -40168,21 +40210,24 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40168
40210
|
}
|
|
40169
40211
|
const aaVec = options.antialiasVector !== false;
|
|
40170
40212
|
const aaTxt = options.antialiasText !== false;
|
|
40171
|
-
|
|
40213
|
+
let cachedClips;
|
|
40214
|
+
let cachedClipMask;
|
|
40172
40215
|
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
40173
40216
|
for (const original of paintOperations(displayList)) {
|
|
40174
40217
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
40175
40218
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
40176
40219
|
const clips = original.value.clipPaths;
|
|
40177
|
-
let clipMask = clips
|
|
40220
|
+
let clipMask = clips && clips === cachedClips ? cachedClipMask : void 0;
|
|
40178
40221
|
if (clips && !clipMask) {
|
|
40179
40222
|
clipMask = new Uint8Array(width * height * 4).fill(255);
|
|
40180
|
-
for (const
|
|
40223
|
+
for (const clip of clips) {
|
|
40224
|
+
const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
|
|
40181
40225
|
const layer = new Uint8Array(width * height * 4);
|
|
40182
|
-
fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 });
|
|
40226
|
+
fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
40183
40227
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
40184
40228
|
}
|
|
40185
|
-
|
|
40229
|
+
cachedClips = clips;
|
|
40230
|
+
cachedClipMask = clipMask;
|
|
40186
40231
|
}
|
|
40187
40232
|
const imageClips = original.value.clipImages;
|
|
40188
40233
|
if (imageClips) {
|
|
@@ -42355,3 +42400,15 @@ export {
|
|
|
42355
42400
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
42356
42401
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
42357
42402
|
*/
|
|
42403
|
+
/*!
|
|
42404
|
+
* Anti-Grain Geometry - Version 2.3
|
|
42405
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
42406
|
+
*
|
|
42407
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
42408
|
+
* is granted provided this copyright notice appears in all copies.
|
|
42409
|
+
* This software is provided "as is" without express or implied
|
|
42410
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
42411
|
+
*
|
|
42412
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
42413
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
42414
|
+
*/
|
|
@@ -35914,7 +35914,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
35914
35914
|
const [x, y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
35915
35915
|
transformedSegments.push({ kind: "cubic", x1, y1, x2, y2, x, y });
|
|
35916
35916
|
} else if (seg.kind === "rect") {
|
|
35917
|
-
if (hasRotOrShear) {
|
|
35917
|
+
if (hasRotOrShear || seg.width * st.ctm[0] < 0 || seg.height * st.ctm[3] < 0) {
|
|
35918
35918
|
const [p0x, p0y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
35919
35919
|
const [p1x, p1y] = transformPoint(st.ctm, seg.x + seg.width, seg.y);
|
|
35920
35920
|
const [p2x, p2y] = transformPoint(st.ctm, seg.x + seg.width, seg.y + seg.height);
|
|
@@ -35947,7 +35947,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
35947
35947
|
transformedSegments.push({ kind: "close" });
|
|
35948
35948
|
}
|
|
35949
35949
|
}
|
|
35950
|
-
|
|
35950
|
+
const applyClip = () => {
|
|
35951
|
+
if (!node.clip) return;
|
|
35952
|
+
st.clipPaths = [...st.clipPaths ?? [], {
|
|
35953
|
+
segments: transformedSegments,
|
|
35954
|
+
fillRule: node.clip === "W*" ? "evenodd" : "nonzero"
|
|
35955
|
+
}];
|
|
35951
35956
|
let cMinX = Infinity, cMinY = Infinity, cMaxX = -Infinity, cMaxY = -Infinity;
|
|
35952
35957
|
for (const s of transformedSegments) {
|
|
35953
35958
|
if (s.kind === "move" || s.kind === "line") {
|
|
@@ -35975,8 +35980,11 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
35975
35980
|
Math.min(st.clipRect[3], cMaxY)
|
|
35976
35981
|
] : [cMinX, cMinY, cMaxX, cMaxY];
|
|
35977
35982
|
}
|
|
35983
|
+
};
|
|
35984
|
+
if (node.paint === "n") {
|
|
35985
|
+
applyClip();
|
|
35986
|
+
break;
|
|
35978
35987
|
}
|
|
35979
|
-
if (node.paint === "n") break;
|
|
35980
35988
|
const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node.paint);
|
|
35981
35989
|
const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node.paint);
|
|
35982
35990
|
let evaluatedFillPattern = false;
|
|
@@ -36109,7 +36117,10 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36109
36117
|
}
|
|
36110
36118
|
}
|
|
36111
36119
|
}
|
|
36112
|
-
if (evaluatedFillPattern && !isStroke)
|
|
36120
|
+
if (evaluatedFillPattern && !isStroke) {
|
|
36121
|
+
applyClip();
|
|
36122
|
+
break;
|
|
36123
|
+
}
|
|
36113
36124
|
const fillRule = node.paint.includes("*") ? "evenodd" : "nonzero";
|
|
36114
36125
|
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
36115
36126
|
const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
|
|
@@ -36129,6 +36140,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36129
36140
|
...st.dashPhase !== void 0 ? { dashPhase: st.dashPhase } : {},
|
|
36130
36141
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
36131
36142
|
} });
|
|
36143
|
+
applyClip();
|
|
36132
36144
|
break;
|
|
36133
36145
|
}
|
|
36134
36146
|
case "xobject": {
|
|
@@ -38773,6 +38785,39 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
38773
38785
|
}
|
|
38774
38786
|
};
|
|
38775
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
|
+
}
|
|
38776
38821
|
function decodePng(pngBytes) {
|
|
38777
38822
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
38778
38823
|
throw new Error("Invalid PNG signature");
|
|
@@ -39536,14 +39581,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
39536
39581
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
39537
39582
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
39538
39583
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
39539
|
-
const
|
|
39584
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
39540
39585
|
let px = curX;
|
|
39541
39586
|
let py = curY;
|
|
39542
|
-
for (let
|
|
39543
|
-
const
|
|
39544
|
-
const mt = 1 - t;
|
|
39545
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
39546
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
39587
|
+
for (let i = 1; i < points.length; i++) {
|
|
39588
|
+
const [qx, qy] = points[i];
|
|
39547
39589
|
edges.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
39548
39590
|
px = qx;
|
|
39549
39591
|
py = qy;
|
|
@@ -39562,8 +39604,8 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
|
|
|
39562
39604
|
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
39563
39605
|
edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
39564
39606
|
}
|
|
39565
|
-
const [rx0, ry0] = toScreen(seg.x, seg.y
|
|
39566
|
-
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y);
|
|
39607
|
+
const [rx0, ry0] = toScreen(seg.x, seg.y);
|
|
39608
|
+
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
|
|
39567
39609
|
edges.push(
|
|
39568
39610
|
{ x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
|
|
39569
39611
|
{ x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
|
|
@@ -39706,21 +39748,24 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
39706
39748
|
}
|
|
39707
39749
|
const aaVec = options.antialiasVector !== false;
|
|
39708
39750
|
const aaTxt = options.antialiasText !== false;
|
|
39709
|
-
|
|
39751
|
+
let cachedClips;
|
|
39752
|
+
let cachedClipMask;
|
|
39710
39753
|
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
39711
39754
|
for (const original of paintOperations(displayList)) {
|
|
39712
39755
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
39713
39756
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
39714
39757
|
const clips = original.value.clipPaths;
|
|
39715
|
-
let clipMask = clips
|
|
39758
|
+
let clipMask = clips && clips === cachedClips ? cachedClipMask : void 0;
|
|
39716
39759
|
if (clips && !clipMask) {
|
|
39717
39760
|
clipMask = new Uint8Array(width * height * 4).fill(255);
|
|
39718
|
-
for (const
|
|
39761
|
+
for (const clip of clips) {
|
|
39762
|
+
const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
|
|
39719
39763
|
const layer = new Uint8Array(width * height * 4);
|
|
39720
|
-
fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 });
|
|
39764
|
+
fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
39721
39765
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
39722
39766
|
}
|
|
39723
|
-
|
|
39767
|
+
cachedClips = clips;
|
|
39768
|
+
cachedClipMask = clipMask;
|
|
39724
39769
|
}
|
|
39725
39770
|
const imageClips = original.value.clipImages;
|
|
39726
39771
|
if (imageClips) {
|
|
@@ -43067,3 +43112,15 @@ export {
|
|
|
43067
43112
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
43068
43113
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
43069
43114
|
*/
|
|
43115
|
+
/*!
|
|
43116
|
+
* Anti-Grain Geometry - Version 2.3
|
|
43117
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
43118
|
+
*
|
|
43119
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
43120
|
+
* is granted provided this copyright notice appears in all copies.
|
|
43121
|
+
* This software is provided "as is" without express or implied
|
|
43122
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
43123
|
+
*
|
|
43124
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
43125
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
43126
|
+
*/
|
|
@@ -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-GR725WRX.js";
|
|
15
|
+
import "../safe-bash/command-chunks/chunk-OSMLVM7P.js";
|
|
16
16
|
import {
|
|
17
17
|
init_buffer
|
|
18
18
|
} from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
|
|
@@ -209421,7 +209421,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209421
209421
|
const [x, y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
209422
209422
|
transformedSegments.push({ kind: "cubic", x1, y1, x2, y2, x, y });
|
|
209423
209423
|
} else if (seg.kind === "rect") {
|
|
209424
|
-
if (hasRotOrShear) {
|
|
209424
|
+
if (hasRotOrShear || seg.width * st.ctm[0] < 0 || seg.height * st.ctm[3] < 0) {
|
|
209425
209425
|
const [p0x, p0y] = transformPoint(st.ctm, seg.x, seg.y);
|
|
209426
209426
|
const [p1x, p1y] = transformPoint(st.ctm, seg.x + seg.width, seg.y);
|
|
209427
209427
|
const [p2x, p2y] = transformPoint(st.ctm, seg.x + seg.width, seg.y + seg.height);
|
|
@@ -209454,7 +209454,12 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209454
209454
|
transformedSegments.push({ kind: "close" });
|
|
209455
209455
|
}
|
|
209456
209456
|
}
|
|
209457
|
-
|
|
209457
|
+
const applyClip = () => {
|
|
209458
|
+
if (!node3.clip) return;
|
|
209459
|
+
st.clipPaths = [...st.clipPaths ?? [], {
|
|
209460
|
+
segments: transformedSegments,
|
|
209461
|
+
fillRule: node3.clip === "W*" ? "evenodd" : "nonzero"
|
|
209462
|
+
}];
|
|
209458
209463
|
let cMinX = Infinity, cMinY = Infinity, cMaxX = -Infinity, cMaxY = -Infinity;
|
|
209459
209464
|
for (const s of transformedSegments) {
|
|
209460
209465
|
if (s.kind === "move" || s.kind === "line") {
|
|
@@ -209482,8 +209487,11 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209482
209487
|
Math.min(st.clipRect[3], cMaxY)
|
|
209483
209488
|
] : [cMinX, cMinY, cMaxX, cMaxY];
|
|
209484
209489
|
}
|
|
209490
|
+
};
|
|
209491
|
+
if (node3.paint === "n") {
|
|
209492
|
+
applyClip();
|
|
209493
|
+
break;
|
|
209485
209494
|
}
|
|
209486
|
-
if (node3.paint === "n") break;
|
|
209487
209495
|
const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node3.paint);
|
|
209488
209496
|
const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node3.paint);
|
|
209489
209497
|
let evaluatedFillPattern = false;
|
|
@@ -209616,7 +209624,10 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209616
209624
|
}
|
|
209617
209625
|
}
|
|
209618
209626
|
}
|
|
209619
|
-
if (evaluatedFillPattern && !isStroke)
|
|
209627
|
+
if (evaluatedFillPattern && !isStroke) {
|
|
209628
|
+
applyClip();
|
|
209629
|
+
break;
|
|
209630
|
+
}
|
|
209620
209631
|
const fillRule = node3.paint.includes("*") ? "evenodd" : "nonzero";
|
|
209621
209632
|
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
209622
209633
|
const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
|
|
@@ -209636,6 +209647,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209636
209647
|
...st.dashPhase !== void 0 ? { dashPhase: st.dashPhase } : {},
|
|
209637
209648
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
209638
209649
|
} });
|
|
209650
|
+
applyClip();
|
|
209639
209651
|
break;
|
|
209640
209652
|
}
|
|
209641
209653
|
case "xobject": {
|
|
@@ -212170,6 +212182,39 @@ function createTrueTypeFontHandle(truetype) {
|
|
|
212170
212182
|
}
|
|
212171
212183
|
};
|
|
212172
212184
|
}
|
|
212185
|
+
function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
212186
|
+
const points = [[x1, y1]];
|
|
212187
|
+
const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
|
|
212188
|
+
if (level > 16) return;
|
|
212189
|
+
const abx = (ax + bx) / 2, aby = (ay + by) / 2;
|
|
212190
|
+
const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
|
|
212191
|
+
const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
|
|
212192
|
+
const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
|
|
212193
|
+
const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
|
|
212194
|
+
const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
|
|
212195
|
+
const chordX = dx - ax, chordY = dy - ay;
|
|
212196
|
+
const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
|
|
212197
|
+
const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
|
|
212198
|
+
const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
|
|
212199
|
+
if (!significant2 && !significant3) {
|
|
212200
|
+
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) {
|
|
212201
|
+
points.push([midx, midy]);
|
|
212202
|
+
return;
|
|
212203
|
+
}
|
|
212204
|
+
} else {
|
|
212205
|
+
const distance2 = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
|
|
212206
|
+
if (distance2 * distance2 <= 0.25 * (chordX * chordX + chordY * chordY)) {
|
|
212207
|
+
points.push([bcx, bcy]);
|
|
212208
|
+
return;
|
|
212209
|
+
}
|
|
212210
|
+
}
|
|
212211
|
+
subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
|
|
212212
|
+
subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
|
|
212213
|
+
};
|
|
212214
|
+
subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
|
|
212215
|
+
points.push([x4, y4]);
|
|
212216
|
+
return points;
|
|
212217
|
+
}
|
|
212173
212218
|
function decodePng2(pngBytes) {
|
|
212174
212219
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
212175
212220
|
throw new Error("Invalid PNG signature");
|
|
@@ -212933,14 +212978,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale2, closeSubpaths = fal
|
|
|
212933
212978
|
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
212934
212979
|
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
212935
212980
|
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
212936
|
-
const
|
|
212981
|
+
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
212937
212982
|
let px = curX;
|
|
212938
212983
|
let py = curY;
|
|
212939
|
-
for (let
|
|
212940
|
-
const
|
|
212941
|
-
const mt = 1 - t;
|
|
212942
|
-
const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
|
|
212943
|
-
const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
|
|
212984
|
+
for (let i = 1; i < points.length; i++) {
|
|
212985
|
+
const [qx, qy] = points[i];
|
|
212944
212986
|
edges2.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
212945
212987
|
px = qx;
|
|
212946
212988
|
py = qy;
|
|
@@ -212959,8 +213001,8 @@ function segmentsToScreenEdges(segments, pageHeight, scale2, closeSubpaths = fal
|
|
|
212959
213001
|
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
212960
213002
|
edges2.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
212961
213003
|
}
|
|
212962
|
-
const [rx0, ry0] = toScreen(seg.x, seg.y
|
|
212963
|
-
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y);
|
|
213004
|
+
const [rx0, ry0] = toScreen(seg.x, seg.y);
|
|
213005
|
+
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
|
|
212964
213006
|
edges2.push(
|
|
212965
213007
|
{ x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
|
|
212966
213008
|
{ x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
|
|
@@ -213103,21 +213145,24 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213103
213145
|
}
|
|
213104
213146
|
const aaVec = options.antialiasVector !== false;
|
|
213105
213147
|
const aaTxt = options.antialiasText !== false;
|
|
213106
|
-
|
|
213148
|
+
let cachedClips;
|
|
213149
|
+
let cachedClipMask;
|
|
213107
213150
|
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
213108
213151
|
for (const original of paintOperations(displayList)) {
|
|
213109
213152
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
213110
213153
|
const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
213111
213154
|
const clips = original.value.clipPaths;
|
|
213112
|
-
let clipMask = clips
|
|
213155
|
+
let clipMask = clips && clips === cachedClips ? cachedClipMask : void 0;
|
|
213113
213156
|
if (clips && !clipMask) {
|
|
213114
213157
|
clipMask = new Uint8Array(width2 * height * 4).fill(255);
|
|
213115
|
-
for (const
|
|
213158
|
+
for (const clip2 of clips) {
|
|
213159
|
+
const { segments, fillRule } = "segments" in clip2 ? clip2 : { segments: clip2, fillRule: "nonzero" };
|
|
213116
213160
|
const layer = new Uint8Array(width2 * height * 4);
|
|
213117
|
-
fillEdgesScanline4x4(layer, width2, height, segmentsToScreenEdges(segments, displayList.height, scale2, true), { r: 1, g: 1, b: 1 });
|
|
213161
|
+
fillEdgesScanline4x4(layer, width2, height, segmentsToScreenEdges(segments, displayList.height, scale2, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
213118
213162
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
213119
213163
|
}
|
|
213120
|
-
|
|
213164
|
+
cachedClips = clips;
|
|
213165
|
+
cachedClipMask = clipMask;
|
|
213121
213166
|
}
|
|
213122
213167
|
const imageClips = original.value.clipImages;
|
|
213123
213168
|
if (imageClips) {
|
|
@@ -233961,6 +234006,18 @@ export {
|
|
|
233961
234006
|
* Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
|
|
233962
234007
|
* See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
|
|
233963
234008
|
*/
|
|
234009
|
+
/*!
|
|
234010
|
+
* Anti-Grain Geometry - Version 2.3
|
|
234011
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
234012
|
+
*
|
|
234013
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
234014
|
+
* is granted provided this copyright notice appears in all copies.
|
|
234015
|
+
* This software is provided "as is" without express or implied
|
|
234016
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
234017
|
+
*
|
|
234018
|
+
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
234019
|
+
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
234020
|
+
*/
|
|
233964
234021
|
/*! Bundled license information:
|
|
233965
234022
|
|
|
233966
234023
|
tslib/tslib.js:
|