@poe-platform/safe-bash 0.1.764 → 0.1.766
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 +80 -27
- package/dist/image-ast/index.js +80 -27
- package/dist/pdf-ast/ast.d.ts +2 -0
- package/dist/pdf-ast/index.js +106 -38
- package/dist/safe-bash/command-chunks/{chunk-B7YLGJRF.js → chunk-DKWMTHU3.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RDPJGIQF.js → chunk-IOH3F3ZO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-G3IIEU2N.js → chunk-XFUFHHLU.js} +80 -27
- package/dist/safe-bash-command-ffmpeg/index.js +4270 -4240
- 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 +80 -27
- package/dist/safe-bash-command-pdfinfo/index.js +106 -38
- package/dist/safe-bash-command-pdftk/index.js +80 -27
- package/dist/safe-bash-command-pdftoppm/index.js +106 -38
- package/dist/safe-bash-command-pdftotext/index.js +80 -27
- package/dist/safe-bash-command-qpdf/index.js +80 -27
- 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 +134 -36
- package/dist/safe-bash-command-wkhtmltopdf/index.js +80 -27
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +13 -0
|
@@ -35704,11 +35704,10 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
35704
35704
|
} else if (operator === "d") {
|
|
35705
35705
|
const arrNode = ops[0]?.kind === "array" ? ops[0] : void 0;
|
|
35706
35706
|
if (arrNode) {
|
|
35707
|
-
const
|
|
35708
|
-
const nums = arrNode.items.map((it) => it.kind === "number" ? it.value * ctmScale : 0).filter((v) => v >= 0);
|
|
35707
|
+
const nums = arrNode.items.map((it) => it.kind === "number" ? it.value : 0).filter((v) => v >= 0);
|
|
35709
35708
|
const sum = nums.reduce((a, b) => a + b, 0);
|
|
35710
35709
|
st.dashArray = sum > 0 ? nums : void 0;
|
|
35711
|
-
st.dashPhase = num(1, 0)
|
|
35710
|
+
st.dashPhase = num(1, 0);
|
|
35712
35711
|
} else {
|
|
35713
35712
|
st.dashArray = void 0;
|
|
35714
35713
|
st.dashPhase = void 0;
|
|
@@ -35840,10 +35839,11 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
35840
35839
|
const patArr = params.cosDoc.resolveArray(dArr.items[0]);
|
|
35841
35840
|
const phaseNode = params.cosDoc.resolve(dArr.items[1]);
|
|
35842
35841
|
if (patArr) {
|
|
35843
|
-
|
|
35842
|
+
const dashArray = patArr.items.map((it) => {
|
|
35844
35843
|
const r = params.cosDoc.resolve(it);
|
|
35845
35844
|
return r?.kind === "number" ? r.value : 0;
|
|
35846
|
-
}).filter((n) => n
|
|
35845
|
+
}).filter((n) => n >= 0);
|
|
35846
|
+
st.dashArray = dashArray.some((value) => value > 0) ? dashArray : void 0;
|
|
35847
35847
|
st.dashPhase = phaseNode?.kind === "number" ? phaseNode.value : 0;
|
|
35848
35848
|
}
|
|
35849
35849
|
}
|
|
@@ -36244,15 +36244,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36244
36244
|
break;
|
|
36245
36245
|
}
|
|
36246
36246
|
const fillRule = node.paint.includes("*") ? "evenodd" : "nonzero";
|
|
36247
|
-
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
36248
|
-
const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
|
|
36249
36247
|
emit({ kind: "path", value: {
|
|
36250
36248
|
segments: transformedSegments,
|
|
36251
36249
|
fillColor: isFill && !evaluatedFillPattern ? st.fillColor : void 0,
|
|
36252
36250
|
fillAlpha: isFill && !evaluatedFillPattern ? st.fillAlpha : void 0,
|
|
36253
36251
|
strokeColor: isStroke ? st.strokeColor : void 0,
|
|
36254
36252
|
strokeAlpha: isStroke ? st.strokeAlpha : void 0,
|
|
36255
|
-
strokeWidth:
|
|
36253
|
+
strokeWidth: st.strokeWidth,
|
|
36254
|
+
...isStroke ? { strokeMatrix: [...st.ctm] } : {},
|
|
36256
36255
|
...st.lineCap !== 0 ? { lineCap: st.lineCap } : {},
|
|
36257
36256
|
...st.lineJoin !== 0 ? { lineJoin: st.lineJoin } : {},
|
|
36258
36257
|
...st.miterLimit !== 10 ? { miterLimit: st.miterLimit } : {},
|
|
@@ -36440,14 +36439,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
36440
36439
|
if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
|
|
36441
36440
|
const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
|
|
36442
36441
|
const isStrokeGlyph = st.textRenderMode === 1 || st.textRenderMode === 2 || st.textRenderMode === 5 || st.textRenderMode === 6;
|
|
36443
|
-
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
36444
36442
|
const paint = {
|
|
36445
36443
|
segments: transformedGlyphSegs,
|
|
36446
36444
|
fillColor: isFillGlyph ? st.fillColor : void 0,
|
|
36447
36445
|
fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
|
|
36448
36446
|
strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
|
|
36449
36447
|
strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
|
|
36450
|
-
strokeWidth: isStrokeGlyph ? st.strokeWidth
|
|
36448
|
+
strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
|
|
36449
|
+
...isStrokeGlyph ? { strokeMatrix: [...st.ctm] } : {},
|
|
36451
36450
|
fillRule: "nonzero",
|
|
36452
36451
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
36453
36452
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
@@ -38958,7 +38957,7 @@ function dashSubpath(path, pattern, phase) {
|
|
|
38958
38957
|
while (remaining <= 0) {
|
|
38959
38958
|
if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
38960
38959
|
if (index % 2 === 0) {
|
|
38961
|
-
if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
|
|
38960
|
+
if (pattern[index] === 0) result.push({ points: [point, point], closed: false, zeroLengthDash: true });
|
|
38962
38961
|
flush();
|
|
38963
38962
|
}
|
|
38964
38963
|
index = (index + 1) % pattern.length;
|
|
@@ -38973,7 +38972,7 @@ function dashSubpath(path, pattern, phase) {
|
|
|
38973
38972
|
throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
38974
38973
|
}
|
|
38975
38974
|
let distance = 0;
|
|
38976
|
-
while (distance
|
|
38975
|
+
while (length - distance > 8 * Number.EPSILON * Math.max(1, length)) {
|
|
38977
38976
|
const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
|
|
38978
38977
|
advance(point);
|
|
38979
38978
|
const step = Math.min(remaining, length - distance);
|
|
@@ -39088,7 +39087,15 @@ function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], das
|
|
|
39088
39087
|
let closed = subpath.closed;
|
|
39089
39088
|
if (closed && points.length > 1 && Math.hypot(points[0][0] - points[points.length - 1][0], points[0][1] - points[points.length - 1][1]) <= 1e-14) points.pop();
|
|
39090
39089
|
if (points.length < 3) closed = false;
|
|
39091
|
-
if (points.length === 1 &&
|
|
39090
|
+
if (points.length === 1 && cap === 2 && subpath.zeroLengthDash) {
|
|
39091
|
+
contour = [];
|
|
39092
|
+
const [x, y] = points[0];
|
|
39093
|
+
add(x - half, y - half);
|
|
39094
|
+
add(x + half, y - half);
|
|
39095
|
+
add(x + half, y + half);
|
|
39096
|
+
add(x - half, y + half);
|
|
39097
|
+
contours.push(contour);
|
|
39098
|
+
} else if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
|
|
39092
39099
|
contour = [];
|
|
39093
39100
|
const [x, y] = points[0];
|
|
39094
39101
|
addCap([x, y], [x + 1, y]);
|
|
@@ -39807,11 +39814,10 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
|
|
|
39807
39814
|
rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
|
|
39808
39815
|
rgba[idx + 3] = Math.round(outA * 255);
|
|
39809
39816
|
}
|
|
39810
|
-
function segmentsToScreenPaths(segments, pageHeight, scale) {
|
|
39817
|
+
function segmentsToScreenPaths(segments, pageHeight, scale, toScreen = (x, y) => [x * scale, (pageHeight - y) * scale]) {
|
|
39811
39818
|
const paths = [];
|
|
39812
39819
|
let points = [];
|
|
39813
39820
|
let current = [0, 0];
|
|
39814
|
-
const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
|
|
39815
39821
|
for (const segment of segments) {
|
|
39816
39822
|
if (segment.kind === "move") {
|
|
39817
39823
|
if (points.length) paths.push({ points, closed: false });
|
|
@@ -39850,6 +39856,63 @@ function segmentsToScreenPaths(segments, pageHeight, scale) {
|
|
|
39850
39856
|
if (points.length) paths.push({ points, closed: false });
|
|
39851
39857
|
return paths;
|
|
39852
39858
|
}
|
|
39859
|
+
function inverseStrokeMatrix(matrix) {
|
|
39860
|
+
const [a, b, c, d, e, f] = matrix;
|
|
39861
|
+
const det = a * d - b * c;
|
|
39862
|
+
if (!Number.isFinite(det) || det === 0) return void 0;
|
|
39863
|
+
return [d / det, -b / det, -c / det, a / det, (c * f - d * e) / det, (b * e - a * f) / det];
|
|
39864
|
+
}
|
|
39865
|
+
function prepareStroke(path, scale) {
|
|
39866
|
+
const matrix = path.strokeMatrix ? [...path.strokeMatrix] : [1, 0, 0, 1, 0, 0];
|
|
39867
|
+
const [a, b, c, d] = matrix;
|
|
39868
|
+
const area = Math.abs(a * d - b * c) * scale * scale;
|
|
39869
|
+
if (!(area > 0) || !Number.isFinite(area)) return void 0;
|
|
39870
|
+
const normX = Math.hypot(a, b) * scale, normY = Math.hypot(c, d) * scale;
|
|
39871
|
+
let width = path.strokeWidth || 1;
|
|
39872
|
+
const scaleX = path.strokeWidth === 0 ? normY / area : Math.max(1, normY / (width * area));
|
|
39873
|
+
const scaleY = path.strokeWidth === 0 ? normX / area : Math.max(1, normX / (width * area));
|
|
39874
|
+
let dashArray = path.dashArray, dashPhase = path.dashPhase ?? 0;
|
|
39875
|
+
if (scaleX === scaleY) {
|
|
39876
|
+
width *= scaleX;
|
|
39877
|
+
} else {
|
|
39878
|
+
matrix[0] *= scaleX;
|
|
39879
|
+
matrix[1] *= scaleX;
|
|
39880
|
+
matrix[2] *= scaleY;
|
|
39881
|
+
matrix[3] *= scaleY;
|
|
39882
|
+
if (dashArray?.length) {
|
|
39883
|
+
const dashScale = Math.max(scaleX, scaleY);
|
|
39884
|
+
dashArray = dashArray.map((value) => value / dashScale);
|
|
39885
|
+
dashPhase /= dashScale;
|
|
39886
|
+
}
|
|
39887
|
+
}
|
|
39888
|
+
return { matrix, width, dashArray, dashPhase };
|
|
39889
|
+
}
|
|
39890
|
+
function strokeContours(path, pageHeight, scale) {
|
|
39891
|
+
const stroke = prepareStroke(path, scale);
|
|
39892
|
+
if (!stroke) return [];
|
|
39893
|
+
const inverse = inverseStrokeMatrix(stroke.matrix);
|
|
39894
|
+
if (!inverse) return [];
|
|
39895
|
+
const [a, b, c, d, e, f] = stroke.matrix;
|
|
39896
|
+
const strokeScale = scale * Math.hypot(a, b, c, d);
|
|
39897
|
+
const project = (x, y) => [
|
|
39898
|
+
(inverse[0] * x + inverse[2] * y + inverse[4]) * strokeScale,
|
|
39899
|
+
(inverse[1] * x + inverse[3] * y + inverse[5]) * strokeScale
|
|
39900
|
+
];
|
|
39901
|
+
const toScreen = ([x, y]) => [
|
|
39902
|
+
(a * x / strokeScale + c * y / strokeScale + e) * scale,
|
|
39903
|
+
(pageHeight - b * x / strokeScale - d * y / strokeScale - f) * scale
|
|
39904
|
+
];
|
|
39905
|
+
const contours = strokeOutlines(
|
|
39906
|
+
segmentsToScreenPaths(path.segments, pageHeight, scale, project),
|
|
39907
|
+
stroke.width * strokeScale,
|
|
39908
|
+
path.lineCap ?? 0,
|
|
39909
|
+
path.lineJoin ?? 0,
|
|
39910
|
+
path.miterLimit ?? 10,
|
|
39911
|
+
stroke.dashArray?.map((value) => Math.max(0, value * strokeScale)),
|
|
39912
|
+
stroke.dashPhase * strokeScale
|
|
39913
|
+
);
|
|
39914
|
+
return contours.map((points) => points.map(toScreen));
|
|
39915
|
+
}
|
|
39853
39916
|
function pathsToEdges(paths, closeSubpaths = false) {
|
|
39854
39917
|
const edges = [];
|
|
39855
39918
|
for (const { points, closed } of paths) {
|
|
@@ -40099,19 +40162,9 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
40099
40162
|
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
|
|
40100
40163
|
}
|
|
40101
40164
|
if (path.strokeColor) {
|
|
40102
|
-
const rawSw = path.strokeWidth * scale;
|
|
40103
|
-
const sw = Math.max(1, rawSw);
|
|
40165
|
+
const rawSw = path.strokeWidth * scale * (path.strokeMatrix ? Math.hypot(path.strokeMatrix[0], path.strokeMatrix[1]) : 1);
|
|
40104
40166
|
const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
|
|
40105
|
-
const
|
|
40106
|
-
segmentsToScreenPaths(path.segments, displayList.height, scale),
|
|
40107
|
-
sw,
|
|
40108
|
-
path.lineCap ?? 0,
|
|
40109
|
-
path.lineJoin ?? 0,
|
|
40110
|
-
path.miterLimit ?? 10,
|
|
40111
|
-
path.dashArray?.map((value) => Math.max(0, value * scale)),
|
|
40112
|
-
(path.dashPhase ?? 0) * scale
|
|
40113
|
-
);
|
|
40114
|
-
const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
|
|
40167
|
+
const edges = pathsToEdges(strokeContours(path, displayList.height, scale).map((points) => ({ points, closed: true })));
|
|
40115
40168
|
const clipScreen = path.clipRect ? [path.clipRect[0] * scale, (displayList.height - path.clipRect[3]) * scale, path.clipRect[2] * scale, (displayList.height - path.clipRect[1]) * scale] : void 0;
|
|
40116
40169
|
fillEdgesScanline4x4(
|
|
40117
40170
|
rgba,
|
|
@@ -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-IOH3F3ZO.js";
|
|
15
|
+
import "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
|
|
16
16
|
import {
|
|
17
17
|
init_buffer
|
|
18
18
|
} from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
|
|
@@ -209211,11 +209211,10 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209211
209211
|
} else if (operator === "d") {
|
|
209212
209212
|
const arrNode = ops[0]?.kind === "array" ? ops[0] : void 0;
|
|
209213
209213
|
if (arrNode) {
|
|
209214
|
-
const
|
|
209215
|
-
const nums = arrNode.items.map((it) => it.kind === "number" ? it.value * ctmScale : 0).filter((v) => v >= 0);
|
|
209214
|
+
const nums = arrNode.items.map((it) => it.kind === "number" ? it.value : 0).filter((v) => v >= 0);
|
|
209216
209215
|
const sum2 = nums.reduce((a3, b3) => a3 + b3, 0);
|
|
209217
209216
|
st.dashArray = sum2 > 0 ? nums : void 0;
|
|
209218
|
-
st.dashPhase = num(1, 0)
|
|
209217
|
+
st.dashPhase = num(1, 0);
|
|
209219
209218
|
} else {
|
|
209220
209219
|
st.dashArray = void 0;
|
|
209221
209220
|
st.dashPhase = void 0;
|
|
@@ -209347,10 +209346,11 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209347
209346
|
const patArr = params.cosDoc.resolveArray(dArr.items[0]);
|
|
209348
209347
|
const phaseNode = params.cosDoc.resolve(dArr.items[1]);
|
|
209349
209348
|
if (patArr) {
|
|
209350
|
-
|
|
209349
|
+
const dashArray = patArr.items.map((it) => {
|
|
209351
209350
|
const r = params.cosDoc.resolve(it);
|
|
209352
209351
|
return r?.kind === "number" ? r.value : 0;
|
|
209353
|
-
}).filter((n) => n
|
|
209352
|
+
}).filter((n) => n >= 0);
|
|
209353
|
+
st.dashArray = dashArray.some((value3) => value3 > 0) ? dashArray : void 0;
|
|
209354
209354
|
st.dashPhase = phaseNode?.kind === "number" ? phaseNode.value : 0;
|
|
209355
209355
|
}
|
|
209356
209356
|
}
|
|
@@ -209751,15 +209751,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209751
209751
|
break;
|
|
209752
209752
|
}
|
|
209753
209753
|
const fillRule = node3.paint.includes("*") ? "evenodd" : "nonzero";
|
|
209754
|
-
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
209755
|
-
const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
|
|
209756
209754
|
emit({ kind: "path", value: {
|
|
209757
209755
|
segments: transformedSegments,
|
|
209758
209756
|
fillColor: isFill && !evaluatedFillPattern ? st.fillColor : void 0,
|
|
209759
209757
|
fillAlpha: isFill && !evaluatedFillPattern ? st.fillAlpha : void 0,
|
|
209760
209758
|
strokeColor: isStroke ? st.strokeColor : void 0,
|
|
209761
209759
|
strokeAlpha: isStroke ? st.strokeAlpha : void 0,
|
|
209762
|
-
strokeWidth:
|
|
209760
|
+
strokeWidth: st.strokeWidth,
|
|
209761
|
+
...isStroke ? { strokeMatrix: [...st.ctm] } : {},
|
|
209763
209762
|
...st.lineCap !== 0 ? { lineCap: st.lineCap } : {},
|
|
209764
209763
|
...st.lineJoin !== 0 ? { lineJoin: st.lineJoin } : {},
|
|
209765
209764
|
...st.miterLimit !== 10 ? { miterLimit: st.miterLimit } : {},
|
|
@@ -209947,14 +209946,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209947
209946
|
if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
|
|
209948
209947
|
const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
|
|
209949
209948
|
const isStrokeGlyph = st.textRenderMode === 1 || st.textRenderMode === 2 || st.textRenderMode === 5 || st.textRenderMode === 6;
|
|
209950
|
-
const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
|
|
209951
209949
|
const paint = {
|
|
209952
209950
|
segments: transformedGlyphSegs,
|
|
209953
209951
|
fillColor: isFillGlyph ? st.fillColor : void 0,
|
|
209954
209952
|
fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
|
|
209955
209953
|
strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
|
|
209956
209954
|
strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
|
|
209957
|
-
strokeWidth: isStrokeGlyph ? st.strokeWidth
|
|
209955
|
+
strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
|
|
209956
|
+
...isStrokeGlyph ? { strokeMatrix: [...st.ctm] } : {},
|
|
209958
209957
|
fillRule: "nonzero",
|
|
209959
209958
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
209960
209959
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
@@ -212355,7 +212354,7 @@ function dashSubpath(path2, pattern, phase) {
|
|
|
212355
212354
|
while (remaining <= 0) {
|
|
212356
212355
|
if (++steps > MAX_STROKE_VERTICES) throw new PdfError2("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
212357
212356
|
if (index2 % 2 === 0) {
|
|
212358
|
-
if (pattern[index2] === 0) result2.push({ points: [point, point], closed: false });
|
|
212357
|
+
if (pattern[index2] === 0) result2.push({ points: [point, point], closed: false, zeroLengthDash: true });
|
|
212359
212358
|
flush();
|
|
212360
212359
|
}
|
|
212361
212360
|
index2 = (index2 + 1) % pattern.length;
|
|
@@ -212370,7 +212369,7 @@ function dashSubpath(path2, pattern, phase) {
|
|
|
212370
212369
|
throw new PdfError2("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
212371
212370
|
}
|
|
212372
212371
|
let distance2 = 0;
|
|
212373
|
-
while (distance2
|
|
212372
|
+
while (length - distance2 > 8 * Number.EPSILON * Math.max(1, length)) {
|
|
212374
212373
|
const point = [start[0] + dx * distance2 / length, start[1] + dy * distance2 / length];
|
|
212375
212374
|
advance2(point);
|
|
212376
212375
|
const step = Math.min(remaining, length - distance2);
|
|
@@ -212485,7 +212484,15 @@ function strokeOutlines(paths, width2, cap, join3, miterLimit, dashArray = [], d
|
|
|
212485
212484
|
let closed = subpath.closed;
|
|
212486
212485
|
if (closed && points.length > 1 && Math.hypot(points[0][0] - points[points.length - 1][0], points[0][1] - points[points.length - 1][1]) <= 1e-14) points.pop();
|
|
212487
212486
|
if (points.length < 3) closed = false;
|
|
212488
|
-
if (points.length === 1 &&
|
|
212487
|
+
if (points.length === 1 && cap === 2 && subpath.zeroLengthDash) {
|
|
212488
|
+
contour = [];
|
|
212489
|
+
const [x, y] = points[0];
|
|
212490
|
+
add5(x - half, y - half);
|
|
212491
|
+
add5(x + half, y - half);
|
|
212492
|
+
add5(x + half, y + half);
|
|
212493
|
+
add5(x - half, y + half);
|
|
212494
|
+
contours.push(contour);
|
|
212495
|
+
} else if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
|
|
212489
212496
|
contour = [];
|
|
212490
212497
|
const [x, y] = points[0];
|
|
212491
212498
|
addCap([x, y], [x + 1, y]);
|
|
@@ -213204,11 +213211,10 @@ function blendPixel(rgba, width2, height, px, py, color5, alpha, blendMode, clip
|
|
|
213204
213211
|
rgba[idx + 2] = Math.round((effB * a3 + cbB * dstA * (1 - a3)) / outA * 255);
|
|
213205
213212
|
rgba[idx + 3] = Math.round(outA * 255);
|
|
213206
213213
|
}
|
|
213207
|
-
function segmentsToScreenPaths(segments, pageHeight, scale2) {
|
|
213214
|
+
function segmentsToScreenPaths(segments, pageHeight, scale2, toScreen = (x, y) => [x * scale2, (pageHeight - y) * scale2]) {
|
|
213208
213215
|
const paths = [];
|
|
213209
213216
|
let points = [];
|
|
213210
213217
|
let current = [0, 0];
|
|
213211
|
-
const toScreen = (x, y) => [x * scale2, (pageHeight - y) * scale2];
|
|
213212
213218
|
for (const segment of segments) {
|
|
213213
213219
|
if (segment.kind === "move") {
|
|
213214
213220
|
if (points.length) paths.push({ points, closed: false });
|
|
@@ -213247,6 +213253,63 @@ function segmentsToScreenPaths(segments, pageHeight, scale2) {
|
|
|
213247
213253
|
if (points.length) paths.push({ points, closed: false });
|
|
213248
213254
|
return paths;
|
|
213249
213255
|
}
|
|
213256
|
+
function inverseStrokeMatrix(matrix2) {
|
|
213257
|
+
const [a3, b3, c4, d2, e, f2] = matrix2;
|
|
213258
|
+
const det = a3 * d2 - b3 * c4;
|
|
213259
|
+
if (!Number.isFinite(det) || det === 0) return void 0;
|
|
213260
|
+
return [d2 / det, -b3 / det, -c4 / det, a3 / det, (c4 * f2 - d2 * e) / det, (b3 * e - a3 * f2) / det];
|
|
213261
|
+
}
|
|
213262
|
+
function prepareStroke(path2, scale2) {
|
|
213263
|
+
const matrix2 = path2.strokeMatrix ? [...path2.strokeMatrix] : [1, 0, 0, 1, 0, 0];
|
|
213264
|
+
const [a3, b3, c4, d2] = matrix2;
|
|
213265
|
+
const area = Math.abs(a3 * d2 - b3 * c4) * scale2 * scale2;
|
|
213266
|
+
if (!(area > 0) || !Number.isFinite(area)) return void 0;
|
|
213267
|
+
const normX = Math.hypot(a3, b3) * scale2, normY = Math.hypot(c4, d2) * scale2;
|
|
213268
|
+
let width2 = path2.strokeWidth || 1;
|
|
213269
|
+
const scaleX = path2.strokeWidth === 0 ? normY / area : Math.max(1, normY / (width2 * area));
|
|
213270
|
+
const scaleY = path2.strokeWidth === 0 ? normX / area : Math.max(1, normX / (width2 * area));
|
|
213271
|
+
let dashArray = path2.dashArray, dashPhase = path2.dashPhase ?? 0;
|
|
213272
|
+
if (scaleX === scaleY) {
|
|
213273
|
+
width2 *= scaleX;
|
|
213274
|
+
} else {
|
|
213275
|
+
matrix2[0] *= scaleX;
|
|
213276
|
+
matrix2[1] *= scaleX;
|
|
213277
|
+
matrix2[2] *= scaleY;
|
|
213278
|
+
matrix2[3] *= scaleY;
|
|
213279
|
+
if (dashArray?.length) {
|
|
213280
|
+
const dashScale = Math.max(scaleX, scaleY);
|
|
213281
|
+
dashArray = dashArray.map((value3) => value3 / dashScale);
|
|
213282
|
+
dashPhase /= dashScale;
|
|
213283
|
+
}
|
|
213284
|
+
}
|
|
213285
|
+
return { matrix: matrix2, width: width2, dashArray, dashPhase };
|
|
213286
|
+
}
|
|
213287
|
+
function strokeContours(path2, pageHeight, scale2) {
|
|
213288
|
+
const stroke = prepareStroke(path2, scale2);
|
|
213289
|
+
if (!stroke) return [];
|
|
213290
|
+
const inverse2 = inverseStrokeMatrix(stroke.matrix);
|
|
213291
|
+
if (!inverse2) return [];
|
|
213292
|
+
const [a3, b3, c4, d2, e, f2] = stroke.matrix;
|
|
213293
|
+
const strokeScale = scale2 * Math.hypot(a3, b3, c4, d2);
|
|
213294
|
+
const project = (x, y) => [
|
|
213295
|
+
(inverse2[0] * x + inverse2[2] * y + inverse2[4]) * strokeScale,
|
|
213296
|
+
(inverse2[1] * x + inverse2[3] * y + inverse2[5]) * strokeScale
|
|
213297
|
+
];
|
|
213298
|
+
const toScreen = ([x, y]) => [
|
|
213299
|
+
(a3 * x / strokeScale + c4 * y / strokeScale + e) * scale2,
|
|
213300
|
+
(pageHeight - b3 * x / strokeScale - d2 * y / strokeScale - f2) * scale2
|
|
213301
|
+
];
|
|
213302
|
+
const contours = strokeOutlines(
|
|
213303
|
+
segmentsToScreenPaths(path2.segments, pageHeight, scale2, project),
|
|
213304
|
+
stroke.width * strokeScale,
|
|
213305
|
+
path2.lineCap ?? 0,
|
|
213306
|
+
path2.lineJoin ?? 0,
|
|
213307
|
+
path2.miterLimit ?? 10,
|
|
213308
|
+
stroke.dashArray?.map((value3) => Math.max(0, value3 * strokeScale)),
|
|
213309
|
+
stroke.dashPhase * strokeScale
|
|
213310
|
+
);
|
|
213311
|
+
return contours.map((points) => points.map(toScreen));
|
|
213312
|
+
}
|
|
213250
213313
|
function pathsToEdges(paths, closeSubpaths = false) {
|
|
213251
213314
|
const edges2 = [];
|
|
213252
213315
|
for (const { points, closed } of paths) {
|
|
@@ -213496,19 +213559,9 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213496
213559
|
fillEdgesScanline4x4(rgba, width2, height, edges2, path2.fillColor, path2.fillAlpha ?? 1, path2.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path2.blendMode, clipMask);
|
|
213497
213560
|
}
|
|
213498
213561
|
if (path2.strokeColor) {
|
|
213499
|
-
const rawSw = path2.strokeWidth * scale2;
|
|
213500
|
-
const sw = Math.max(1, rawSw);
|
|
213562
|
+
const rawSw = path2.strokeWidth * scale2 * (path2.strokeMatrix ? Math.hypot(path2.strokeMatrix[0], path2.strokeMatrix[1]) : 1);
|
|
213501
213563
|
const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path2.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path2.strokeAlpha ?? 1;
|
|
213502
|
-
const
|
|
213503
|
-
segmentsToScreenPaths(path2.segments, displayList.height, scale2),
|
|
213504
|
-
sw,
|
|
213505
|
-
path2.lineCap ?? 0,
|
|
213506
|
-
path2.lineJoin ?? 0,
|
|
213507
|
-
path2.miterLimit ?? 10,
|
|
213508
|
-
path2.dashArray?.map((value3) => Math.max(0, value3 * scale2)),
|
|
213509
|
-
(path2.dashPhase ?? 0) * scale2
|
|
213510
|
-
);
|
|
213511
|
-
const edges2 = pathsToEdges(contours.map((points) => ({ points, closed: true })));
|
|
213564
|
+
const edges2 = pathsToEdges(strokeContours(path2, displayList.height, scale2).map((points) => ({ points, closed: true })));
|
|
213512
213565
|
const clipScreen = path2.clipRect ? [path2.clipRect[0] * scale2, (displayList.height - path2.clipRect[3]) * scale2, path2.clipRect[2] * scale2, (displayList.height - path2.clipRect[1]) * scale2] : void 0;
|
|
213513
213566
|
fillEdgesScanline4x4(
|
|
213514
213567
|
rgba,
|
|
@@ -231908,15 +231961,27 @@ function compile(pattern, host) {
|
|
|
231908
231961
|
return value3;
|
|
231909
231962
|
};
|
|
231910
231963
|
const literal2 = (byte, mode) => node3({ kind: "char", byte, test: (input) => mode.insensitive ? fold2(input) === fold2(byte) : input === byte });
|
|
231964
|
+
const blanks = () => {
|
|
231965
|
+
while (pattern[at] === " " || pattern[at] === " ") {
|
|
231966
|
+
host.tick();
|
|
231967
|
+
at++;
|
|
231968
|
+
}
|
|
231969
|
+
};
|
|
231911
231970
|
const identifier = (closing) => {
|
|
231971
|
+
if (closing === "}")
|
|
231972
|
+
blanks();
|
|
231912
231973
|
let name = "";
|
|
231913
231974
|
while (at < pattern.length && pattern[at] !== closing) {
|
|
231975
|
+
if (closing === "}" && (pattern[at] === " " || pattern[at] === " "))
|
|
231976
|
+
break;
|
|
231914
231977
|
host.tick();
|
|
231915
231978
|
const byte = pattern.charCodeAt(at++);
|
|
231916
231979
|
if (!word2(byte) || !name && byte >= 48 && byte <= 57)
|
|
231917
231980
|
return unsupported8();
|
|
231918
231981
|
name += String.fromCharCode(byte);
|
|
231919
231982
|
}
|
|
231983
|
+
if (closing === "}")
|
|
231984
|
+
blanks();
|
|
231920
231985
|
if (!name || pattern[at++] !== closing)
|
|
231921
231986
|
return unsupported8();
|
|
231922
231987
|
return name;
|
|
@@ -231957,16 +232022,29 @@ function compile(pattern, host) {
|
|
|
231957
232022
|
if (!inClass && (char >= "1" && char <= "9" || char === "g")) {
|
|
231958
232023
|
let index3;
|
|
231959
232024
|
if (char === "g") {
|
|
231960
|
-
|
|
231961
|
-
|
|
231962
|
-
|
|
231963
|
-
|
|
232025
|
+
let end2;
|
|
232026
|
+
if (pattern[at] === "{") {
|
|
232027
|
+
end2 = ++at;
|
|
232028
|
+
while (end2 < pattern.length && pattern[end2] !== "}") {
|
|
232029
|
+
host.tick();
|
|
232030
|
+
end2++;
|
|
232031
|
+
}
|
|
232032
|
+
if (end2 === pattern.length)
|
|
232033
|
+
return unsupported8();
|
|
232034
|
+
blanks();
|
|
232035
|
+
if (pattern[at] !== "-" && !(pattern[at] >= "0" && pattern[at] <= "9"))
|
|
232036
|
+
return namedReference(identifier("}"), mode);
|
|
232037
|
+
}
|
|
231964
232038
|
const relative = pattern[at] === "-";
|
|
231965
232039
|
if (relative)
|
|
231966
232040
|
at++;
|
|
232041
|
+
if (!(pattern[at] >= "1" && pattern[at] <= "9"))
|
|
232042
|
+
return unsupported8();
|
|
231967
232043
|
const number5 = integer7();
|
|
231968
|
-
if (
|
|
232044
|
+
if (number5 >= 2147483647)
|
|
231969
232045
|
return unsupported8();
|
|
232046
|
+
if (end2 !== void 0)
|
|
232047
|
+
at = end2 + 1;
|
|
231970
232048
|
index3 = relative ? captures - number5 + 1 : number5;
|
|
231971
232049
|
} else {
|
|
231972
232050
|
index3 = Number(char);
|
|
@@ -232169,8 +232247,25 @@ function compile(pattern, host) {
|
|
|
232169
232247
|
let behind = false;
|
|
232170
232248
|
let atomic = false;
|
|
232171
232249
|
let resetCaptures = false;
|
|
232172
|
-
let capture = pattern[at] === "?" ? void 0 : ++captures;
|
|
232173
|
-
if (pattern[at] === "
|
|
232250
|
+
let capture = pattern[at] === "?" || pattern[at] === "*" ? void 0 : ++captures;
|
|
232251
|
+
if (pattern[at] === "*") {
|
|
232252
|
+
at++;
|
|
232253
|
+
const name = identifier(":");
|
|
232254
|
+
if (name === "atomic")
|
|
232255
|
+
atomic = true;
|
|
232256
|
+
else if (name === "pla" || name === "positive_lookahead")
|
|
232257
|
+
assertion = false;
|
|
232258
|
+
else if (name === "nla" || name === "negative_lookahead")
|
|
232259
|
+
assertion = true;
|
|
232260
|
+
else if (name === "plb" || name === "positive_lookbehind") {
|
|
232261
|
+
assertion = false;
|
|
232262
|
+
behind = true;
|
|
232263
|
+
} else if (name === "nlb" || name === "negative_lookbehind") {
|
|
232264
|
+
assertion = true;
|
|
232265
|
+
behind = true;
|
|
232266
|
+
} else
|
|
232267
|
+
return unsupported8();
|
|
232268
|
+
} else if (pattern[at] === "?") {
|
|
232174
232269
|
at++;
|
|
232175
232270
|
if (pattern[at] === ":")
|
|
232176
232271
|
at++;
|
|
@@ -232183,8 +232278,11 @@ function compile(pattern, host) {
|
|
|
232183
232278
|
} else if (pattern[at] === "(") {
|
|
232184
232279
|
at++;
|
|
232185
232280
|
let condition;
|
|
232186
|
-
if (pattern[at] === "?" && (pattern[at + 1] === "=" || pattern[at + 1] === "!" || pattern[at + 1] === "<" && (pattern[at + 2] === "=" || pattern[at + 2] === "!"))) {
|
|
232187
|
-
|
|
232281
|
+
if (pattern[at] === "*" || pattern[at] === "?" && (pattern[at + 1] === "=" || pattern[at + 1] === "!" || pattern[at + 1] === "<" && (pattern[at + 2] === "=" || pattern[at + 2] === "!"))) {
|
|
232282
|
+
const assertionNode = group({ ...mode });
|
|
232283
|
+
if (assertionNode.kind !== "assert" && assertionNode.kind !== "behind")
|
|
232284
|
+
return unsupported8();
|
|
232285
|
+
condition = { kind: "assertion", node: assertionNode };
|
|
232188
232286
|
} else {
|
|
232189
232287
|
const indices = [];
|
|
232190
232288
|
if (pattern[at] === "<" || pattern[at] === "'") {
|