Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ansiToJSON(input, useClasses) {
const classes = useClasses == null || !useClasses ? false : useClasses;
return Anser.ansiToJson(escapeCarriageReturn(input), {
use_classes: classes,
json: true,
remove_empty: true,
});
}
function ansiToJSON(input) {
input = escapeCarriageReturn(input);
return ansiToJson(input, {
json: true,
remove_empty: true
});
}
renderMessageContent({ msg, level }) {
if (!hasAnsi(msg)) {
return (
<div>
{msg}
</div>
);
}
const chunks = ansiToJson(msg, {
remove_empty: true,
});
const content = chunks.map(chunk => {
const style = {};
if (chunk.bg) {
style.backgroundColor = Constants.ansiColorOverrides[chunk.bg] || `rgb(${chunk.bg})`;
}
if (chunk.fg) {
style.color = Constants.ansiColorOverrides[chunk.fg] || `rgb(${chunk.fg})`;
}
return <span style="{style}">{chunk.content}</span>;
});
return <div>{content}</div>;
}
function ansiToJSON(input: string, use_classes = false) {
input = escapeCarriageReturn(input);
return Anser.ansiToJson(input, {
json: true,
remove_empty: true,
use_classes
});
}
function ansiToJSON(input: string) {
input = escapeCarriageReturn(input);
return ansiToJson(input, {
json: true,
remove_empty: true
});
}
const ansiEnhancer = (line) => {
return Anser.ansiToJson(
line.text,
{ use_classes: true }
).map((p) => {
const { content, fg, bg, decoration } = p;
const classes = classNames({
[`${fg}`]: !!fg,
[`${bg}-bg`]: bg,
[`ansi-${decoration}`]: decoration
});
return {
content,
classes
};
});
};