@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.
Files changed (31) hide show
  1. package/dist/image-ast/index.browser.js +268 -153
  2. package/dist/image-ast/index.js +268 -153
  3. package/dist/pdf-ast/index.js +270 -153
  4. package/dist/safe-bash/chunks/{chunk-CRQDMBQA.js → chunk-FSH7QRIC.js} +10 -1
  5. package/dist/safe-bash/command-chunks/{chunk-4XHONGIU.js → chunk-B7YLGJRF.js} +2 -2
  6. package/dist/safe-bash/command-chunks/{chunk-S3G2B4OX.js → chunk-G3IIEU2N.js} +271 -153
  7. package/dist/safe-bash/command-chunks/{chunk-S5EX6UP5.js → chunk-RDPJGIQF.js} +1 -1
  8. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  9. package/dist/safe-bash/commands/python/llm-module.js +3 -1
  10. package/dist/safe-bash/commands/python/shell-module.js +7 -0
  11. package/dist/safe-bash/core.browser.js +32 -12
  12. package/dist/safe-bash/shell/runtime.js +43 -11
  13. package/dist/safe-bash-command-ffmpeg/index.js +5649 -5565
  14. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  15. package/dist/safe-bash-command-pandoc/command.js +3 -3
  16. package/dist/safe-bash-command-pandoc/index.js +3 -3
  17. package/dist/safe-bash-command-pdfimages/index.js +268 -153
  18. package/dist/safe-bash-command-pdfinfo/index.js +268 -153
  19. package/dist/safe-bash-command-pdftk/index.js +268 -153
  20. package/dist/safe-bash-command-pdftoppm/index.js +268 -153
  21. package/dist/safe-bash-command-pdftotext/index.js +268 -153
  22. package/dist/safe-bash-command-qpdf/index.js +268 -153
  23. package/dist/safe-bash-command-sips/index.js +2 -2
  24. package/dist/safe-bash-command-soffice/index.js +1 -1
  25. package/dist/safe-bash-command-ssconvert/index.js +265 -150
  26. package/dist/safe-bash-command-wkhtmltopdf/index.js +269 -153
  27. package/dist/safe-playwright-cloudflare/browser-snapshot-labels.d.ts +14 -0
  28. package/dist/safe-playwright-cloudflare/browser-snapshot-labels.js +62 -0
  29. package/dist/safe-playwright-cloudflare/browser-snapshot-scheduler.js +8 -1
  30. package/package.json +2 -2
  31. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +14 -0
@@ -39364,6 +39364,184 @@ function downscaleImage(image, widthScale, heightScale) {
39364
39364
  }
39365
39365
  return image;
39366
39366
  }
