@poe-platform/safe-bash 0.1.763 → 0.1.764
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 +268 -153
- package/dist/image-ast/index.js +268 -153
- package/dist/pdf-ast/index.js +270 -153
- package/dist/safe-bash/chunks/{chunk-CRQDMBQA.js → chunk-FSH7QRIC.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-4XHONGIU.js → chunk-B7YLGJRF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-S3G2B4OX.js → chunk-G3IIEU2N.js} +271 -153
- package/dist/safe-bash/command-chunks/{chunk-S5EX6UP5.js → chunk-RDPJGIQF.js} +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/llm-module.js +3 -1
- package/dist/safe-bash/commands/python/shell-module.js +7 -0
- package/dist/safe-bash/core.browser.js +32 -12
- package/dist/safe-bash/shell/runtime.js +43 -11
- package/dist/safe-bash-command-ffmpeg/index.js +5649 -5565
- 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 +268 -153
- package/dist/safe-bash-command-pdfinfo/index.js +268 -153
- package/dist/safe-bash-command-pdftk/index.js +268 -153
- package/dist/safe-bash-command-pdftoppm/index.js +268 -153
- package/dist/safe-bash-command-pdftotext/index.js +268 -153
- package/dist/safe-bash-command-qpdf/index.js +268 -153
- 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 +265 -150
- package/dist/safe-bash-command-wkhtmltopdf/index.js +269 -153
- package/dist/safe-playwright-cloudflare/browser-snapshot-labels.d.ts +14 -0
- package/dist/safe-playwright-cloudflare/browser-snapshot-labels.js +62 -0
- package/dist/safe-playwright-cloudflare/browser-snapshot-scheduler.js +8 -1
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +14 -0
package/dist/image-ast/index.js
CHANGED
|
@@ -46824,6 +46824,184 @@ function downscaleImage(image, widthScale, heightScale) {
|
|
|
46824
46824
|
}
|
|
46825
46825
|
return image;
|
|
46826
46826
|
}
|
|
46827
|
+
var MAX_STROKE_VERTICES = 1e6;
|
|
46828
|
+
function dashSubpath(path, pattern, phase) {
|
|
46829
|
+
const cycle = pattern.reduce((sum, value) => sum + value, 0);
|
|
46830
|
+
if (!(cycle > 0)) return [path];
|
|
46831
|
+
let offset = (phase % cycle + cycle) % cycle, index = 0;
|
|
46832
|
+
while (offset > 0) {
|
|
46833
|
+
if (offset < pattern[index]) break;
|
|
46834
|
+
offset -= pattern[index];
|
|
46835
|
+
index = (index + 1) % pattern.length;
|
|
46836
|
+
}
|
|
46837
|
+
let remaining = pattern[index] - offset;
|
|
46838
|
+
const points = path.closed ? [...path.points, path.points[0]] : path.points;
|
|
46839
|
+
const result = [];
|
|
46840
|
+
let current = [];
|
|
46841
|
+
let steps = 0;
|
|
46842
|
+
const flush = () => {
|
|
46843
|
+
if (current.length) result.push({ points: current, closed: false });
|
|
46844
|
+
current = [];
|
|
46845
|
+
};
|
|
46846
|
+
const advance = (point) => {
|
|
46847
|
+
while (remaining <= 0) {
|
|
46848
|
+
if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
46849
|
+
if (index % 2 === 0) {
|
|
46850
|
+
if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
|
|
46851
|
+
flush();
|
|
46852
|
+
}
|
|
46853
|
+
index = (index + 1) % pattern.length;
|
|
46854
|
+
remaining = pattern[index];
|
|
46855
|
+
}
|
|
46856
|
+
};
|
|
46857
|
+
for (let i = 1; i < points.length; i++) {
|
|
46858
|
+
const start = points[i - 1], end = points[i];
|
|
46859
|
+
const dx = end[0] - start[0], dy = end[1] - start[1];
|
|
46860
|
+
const length = Math.hypot(dx, dy);
|
|
46861
|
+
if (!Number.isFinite(length) || length / cycle * pattern.length > MAX_STROKE_VERTICES) {
|
|
46862
|
+
throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
46863
|
+
}
|
|
46864
|
+
let distance = 0;
|
|
46865
|
+
while (distance < length) {
|
|
46866
|
+
const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
|
|
46867
|
+
advance(point);
|
|
46868
|
+
const step = Math.min(remaining, length - distance);
|
|
46869
|
+
if (distance + step === distance || ++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
46870
|
+
distance += step;
|
|
46871
|
+
remaining -= step;
|
|
46872
|
+
if (index % 2 === 0) {
|
|
46873
|
+
if (!current.length) current.push(point);
|
|
46874
|
+
current.push([start[0] + dx * distance / length, start[1] + dy * distance / length]);
|
|
46875
|
+
}
|
|
46876
|
+
}
|
|
46877
|
+
}
|
|
46878
|
+
flush();
|
|
46879
|
+
if (path.closed && result.length) {
|
|
46880
|
+
const first = result[0], last = result[result.length - 1];
|
|
46881
|
+
const start = path.points[0];
|
|
46882
|
+
const firstPoint = first.points[0], lastPoint = last.points[last.points.length - 1];
|
|
46883
|
+
if (firstPoint[0] === start[0] && firstPoint[1] === start[1] && lastPoint[0] === start[0] && lastPoint[1] === start[1]) {
|
|
46884
|
+
if (first === last) result[0] = { points: first.points, closed: true };
|
|
46885
|
+
else {
|
|
46886
|
+
result[0] = { points: [...last.points, ...first.points.slice(1)], closed: false };
|
|
46887
|
+
result.pop();
|
|
46888
|
+
}
|
|
46889
|
+
}
|
|
46890
|
+
}
|
|
46891
|
+
return result;
|
|
46892
|
+
}
|
|
46893
|
+
function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], dashPhase = 0) {
|
|
46894
|
+
const half = width / 2;
|
|
46895
|
+
const contours = [];
|
|
46896
|
+
const pattern = dashArray.length % 2 ? [...dashArray, ...dashArray] : dashArray;
|
|
46897
|
+
let count = 0;
|
|
46898
|
+
let contour = [];
|
|
46899
|
+
const add = (x, y) => {
|
|
46900
|
+
if (++count > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke outline exceeds the vertex limit");
|
|
46901
|
+
contour.push([x, y]);
|
|
46902
|
+
};
|
|
46903
|
+
const arc = (point, dx1, dy1, dx2, dy2) => {
|
|
46904
|
+
let a1 = Math.atan2(dy1, dx1), a2 = Math.atan2(dy2, dx2);
|
|
46905
|
+
const ccw = a1 - a2 > 0 && a1 - a2 < Math.PI;
|
|
46906
|
+
const step = Math.acos(half / (half + 0.125)) * 2;
|
|
46907
|
+
add(point[0] + dx1, point[1] + dy1);
|
|
46908
|
+
if (step > 0) {
|
|
46909
|
+
if (!ccw) {
|
|
46910
|
+
if (a1 > a2) a2 += 2 * Math.PI;
|
|
46911
|
+
a2 -= step / 4;
|
|
46912
|
+
if ((a2 - a1) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
46913
|
+
for (a1 += step; a1 < a2; a1 += step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
46914
|
+
} else {
|
|
46915
|
+
if (a1 < a2) a2 -= 2 * Math.PI;
|
|
46916
|
+
a2 += step / 4;
|
|
46917
|
+
if ((a1 - a2) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
46918
|
+
for (a1 -= step; a1 > a2; a1 -= step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
46919
|
+
}
|
|
46920
|
+
}
|
|
46921
|
+
add(point[0] + dx2, point[1] + dy2);
|
|
46922
|
+
};
|
|
46923
|
+
const addCap = (point, next) => {
|
|
46924
|
+
const length = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
46925
|
+
const dx = half * (next[1] - point[1]) / length;
|
|
46926
|
+
const dy = half * (next[0] - point[0]) / length;
|
|
46927
|
+
if (cap !== 1) {
|
|
46928
|
+
const sx = cap === 2 ? dy : 0, sy = cap === 2 ? dx : 0;
|
|
46929
|
+
add(point[0] - dx - sx, point[1] + dy - sy);
|
|
46930
|
+
add(point[0] + dx - sx, point[1] - dy - sy);
|
|
46931
|
+
} else {
|
|
46932
|
+
const angle = Math.atan2(dy, -dx);
|
|
46933
|
+
const step = Math.max(1e-3, Math.acos(half / (half + 0.125)) * 2);
|
|
46934
|
+
add(point[0] - dx, point[1] + dy);
|
|
46935
|
+
for (let a = angle + step; a < angle + Math.PI - step / 4; a += step) add(point[0] + half * Math.cos(a), point[1] + half * Math.sin(a));
|
|
46936
|
+
add(point[0] + dx, point[1] - dy);
|
|
46937
|
+
}
|
|
46938
|
+
};
|
|
46939
|
+
const addJoin = (prev, point, next) => {
|
|
46940
|
+
const len1 = Math.hypot(point[0] - prev[0], point[1] - prev[1]);
|
|
46941
|
+
const len2 = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
46942
|
+
const dx1 = half * (point[1] - prev[1]) / len1, dy1 = half * (point[0] - prev[0]) / len1;
|
|
46943
|
+
const dx2 = half * (next[1] - point[1]) / len2, dy2 = half * (next[0] - point[0]) / len2;
|
|
46944
|
+
const inner = (next[0] - point[0]) * (point[1] - prev[1]) - (next[1] - point[1]) * (point[0] - prev[0]) > 0;
|
|
46945
|
+
if (!inner && join === 1) {
|
|
46946
|
+
arc(point, dx1, -dy1, dx2, -dy2);
|
|
46947
|
+
return;
|
|
46948
|
+
}
|
|
46949
|
+
if (inner || join === 0) {
|
|
46950
|
+
const ax = prev[0] + dx1, ay = prev[1] - dy1;
|
|
46951
|
+
const bx = point[0] + dx1, by = point[1] - dy1;
|
|
46952
|
+
const cx = point[0] + dx2, cy = point[1] - dy2;
|
|
46953
|
+
const dx = next[0] + dx2, dy = next[1] - dy2;
|
|
46954
|
+
const den = (bx - ax) * (dy - cy) - (by - ay) * (dx - cx);
|
|
46955
|
+
if (Math.abs(den) >= 1e-30) {
|
|
46956
|
+
const t = ((ay - cy) * (dx - cx) - (ax - cx) * (dy - cy)) / den;
|
|
46957
|
+
const x = ax + (bx - ax) * t, y = ay + (by - ay) * t;
|
|
46958
|
+
if (Math.hypot(x - point[0], y - point[1]) <= half * (inner ? 1.01 : miterLimit)) {
|
|
46959
|
+
add(x, y);
|
|
46960
|
+
return;
|
|
46961
|
+
}
|
|
46962
|
+
} else if ((bx - prev[0]) * dy1 - (prev[1] - by) * dx1 < 0 !== (bx - next[0]) * dy1 - (next[1] - by) * dx1 < 0) {
|
|
46963
|
+
add(bx, by);
|
|
46964
|
+
return;
|
|
46965
|
+
}
|
|
46966
|
+
}
|
|
46967
|
+
add(point[0] + dx1, point[1] - dy1);
|
|
46968
|
+
add(point[0] + dx2, point[1] - dy2);
|
|
46969
|
+
};
|
|
46970
|
+
for (const path of paths) {
|
|
46971
|
+
for (const subpath of pattern.length ? dashSubpath(path, pattern, dashPhase) : [path]) {
|
|
46972
|
+
const points = [];
|
|
46973
|
+
for (const point of subpath.points) {
|
|
46974
|
+
const prev = points[points.length - 1];
|
|
46975
|
+
if (!prev || Math.hypot(prev[0] - point[0], prev[1] - point[1]) > 1e-14) points.push(point);
|
|
46976
|
+
}
|
|
46977
|
+
let closed = subpath.closed;
|
|
46978
|
+
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();
|
|
46979
|
+
if (points.length < 3) closed = false;
|
|
46980
|
+
if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
|
|
46981
|
+
contour = [];
|
|
46982
|
+
const [x, y] = points[0];
|
|
46983
|
+
addCap([x, y], [x + 1, y]);
|
|
46984
|
+
addCap([x, y], [x - 1, y]);
|
|
46985
|
+
contours.push(contour);
|
|
46986
|
+
} else if (points.length >= 2) {
|
|
46987
|
+
contour = [];
|
|
46988
|
+
if (!closed) addCap(points[0], points[1]);
|
|
46989
|
+
for (let i = closed ? 0 : 1; i < points.length - (closed ? 0 : 1); i++) {
|
|
46990
|
+
addJoin(points[(i + points.length - 1) % points.length], points[i], points[(i + 1) % points.length]);
|
|
46991
|
+
}
|
|
46992
|
+
if (closed) {
|
|
46993
|
+
contours.push(contour);
|
|
46994
|
+
contour = [];
|
|
46995
|
+
} else addCap(points[points.length - 1], points[points.length - 2]);
|
|
46996
|
+
for (let i = points.length - (closed ? 1 : 2); i >= (closed ? 0 : 1); i--) {
|
|
46997
|
+
addJoin(points[(i + 1) % points.length], points[i], points[(i + points.length - 1) % points.length]);
|
|
46998
|
+
}
|
|
46999
|
+
contours.push(contour);
|
|
47000
|
+
}
|
|
47001
|
+
}
|
|
47002
|
+
}
|
|
47003
|
+
return contours;
|
|
47004
|
+
}
|
|
46827
47005
|
function decodePng(pngBytes) {
|
|
46828
47006
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
46829
47007
|
throw new Error("Invalid PNG signature");
|
|
@@ -47518,111 +47696,60 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
|
|
|
47518
47696
|
rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
|
|
47519
47697
|
rgba[idx + 3] = Math.round(outA * 255);
|
|
47520
47698
|
}
|
|
47521
|
-
function
|
|
47522
|
-
const
|
|
47523
|
-
|
|
47524
|
-
|
|
47525
|
-
const lenSq = dx * dx + dy * dy;
|
|
47526
|
-
const segLen = Math.sqrt(lenSq);
|
|
47527
|
-
const pad = lineCap === 2 ? halfW + 2 : halfW + 1;
|
|
47528
|
-
const minX = Math.max(0, Math.floor(Math.min(x0, x1) - pad));
|
|
47529
|
-
const maxX = Math.min(width - 1, Math.ceil(Math.max(x0, x1) + pad));
|
|
47530
|
-
const minY = Math.max(0, Math.floor(Math.min(y0, y1) - pad));
|
|
47531
|
-
const maxY = Math.min(height - 1, Math.ceil(Math.max(y0, y1) + pad));
|
|
47532
|
-
for (let py = minY; py <= maxY; py++) {
|
|
47533
|
-
for (let px = minX; px <= maxX; px++) {
|
|
47534
|
-
const cx = px + 0.5;
|
|
47535
|
-
const cy = py + 0.5;
|
|
47536
|
-
if (segLen > 1e-6 && (lineCap === 0 || lineCap === 2)) {
|
|
47537
|
-
const ux = dx / segLen;
|
|
47538
|
-
const uy = dy / segLen;
|
|
47539
|
-
const along = (cx - x0) * ux + (cy - y0) * uy;
|
|
47540
|
-
const perp = Math.abs(-(cx - x0) * uy + (cy - y0) * ux);
|
|
47541
|
-
const minAlong = lineCap === 2 ? -halfW : 0;
|
|
47542
|
-
const maxAlong = lineCap === 2 ? segLen + halfW : segLen;
|
|
47543
|
-
const overAlong = along < minAlong ? minAlong - along : along > maxAlong ? along - maxAlong : 0;
|
|
47544
|
-
const dist2 = overAlong > 0 ? Math.max(perp, halfW + overAlong) : perp;
|
|
47545
|
-
if (dist2 <= halfW + 0.75) {
|
|
47546
|
-
const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist2)) : dist2 <= halfW + 0.25 ? 1 : 0;
|
|
47547
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
47548
|
-
}
|
|
47549
|
-
continue;
|
|
47550
|
-
}
|
|
47551
|
-
let t = lenSq > 1e-6 ? ((cx - x0) * dx + (cy - y0) * dy) / lenSq : 0;
|
|
47552
|
-
t = Math.max(0, Math.min(1, t));
|
|
47553
|
-
const projX = x0 + t * dx;
|
|
47554
|
-
const projY = y0 + t * dy;
|
|
47555
|
-
const dist = Math.hypot(cx - projX, cy - projY);
|
|
47556
|
-
if (dist <= halfW + 0.75) {
|
|
47557
|
-
const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist)) : dist <= halfW + 0.25 ? 1 : 0;
|
|
47558
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
47559
|
-
}
|
|
47560
|
-
}
|
|
47561
|
-
}
|
|
47562
|
-
}
|
|
47563
|
-
function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = false) {
|
|
47564
|
-
const edges = [];
|
|
47565
|
-
let curX = 0;
|
|
47566
|
-
let curY = 0;
|
|
47567
|
-
let startX = 0;
|
|
47568
|
-
let startY = 0;
|
|
47569
|
-
let hasOpenSubpath = false;
|
|
47699
|
+
function segmentsToScreenPaths(segments, pageHeight, scale) {
|
|
47700
|
+
const paths = [];
|
|
47701
|
+
let points = [];
|
|
47702
|
+
let current = [0, 0];
|
|
47570
47703
|
const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
|
|
47571
|
-
for (const
|
|
47572
|
-
if (
|
|
47573
|
-
if (
|
|
47574
|
-
|
|
47575
|
-
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
|
|
47580
|
-
} else if (
|
|
47581
|
-
|
|
47582
|
-
|
|
47583
|
-
|
|
47584
|
-
|
|
47585
|
-
|
|
47586
|
-
|
|
47587
|
-
|
|
47588
|
-
|
|
47589
|
-
|
|
47590
|
-
|
|
47591
|
-
|
|
47592
|
-
|
|
47593
|
-
|
|
47594
|
-
|
|
47595
|
-
|
|
47596
|
-
|
|
47597
|
-
|
|
47598
|
-
|
|
47599
|
-
|
|
47600
|
-
|
|
47601
|
-
|
|
47602
|
-
|
|
47603
|
-
|
|
47604
|
-
|
|
47605
|
-
|
|
47606
|
-
|
|
47607
|
-
|
|
47608
|
-
|
|
47609
|
-
|
|
47610
|
-
|
|
47611
|
-
|
|
47612
|
-
|
|
47613
|
-
const [
|
|
47614
|
-
|
|
47615
|
-
|
|
47616
|
-
|
|
47617
|
-
|
|
47618
|
-
|
|
47619
|
-
{ x0: rx0, y0: ry1, x1: rx0, y1: ry0 }
|
|
47620
|
-
);
|
|
47621
|
-
hasOpenSubpath = false;
|
|
47704
|
+
for (const segment of segments) {
|
|
47705
|
+
if (segment.kind === "move") {
|
|
47706
|
+
if (points.length) paths.push({ points, closed: false });
|
|
47707
|
+
current = toScreen(segment.x, segment.y);
|
|
47708
|
+
points = [current];
|
|
47709
|
+
} else if (segment.kind === "line") {
|
|
47710
|
+
if (!points.length) points = [current];
|
|
47711
|
+
current = toScreen(segment.x, segment.y);
|
|
47712
|
+
points.push(current);
|
|
47713
|
+
} else if (segment.kind === "cubic") {
|
|
47714
|
+
if (!points.length) points = [current];
|
|
47715
|
+
const a = toScreen(segment.x1, segment.y1), b = toScreen(segment.x2, segment.y2);
|
|
47716
|
+
const end = toScreen(segment.x, segment.y);
|
|
47717
|
+
const curve = flattenCubic(current[0], current[1], a[0], a[1], b[0], b[1], end[0], end[1]);
|
|
47718
|
+
for (let i = 1; i < curve.length; i++) points.push(curve[i]);
|
|
47719
|
+
current = end;
|
|
47720
|
+
} else if (segment.kind === "close") {
|
|
47721
|
+
if (points.length) {
|
|
47722
|
+
paths.push({ points, closed: true });
|
|
47723
|
+
current = points[0];
|
|
47724
|
+
points = [];
|
|
47725
|
+
}
|
|
47726
|
+
} else if (segment.kind === "rect") {
|
|
47727
|
+
if (points.length) paths.push({ points, closed: false });
|
|
47728
|
+
const first = toScreen(segment.x, segment.y);
|
|
47729
|
+
paths.push({ points: [
|
|
47730
|
+
first,
|
|
47731
|
+
toScreen(segment.x + segment.width, segment.y),
|
|
47732
|
+
toScreen(segment.x + segment.width, segment.y + segment.height),
|
|
47733
|
+
toScreen(segment.x, segment.y + segment.height)
|
|
47734
|
+
], closed: true });
|
|
47735
|
+
current = first;
|
|
47736
|
+
points = [];
|
|
47737
|
+
}
|
|
47738
|
+
}
|
|
47739
|
+
if (points.length) paths.push({ points, closed: false });
|
|
47740
|
+
return paths;
|
|
47741
|
+
}
|
|
47742
|
+
function pathsToEdges(paths, closeSubpaths = false) {
|
|
47743
|
+
const edges = [];
|
|
47744
|
+
for (const { points, closed } of paths) {
|
|
47745
|
+
for (let i = 1; i < points.length; i++) {
|
|
47746
|
+
const a = points[i - 1], b = points[i];
|
|
47747
|
+
edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
|
|
47748
|
+
}
|
|
47749
|
+
if ((closed || closeSubpaths) && points.length > 1) {
|
|
47750
|
+
const a = points[points.length - 1], b = points[0];
|
|
47751
|
+
edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
|
|
47622
47752
|
}
|
|
47623
|
-
}
|
|
47624
|
-
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
47625
|
-
edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
47626
47753
|
}
|
|
47627
47754
|
return edges;
|
|
47628
47755
|
}
|
|
@@ -47809,7 +47936,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47809
47936
|
for (const clip of clips) {
|
|
47810
47937
|
const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
|
|
47811
47938
|
const layer = new Uint8Array(width * height * 4);
|
|
47812
|
-
fillEdgesScanline4x4(layer, width, height,
|
|
47939
|
+
fillEdgesScanline4x4(layer, width, height, pathsToEdges(segmentsToScreenPaths(segments, displayList.height, scale), true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
47813
47940
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
47814
47941
|
}
|
|
47815
47942
|
cachedClips = clips;
|
|
@@ -47856,62 +47983,38 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
47856
47983
|
if (operation.kind === "path") {
|
|
47857
47984
|
const path = operation.value;
|
|
47858
47985
|
if (path.fillColor) {
|
|
47859
|
-
const edges =
|
|
47986
|
+
const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale), true);
|
|
47860
47987
|
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;
|
|
47861
47988
|
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
|
|
47862
47989
|
}
|
|
47863
47990
|
if (path.strokeColor) {
|
|
47864
|
-
const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, false);
|
|
47865
47991
|
const rawSw = path.strokeWidth * scale;
|
|
47866
47992
|
const sw = Math.max(1, rawSw);
|
|
47867
47993
|
const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
|
|
47868
|
-
const
|
|
47869
|
-
|
|
47870
|
-
|
|
47871
|
-
|
|
47872
|
-
|
|
47873
|
-
|
|
47874
|
-
|
|
47875
|
-
|
|
47876
|
-
|
|
47877
|
-
|
|
47878
|
-
|
|
47879
|
-
|
|
47880
|
-
|
|
47881
|
-
|
|
47882
|
-
|
|
47883
|
-
|
|
47884
|
-
|
|
47885
|
-
|
|
47886
|
-
|
|
47887
|
-
|
|
47888
|
-
|
|
47889
|
-
|
|
47890
|
-
|
|
47891
|
-
|
|
47892
|
-
const t1 = (pos + step) / edgeLen;
|
|
47893
|
-
drawAntiAliasedSegment(
|
|
47894
|
-
rgba,
|
|
47895
|
-
width,
|
|
47896
|
-
height,
|
|
47897
|
-
e.x0 + dx * t0,
|
|
47898
|
-
e.y0 + dy * t0,
|
|
47899
|
-
e.x0 + dx * t1,
|
|
47900
|
-
e.y0 + dy * t1,
|
|
47901
|
-
sw,
|
|
47902
|
-
path.strokeColor,
|
|
47903
|
-
strokeAlpha,
|
|
47904
|
-
path.lineCap ?? 0,
|
|
47905
|
-
original.kind === "glyph" ? aaTxt : aaVec,
|
|
47906
|
-
path.blendMode,
|
|
47907
|
-
clipMask
|
|
47908
|
-
);
|
|
47909
|
-
}
|
|
47910
|
-
pos += step;
|
|
47911
|
-
dashDist = (dashDist + step) % dashCycle;
|
|
47912
|
-
}
|
|
47913
|
-
}
|
|
47914
|
-
}
|
|
47994
|
+
const contours = strokeOutlines(
|
|
47995
|
+
segmentsToScreenPaths(path.segments, displayList.height, scale),
|
|
47996
|
+
sw,
|
|
47997
|
+
path.lineCap ?? 0,
|
|
47998
|
+
path.lineJoin ?? 0,
|
|
47999
|
+
path.miterLimit ?? 10,
|
|
48000
|
+
path.dashArray?.map((value) => Math.max(0, value * scale)),
|
|
48001
|
+
(path.dashPhase ?? 0) * scale
|
|
48002
|
+
);
|
|
48003
|
+
const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
|
|
48004
|
+
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;
|
|
48005
|
+
fillEdgesScanline4x4(
|
|
48006
|
+
rgba,
|
|
48007
|
+
width,
|
|
48008
|
+
height,
|
|
48009
|
+
edges,
|
|
48010
|
+
path.strokeColor,
|
|
48011
|
+
strokeAlpha,
|
|
48012
|
+
"nonzero",
|
|
48013
|
+
clipScreen,
|
|
48014
|
+
original.kind === "glyph" ? aaTxt : aaVec,
|
|
48015
|
+
path.blendMode,
|
|
48016
|
+
clipMask
|
|
48017
|
+
);
|
|
47915
48018
|
}
|
|
47916
48019
|
} else if (operation.kind === "image") {
|
|
47917
48020
|
const img = operation.value;
|
|
@@ -62701,3 +62804,15 @@ export {
|
|
|
62701
62804
|
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
62702
62805
|
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
62703
62806
|
*/
|
|
62807
|
+
/*!
|
|
62808
|
+
* Anti-Grain Geometry - Version 2.3
|
|
62809
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
62810
|
+
*
|
|
62811
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
62812
|
+
* is granted provided this copyright notice appears in all copies.
|
|
62813
|
+
* This software is provided "as is" without express or implied
|
|
62814
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
62815
|
+
*
|
|
62816
|
+
* Adapted from PDFium agg_math_stroke.h and agg_vcgen_stroke.cpp.
|
|
62817
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
62818
|
+
*/
|