some ideas for new plugin api

This commit is contained in:
sawka 2024-02-15 09:03:23 -08:00
parent fb7f055449
commit 8af0b0b7ae

41
src/plugins/pluginapi.ts Normal file
View File

@ -0,0 +1,41 @@
// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
type CmdContextType = {
screenid: string;
lineid: string;
linenum: number;
ts: number;
cmdstr: string;
festate: Record<string, string>;
remoteptr: RemotePtrType;
cmdstatus: string;
exitcode: number;
durationms: number;
};
type DataUpdateType = {
pos: number;
data: Uint8Array;
eof: boolean;
};
type PluginApi = {
loadPtyData(): Promise<ExtFile>;
onDataUpdate(datatype: string, cb: (datatype: string, update: DataUpdateType) => void): void;
onCmdDone(cb: (cmdContext: CmdContextType) => void): void;
releaseFocus(): void;
setLineState(lineState: LineStateType): void;
writeRemoteFile(filePath: string, data: Uint8Array): Promise<void>;
readRemoteFile(filePath: string): ExtFile;
streamRemoteFile(filePath: string, cb: (data: DataUpdateType) => void): void;
};
type PluginProps = {
cmdContext: CmdContextType;
pluginDecl: RendererPluginType;
rendererOpts: RendererOpts;
lineState: LineStateType;
focusState: "none" | "selected" | "focused";
api: PluginApi;
};