summaryrefslogtreecommitdiffstats
path: root/html/src/components/app.tsx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:54:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:54:31 +0000
commit3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f (patch)
treec91ab0ac9447b25f91c05e901212c2142fb95953 /html/src/components/app.tsx
parentInitial commit. (diff)
downloadttyd-3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f.tar.xz
ttyd-3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f.zip
Adding upstream version 1.7.4.upstream/1.7.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'html/src/components/app.tsx')
-rw-r--r--html/src/components/app.tsx65
1 files changed, 65 insertions, 0 deletions
diff --git a/html/src/components/app.tsx b/html/src/components/app.tsx
new file mode 100644
index 0000000..1ad5fd3
--- /dev/null
+++ b/html/src/components/app.tsx
@@ -0,0 +1,65 @@
+import { h, Component } from 'preact';
+
+import { ITerminalOptions, ITheme } from 'xterm';
+import { ClientOptions, FlowControl } from './terminal/xterm';
+import { Terminal } from './terminal';
+
+const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+const path = window.location.pathname.replace(/[/]+$/, '');
+const wsUrl = [protocol, '//', window.location.host, path, '/ws', window.location.search].join('');
+const tokenUrl = [window.location.protocol, '//', window.location.host, path, '/token'].join('');
+const clientOptions = {
+ rendererType: 'webgl',
+ disableLeaveAlert: false,
+ disableResizeOverlay: false,
+ enableZmodem: false,
+ enableTrzsz: false,
+ enableSixel: false,
+ isWindows: false,
+} as ClientOptions;
+const termOptions = {
+ fontSize: 13,
+ fontFamily: 'Consolas,Liberation Mono,Menlo,Courier,monospace',
+ theme: {
+ foreground: '#d2d2d2',
+ background: '#2b2b2b',
+ cursor: '#adadad',
+ black: '#000000',
+ red: '#d81e00',
+ green: '#5ea702',
+ yellow: '#cfae00',
+ blue: '#427ab3',
+ magenta: '#89658e',
+ cyan: '#00a7aa',
+ white: '#dbded8',
+ brightBlack: '#686a66',
+ brightRed: '#f54235',
+ brightGreen: '#99e343',
+ brightYellow: '#fdeb61',
+ brightBlue: '#84b0d8',
+ brightMagenta: '#bc94b7',
+ brightCyan: '#37e6e8',
+ brightWhite: '#f1f1f0',
+ } as ITheme,
+ allowProposedApi: true,
+} as ITerminalOptions;
+const flowControl = {
+ limit: 100000,
+ highWater: 10,
+ lowWater: 4,
+} as FlowControl;
+
+export class App extends Component {
+ render() {
+ return (
+ <Terminal
+ id="terminal-container"
+ wsUrl={wsUrl}
+ tokenUrl={tokenUrl}
+ clientOptions={clientOptions}
+ termOptions={termOptions}
+ flowControl={flowControl}
+ />
+ );
+ }
+}