//// // temporary hack for browser commands import type { CommandOutput } from "../shared/types" import { scrollback, content } from "./dom" import { resize } from "./resize" import { autoScroll } from "./scrollback" import { sessionId } from "./session" import { send } from "./websocket" import { focusInput } from "./focus" export const commands: string[] = [] export const browserCommands: Record void | Promise | CommandOutput> = { "browser-session": () => sessionId, clear: () => scrollback.innerHTML = "", commands: () => { return { html: "
" + commands.map(cmd => `${cmd}`).join("") + "
" } }, fullscreen: () => document.body.requestFullscreen(), mode: (mode?: string) => { if (!mode) { mode = document.body.dataset.mode === "tall" ? "cinema" : "tall" send({ type: "ui:mode", data: mode }) } content.style.display = "" document.body.dataset.mode = mode resize() autoScroll() focusInput() }, reload: () => window.location.reload(), } export function cacheCommands(cmds: string[]) { commands.length = 0 commands.push(...cmds) commands.push(...Object.keys(browserCommands)) commands.sort() }