You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be ok when I update xterm from "4.2.0"/"5.3.0" to "^5.4.0"
😯 Current Behavior
yarn build failed with the following errors.
> yarn build
yarn run v1.22.17
warning package.json: No license field
$ parcel build --public-url ./ index.html
\ Building index.js...Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
- Building backo2.js...Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
× D:\code\node\how-to-create-web-terminals\client\node_modules\xterm\lib\xterm.js:1:11295: This experimental syntax requires enabling the parser plugin: 'optionalChaining' (1:11295)
> 1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof
......
💁 Possible Solution
🔦 Context
💻 Code Sample
index.html
<!DOCTYPE html><html><head><title>How to create web terminals</title><metacharset="UTF-8" /></head><body><divid="terminal-container"></div><scriptsrc="src/index.js"></script></body></html>
index.js
// index.jsimport{TerminalUI}from"./TerminalUI.js";importiofrom"socket.io-client";// IMPORTANT: Make sure you replace this address with your server address.constserverAddress="http://localhost:8080";//Server sandbox available at https://codesandbox.io/s/web-terminal-tutorial-server-g2ihufunctionconnectToSocket(serverAddress){returnnewPromise(res=>{constsocket=io(serverAddress);res(socket);});}functionstartTerminal(container,socket){// Create an xterm.js instance (TerminalUI class is a wrapper with some utils. Check that file for info.)constterminal=newTerminalUI(socket);// Attach created terminal to a DOM element.terminal.attachTo(container);// When terminal attached to DOM, start listening for input, output events.// Check TerminalUI startListening() function for details.terminal.startListening();}functionstart(){constcontainer=document.getElementById("terminal-container");// Connect to socket and when it is available, start terminal.connectToSocket(serverAddress).then(socket=>{startTerminal(container,socket);});}// Better to start on DOMContentLoaded. So, we know terminal-container is loadedstart();
TerminalUI.js
// TerminalUI.jsimport{Terminal}from"xterm";// import the xterm.css if use bundlers or insert link element in the head// <link rel="stylesheet" href="https://unpkg.com/[email protected]/css/xterm.css" />import"xterm/css/xterm.css";exportclassTerminalUI{constructor(socket){this.terminal=newTerminal();/* You can make your terminals colorful :) */// https://github.com/xtermjs/xterm.js/issues/4256#issuecomment-1510977408// this.terminal.setOption("theme", {// background: "#202B33",// foreground: "#F5F8FA"// });this.terminal.options.theme={background: "#202B33",foreground: "#F5F8FA"};this.socket=socket;}/** * Attach event listeners for terminal UI and socket.io client */startListening(){this.terminal.onData(data=>this.sendInput(data));this.socket.on("output",data=>{// When there is data from PTY on server, print that on Terminal.this.write(data);});}/** * Print something to terminal UI. */write(text){this.terminal.write(text);}/** * Utility function to print new line on terminal. */prompt(){this.terminal.write(`\r\n$ `);}/** * Send whatever you type in Terminal UI to PTY process in server. * @param {*} input Input to send to server */sendInput(input){this.socket.emit("input",input);}/** * * @param {HTMLElement} container HTMLElement where xterm can attach terminal ui instance. */attachTo(container){this.terminal.open(container);// Default text to display on terminal.this.terminal.write("Terminal Connected");this.terminal.write("");this.prompt();}clear(){this.terminal.clear();}}
🌍 Your Environment
Software
Version(s)
Parcel
^1.6.1
Node
v20.11.1
npm/Yarn
10.5.0/1.22.17
Operating System
Microsoft Windows [Version 10.0.22631.3374]
The text was updated successfully, but these errors were encountered:
🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
It should be ok when I update
xterm
from "4.2.0"/"5.3.0" to "^5.4.0"😯 Current Behavior
yarn build
failed with the following errors.💁 Possible Solution
🔦 Context
💻 Code Sample
index.html
index.js
TerminalUI.js
🌍 Your Environment
The text was updated successfully, but these errors were encountered: