@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
|
@@ -34122,6 +34122,187 @@ function downscaleImage(image, widthScale, heightScale) {
|
|
|
34122
34122
|
return image;
|
|
34123
34123
|
}
|
|
34124
34124
|
|
|
34125
|
+
// packages/pdf-ast/src/render/stroke.ts
|
|
34126
|
+
init_buffer();
|
|
34127
|
+
var MAX_STROKE_VERTICES = 1e6;
|
|
34128
|
+
function dashSubpath(path, pattern, phase) {
|
|
34129
|
+
const cycle = pattern.reduce((sum, value) => sum + value, 0);
|
|
34130
|
+
if (!(cycle > 0)) return [path];
|
|
34131
|
+
let offset = (phase % cycle + cycle) % cycle, index = 0;
|
|
34132
|
+
while (offset > 0) {
|
|
34133
|
+
if (offset < pattern[index]) break;
|
|
34134
|
+
offset -= pattern[index];
|
|
34135
|
+
index = (index + 1) % pattern.length;
|
|
34136
|
+
}
|
|
34137
|
+
let remaining = pattern[index] - offset;
|
|
34138
|
+
const points = path.closed ? [...path.points, path.points[0]] : path.points;
|
|
34139
|
+
const result = [];
|
|
34140
|
+
let current = [];
|
|
34141
|
+
let steps = 0;
|
|
34142
|
+
const flush = () => {
|
|
34143
|
+
if (current.length) result.push({ points: current, closed: false });
|
|
34144
|
+
current = [];
|
|
34145
|
+
};
|
|
34146
|
+
const advance = (point) => {
|
|
34147
|
+
while (remaining <= 0) {
|
|
34148
|
+
if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
34149
|
+
if (index % 2 === 0) {
|
|
34150
|
+
if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
|
|
34151
|
+
flush();
|
|
34152
|
+
}
|
|
34153
|
+
index = (index + 1) % pattern.length;
|
|
34154
|
+
remaining = pattern[index];
|
|
34155
|
+
}
|
|
34156
|
+
};
|
|
34157
|
+
for (let i = 1; i < points.length; i++) {
|
|
34158
|
+
const start = points[i - 1], end = points[i];
|
|
34159
|
+
const dx = end[0] - start[0], dy = end[1] - start[1];
|
|
34160
|
+
const length = Math.hypot(dx, dy);
|
|
34161
|
+
if (!Number.isFinite(length) || length / cycle * pattern.length > MAX_STROKE_VERTICES) {
|
|
34162
|
+
throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
34163
|
+
}
|
|
34164
|
+
let distance = 0;
|
|
34165
|
+
while (distance < length) {
|
|
34166
|
+
const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
|
|
34167
|
+
advance(point);
|
|
34168
|
+
const step = Math.min(remaining, length - distance);
|
|
34169
|
+
if (distance + step === distance || ++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
|
|
34170
|
+
distance += step;
|
|
34171
|
+
remaining -= step;
|
|
34172
|
+
if (index % 2 === 0) {
|
|
34173
|
+
if (!current.length) current.push(point);
|
|
34174
|
+
current.push([start[0] + dx * distance / length, start[1] + dy * distance / length]);
|
|
34175
|
+
}
|
|
34176
|
+
}
|
|
34177
|
+
}
|
|
34178
|
+
flush();
|
|
34179
|
+
if (path.closed && result.length) {
|
|
34180
|
+
const first = result[0], last = result[result.length - 1];
|
|
34181
|
+
const start = path.points[0];
|
|
34182
|
+
const firstPoint = first.points[0], lastPoint = last.points[last.points.length - 1];
|
|
34183
|
+
if (firstPoint[0] === start[0] && firstPoint[1] === start[1] && lastPoint[0] === start[0] && lastPoint[1] === start[1]) {
|
|
34184
|
+
if (first === last) result[0] = { points: first.points, closed: true };
|
|
34185
|
+
else {
|
|
34186
|
+
result[0] = { points: [...last.points, ...first.points.slice(1)], closed: false };
|
|
34187
|
+
result.pop();
|
|
34188
|
+
}
|
|
34189
|
+
}
|
|
34190
|
+
}
|
|
34191
|
+
return result;
|
|
34192
|
+
}
|
|
34193
|
+
function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], dashPhase = 0) {
|
|
34194
|
+
const half = width / 2;
|
|
34195
|
+
const contours = [];
|
|
34196
|
+
const pattern = dashArray.length % 2 ? [...dashArray, ...dashArray] : dashArray;
|
|
34197
|
+
let count = 0;
|
|
34198
|
+
let contour = [];
|
|
34199
|
+
const add = (x, y) => {
|
|
34200
|
+
if (++count > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke outline exceeds the vertex limit");
|
|
34201
|
+
contour.push([x, y]);
|
|
34202
|
+
};
|
|
34203
|
+
const arc = (point, dx1, dy1, dx2, dy2) => {
|
|
34204
|
+
let a1 = Math.atan2(dy1, dx1), a2 = Math.atan2(dy2, dx2);
|
|
34205
|
+
const ccw = a1 - a2 > 0 && a1 - a2 < Math.PI;
|
|
34206
|
+
const step = Math.acos(half / (half + 0.125)) * 2;
|
|
34207
|
+
add(point[0] + dx1, point[1] + dy1);
|
|
34208
|
+
if (step > 0) {
|
|
34209
|
+
if (!ccw) {
|
|
34210
|
+
if (a1 > a2) a2 += 2 * Math.PI;
|
|
34211
|
+
a2 -= step / 4;
|
|
34212
|
+
if ((a2 - a1) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
34213
|
+
for (a1 += step; a1 < a2; a1 += step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
34214
|
+
} else {
|
|
34215
|
+
if (a1 < a2) a2 -= 2 * Math.PI;
|
|
34216
|
+
a2 += step / 4;
|
|
34217
|
+
if ((a1 - a2) / step > MAX_STROKE_VERTICES - count) throw new PdfError("E_LIMIT", "Stroke arc exceeds the vertex limit");
|
|
34218
|
+
for (a1 -= step; a1 > a2; a1 -= step) add(point[0] + half * Math.cos(a1), point[1] + half * Math.sin(a1));
|
|
34219
|
+
}
|
|
34220
|
+
}
|
|
34221
|
+
add(point[0] + dx2, point[1] + dy2);
|
|
34222
|
+
};
|
|
34223
|
+
const addCap = (point, next) => {
|
|
34224
|
+
const length = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
34225
|
+
const dx = half * (next[1] - point[1]) / length;
|
|
34226
|
+
const dy = half * (next[0] - point[0]) / length;
|
|
34227
|
+
if (cap !== 1) {
|
|
34228
|
+
const sx = cap === 2 ? dy : 0, sy = cap === 2 ? dx : 0;
|
|
34229
|
+
add(point[0] - dx - sx, point[1] + dy - sy);
|
|
34230
|
+
add(point[0] + dx - sx, point[1] - dy - sy);
|
|
34231
|
+
} else {
|
|
34232
|
+
const angle = Math.atan2(dy, -dx);
|
|
34233
|
+
const step = Math.max(1e-3, Math.acos(half / (half + 0.125)) * 2);
|
|
34234
|
+
add(point[0] - dx, point[1] + dy);
|
|
34235
|
+
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));
|
|
34236
|
+
add(point[0] + dx, point[1] - dy);
|
|
34237
|
+
}
|
|
34238
|
+
};
|
|
34239
|
+
const addJoin = (prev, point, next) => {
|
|
34240
|
+
const len1 = Math.hypot(point[0] - prev[0], point[1] - prev[1]);
|
|
34241
|
+
const len2 = Math.hypot(next[0] - point[0], next[1] - point[1]);
|
|
34242
|
+
const dx1 = half * (point[1] - prev[1]) / len1, dy1 = half * (point[0] - prev[0]) / len1;
|
|
34243
|
+
const dx2 = half * (next[1] - point[1]) / len2, dy2 = half * (next[0] - point[0]) / len2;
|
|
34244
|
+
const inner = (next[0] - point[0]) * (point[1] - prev[1]) - (next[1] - point[1]) * (point[0] - prev[0]) > 0;
|
|
34245
|
+
if (!inner && join === 1) {
|
|
34246
|
+
arc(point, dx1, -dy1, dx2, -dy2);
|
|
34247
|
+
return;
|
|
34248
|
+
}
|
|
34249
|
+
if (inner || join === 0) {
|
|
34250
|
+
const ax = prev[0] + dx1, ay = prev[1] - dy1;
|
|
34251
|
+
const bx = point[0] + dx1, by = point[1] - dy1;
|
|
34252
|
+
const cx = point[0] + dx2, cy = point[1] - dy2;
|
|
34253
|
+
const dx = next[0] + dx2, dy = next[1] - dy2;
|
|
34254
|
+
const den = (bx - ax) * (dy - cy) - (by - ay) * (dx - cx);
|
|
34255
|
+
if (Math.abs(den) >= 1e-30) {
|
|
34256
|
+
const t = ((ay - cy) * (dx - cx) - (ax - cx) * (dy - cy)) / den;
|
|
34257
|
+
const x = ax + (bx - ax) * t, y = ay + (by - ay) * t;
|
|
34258
|
+
if (Math.hypot(x - point[0], y - point[1]) <= half * (inner ? 1.01 : miterLimit)) {
|
|
34259
|
+
add(x, y);
|
|
34260
|
+
return;
|
|
34261
|
+
}
|
|
34262
|
+
} else if ((bx - prev[0]) * dy1 - (prev[1] - by) * dx1 < 0 !== (bx - next[0]) * dy1 - (next[1] - by) * dx1 < 0) {
|
|
34263
|
+
add(bx, by);
|
|
34264
|
+
return;
|
|
34265
|
+
}
|
|
34266
|
+
}
|
|
34267
|
+
add(point[0] + dx1, point[1] - dy1);
|
|
34268
|
+
add(point[0] + dx2, point[1] - dy2);
|
|
34269
|
+
};
|
|
34270
|
+
for (const path of paths) {
|
|
34271
|
+
for (const subpath of pattern.length ? dashSubpath(path, pattern, dashPhase) : [path]) {
|
|
34272
|
+
const points = [];
|
|
34273
|
+
for (const point of subpath.points) {
|
|
34274
|
+
const prev = points[points.length - 1];
|
|
34275
|
+
if (!prev || Math.hypot(prev[0] - point[0], prev[1] - point[1]) > 1e-14) points.push(point);
|
|
34276
|
+
}
|
|
34277
|
+
let closed = subpath.closed;
|
|
34278
|
+
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();
|
|
34279
|
+
if (points.length < 3) closed = false;
|
|
34280
|
+
if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
|
|
34281
|
+
contour = [];
|
|
34282
|
+
const [x, y] = points[0];
|
|
34283
|
+
addCap([x, y], [x + 1, y]);
|
|
34284
|
+
addCap([x, y], [x - 1, y]);
|
|
34285
|
+
contours.push(contour);
|
|
34286
|
+
} else if (points.length >= 2) {
|
|
34287
|
+
contour = [];
|
|
34288
|
+
if (!closed) addCap(points[0], points[1]);
|
|
34289
|
+
for (let i = closed ? 0 : 1; i < points.length - (closed ? 0 : 1); i++) {
|
|
34290
|
+
addJoin(points[(i + points.length - 1) % points.length], points[i], points[(i + 1) % points.length]);
|
|
34291
|
+
}
|
|
34292
|
+
if (closed) {
|
|
34293
|
+
contours.push(contour);
|
|
34294
|
+
contour = [];
|
|
34295
|
+
} else addCap(points[points.length - 1], points[points.length - 2]);
|
|
34296
|
+
for (let i = points.length - (closed ? 1 : 2); i >= (closed ? 0 : 1); i--) {
|
|
34297
|
+
addJoin(points[(i + 1) % points.length], points[i], points[(i + points.length - 1) % points.length]);
|
|
34298
|
+
}
|
|
34299
|
+
contours.push(contour);
|
|
34300
|
+
}
|
|
34301
|
+
}
|
|
34302
|
+
}
|
|
34303
|
+
return contours;
|
|
34304
|
+
}
|
|
34305
|
+
|
|
34125
34306
|
// packages/pdf-ast/src/render/raster.ts
|
|
34126
34307
|
function encodePng(bitmap) {
|
|
34127
34308
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
@@ -34820,111 +35001,60 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
|
|
|
34820
35001
|
rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
|
|
34821
35002
|
rgba[idx + 3] = Math.round(outA * 255);
|
|
34822
35003
|
}
|
|
34823
|
-
function
|
|
34824
|
-
const
|
|
34825
|
-
|
|
34826
|
-
|
|
34827
|
-
const lenSq = dx * dx + dy * dy;
|
|
34828
|
-
const segLen = Math.sqrt(lenSq);
|
|
34829
|
-
const pad = lineCap === 2 ? halfW + 2 : halfW + 1;
|
|
34830
|
-
const minX = Math.max(0, Math.floor(Math.min(x0, x1) - pad));
|
|
34831
|
-
const maxX = Math.min(width - 1, Math.ceil(Math.max(x0, x1) + pad));
|
|
34832
|
-
const minY = Math.max(0, Math.floor(Math.min(y0, y1) - pad));
|
|
34833
|
-
const maxY = Math.min(height - 1, Math.ceil(Math.max(y0, y1) + pad));
|
|
34834
|
-
for (let py = minY; py <= maxY; py++) {
|
|
34835
|
-
for (let px = minX; px <= maxX; px++) {
|
|
34836
|
-
const cx = px + 0.5;
|
|
34837
|
-
const cy = py + 0.5;
|
|
34838
|
-
if (segLen > 1e-6 && (lineCap === 0 || lineCap === 2)) {
|
|
34839
|
-
const ux = dx / segLen;
|
|
34840
|
-
const uy = dy / segLen;
|
|
34841
|
-
const along = (cx - x0) * ux + (cy - y0) * uy;
|
|
34842
|
-
const perp = Math.abs(-(cx - x0) * uy + (cy - y0) * ux);
|
|
34843
|
-
const minAlong = lineCap === 2 ? -halfW : 0;
|
|
34844
|
-
const maxAlong = lineCap === 2 ? segLen + halfW : segLen;
|
|
34845
|
-
const overAlong = along < minAlong ? minAlong - along : along > maxAlong ? along - maxAlong : 0;
|
|
34846
|
-
const dist2 = overAlong > 0 ? Math.max(perp, halfW + overAlong) : perp;
|
|
34847
|
-
if (dist2 <= halfW + 0.75) {
|
|
34848
|
-
const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist2)) : dist2 <= halfW + 0.25 ? 1 : 0;
|
|
34849
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
34850
|
-
}
|
|
34851
|
-
continue;
|
|
34852
|
-
}
|
|
34853
|
-
let t = lenSq > 1e-6 ? ((cx - x0) * dx + (cy - y0) * dy) / lenSq : 0;
|
|
34854
|
-
t = Math.max(0, Math.min(1, t));
|
|
34855
|
-
const projX = x0 + t * dx;
|
|
34856
|
-
const projY = y0 + t * dy;
|
|
34857
|
-
const dist = Math.hypot(cx - projX, cy - projY);
|
|
34858
|
-
if (dist <= halfW + 0.75) {
|
|
34859
|
-
const cov = antialias ? Math.max(0, Math.min(1, halfW + 0.5 - dist)) : dist <= halfW + 0.25 ? 1 : 0;
|
|
34860
|
-
blendPixel(rgba, width, height, px, py, color, cov * alpha, blendMode, clipMask);
|
|
34861
|
-
}
|
|
34862
|
-
}
|
|
34863
|
-
}
|
|
34864
|
-
}
|
|
34865
|
-
function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = false) {
|
|
34866
|
-
const edges = [];
|
|
34867
|
-
let curX = 0;
|
|
34868
|
-
let curY = 0;
|
|
34869
|
-
let startX = 0;
|
|
34870
|
-
let startY = 0;
|
|
34871
|
-
let hasOpenSubpath = false;
|
|
35004
|
+
function segmentsToScreenPaths(segments, pageHeight, scale) {
|
|
35005
|
+
const paths = [];
|
|
35006
|
+
let points = [];
|
|
35007
|
+
let current = [0, 0];
|
|
34872
35008
|
const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
|
|
34873
|
-
for (const
|
|
34874
|
-
if (
|
|
34875
|
-
if (
|
|
34876
|
-
|
|
34877
|
-
|
|
34878
|
-
|
|
34879
|
-
|
|
34880
|
-
|
|
34881
|
-
|
|
34882
|
-
} else if (
|
|
34883
|
-
|
|
34884
|
-
|
|
34885
|
-
|
|
34886
|
-
|
|
34887
|
-
|
|
34888
|
-
|
|
34889
|
-
|
|
34890
|
-
|
|
34891
|
-
|
|
34892
|
-
|
|
34893
|
-
|
|
34894
|
-
|
|
34895
|
-
|
|
34896
|
-
|
|
34897
|
-
|
|
34898
|
-
|
|
34899
|
-
|
|
34900
|
-
|
|
34901
|
-
|
|
34902
|
-
|
|
34903
|
-
|
|
34904
|
-
|
|
34905
|
-
|
|
34906
|
-
|
|
34907
|
-
|
|
34908
|
-
|
|
34909
|
-
|
|
34910
|
-
|
|
34911
|
-
|
|
34912
|
-
|
|
34913
|
-
|
|
34914
|
-
|
|
34915
|
-
const [
|
|
34916
|
-
|
|
34917
|
-
|
|
34918
|
-
|
|
34919
|
-
|
|
34920
|
-
|
|
34921
|
-
{ x0: rx0, y0: ry1, x1: rx0, y1: ry0 }
|
|
34922
|
-
);
|
|
34923
|
-
hasOpenSubpath = false;
|
|
35009
|
+
for (const segment of segments) {
|
|
35010
|
+
if (segment.kind === "move") {
|
|
35011
|
+
if (points.length) paths.push({ points, closed: false });
|
|
35012
|
+
current = toScreen(segment.x, segment.y);
|
|
35013
|
+
points = [current];
|
|
35014
|
+
} else if (segment.kind === "line") {
|
|
35015
|
+
if (!points.length) points = [current];
|
|
35016
|
+
current = toScreen(segment.x, segment.y);
|
|
35017
|
+
points.push(current);
|
|
35018
|
+
} else if (segment.kind === "cubic") {
|
|
35019
|
+
if (!points.length) points = [current];
|
|
35020
|
+
const a = toScreen(segment.x1, segment.y1), b = toScreen(segment.x2, segment.y2);
|
|
35021
|
+
const end = toScreen(segment.x, segment.y);
|
|
35022
|
+
const curve = flattenCubic(current[0], current[1], a[0], a[1], b[0], b[1], end[0], end[1]);
|
|
35023
|
+
for (let i = 1; i < curve.length; i++) points.push(curve[i]);
|
|
35024
|
+
current = end;
|
|
35025
|
+
} else if (segment.kind === "close") {
|
|
35026
|
+
if (points.length) {
|
|
35027
|
+
paths.push({ points, closed: true });
|
|
35028
|
+
current = points[0];
|
|
35029
|
+
points = [];
|
|
35030
|
+
}
|
|
35031
|
+
} else if (segment.kind === "rect") {
|
|
35032
|
+
if (points.length) paths.push({ points, closed: false });
|
|
35033
|
+
const first = toScreen(segment.x, segment.y);
|
|
35034
|
+
paths.push({ points: [
|
|
35035
|
+
first,
|
|
35036
|
+
toScreen(segment.x + segment.width, segment.y),
|
|
35037
|
+
toScreen(segment.x + segment.width, segment.y + segment.height),
|
|
35038
|
+
toScreen(segment.x, segment.y + segment.height)
|
|
35039
|
+
], closed: true });
|
|
35040
|
+
current = first;
|
|
35041
|
+
points = [];
|
|
35042
|
+
}
|
|
35043
|
+
}
|
|
35044
|
+
if (points.length) paths.push({ points, closed: false });
|
|
35045
|
+
return paths;
|
|
35046
|
+
}
|
|
35047
|
+
function pathsToEdges(paths, closeSubpaths = false) {
|
|
35048
|
+
const edges = [];
|
|
35049
|
+
for (const { points, closed } of paths) {
|
|
35050
|
+
for (let i = 1; i < points.length; i++) {
|
|
35051
|
+
const a = points[i - 1], b = points[i];
|
|
35052
|
+
edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
|
|
35053
|
+
}
|
|
35054
|
+
if ((closed || closeSubpaths) && points.length > 1) {
|
|
35055
|
+
const a = points[points.length - 1], b = points[0];
|
|
35056
|
+
edges.push({ x0: a[0], y0: a[1], x1: b[0], y1: b[1] });
|
|
34924
35057
|
}
|
|
34925
|
-
}
|
|
34926
|
-
if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
|
|
34927
|
-
edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
|
|
34928
35058
|
}
|
|
34929
35059
|
return edges;
|
|
34930
35060
|
}
|
|
@@ -35111,7 +35241,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
35111
35241
|
for (const clip of clips) {
|
|
35112
35242
|
const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
|
|
35113
35243
|
const layer = new Uint8Array(width * height * 4);
|
|
35114
|
-
fillEdgesScanline4x4(layer, width, height,
|
|
35244
|
+
fillEdgesScanline4x4(layer, width, height, pathsToEdges(segmentsToScreenPaths(segments, displayList.height, scale), true), { r: 1, g: 1, b: 1 }, 1, fillRule);
|
|
35115
35245
|
for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
|
|
35116
35246
|
}
|
|
35117
35247
|
cachedClips = clips;
|
|
@@ -35158,62 +35288,38 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
35158
35288
|
if (operation.kind === "path") {
|
|
35159
35289
|
const path = operation.value;
|
|
35160
35290
|
if (path.fillColor) {
|
|
35161
|
-
const edges =
|
|
35291
|
+
const edges = pathsToEdges(segmentsToScreenPaths(path.segments, displayList.height, scale), true);
|
|
35162
35292
|
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;
|
|
35163
35293
|
fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
|
|
35164
35294
|
}
|
|
35165
35295
|
if (path.strokeColor) {
|
|
35166
|
-
const edges = segmentsToScreenEdges(path.segments, displayList.height, scale, false);
|
|
35167
35296
|
const rawSw = path.strokeWidth * scale;
|
|
35168
35297
|
const sw = Math.max(1, rawSw);
|
|
35169
35298
|
const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
|
|
35170
|
-
const
|
|
35171
|
-
|
|
35172
|
-
|
|
35173
|
-
|
|
35174
|
-
|
|
35175
|
-
|
|
35176
|
-
|
|
35177
|
-
|
|
35178
|
-
|
|
35179
|
-
|
|
35180
|
-
|
|
35181
|
-
|
|
35182
|
-
|
|
35183
|
-
|
|
35184
|
-
|
|
35185
|
-
|
|
35186
|
-
|
|
35187
|
-
|
|
35188
|
-
|
|
35189
|
-
|
|
35190
|
-
|
|
35191
|
-
|
|
35192
|
-
|
|
35193
|
-
|
|
35194
|
-
const t1 = (pos + step) / edgeLen;
|
|
35195
|
-
drawAntiAliasedSegment(
|
|
35196
|
-
rgba,
|
|
35197
|
-
width,
|
|
35198
|
-
height,
|
|
35199
|
-
e.x0 + dx * t0,
|
|
35200
|
-
e.y0 + dy * t0,
|
|
35201
|
-
e.x0 + dx * t1,
|
|
35202
|
-
e.y0 + dy * t1,
|
|
35203
|
-
sw,
|
|
35204
|
-
path.strokeColor,
|
|
35205
|
-
strokeAlpha,
|
|
35206
|
-
path.lineCap ?? 0,
|
|
35207
|
-
original.kind === "glyph" ? aaTxt : aaVec,
|
|
35208
|
-
path.blendMode,
|
|
35209
|
-
clipMask
|
|
35210
|
-
);
|
|
35211
|
-
}
|
|
35212
|
-
pos += step;
|
|
35213
|
-
dashDist = (dashDist + step) % dashCycle;
|
|
35214
|
-
}
|
|
35215
|
-
}
|
|
35216
|
-
}
|
|
35299
|
+
const contours = strokeOutlines(
|
|
35300
|
+
segmentsToScreenPaths(path.segments, displayList.height, scale),
|
|
35301
|
+
sw,
|
|
35302
|
+
path.lineCap ?? 0,
|
|
35303
|
+
path.lineJoin ?? 0,
|
|
35304
|
+
path.miterLimit ?? 10,
|
|
35305
|
+
path.dashArray?.map((value) => Math.max(0, value * scale)),
|
|
35306
|
+
(path.dashPhase ?? 0) * scale
|
|
35307
|
+
);
|
|
35308
|
+
const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
|
|
35309
|
+
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;
|
|
35310
|
+
fillEdgesScanline4x4(
|
|
35311
|
+
rgba,
|
|
35312
|
+
width,
|
|
35313
|
+
height,
|
|
35314
|
+
edges,
|
|
35315
|
+
path.strokeColor,
|
|
35316
|
+
strokeAlpha,
|
|
35317
|
+
"nonzero",
|
|
35318
|
+
clipScreen,
|
|
35319
|
+
original.kind === "glyph" ? aaTxt : aaVec,
|
|
35320
|
+
path.blendMode,
|
|
35321
|
+
clipMask
|
|
35322
|
+
);
|
|
35217
35323
|
}
|
|
35218
35324
|
} else if (operation.kind === "image") {
|
|
35219
35325
|
const img = operation.value;
|
|
@@ -37474,3 +37580,15 @@ export {
|
|
|
37474
37580
|
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
37475
37581
|
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
37476
37582
|
*/
|
|
37583
|
+
/*!
|
|
37584
|
+
* Anti-Grain Geometry - Version 2.3
|
|
37585
|
+
* Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
|
37586
|
+
*
|
|
37587
|
+
* Permission to copy, use, modify, sell and distribute this software
|
|
37588
|
+
* is granted provided this copyright notice appears in all copies.
|
|
37589
|
+
* This software is provided "as is" without express or implied
|
|
37590
|
+
* warranty, and with no claim as to its suitability for any purpose.
|
|
37591
|
+
*
|
|
37592
|
+
* Adapted from PDFium agg_math_stroke.h and agg_vcgen_stroke.cpp.
|
|
37593
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
37594
|
+
*/
|
|
@@ -7,6 +7,7 @@ import asyncio
|
|
|
7
7
|
import copy
|
|
8
8
|
import inspect
|
|
9
9
|
import math
|
|
10
|
+
import os
|
|
10
11
|
from dataclasses import dataclass, field, replace
|
|
11
12
|
from typing import Any, AsyncIterator, Callable, Mapping, Optional, Protocol, Sequence, Union
|
|
12
13
|
|
|
@@ -49,7 +50,8 @@ class Attachment:
|
|
|
49
50
|
def payload(self):
|
|
50
51
|
if not isinstance(self.path, str) or not self.path or "\0" in self.path:
|
|
51
52
|
raise ValueError("Attachment requires an agent filesystem path")
|
|
52
|
-
|
|
53
|
+
path = self.path if os.path.isabs(self.path) else os.path.join(os.getcwd(), self.path)
|
|
54
|
+
result = {"path": path}
|
|
53
55
|
if self.mime_type is not None:
|
|
54
56
|
result["mimeType"] = self.mime_type
|
|
55
57
|
return result
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import asyncio
|
|
5
5
|
import math
|
|
6
6
|
import inspect
|
|
7
|
+
import os
|
|
7
8
|
import subprocess
|
|
8
9
|
from dataclasses import dataclass
|
|
9
10
|
|
|
@@ -59,6 +60,12 @@ def _payload(args, *, shell=False, input=None, cwd=None, env=None, timeout=None,
|
|
|
59
60
|
elif not isinstance(input, (bytes, bytearray, memoryview)):
|
|
60
61
|
raise TypeError('Binary input must be bytes')
|
|
61
62
|
result['input'] = list(input)
|
|
63
|
+
# The host retains the original shell context; snapshot the current guest state.
|
|
64
|
+
if cwd is None:
|
|
65
|
+
cwd = os.getcwd()
|
|
66
|
+
elif cwd and not os.path.isabs(cwd):
|
|
67
|
+
cwd = os.path.join(os.getcwd(), cwd)
|
|
68
|
+
env = dict(os.environ if env is None else env)
|
|
62
69
|
result.update(cwd=cwd, env=env, timeout=timeout, max_output_bytes=max_output_bytes)
|
|
63
70
|
return result
|
|
64
71
|
|
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
sha256,
|
|
159
159
|
sha384,
|
|
160
160
|
sha512
|
|
161
|
-
} from "./chunks/chunk-
|
|
161
|
+
} from "./chunks/chunk-FSH7QRIC.js";
|
|
162
162
|
import {
|
|
163
163
|
PythonFailure,
|
|
164
164
|
inspectPythonCapabilities
|
|
@@ -85450,6 +85450,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
85450
85450
|
let inc = 1;
|
|
85451
85451
|
let noRenumber = false;
|
|
85452
85452
|
let joinBlanks = 1;
|
|
85453
|
+
let hasFileOperand = false;
|
|
85453
85454
|
const parseSecSpec = (v) => {
|
|
85454
85455
|
if (v === "a" || v === "t" || v === "n") return { style: v };
|
|
85455
85456
|
if (v.startsWith("p") && v.length > 1) {
|
|
@@ -85542,9 +85543,11 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
85542
85543
|
} else if (/^-i-?[0-9]{1,9}$/.test(a)) {
|
|
85543
85544
|
inc = Number(a.slice(2));
|
|
85544
85545
|
} else if (!a.startsWith("-")) {
|
|
85545
|
-
if (cwd === void 0) return
|
|
85546
|
+
if (cwd === void 0) return void 0;
|
|
85546
85547
|
const fl = this.readSyncMemoryLines(resolvePath(cwd, a));
|
|
85547
85548
|
if (!fl) return void 0;
|
|
85549
|
+
if (!hasFileOperand) rawLines = [];
|
|
85550
|
+
hasFileOperand = true;
|
|
85548
85551
|
rawLines = [...rawLines, ...fl];
|
|
85549
85552
|
} else {
|
|
85550
85553
|
return void 0;
|
|
@@ -87258,11 +87261,11 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87258
87261
|
if (cmdName === "whoami") {
|
|
87259
87262
|
if (opArgs.length !== 0 || this.tryReadMemoryFileViewSync("/etc/passwd", false) !== void 0) return void 0;
|
|
87260
87263
|
if (getEnv("ID_EUID") !== void 0 || getEnv("EUID") !== void 0 || getEnv("ID_UID") !== void 0 || getEnv("UID") !== void 0) return void 0;
|
|
87261
|
-
return getEnv("
|
|
87264
|
+
return getEnv("WHOAMI") ?? getEnv("USER") ?? getEnv("LOGNAME") ?? "sandbox";
|
|
87262
87265
|
}
|
|
87263
87266
|
if (cmdName === "id") {
|
|
87264
87267
|
if (this.tryReadMemoryFileViewSync("/etc/passwd", false) !== void 0 || this.tryReadMemoryFileViewSync("/etc/group", false) !== void 0) return void 0;
|
|
87265
|
-
for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "
|
|
87268
|
+
for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "GROUP", "ID_GROUPS", "SELINUX_CONTEXT"]) {
|
|
87266
87269
|
if (getEnv(k) !== void 0) return void 0;
|
|
87267
87270
|
}
|
|
87268
87271
|
if (opArgs.length === 0) return "uid=1000(sandbox) gid=1000(sandbox) groups=1000(sandbox)";
|
|
@@ -87275,10 +87278,12 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87275
87278
|
}
|
|
87276
87279
|
if (cmdName === "hostname") {
|
|
87277
87280
|
if (this.tryReadMemoryFileViewSync("/etc/hostname", false) !== void 0 || getEnv("HOSTNAME_DOMAIN") !== void 0 || getEnv("HOSTNAME_IP") !== void 0) return void 0;
|
|
87278
|
-
const host2 = getEnv("HOSTNAME")
|
|
87279
|
-
if (opArgs.length === 0
|
|
87281
|
+
const host2 = getEnv("HOSTNAME") || "sandbox";
|
|
87282
|
+
if (opArgs.length === 0) return host2;
|
|
87283
|
+
if (opArgs.length === 1 && (opArgs[0] === "-f" || opArgs[0] === "--fqdn" || opArgs[0] === "--long")) return host2.includes(".") ? host2 : `${host2}.vfs.local`;
|
|
87280
87284
|
if (opArgs.length === 1 && (opArgs[0] === "-s" || opArgs[0] === "--short")) return host2.split(".")[0];
|
|
87281
|
-
if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address"
|
|
87285
|
+
if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address")) return "127.0.0.1";
|
|
87286
|
+
if (opArgs.length === 1 && (opArgs[0] === "-I" || opArgs[0] === "--all-ip-addresses")) return "127.0.0.1 ";
|
|
87282
87287
|
return void 0;
|
|
87283
87288
|
}
|
|
87284
87289
|
if (cmdName === "nproc") {
|
|
@@ -87460,6 +87465,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87460
87465
|
if (operands.length > 0) {
|
|
87461
87466
|
for (const op of operands) tokens.push(op);
|
|
87462
87467
|
} else {
|
|
87468
|
+
if (rawLines === void 0) return void 0;
|
|
87463
87469
|
for (const line of rawLines) {
|
|
87464
87470
|
for (const t of line.split(/[ \t\r\n\f\v]+/)) {
|
|
87465
87471
|
if (t.length > 0) tokens.push(t);
|
|
@@ -87524,6 +87530,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87524
87530
|
if (memLines === void 0) return void 0;
|
|
87525
87531
|
linesToRead = memLines;
|
|
87526
87532
|
}
|
|
87533
|
+
if (linesToRead === void 0) return void 0;
|
|
87527
87534
|
const tokens = [];
|
|
87528
87535
|
for (const line of linesToRead) {
|
|
87529
87536
|
for (const t of line.split(/[ \t\r\n\f\v]+/)) {
|
|
@@ -87604,6 +87611,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87604
87611
|
const vars = extractVars(operands[0]);
|
|
87605
87612
|
return vars.length > 0 ? vars.join("\n") + "\n" : "";
|
|
87606
87613
|
}
|
|
87614
|
+
if (inStr === void 0) return void 0;
|
|
87607
87615
|
const allowedVars = operands.length === 1 ? new Set(extractVars(operands[0])) : void 0;
|
|
87608
87616
|
const raw = stateMonitor(rawState)?.raw ?? rawState;
|
|
87609
87617
|
const isRestrictedEnv = raw._exported === void 0 && "_exported" in raw;
|
|
@@ -88805,7 +88813,18 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
88805
88813
|
const list = part.script.lists[0];
|
|
88806
88814
|
if (list.terminator || list.pipelines.length !== 1) return void 0;
|
|
88807
88815
|
const pipeline = list.pipelines[0];
|
|
88808
|
-
if (pipeline.negate) return void 0;
|
|
88816
|
+
if (pipeline.negate || customRegisteredRegistries.has(this.commands)) return void 0;
|
|
88817
|
+
for (const command4 of pipeline.commands) {
|
|
88818
|
+
if (command4.kind !== "simple") continue;
|
|
88819
|
+
const name2 = command4.words[0]?.plain;
|
|
88820
|
+
if (!name2) continue;
|
|
88821
|
+
if (name2 === "fmt" && command4 === pipeline.commands[0] && command4.redirects.length === 0 && !io.stdinIsDefault) return void 0;
|
|
88822
|
+
const definition2 = this.getExternalCommand(name2);
|
|
88823
|
+
if (definition2 && customRegisteredCommands.has(definition2.execute)) return void 0;
|
|
88824
|
+
if (name2 === "uname" || name2 === "nproc" || name2 === "hostname" || name2 === "id" || name2 === "whoami") {
|
|
88825
|
+
if (!definition2 || !internal_exports.builtInDirectContextExecutors.has(definition2.execute)) return void 0;
|
|
88826
|
+
}
|
|
88827
|
+
}
|
|
88809
88828
|
if (pipeline.commands.length >= 2 && pipeline.commands.length <= 5) {
|
|
88810
88829
|
if (syncPurePipelineSlotInUse || !this.budget.canSyncPurePipe || (0, yield_exports.hasYieldCheckpoint)(this.signal) || rawState.errexit || rawState.nounset || this.budget.commands + pipeline.commands.length > this.budget.limits.maxCommands) {
|
|
88811
88830
|
return void 0;
|
|
@@ -89790,7 +89809,8 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
89790
89809
|
if (cmd.kind !== "simple" || cmd.redirects.length > 0 && !hasSingleStdinRedir && !hasSingleHereStringRedir || cmd.words.length === 0) return void 0;
|
|
89791
89810
|
let w0Plain = cmd.words[0].plain;
|
|
89792
89811
|
if (!w0Plain || rawState.extensions?.builtins.has(w0Plain)) return void 0;
|
|
89793
|
-
if (w0Plain === "
|
|
89812
|
+
if (w0Plain === "fmt" && !hasSingleStdinRedir && !hasSingleHereStringRedir && !io.stdinIsDefault) return void 0;
|
|
89813
|
+
if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod" || w0Plain === "uname" || w0Plain === "nproc" || w0Plain === "hostname" || w0Plain === "id" || w0Plain === "whoami") {
|
|
89794
89814
|
const definition2 = this.getExternalCommand(w0Plain);
|
|
89795
89815
|
if (!definition2 || !internal_exports.builtInDirectContextExecutors.has(definition2.execute)) return void 0;
|
|
89796
89816
|
}
|
|
@@ -90432,11 +90452,11 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
90432
90452
|
if (w0Plain === "comm") cjLines = this.evalSyncComm(stdinLines, allArgs, rawState.cwd);
|
|
90433
90453
|
else if (w0Plain === "join") cjLines = this.evalSyncJoin(stdinLines, allArgs, rawState.cwd);
|
|
90434
90454
|
else if (w0Plain === "paste") cjLines = this.evalSyncPaste(stdinLines ?? [], allArgs, rawState.cwd);
|
|
90435
|
-
else if (w0Plain === "factor") cjLines = this.evalSyncFactor(stdinLines
|
|
90436
|
-
else if (w0Plain === "tsort") cjLines = this.evalSyncTsort(stdinLines
|
|
90455
|
+
else if (w0Plain === "factor") cjLines = this.evalSyncFactor(stdinLines, allArgs);
|
|
90456
|
+
else if (w0Plain === "tsort") cjLines = this.evalSyncTsort(stdinLines, allArgs, rawState.cwd);
|
|
90437
90457
|
else if (w0Plain === "jq") cjLines = this.evalSyncJq(void 0, allArgs, rawState.cwd);
|
|
90438
90458
|
else if (w0Plain === "envsubst") {
|
|
90439
|
-
const esOut = this.evalSyncEnvsubst(
|
|
90459
|
+
const esOut = this.evalSyncEnvsubst(void 0, allArgs, rawState);
|
|
90440
90460
|
if (esOut !== void 0) cjLines = esOut.endsWith("\n") ? esOut.slice(0, -1).split("\n") : esOut ? [esOut] : [];
|
|
90441
90461
|
} else if (w0Plain === "numfmt") {
|
|
90442
90462
|
const optArgs = [];
|