electron-nodepty: Using node for background server

The electron-nodepty directory contains an experimental version of DomTerm as a combined frontend and backend using Electron and node.js. This re-uses the JavaScript front-end code, but replaces the lws-term server part with Electron code.

Advantages

Using node.js may make building and install domterm easier, as there are fewer dependencies, and they can mostly be handled by npm.

The code is more compact and easier to understand than the C code.

Runs on native Windows (without needing WSL), using node-pty.

Uses Electron ipc instead of WebSockets.

Issues

The Electron instance is not daemonized. Could use nohub or daemon node module.

The domterm command (using lws-term) has lots of options and sub-commands. Re-implementing this would be some work. Probably use node net module; see this blog.

No support for auto-input-mode due to missing tcgetattr hook. No way to put process pid and ttyname in DOMTERM environment variable. (Maybe fix by hacking node-pty.)

No support for using other non-Electron front-ends, including using a web-browser. (Could be implemented, of course, by adding server for http and WebSockets.)

Builing and running

You will probably need to run electron-rebuild; the easiest way is to use npm:

cd $DOMTERM_DIR/electron-nodepty
npm install
npm install --save-dev electron-rebuild
$(npm bin)/electron-rebuild --version $(electron --version)

The file hlib/domterm-version.js built from hlib/domterm-version.js.in by the configure script. If you don’t have the shell and other Unix-style tools to generate and run configure, you can cheat by just copying hlib/domterm-version.js.in over:

cd $DOMTERM_DIR/hlib && cp domterm-version.js.in domterm-version.js

To start DomTerm do:

electron $DOMTERM_DIR/electron-nodepty