@binaryandthread/cli 0.2.0 → 0.2.1
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/bin.js +3 -3
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-NJ3DW5AX.js → chunk-AP5ARNWU.js} +12 -3
- package/dist/{chunk-NJ3DW5AX.js.map → chunk-AP5ARNWU.js.map} +1 -1
- package/dist/{interactive-5PBJCENZ.js → interactive-4XWSUOOK.js} +2 -2
- package/package.json +4 -1
- /package/dist/{interactive-5PBJCENZ.js.map → interactive-4XWSUOOK.js.map} +0 -0
|
@@ -1094,6 +1094,14 @@ ${urlFloor(blobUrl)}`;
|
|
|
1094
1094
|
}
|
|
1095
1095
|
var IMAGE_FETCH_TIMEOUT_MS = 5e3;
|
|
1096
1096
|
var IMAGE_BYTE_CAP = 2 * 1024 * 1024;
|
|
1097
|
+
function isWebp(buf) {
|
|
1098
|
+
return buf.length >= 12 && buf.toString("ascii", 0, 4) === "RIFF" && buf.toString("ascii", 8, 12) === "WEBP";
|
|
1099
|
+
}
|
|
1100
|
+
async function toPng(buf) {
|
|
1101
|
+
if (!isWebp(buf)) return buf;
|
|
1102
|
+
const sharp = (await import("sharp")).default;
|
|
1103
|
+
return sharp(buf).png().toBuffer();
|
|
1104
|
+
}
|
|
1097
1105
|
async function defaultRender(url, opts) {
|
|
1098
1106
|
const mod = await import("terminal-image");
|
|
1099
1107
|
const terminalImage = mod.default ?? mod;
|
|
@@ -1117,10 +1125,11 @@ async function defaultRender(url, opts) {
|
|
|
1117
1125
|
if (Number.isFinite(declaredLen) && declaredLen > cap) {
|
|
1118
1126
|
throw new Error("blob exceeds byte cap (declared)");
|
|
1119
1127
|
}
|
|
1120
|
-
const
|
|
1121
|
-
if (
|
|
1128
|
+
const rawBuf = Buffer.from(await res.arrayBuffer());
|
|
1129
|
+
if (rawBuf.byteLength === 0 || rawBuf.byteLength > cap) {
|
|
1122
1130
|
throw new Error("blob empty or exceeds byte cap");
|
|
1123
1131
|
}
|
|
1132
|
+
const buf = await toPng(rawBuf);
|
|
1124
1133
|
return bufferFn(buf, {
|
|
1125
1134
|
height: opts.height ?? DEFAULT_RENDER_HEIGHT,
|
|
1126
1135
|
preserveAspectRatio: true,
|
|
@@ -1410,4 +1419,4 @@ export {
|
|
|
1410
1419
|
runStage,
|
|
1411
1420
|
registerStage
|
|
1412
1421
|
};
|
|
1413
|
-
//# sourceMappingURL=chunk-
|
|
1422
|
+
//# sourceMappingURL=chunk-AP5ARNWU.js.map
|