@visulima/ansi
Version:
ANSI escape codes for some terminal swag.
25 lines (22 loc) • 795 B
JavaScript
import { Buffer } from 'node:buffer';
import { O as OSC, B as BEL } from './packem_shared/constants-CE7WkXh_.mjs';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const image = /* @__PURE__ */ __name((data, options = {}) => {
if (!data) {
return "";
}
let returnValue = `${OSC}1337;File=inline=1`;
if (options.width !== void 0) {
returnValue += `;width=${options.width}`;
}
if (options.height !== void 0) {
returnValue += `;height=${options.height}`;
}
if (options.preserveAspectRatio === false) {
returnValue += ";preserveAspectRatio=0";
}
const base64Data = Buffer.from(data).toString("base64");
return `${returnValue}:${base64Data}${BEL}`;
}, "image");
export { image };