@squid-dev/cc-web-term
Version:
A ComputerCraft terminal for the internet
67 lines (66 loc) • 2.06 kB
TypeScript
import { Component, type ComponentChild } from "preact";
import type { ComputerActionable, Semaphore } from "../computer";
import type { TerminalData } from "./data";
declare const enum RecordingState {
None = 0,
Recording = 1,
Rendering = 2
}
/**
* Properties for the current terminal
*/
export type TerminalProps = {
id: number | null; /** The computer's ID */
label: string | null; /** The computer's label */
on: boolean; /** Whether the computer is on */
computer: ComputerActionable; /** The computer to fire events back to */
changed: Semaphore; /** A semaphore which is signaled when the terminal changes */
terminal: TerminalData; /** The terminal to draw. */
focused: boolean; /** Whether this component is considered focused. */
font: string; /** The font to draw the terminal with */
};
type TerminalState = {
recording: RecordingState;
progress: number;
};
export declare class Terminal extends Component<TerminalProps, TerminalState> {
private readonly canvasElem;
private canvasContext?;
private readonly inputElem;
private readonly wrapperElem;
private changed;
private lastBlink;
private mounted;
private drawQueued;
private readonly vdom;
private lastX;
private lastY;
private gif;
private lastGifFrame;
constructor(props: TerminalProps, context: unknown);
componentDidMount(): void;
componentWillUnmount(): void;
render({ id, label, on }: TerminalProps, { recording, progress }: TerminalState): ComponentChild;
componentDidUpdate(): void;
queueDraw(): void;
private draw;
private onResized;
private paste;
private addGifFrame;
private onPaste;
private convertMousePos;
private onMouse;
private onMouseWheel;
private onEventDefault;
private onKey;
private onInput;
private onTerminate;
private onChanged;
private onPowerOff;
private onPowerOn;
private onScreenshot;
private onRecord;
private makeFullscreen;
private onDrop;
}
export {};