@poe-platform/safe-bash 0.1.763 → 0.1.765
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 +321 -162
- package/dist/image-ast/index.js +321 -162
- package/dist/pdf-ast/ast.d.ts +2 -0
- package/dist/pdf-ast/index.js +340 -173
- package/dist/safe-bash/chunks/{chunk-CRQDMBQA.js → chunk-FSH7QRIC.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-4XHONGIU.js → chunk-DT4MFWV4.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-S3G2B4OX.js → chunk-KO4PXCNL.js} +324 -162
- package/dist/safe-bash/command-chunks/{chunk-S5EX6UP5.js → chunk-SVL6HYQL.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 +5800 -5693
- 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 +321 -162
- package/dist/safe-bash-command-pdfinfo/index.js +338 -173
- package/dist/safe-bash-command-pdftk/index.js +321 -162
- package/dist/safe-bash-command-pdftoppm/index.js +338 -173
- package/dist/safe-bash-command-pdftotext/index.js +321 -162
- package/dist/safe-bash-command-qpdf/index.js +321 -162
- 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 +373 -169
- package/dist/safe-bash-command-wkhtmltopdf/index.js +322 -162
- 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 +24 -0
|
@@ -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;
|
|
@@ -209751,15 +209750,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209751
209750
|
break;
|
|
209752
209751
|
}
|
|
209753
209752
|
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
209753
|
emit({ kind: "path", value: {
|
|
209757
209754
|
segments: transformedSegments,
|
|
209758
209755
|
fillColor: isFill && !evaluatedFillPattern ? st.fillColor : void 0,
|
|
209759
209756
|
fillAlpha: isFill && !evaluatedFillPattern ? st.fillAlpha : void 0,
|
|
209760
209757
|
strokeColor: isStroke ? st.strokeColor : void 0,
|
|
209761
209758
|
strokeAlpha: isStroke ? st.strokeAlpha : void 0,
|
|
209762
|
-
strokeWidth:
|
|
209759
|
+
strokeWidth: st.strokeWidth,
|
|
209760
|
+
...isStroke ? { strokeMatrix: [...st.ctm] } : {},
|
|
209763
209761
|
...st.lineCap !== 0 ? { lineCap: st.lineCap } : {},
|
|
209764
209762
|
...st.lineJoin !== 0 ? { lineJoin: st.lineJoin } : {},
|
|
209765
209763
|
...st.miterLimit !== 10 ? { miterLimit: st.miterLimit } : {},
|
|
@@ -209947,14 +209945,14 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
209947
209945
|
if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
|
|
209948
209946
|
const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
|
|
209949
209947
|
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
209948
|
const paint = {
|
|
209952
209949
|
segments: transformedGlyphSegs,
|
|
209953
209950
|
fillColor: isFillGlyph ? st.fillColor : void 0,
|
|
209954
209951
|
fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
|
|
209955
209952
|
strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
|
|
209956
209953
|
strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
|
|
209957
|
-
strokeWidth: isStrokeGlyph ? st.strokeWidth
|
|
209954
|
+
strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
|
|
209955
|
+
...isStrokeGlyph ? { strokeMatrix: [...st.ctm] } : {},
|
|
209958
209956
|
fillRule: "nonzero",
|
|
209959
209957
|
...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
|
|
209960
209958
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
@@ -212332,6 +212330,184 @@ function downscaleImage(image, widthScale, heightScale) {
|
|
|
212332
212330
|
}
|
|
212333
212331
|
return image;
|
|
212334
212332
|
}
|
|
212333
|
+
var MAX_STROKE_VERTICES = 1e6;
|
|
212334
|
+
function dashSubpath(path2, pattern, phase) {
|
|
212335
|
+
const cycle = pattern.reduce((sum2, value3) => sum2 + value3, 0);
|
|
212336
|
+
if (!(cycle > 0)) return [path2];
|
|
212337
|
+
let offset = (phase % cycle + cycle) % cycle, index2 = 0;
|
|
212338
|
+
while (offset > 0) {
|
|
212339
|
+
if (offset < pattern[index2]) break;
|
|
212340
|
+
offset -= pattern[index2];
|
|
212341
|
+
index2 = (index2 + 1) % pattern.length;
|
|
212342
|
+
}
|
|
212343
|
+
let remaining = pattern[index2] - offset;
|
|
212344
|
+
const points = path2.closed ? [...path2.points, path2.points[0]] : path2.points;
|
|
212345
|
+
const result2 = [];
|
|
212346
|
+
let current = [];
|
|
212347
|
+
let steps = 0;
|
|
212348
|
+
const flush = () => {
|
|
212349
|
+
if (current.length) result2.push({ points: current, closed: false });
|
|
212350
|
+
current = [];
|
|
212351
|
+
};
|
|
212352
|
+
const advance2 = (point) => {
|
|
212353
|
+
while (remaining <= 0) {
|
|
212354
|
+
if (++steps > MAX_STROKE_VERTICES) throw new PdfError2("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
212355
|
+
if (index2 % 2 === 0) {
|
|
212356
|
+
if (pattern[index2] === 0) result2.push({ points: [point, point], closed: false });
|
|
212357
|
+
flush();
|
|
212358
|
+
}
|
|
212359
|
+
index2 = (index2 + 1) % pattern.length;
|
|
212360
|
+
remaining = pattern[index2];
|
|
212361
|
+
}
|
|
212362
|
+
};
|
|
212363
|
+
for (let i = 1; i < points.length; i++) {
|
|
212364
|
+
const start = points[i - 1], end2 = points[i];
|
|
212365
|
+
const dx = end2[0] - start[0], dy = end2[1] - start[1];
|
|
212366
|
+
const length = Math.hypot(dx, dy);
|
|
212367
|
+
if (!Number.isFinite(length) || length / cycle * pattern.length > MAX_STROKE_VERTICES) {
|
|
212368
|
+
throw new PdfError2("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
212369
|
+
}
|
|
212370
|
+
let distance2 = 0;
|
|
212371
|
+
while (distance2 < length) {
|
|
212372
|
+
const point = [start[0] + dx * distance2 / length, start[1] + dy * distance2 / length];
|
|
212373
|
+
advance2(point);
|
|
212374
|
+
const step = Math.min(remaining, length - distance2);
|
|
212375
|
+
if (distance2 + step === distance2 || ++steps > MAX_STROKE_VERTICES) throw new PdfError2("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
212376
|
+
distance2 += step;
|
|
212377
|
+
remaining -= step;
|
|
212378
|
+
if (index2 % 2 === 0) {
|
|
212379
|
+
if (!current.length) current.push(point);
|
|
212380
|
+
current.push([start[0] + dx * distance2 / length, start[1] + dy * distance2 / length]);
|
|
212381
|
+
}
|
|
212382
|
+
}
|
|
212383
|
+
}
|
|
212384
|
+
flush();
|
|
212385
|
+
if (path2.closed && result2.length) {
|
|
212386
|
+
const first = result2[0], last = result2[result2.length - 1];
|
|
212387
|
+
const start = path2.points[0];
|
|
212388
|
+
const firstPoint = first.points[0], lastPoint = last.points[last.points.length - 1];
|
|
212389
|
+
if (firstPoint[0] === start[0] && firstPoint[1] === start[1] && lastPoint[0] === start[0] && lastPoint[1] === start[1]) {
|
|
212390
|
+
if (first === last) result2[0] = { points: first.points, closed: true };
|
|
212391
|
+
else {
|
|
212392
|
+
result2[0] = { points: [...last.points, ...first.points.slice(1)], closed: false };
|
|
212393
|
+
result2.pop();
|
|
212394
|
+
}
|
|
212395
|
+
}
|
|
212396
|
+
}
|
|
212397
|
+
return result2;
|
|
212398
|
+
}
|
|
212399
|
+
function strokeOutlines(paths, width2, cap, join3, miterLimit, dashArray = [], dashPhase = 0) {
|
|
212400
|
+
const half = width2 / 2;
|
|
212401
|
+
const contours = [];
|
|
212402
|
+
const pattern = dashArray.length % 2 ? [...dashArray, ...dashArray] : dashArray;
|
|
212403
|
+
let count = 0;
|
|
212404
|
+
let contour = [];
|
|
212405
|
+
const add5 = (x, y) => {
|
|
212406
|
+
if (++count > MAX_STROKE_VERTICES) throw new PdfError2("E_LIMIT", "Stroke outline exceeds the vertex limit");
|
|
212407
|
+
contour.push([x, y]);
|
|
212408
|
+
};
|
|
212409
|
+
const arc = (point, dx1, dy1, dx2, dy2) => {
|
|
212410
|
+
let a1 = Math.atan2(dy1, dx1), a22 = Math.atan2(dy2, dx2);
|
|
212411
|
+
const ccw = a1 - a22 > 0 && a1 - a22 < Math.PI;
|
|
212412
|
+
const step = Math.acos(half / (half + 0.125)) * 2;
|
|
212413
|
+
add5(point[0] + dx1, point[1] + dy1);
|
|
212414
|
+
if (step > 0) {
|
|
212415
|
+
if (!ccw) {
|
|
212416
|
+
if (a1 > a22) a22 += 2 * Math.PI;
|
|
212417
|
+
a22 -= step / 4;
|
|
212418
|
+
if ((a22 - a1) / step > MAX_STROKE_VERTICES - count) throw new PdfError2("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
212419
|
+
for (a1 += step; a1 < a22; a1 += step) add5(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
212420
|
+
} else {
|
|
212421
|
+
if (a1 < a22) a22 -= 2 * Math.PI;
|
|
212422
|
+
a22 += step / 4;
|
|
212423
|
+
if ((a1 - a22) / step > MAX_STROKE_VERTICES - count) throw new PdfError2("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
212424
|
+
for (a1 -= step; a1 > a22; a1 -= step) add5(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
212425
|
+
}
|
|
212426
|
+
}
|
|
212427
|
+
add5(point[0] + dx2, point[1] + dy2);
|
|
212428
|
+
};
|
|
212429
|
+
const addCap = (point, next) => {
|
|
212430
|
+
const length = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
212431
|
+
const dx = half * (next[1] - point[1]) / length;
|
|
212432
|
+
const dy = half * (next[0] - point[0]) / length;
|
|
212433
|
+
if (cap !== 1) {
|
|
212434
|
+
const sx = cap === 2 ? dy : 0, sy = cap === 2 ? dx : 0;
|
|
212435
|
+
add5(point[0] - dx - sx, point[1] + dy - sy);
|
|
212436
|
+
add5(point[0] + dx - sx, point[1] - dy - sy);
|
|
212437
|
+
} else {
|
|
212438
|
+
const angle = Math.atan2(dy, -dx);
|
|
212439
|
+
const step = Math.max(1e-3, Math.acos(half / (half + 0.125)) * 2);
|
|
212440
|
+
add5(point[0] - dx, point[1] + dy);
|
|
212441
|
+
for (let a3 = angle + step; a3 < angle + Math.PI - step / 4; a3 += step) add5(point[0] + half * Math.cos(a3), point[1] + half * Math.sin(a3));
|
|
212442
|
+
add5(point[0] + dx, point[1] - dy);
|
|
212443
|
+
}
|
|
212444
|
+
};
|
|
212445
|
+
const addJoin = (prev, point, next) => {
|
|
212446
|
+
const len1 = Math.hypot(point[0] - prev[0], point[1] - prev[1]);
|
|
212447
|
+
const len2 = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
212448
|
+
const dx1 = half * (point[1] - prev[1]) / len1, dy1 = half * (point[0] - prev[0]) / len1;
|
|
212449
|
+
const dx2 = half * (next[1] - point[1]) / len2, dy2 = half * (next[0] - point[0]) / len2;
|
|
212450
|
+
const inner = (next[0] - point[0]) * (point[1] - prev[1]) - (next[1] - point[1]) * (point[0] - prev[0]) > 0;
|
|
212451
|
+
if (!inner && join3 === 1) {
|
|
212452
|
+
arc(point, dx1, -dy1, dx2, -dy2);
|
|
212453
|
+
return;
|
|
212454
|
+
}
|
|
212455
|
+
if (inner || join3 === 0) {
|
|
212456
|
+
const ax = prev[0] + dx1, ay = prev[1] - dy1;
|
|
212457
|
+
const bx = point[0] + dx1, by = point[1] - dy1;
|
|
212458
|
+
const cx = point[0] + dx2, cy = point[1] - dy2;
|
|
212459
|
+
const dx = next[0] + dx2, dy = next[1] - dy2;
|
|
212460
|
+
const den = (bx - ax) * (dy - cy) - (by - ay) * (dx - cx);
|
|
212461
|
+
if (Math.abs(den) >= 1e-30) {
|
|
212462
|
+
const t = ((ay - cy) * (dx - cx) - (ax - cx) * (dy - cy)) / den;
|
|
212463
|
+
const x = ax + (bx - ax) * t, y = ay + (by - ay) * t;
|
|
212464
|
+
if (Math.hypot(x - point[0], y - point[1]) <= half * (inner ? 1.01 : miterLimit)) {
|
|
212465
|
+
add5(x, y);
|
|
212466
|
+
return;
|
|
212467
|
+
}
|
|
212468
|
+
} else if ((bx - prev[0]) * dy1 - (prev[1] - by) * dx1 < 0 !== (bx - next[0]) * dy1 - (next[1] - by) * dx1 < 0) {
|
|
212469
|
+
add5(bx, by);
|
|
212470
|
+
return;
|
|
212471
|
+
}
|
|
212472
|
+
}
|
|
212473
|
+
add5(point[0] + dx1, point[1] - dy1);
|
|
212474
|
+
add5(point[0] + dx2, point[1] - dy2);
|
|
212475
|
+
};
|
|
212476
|
+
for (const path2 of paths) {
|
|
212477
|
+
for (const subpath of pattern.length ? dashSubpath(path2, pattern, dashPhase) : [path2]) {
|
|
212478
|
+
const points = [];
|
|
212479
|
+
for (const point of subpath.points) {
|
|
212480
|
+
const prev = points[points.length - 1];
|
|
212481
|
+
if (!prev || Math.hypot(prev[0] - point[0], prev[1] - point[1]) > 1e-14) points.push(point);
|
|
212482
|
+
}
|
|
212483
|
+
let closed = subpath.closed;
|
|
212484
|
+
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();
|
|
212485
|
+
if (points.length < 3) closed = false;
|
|
212486
|
+
if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
|
|
212487
|
+
contour = [];
|
|
212488
|
+
const [x, y] = points[0];
|
|
212489
|
+
addCap([x, y], [x + 1, y]);
|
|
212490
|
+
addCap([x, y], [x - 1, y]);
|
|
212491
|
+
contours.push(contour);
|
|
212492
|
+
} else if (points.length >= 2) {
|
|
212493
|
+
contour = [];
|
|
212494
|
+
if (!closed) addCap(points[0], points[1]);
|
|
212495
|
+
for (let i = closed ? 0 : 1; i < points.length - (closed ? 0 : 1); i++) {
|
|
212496
|
+
addJoin(points[(i + points.length - 1) % points.length], points[i], points[(i + 1) % points.length]);
|
|
212497
|
+
}
|
|
212498
|
+
if (closed) {
|
|
212499
|
+
contours.push(contour);
|
|
212500
|
+
contour = [];
|
|
212501
|
+
} else addCap(points[points.length - 1], points[points.length - 2]);
|
|
212502
|
+
for (let i = points.length - (closed ? 1 : 2); i >= (closed ? 0 : 1); i--) {
|
|
212503
|
+
addJoin(points[(i + 1) % points.length], points[i], points[(i + points.length - 1) % points.length]);
|
|
212504
|
+
}
|
|
212505
|
+
contours.push(contour);
|
|
212506
|
+
}
|
|
212507
|
+
}
|
|
212508
|
+
}
|
|
212509
|
+
return contours;
|
|
212510
|
+
}
|
|
212335
212511
|
function decodePng2(pngBytes) {
|
|
212336
212512
|
if (pngBytes.length < 24 || pngBytes[0] !== 137 || pngBytes[1] !== 80 || pngBytes[2] !== 78 || pngBytes[3] !== 71) {
|
|
212337
212513
|
throw new Error("Invalid PNG signature");
|
|
@@ -213026,111 +213202,116 @@ function blendPixel(rgba, width2, height, px, py, color5, alpha, blendMode, clip
|
|
|
213026
213202
|
rgba[idx + 2] = Math.round((effB * a3 + cbB * dstA * (1 - a3)) / outA * 255);
|
|
213027
213203
|
rgba[idx + 3] = Math.round(outA * 255);
|
|
213028
213204
|
}
|
|
213029
|
-
function
|
|
213030
|
-
const
|
|
213031
|
-
|
|
213032
|
-
|
|
213033
|
-
const
|
|
213034
|
-
|
|
213035
|
-
|
|
213036
|
-
|
|
213037
|
-
|
|
213038
|
-
|
|
213039
|
-
|
|
213040
|
-
|
|
213041
|
-
|
|
213042
|
-
|
|
213043
|
-
|
|
213044
|
-
|
|
213045
|
-
|
|
213046
|
-
|
|
213047
|
-
|
|
213048
|
-
|
|
213049
|
-
|
|
213050
|
-
|
|
213051
|
-
|
|
213052
|
-
|
|
213053
|
-
|
|
213054
|
-
|
|
213055
|
-
|
|
213056
|
-
|
|
213057
|
-
|
|
213058
|
-
|
|
213059
|
-
|
|
213060
|
-
|
|
213061
|
-
|
|
213062
|
-
|
|
213063
|
-
|
|
213064
|
-
|
|
213065
|
-
|
|
213066
|
-
blendPixel(rgba, width2, height, px, py, color5, cov * alpha, blendMode, clipMask);
|
|
213067
|
-
}
|
|
213205
|
+
function segmentsToScreenPaths(segments, pageHeight, scale2, toScreen = (x, y) => [x * scale2, (pageHeight - y) * scale2]) {
|
|
213206
|
+
const paths = [];
|
|
213207
|
+
let points = [];
|
|
213208
|
+
let current = [0, 0];
|
|
213209
|
+
for (const segment of segments) {
|
|
213210
|
+
if (segment.kind === "move") {
|
|
213211
|
+
if (points.length) paths.push({ points, closed: false });
|
|
213212
|
+
current = toScreen(segment.x, segment.y);
|
|
213213
|
+
points = [current];
|
|
213214
|
+
} else if (segment.kind === "line") {
|
|
213215
|
+
if (!points.length) points = [current];
|
|
213216
|
+
current = toScreen(segment.x, segment.y);
|
|
213217
|
+
points.push(current);
|
|
213218
|
+
} else if (segment.kind === "cubic") {
|
|
213219
|
+
if (!points.length) points = [current];
|
|
213220
|
+
const a3 = toScreen(segment.x1, segment.y1), b3 = toScreen(segment.x2, segment.y2);
|
|
213221
|
+
const end2 = toScreen(segment.x, segment.y);
|
|
213222
|
+
const curve = flattenCubic(current[0], current[1], a3[0], a3[1], b3[0], b3[1], end2[0], end2[1]);
|
|
213223
|
+
for (let i = 1; i < curve.length; i++) points.push(curve[i]);
|
|
213224
|
+
current = end2;
|
|
213225
|
+
} else if (segment.kind === "close") {
|
|
213226
|
+
if (points.length) {
|
|
213227
|
+
paths.push({ points, closed: true });
|
|
213228
|
+
current = points[0];
|
|
213229
|
+
points = [];
|
|
213230
|
+
}
|
|
213231
|
+
} else if (segment.kind === "rect") {
|
|
213232
|
+
if (points.length) paths.push({ points, closed: false });
|
|
213233
|
+
const first = toScreen(segment.x, segment.y);
|
|
213234
|
+
paths.push({ points: [
|
|
213235
|
+
first,
|
|
213236
|
+
toScreen(segment.x + segment.width, segment.y),
|
|
213237
|
+
toScreen(segment.x + segment.width, segment.y + segment.height),
|
|
213238
|
+
toScreen(segment.x, segment.y + segment.height)
|
|
213239
|
+
], closed: true });
|
|
213240
|
+
current = first;
|
|
213241
|
+
points = [];
|
|
213068
213242
|
}
|
|
213069
213243
|
}
|
|
213244
|
+
if (points.length) paths.push({ points, closed: false });
|
|
213245
|
+
return paths;
|
|
213070
213246
|
}
|
|
213071
|
-
function
|
|
213247
|
+
function inverseStrokeMatrix(matrix2) {
|
|
213248
|
+
const [a3, b3, c4, d2, e, f2] = matrix2;
|
|
213249
|
+
const det = a3 * d2 - b3 * c4;
|
|
213250
|
+
if (!Number.isFinite(det) || det === 0) return void 0;
|
|
213251
|
+
return [d2 / det, -b3 / det, -c4 / det, a3 / det, (c4 * f2 - d2 * e) / det, (b3 * e - a3 * f2) / det];
|
|
213252
|
+
}
|
|
213253
|
+
function prepareStroke(path2, scale2) {
|
|
213254
|
+
const matrix2 = path2.strokeMatrix ? [...path2.strokeMatrix] : [1, 0, 0, 1, 0, 0];
|
|
213255
|
+
const [a3, b3, c4, d2] = matrix2;
|
|
213256
|
+
const area = Math.abs(a3 * d2 - b3 * c4) * scale2 * scale2;
|
|
213257
|
+
if (!(area > 0) || !Number.isFinite(area)) return void 0;
|
|
213258
|
+
const normX = Math.hypot(a3, b3) * scale2, normY = Math.hypot(c4, d2) * scale2;
|
|
213259
|
+
let width2 = path2.strokeWidth || 1;
|
|
213260
|
+
const scaleX = path2.strokeWidth === 0 ? normY / area : Math.max(1, normY / (width2 * area));
|
|
213261
|
+
const scaleY = path2.strokeWidth === 0 ? normX / area : Math.max(1, normX / (width2 * area));
|
|
213262
|
+
let dashArray = path2.dashArray, dashPhase = path2.dashPhase ?? 0;
|
|
213263
|
+
if (scaleX === scaleY) {
|
|
213264
|
+
width2 *= scaleX;
|
|
213265
|
+
} else {
|
|
213266
|
+
matrix2[0] *= scaleX;
|
|
213267
|
+
matrix2[1] *= scaleX;
|
|
213268
|
+
matrix2[2] *= scaleY;
|
|
213269
|
+
matrix2[3] *= scaleY;
|
|
213270
|
+
if (dashArray?.length) {
|
|
213271
|
+
const dashScale = Math.max(scaleX, scaleY);
|
|
213272
|
+
dashArray = dashArray.map((value3) => value3 / dashScale);
|
|
213273
|
+
dashPhase /= dashScale;
|
|
213274
|
+
}
|
|
213275
|
+
}
|
|
213276
|
+
return { matrix: matrix2, width: width2, dashArray, dashPhase };
|
|
213277
|
+
}
|
|
213278
|
+
function strokeEdges(path2, pageHeight, scale2) {
|
|
213279
|
+
const stroke = prepareStroke(path2, scale2);
|
|
213280
|
+
if (!stroke) return [];
|
|
213281
|
+
const inverse2 = inverseStrokeMatrix(stroke.matrix);
|
|
213282
|
+
if (!inverse2) return [];
|
|
213283
|
+
const [a3, b3, c4, d2, e, f2] = stroke.matrix;
|
|
213284
|
+
const strokeScale = scale2 * Math.hypot(a3, b3, c4, d2);
|
|
213285
|
+
const project = (x, y) => [
|
|
213286
|
+
(inverse2[0] * x + inverse2[2] * y + inverse2[4]) * strokeScale,
|
|
213287
|
+
(inverse2[1] * x + inverse2[3] * y + inverse2[5]) * strokeScale
|
|
213288
|
+
];
|
|
213289
|
+
const toScreen = ([x, y]) => [
|
|
213290
|
+
(a3 * x / strokeScale + c4 * y / strokeScale + e) * scale2,
|
|
213291
|
+
(pageHeight - b3 * x / strokeScale - d2 * y / strokeScale - f2) * scale2
|
|
213292
|
+
];
|
|
213293
|
+
const contours = strokeOutlines(
|
|
213294
|
+
segmentsToScreenPaths(path2.segments, pageHeight, scale2, project),
|
|
213295
|
+
stroke.width * strokeScale,
|
|
213296
|
+
path2.lineCap ?? 0,
|
|
213297
|
+
path2.lineJoin ?? 0,
|
|
213298
|
+
path2.miterLimit ?? 10,
|
|
213299
|
+
stroke.dashArray?.map((value3) => Math.max(0, value3 * strokeScale)),
|
|
213300
|
+
stroke.dashPhase * strokeScale
|
|
213301
|
+
);
|
|
213302
|
+
return pathsToEdges(contours.map((points) => ({ points: points.map(toScreen), closed: true })));
|
|
213303
|
+
}
|
|
213304
|
+
function pathsToEdges(paths, closeSubpaths = false) {
|
|
213072
213305
|
const edges2 = [];
|
|
213073
|
-
|
|
213074
|
-
|
|
213075
|
-
|
|
213076
|
-
|
|
213077
|
-
|
|
213078
|
-
|
|
213079
|
-
|
|
213080
|
-
|
|
213081
|
-
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
213082
|
-
edges2.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
213083
|
-
}
|
|
213084
|
-
[curX, curY] = toScreen(seg.x, seg.y);
|
|
213085
|
-
startX = curX;
|
|
213086
|
-
startY = curY;
|
|
213087
|
-
hasOpenSubpath = false;
|
|
213088
|
-
} else if (seg.kind === "line") {
|
|
213089
|
-
const [nx, ny] = toScreen(seg.x, seg.y);
|
|
213090
|
-
edges2.push({ x0: curX, y0: curY, x1: nx, y1: ny });
|
|
213091
|
-
curX = nx;
|
|
213092
|
-
curY = ny;
|
|
213093
|
-
hasOpenSubpath = true;
|
|
213094
|
-
} else if (seg.kind === "cubic") {
|
|
213095
|
-
const [p1x, p1y] = toScreen(seg.x1, seg.y1);
|
|
213096
|
-
const [p2x, p2y] = toScreen(seg.x2, seg.y2);
|
|
213097
|
-
const [p3x, p3y] = toScreen(seg.x, seg.y);
|
|
213098
|
-
const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
|
|
213099
|
-
let px = curX;
|
|
213100
|
-
let py = curY;
|
|
213101
|
-
for (let i = 1; i < points.length; i++) {
|
|
213102
|
-
const [qx, qy] = points[i];
|
|
213103
|
-
edges2.push({ x0: px, y0: py, x1: qx, y1: qy });
|
|
213104
|
-
px = qx;
|
|
213105
|
-
py = qy;
|
|
213106
|
-
}
|
|
213107
|
-
curX = p3x;
|
|
213108
|
-
curY = p3y;
|
|
213109
|
-
hasOpenSubpath = true;
|
|
213110
|
-
} else if (seg.kind === "close") {
|
|
213111
|
-
if (curX !== startX || curY !== startY) {
|
|
213112
|
-
edges2.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
213113
|
-
curX = startX;
|
|
213114
|
-
curY = startY;
|
|
213115
|
-
}
|
|
213116
|
-
hasOpenSubpath = false;
|
|
213117
|
-
} else if (seg.kind === "rect") {
|
|
213118
|
-
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
213119
|
-
edges2.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
213120
|
-
}
|
|
213121
|
-
const [rx0, ry0] = toScreen(seg.x, seg.y);
|
|
213122
|
-
const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
|
|
213123
|
-
edges2.push(
|
|
213124
|
-
{ x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
|
|
213125
|
-
{ x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
|
|
213126
|
-
{ x0: rx1, y0: ry1, x1: rx0, y1: ry1 },
|
|
213127
|
-
{ x0: rx0, y0: ry1, x1: rx0, y1: ry0 }
|
|
213128
|
-
);
|
|
213129
|
-
hasOpenSubpath = false;
|
|
213306
|
+
for (const { points, closed } of paths) {
|
|
213307
|
+
for (let i = 1; i < points.length; i++) {
|
|
213308
|
+
const a3 = points[i - 1], b3 = points[i];
|
|
213309
|
+
edges2.push({ x0: a3[0], y0: a3[1], x1: b3[0], y1: b3[1] });
|
|
213310
|
+
}
|
|
213311
|
+
if ((closed || closeSubpaths) && points.length > 1) {
|
|
213312
|
+
const a3 = points[points.length - 1], b3 = points[0];
|
|
213313
|
+
edges2.push({ x0: a3[0], y0: a3[1], x1: b3[0], y1: b3[1] });
|
|
213130
213314
|
}
|
|
213131
|
-
}
|
|
213132
|
-
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
213133
|
-
edges2.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
213134
213315
|
}
|
|
213135
213316
|
return edges2;
|
|
213136
213317
|
}
|
|
@@ -213317,7 +213498,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213317
213498
|
for (const clip2 of clips) {
|
|
213318
213499
|
const { segments, fillRule } = "segments" in clip2 ? clip2 : { segments: clip2, fillRule: "nonzero" };
|
|
213319
213500
|
const layer = new Uint8Array(width2 * height * 4);
|
|
213320
|
-
fillEdgesScanline4x4(layer, width2, height,
|
|
213501
|
+
fillEdgesScanline4x4(layer, width2, height, pathsToEdges(segmentsToScreenPaths(segments, displayList.height, scale2), true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
213321
213502
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
213322
213503
|
}
|
|
213323
213504
|
cachedClips = clips;
|
|
@@ -213364,62 +213545,28 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
213364
213545
|
if (operation.kind === "path") {
|
|
213365
213546
|
const path2 = operation.value;
|
|
213366
213547
|
if (path2.fillColor) {
|
|
213367
|
-
const edges2 =
|
|
213548
|
+
const edges2 = pathsToEdges(segmentsToScreenPaths(path2.segments, displayList.height, scale2), true);
|
|
213368
213549
|
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;
|
|
213369
213550
|
fillEdgesScanline4x4(rgba, width2, height, edges2, path2.fillColor, path2.fillAlpha ?? 1, path2.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path2.blendMode, clipMask);
|
|
213370
213551
|
}
|
|
213371
213552
|
if (path2.strokeColor) {
|
|
213372
|
-
const
|
|
213373
|
-
const rawSw = path2.strokeWidth * scale2;
|
|
213374
|
-
const sw = Math.max(1, rawSw);
|
|
213553
|
+
const rawSw = path2.strokeWidth * scale2 * (path2.strokeMatrix ? Math.hypot(path2.strokeMatrix[0], path2.strokeMatrix[1]) : 1);
|
|
213375
213554
|
const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path2.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path2.strokeAlpha ?? 1;
|
|
213376
|
-
const
|
|
213377
|
-
const
|
|
213378
|
-
|
|
213379
|
-
|
|
213380
|
-
|
|
213381
|
-
|
|
213382
|
-
|
|
213383
|
-
|
|
213384
|
-
|
|
213385
|
-
|
|
213386
|
-
|
|
213387
|
-
|
|
213388
|
-
|
|
213389
|
-
|
|
213390
|
-
|
|
213391
|
-
let dIdx = 0;
|
|
213392
|
-
while (dIdx < dashArr.length - 1 && cycleRem >= dashArr[dIdx]) {
|
|
213393
|
-
cycleRem -= dashArr[dIdx];
|
|
213394
|
-
dIdx++;
|
|
213395
|
-
}
|
|
213396
|
-
const segRemainInDash = Math.max(1e-4, dashArr[dIdx] - cycleRem);
|
|
213397
|
-
const step = Math.min(edgeLen - pos, segRemainInDash);
|
|
213398
|
-
if (dIdx % 2 === 0) {
|
|
213399
|
-
const t0 = pos / edgeLen;
|
|
213400
|
-
const t1 = (pos + step) / edgeLen;
|
|
213401
|
-
drawAntiAliasedSegment(
|
|
213402
|
-
rgba,
|
|
213403
|
-
width2,
|
|
213404
|
-
height,
|
|
213405
|
-
e.x0 + dx * t0,
|
|
213406
|
-
e.y0 + dy * t0,
|
|
213407
|
-
e.x0 + dx * t1,
|
|
213408
|
-
e.y0 + dy * t1,
|
|
213409
|
-
sw,
|
|
213410
|
-
path2.strokeColor,
|
|
213411
|
-
strokeAlpha,
|
|
213412
|
-
path2.lineCap ?? 0,
|
|
213413
|
-
original.kind === "glyph" ? aaTxt : aaVec,
|
|
213414
|
-
path2.blendMode,
|
|
213415
|
-
clipMask
|
|
213416
|
-
);
|
|
213417
|
-
}
|
|
213418
|
-
pos += step;
|
|
213419
|
-
dashDist = (dashDist + step) % dashCycle;
|
|
213420
|
-
}
|
|
213421
|
-
}
|
|
213422
|
-
}
|
|
213555
|
+
const edges2 = strokeEdges(path2, displayList.height, scale2);
|
|
213556
|
+
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;
|
|
213557
|
+
fillEdgesScanline4x4(
|
|
213558
|
+
rgba,
|
|
213559
|
+
width2,
|
|
213560
|
+
height,
|
|
213561
|
+
edges2,
|
|
213562
|
+
path2.strokeColor,
|
|
213563
|
+
strokeAlpha,
|
|
213564
|
+
"nonzero",
|
|
213565
|
+
clipScreen,
|
|
213566
|
+
original.kind === "glyph" ? aaTxt : aaVec,
|
|
213567
|
+
path2.blendMode,
|
|
213568
|
+
clipMask
|
|
213569
|
+
);
|
|
213423
213570
|
}
|
|
213424
213571
|
} else if (operation.kind === "image") {
|
|
213425
213572
|
const img = operation.value;
|
|
@@ -231805,15 +231952,27 @@ function compile(pattern, host) {
|
|
|
231805
231952
|
return value3;
|
|
231806
231953
|
};
|
|
231807
231954
|
const literal2 = (byte, mode) => node3({ kind: "char", byte, test: (input) => mode.insensitive ? fold2(input) === fold2(byte) : input === byte });
|
|
231955
|
+
const blanks = () => {
|
|
231956
|
+
while (pattern[at] === " " || pattern[at] === " ") {
|
|
231957
|
+
host.tick();
|
|
231958
|
+
at++;
|
|
231959
|
+
}
|
|
231960
|
+
};
|
|
231808
231961
|
const identifier = (closing) => {
|
|
231962
|
+
if (closing === "}")
|
|
231963
|
+
blanks();
|
|
231809
231964
|
let name = "";
|
|
231810
231965
|
while (at < pattern.length && pattern[at] !== closing) {
|
|
231966
|
+
if (closing === "}" && (pattern[at] === " " || pattern[at] === " "))
|
|
231967
|
+
break;
|
|
231811
231968
|
host.tick();
|
|
231812
231969
|
const byte = pattern.charCodeAt(at++);
|
|
231813
231970
|
if (!word2(byte) || !name && byte >= 48 && byte <= 57)
|
|
231814
231971
|
return unsupported8();
|
|
231815
231972
|
name += String.fromCharCode(byte);
|
|
231816
231973
|
}
|
|
231974
|
+
if (closing === "}")
|
|
231975
|
+
blanks();
|
|
231817
231976
|
if (!name || pattern[at++] !== closing)
|
|
231818
231977
|
return unsupported8();
|
|
231819
231978
|
return name;
|
|
@@ -231854,16 +232013,29 @@ function compile(pattern, host) {
|
|
|
231854
232013
|
if (!inClass && (char >= "1" && char <= "9" || char === "g")) {
|
|
231855
232014
|
let index3;
|
|
231856
232015
|
if (char === "g") {
|
|
231857
|
-
|
|
231858
|
-
|
|
231859
|
-
|
|
231860
|
-
|
|
232016
|
+
let end2;
|
|
232017
|
+
if (pattern[at] === "{") {
|
|
232018
|
+
end2 = ++at;
|
|
232019
|
+
while (end2 < pattern.length && pattern[end2] !== "}") {
|
|
232020
|
+
host.tick();
|
|
232021
|
+
end2++;
|
|
232022
|
+
}
|
|
232023
|
+
if (end2 === pattern.length)
|
|
232024
|
+
return unsupported8();
|
|
232025
|
+
blanks();
|
|
232026
|
+
if (pattern[at] !== "-" && !(pattern[at] >= "0" && pattern[at] <= "9"))
|
|
232027
|
+
return namedReference(identifier("}"), mode);
|
|
232028
|
+
}
|
|
231861
232029
|
const relative = pattern[at] === "-";
|
|
231862
232030
|
if (relative)
|
|
231863
232031
|
at++;
|
|
232032
|
+
if (!(pattern[at] >= "1" && pattern[at] <= "9"))
|
|
232033
|
+
return unsupported8();
|
|
231864
232034
|
const number5 = integer7();
|
|
231865
|
-
if (
|
|
232035
|
+
if (number5 >= 2147483647)
|
|
231866
232036
|
return unsupported8();
|
|
232037
|
+
if (end2 !== void 0)
|
|
232038
|
+
at = end2 + 1;
|
|
231867
232039
|
index3 = relative ? captures - number5 + 1 : number5;
|
|
231868
232040
|
} else {
|
|
231869
232041
|
index3 = Number(char);
|
|
@@ -232066,8 +232238,25 @@ function compile(pattern, host) {
|
|
|
232066
232238
|
let behind = false;
|
|
232067
232239
|
let atomic = false;
|
|
232068
232240
|
let resetCaptures = false;
|
|
232069
|
-
let capture = pattern[at] === "?" ? void 0 : ++captures;
|
|
232070
|
-
if (pattern[at] === "
|
|
232241
|
+
let capture = pattern[at] === "?" || pattern[at] === "*" ? void 0 : ++captures;
|
|
232242
|
+
if (pattern[at] === "*") {
|
|
232243
|
+
at++;
|
|
232244
|
+
const name = identifier(":");
|
|
232245
|
+
if (name === "atomic")
|
|
232246
|
+
atomic = true;
|
|
232247
|
+
else if (name === "pla" || name === "positive_lookahead")
|
|
232248
|
+
assertion = false;
|
|
232249
|
+
else if (name === "nla" || name === "negative_lookahead")
|
|
232250
|
+
assertion = true;
|
|
232251
|
+
else if (name === "plb" || name === "positive_lookbehind") {
|
|
232252
|
+
assertion = false;
|
|
232253
|
+
behind = true;
|
|
232254
|
+
} else if (name === "nlb" || name === "negative_lookbehind") {
|
|
232255
|
+
assertion = true;
|
|
232256
|
+
behind = true;
|
|
232257
|
+
} else
|
|
232258
|
+
return unsupported8();
|
|
232259
|
+
} else if (pattern[at] === "?") {
|
|
232071
232260
|
at++;
|
|
232072
232261
|
if (pattern[at] === ":")
|
|
232073
232262
|
at++;
|
|
@@ -232080,8 +232269,11 @@ function compile(pattern, host) {
|
|
|
232080
232269
|
} else if (pattern[at] === "(") {
|
|
232081
232270
|
at++;
|
|
232082
232271
|
let condition;
|
|
232083
|
-
if (pattern[at] === "?" && (pattern[at + 1] === "=" || pattern[at + 1] === "!" || pattern[at + 1] === "<" && (pattern[at + 2] === "=" || pattern[at + 2] === "!"))) {
|
|
232084
|
-
|
|
232272
|
+
if (pattern[at] === "*" || pattern[at] === "?" && (pattern[at + 1] === "=" || pattern[at + 1] === "!" || pattern[at + 1] === "<" && (pattern[at + 2] === "=" || pattern[at + 2] === "!"))) {
|
|
232273
|
+
const assertionNode = group({ ...mode });
|
|
232274
|
+
if (assertionNode.kind !== "assert" && assertionNode.kind !== "behind")
|
|
232275
|
+
return unsupported8();
|
|
232276
|
+
condition = { kind: "assertion", node: assertionNode };
|
|
232085
232277
|
} else {
|
|
232086
232278
|
const indices = [];
|
|
232087
232279
|
if (pattern[at] === "<" || pattern[at] === "'") {
|
|
@@ -234271,6 +234463,18 @@ export {
|
|
|
234271
234463
|
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
234272
234464
|
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
234273
234465
|
*/
|
|
234466
|
+
/*!
|
|
234467
|
+
* Anti-Grain Geometry - Version 2.3
|
|
234468
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
234469
|
+
*
|
|
234470
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
234471
|
+
* is granted provided this copyright notice appears in all copies.
|
|
234472
|
+
* This software is provided "as is" without express or implied
|
|
234473
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
234474
|
+
*
|
|
234475
|
+
* Adapted from PDFium agg_math_stroke.h and agg_vcgen_stroke.cpp.
|
|
234476
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
234477
|
+
*/
|
|
234274
234478
|
/*! Bundled license information:
|
|
234275
234479
|
|
|
234276
234480
|
tslib/tslib.js:
|