v86
v86 copied to clipboard
SerialAdapterXtermJS doesn’t detect xterm.js in ESM builds (window.Terminal is undefined)
In pure ESM import (import { Terminal } from '@xterm/xterm'), nothing is put on window, so the adapter never instantiates the terminal.
Possible solutions:
- document that esm users need to add
window["Terminal"] = Terminalsomewhere - accept the Terminal constructor as a parameter to V86
Feel free to send a PR for either (or both)
accept the Terminal constructor as a parameter to V86
Fixed in #1463.
import { Terminal } from "xterm";
window.onload = function()
{
var emulator = window.emulator = new V86({
serial_container_xtermjs: document.getElementById("terminal"),
xterm_lib: Terminal,
});
};
Also works with ghostty-web:
import { init, Terminal } from "ghostty-web";
window.onload = async function()
{
await init();
var emulator = window.emulator = new V86({
serial_container_xtermjs: document.getElementById("terminal"),
xterm_lib: Terminal,
});
};