svg-term
Version:
Share terminal sessions via SVG and CSS
30 lines • 1.74 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const React = __importStar(require("react"));
const server_1 = require("react-dom/server");
const load_cast_1 = require("./load-cast");
const default_theme_1 = require("./default-theme");
const svg_term_1 = require("./svg-term");
function render(input, options) {
const cast = typeof input === "string" ? load_cast_1.loadCast(input, options) : input;
const theme = Object.assign({}, (options.theme || default_theme_1.defaultTheme));
theme.fontFamily =
"fontFamily" in theme ? theme.fontFamily : default_theme_1.defaultTheme.fontFamily;
theme.fontSize = "fontSize" in theme ? theme.fontSize : default_theme_1.defaultTheme.fontSize;
theme.lineHeight =
"lineHeight" in theme ? theme.lineHeight : default_theme_1.defaultTheme.lineHeight;
const paddingX = typeof options.paddingX === "number" ? options.paddingX : 0;
const paddingY = typeof options.paddingY === "number" ? options.paddingY : 0;
const decorations = typeof options.window === "boolean" ? options.window : false;
const cursor = typeof options.cursor === "boolean" ? options.cursor : false;
return server_1.renderToStaticMarkup(React.createElement(svg_term_1.SvgTerm, { cast: cast, theme: theme, paddingX: paddingX, paddingY: paddingY, decorations: decorations, cursor: cursor, height: options.height }));
}
exports.render = render;
//# sourceMappingURL=render.js.map