react-terminal-plus
Version:
A improved version of `react-terminal` - react-terminal-plus
75 lines (74 loc) • 1.88 kB
TypeScript
import * as React from "react";
type ProcessingStatus = "idle" | "processing" | "success" | "error";
type TerminalState = {
bufferedContent: React.ReactNode;
editorInput: string;
currentLineStatus: ProcessingStatus;
caretPosition: number;
textBeforeCaret: string;
textAfterCaret: string;
commandsHistory: string[];
};
type TerminalActions = {
type: "CLEAR";
} | {
type: "CANCEL";
cancelNode: React.ReactNode;
} | {
type: "SUBMIT";
loaderNode: React.ReactNode;
command: string;
} | {
type: "SUBMIT_SUCCESS";
successNode: React.ReactNode;
} | {
type: "TYPE";
text: string;
} | {
type: "DELETE";
} | {
type: "COPY";
} | {
type: "PASTE";
text: string;
} | {
type: "ARROW_UP";
previousCommand: string;
} | {
type: "ARROW_DOWN";
nextCommand: string;
} | {
type: "ARROW_LEFT";
} | {
type: "ARROW_RIGHT";
} | {
type: "RESET_CARET_POSITION";
} | {
type: "MOVE_CARET_TO_START";
} | {
type: "MOVE_CARET_TO_END";
} | {
type: "FORWARD_WORD";
} | {
type: "BACKWARD_WORD";
} | {
type: "UPDATE_BUFFERED_CONTENT";
payload: React.ReactNode;
};
type TerminalContextState = {
send: React.Dispatch<TerminalActions>;
store: TerminalState;
getPreviousCommand: () => string;
getNextCommand: () => string;
};
type TerminalContextProviderProps = {
children: React.ReactNode;
useLocalStorage?: boolean;
};
export declare function TerminalContextProvider({ children, useLocalStorage, }: TerminalContextProviderProps): React.JSX.Element;
export declare function useTerminal(): TerminalContextState;
declare const _default: {
TerminalContext: React.Context<TerminalContextState>;
TerminalContextProvider: typeof TerminalContextProvider;
};
export default _default;