diff --git a/apps/1test/package.json b/apps/1test/package.json
index acbc0e471f..138fe3a1c2 100644
--- a/apps/1test/package.json
+++ b/apps/1test/package.json
@@ -24,6 +24,8 @@
"@electron-forge/maker-squirrel": "^6.1.1",
"@electron-forge/maker-zip": "^6.1.1",
"@electron-forge/plugin-webpack": "^6.1.1",
+ "@types/react": "^18.2.8",
+ "@types/react-dom": "^18.2.4",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
@@ -41,6 +43,12 @@
"dependencies": {
"chokidar": "^3.5.3",
"electron-squirrel-startup": "^1.0.0",
- "fix-path": "^4.0.0"
+ "fix-path": "^4.0.0",
+ "node-pty": "0.10.1",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "xterm": "^5.1.0",
+ "xterm-addon-fit": "^0.7.0",
+ "xterm-for-react": "^1.0.4"
}
}
diff --git a/apps/1test/src/app.tsx b/apps/1test/src/app.tsx
new file mode 100644
index 0000000000..1ac31ebff3
--- /dev/null
+++ b/apps/1test/src/app.tsx
@@ -0,0 +1,8 @@
+import * as ReactDOM from 'react-dom';
+import { RemixUiXterminals } from './remix/ui/remix-ui-xterminals';
+import { xterm } from './renderer';
+
+import { createRoot } from 'react-dom/client';
+const container = document.getElementById('app');
+const root = createRoot(container); // createRoot(container!) if you use TypeScript
+root.render()
\ No newline at end of file
diff --git a/apps/1test/src/electron/engine.ts b/apps/1test/src/electron/engine.ts
index d71e22511f..9a27037d47 100644
--- a/apps/1test/src/electron/engine.ts
+++ b/apps/1test/src/electron/engine.ts
@@ -3,14 +3,17 @@ import { ipcMain } from 'electron';
import { FSPlugin } from './fsPlugin';
import { GitPlugin } from './gitPlugin';
import { app } from 'electron';
+import { XtermPlugin } from './xtermPlugin';
const engine = new Engine()
const appManager = new PluginManager()
const fsPlugin = new FSPlugin()
const gitPlugin = new GitPlugin()
+const xtermPlugin = new XtermPlugin()
engine.register(appManager)
engine.register(fsPlugin)
engine.register(gitPlugin)
+engine.register(xtermPlugin)
ipcMain.handle('manager:activatePlugin', async (event, arg) => {
console.log('manager:activatePlugin', arg)
diff --git a/apps/1test/src/electron/xtermPlugin.ts b/apps/1test/src/electron/xtermPlugin.ts
new file mode 100644
index 0000000000..20f735b61a
--- /dev/null
+++ b/apps/1test/src/electron/xtermPlugin.ts
@@ -0,0 +1,73 @@
+import { Plugin } from "@remixproject/engine";
+import { PluginClient } from "@remixproject/plugin";
+import { Profile } from "@remixproject/plugin-utils";
+import { spawn } from "child_process";
+import { createElectronClient } from "./lib/electronPluginClient";
+
+import os from 'os';
+import * as pty from "node-pty"
+
+const profile: Profile = {
+ name: 'xterm',
+ displayName: 'xterm',
+ description: 'xterm plugin',
+}
+
+export class XtermPlugin extends Plugin {
+ client: PluginClient
+ constructor() {
+ super(profile)
+ }
+
+ onActivation(): void {
+ this.client = new XtermPluginClient()
+ }
+
+}
+
+class XtermPluginClient extends PluginClient {
+ terminals: pty.IPty[] = []
+ constructor() {
+ super()
+ this.methods = ['keystroke', 'createTerminal', 'close']
+ createElectronClient(this, profile)
+ this.onload(() => {
+ console.log('XtermPluginClient onload')
+ })
+ }
+
+ async keystroke(key: string, pid: number): Promise {
+ console.log('keystroke', key)
+ this.terminals[pid].write(key)
+ }
+
+ async createTerminal(path?: string): Promise{
+ const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
+
+ const ptyProcess = pty.spawn(shell, [], {
+ name: 'xterm-color',
+ cols: 80,
+ rows: 30,
+ cwd: path || process.cwd() ,
+ env: process.env
+ });
+
+ ptyProcess.onData((data: string) => {
+ this.sendData(data, ptyProcess.pid);
+ })
+ this.terminals[ptyProcess.pid] = ptyProcess
+ console.log('create terminal', ptyProcess.pid)
+ return ptyProcess.pid
+ }
+
+ async close(pid: number): Promise{
+ this.terminals[pid].kill()
+ delete this.terminals[pid]
+ this.emit('close', pid)
+ }
+
+ async sendData(data: string, pid: number){
+ this.emit('data', data, pid)
+ }
+
+}
\ No newline at end of file
diff --git a/apps/1test/src/index.html b/apps/1test/src/index.html
index a37c733059..e62f79d97f 100644
--- a/apps/1test/src/index.html
+++ b/apps/1test/src/index.html
@@ -1,7 +1,11 @@
+
+ Hello Terminal!
+
+
-
+