@poe-platform/safe-bash 0.1.761 → 0.1.763
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 +255 -62
- package/dist/image-ast/index.js +255 -62
- package/dist/pdf-ast/ast.d.ts +23 -0
- package/dist/pdf-ast/index.js +344 -98
- package/dist/safe-bash/command-chunks/{chunk-6VX5ZQL5.js → chunk-4XHONGIU.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-OSMLVM7P.js → chunk-S3G2B4OX.js} +258 -62
- package/dist/safe-bash/command-chunks/{chunk-GR725WRX.js → chunk-S5EX6UP5.js} +1 -1
- package/dist/safe-bash/commands/csvcut/index.d.ts +1 -1
- package/dist/safe-bash/commands/csvcut/index.js +3 -1
- package/dist/safe-bash/commands/csvgrep/index.d.ts +1 -1
- package/dist/safe-bash/commands/csvgrep/index.js +3 -1
- package/dist/safe-bash/core.browser.js +8 -6
- package/dist/safe-bash/shell/runtime.js +5 -5
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +5 -1
- package/dist/safe-bash-command-ffmpeg/index.js +7942 -7853
- package/dist/safe-bash-command-gh/index.js +174 -105
- 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 +255 -62
- package/dist/safe-bash-command-pdfinfo/index.js +342 -98
- package/dist/safe-bash-command-pdftk/index.js +255 -62
- package/dist/safe-bash-command-pdftoppm/index.js +342 -98
- package/dist/safe-bash-command-pdftotext/index.js +255 -62
- package/dist/safe-bash-command-qpdf/index.js +255 -62
- 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 +318 -65
- package/dist/safe-bash-command-wkhtmltopdf/index.js +255 -62
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +23 -0
|
@@ -32076,14 +32076,18 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32076
32076
|
const paths = [];
|
|
32077
32077
|
const images = [];
|
|
32078
32078
|
const operations = [];
|
|
32079
|
+
let capturedOperations;
|
|
32080
|
+
let insideSoftMask = false;
|
|
32079
32081
|
const emit = (operation) => {
|
|
32080
|
-
const { clipPaths, clipImages } = curState();
|
|
32081
|
-
if (clipPaths || clipImages) operation = { ...operation, value: {
|
|
32082
|
+
const { clipPaths, clipImages, softMask } = curState();
|
|
32083
|
+
if (clipPaths || clipImages || softMask) operation = { ...operation, value: {
|
|
32082
32084
|
...operation.value,
|
|
32083
32085
|
...clipPaths ? { clipPaths } : {},
|
|
32084
|
-
...clipImages ? { clipImages } : {}
|
|
32086
|
+
...clipImages ? { clipImages } : {},
|
|
32087
|
+
...softMask ? { softMask } : {}
|
|
32085
32088
|
} };
|
|
32086
|
-
operations.push(operation);
|
|
32089
|
+
(capturedOperations ?? operations).push(operation);
|
|
32090
|
+
if (insideSoftMask) return;
|
|
32087
32091
|
switch (operation.kind) {
|
|
32088
32092
|
case "path":
|
|
32089
32093
|
paths.push(operation.value);
|
|
@@ -32189,7 +32193,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32189
32193
|
);
|
|
32190
32194
|
return { r: kClamp(r), g: kClamp(g), b: kClamp(b) };
|
|
32191
32195
|
};
|
|
32192
|
-
const applyStateOperator = (st, operator, ops, activeResources) => {
|
|
32196
|
+
const applyStateOperator = (st, operator, ops, activeResources, activeFonts, depth) => {
|
|
32193
32197
|
const num = (i, fb = 0) => ops[i]?.kind === "number" ? ops[i].value : fb;
|
|
32194
32198
|
if (operator === "cm") {
|
|
32195
32199
|
const m = [num(0, 1), num(1, 0), num(2, 0), num(3, 1), num(4, 0), num(5, 0)];
|
|
@@ -32272,6 +32276,46 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32272
32276
|
const extDict = params.cosDoc.resolveDict(dictGet(activeResources, "ExtGState"));
|
|
32273
32277
|
const gsDict = extDict ? params.cosDoc.resolveDict(dictGet(extDict, ops[0].decoded)) : void 0;
|
|
32274
32278
|
if (gsDict) {
|
|
32279
|
+
const mask = params.cosDoc.resolve(dictGet(gsDict, "SMask"));
|
|
32280
|
+
if (mask?.kind === "name" && mask.decoded === "None") {
|
|
32281
|
+
st.softMask = void 0;
|
|
32282
|
+
} else if (mask?.kind === "dict") {
|
|
32283
|
+
const subtype = params.cosDoc.resolve(dictGet(mask, "S"));
|
|
32284
|
+
const form = params.cosDoc.resolve(dictGet(mask, "G"));
|
|
32285
|
+
if (form?.kind === "stream" && subtype?.kind === "name" && (subtype.decoded === "Alpha" || subtype.decoded === "Luminosity")) {
|
|
32286
|
+
if (depth >= 8) throw new PdfError("E_LIMIT", "Soft-mask nesting exceeds the form depth limit");
|
|
32287
|
+
const parentOperations = capturedOperations;
|
|
32288
|
+
const parentInsideSoftMask = insideSoftMask;
|
|
32289
|
+
const savedTextState = { pendingTextClip, hasTextClip, activeTm, activeTlm };
|
|
32290
|
+
const captured = [];
|
|
32291
|
+
capturedOperations = captured;
|
|
32292
|
+
insideSoftMask = true;
|
|
32293
|
+
const maskState = { ...st, softMask: void 0, fillAlpha: 1, strokeAlpha: 1, blendMode: "Normal" };
|
|
32294
|
+
delete maskState.clipPaths;
|
|
32295
|
+
delete maskState.clipImages;
|
|
32296
|
+
delete maskState.clipRect;
|
|
32297
|
+
stateStack.push(maskState);
|
|
32298
|
+
try {
|
|
32299
|
+
paintForm(form, activeResources, activeFonts, depth, void 0, void 0, true);
|
|
32300
|
+
} finally {
|
|
32301
|
+
stateStack.pop();
|
|
32302
|
+
capturedOperations = parentOperations;
|
|
32303
|
+
insideSoftMask = parentInsideSoftMask;
|
|
32304
|
+
({ pendingTextClip, hasTextClip, activeTm, activeTlm } = savedTextState);
|
|
32305
|
+
}
|
|
32306
|
+
const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
|
|
32307
|
+
const colorSpace = group ? dictGet(group, "CS") : void 0;
|
|
32308
|
+
const bc = params.cosDoc.resolveArray(dictGet(mask, "BC"));
|
|
32309
|
+
const components = bc?.items.map((item) => {
|
|
32310
|
+
const value = params.cosDoc.resolve(item);
|
|
32311
|
+
return value?.kind === "number" ? value.value : 0;
|
|
32312
|
+
});
|
|
32313
|
+
const [r, g, b] = components ? convertColorSpaceComponentsToRgb(params.cosDoc, colorSpace, "DeviceRGB", components, activeResources) : [0, 0, 0];
|
|
32314
|
+
const transfer = params.cosDoc.resolve(dictGet(mask, "TR"));
|
|
32315
|
+
const transferMap = transfer?.kind === "dict" || transfer?.kind === "stream" ? Uint8Array.from({ length: 256 }, (_, i) => Math.floor(kClamp(Math.fround(evalShadingFunctionToComponents(params.cosDoc, transfer, Math.fround(i / 255))[0] ?? 0)) * 255)) : void 0;
|
|
32316
|
+
st.softMask = { subtype: subtype.decoded, operations: captured, backdrop: { r, g, b }, transferMap };
|
|
32317
|
+
}
|
|
32318
|
+
}
|
|
32275
32319
|
const bmNode = params.cosDoc.resolve(dictGet(gsDict, "BM"));
|
|
32276
32320
|
if (bmNode?.kind === "name") {
|
|
32277
32321
|
st.blendMode = bmNode.decoded === "Compatible" ? "Normal" : bmNode.decoded;
|
|
@@ -32358,6 +32402,84 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32358
32402
|
] }], void 0, void 0, resources, activeFonts, depth);
|
|
32359
32403
|
stateStack.pop();
|
|
32360
32404
|
};
|
|
32405
|
+
const paintForm = (form, activeResources, activeFonts, depth, mcid, actualText, maskGroup = false) => {
|
|
32406
|
+
const st = curState();
|
|
32407
|
+
const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
|
|
32408
|
+
const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
|
|
32409
|
+
const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
|
|
32410
|
+
const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
|
|
32411
|
+
const formStreamBytes = params.cosDoc.decodeStream(form);
|
|
32412
|
+
const formNodes = parseContentStream(formStreamBytes);
|
|
32413
|
+
const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
|
|
32414
|
+
const formFonts = new Map(activeFonts);
|
|
32415
|
+
for (const [k, v] of resolvePageFonts(params.cosDoc, formResDict).entries()) {
|
|
32416
|
+
formFonts.set(k, v);
|
|
32417
|
+
}
|
|
32418
|
+
let nextCtm = [...st.ctm];
|
|
32419
|
+
const matArr = params.cosDoc.resolveArray(dictGet(form.dict, "Matrix"));
|
|
32420
|
+
if (matArr && matArr.items.length >= 6) {
|
|
32421
|
+
const mn = (idx, fb = 0) => {
|
|
32422
|
+
const resolved = params.cosDoc.resolve(matArr.items[idx]);
|
|
32423
|
+
return resolved?.kind === "number" ? resolved.value : fb;
|
|
32424
|
+
};
|
|
32425
|
+
const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
32426
|
+
nextCtm = multiplyMatrices(formMat, nextCtm);
|
|
32427
|
+
}
|
|
32428
|
+
let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
|
|
32429
|
+
let nextClipPaths = isolate ? void 0 : st.clipPaths;
|
|
32430
|
+
const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
|
|
32431
|
+
if (bboxArr && bboxArr.items.length >= 4) {
|
|
32432
|
+
const bn = (idx, fb = 0) => {
|
|
32433
|
+
const resolved = params.cosDoc.resolve(bboxArr.items[idx]);
|
|
32434
|
+
return resolved?.kind === "number" ? resolved.value : fb;
|
|
32435
|
+
};
|
|
32436
|
+
const bx0 = bn(0, 0), by0 = bn(1, 0), bx1 = bn(2, 0), by1 = bn(3, 0);
|
|
32437
|
+
const pts = [
|
|
32438
|
+
transformPoint(nextCtm, bx0, by0),
|
|
32439
|
+
transformPoint(nextCtm, bx1, by0),
|
|
32440
|
+
transformPoint(nextCtm, bx1, by1),
|
|
32441
|
+
transformPoint(nextCtm, bx0, by1)
|
|
32442
|
+
];
|
|
32443
|
+
nextClipPaths = [...nextClipPaths ?? [], [
|
|
32444
|
+
...pts.map(([x, y], index) => ({ kind: index === 0 ? "move" : "line", x, y })),
|
|
32445
|
+
{ kind: "close" }
|
|
32446
|
+
]];
|
|
32447
|
+
const fMinX = Math.min(...pts.map((p) => p[0]));
|
|
32448
|
+
const fMinY = Math.min(...pts.map((p) => p[1]));
|
|
32449
|
+
const fMaxX = Math.max(...pts.map((p) => p[0]));
|
|
32450
|
+
const fMaxY = Math.max(...pts.map((p) => p[1]));
|
|
32451
|
+
if (fMaxX > fMinX && fMaxY > fMinY) {
|
|
32452
|
+
nextClip = nextClip ? [
|
|
32453
|
+
Math.max(nextClip[0], fMinX),
|
|
32454
|
+
Math.max(nextClip[1], fMinY),
|
|
32455
|
+
Math.min(nextClip[2], fMaxX),
|
|
32456
|
+
Math.min(nextClip[3], fMaxY)
|
|
32457
|
+
] : [fMinX, fMinY, fMaxX, fMaxY];
|
|
32458
|
+
}
|
|
32459
|
+
}
|
|
32460
|
+
const parentOperations = capturedOperations;
|
|
32461
|
+
const children = [];
|
|
32462
|
+
const nextState = { ...st, ctm: nextCtm };
|
|
32463
|
+
if (isolate) {
|
|
32464
|
+
capturedOperations = children;
|
|
32465
|
+
nextState.fillAlpha = nextState.strokeAlpha = 1;
|
|
32466
|
+
nextState.blendMode = "Normal";
|
|
32467
|
+
nextState.softMask = void 0;
|
|
32468
|
+
delete nextState.clipImages;
|
|
32469
|
+
delete nextState.clipPaths;
|
|
32470
|
+
delete nextState.clipRect;
|
|
32471
|
+
}
|
|
32472
|
+
if (nextClip) nextState.clipRect = nextClip;
|
|
32473
|
+
if (nextClipPaths) nextState.clipPaths = nextClipPaths;
|
|
32474
|
+
stateStack.push(nextState);
|
|
32475
|
+
try {
|
|
32476
|
+
walkNodes(formNodes, mcid, actualText, formResDict, formFonts, depth + 1);
|
|
32477
|
+
} finally {
|
|
32478
|
+
stateStack.pop();
|
|
32479
|
+
capturedOperations = parentOperations;
|
|
32480
|
+
}
|
|
32481
|
+
if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
|
|
32482
|
+
};
|
|
32361
32483
|
const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
|
|
32362
32484
|
for (const node of nodes) {
|
|
32363
32485
|
switch (node.kind) {
|
|
@@ -32402,7 +32524,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32402
32524
|
break;
|
|
32403
32525
|
}
|
|
32404
32526
|
case "state-op": {
|
|
32405
|
-
applyStateOperator(curState(), node.operator, node.operands, activeResources);
|
|
32527
|
+
applyStateOperator(curState(), node.operator, node.operands, activeResources, activeFonts, depth);
|
|
32406
32528
|
break;
|
|
32407
32529
|
}
|
|
32408
32530
|
case "path-op": {
|
|
@@ -32688,53 +32810,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32688
32810
|
...st.clipRect ? { clipRect: [...st.clipRect] } : {}
|
|
32689
32811
|
}, patternMask, activeResources, activeFonts, depth);
|
|
32690
32812
|
} else if (sub === "Form" && depth < 8) {
|
|
32691
|
-
|
|
32692
|
-
const formNodes = parseContentStream(formStreamBytes);
|
|
32693
|
-
const formResDict = params.cosDoc.resolveDict(dictGet(xobjNode.dict, "Resources")) ?? activeResources;
|
|
32694
|
-
const formFonts = new Map(activeFonts);
|
|
32695
|
-
for (const [k, v] of resolvePageFonts(params.cosDoc, formResDict).entries()) {
|
|
32696
|
-
formFonts.set(k, v);
|
|
32697
|
-
}
|
|
32698
|
-
let nextCtm = [...st.ctm];
|
|
32699
|
-
const matArr = params.cosDoc.resolveArray(dictGet(xobjNode.dict, "Matrix"));
|
|
32700
|
-
if (matArr && matArr.items.length >= 6) {
|
|
32701
|
-
const mn = (idx, fb = 0) => {
|
|
32702
|
-
const resolved = params.cosDoc.resolve(matArr.items[idx]);
|
|
32703
|
-
return resolved?.kind === "number" ? resolved.value : fb;
|
|
32704
|
-
};
|
|
32705
|
-
const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
|
|
32706
|
-
nextCtm = multiplyMatrices(formMat, nextCtm);
|
|
32707
|
-
}
|
|
32708
|
-
let nextClip = st.clipRect ? [...st.clipRect] : void 0;
|
|
32709
|
-
const bboxArr = params.cosDoc.resolveArray(dictGet(xobjNode.dict, "BBox"));
|
|
32710
|
-
if (bboxArr && bboxArr.items.length >= 4) {
|
|
32711
|
-
const bn = (idx, fb = 0) => {
|
|
32712
|
-
const resolved = params.cosDoc.resolve(bboxArr.items[idx]);
|
|
32713
|
-
return resolved?.kind === "number" ? resolved.value : fb;
|
|
32714
|
-
};
|
|
32715
|
-
const bx0 = bn(0, 0), by0 = bn(1, 0), bx1 = bn(2, 0), by1 = bn(3, 0);
|
|
32716
|
-
const pts = [
|
|
32717
|
-
transformPoint(nextCtm, bx0, by0),
|
|
32718
|
-
transformPoint(nextCtm, bx1, by0),
|
|
32719
|
-
transformPoint(nextCtm, bx0, by1),
|
|
32720
|
-
transformPoint(nextCtm, bx1, by1)
|
|
32721
|
-
];
|
|
32722
|
-
const fMinX = Math.min(...pts.map((p) => p[0]));
|
|
32723
|
-
const fMinY = Math.min(...pts.map((p) => p[1]));
|
|
32724
|
-
const fMaxX = Math.max(...pts.map((p) => p[0]));
|
|
32725
|
-
const fMaxY = Math.max(...pts.map((p) => p[1]));
|
|
32726
|
-
if (fMaxX > fMinX && fMaxY > fMinY) {
|
|
32727
|
-
nextClip = nextClip ? [
|
|
32728
|
-
Math.max(nextClip[0], fMinX),
|
|
32729
|
-
Math.max(nextClip[1], fMinY),
|
|
32730
|
-
Math.min(nextClip[2], fMaxX),
|
|
32731
|
-
Math.min(nextClip[3], fMaxY)
|
|
32732
|
-
] : [fMinX, fMinY, fMaxX, fMaxY];
|
|
32733
|
-
}
|
|
32734
|
-
}
|
|
32735
|
-
stateStack.push({ ...st, ctm: nextCtm, ...nextClip ? { clipRect: nextClip } : {} });
|
|
32736
|
-
walkNodes(formNodes, mcid, actualText, formResDict, formFonts, depth + 1);
|
|
32737
|
-
if (stateStack.length > 1) stateStack.pop();
|
|
32813
|
+
paintForm(xobjNode, activeResources, activeFonts, depth, mcid, actualText);
|
|
32738
32814
|
}
|
|
32739
32815
|
}
|
|
32740
32816
|
}
|
|
@@ -32953,7 +33029,7 @@ function evaluateContentStreamToDisplayList(params) {
|
|
|
32953
33029
|
st.textRenderMode = cmd.mode;
|
|
32954
33030
|
break;
|
|
32955
33031
|
case "state-op":
|
|
32956
|
-
applyStateOperator(st, cmd.operator, cmd.operands, activeResources);
|
|
33032
|
+
applyStateOperator(st, cmd.operator, cmd.operands, activeResources, activeFonts, depth);
|
|
32957
33033
|
break;
|
|
32958
33034
|
case "show-text":
|
|
32959
33035
|
emitTokenBytes(cmd.token.bytes);
|
|
@@ -34002,6 +34078,50 @@ function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
|
34002
34078
|
return points;
|
|
34003
34079
|
}
|
|
34004
34080
|
|
|
34081
|
+
// packages/pdf-ast/src/render/image-sampling.ts
|
|
34082
|
+
init_buffer();
|
|
34083
|
+
function sampleImageLinear(image, x, y, out) {
|
|
34084
|
+
x = Math.max(0, Math.min(image.width - 1, x));
|
|
34085
|
+
y = Math.max(0, Math.min(image.height - 1, y));
|
|
34086
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
34087
|
+
const fx = x - x0, fy = y - y0;
|
|
34088
|
+
out.fill(0);
|
|
34089
|
+
for (let j = 0; j < 2; j++) {
|
|
34090
|
+
for (let i = 0; i < 2; i++) {
|
|
34091
|
+
const offset = (Math.min(image.height - 1, y0 + j) * image.width + Math.min(image.width - 1, x0 + i)) * 4;
|
|
34092
|
+
const alpha = image.data[offset + 3] * (i ? fx : 1 - fx) * (j ? fy : 1 - fy);
|
|
34093
|
+
out[0] = out[0] + image.data[offset] * alpha;
|
|
34094
|
+
out[1] = out[1] + image.data[offset + 1] * alpha;
|
|
34095
|
+
out[2] = out[2] + image.data[offset + 2] * alpha;
|
|
34096
|
+
out[3] = out[3] + alpha;
|
|
34097
|
+
}
|
|
34098
|
+
}
|
|
34099
|
+
if (out[3] > 0) {
|
|
34100
|
+
out[0] = out[0] / out[3];
|
|
34101
|
+
out[1] = out[1] / out[3];
|
|
34102
|
+
out[2] = out[2] / out[3];
|
|
34103
|
+
}
|
|
34104
|
+
}
|
|
34105
|
+
function downscaleImage(image, widthScale, heightScale) {
|
|
34106
|
+
const sample = new Float64Array(4);
|
|
34107
|
+
while (widthScale > 2 && image.width > 1 || heightScale > 2 && image.height > 1) {
|
|
34108
|
+
const width = widthScale > 2 ? Math.ceil(image.width / 2) : image.width;
|
|
34109
|
+
const height = heightScale > 2 ? Math.ceil(image.height / 2) : image.height;
|
|
34110
|
+
const data = new Uint8Array(width * height * 4);
|
|
34111
|
+
for (let y = 0; y < height; y++) {
|
|
34112
|
+
for (let x = 0; x < width; x++) {
|
|
34113
|
+
sampleImageLinear(image, (x + 0.5) * image.width / width - 0.5, (y + 0.5) * image.height / height - 0.5, sample);
|
|
34114
|
+
const offset = (y * width + x) * 4;
|
|
34115
|
+
for (let c = 0; c < 4; c++) data[offset + c] = Math.round(sample[c]);
|
|
34116
|
+
}
|
|
34117
|
+
}
|
|
34118
|
+
widthScale /= image.width / width;
|
|
34119
|
+
heightScale /= image.height / height;
|
|
34120
|
+
image = { width, height, data };
|
|
34121
|
+
}
|
|
34122
|
+
return image;
|
|
34123
|
+
}
|
|
34124
|
+
|
|
34005
34125
|
// packages/pdf-ast/src/render/raster.ts
|
|
34006
34126
|
function encodePng(bitmap) {
|
|
34007
34127
|
return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
|
|
@@ -34915,6 +35035,30 @@ function paintOperations(displayList) {
|
|
|
34915
35035
|
...displayList.glyphs.map((value) => ({ kind: "glyph", value }))
|
|
34916
35036
|
];
|
|
34917
35037
|
}
|
|
35038
|
+
function renderSoftMask(mask, displayList, scale) {
|
|
35039
|
+
const bitmap = renderDisplayListToBitmap({
|
|
35040
|
+
...displayList,
|
|
35041
|
+
rotation: 0,
|
|
35042
|
+
glyphs: [],
|
|
35043
|
+
paths: [],
|
|
35044
|
+
images: [],
|
|
35045
|
+
operations: mask.operations
|
|
35046
|
+
}, { scale, transparent: true });
|
|
35047
|
+
const { data } = bitmap;
|
|
35048
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
35049
|
+
let value = data[i + 3];
|
|
35050
|
+
if (mask.subtype === "Luminosity") {
|
|
35051
|
+
const alpha = value / 255;
|
|
35052
|
+
const r = Math.round(data[i] * alpha + mask.backdrop.r * 255 * (1 - alpha));
|
|
35053
|
+
const g = Math.round(data[i + 1] * alpha + mask.backdrop.g * 255 * (1 - alpha));
|
|
35054
|
+
const b = Math.round(data[i + 2] * alpha + mask.backdrop.b * 255 * (1 - alpha));
|
|
35055
|
+
value = Math.round(pdfLum(r, g, b));
|
|
35056
|
+
}
|
|
35057
|
+
data[i] = data[i + 1] = data[i + 2] = 0;
|
|
35058
|
+
data[i + 3] = mask.transferMap?.[value] ?? value;
|
|
35059
|
+
}
|
|
35060
|
+
return bitmap;
|
|
35061
|
+
}
|
|
34918
35062
|
function renderDisplayListToBitmap(displayList, options = {}) {
|
|
34919
35063
|
const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
|
|
34920
35064
|
const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
|
|
@@ -34938,10 +35082,28 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
34938
35082
|
const aaTxt = options.antialiasText !== false;
|
|
34939
35083
|
let cachedClips;
|
|
34940
35084
|
let cachedClipMask;
|
|
35085
|
+
let cachedSoftMask;
|
|
35086
|
+
let cachedSoftMaskPixels;
|
|
34941
35087
|
const imageClipMasks = /* @__PURE__ */ new Map();
|
|
34942
35088
|
for (const original of paintOperations(displayList)) {
|
|
34943
35089
|
if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
|
|
34944
|
-
|
|
35090
|
+
let operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
|
|
35091
|
+
if (operation.kind === "group") {
|
|
35092
|
+
const group = operation.value;
|
|
35093
|
+
const bitmap = renderDisplayListToBitmap({ ...displayList, rotation: 0, operations: group.operations }, { ...options, scale, dpiX: void 0, dpiY: void 0, cropRect: void 0, transparent: true });
|
|
35094
|
+
for (let i = 3; i < bitmap.data.length; i += 4) bitmap.data[i] = Math.round(bitmap.data[i] * group.alpha);
|
|
35095
|
+
operation = { kind: "image", value: {
|
|
35096
|
+
name: "TransparencyGroup",
|
|
35097
|
+
width: bitmap.width,
|
|
35098
|
+
height: bitmap.height,
|
|
35099
|
+
decodedRgba: bitmap.data,
|
|
35100
|
+
matrix: [bitmap.width / scale, 0, 0, bitmap.height / scale, 0, displayList.height - bitmap.height / scale],
|
|
35101
|
+
colorSpace: "DeviceRGB",
|
|
35102
|
+
bitsPerComponent: 8,
|
|
35103
|
+
blendMode: group.blendMode,
|
|
35104
|
+
clipRect: group.clipRect
|
|
35105
|
+
} };
|
|
35106
|
+
}
|
|
34945
35107
|
const clips = original.value.clipPaths;
|
|
34946
35108
|
let clipMask = clips && clips === cachedClips ? cachedClipMask : void 0;
|
|
34947
35109
|
if (clips && !clipMask) {
|
|
@@ -34955,6 +35117,19 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
34955
35117
|
cachedClips = clips;
|
|
34956
35118
|
cachedClipMask = clipMask;
|
|
34957
35119
|
}
|
|
35120
|
+
const softMask = original.value.softMask;
|
|
35121
|
+
if (softMask) {
|
|
35122
|
+
if (softMask !== cachedSoftMask) {
|
|
35123
|
+
cachedSoftMaskPixels = renderSoftMask(softMask, displayList, scale).data;
|
|
35124
|
+
cachedSoftMask = softMask;
|
|
35125
|
+
}
|
|
35126
|
+
if (clipMask) {
|
|
35127
|
+
clipMask = clipMask.slice();
|
|
35128
|
+
for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * cachedSoftMaskPixels[i] / 255);
|
|
35129
|
+
} else {
|
|
35130
|
+
clipMask = cachedSoftMaskPixels;
|
|
35131
|
+
}
|
|
35132
|
+
}
|
|
34958
35133
|
const imageClips = original.value.clipImages;
|
|
34959
35134
|
if (imageClips) {
|
|
34960
35135
|
let imageMask = imageClipMasks.get(imageClips);
|
|
@@ -35058,6 +35233,17 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
35058
35233
|
const maxPx = Math.min(width - 1, clipMaxPx, Math.ceil(Math.max(...cornersPx)) - 1);
|
|
35059
35234
|
const minPy = Math.max(0, clipMinPy, Math.floor(Math.min(...cornersPy)));
|
|
35060
35235
|
const maxPy = Math.min(height - 1, clipMaxPy, Math.ceil(Math.max(...cornersPy)) - 1);
|
|
35236
|
+
if (minPx > maxPx || minPy > maxPy) continue;
|
|
35237
|
+
const source = downscaleImage(
|
|
35238
|
+
{ width: img.width, height: img.height, data: img.decodedRgba },
|
|
35239
|
+
Math.hypot(d, c) * img.width / Math.abs(det * scale),
|
|
35240
|
+
Math.hypot(b, a) * img.height / Math.abs(det * scale)
|
|
35241
|
+
);
|
|
35242
|
+
const ax = a * scale / img.width, ay = b * scale / img.width;
|
|
35243
|
+
const bx = c * scale / img.height, by = d * scale / img.height;
|
|
35244
|
+
const s1 = ax * ax + ay * ay, s2 = bx * bx + by * by, cross = ax * bx + ay * by;
|
|
35245
|
+
const smooth = Math.fround((s1 + s2 + Math.hypot(s1 - s2, 2 * cross)) / 2) <= 1;
|
|
35246
|
+
const sample = new Float64Array(4);
|
|
35061
35247
|
for (let py = minPy; py <= maxPy; py++) {
|
|
35062
35248
|
const yPdf = displayList.height - (py + 0.5) / scale;
|
|
35063
35249
|
if (img.clipRect && (yPdf < img.clipRect[1] || yPdf > img.clipRect[3])) continue;
|
|
@@ -35069,9 +35255,14 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
35069
35255
|
const u = (d * dxPdf - c * dyPdf) / det;
|
|
35070
35256
|
const v = (-b * dxPdf + a * dyPdf) / det;
|
|
35071
35257
|
if (u < 0 || u > 1 || v < 0 || v > 1) continue;
|
|
35072
|
-
|
|
35073
|
-
|
|
35074
|
-
|
|
35258
|
+
if (smooth) {
|
|
35259
|
+
sampleImageLinear(source, u * source.width - 0.5, (1 - v) * source.height - 0.5, sample);
|
|
35260
|
+
} else {
|
|
35261
|
+
const sx = Math.min(source.width - 1, Math.max(0, Math.floor(u * source.width)));
|
|
35262
|
+
const sy = Math.min(source.height - 1, Math.max(0, Math.floor((1 - v) * source.height)));
|
|
35263
|
+
const sIdx = (sy * source.width + sx) * 4;
|
|
35264
|
+
for (let c2 = 0; c2 < 4; c2++) sample[c2] = source.data[sIdx + c2];
|
|
35265
|
+
}
|
|
35075
35266
|
blendPixel(
|
|
35076
35267
|
rgba,
|
|
35077
35268
|
width,
|
|
@@ -35079,11 +35270,11 @@ function renderDisplayListToBitmap(displayList, options = {}) {
|
|
|
35079
35270
|
px,
|
|
35080
35271
|
py,
|
|
35081
35272
|
{
|
|
35082
|
-
r:
|
|
35083
|
-
g:
|
|
35084
|
-
b:
|
|
35273
|
+
r: sample[0] / 255,
|
|
35274
|
+
g: sample[1] / 255,
|
|
35275
|
+
b: sample[2] / 255
|
|
35085
35276
|
},
|
|
35086
|
-
|
|
35277
|
+
sample[3] / 255,
|
|
35087
35278
|
img.blendMode,
|
|
35088
35279
|
clipMask
|
|
35089
35280
|
);
|
|
@@ -37278,3 +37469,8 @@ export {
|
|
|
37278
37469
|
* Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
|
|
37279
37470
|
* See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
|
|
37280
37471
|
*/
|
|
37472
|
+
/*!
|
|
37473
|
+
* Staged image reduction adapted from Mozilla PDF.js CanvasGraphics._scaleImage.
|
|
37474
|
+
* Copyright 2012 Mozilla Foundation. Licensed under Apache-2.0.
|
|
37475
|
+
* See THIRD_PARTY_NOTICES.md for the source revision and adaptations.
|
|
37476
|
+
*/
|
|
@@ -5,5 +5,5 @@ export declare function createCsvcutCommand(options?: CsvcutCommandOptions): Com
|
|
|
5
5
|
export declare const csvcutCommand: CommandDefinition;
|
|
6
6
|
export declare function createCsvcutCommands(options?: CsvcutCommandsOptions): readonly CommandDefinition[];
|
|
7
7
|
export declare function csvcutCommands(options?: CsvcutCommandsOptions): VirtualShellPlugin;
|
|
8
|
-
export declare function evalSyncCsvcut(inBytes: Uint8Array, opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined): string | undefined;
|
|
8
|
+
export declare function evalSyncCsvcut(inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined): string | undefined;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -31,7 +31,7 @@ export function csvcutCommands(options = {}) {
|
|
|
31
31
|
let _syncAbortSignal;
|
|
32
32
|
const syncAbortSignal = () => (_syncAbortSignal ??= new AbortController().signal);
|
|
33
33
|
export function evalSyncCsvcut(inBytes, opArgs, readFileSync) {
|
|
34
|
-
if (inBytes.byteLength > 16384)
|
|
34
|
+
if (inBytes !== undefined && inBytes.byteLength > 16384)
|
|
35
35
|
return undefined;
|
|
36
36
|
const budget = new CsvBudget({}, syncAbortSignal());
|
|
37
37
|
try {
|
|
@@ -55,6 +55,8 @@ export function evalSyncCsvcut(inBytes, opArgs, readFileSync) {
|
|
|
55
55
|
const dialect = { ...supplied.dialect, profile: supplied.dialect?.profile ?? "utf8-sig-permissive-v1" };
|
|
56
56
|
if (Number.isSafeInteger(dialect.skipLines) && dialect.skipLines < 0)
|
|
57
57
|
dialect.skipLines = 0;
|
|
58
|
+
if (sourceBytes === undefined)
|
|
59
|
+
return undefined;
|
|
58
60
|
const parser = new CsvParser(dialect, budget);
|
|
59
61
|
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
60
62
|
const first = rows[0];
|
|
@@ -5,5 +5,5 @@ export declare function createCsvgrepCommand(options?: CsvgrepCommandOptions): C
|
|
|
5
5
|
export declare const csvgrepCommand: CommandDefinition;
|
|
6
6
|
export declare function createCsvgrepCommands(options?: CsvgrepCommandsOptions): readonly CommandDefinition[];
|
|
7
7
|
export declare function csvgrepCommands(options?: CsvgrepCommandsOptions): VirtualShellPlugin;
|
|
8
|
-
export declare function evalSyncCsvgrep(inBytes: Uint8Array, opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined): string | undefined;
|
|
8
|
+
export declare function evalSyncCsvgrep(inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined): string | undefined;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -31,7 +31,7 @@ export function csvgrepCommands(options = {}) {
|
|
|
31
31
|
let _syncAbortSignal;
|
|
32
32
|
const syncAbortSignal = () => (_syncAbortSignal ??= new AbortController().signal);
|
|
33
33
|
export function evalSyncCsvgrep(inBytes, opArgs, readFileSync) {
|
|
34
|
-
if (inBytes.byteLength > 16384)
|
|
34
|
+
if (inBytes !== undefined && inBytes.byteLength > 16384)
|
|
35
35
|
return undefined;
|
|
36
36
|
const budget = new CsvBudget({}, syncAbortSignal());
|
|
37
37
|
try {
|
|
@@ -64,6 +64,8 @@ export function evalSyncCsvgrep(inBytes, opArgs, readFileSync) {
|
|
|
64
64
|
return undefined;
|
|
65
65
|
sourceBytes = fileBytes;
|
|
66
66
|
}
|
|
67
|
+
if (sourceBytes === undefined)
|
|
68
|
+
return undefined;
|
|
67
69
|
const parser = new CsvParser(options.dialect ?? {}, budget);
|
|
68
70
|
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
69
71
|
const matcher = options.names ? undefined : createMatcher(options, fileMatchSet, budget);
|
|
@@ -52394,7 +52394,7 @@ function csvcutCommands(options8 = {}) {
|
|
|
52394
52394
|
var _syncAbortSignal;
|
|
52395
52395
|
var syncAbortSignal = () => _syncAbortSignal ??= new AbortController().signal;
|
|
52396
52396
|
function evalSyncCsvcut(inBytes, opArgs, readFileSync) {
|
|
52397
|
-
if (inBytes.byteLength > 16384) return void 0;
|
|
52397
|
+
if (inBytes !== void 0 && inBytes.byteLength > 16384) return void 0;
|
|
52398
52398
|
const budget = new CsvBudget({}, syncAbortSignal());
|
|
52399
52399
|
try {
|
|
52400
52400
|
const supplied = parseCsvcutArguments(opArgs, budget);
|
|
@@ -52412,6 +52412,7 @@ function evalSyncCsvcut(inBytes, opArgs, readFileSync) {
|
|
|
52412
52412
|
if (supplied.names && supplied.headerless) return void 0;
|
|
52413
52413
|
const dialect = { ...supplied.dialect, profile: supplied.dialect?.profile ?? "utf8-sig-permissive-v1" };
|
|
52414
52414
|
if (Number.isSafeInteger(dialect.skipLines) && dialect.skipLines < 0) dialect.skipLines = 0;
|
|
52415
|
+
if (sourceBytes === void 0) return void 0;
|
|
52415
52416
|
const parser = new CsvParser(dialect, budget);
|
|
52416
52417
|
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
52417
52418
|
const first = rows[0];
|
|
@@ -52503,7 +52504,7 @@ function csvgrepCommands(options8 = {}) {
|
|
|
52503
52504
|
var _syncAbortSignal2;
|
|
52504
52505
|
var syncAbortSignal2 = () => _syncAbortSignal2 ??= new AbortController().signal;
|
|
52505
52506
|
function evalSyncCsvgrep(inBytes, opArgs, readFileSync) {
|
|
52506
|
-
if (inBytes.byteLength > 16384) return void 0;
|
|
52507
|
+
if (inBytes !== void 0 && inBytes.byteLength > 16384) return void 0;
|
|
52507
52508
|
const budget = new CsvBudget2({}, syncAbortSignal2());
|
|
52508
52509
|
try {
|
|
52509
52510
|
const options8 = parseCsvgrepArguments(opArgs, budget);
|
|
@@ -52528,6 +52529,7 @@ function evalSyncCsvgrep(inBytes, opArgs, readFileSync) {
|
|
|
52528
52529
|
if (!fileBytes || fileBytes.byteLength > 16384) return void 0;
|
|
52529
52530
|
sourceBytes = fileBytes;
|
|
52530
52531
|
}
|
|
52532
|
+
if (sourceBytes === void 0) return void 0;
|
|
52531
52533
|
const parser = new CsvParser2(options8.dialect ?? {}, budget);
|
|
52532
52534
|
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
52533
52535
|
const matcher = options8.names ? void 0 : createMatcher(options8, fileMatchSet, budget);
|
|
@@ -87414,9 +87416,9 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
87414
87416
|
"LC_MEASUREMENT",
|
|
87415
87417
|
"LC_IDENTIFICATION"
|
|
87416
87418
|
]) {
|
|
87417
|
-
if (lcAll) lines4.push(`${cat}
|
|
87419
|
+
if (lcAll) lines4.push(`${cat}="${lcAll}"`);
|
|
87418
87420
|
else if (getEnv(cat)) lines4.push(`${cat}=${getEnv(cat)}`);
|
|
87419
|
-
else lines4.push(`${cat}="${lang}"`);
|
|
87421
|
+
else lines4.push(`${cat}="${lang || "C.UTF-8"}"`);
|
|
87420
87422
|
}
|
|
87421
87423
|
lines4.push(`LC_ALL=${lcAll ?? ""}`);
|
|
87422
87424
|
return lines4.join("\n");
|
|
@@ -89972,7 +89974,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
89972
89974
|
const inBytes = hasSingleHereStringRedir ? fastSharedTextEncoder.encode(hereStrVal) : EMPTY_BYTES;
|
|
89973
89975
|
const optInBytes = hasSingleHereStringRedir ? inBytes : void 0;
|
|
89974
89976
|
const readFile = (p) => this.tryReadMemoryFileViewSync(resolvePath(rawState.cwd, p), true, true);
|
|
89975
|
-
let csvOut = w0Plain === "csvcut" ? evalSyncCsvcut(
|
|
89977
|
+
let csvOut = w0Plain === "csvcut" ? evalSyncCsvcut(optInBytes, allArgs, readFile) : w0Plain === "csvgrep" ? evalSyncCsvgrep(optInBytes, allArgs, readFile) : w0Plain === "csvlook" ? evalSyncCsvlook(optInBytes, allArgs, readFile) : w0Plain === "csvjson" ? evalSyncCsvjson(optInBytes, allArgs, readFile) : w0Plain === "csvsort" ? evalSyncCsvsort(optInBytes, allArgs, readFile) : w0Plain === "csvformat" ? evalSyncCsvformat(optInBytes, allArgs, readFile) : w0Plain === "csvstat" ? evalSyncCsvstat(optInBytes, allArgs, readFile) : w0Plain === "in2csv" ? evalSyncIn2csv(optInBytes, allArgs, readFile) : w0Plain === "csvstack" ? evalSyncCsvstack(optInBytes, allArgs, readFile) : w0Plain === "csvjoin" ? evalSyncCsvjoin(optInBytes, allArgs, readFile) : w0Plain === "dd" ? evalSyncDd(optInBytes, allArgs, readFile, (p, b) => {
|
|
89976
89978
|
try {
|
|
89977
89979
|
if (this._inSyncLoopPreflight) return Boolean(this.canFastMemoryRedirect && this._isMemoryBackingFs);
|
|
89978
89980
|
return tryWriteMemoryFileSync(this.backingFs, resolvePath(rawState.cwd, p), b, false, 438 & ~(rawState.umask ?? 18), this.commandSignal);
|
|
@@ -90384,7 +90386,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
90384
90386
|
return false;
|
|
90385
90387
|
}
|
|
90386
90388
|
}, (s, d, sym) => this.tryLinkMemoryNodeSync(sym ? s : resolvePath(rawState.cwd, s), resolvePath(rawState.cwd, d), sym)) : (allArgs.includes("--help") || allArgs.includes("--version")) && (0, gnu_information_exports.gnuInformationSync)(w0Plain, allArgs) !== void 0 ? (0, gnu_information_exports.gnuInformationSync)(w0Plain, allArgs) : w0Plain === "mdq" ? evalSyncMdq(inBytes, allArgs, readFile) : w0Plain === "shuf" ? evalSyncShuf(inBytes, allArgs, readFile) : w0Plain === "html-to-markdown" ? (0, html_to_markdown_exports.evalSyncHtmlToMarkdown)(inBytes, allArgs, readFile) : w0Plain === "unrtf" ? evalSyncUnrtf(optInBytes, allArgs, readFile) : w0Plain === "fmt" ? this.evalSyncFmt(inBytes, allArgs, readFile) : w0Plain === "pr" ? evalSyncPr(optInBytes, allArgs, readFile) : w0Plain === "file" ? (0, file_exports.evalSyncFile)(optInBytes, allArgs, readFile, (p) => this.tryStatMemoryNodeTypeSync(resolvePath(rawState.cwd, p), true)) : w0Plain === "diff3" ? evalSyncDiff3(optInBytes, allArgs, readFile) : w0Plain === "cmp" ? evalSyncCmp(optInBytes, allArgs, readFile) : w0Plain === "diff" ? evalSyncDiff(optInBytes, allArgs, readFile) : w0Plain === "xan" ? evalSyncXan(optInBytes, allArgs, readFile) : w0Plain === "less" || w0Plain === "more" ? (0, less_exports.evalSyncLess)(optInBytes, allArgs, readFile) : w0Plain === "rg" ? evalSyncRg(optInBytes, allArgs, readFile) : w0Plain === "md5sum" || w0Plain === "sha1sum" || w0Plain === "sha224sum" || w0Plain === "sha256sum" || w0Plain === "sha384sum" || w0Plain === "sha512sum" || w0Plain === "cksum" ? (() => {
|
|
90387
|
-
const cs = evalSyncChecksum(w0Plain,
|
|
90389
|
+
const cs = evalSyncChecksum(w0Plain, optInBytes, allArgs, readFile);
|
|
90388
90390
|
return cs !== void 0 && !cs.includes("\0") ? cs : void 0;
|
|
90389
90391
|
})() : w0Plain === "base32" ? (() => {
|
|
90390
90392
|
const b32 = (0, base_exports.evalSyncBase32)(inBytes, allArgs, readFile);
|
|
@@ -34102,11 +34102,11 @@ export class Runtime {
|
|
|
34102
34102
|
"LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION"
|
|
34103
34103
|
]) {
|
|
34104
34104
|
if (lcAll)
|
|
34105
|
-
lines.push(`${cat}
|
|
34105
|
+
lines.push(`${cat}="${lcAll}"`);
|
|
34106
34106
|
else if (getEnv(cat))
|
|
34107
34107
|
lines.push(`${cat}=${getEnv(cat)}`);
|
|
34108
34108
|
else
|
|
34109
|
-
lines.push(`${cat}="${lang}"`);
|
|
34109
|
+
lines.push(`${cat}="${lang || "C.UTF-8"}"`);
|
|
34110
34110
|
}
|
|
34111
34111
|
lines.push(`LC_ALL=${lcAll ?? ""}`);
|
|
34112
34112
|
return lines.join("\n");
|
|
@@ -37741,9 +37741,9 @@ export class Runtime {
|
|
|
37741
37741
|
const optInBytes = hasSingleHereStringRedir ? inBytes : undefined;
|
|
37742
37742
|
const readFile = (p) => this.tryReadMemoryFileViewSync(resolvePath(rawState.cwd, p), true, true);
|
|
37743
37743
|
let csvOut = w0Plain === "csvcut"
|
|
37744
|
-
? evalSyncCsvcut(
|
|
37744
|
+
? evalSyncCsvcut(optInBytes, allArgs, readFile)
|
|
37745
37745
|
: w0Plain === "csvgrep"
|
|
37746
|
-
? evalSyncCsvgrep(
|
|
37746
|
+
? evalSyncCsvgrep(optInBytes, allArgs, readFile)
|
|
37747
37747
|
: w0Plain === "csvlook"
|
|
37748
37748
|
? evalSyncCsvlook(optInBytes, allArgs, readFile)
|
|
37749
37749
|
: w0Plain === "csvjson"
|
|
@@ -38318,7 +38318,7 @@ export class Runtime {
|
|
|
38318
38318
|
: w0Plain === "rg"
|
|
38319
38319
|
? evalSyncRg(optInBytes, allArgs, readFile)
|
|
38320
38320
|
: (w0Plain === "md5sum" || w0Plain === "sha1sum" || w0Plain === "sha224sum" || w0Plain === "sha256sum" || w0Plain === "sha384sum" || w0Plain === "sha512sum" || w0Plain === "cksum")
|
|
38321
|
-
? (() => { const cs = evalSyncChecksum(w0Plain,
|
|
38321
|
+
? (() => { const cs = evalSyncChecksum(w0Plain, optInBytes, allArgs, readFile); return cs !== undefined && !cs.includes("\0") ? cs : undefined; })()
|
|
38322
38322
|
: w0Plain === "base32"
|
|
38323
38323
|
? (() => { const b32 = evalSyncBase32(inBytes, allArgs, readFile); return b32 !== undefined ? sharedSyncPipeDecoder.decode(b32) : undefined; })()
|
|
38324
38324
|
: (w0Plain === "xq" || w0Plain === "yq")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CommandDefinition } from "../safe-bash-contracts/index.js";
|
|
2
2
|
type Algorithm = "sha512" | "sha384" | "sha256" | "sha224" | "sha1" | "md5" | "crc" | "bsd" | "sysv" | "crc32b" | "sm3" | "blake2b" | "sha3";
|
|
3
3
|
export declare function command(name: string, algorithm: Algorithm, maxInputBytes: number): CommandDefinition;
|
|
4
|
-
export declare function evalSyncChecksum(name: string, inBytes: Uint8Array, opArgs: readonly string[], readFileSync?: (p: string) => Uint8Array | undefined, fileOperandName?: string): string | undefined;
|
|
4
|
+
export declare function evalSyncChecksum(name: string, inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (p: string) => Uint8Array | undefined, fileOperandName?: string): string | undefined;
|
|
5
5
|
export {};
|
|
@@ -505,7 +505,7 @@ function digestSync(bytes, algorithm, bits = 512) {
|
|
|
505
505
|
return { hex: String(~crc >>> 0), length };
|
|
506
506
|
}
|
|
507
507
|
function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName) {
|
|
508
|
-
if (inBytes.byteLength > 16384)
|
|
508
|
+
if (inBytes && inBytes.byteLength > 16384)
|
|
509
509
|
return void 0;
|
|
510
510
|
const baseAlg = name === "cksum" ? "crc" : name === "md5sum" ? "md5" : name === "sha1sum" ? "sha1" : name === "sha224sum" ? "sha224" : name === "sha256sum" ? "sha256" : name === "sha384sum" ? "sha384" : name === "sha512sum" ? "sha512" : void 0;
|
|
511
511
|
if (!baseAlg)
|
|
@@ -520,6 +520,8 @@ function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName)
|
|
|
520
520
|
} catch {
|
|
521
521
|
return void 0;
|
|
522
522
|
}
|
|
523
|
+
if (fileOperandName !== void 0 && settings.operands.includes("-"))
|
|
524
|
+
return void 0;
|
|
523
525
|
if (settings.encoding === "raw")
|
|
524
526
|
return void 0;
|
|
525
527
|
let stdinUsed = false;
|
|
@@ -530,6 +532,8 @@ function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName)
|
|
|
530
532
|
return void 0;
|
|
531
533
|
}
|
|
532
534
|
if (filename === "-") {
|
|
535
|
+
if (inBytes === void 0)
|
|
536
|
+
return void 0;
|
|
533
537
|
if (stdinUsed)
|
|
534
538
|
return new Uint8Array(0);
|
|
535
539
|
stdinUsed = true;
|