/** * Core types and interfaces for the termenv library. * Port of github.com/muesli/termenv types to TypeScript. */ import { type Color as ColorfulColor } from '@tsports/go-colorful'; /** Standard ANSI escape sequences */ export declare const ESC = "\u001B"; export declare const BEL = "\u0007"; export declare const CSI = "\u001B["; export declare const OSC = "\u001B]"; export declare const ST = "\u001B\\"; /** Foreground and Background sequence codes */ export declare const Foreground = "38"; export declare const Background = "48"; /** Error types */ export declare class TermEnvError extends Error { constructor(message: string); } export declare class InvalidColorError extends TermEnvError { constructor(message?: string); } export declare class StatusReportError extends TermEnvError { constructor(message?: string); } /** * Color is an interface implemented by all colors that can be converted to an ANSI sequence. */ export interface Color { /** Returns the ANSI Sequence for the color */ sequence(bg: boolean): string; /** String representation of the color */ toString(): string; } /** * Profile is a color profile: Ascii, ANSI, ANSI256, or TrueColor. */ export declare enum Profile { TrueColor = 0,// 24-bit color profile ANSI256 = 1,// 8-bit color profile ANSI = 2,// 4-bit color profile Ascii = 3 } /** * NoColor is a nop for terminals that don't support colors. */ export declare class NoColor implements Color { sequence(_bg: boolean): string; toString(): string; } /** * ANSIColor is a color (0-15) as defined by the ANSI Standard. */ export declare class ANSIColor implements Color { value: number; constructor(value: number); sequence(bg: boolean): string; toString(): string; } /** * ANSI256Color is a color (16-255) as defined by the ANSI Standard. */ export declare class ANSI256Color implements Color { value: number; constructor(value: number); sequence(bg: boolean): string; toString(): string; } /** * RGBColor is a hex-encoded color, e.g. "#abcdef". */ export declare class RGBColor implements Color { hex: string; constructor(hex: string); sequence(bg: boolean): string; private parseHexLenient; toString(): string; } /** * Convert a Color to a colorful.Color */ export declare function convertToRGB(c: Color): ColorfulColor | null; /** * Environ interface for getting environment variables */ export interface Environ { environ(): string[]; getenv(key: string): string; } /** * Default environment implementation using process.env */ export declare class ProcessEnviron implements Environ { environ(): string[]; getenv(key: string): string; } /** * OutputOption sets an option on Output. * Note: Uses generic to allow cross-import with OutputImpl */ export type OutputOption = (output: T) => void; /** * Output represents a terminal output. */ export interface Output { profile: Profile; writer(): NodeJS.WriteStream | NodeJS.WritableStream; environ: Environ; assumeTTY: boolean; unsafe: boolean; cache: boolean; /** Write data to the output */ write(data: Uint8Array): Promise; writeString(s: string): Promise; /** Check if output is a TTY */ isTTY(): boolean; /** Color profile and environment methods */ colorProfile(): Profile; envColorProfile(): Profile; envNoColor(): boolean; foregroundColor(): Color; backgroundColor(): Color; hasDarkBackground(): boolean; /** Create a styled string */ string(...strings: string[]): unknown; /** Create a Color from a string */ color(s: string): Color | null; moveCursor(row: number, column: number): void; cursorUp(n?: number): void; cursorDown(n?: number): void; cursorForward(n?: number): void; cursorBack(n?: number): void; saveCursorPosition(): void; restoreCursorPosition(): void; hideCursor(): void; showCursor(): void; clearScreen(): void; clearLine(): void; clearLines(n: number): void; altScreen(): void; exitAltScreen(): void; saveScreen(): void; restoreScreen(): void; reset(): void; setForegroundColor(color: Color): void; setBackgroundColor(color: Color): void; setCursorColor(color: Color): void; setWindowTitle(title: string): void; enableMouse(): void; disableMouse(): void; enableMousePress(): void; disableMousePress(): void; enableMouseHilite(): void; disableMouseHilite(): void; enableMouseCellMotion(): void; disableMouseCellMotion(): void; enableMouseAllMotion(): void; disableMouseAllMotion(): void; enableMouseExtendedMode(): void; disableMouseExtendedMode(): void; enableMousePixelsMode(): void; disableMousePixelsMode(): void; enableBracketedPaste(): void; disableBracketedPaste(): void; changeScrollingRegion(top: number, bottom: number): void; insertLines(n: number): void; deleteLines(n: number): void; hyperlink(link: string, name: string): void; notify(title: string, body: string): void; } /** * File interface for compatibility (deprecated in Go version) */ export interface File { fd(): number; write(data: Uint8Array): Promise; read(buffer: Uint8Array): Promise; } export declare const ansiHex: { [key: number]: string; }; export declare const ANSIBlack: ANSIColor; export declare const ANSIRed: ANSIColor; export declare const ANSIGreen: ANSIColor; export declare const ANSIYellow: ANSIColor; export declare const ANSIBlue: ANSIColor; export declare const ANSIMagenta: ANSIColor; export declare const ANSICyan: ANSIColor; export declare const ANSIWhite: ANSIColor; export declare const ANSIBrightBlack: ANSIColor; export declare const ANSIBrightRed: ANSIColor; export declare const ANSIBrightGreen: ANSIColor; export declare const ANSIBrightYellow: ANSIColor; export declare const ANSIBrightBlue: ANSIColor; export declare const ANSIBrightMagenta: ANSIColor; export declare const ANSIBrightCyan: ANSIColor; export declare const ANSIBrightWhite: ANSIColor; //# sourceMappingURL=types.d.ts.map