39367
+ var MAX_STROKE_VERTICES = 1e6;
39368
+ function dashSubpath(path, pattern, phase) {
39369
+ const cycle = pattern.reduce((sum, value) => sum + value, 0);
39370
+ if (!(cycle > 0)) return [path];
39371
+ let offset = (phase % cycle + cycle) % cycle, index = 0;
39372
+ while (offset > 0) {
39373
+ if (offset < pattern[index]) break;
39374
+ offset -= pattern[index];
39375
+ index = (index + 1) % pattern.length;
39376
+ }
39377
+ let remaining = pattern[index] - offset;
39378
+ const points = path.closed ? [...path.points, path.points[0]] : path.points;
39379
+ const result = [];
39380
+ let current = [];
39381
+ let steps = 0;
39382
+ const flush = () => {
39383
+ if (current.length) result.push({ points: current, closed: false });
39384
+ current = [];
39385
+ };
39386
+ const advance = (point) => {
39387
+ while (remaining <= 0) {
39388
+ if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39389
+ if (index % 2 === 0) {
39390
+ if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
39391
+ flush();
39392
+ }
39393
+ index = (index + 1) % pattern.length;
39394
+ remaining = pattern[index];
39395
+ }
39396
+ };
39397
+ for (let i = 1; i < points.length; i++) {
39398
+ const start = points[i - 1], end = points[i];
39399
+ const dx = end[0] - start[0], dy = end[1] - start[1];
39400
+ const length = Math.hypot(dx, dy);
39401
+ if (!Number.isFinite(length) || length / cycle * pattern.length > MAX_STROKE_VERTICES) {
39402
+ throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39403
+ }
39404
+ let distance = 0;
39405
+ while (distance < length) {
39406
+ const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
39407
+ advance(point);
39408
+ const step = Math.min(remaining, length - distance);
39409
+ if (distance + step === distance || ++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39410
+ distance += step;
39411
+ remaining -= step;
39412
+ if (index % 2 === 0) {
39413
+ if (!current.length) current.push(point);
39414
+ current.push([start[0] + dx * distance / length, start[1] + dy * distance / length]);
39415
+ }
39416
+ }
39417
+ }
39418
+ flush();
39419
+ if (path.closed && result.length) {
39420
+ const first = result[0], last = result[result.length - 1];
39421
+ const start = path.points[0];
39422
+ const firstPoint = first.points[0], lastPoint = last.points[last.points.length - 1];
39423
+ if (firstPoint[0] === start[0] && firstPoint[1] === start[1] && lastPoint[0] === start[0] && lastPoint[1] === start[1]) {
39424
+ if (first === last) result[0] = { points: first.points, closed: true };
39425
+ else {
39426
+ result[0] = { points: [...last.points, ...first.points.slice(1)], closed: false };
39427
+ result.pop();
39428
+ }
39429
+ }
39430
+ }
39431
+ return result;
39432
+ }
39433
+ function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], dashPhase = 0) {
39434
+ const half = width / 2;
39435
+ const contours = [];
39436
+ const pattern = dashArray.length % 2 ? [...dashArray, ...dashArray] : dashArray;
39437
+ let count = 0;
39438
+ let contour = [];
39439
+ const add = (x, y) => {
39440
+ if (++count > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke outline exceeds the vertex limit");
39441
+ contour.push([x, y]);
39442
+ };
39443
+ const arc = (point, dx1, dy1, dx2, dy2) => {
39444
+ let a1 = Math.atan2(dy1, dx1), a2 = Math.atan2(dy2, dx2);
39445
+ const ccw = a1 - a2 > 0 && a1 - a2 < Math.PI;
39446
+ const step = Math.acos(half / (half + 0.125)) * 2;
39447
+ add(point[0] + dx1, point[1] + dy1);
39448
+ if (step > 0) {
39449
+ if (!ccw) {
39450
+ if (a1 > a2) a2 += 2 * Math.PI;
39451
+ a2 -= step / 4;
39452
+ if ((a2 - a1) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
39453
+ for (a1 += step; a1 < a2; a1 += step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
39454
+ } else {
39455
+ if (a1 < a2) a2 -= 2 * Math.PI;
39456
+ a2 += step / 4;
39457
+ if ((a1 - a2) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
39458
+ for (a1 -= step; a1 > a2; a1 -= step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
39459
+ }
39460
+ }
39461
+ add(point[0] + dx2, point[1] + dy2);
39462
+ };
39463
+ const addCap = (point, next) => {
39464
+ const length = Math.hypot(next[0] - point[0], next[1] - point[1]);
39465
+ const dx = half * (next[1] - point[1]) / length;
39466
+ const dy = half * (next[0] - point[0]) / length;
39467
+ if (cap !== 1) {
39468
+ const sx = cap === 2 ? dy : 0, sy = cap === 2 ? dx : 0;
39469
+ add(point[0] - dx - sx, point[1] + dy - sy);
39470
+ add(point[0] + dx - sx, point[1] - dy - sy);
39471
+ } else {
39472
+ const angle = Math.atan2(dy, -dx);
39473
+ const step = Math.max(1e-3, Math.acos(half / (half + 0.125)) * 2);
39474
+ add(point[0] - dx, point[1] + dy);
39475
+ 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));
39476
+ add(point[0] + dx, point[1] - dy);
39477
+ }
39478
+ };
39479
+ const addJoin = (prev, point, next) => {
39480
+ const len1 = Math.hypot(point[0] - prev[0], point[1] - prev[1]);
39481
+ const len2 = Math.hypot(next[0] - point[0], next[1] - point[1]);
39482
+ const dx1 = half * (point[1] - prev[1]) / len1, dy1 = half * (point[0] - prev[0]) / len1;
39483
+ const dx2 = half * (next[1] - point[1]) / len2, dy2 = half * (next[0] - point[0]) / len2;
39484
+ const inner = (next[0] - point[0]) * (point[1] - prev[1]) - (next[1] - point[1]) * (point[0] - prev[0]) > 0;
39485
+ if (!inner && join === 1) {
39486
+ arc(point, dx1, -dy1, dx2, -dy2);
39487
+ return;
39488
+ }
39489
+ if (inner || join === 0) {
39490
+ const ax = prev[0] + dx1, ay = prev[1] - dy1;
39491
+ const bx = point[0] + dx1, by = point[1] - dy1;
39492
+ const cx = point[0] + dx2, cy = point[1] - dy2;
39493
+ const dx = next[0] + dx2, dy = next[1] - dy2;
39494
+ const den = (bx - ax) * (dy - cy) - (by - ay) * (dx - cx);
39495
+ if (Math.abs(den) >= 1e-30) {
39496
+ const t = ((ay - cy) * (dx - cx) - (ax - cx) * (dy - cy)) / den;
39497
+ const x = ax + (bx - ax) * t, y = ay + (by - ay) * t;
39498
+ if (Math.hypot(x - point[0], y - point[1]) <= half * (inner ? 1.01 : miterLimit)) {
39499
+ add(x, y);
39500
+ return;
39501
+ }
39502
+ } else if ((bx - prev[0]) * dy1 - (prev[1] - by) * dx1 < 0 !== (bx - next[0]) * dy1 - (next[1] - by) * dx1 < 0) {
39503
+ add(bx, by);
39504
+ return;
39505
+ }
39506
+ }
39507
+ add(point[0] + dx1, point[1] - dy1);
39508
+ add(point[0] + dx2, point[1] - dy2);
39509
+ };
39510
+ for (const path of paths) {
39511
+ for (const subpath of pattern.length ? dashSubpath(path, pattern, dashPhase) : [path]) {
39512
+ const points = [];
39513
+ for (const point of subpath.points) {
39514
+ const prev = points[points.length - 1];
39515
+ if (!prev || Math.hypot(prev[0] - point[0], prev[1] - point[1]) > 1e-14) points.push(point);
39516
+ }
39517
+ let closed = subpath.closed;
39518
+ 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();
39519
+ if (points.length < 3) closed = false;
39520
+ if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
39521
+ contour = [];
39522
+ const [x, y] = points[0];
39523
+ addCap([x, y], [x + 1, y]);
39524
+ addCap([x, y], [x - 1, y]);
39525
+ contours.push(contour);
39526
+ } else if (points.length >= 2) {
39527
+ contour = [];
39528
+ if (!closed) addCap(points[0], points[1]);
39529
+ for (let i = closed ? 0 : 1; i < points.length - (closed ? 0 : 1); i++) {
39530
+ addJoin(points[(i + points.length - 1) % points.length], points[i], points[(i + 1) % points.length]);
39531
+ }
39532
+ if (closed) {
39533
+ contours.push(contour);
39534
+ contour = [];
39535
+ } else addCap(points[points.length - 1], points[points.length - 2]);
39536
+ for (let i = points.length - (closed ? 1 : 2); i >= (closed ? 0 : 1); i--) {
39537
+ addJoin(points[(i + 1) % points.length], points[i], points[(i + points.length - 1) % points.length]);
39538
+ }
39539
+ contours.push(contour);
39540
+ }
39541
+ }
39542
+ }
39543
+ return contours;
39544
+ }
39367
39545
  function encodePng(bitmap) {
39368
39546
  return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
39369
39547
  }
@@ -40454,111 +40632,60 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
40454
40632
  rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
40455
40633
  rgba[idx + 3] = Math.round(outA * 255);
40456
40634
  }
40457
- function drawAntiAliasedSegment(rgba, width, height, x0, y0, x1, y1, strokeWidth, color, alpha = 1, lineCap = 0, antialias = true, blendMode, clipMask) {
40458
- const halfW = Math.max(0.6, strokeWidth * 0.5);
40459
- const dx = x1 - x0;
40460
- const dy = y1 - y0;
40461
- const lenSq = dx * dx + dy * dy;
40462
- const segLen = Math.sqrt(lenSq);
40463
- const pad = lineCap === 2 ? halfW + 2 : halfW + 1;
40464
- const minX = Math.max(0, Math.floor(Math.min(x0, x1) - pad));
40465
- const maxX = Math.min(width - 1, Math.ceil(Math.max(x0, x1) + pad));
40466
- const minY = Math.max(0, Math.floor(Math.min(y0, y1) - pad));
40467
- const maxY = Math.min(height - 1, Math.ceil(Math.max(y0, y1) + pad));
40468
- for (let py = minY; py <= maxY; py++) {
40469
- for (let px = minX; px <= maxX; px++) {
40470
- const cx = px + 0.5;
40471
- const cy = py + 0.5;
40472
- if (segLen > 1e-6 && (lineCap === 0 || lineCap === 2)) {
40473
- const ux = dx / segLen;
40474
- const uy = dy / segLen;
40475
- const along = (cx - x0) * ux + (cy - y0) * uy;
40476
- const perp = Math.abs(-(cx - x0) * uy + (cy - y0) * ux);
40477
- const minAlong = lineCap === 2 ? -halfW : 0;
40478
- const maxAlong = lineCap === 2 ? segLen + halfW : segLen;
40479
- const overAlong = along < minAlong ? minAlong - along : along > maxAlong ? along - maxAlong : 0;
40480
- const dist2 = overAlong > 0 ? Math.max(perp, halfW + overAlong) : perp;
40481
- if (dist2 <= halfW + 0.75) {
40482
- const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist2)) : dist2 <= halfW + 0.25 ? 1 : 0;
40483
- blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
40484
- }
40485
- continue;
40486
- }
40487
- let t = lenSq > 1e-6 ? ((cx - x0) * dx + (cy - y0) * dy) / lenSq : 0;
40488
- t = Math.max(0, Math.min(1, t));
40489
- const projX = x0 + t * dx;
40490
- const projY = y0 + t * dy;
40491
- const dist = Math.hypot(cx - projX, cy - projY);
40492
- if (dist <= halfW + 0.75) {
40493
- const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist)) : dist <= halfW + 0.25 ? 1 : 0;
40494
- blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
40495
- }
40496
- }
40497
- }
40498
- }
40499
- function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = false) {
40500
- const edges = [];
40501
- let curX = 0;
40502
- let curY = 0;
40503
- let startX = 0;
40504
- let startY = 0;
40505
- let hasOpenSubpath = false;
40635
+ function segmentsToScreenPaths(segments, pageHeight, scale) {
40636
+ const paths = [];
40637
+ let points = [];
40638
+ let current = [0, 0];
40506
40639
  const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
40507
- for (const seg of segments) {
40508
- if (seg.kind === "move") {
40509
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40510
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40511
- }
40512
- [curX, curY] = toScreen(seg.x, seg.y);
40513
- startX = curX;
40514
- startY = curY;
40515
- hasOpenSubpath = false;
40516
- } else if (seg.kind === "line") {
40517
- const [nx, ny] = toScreen(seg.x, seg.y);
40518
- edges.push({ x0: curX, y0: curY, x1: nx, y1: ny });
40519
- curX = nx;
40520
- curY = ny;
40521
- hasOpenSubpath = true;
40522
- } else if (seg.kind === "cubic") {
40523
- const [p1x, p1y] = toScreen(seg.x1, seg.y1);
40524
- const [p2x, p2y] = toScreen(seg.x2, seg.y2);
40525
- const [p3x, p3y] = toScreen(seg.x, seg.y);
40526
- const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
40527
- let px = curX;
40528
- let py = curY;
40529
- for (let i = 1; i < points.length; i++) {
40530
- const [qx, qy] = points[i];
40531
- edges.push({ x0: px, y0: py, x1: qx, y1: qy });
40532
- px = qx;
40533
- py = qy;
40534
- }
40535
- curX = p3x;
40536
- curY = p3y;
40537
- hasOpenSubpath = true;
40538
- } else if (seg.kind === "close") {
40539
- if (curX !== startX || curY !== startY) {
40540
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40541
- curX = startX;
40542
- curY = startY;
40543
- }
40544
- hasOpenSubpath = false;
40545
- } else if (seg.kind === "rect") {
40546
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40547
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40548
- }
40549
- const [rx0, ry0] = toScreen(seg.x, seg.y);
40550
- const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
40551
- edges.push(
40552
- { x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
40553
- { x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
40554
- { x0: rx1, y0: ry1, x1: rx0, y1: ry1 },
40555
- { x0: rx0, y0: ry1, x1: rx0, y1: ry0 }
40556
- );
40557
- hasOpenSubpath = false;
40640
+ for (const segment of segments) {
40641
+ if (segment.kind === "move") {
40642
+ if (points.length) paths.push({ points, closed: false });
40643
+ current = toScreen(segment.x, segment.y);
40644
+ points = [current];
40645
+ } else if (segment.kind === "line") {
40646
+ if (!points.length) points = [current];
40647
+ current = toScreen(segment.x, segment.y);
40648
+ points.push(current);
40649
+ } else if (segment.kind === "cubic") {
40650
+ if (!points.length) points = [current];
40651
+ const a = toScreen(segment.x1, segment.y1), b = toScreen(segment.x2, segment.y2);
40652
+ const end = toScreen(segment.x, segment.y);
40653
+ const curve = flattenCubic(current[0], current[1], a[0], a[1], b[0], b[1], end[0], end[1]);
40654
+ for (let i = 1; i < curve.length; i++) points.push(curve[i]);
40655
+ current = end;
40656
+ } else if (segment.kind === "close") {
40657
+ if (points.length) {
40658
+ paths.push({ points, closed: true });
40659
+ current = points[0];
40660
+ points = [];
40661
+ }
40662
+ } else if (segment.kind === "rect") {
40663
+ if (points.length) paths.push({ points, closed: false });
40664
+ const first = toScreen(segment.x, segment.y);
40665
+ paths.push({ points: [
40666
+ first,
40667
+ toScreen(segment.x + segment.width, segment.y),
40668
+ toScreen(segment.x + segment.width, segment.y + segment.height),
40669
+ toScreen(segment.x, segment.y + segment.height)
40670
+ ], closed: true });
40671
+ current = first;
40672
+ points = [];
40673
+ }
40674
+ }
40675
+ if (points.length) paths.push({ points, closed: false });
40676
+ return paths;
40677
+ }
40678
+ function pathsToEdges(paths, closeSubpaths = false) {
40679
+ const edges = [];
40680
+ for (const { points, closed } of paths) {
40681
+ for (let i = 1; i < points.length; i++) {
40682
+ const a = points[i - 1], b = points[i];
40683
+ edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
40684
+ }
40685
+ if ((closed || closeSubpaths) && points.length > 1) {
40686
+ const a = points[points.length - 1], b = points[0];
40687
+ edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
40558
40688
  }
40559
- }
40560
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40561
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40562
40689
  }
40563
40690
  return edges;
40564
40691
  }
@@ -40745,7 +40872,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40745
40872
  for (const clip of clips) {
40746
40873
  const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
40747
40874
  const layer = new Uint8Array(width * height * 4);
40748
- fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
40875
+ fillEdgesScanline4x4(layer, width, height, pathsToEdges(segmentsToScreenPaths(segments, displayList.height, scale), true), { r: 1, g: 1, b: 1 }, 1, fillRule);
40749
40876
  for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
40750
40877
  }
40751
40878
  cachedClips = clips;
@@ -40792,62 +40919,38 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40792
40919
  if (operation.kind === "path") {
40793
40920
  const path = operation.value;
40794
40921
  if (path.fillColor) {
40795
- const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, true);
40922
+ const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale), true);
40796
40923
  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;
40797
40924
  fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
40798
40925
  }
