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 dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { GlobalModel, LineContainerModel } from "../../../models";
|
||||
import type { LineType, RemoteType, RemotePtrType, LineHeightChangeCallbackType } from "../../../types/types";
|
||||
import { GlobalModel } from "../../../models";
|
||||
import type {
|
||||
LineType,
|
||||
RemoteType,
|
||||
RemotePtrType,
|
||||
LineHeightChangeCallbackType,
|
||||
LineContainerType,
|
||||
} from "../../../types/types";
|
||||
import cn from "classnames";
|
||||
import { isBlank } from "../../../util/util";
|
||||
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 RendererComponentProps = {
|
||||
screen: LineContainerModel;
|
||||
screen: LineContainerType;
|
||||
line: LineType;
|
||||
width: number;
|
||||
staticRender: boolean;
|
||||
|
@ -22,6 +22,7 @@ import type {
|
||||
LineType,
|
||||
TermContextUnion,
|
||||
RendererContainerType,
|
||||
ExtBlob,
|
||||
} from "../../../types/types";
|
||||
import { debounce } from "throttle-debounce";
|
||||
import * as util from "../../../util/util";
|
||||
@ -277,7 +278,7 @@ class SimpleBlobRenderer extends React.Component<
|
||||
cwd={festate.cwd}
|
||||
cmdstr={cmdstr}
|
||||
exitcode={exitcode}
|
||||
data={model.dataBlob}
|
||||
data={model.dataBlob as ExtBlob}
|
||||
readOnly={model.readOnly}
|
||||
notFound={model.notFound}
|
||||
lineState={model.lineState}
|
||||
|
@ -40,7 +40,7 @@ type TermWrapOpts = {
|
||||
isRunning: boolean;
|
||||
customKeyHandler?: (event: any, termWrap: TermWrap) => boolean;
|
||||
fontSize: number;
|
||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
||||
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
||||
};
|
||||
|
||||
@ -63,7 +63,7 @@ class TermWrap {
|
||||
isRunning: boolean;
|
||||
fontSize: number;
|
||||
onUpdateContentHeight: (termContext: RendererContext, height: number) => void;
|
||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
||||
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||
initializing: boolean;
|
||||
dataHandler?: (data: string, termWrap: TermWrap) => void;
|
||||
|
||||
|
@ -8,9 +8,9 @@ import { boundMethod } from "autobind-decorator";
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { If } from "tsx-control-statements/components";
|
||||
import { GlobalModel, LineContainerModel } from "../../models";
|
||||
import { GlobalModel } from "../../models";
|
||||
import { termHeightFromRows } from "../../util/textmeasure";
|
||||
import type { LineType } from "../../types/types";
|
||||
import type { LineType, LineContainerType } from "../../types/types";
|
||||
import cn from "classnames";
|
||||
import * as lineutil from "../../app/line/lineutil";
|
||||
|
||||
@ -25,7 +25,7 @@ type OMap<K, V> = mobx.ObservableMap<K, V>;
|
||||
@mobxReact.observer
|
||||
class TerminalRenderer extends React.Component<
|
||||
{
|
||||
screen: LineContainerModel;
|
||||
screen: LineContainerType;
|
||||
line: LineType;
|
||||
width: number;
|
||||
staticRender: boolean;
|
||||
|
@ -474,7 +474,7 @@ type RendererModelInitializeParams = {
|
||||
opts: RendererOpts;
|
||||
lineState: LineStateType;
|
||||
api: RendererModelContainerApi;
|
||||
ptyDataSource: (termContext: TermContextUnion, globalModel: Model) => Promise<PtyDataType>;
|
||||
ptyDataSource: (termContext: TermContextUnion) => Promise<PtyDataType>;
|
||||
};
|
||||
|
||||
type RendererModel = {
|
||||
|
@ -1,77 +1,33 @@
|
||||
import { sprintf } from "sprintf-js";
|
||||
import { Model } from "../models/model";
|
||||
import {
|
||||
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 { GlobalModel } from "../models/model";
|
||||
import { RemotePtrType, FeCmdPacketType, PtyDataType, TermContextUnion } from "../types/types";
|
||||
import { isBlank } from "./util";
|
||||
|
||||
function getTermPtyData(termContext: TermContextUnion, globalModel: Model): Promise<PtyDataType> {
|
||||
function getTermPtyData(termContext: TermContextUnion): Promise<PtyDataType> {
|
||||
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(
|
||||
globalModel.getBaseHostPort() + "/api/ptyout?linenum=%d&screenid=%s&lineid=%s",
|
||||
GlobalModel.getBaseHostPort() + "/api/ptyout?linenum=%d&screenid=%s&lineid=%s",
|
||||
lineNum,
|
||||
screenId,
|
||||
lineId
|
||||
);
|
||||
return getPtyDataFromUrl(url, globalModel);
|
||||
return getPtyDataFromUrl(url);
|
||||
}
|
||||
|
||||
function getRemotePtyData(remoteId: string, globalModel: Model): Promise<PtyDataType> {
|
||||
let url = sprintf(globalModel.getBaseHostPort() + "/api/remote-pty?remoteid=%s", remoteId);
|
||||
return getPtyDataFromUrl(url, globalModel);
|
||||
function getRemotePtyData(remoteId: string): Promise<PtyDataType> {
|
||||
let url = sprintf(GlobalModel.getBaseHostPort() + "/api/remote-pty?remoteid=%s", remoteId);
|
||||
return getPtyDataFromUrl(url);
|
||||
}
|
||||
|
||||
function getPtyDataFromUrl(url: string, globalModel: Model): Promise<PtyDataType> {
|
||||
function getPtyDataFromUrl(url: string): Promise<PtyDataType> {
|
||||
let ptyOffset = 0;
|
||||
let fetchHeaders = globalModel.getFetchHeaders();
|
||||
let fetchHeaders = GlobalModel.getFetchHeaders();
|
||||
return fetch(url, { headers: fetchHeaders })
|
||||
.then((resp) => {
|
||||
if (!resp.ok) {
|
||||
|
Loading…
Reference in New Issue
Block a user