Sync code

This commit is contained in:
LitoMore 2022-10-10 14:41:45 +08:00
parent ef53fde412
commit 79e9185fd6
No known key found for this signature in database
GPG key ID: B8653F9344667340
5 changed files with 80 additions and 53 deletions

View file

@ -180,6 +180,49 @@ export interface ConvertColor {
hexToAnsi(hex: string): number;
}
/**
Basic modifier names.
*/
export type ModifierName = keyof Modifier;
/**
Basic foreground color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
*/
export type ForegroundColorName = keyof ForegroundColor;
/**
Basic background color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
*/
export type BackgroundColorName = keyof BackgroundColor;
/**
Basic color names. The combination of foreground and background color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
*/
export type ColorName = ForegroundColorName | BackgroundColorName;
/**
Basic modifier names.
*/
export const modifierNames: readonly ModifierName[];
/**
Basic foreground color names.
*/
export const foregroundColorNames: readonly ForegroundColorName[];
/**
Basic background color names.
*/
export const backgroundColorNames: readonly BackgroundColorName[];
/*
Basic color names. The combination of foreground and background color names.
*/
export const colorNames: readonly ColorName[];
declare const ansiStyles: {
readonly modifier: Modifier;
readonly color: ColorBase & ForegroundColor;
@ -187,9 +230,4 @@ declare const ansiStyles: {
readonly codes: ReadonlyMap<number, number>;
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
declare const modifiers: readonly Modifier[];
declare const foregroundColors: readonly ForegroundColor[];
declare const backgroundColors: readonly BackgroundColor[];
declare const colors: readonly Color[];
export default ansiStyles;

View file

@ -214,8 +214,9 @@ function assembleStyles() {
}
const ansiStyles = assembleStyles();
export const modifiers = Object.keys(styles.modifier);
export const foregroundColors = Object.keys(styles.color);
export const backgroundColors = Object.keys(styles.bgColor);
export const modifierNames = Object.keys(styles.modifier);
export const foregroundColorNames = Object.keys(styles.color);
export const backgroundColorNames = Object.keys(styles.bgColor);
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
export default ansiStyles;