@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
@@ -39170,6 +39170,184 @@ function downscaleImage(image, widthScale, heightScale) {
39170
39170
  }
39171
39171
  return image;
39172
39172
  }
39173
+ var MAX_STROKE_VERTICES = 1e6;
39174
+ function dashSubpath(path, pattern, phase) {
39175
+ const cycle = pattern.reduce((sum, value) => sum + value, 0);
39176
+ if (!(cycle > 0)) return [path];
39177
+ let offset = (phase % cycle + cycle) % cycle, index = 0;
39178
+ while (offset > 0) {
39179
+ if (offset < pattern[index]) break;
39180
+ offset -= pattern[index];
39181
+ index = (index + 1) % pattern.length;
39182
+ }
39183
+ let remaining = pattern[index] - offset;
39184
+ const points = path.closed ? [...path.points, path.points[0]] : path.points;
39185
+ const result = [];
39186
+ let current = [];
39187
+ let steps = 0;
39188
+ const flush = () => {
39189
+ if (current.length) result.push({ points: current, closed: false });
39190
+ current = [];
39191
+ };
39192
+ const advance = (point) => {
39193
+ while (remaining <= 0) {
39194
+ if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39195
+ if (index % 2 === 0) {
39196
+ if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
39197
+ flush();
39198
+ }
39199
+ index = (index + 1) % pattern.length;
39200
+ remaining = pattern[index];
39201
+ }
39202
+ };
39203
+ for (let i = 1; i < points.length; i++) {
39204
+ const start = points[i - 1], end = points[i];
39205
+ const dx = end[0] - start[0], dy = end[1] - start[1];
39206
+ const length = Math.hypot(dx, dy);
39207
+ if (!Number.isFinite(length) || length / cycle * pattern.length > MAX_STROKE_VERTICES) {
39208
+ throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39209
+ }
39210
+ let distance = 0;
39211
+ while (distance < length) {
39212
+ const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
39213
+ advance(point);
39214
+ const step = Math.min(remaining, length - distance);
39215
+ if (distance + step === distance || ++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
39216
+ distance += step;
39217
+ remaining -= step;
39218
+ if (index % 2 === 0) {
39219
+ if (!current.length) current.push(point);
39220
+ current.push([start[0] + dx * distance / length, start[1] + dy * distance / length]);
39221
+ }
39222
+ }
39223
+ }
39224
+ flush();
39225
+ if (path.closed && result.length) {
39226
+ const first = result[0], last = result[result.length - 1];
39227
+ const start = path.points[0];
39228
+ const firstPoint = first.points[0], lastPoint = last.points[last.points.length - 1];
39229
+ if (firstPoint[0] === start[0] && firstPoint[1] === start[1] && lastPoint[0] === start[0] && lastPoint[1] === start[1]) {
39230
+ if (first === last) result[0] = { points: first.points, closed: true };
39231
+ else {
39232
+ result[0] = { points: [...last.points, ...first.points.slice(1)], closed: false };
39233
+ result.pop();
39234
+ }
39235
+ }
39236
+ }
39237
+ return result;
39238
+ }
39239
+ function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], dashPhase = 0) {
39240
+ const half = width / 2;
39241
+ const contours = [];
39242
+ const pattern = dashArray.length % 2 ? [...dashArray, ...dashArray] : dashArray;
39243
+ let count = 0;
39244
+ let contour = [];
39245
+ const add = (x, y) => {
39246
+ if (++count > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke outline exceeds the vertex limit");
39247
+ contour.push([x, y]);
39248
+ };
39249
+ const arc = (point, dx1, dy1, dx2, dy2) => {
39250
+ let a1 = Math.atan2(dy1, dx1), a2 = Math.atan2(dy2, dx2);
39251
+ const ccw = a1 - a2 > 0 && a1 - a2 < Math.PI;
39252
+ const step = Math.acos(half / (half + 0.125)) * 2;
39253
+ add(point[0] + dx1, point[1] + dy1);
39254
+ if (step > 0) {
39255
+ if (!ccw) {
39256
+ if (a1 > a2) a2 += 2 * Math.PI;
39257
+ a2 -= step / 4;
39258
+ if ((a2 - a1) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
39259
+ for (a1 += step; a1 < a2; a1 += step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
39260
+ } else {
39261
+ if (a1 < a2) a2 -= 2 * Math.PI;
39262
+ a2 += step / 4;
39263
+ if ((a1 - a2) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
39264
+ for (a1 -= step; a1 > a2; a1 -= step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
39265
+ }
39266
+ }
39267
+ add(point[0] + dx2, point[1] + dy2);
39268
+ };
39269
+ const addCap = (point, next) => {
39270
+ const length = Math.hypot(next[0] - point[0], next[1] - point[1]);
39271
+ const dx = half * (next[1] - point[1]) / length;
39272
+ const dy = half * (next[0] - point[0]) / length;
39273
+ if (cap !== 1) {
39274
+ const sx = cap === 2 ? dy : 0, sy = cap === 2 ? dx : 0;
39275
+ add(point[0] - dx - sx, point[1] + dy - sy);
39276
+ add(point[0] + dx - sx, point[1] - dy - sy);
39277
+ } else {
39278
+ const angle = Math.atan2(dy, -dx);
39279
+ const step = Math.max(1e-3, Math.acos(half / (half + 0.125)) * 2);
39280
+ add(point[0] - dx, point[1] + dy);
39281
+ 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));
39282
+ add(point[0] + dx, point[1] - dy);
39283
+ }
39284
+ };
39285
+ const addJoin = (prev, point, next) => {
39286
+ const len1 = Math.hypot(point[0] - prev[0], point[1] - prev[1]);
39287
+ const len2 = Math.hypot(next[0] - point[0], next[1] - point[1]);
39288
+ const dx1 = half * (point[1] - prev[1]) / len1, dy1 = half * (point[0] - prev[0]) / len1;
39289
+ const dx2 = half * (next[1] - point[1]) / len2, dy2 = half * (next[0] - point[0]) / len2;
39290
+ const inner = (next[0] - point[0]) * (point[1] - prev[1]) - (next[1] - point[1]) * (point[0] - prev[0]) > 0;
39291
+ if (!inner && join === 1) {
39292
+ arc(point, dx1, -dy1, dx2, -dy2);
39293
+ return;
39294
+ }
39295
+ if (inner || join === 0) {
39296
+ const ax = prev[0] + dx1, ay = prev[1] - dy1;
39297
+ const bx = point[0] + dx1, by = point[1] - dy1;
39298
+ const cx = point[0] + dx2, cy = point[1] - dy2;
39299
+ const dx = next[0] + dx2, dy = next[1] - dy2;
39300
+ const den = (bx - ax) * (dy - cy) - (by - ay) * (dx - cx);
39301
+ if (Math.abs(den) >= 1e-30) {
39302
+ const t = ((ay - cy) * (dx - cx) - (ax - cx) * (dy - cy)) / den;
39303
+ const x = ax + (bx - ax) * t, y = ay + (by - ay) * t;
39304
+ if (Math.hypot(x - point[0], y - point[1]) <= half * (inner ? 1.01 : miterLimit)) {
39305
+ add(x, y);
39306
+ return;
39307
+ }
39308
+ } else if ((bx - prev[0]) * dy1 - (prev[1] - by) * dx1 < 0 !== (bx - next[0]) * dy1 - (next[1] - by) * dx1 < 0) {
39309
+ add(bx, by);
39310
+ return;
39311
+ }
39312
+ }
39313
+ add(point[0] + dx1, point[1] - dy1);
39314
+ add(point[0] + dx2, point[1] - dy2);
39315
+ };
39316
+ for (const path of paths) {
39317
+ for (const subpath of pattern.length ? dashSubpath(path, pattern, dashPhase) : [path]) {
39318
+ const points = [];
39319
+ for (const point of subpath.points) {
39320
+ const prev = points[points.length - 1];
39321
+ if (!prev || Math.hypot(prev[0] - point[0], prev[1] - point[1]) > 1e-14) points.push(point);
39322
+ }
39323
+ let closed = subpath.closed;
39324
+ 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();
39325
+ if (points.length < 3) closed = false;
39326
+ if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
39327
+ contour = [];
39328
+ const [x, y] = points[0];
39329
+ addCap([x, y], [x + 1, y]);
39330
+ addCap([x, y], [x - 1, y]);
39331
+ contours.push(contour);
39332
+ } else if (points.length >= 2) {
39333
+ contour = [];
39334
+ if (!closed) addCap(points[0], points[1]);
39335
+ for (let i = closed ? 0 : 1; i < points.length - (closed ? 0 : 1); i++) {
39336
+ addJoin(points[(i + points.length - 1) % points.length], points[i], points[(i + 1) % points.length]);
39337
+ }
39338
+ if (closed) {
39339
+ contours.push(contour);
39340
+ contour = [];
39341
+ } else addCap(points[points.length - 1], points[points.length - 2]);
39342
+ for (let i = points.length - (closed ? 1 : 2); i >= (closed ? 0 : 1); i--) {
39343
+ addJoin(points[(i + 1) % points.length], points[i], points[(i + points.length - 1) % points.length]);
39344
+ }
39345
+ contours.push(contour);
39346
+ }
39347
+ }
39348
+ }
39349
+ return contours;
39350
+ }
39173
39351
  function encodePng(bitmap) {
39174
39352
  return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
39175
39353
  }
@@ -40091,111 +40269,60 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
40091
40269
  rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
40092
40270
  rgba[idx + 3] = Math.round(outA * 255);
40093
40271
  }
40094
- function drawAntiAliasedSegment(rgba, width, height, x0, y0, x1, y1, strokeWidth, color, alpha = 1, lineCap = 0, antialias = true, blendMode, clipMask) {
40095
- const halfW = Math.max(0.6, strokeWidth * 0.5);
40096
- const dx = x1 - x0;
40097
- const dy = y1 - y0;
40098
- const lenSq = dx * dx + dy * dy;
40099
- const segLen = Math.sqrt(lenSq);
40100
- const pad = lineCap === 2 ? halfW + 2 : halfW + 1;
40101
- const minX = Math.max(0, Math.floor(Math.min(x0, x1) - pad));
40102
- const maxX = Math.min(width - 1, Math.ceil(Math.max(x0, x1) + pad));
40103
- const minY = Math.max(0, Math.floor(Math.min(y0, y1) - pad));
40104
- const maxY = Math.min(height - 1, Math.ceil(Math.max(y0, y1) + pad));
40105
- for (let py = minY; py <= maxY; py++) {
40106
- for (let px = minX; px <= maxX; px++) {
40107
- const cx = px + 0.5;
40108
- const cy = py + 0.5;
40109
- if (segLen > 1e-6 && (lineCap === 0 || lineCap === 2)) {
40110
- const ux = dx / segLen;
40111
- const uy = dy / segLen;
40112
- const along = (cx - x0) * ux + (cy - y0) * uy;
40113
- const perp = Math.abs(-(cx - x0) * uy + (cy - y0) * ux);
40114
- const minAlong = lineCap === 2 ? -halfW : 0;
40115
- const maxAlong = lineCap === 2 ? segLen + halfW : segLen;
40116
- const overAlong = along < minAlong ? minAlong - along : along > maxAlong ? along - maxAlong : 0;
40117
- const dist2 = overAlong > 0 ? Math.max(perp, halfW + overAlong) : perp;
40118
- if (dist2 <= halfW + 0.75) {
40119
- const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist2)) : dist2 <= halfW + 0.25 ? 1 : 0;
40120
- blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
40121
- }
40122
- continue;
40123
- }
40124
- let t = lenSq > 1e-6 ? ((cx - x0) * dx + (cy - y0) * dy) / lenSq : 0;
40125
- t = Math.max(0, Math.min(1, t));
40126
- const projX = x0 + t * dx;
40127
- const projY = y0 + t * dy;
40128
- const dist = Math.hypot(cx - projX, cy - projY);
40129
- if (dist <= halfW + 0.75) {
40130
- const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist)) : dist <= halfW + 0.25 ? 1 : 0;
40131
- blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
40132
- }
40133
- }
40134
- }
40135
- }
40136
- function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = false) {
40137
- const edges = [];
40138
- let curX = 0;
40139
- let curY = 0;
40140
- let startX = 0;
40141
- let startY = 0;
40142
- let hasOpenSubpath = false;
40272
+ function segmentsToScreenPaths(segments, pageHeight, scale) {
40273
+ const paths = [];
40274
+ let points = [];
40275
+ let current = [0, 0];
40143
40276
  const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
40144
- for (const seg of segments) {
40145
- if (seg.kind === "move") {
40146
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40147
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40148
- }
40149
- [curX, curY] = toScreen(seg.x, seg.y);
40150
- startX = curX;
40151
- startY = curY;
40152
- hasOpenSubpath = false;
40153
- } else if (seg.kind === "line") {
40154
- const [nx, ny] = toScreen(seg.x, seg.y);
40155
- edges.push({ x0: curX, y0: curY, x1: nx, y1: ny });
40156
- curX = nx;
40157
- curY = ny;
40158
- hasOpenSubpath = true;
40159
- } else if (seg.kind === "cubic") {
40160
- const [p1x, p1y] = toScreen(seg.x1, seg.y1);
40161
- const [p2x, p2y] = toScreen(seg.x2, seg.y2);
40162
- const [p3x, p3y] = toScreen(seg.x, seg.y);
40163
- const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
40164
- let px = curX;
40165
- let py = curY;
40166
- for (let i = 1; i < points.length; i++) {
40167
- const [qx, qy] = points[i];
40168
- edges.push({ x0: px, y0: py, x1: qx, y1: qy });
40169
- px = qx;
40170
- py = qy;
40171
- }
40172
- curX = p3x;
40173
- curY = p3y;
40174
- hasOpenSubpath = true;
40175
- } else if (seg.kind === "close") {
40176
- if (curX !== startX || curY !== startY) {
40177
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40178
- curX = startX;
40179
- curY = startY;
40180
- }
40181
- hasOpenSubpath = false;
40182
- } else if (seg.kind === "rect") {
40183
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40184
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40185
- }
40186
- const [rx0, ry0] = toScreen(seg.x, seg.y);
40187
- const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
40188
- edges.push(
40189
- { x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
40190
- { x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
40191
- { x0: rx1, y0: ry1, x1: rx0, y1: ry1 },
40192
- { x0: rx0, y0: ry1, x1: rx0, y1: ry0 }
40193
- );
40194
- hasOpenSubpath = false;
40277
+ for (const segment of segments) {
40278
+ if (segment.kind === "move") {
40279
+ if (points.length) paths.push({ points, closed: false });
40280
+ current = toScreen(segment.x, segment.y);
40281
+ points = [current];
40282
+ } else if (segment.kind === "line") {
40283
+ if (!points.length) points = [current];
40284
+ current = toScreen(segment.x, segment.y);
40285
+ points.push(current);
40286
+ } else if (segment.kind === "cubic") {
40287
+ if (!points.length) points = [current];
40288
+ const a = toScreen(segment.x1, segment.y1), b = toScreen(segment.x2, segment.y2);
40289
+ const end = toScreen(segment.x, segment.y);
40290
+ const curve = flattenCubic(current[0], current[1], a[0], a[1], b[0], b[1], end[0], end[1]);
40291
+ for (let i = 1; i < curve.length; i++) points.push(curve[i]);
40292
+ current = end;
40293
+ } else if (segment.kind === "close") {
40294
+ if (points.length) {
40295
+ paths.push({ points, closed: true });
40296
+ current = points[0];
40297
+ points = [];
40298
+ }
40299
+ } else if (segment.kind === "rect") {
40300
+ if (points.length) paths.push({ points, closed: false });
40301
+ const first = toScreen(segment.x, segment.y);
40302
+ paths.push({ points: [
40303
+ first,
40304
+ toScreen(segment.x + segment.width, segment.y),
40305
+ toScreen(segment.x + segment.width, segment.y + segment.height),
40306
+ toScreen(segment.x, segment.y + segment.height)
40307
+ ], closed: true });
40308
+ current = first;
40309
+ points = [];
40310
+ }
40311
+ }
40312
+ if (points.length) paths.push({ points, closed: false });
40313
+ return paths;
40314
+ }
40315
+ function pathsToEdges(paths, closeSubpaths = false) {
40316
+ const edges = [];
40317
+ for (const { points, closed } of paths) {
40318
+ for (let i = 1; i < points.length; i++) {
40319
+ const a = points[i - 1], b = points[i];
40320
+ edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
40321
+ }
40322
+ if ((closed || closeSubpaths) && points.length > 1) {
40323
+ const a = points[points.length - 1], b = points[0];
40324
+ edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
40195
40325
  }
40196
- }
40197
- if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
40198
- edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
40199
40326
  }
40200
40327
  return edges;
40201
40328
  }
@@ -40382,7 +40509,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40382
40509
  for (const clip of clips) {
40383
40510
  const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
40384
40511
  const layer = new Uint8Array(width * height * 4);
40385
- fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
40512
+ fillEdgesScanline4x4(layer, width, height, pathsToEdges(segmentsToScreenPaths(segments, displayList.height, scale), true), { r: 1, g: 1, b: 1 }, 1, fillRule);
40386
40513
  for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
40387
40514
  }
40388
40515
  cachedClips = clips;
@@ -40429,62 +40556,38 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40429
40556
  if (operation.kind === "path") {
40430
40557
  const path = operation.value;
40431
40558
  if (path.fillColor) {
40432
- const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, true);
40559
+ const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale), true);
40433
40560
  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;
40434
40561
  fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
40435
40562
  }
