UNPKG

dax

Version:

Cross platform shell tools inspired by zx.

47 lines 1.97 kB
import { type TextItem } from "../../deps/jsr.io/@david/console-static-text/0.3.4/mod.js"; import { stdin } from "../../deps/jsr.io/@david/shell/0.6.0/mod.js"; export declare enum Keys { Up = 0, Down = 1, Left = 2, Right = 3, Enter = 4, Space = 5, Backspace = 6 } export declare function readKeys(reader: Pick<typeof stdin, "read">, signal: AbortSignal | undefined): AsyncGenerator<string | Keys, void, unknown>; export declare function hideCursor(): void; export declare function showCursor(): void; export declare let isOutputTty: boolean; export declare function setNotTtyForTesting(): void; export declare function resultOrExit<T>(result: T | undefined): T; /** For `maybe*` variants: convert an abort rejection into `undefined`, so * a cancelled signal looks the same to callers as a ctrl+c. Callers that * need to distinguish can check `signal.aborted`. */ export declare function undefinedOnAbort<T>(signal: AbortSignal | undefined, p: Promise<T>): Promise<T | undefined>; /** * Result of a selection prompt. Coerces to its `index` so it can be used * directly as an array index for backwards compatibility. */ export declare class SelectionItem { readonly index: number; readonly value: string; constructor(index: number, value: string); [Symbol.toPrimitive](hint: string): number | string; toString(): string; valueOf(): number; } export interface SelectionOptions<TReturn> { message: string; render: () => TextItem[]; noClear: boolean | undefined; /** * Signal that cancels the prompt. When aborted, the returned promise * rejects with `signal.reason`. The `maybe*` variants convert this * rejection into a resolved `undefined`. */ signal?: AbortSignal; onKey: (key: string | Keys) => TReturn | undefined; } export declare function createSelection<TReturn>(options: SelectionOptions<TReturn>): Promise<TReturn | undefined>; //# sourceMappingURL=utils.d.ts.map