import { AnsiTerminalDisplay } from "./ansi.ts"; import { UIConfig } from "./config.ts"; import { Display } from "./display.ts"; import { TextUI } from "./ui.ts"; import { CanvasTerminalDisplay, DivTerminalDisplay, PreTerminalDisplay, } from "./web.ts"; export { TextUI }; export const UI_DISPLAY_TYPES = { autodetect: undefined, ansi: AnsiTerminalDisplay, web_pre: PreTerminalDisplay, web_div: DivTerminalDisplay, web_canvas: CanvasTerminalDisplay, dummy: Display, } as const; export async function createTextUI( config: Partial, display_type: keyof typeof UI_DISPLAY_TYPES = "autodetect", ): Promise { if (display_type == "autodetect") { if (typeof (window as any).document != "undefined") { display_type = "web_canvas"; } else { display_type = "ansi"; } } var display = new UI_DISPLAY_TYPES[display_type](); var ui = new TextUI(display, config); await ui.init(); return ui; }