40799
40926
  if (path.strokeColor) {
40800
- const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, false);
40801
40927
  const rawSw = path.strokeWidth * scale;
40802
40928
  const sw = Math.max(1, rawSw);
40803
40929
  const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
40804
- const dashArr = path.dashArray && path.dashArray.length > 0 ? path.dashArray.map((d) => Math.max(0, d * scale)) : void 0;
40805
- const dashCycle = dashArr ? dashArr.reduce((a, b) => a + b, 0) : 0;
40806
- let dashDist = (path.dashPhase ?? 0) * scale % (dashCycle || 1);
40807
- if (dashDist < 0) dashDist += dashCycle;
40808
- for (const e of edges) {
40809
- if (!dashArr || dashCycle <= 1e-4) {
40810
- drawAntiAliasedSegment(rgba, width, height, e.x0, e.y0, e.x1, e.y1, sw, path.strokeColor, strokeAlpha, path.lineCap ?? 0, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
40811
- } else {
40812
- const dx = e.x1 - e.x0;
40813
- const dy = e.y1 - e.y0;
40814
- const edgeLen = Math.hypot(dx, dy);
40815
- if (edgeLen <= 1e-4) continue;
40816
- let pos = 0;
40817
- while (pos < edgeLen) {
40818
- let cycleRem = dashDist % dashCycle;
40819
- let dIdx = 0;
40820
- while (dIdx < dashArr.length - 1 && cycleRem >= dashArr[dIdx]) {
40821
- cycleRem -= dashArr[dIdx];
40822
- dIdx++;
40823
- }
40824
- const segRemainInDash = Math.max(1e-4, dashArr[dIdx] - cycleRem);
40825
- const step = Math.min(edgeLen - pos, segRemainInDash);
40826
- if (dIdx % 2 === 0) {
40827
- const t0 = pos / edgeLen;
40828
- const t1 = (pos + step) / edgeLen;
40829
- drawAntiAliasedSegment(
40830
- rgba,
40831
- width,
40832
- height,
40833
- e.x0 + dx * t0,
40834
- e.y0 + dy * t0,
40835
- e.x0 + dx * t1,
40836
- e.y0 + dy * t1,
40837
- sw,
40838
- path.strokeColor,
40839
- strokeAlpha,
40840
- path.lineCap ?? 0,
40841
- original.kind === "glyph" ? aaTxt : aaVec,
40842
- path.blendMode,
40843
- clipMask
40844
- );
40845
- }
40846
- pos += step;
40847
- dashDist = (dashDist + step) % dashCycle;
40848
- }
40849
- }
40850
- }
40930
+ const contours = strokeOutlines(
40931
+ segmentsToScreenPaths(path.segments, displayList.height, scale),
40932
+ sw,
40933
+ path.lineCap ?? 0,
40934
+ path.lineJoin ?? 0,
40935
+ path.miterLimit ?? 10,
40936
+ path.dashArray?.map((value) => Math.max(0, value * scale)),
40937
+ (path.dashPhase ?? 0) * scale
40938
+ );
40939
+ const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
40940
+ 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;
40941
+ fillEdgesScanline4x4(
40942
+ rgba,
40943
+ width,
40944
+ height,
40945
+ edges,
40946
+ path.strokeColor,
40947
+ strokeAlpha,
40948
+ "nonzero",
40949
+ clipScreen,
40950
+ original.kind === "glyph" ? aaTxt : aaVec,
40951
+ path.blendMode,
40952
+ clipMask
40953
+ );
40851
40954
  }
40852
40955
  } else if (operation.kind === "image") {
40853
40956
  const img = operation.value;
@@ -44512,3 +44615,15 @@ export {
44512
44615
  * Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
44513
44616
  * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
44514
44617
  */
44618
+ /*!
44619
+ * Anti-Grain Geometry - Version 2.3
44620
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
44621
+ *
44622
+ * Permission to copy, use, modify, sell and distribute this software
44623
+ * is granted provided this copyright notice appears in all copies.
44624
+ * This software is provided "as is" without express or implied
44625
+ * warranty, and with no claim as to its suitability for any purpose.
44626
+ *
44627
+ * Adapted from PDFium agg_math_stroke.h and agg_vcgen_stroke.cpp.
44628
+ * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
44629
+ */