astro-ghostcms/.pnpm-store/v3/files/a0/3b68d0460f75226278fa87d6cad...

39 lines
1.4 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformToBrowserStyle = exports.transformToNodeStyle = void 0;
var utils_1 = require("./utils");
function transformToNodeStyle(style) {
if (typeof style === 'string') {
return "\u001B[" + handleUndefined(utils_1.stringColorToAnsiColor('color', style)).replace(/;$/, '') + "m";
}
else {
var codes = "" + addBoldStyle(style) + handleUndefined(utils_1.stringColorToAnsiColor('color', style.color)) + handleUndefined(utils_1.stringColorToAnsiColor('background', style.background));
return "\u001B[" + codes.replace(/;$/, '') + "m";
}
}
exports.transformToNodeStyle = transformToNodeStyle;
function addBoldStyle(style) {
return style['font-weight'] === 'bold' ? utils_1.ANSICodes('bold') + ";" : '';
}
function handleUndefined(input) {
return input ? input : '';
}
function transformToBrowserStyle(style) {
if (style == undefined)
return '';
if (typeof style === 'string') {
return "color: " + style + ";";
}
var out = '';
if (!('display' in style)) {
out += "display: inline-block; ";
}
for (var key in style) {
if (Object.prototype.hasOwnProperty.call(style, key)) {
out += key + ": " + style[key] + "; ";
}
}
return out;
}
exports.transformToBrowserStyle = transformToBrowserStyle;