js-log-lib
Version:
浏览器和 node 共用的 log 样式,行为控制工具,可以自定义输出样式,其核心原理是采用了 ANSI 指令以及 css 属性,更多用法可以参照 ANSI 的详细介绍
38 lines (37 loc) • 1.16 kB
TypeScript
import { ANSIParams } from "./static.js";
export type IColorStr = keyof typeof ANSIParams.color;
export type IColor = IRGB | IColorStr;
export type ITextStyle = keyof typeof ANSIParams.textStyle;
export type IDirect = keyof typeof ANSIParams.cursor.direct;
export type ICursor = keyof Omit<typeof ANSIParams.cursor, "direct">;
export type IGlobalOpts = Partial<{
text: string;
reset: boolean;
type: string;
split: boolean;
color: IColor[] | IColor;
textStyle: ITextStyle[] | ITextStyle;
cursor: ICursor;
move: IMoveParams;
scroll: number;
style: Partial<CSSStyleDeclaration>;
}>;
export type IOpts = Omit<IGlobalOpts, "type" | "split">;
export type IColorMode = keyof typeof ANSIParams.colorMode;
export type IColorType = keyof typeof ANSIParams.colorType;
export type IRGB = {
red?: string | number;
green?: string | number;
blue?: string | number;
type?: IColorType;
mode?: IColorMode;
color?: string | number;
};
export type IPosition = {
col: number | string;
row: number | string;
};
export type IMoveParams = {
direct: IDirect;
position: IPosition | number | string;
};