mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-24 08:33:50 +01:00
commit
736bb2877a
4
dist/main.bundle.js
vendored
4
dist/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main.bundle.js.map
vendored
2
dist/main.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
@ -56,11 +56,12 @@ const lineClass = (classes: Record<string, string>, s: string): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
text: string;
|
text: unknown;
|
||||||
color: "primary" | "error" | "success" | "info" | "warn";
|
color: "primary" | "error" | "success" | "info" | "warn";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ANSIITypography = React.memo((props: IProps): React.ReactElement => {
|
export const ANSIITypography = React.memo((props: IProps): React.ReactElement => {
|
||||||
|
const text = String(props.text);
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const parts = [];
|
const parts = [];
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ export const ANSIITypography = React.memo((props: IProps): React.ReactElement =>
|
|||||||
index: 0,
|
index: 0,
|
||||||
groups: { code: null },
|
groups: { code: null },
|
||||||
};
|
};
|
||||||
const matches = [INITIAL, ...props.text.matchAll(ANSI_ESCAPE), null];
|
const matches = [INITIAL, ...text.matchAll(ANSI_ESCAPE), null];
|
||||||
if (matches.length > 2) {
|
if (matches.length > 2) {
|
||||||
matches.slice(0, -1).forEach((m, i) => {
|
matches.slice(0, -1).forEach((m, i) => {
|
||||||
const n = matches[i + 1];
|
const n = matches[i + 1];
|
||||||
@ -78,8 +79,8 @@ export const ANSIITypography = React.memo((props: IProps): React.ReactElement =>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const startIndex = m.index + m[0].length;
|
const startIndex = m.index + m[0].length;
|
||||||
const stopIndex = n ? n.index : props.text.length;
|
const stopIndex = n ? n.index : text.length;
|
||||||
const partText = props.text.slice(startIndex, stopIndex);
|
const partText = text.slice(startIndex, stopIndex);
|
||||||
if (startIndex !== stopIndex) {
|
if (startIndex !== stopIndex) {
|
||||||
// Don't generate "empty" spans
|
// Don't generate "empty" spans
|
||||||
parts.push({ code: m.groups.code, text: partText });
|
parts.push({ code: m.groups.code, text: partText });
|
||||||
@ -88,7 +89,7 @@ export const ANSIITypography = React.memo((props: IProps): React.ReactElement =>
|
|||||||
}
|
}
|
||||||
if (parts.length === 0) {
|
if (parts.length === 0) {
|
||||||
// For example, if the string was empty or there were no escape sequence matches
|
// For example, if the string was empty or there were no escape sequence matches
|
||||||
parts.push({ code: null, text: props.text });
|
parts.push({ code: null, text: text });
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Typography classes={{ root: lineClass(classes, props.color) }} paragraph={false}>
|
<Typography classes={{ root: lineClass(classes, props.color) }} paragraph={false}>
|
||||||
|
Loading…
Reference in New Issue
Block a user