// Terminal interop bridge: xterm.js <-> .NET Blazor WASM window.terminalInterop = { term: null, fitAddon: null, init: function () { const term = new Terminal({ cols: 120, rows: 30, fontFamily: "'Cascadia Mono', 'Consolas', 'Courier New', monospace", fontSize: 14, theme: { background: '#1a1a2e', foreground: '#e0e0e0', cursor: '#ffd700', cursorAccent: '#1a1a2e', selectionBackground: 'rgba(255, 215, 0, 0.3)' }, cursorBlink: true, allowProposedApi: true, scrollback: 1000 }); const fitAddon = new FitAddon.FitAddon(); term.loadAddon(fitAddon); term.open(document.getElementById('terminal')); fitAddon.fit(); // Forward key input to C# term.onData(function (data) { DotNet.invokeMethodAsync('OpenTheBox.Web', 'OnTerminalInput', data); }); // Handle resize window.addEventListener('resize', function () { fitAddon.fit(); }); this.term = term; this.fitAddon = fitAddon; // Show terminal, hide loading document.getElementById('loading').classList.add('hidden'); document.getElementById('terminal-container').classList.add('active'); term.focus(); }, write: function (text) { if (this.term) { this.term.write(text); } }, clear: function () { if (this.term) { this.term.clear(); this.term.write('\x1b[H\x1b[2J'); } }, focus: function () { if (this.term) { this.term.focus(); } } };