40436
40563
  if (path.strokeColor) {
40437
- const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, false);
40438
40564
  const rawSw = path.strokeWidth * scale;
40439
40565
  const sw = Math.max(1, rawSw);
40440
40566
  const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
40441
- const dashArr = path.dashArray && path.dashArray.length > 0 ? path.dashArray.map((d) => Math.max(0, d * scale)) : void 0;
40442
- const dashCycle = dashArr ? dashArr.reduce((a, b) => a + b, 0) : 0;
40443
- let dashDist = (path.dashPhase ?? 0) * scale % (dashCycle || 1);
40444
- if (dashDist < 0) dashDist += dashCycle;
40445
- for (const e of edges) {
40446
- if (!dashArr || dashCycle <= 1e-4) {
40447
- 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);
40448
- } else {
40449
- const dx = e.x1 - e.x0;
40450
- const dy = e.y1 - e.y0;
40451
- const edgeLen = Math.hypot(dx, dy);
40452
- if (edgeLen <= 1e-4) continue;
40453
- let pos = 0;
40454
- while (pos < edgeLen) {
40455
- let cycleRem = dashDist % dashCycle;
40456
- let dIdx = 0;
40457
- while (dIdx < dashArr.length - 1 && cycleRem >= dashArr[dIdx]) {
40458
- cycleRem -= dashArr[dIdx];
40459
- dIdx++;
40460
- }
40461
- const segRemainInDash = Math.max(1e-4, dashArr[dIdx] - cycleRem);
40462
- const step = Math.min(edgeLen - pos, segRemainInDash);
40463
- if (dIdx % 2 === 0) {
40464
- const t0 = pos / edgeLen;
40465
- const t1 = (pos + step) / edgeLen;
40466
- drawAntiAliasedSegment(
40467
- rgba,
40468
- width,
40469
- height,
40470
- e.x0 + dx * t0,
40471
- e.y0 + dy * t0,
40472
- e.x0 + dx * t1,
40473
- e.y0 + dy * t1,
40474
- sw,
40475
- path.strokeColor,
40476
- strokeAlpha,
40477
- path.lineCap ?? 0,
40478
- original.kind === "glyph" ? aaTxt : aaVec,
40479
- path.blendMode,
40480
- clipMask
40481
- );
40482
- }
40483
- pos += step;
40484
- dashDist = (dashDist + step) % dashCycle;
40485
- }
40486
- }
40487
- }
40567
+ const contours = strokeOutlines(
40568
+ segmentsToScreenPaths(path.segments, displayList.height, scale),
40569
+ sw,
40570
+ path.lineCap ?? 0,
40571
+ path.lineJoin ?? 0,
40572
+ path.miterLimit ?? 10,
40573
+ path.dashArray?.map((value) => Math.max(0, value * scale)),
40574
+ (path.dashPhase ?? 0) * scale
40575
+ );
40576
+ const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
40577
+ 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;
40578
+ fillEdgesScanline4x4(
40579
+ rgba,
40580
+ width,
40581
+ height,
40582
+ edges,
40583
+ path.strokeColor,
40584
+ strokeAlpha,
40585
+ "nonzero",
40586
+ clipScreen,
40587
+ original.kind === "glyph" ? aaTxt : aaVec,
40588
+ path.blendMode,
40589
+ clipMask
40590
+ );
40488
40591
  }
40489
40592
  } else if (operation.kind === "image") {
40490
40593
  const img = operation.value;
@@ -42605,3 +42708,15 @@ export {
42605
42708
  * Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
42606
42709
  * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
42607
42710
  */
42711
+ /*!
42712
+ * Anti-Grain Geometry - Version 2.3
42713
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
42714
+ *
42715
+ * Permission to copy, use, modify, sell and distribute this software
42716
+ * is granted provided this copyright notice appears in all copies.
42717
+ * This software is provided "as is" without express or implied
42718
+ * warranty, and with no claim as to its suitability for any purpose.
42719
+ *
42720
+ * Adapted from PDFium agg_math_stroke.h and agg_vcgen_stroke.cpp.
42721
+ * See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
42722
+ */