webtty 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -7
- package/dist/cli/index.js +322 -2278
- package/dist/cli/index.js.map +7 -14
- package/dist/client-browser.js +3 -0
- package/dist/client.css +18 -0
- package/dist/client.html +14 -0
- package/dist/ghostty-vt.wasm +0 -0
- package/dist/ghostty-web.js +3425 -0
- package/dist/server/index.js +82 -160
- package/dist/server/index.js.map +8 -10
- package/package.json +2 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{FitAddon as y,init as h,Terminal as S}from"/dist/ghostty-web.js";var w=new RegExp("\x1B\\[(\\d*) q","g");function b(t,i){w.lastIndex=0;let c=w.exec(i);while(c!==null){let n=c[1]===""?0:Number(c[1]);if(!Number.isNaN(n)&&n>=0&&n<=6)t.options.cursorStyle=n===0||n===1||n===2?"block":n===3||n===4?"underline":"bar",t.options.cursorBlink=n===0||n===1||n===3||n===5;c=w.exec(i)}}var u=window.location.pathname.split("/s/")[1]??"main",r=await fetch("/api/config").then((t)=>t.json());document.title=`${u} | webtty`;await h();var e=new S({cols:r.cols,rows:r.rows,cursorStyle:r.cursorStyle,cursorBlink:r.cursorStyleBlink,fontSize:r.fontSize,fontFamily:r.fontFamily,scrollback:Math.ceil(r.scrollback/80),theme:r.theme}),a=new y;e.loadAddon(a);var d=document.getElementById("terminal");await e.open(d);a.fit();a.observeResize();var k=window.location.protocol==="https:"?"wss:":"ws:",o;function f(){let t=`${k}//${window.location.host}/ws/${u}?cols=${e.cols}&rows=${e.rows}`;o=new WebSocket(t);let i="\x1B[2m",c="\x1B[1;33m",n="\x1B[3m",l="\x1B[0m",m=`${i}[${l} ${c}webtty${l} ${i}]${l}`,g=(s)=>`\r
|
|
2
|
+
${m} ${i}${n}${s}${l}\r
|
|
3
|
+
`;o.onopen=()=>{o.send(JSON.stringify({type:"resize",cols:e.cols,rows:e.rows}))},o.onmessage=(s)=>{b(e,s.data),e.write(s.data)},o.onclose=(s)=>{if(s.code===4001){e.write(g("Session removed.")),setTimeout(()=>window.close(),500);return}if(s.code===1001){e.write(g("Server stopped.")),setTimeout(()=>window.close(),500);return}e.write(g("Connection lost. Reconnecting in 2s...")),setTimeout(f,2000)},o.onerror=()=>{e.write(g("WebSocket error."))}}f();e.onData((t)=>{if(o&&o.readyState===WebSocket.OPEN)o.send(t)});e.onResize(({cols:t,rows:i})=>{if(o&&o.readyState===WebSocket.OPEN)o.send(JSON.stringify({type:"resize",cols:t,rows:i}))});window.addEventListener("resize",()=>{a.fit()});if(r.copyOnSelect)e.onSelectionChange(()=>{let t=e.getSelection();if(!t)return;navigator.clipboard.writeText(t).catch(()=>{})});if(r.rightClickBehavior==="copyPaste")d.addEventListener("contextmenu",(t)=>{let i=e.getSelection();if(!i)return;t.preventDefault(),navigator.clipboard.writeText(i).catch(()=>{}),e.clearSelection()});
|
package/dist/client.css
ADDED
package/dist/client.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>webtty</title>
|
|
7
|
+
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect x='5' y='5' width='90' height='90' rx='18' fill='white'/><text x='8' y='73' font-size='58' font-family='monospace' font-weight='bold' fill='%23161b22'>>_</text></svg>">
|
|
8
|
+
<link rel="stylesheet" href="/dist/client.css" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="terminal"></div>
|
|
12
|
+
<script type="module" src="/dist/client-browser.js"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
Binary file
|