mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-03 18:47:56 +01:00
fix typescript warnings
This commit is contained in:
parent
35179e06ec
commit
e677455419
19
src/main.tsx
19
src/main.tsx
@ -8,7 +8,7 @@ import dayjs from 'dayjs'
|
|||||||
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
|
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
|
||||||
import cn from "classnames"
|
import cn from "classnames"
|
||||||
import {TermWrap} from "./term";
|
import {TermWrap} from "./term";
|
||||||
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType} from "./types";
|
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType, RemotePtrType} from "./types";
|
||||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||||
import {GlobalModel, GlobalInput, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr} from "./model";
|
import {GlobalModel, GlobalInput, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr} from "./model";
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
|||||||
}
|
}
|
||||||
|
|
||||||
@boundMethod
|
@boundMethod
|
||||||
clickTermBlock(e : any, handler : string) {
|
clickTermBlock(e : any) {
|
||||||
let {sw, line} = this.props;
|
let {sw, line} = this.props;
|
||||||
let model = GlobalModel;
|
let model = GlobalModel;
|
||||||
let termWrap = sw.getTermWrap(line.cmdid);
|
let termWrap = sw.getTermWrap(line.cmdid);
|
||||||
@ -415,7 +415,7 @@ class TextAreaInput extends React.Component<{}, {}> {
|
|||||||
if (e.code == "Enter") {
|
if (e.code == "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!ctrlMod) {
|
if (!ctrlMod) {
|
||||||
setTimeout(() => this.doSubmitCmd(), 0);
|
setTimeout(() => GlobalModel.inputModel.uiSubmitCommand(), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.target.setRangeText("\n", e.target.selectionStart, e.target.selectionEnd, "end");
|
e.target.setRangeText("\n", e.target.selectionStart, e.target.selectionEnd, "end");
|
||||||
@ -466,17 +466,6 @@ class TextAreaInput extends React.Component<{}, {}> {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
@boundMethod
|
|
||||||
doSubmitCmd() {
|
|
||||||
let model = GlobalModel;
|
|
||||||
let inputModel = model.inputModel;
|
|
||||||
let commandStr = inputModel.getCurLine();
|
|
||||||
let hitem = {cmdtext: commandStr};
|
|
||||||
inputModel.clearCurLine();
|
|
||||||
GlobalModel.clearInfoMsg(true);
|
|
||||||
model.submitRawCommand(commandStr, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let model = GlobalModel;
|
let model = GlobalModel;
|
||||||
let inputModel = model.inputModel;
|
let inputModel = model.inputModel;
|
||||||
@ -585,7 +574,7 @@ class CmdInput extends React.Component<{}, {}> {
|
|||||||
<TextAreaInput/>
|
<TextAreaInput/>
|
||||||
</div>
|
</div>
|
||||||
<div className="control cmd-exec">
|
<div className="control cmd-exec">
|
||||||
<div onClick={this.doSubmitCmd} className="button">
|
<div onClick={GlobalModel.inputModel.uiSubmitCommand} className="button">
|
||||||
<span className="icon">
|
<span className="icon">
|
||||||
<i className="fa fa-rocket"/>
|
<i className="fa fa-rocket"/>
|
||||||
</span>
|
</span>
|
||||||
|
40
src/model.ts
40
src/model.ts
@ -4,7 +4,7 @@ import {boundMethod} from "autobind-decorator";
|
|||||||
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData} from "./util";
|
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData} from "./util";
|
||||||
import {TermWrap} from "./term";
|
import {TermWrap} from "./term";
|
||||||
import {v4 as uuidv4} from "uuid";
|
import {v4 as uuidv4} from "uuid";
|
||||||
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, SessionUpdateType, WindowUpdateType, UpdateMessage, LineCmdUpdateType, InfoType, CmdLineUpdateType} from "./types";
|
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType} from "./types";
|
||||||
import {WSControl} from "./ws";
|
import {WSControl} from "./ws";
|
||||||
|
|
||||||
var GlobalUser = "sawka";
|
var GlobalUser = "sawka";
|
||||||
@ -37,7 +37,7 @@ function riToRPtr(ri : RemoteInstanceType) : RemotePtrType {
|
|||||||
if (ri == null) {
|
if (ri == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return {ownerid: ri.ownerid, remoteid: ri.remoteid, name: ri.name};
|
return {ownerid: ri.remoteownerid, remoteid: ri.remoteid, name: ri.name};
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyModsType = {
|
type KeyModsType = {
|
||||||
@ -576,6 +576,16 @@ class InputModel {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@boundMethod
|
||||||
|
uiSubmitCommand() : void {
|
||||||
|
mobx.action(() => {
|
||||||
|
let commandStr = this.getCurLine();
|
||||||
|
this.clearCurLine();
|
||||||
|
GlobalModel.clearInfoMsg(true);
|
||||||
|
GlobalModel.submitRawCommand(commandStr, true);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
setCurLine(val : string) {
|
setCurLine(val : string) {
|
||||||
let hidx = this.historyIndex.get();
|
let hidx = this.historyIndex.get();
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
@ -952,20 +962,21 @@ class Model {
|
|||||||
return this.ws.open.get();
|
return this.ws.open.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
runUpdate(update : UpdateMessage, interactive : boolean) {
|
runUpdate(genUpdate : UpdateMessage, interactive : boolean) {
|
||||||
if ("ptydata64" in update) {
|
if ("ptydata64" in genUpdate) {
|
||||||
let ptyMsg : PtyDataUpdateType = update;
|
let ptyMsg : PtyDataUpdateType = genUpdate;
|
||||||
let activeScreen = this.getActiveScreen();
|
let activeScreen = this.getActiveScreen();
|
||||||
if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
|
if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activeScreen.updatePtyData(ptyMsg);
|
activeScreen.updatePtyData(ptyMsg);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
let update : ModelUpdateType = genUpdate;
|
||||||
if ("sessions" in update) {
|
if ("sessions" in update) {
|
||||||
let sessionUpdateMsg : SessionUpdateType = update;
|
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
let oldActiveScreen = this.getActiveScreen();
|
let oldActiveScreen = this.getActiveScreen();
|
||||||
genMergeData(this.sessionList, sessionUpdateMsg.sessions, (s : Session) => s.sessionId, (sdata : SessionDataType) => sdata.sessionid, (sdata : SessionDataType) => new Session(sdata), (s : Session) => s.sessionIdx.get());
|
genMergeData(this.sessionList, update.sessions, (s : Session) => s.sessionId, (sdata : SessionDataType) => sdata.sessionid, (sdata : SessionDataType) => new Session(sdata), (s : Session) => s.sessionIdx.get());
|
||||||
if (update.activesessionid) {
|
if (update.activesessionid) {
|
||||||
this.activateSession(update.activesessionid);
|
this.activateSession(update.activesessionid);
|
||||||
}
|
}
|
||||||
@ -983,28 +994,25 @@ class Model {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
if ("line" in update) {
|
if ("line" in update) {
|
||||||
let lineMsg : LineCmdUpdateType = update;
|
if (update.line != null) {
|
||||||
if (lineMsg.line != null) {
|
this.addLineCmd(update.line, update.cmd, interactive);
|
||||||
this.addLineCmd(lineMsg.line, lineMsg.cmd, interactive);
|
|
||||||
}
|
}
|
||||||
else if (lineMsg.line == null && lineMsg.cmd != null) {
|
else if (update.line == null && update.cmd != null) {
|
||||||
this.updateCmd(lineMsg.cmd);
|
this.updateCmd(update.cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ("cmd" in update) {
|
else if ("cmd" in update) {
|
||||||
this.updateCmd(update.cmd);
|
this.updateCmd(update.cmd);
|
||||||
}
|
}
|
||||||
if ("window" in update) {
|
if ("window" in update) {
|
||||||
let winMsg : WindowUpdateType = update;
|
this.updateWindow(update.window, false);
|
||||||
this.updateWindow(winMsg.window, false);
|
|
||||||
}
|
}
|
||||||
if ("info" in update) {
|
if ("info" in update) {
|
||||||
let info : InfoType = update.info;
|
let info : InfoType = update.info;
|
||||||
this.flashInfoMsg(info, info.timeoutms);
|
this.flashInfoMsg(info, info.timeoutms);
|
||||||
}
|
}
|
||||||
if ("cmdline" in update) {
|
if ("cmdline" in update) {
|
||||||
let cmdline : CmdLineUpdateType = update.cmdline;
|
this.inputModel.updateCmdLine(update.cmdline);
|
||||||
this.inputModel.updateCmdLine(cmdline);
|
|
||||||
}
|
}
|
||||||
// console.log("run-update>", Date.now(), interactive, update);
|
// console.log("run-update>", Date.now(), interactive, update);
|
||||||
}
|
}
|
||||||
|
31
src/types.ts
31
src/types.ts
@ -196,15 +196,15 @@ type PtyDataUpdateType = {
|
|||||||
ptydatalen : number,
|
ptydatalen : number,
|
||||||
};
|
};
|
||||||
|
|
||||||
type SessionUpdateType = {
|
type ModelUpdateType = {
|
||||||
sessions : SessionDataType[],
|
sessions? : SessionDataType[],
|
||||||
activesessionid? : string,
|
activesessionid? : string,
|
||||||
};
|
window? : WindowDataType,
|
||||||
|
line? : LineType,
|
||||||
type LineCmdUpdateType = {
|
cmd? : CmdDataType,
|
||||||
line : LineType,
|
info? : InfoType,
|
||||||
cmd : CmdDataType,
|
cmdline? : CmdLineUpdateType,
|
||||||
remove : boolean,
|
remote? : RemoteType,
|
||||||
};
|
};
|
||||||
|
|
||||||
type CmdLineUpdateType = {
|
type CmdLineUpdateType = {
|
||||||
@ -212,17 +212,6 @@ type CmdLineUpdateType = {
|
|||||||
insertpos : number,
|
insertpos : number,
|
||||||
};
|
};
|
||||||
|
|
||||||
type InfoUpdateType = {
|
|
||||||
cmdline : CmdLineUpdateType,
|
|
||||||
info : InfoType,
|
|
||||||
};
|
|
||||||
|
|
||||||
type UpdateMessage = PtyDataUpdateType | SessionUpdateType | LineCmdUpdateType | InfoUpdateType;
|
|
||||||
|
|
||||||
type WindowUpdateType = {
|
|
||||||
window: WindowDataType,
|
|
||||||
}
|
|
||||||
|
|
||||||
type InfoType = {
|
type InfoType = {
|
||||||
infotitle? : string,
|
infotitle? : string,
|
||||||
infomsg? : string,
|
infomsg? : string,
|
||||||
@ -233,4 +222,6 @@ type InfoType = {
|
|||||||
timeoutms? : number,
|
timeoutms? : number,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, SessionUpdateType, WindowUpdateType, UpdateMessage, LineCmdUpdateType, InfoType, CmdLineUpdateType, RemotePtrType};
|
type UpdateMessage = PtyDataUpdateType | ModelUpdateType;
|
||||||
|
|
||||||
|
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType};
|
||||||
|
Loading…
Reference in New Issue
Block a user