mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-23 16:58:27 +01:00
ws merging working
This commit is contained in:
parent
7609909e6d
commit
62f6be22ea
24
src/types.ts
24
src/types.ts
@ -537,4 +537,26 @@ type WebFullScreen = {
|
||||
vts : number,
|
||||
}
|
||||
|
||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts, RendererContext, WindowSize, RendererModel, PtyDataType, BookmarkType, ClientDataType, PlaybookType, PlaybookEntryType, HistoryViewDataType, RenderModeType, AlertMessageType, HistorySearchParams, ScreenLinesType, FocusTypeStrs, HistoryTypeStrs, RendererOpts, RendererPluginType, SimpleBlobRendererComponent, RendererModelContainerApi, RendererModelInitializeParams, RendererOptsUpdate, ClientMigrationInfo, WebShareOpts, RemoteStatusTypeStrs, WebFullScreen, WebScreen, WebLine, WebCmd, RemoteTermContext, TermContextUnion, WebRemote};
|
||||
type PtyDataUpdate = {
|
||||
screenid : string,
|
||||
lineid : string,
|
||||
ptypos : number,
|
||||
data : string,
|
||||
};
|
||||
|
||||
type WebScreenUpdate = {
|
||||
type : string,
|
||||
screenid : string,
|
||||
screen : WebScreen,
|
||||
lines : WebLine[],
|
||||
cmds : WebCmd[],
|
||||
ptydata : PtyDataUpdate[],
|
||||
};
|
||||
|
||||
type WebShareWSMessage = {
|
||||
type : string,
|
||||
screenid : string,
|
||||
viewkey : string,
|
||||
}
|
||||
|
||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts, RendererContext, WindowSize, RendererModel, PtyDataType, BookmarkType, ClientDataType, PlaybookType, PlaybookEntryType, HistoryViewDataType, RenderModeType, AlertMessageType, HistorySearchParams, ScreenLinesType, FocusTypeStrs, HistoryTypeStrs, RendererOpts, RendererPluginType, SimpleBlobRendererComponent, RendererModelContainerApi, RendererModelInitializeParams, RendererOptsUpdate, ClientMigrationInfo, WebShareOpts, RemoteStatusTypeStrs, WebFullScreen, WebScreen, WebLine, WebCmd, RemoteTermContext, TermContextUnion, WebRemote, WebScreenUpdate, PtyDataUpdate, WebShareWSMessage};
|
||||
|
@ -18,7 +18,9 @@ type OArr<V> = mobx.IObservableArray<V>;
|
||||
type OMap<K,V> = mobx.ObservableMap<K,V>;
|
||||
|
||||
// TODO selection
|
||||
// TODO websocket
|
||||
// TODO bug with finishing up the ptydata
|
||||
// TODO bug with ptydata late -- not updating usedrows
|
||||
// TODO scroll screen when new cmds arrive (selection)
|
||||
|
||||
function makeFullRemoteRef(ownerName : string, remoteRef : string, name : string) : string {
|
||||
if (isBlank(ownerName) && isBlank(name)) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as mobx from "mobx";
|
||||
import {sprintf} from "sprintf-js";
|
||||
import {boundMethod} from "autobind-decorator";
|
||||
import {handleJsonFetchResponse, isModKeyPress} from "./util";
|
||||
import {handleJsonFetchResponse, isModKeyPress, base64ToArray} from "./util";
|
||||
import * as T from "./types";
|
||||
import {TermWrap} from "./term";
|
||||
import * as lineutil from "./lineutil";
|
||||
@ -58,12 +58,81 @@ class WebShareModelClass {
|
||||
return 12;
|
||||
}
|
||||
|
||||
mergeLine(fullScreen : T.WebFullScreen, newLine : T.WebLine) {
|
||||
for (let i=0; i<fullScreen.lines.length; i++) {
|
||||
let line = fullScreen.lines[i];
|
||||
if (line.lineid == newLine.lineid) {
|
||||
fullScreen.lines[i] = newLine;
|
||||
return;
|
||||
}
|
||||
if (line.linenum > newLine.linenum) {
|
||||
fullScreen.lines.splice(i, 0, newLine);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fullScreen.lines.push(newLine);
|
||||
}
|
||||
|
||||
mergeCmd(fullScreen : T.WebFullScreen, newCmd : T.WebCmd) {
|
||||
for (let i=0; i<fullScreen.cmds.length; i++) {
|
||||
let cmd = fullScreen.cmds[i];
|
||||
if (cmd.lineid == newCmd.lineid) {
|
||||
fullScreen.cmds[i] = newCmd;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fullScreen.cmds.push(newCmd);
|
||||
}
|
||||
|
||||
mergeUpdate(msg : T.WebScreenUpdate) {
|
||||
if (msg.screenid != this.screenId) {
|
||||
console.log("bad WebScreenUpdate, wrong screenid", msg.screenid);
|
||||
return;
|
||||
}
|
||||
console.log("merge", msg);
|
||||
mobx.action(() => {
|
||||
let fullScreen = this.screen.get();
|
||||
if (msg.screen) {
|
||||
fullScreen.screen = msg.screen;
|
||||
}
|
||||
if (msg.lines != null && msg.lines.length > 0) {
|
||||
for (let line of msg.lines) {
|
||||
this.mergeLine(fullScreen, line);
|
||||
}
|
||||
}
|
||||
if (msg.cmds != null && msg.cmds.length > 0) {
|
||||
for (let cmd of msg.cmds) {
|
||||
this.mergeCmd(fullScreen, cmd);
|
||||
}
|
||||
}
|
||||
if (msg.ptydata != null && msg.ptydata.length > 0) {
|
||||
for (let data of msg.ptydata) {
|
||||
let termWrap = this.getTermWrap(data.lineid);
|
||||
if (termWrap == null) {
|
||||
continue;
|
||||
}
|
||||
termWrap.receiveData(data.ptypos, base64ToArray(data.data));
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
wsMessageCallback(msg : any) {
|
||||
if (msg.type == "webscreen:update") {
|
||||
this.mergeUpdate(msg);
|
||||
return;
|
||||
}
|
||||
console.log("ws message", msg);
|
||||
}
|
||||
|
||||
setWebFullScreen(screen : T.WebFullScreen) {
|
||||
mobx.action(() => {
|
||||
if (screen.lines == null) {
|
||||
screen.lines = [];
|
||||
}
|
||||
if (screen.cmds == null) {
|
||||
screen.cmds = [];
|
||||
}
|
||||
this.screen.set(screen);
|
||||
if (screen.lines != null && screen.lines.length > 0) {
|
||||
this.selectedLine.set(screen.lines[screen.lines.length-1].linenum);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as mobx from "mobx";
|
||||
import {sprintf} from "sprintf-js";
|
||||
import {boundMethod} from "autobind-decorator";
|
||||
import {WatchScreenPacketType} from "./types";
|
||||
import {WebShareWSMessage} from "./types";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
class WebShareWSControl {
|
||||
@ -153,7 +153,7 @@ class WebShareWSControl {
|
||||
this.messageCallback(eventData);
|
||||
}
|
||||
catch (e) {
|
||||
this.log("[error] messageCallback", e);
|
||||
this.log("[error] messageCallback " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ class WebShareWSControl {
|
||||
}
|
||||
|
||||
sendWebShareInit() {
|
||||
let pk : WatchScreenPacketType = {"type": "webshare", screenid: this.screenId, viewkey: this.viewKey};
|
||||
let pk : WebShareWSMessage = {"type": "webshare", screenid: this.screenId, viewkey: this.viewKey};
|
||||
this.pushMessage(pk);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user