Skip to content

Commit

Permalink
Merge pull request #4240 from Tyriar/4222_shims
Browse files Browse the repository at this point in the history
Remove promise and fetch shims and use await for fetch
  • Loading branch information
Tyriar committed Nov 4, 2022
2 parents 7d98375 + 5a4a46f commit 0edabed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 9 additions & 11 deletions demo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function createTerminal(): void {
});

// fit is called within a setTimeout, cols and rows need this.
setTimeout(() => {
setTimeout(async () => {
initOptions(term);
// TODO: Clean this up, opt-cols/rows doesn't exist anymore
(document.getElementById(`opt-cols`) as HTMLInputElement).value = term.cols;
Expand All @@ -317,16 +317,14 @@ function createTerminal(): void {
// Set terminal size again to set the specific dimensions on the demo
updateTerminalSize();

fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' }).then((res) => {
res.text().then((processId) => {
pid = processId;
socketURL += processId;
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
});
});
const res = await fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' });
const processId = await res.text();
pid = processId;
socketURL += processId;
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
}, 0);
}

Expand Down
2 changes: 0 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<link rel="shortcut icon" type="image/png" href="/logo.png">
<link rel="stylesheet" href="/xterm.css" />
<link rel="stylesheet" href="/style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js" integrity="sha384-kM3+BR0fKGmv8mDasMGLSHdqcbgWHUNWV1rAL+tkqnH578xS82vhlu9gR5BHhBai" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js" integrity="sha384-bR8my2pcqqtUkMMTomrgTyDVACSJz1M9D70XdkeK2BaYbCYxG3CfngYdSAOcPkUZ" crossorigin="anonymous"></script>
</head>
<body>
<h1 style="color: #2D2E2C">xterm.js: A terminal for the <em style="color: #5DA5D5">web</em></h1>
Expand Down

0 comments on commit 0edabed

Please sign in to comment.