//#region src/capabilities/detect.d.ts /** An RGB color with 8-bit channels, as reported by the terminal. */ type RgbColor = { r: number; g: number; b: number; }; type TerminalAppearance = "dark" | "light"; type Multiplexer = "tmux" | "screen" | "zellij"; /** Color support level: 0 = none, 1 = 16 colors, 2 = 256 colors, 3 = truecolor. */ type ColorSupportLevel = 0 | 1 | 2 | 3; /** The chalk-compatible color support shape. */ type ColorSupport = { readonly level: ColorSupportLevel; readonly hasBasic: boolean; readonly has256: boolean; readonly has16m: boolean; }; type ColorInfo = ColorSupport | false; type TerminalIdentity = { /** Normalized terminal name (`"kitty"`, `"iterm"`, `"wezterm"`, …), or `undefined` when unknown. `queryTerminal` can refine this with the terminal's own XTVERSION answer. */ name: string | undefined; /** The terminal's version, when the environment reports one. */ version: string | undefined; /** The raw `TERM` environment variable. */ term: string | undefined; /** The multiplexer the app is running under, if any. Note that inside a multiplexer, capabilities reflect the multiplexer — not the outer terminal. */ multiplexer: Multiplexer | undefined; }; type PixelGeometry = { /** Text area size in pixels (XTWINOPS 14). */ textArea: { width: number; height: number; } | undefined; /** Size of a single character cell in pixels (XTWINOPS 16). */ cell: { width: number; height: number; } | undefined; }; type Capabilities = { /** Current terminal dimensions in cells, plus pixel geometry once the terminal has answered the query. `source` tells where the cell dimensions come from. `"pty"` is the stream's own `columns`/`rows`, updated by the OS on SIGWINCH — which says nothing about whether the emulator has finished rewrapping its screen. `"terminal"` is the emulator's in-band size report (mode 2048), which arrives in the input stream after the rewrap and so describes the screen exactly as later output will find it. While the terminal reports, its size wins over the stream's. */ size: { columns: number; rows: number; pixels: PixelGeometry | undefined; source: "pty" | "terminal"; }; platform: NodeJS.Platform; /** Running under a CI provider. */ ci: boolean; /** Running over an SSH connection. */ ssh: boolean; screenReader: boolean; /** Same detection `render()` uses: stdout is a TTY and not CI. */ interactive: boolean; /** Whether the terminal window has focus. Requires focus events (mode 1004), which the capabilities store enables automatically while it has subscribers; `undefined` until the first focus report arrives. */ focused: boolean | undefined; terminal: TerminalIdentity; color: { level: ColorSupportLevel; /** The same fact as bits per color: 1, 4, 8, or 24. */ depth: 1 | 4 | 8 | 24; trueColor: boolean; }; theme: { /** The terminal's own appearance. After `queryTerminal` this is derived from the actual background color's luminance (a dark terminal theme on a light OS stays `"dark"`); before that it's a `COLORFGBG` guess. */ appearance: TerminalAppearance | undefined; /** The operating system's color preference, from the color scheme report. Independent of the terminal's own theme — only available after `queryTerminal` on terminals that support the report. */ systemAppearance: TerminalAppearance | undefined; /** The user's configured foreground/background/cursor colors and 16-color palette. Only available after `queryTerminal`. */ foreground: RgbColor | undefined; background: RgbColor | undefined; cursor: RgbColor | undefined; palette: RgbColor[] | undefined; }; /** Feature support. Fields typed `boolean | undefined` are only knowable by asking the terminal — they stay `undefined` until `queryTerminal` has answered (see `TerminalQueryResult` for what each means). */ supports: { color: boolean; hyperlinks: boolean; unicode: boolean; alternateScreen: boolean; kittyKeyboard: boolean | undefined; kittyGraphics: boolean | undefined; sixel: boolean | undefined; focusEvents: boolean | undefined; sgrMouse: boolean | undefined; sgrPixelMouse: boolean | undefined; bracketedPaste: boolean | undefined; synchronizedOutput: boolean | undefined; graphemeClustering: boolean | undefined; colorSchemeUpdates: boolean | undefined; inBandResize: boolean | undefined; }; }; declare function detectTerminal(): TerminalIdentity; type DetectStream = { isTTY?: boolean; }; /** Detects the color support level for a stream from the environment. Purely env-derived — the terminal query can upgrade this to truecolor when the terminal confirms it via XTGETTCAP. */ declare function detectColorLevel(stream?: DetectStream): ColorSupportLevel; /** The color level in chalk's `ColorInfo` shape. */ declare function createSupportsColor(stream?: DetectStream): ColorInfo; /** Detects OSC 8 hyperlink support for a stream from the environment. */ declare function detectHyperlinkSupport(stream?: DetectStream): boolean; /** Detects whether the terminal renders unicode reliably. */ declare function detectUnicodeSupport(): boolean; type CapabilityStdout = DetectStream & { columns?: number; rows?: number; }; type DetectOptions = { stdout?: CapabilityStdout; }; /** Takes a snapshot of everything knowable about the terminal from streams and environment variables. The environment-derived parts are computed once per stream and cached; size and theme are read fresh on every call. Fields that require asking the terminal itself start as `undefined` — run `queryTerminal` and merge with `applyTerminalQuery` to fill them in, or use the `useCapabilities` hook which does both. */ declare function detectCapabilities({ stdout }?: DetectOptions): Capabilities; //#endregion export { Multiplexer as a, TerminalAppearance as c, detectCapabilities as d, detectColorLevel as f, detectUnicodeSupport as h, ColorSupportLevel as i, TerminalIdentity as l, detectTerminal as m, ColorInfo as n, PixelGeometry as o, detectHyperlinkSupport as p, ColorSupport as r, RgbColor as s, Capabilities as t, createSupportsColor as u };