feat: update using gofiber

This commit is contained in:
2024-11-06 09:50:41 +00:00
parent 5b37d7bae5
commit b9d879330a
6 changed files with 275 additions and 165 deletions
@@ -1,4 +1,3 @@
import { View, Text } from "react-native";
import React from "react";
import Terminal from "./terminal";
import { BASE_WS_URL } from "@/lib/api";
@@ -19,7 +18,9 @@ const InteractiveSession = ({ type, options }: Props) => {
serverId: options.serverId,
token: "token",
});
return <Terminal wsUrl={BASE_WS_URL + "/ws/ssh?" + params} />;
return (
<Terminal client="xtermjs" wsUrl={`${BASE_WS_URL}/ws/ssh?${params}`} />
);
default:
throw new Error("Unknown interactive session type");
+18 -5
View File
@@ -26,20 +26,33 @@ const Keys = {
Tab: "\x09",
};
type TerminalProps = ComponentPropsWithoutRef<typeof View> & {
type XTermJsProps = {
client: "xtermjs";
wsUrl: string;
};
const Terminal = ({ wsUrl, style, ...props }: TerminalProps) => {
const ref = React.useRef<XTermRef>(null);
type TerminalProps = ComponentPropsWithoutRef<typeof View> & XTermJsProps;
const Terminal = ({ client, style, ...props }: TerminalProps) => {
const xtermRef = React.useRef<XTermRef>(null);
const send = (data: string) => {
ref.current?.send(data);
switch (client) {
case "xtermjs":
xtermRef.current?.send(data);
break;
}
};
return (
<View style={[styles.container, style]} {...props}>
<XTermJs ref={ref} dom={{ scrollEnabled: false }} wsUrl={wsUrl} />
{client === "xtermjs" && (
<XTermJs
ref={xtermRef}
dom={{ scrollEnabled: false }}
wsUrl={props.wsUrl}
/>
)}
<ScrollView
horizontal