mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
fix ptyDataSource errors
This commit is contained in:
parent
f65e632c35
commit
d2829c466d
@ -6,8 +6,14 @@ import * as mobxReact from "mobx-react";
|
|||||||
import * as mobx from "mobx";
|
import * as mobx from "mobx";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||||
import { GlobalModel, LineContainerModel } from "../../../models";
|
import { GlobalModel } from "../../../models";
|
||||||
import type { LineType, RemoteType, RemotePtrType, LineHeightChangeCallbackType } from "../../../types/types";
|
import type {
|
||||||
|
LineType,
|
||||||
|
RemoteType,
|
||||||
|
RemotePtrType,
|
||||||
|
LineHeightChangeCallbackType,
|
||||||
|
LineContainerType,
|
||||||
|
} from "../../../types/types";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
import { isBlank } from "../../../util/util";
|
import { isBlank } from "../../../util/util";
|
||||||
import { ReactComponent as FolderIcon } from "../../assets/icons/folder.svg";
|
import { ReactComponent as FolderIcon } from "../../assets/icons/folder.svg";
|
||||||
@ -21,7 +27,7 @@ type OArr<V> = mobx.IObservableArray<V>;
|
|||||||
type OMap<K, V> = mobx.ObservableMap<K, V>;
|
type OMap<K, V> = mobx.ObservableMap<K, V>;
|
||||||
|
|
||||||
type RendererComponentProps = {
|
type RendererComponentProps = {
|
||||||
screen: LineContainerModel;
|
screen: LineContainerType;
|
||||||
line: LineType;
|
line: LineType;
|
||||||
width: number;
|
width: number;
|
||||||
staticRender: boolean;
|
staticRender: boolean;
|
||||||
|
@ -22,6 +22,7 @@ import type {
|
|||||||
LineType,
|
LineType,
|
||||||
TermContextUnion,
|
TermContextUnion,
|
||||||
RendererContainerType,
|
RendererContainerType,
|
||||||
|
ExtBlob,
|
||||||
} from "../../../types/types";
|
} from "../../../types/types";
|
||||||
import { debounce } from "throttle-debounce";
|
import { debounce } from "throttle-debounce";
|
||||||
import * as util from "../../../util/util";
|
import * as util from "../../../util/util";
|
||||||
@ -277,7 +278,7 @@ class SimpleBlobRenderer extends React.Component<
|
|||||||
cwd={festate.cwd}
|
cwd={festate.cwd}
|
||||||
cmdstr={cmdstr}
|
cmdstr={cmdstr}
|
||||||
exitcode={exitcode}
|
exitcode={exitcode}
|
||||||
data={model.dataBlob}
|
data={model.dataBlob as ExtBlob}
|
||||||
readOnly={model.readOnly}
|
readOnly={model.readOnly}
|
||||||
notFound={model.notFound}
|
notFound={model.notFound}
|
||||||
lineState={model.lineState}
|
lineState={model.lineState}
|
||||||
|
@ -40,7 +40,7 @@ type TermWrapOpts = {
|
|||||||
isRunning: boolean;
|
isRunning: boolean;
|
||||||
customKeyHandler?: (event: any, termWrap: TermWrap) => boolean;
|
customKeyHandler?: (event: any, termWrap: TermWrap) => boolean;
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||||
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class TermWrap {
|
|||||||
isRunning: boolean;
|
isRunning: boolean;
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
||||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||||
initializing: boolean;
|
initializing: boolean;
|
||||||
dataHandler?: (data: string, termWrap: TermWrap) => void;
|
dataHandler?: (data: string, termWrap: TermWrap) => void;
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ import { boundMethod } from "autobind-decorator";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||||
import { If } from "tsx-control-statements/components";
|
import { If } from "tsx-control-statements/components";
|
||||||
import { GlobalModel, LineContainerModel } from "../../models";
|
import { GlobalModel } from "../../models";
|
||||||
import { termHeightFromRows } from "../../util/textmeasure";
|
import { termHeightFromRows } from "../../util/textmeasure";
|
||||||
import type { LineType } from "../../types/types";
|
import type { LineType, LineContainerType } from "../../types/types";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
import * as lineutil from "../../app/line/lineutil";
|
import * as lineutil from "../../app/line/lineutil";
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ type OMap<K, V> = mobx.ObservableMap<K, V>;
|
|||||||
@mobxReact.observer
|
@mobxReact.observer
|
||||||
class TerminalRenderer extends React.Component<
|
class TerminalRenderer extends React.Component<
|
||||||
{
|
{
|
||||||
screen: LineContainerModel;
|
screen: LineContainerType;
|
||||||
line: LineType;
|
line: LineType;
|
||||||
width: number;
|
width: number;
|
||||||
staticRender: boolean;
|
staticRender: boolean;
|
||||||
|
@ -474,7 +474,7 @@ type RendererModelInitializeParams = {
|
|||||||
opts: RendererOpts;
|
opts: RendererOpts;
|
||||||
lineState: LineStateType;
|
lineState: LineStateType;
|
||||||
api: RendererModelContainerApi;
|
api: RendererModelContainerApi;
|
||||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RendererModel = {
|
type RendererModel = {
|
||||||
|
@ -1,77 +1,33 @@
|
|||||||
import { sprintf } from "sprintf-js";
|
import { sprintf } from "sprintf-js";
|
||||||
import { Model } from "../models/model";
|
import { GlobalModel } from "../models/model";
|
||||||
import {
|
import { RemotePtrType, FeCmdPacketType, PtyDataType, TermContextUnion } from "../types/types";
|
||||||
SessionDataType,
|
|
||||||
LineType,
|
|
||||||
RemoteType,
|
|
||||||
HistoryItem,
|
|
||||||
RemoteInstanceType,
|
|
||||||
RemotePtrType,
|
|
||||||
CmdDataType,
|
|
||||||
FeCmdPacketType,
|
|
||||||
TermOptsType,
|
|
||||||
ScreenDataType,
|
|
||||||
ScreenOptsType,
|
|
||||||
PtyDataUpdateType,
|
|
||||||
ModelUpdateType,
|
|
||||||
UpdateMessage,
|
|
||||||
InfoType,
|
|
||||||
UIContextType,
|
|
||||||
HistoryInfoType,
|
|
||||||
HistoryQueryOpts,
|
|
||||||
FeInputPacketType,
|
|
||||||
RemoteInputPacketType,
|
|
||||||
ContextMenuOpts,
|
|
||||||
RendererContext,
|
|
||||||
RendererModel,
|
|
||||||
PtyDataType,
|
|
||||||
BookmarkType,
|
|
||||||
ClientDataType,
|
|
||||||
HistoryViewDataType,
|
|
||||||
AlertMessageType,
|
|
||||||
HistorySearchParams,
|
|
||||||
FocusTypeStrs,
|
|
||||||
ScreenLinesType,
|
|
||||||
HistoryTypeStrs,
|
|
||||||
RendererPluginType,
|
|
||||||
WindowSize,
|
|
||||||
WebShareOpts,
|
|
||||||
TermContextUnion,
|
|
||||||
RemoteEditType,
|
|
||||||
RemoteViewType,
|
|
||||||
CommandRtnType,
|
|
||||||
WebCmd,
|
|
||||||
WebRemote,
|
|
||||||
OpenAICmdInfoChatMessageType,
|
|
||||||
StatusIndicatorLevel,
|
|
||||||
} from "../types/types";
|
|
||||||
import { isBlank } from "./util";
|
import { isBlank } from "./util";
|
||||||
|
|
||||||
function getTermPtyData(termContext: TermContextUnion, globalModel: Model): Promise<PtyDataType> {
|
function getTermPtyData(termContext: TermContextUnion): Promise<PtyDataType> {
|
||||||
if ("remoteId" in termContext) {
|
if ("remoteId" in termContext) {
|
||||||
return getRemotePtyData(termContext.remoteId, globalModel);
|
return getRemotePtyData(termContext.remoteId);
|
||||||
}
|
}
|
||||||
return getPtyData(termContext.screenId, termContext.lineId, termContext.lineNum, globalModel);
|
return getPtyData(termContext.screenId, termContext.lineId, termContext.lineNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPtyData(screenId: string, lineId: string, lineNum: number, globalModel: Model): Promise<PtyDataType> {
|
function getPtyData(screenId: string, lineId: string, lineNum: number): Promise<PtyDataType> {
|
||||||
let url = sprintf(
|
let url = sprintf(
|
||||||
globalModel.getBaseHostPort() + "/api/ptyout?linenum=%d&screenid=%s&lineid=%s",
|
GlobalModel.getBaseHostPort() + "/api/ptyout?linenum=%d&screenid=%s&lineid=%s",
|
||||||
lineNum,
|
lineNum,
|
||||||
screenId,
|
screenId,
|
||||||
lineId
|
lineId
|
||||||
);
|
);
|
||||||
return getPtyDataFromUrl(url, globalModel);
|
return getPtyDataFromUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRemotePtyData(remoteId: string, globalModel: Model): Promise<PtyDataType> {
|
function getRemotePtyData(remoteId: string): Promise<PtyDataType> {
|
||||||
let url = sprintf(globalModel.getBaseHostPort() + "/api/remote-pty?remoteid=%s", remoteId);
|
let url = sprintf(GlobalModel.getBaseHostPort() + "/api/remote-pty?remoteid=%s", remoteId);
|
||||||
return getPtyDataFromUrl(url, globalModel);
|
return getPtyDataFromUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPtyDataFromUrl(url: string, globalModel: Model): Promise<PtyDataType> {
|
function getPtyDataFromUrl(url: string): Promise<PtyDataType> {
|
||||||
let ptyOffset = 0;
|
let ptyOffset = 0;
|
||||||
let fetchHeaders = globalModel.getFetchHeaders();
|
let fetchHeaders = GlobalModel.getFetchHeaders();
|
||||||
return fetch(url, { headers: fetchHeaders })
|
return fetch(url, { headers: fetchHeaders })
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
|
Loading…
Reference in New Issue
Block a user