how to run xterm-headless without nodejs #5248
-
I am looking for a way to run xterm headless without relying on the node environment. Is there any way to compile xterm.js into a dynamic library for use, using Rust or CPP,If using a node environment, I am not sure if its speed will affect the state of the mirror server terminal.And I also need to increase communication methods to obtain the status of the mirror terminal,it's not good. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hmm, in theory this should be possible as xterm.js does not rely on specific parts of the node env per se. We have only one place, where we deduct the underlying platform in xterm.js/src/common/TaskQueue.ts Line 145 in e826f6b Idk if the bundler for the headless version further injects node specific shims, if so, you might be able to polyfill them as well. Regarding JS engine caps - things like array buffer / dataview types, Math, console, setTimeout should be available. Also property accessors are used here and there. The core gets compiled with ES2021 currently (might still work down to ES2017 as we changed that not long ago). In summary - yes should be possible, as xterm.js internals are all quite vanilla JS, but you are on your own to polyfill missing pieces in your JS engine. A good starting point to mess with would be the headless bundle in the @xterm/headless package under |
Beta Was this translation helpful? Give feedback.
Hmm, in theory this should be possible as xterm.js does not rely on specific parts of the node env per se. We have only one place, where we deduct the underlying platform in
src/common/Platform.ts
. As you can see there you'd get node behavior by defining a globalprocess
object.To find follow-ups in the code you can search for
isNode
and check impl details at the occasions and whether you can polyfill it in your JS engine. A quick search myself revealed only one impl switch here:xterm.js/src/common/TaskQueue.ts
Line 145 in e826f6b
Idk if the bundler fo…