ghostty-web 0.3.0 → 0.4.0-next.1.g65aeac9
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/README.md +48 -102
- package/dist/ghostty-vt.wasm +0 -0
- package/dist/ghostty-web.js +1209 -1114
- package/dist/ghostty-web.umd.cjs +5 -5
- package/dist/index.d.ts +409 -322
- package/ghostty-vt.wasm +0 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,141 +1,87 @@
|
|
|
1
1
|
# ghostty-web
|
|
2
2
|
|
|
3
|
-
 that leverages
|
|
6
|
-
[Ghostty's](https://github.com/ghostty-org/ghostty)
|
|
7
|
-
terminal emulation core via WebAssembly. Because it leans on Ghostty to handle the complexity of terminal
|
|
8
|
-
emulation, `ghostty-web` can deliver fast, robust terminal emulation in the browser. The intent is
|
|
9
|
-
for this project to become a drop-in replacement for xterm.js. Under heavy development, no compatibility guarantees yet.
|
|
10
|
-
|
|
11
|
-
## Live Demo
|
|
12
|
-
|
|
13
|
-
Try ghostty-web yourself with:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npx @ghostty-web/demo@next
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
This starts a local demo server with a real shell session. The demo server works best when run from Linux, but you can also try
|
|
20
|
-
it on macOS. Windows is not supported (yet).
|
|
3
|
+
[](https://npmjs.com/package/ghostty-web) [](https://npmjs.com/package/ghostty-web) [](https://npmjs.com/package/ghostty-web) [](./LICENSE)
|
|
21
4
|
|
|
22
|
-
|
|
23
|
-
<summary>Development setup (building from source)</summary>
|
|
5
|
+
[Ghostty](https://github.com/ghostty-org/ghostty) for the web with [xterm.js](https://github.com/xtermjs/xterm.js) API compatibility — giving you a proper VT100 implementation in the browser.
|
|
24
6
|
|
|
25
|
-
|
|
7
|
+
- Migrate from xterm by changing your import: `@xterm/xterm` → `ghostty-web`
|
|
8
|
+
- WASM-compiled parser from Ghostty—the same code that runs the native app
|
|
9
|
+
- Zero runtime dependencies, ~400KB WASM bundle
|
|
26
10
|
|
|
27
|
-
|
|
28
|
-
git clone https://github.com/coder/ghostty-web
|
|
29
|
-
cd ghostty-web
|
|
30
|
-
bun install
|
|
31
|
-
bun run build # Builds the WASM module and library
|
|
32
|
-
bun run demo:dev # http://localhost:8000/demo/
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
</details>
|
|
36
|
-
|
|
37
|
-
## Getting Started
|
|
11
|
+
Originally created for [Mux](https://github.com/coder/mux) (a desktop app for isolated, parallel agentic development), but designed to be used anywhere.
|
|
38
12
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm install ghostty-web
|
|
43
|
-
```
|
|
13
|
+
## Try It
|
|
44
14
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```html
|
|
48
|
-
<!doctype html>
|
|
49
|
-
<html>
|
|
50
|
-
<body>
|
|
51
|
-
<div id="terminal"></div>
|
|
52
|
-
<script type="module">
|
|
53
|
-
import { init, Terminal } from 'ghostty-web';
|
|
54
|
-
|
|
55
|
-
await init();
|
|
56
|
-
const term = new Terminal();
|
|
57
|
-
term.open(document.getElementById('terminal'));
|
|
58
|
-
term.write('Hello from \x1B[1;3;31mghostty-web\x1B[0m $ ');
|
|
59
|
-
</script>
|
|
60
|
-
</body>
|
|
61
|
-
</html>
|
|
62
|
-
```
|
|
15
|
+
- [Live Demo](https://ghostty.ondis.co) on an ephemeral VM (thank you to Greg from [disco.cloud](https://disco.cloud) for hosting).
|
|
63
16
|
|
|
64
|
-
|
|
17
|
+
- On your computer:
|
|
65
18
|
|
|
66
|
-
|
|
67
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npx @ghostty-web/demo@next
|
|
21
|
+
```
|
|
68
22
|
|
|
69
|
-
|
|
23
|
+
This starts a local HTTP server with a real shell on `http://localhost:8080`. Works best on Linux and macOS.
|
|
70
24
|
|
|
71
|
-
-
|
|
72
|
-
- True color (24-bit RGB) + 256 color + 16 ANSI colors
|
|
73
|
-
- Text styles: bold, italic, underline, strikethrough, dim, reverse
|
|
74
|
-
- Alternate screen buffer (for vim, htop, less, etc.)
|
|
75
|
-
- Scrollback buffer with mouse wheel support
|
|
25
|
+

|
|
76
26
|
|
|
77
|
-
|
|
27
|
+
## Comparison with xterm.js
|
|
78
28
|
|
|
79
|
-
|
|
80
|
-
- Mouse tracking modes
|
|
81
|
-
- Custom key/wheel event handlers
|
|
29
|
+
xterm.js is everywhere—VS Code, Hyper, countless web terminals. But it has fundamental issues:
|
|
82
30
|
|
|
83
|
-
|
|
31
|
+
| Issue | xterm.js | ghostty-web |
|
|
32
|
+
| ---------------------------------------- | ---------------------------------------------------------------- | -------------------------- |
|
|
33
|
+
| **Complex scripts** (Devanagari, Arabic) | Rendering issues | ✓ Proper grapheme handling |
|
|
34
|
+
| **XTPUSHSGR/XTPOPSGR** | [Not supported](https://github.com/xtermjs/xterm.js/issues/2570) | ✓ Full support |
|
|
84
35
|
|
|
85
|
-
|
|
86
|
-
- FitAddon for responsive terminal sizing
|
|
87
|
-
- Event system (onData, onResize, onBell, onScroll, etc.)
|
|
36
|
+
xterm.js reimplements terminal emulation in JavaScript. Every escape sequence, every edge case, every Unicode quirk—all hand-coded. Ghostty's emulator is the same battle-tested code that runs the native Ghostty app.
|
|
88
37
|
|
|
89
|
-
|
|
38
|
+
## Installation
|
|
90
39
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
40
|
+
```bash
|
|
41
|
+
npm install ghostty-web
|
|
42
|
+
```
|
|
94
43
|
|
|
95
|
-
## Usage
|
|
44
|
+
## Usage
|
|
96
45
|
|
|
97
|
-
|
|
46
|
+
ghostty-web aims to be API-compatible with the xterm.js API.
|
|
98
47
|
|
|
99
|
-
```
|
|
100
|
-
import { init, Terminal
|
|
48
|
+
```javascript
|
|
49
|
+
import { init, Terminal } from 'ghostty-web';
|
|
101
50
|
|
|
102
|
-
// Initialize WASM (call once at app startup)
|
|
103
51
|
await init();
|
|
104
52
|
|
|
105
53
|
const term = new Terminal({
|
|
106
|
-
cursorBlink: true,
|
|
107
54
|
fontSize: 14,
|
|
108
55
|
theme: {
|
|
109
|
-
background: '#
|
|
110
|
-
foreground: '#
|
|
56
|
+
background: '#1a1b26',
|
|
57
|
+
foreground: '#a9b1d6',
|
|
111
58
|
},
|
|
112
59
|
});
|
|
113
60
|
|
|
114
|
-
const fitAddon = new FitAddon();
|
|
115
|
-
term.loadAddon(fitAddon);
|
|
116
|
-
|
|
117
61
|
term.open(document.getElementById('terminal'));
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Handle user input
|
|
121
|
-
term.onData((data) => {
|
|
122
|
-
// Send to backend/PTY
|
|
123
|
-
console.log('User typed:', data);
|
|
124
|
-
});
|
|
62
|
+
term.onData((data) => websocket.send(data));
|
|
63
|
+
websocket.onmessage = (e) => term.write(e.data);
|
|
125
64
|
```
|
|
126
65
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
### Prerequisites
|
|
66
|
+
For a comprehensive client <-> server example, refer to the [demo](./demo/index.html#L141).
|
|
130
67
|
|
|
131
|
-
|
|
132
|
-
- [zig](https://ziglang.org/download/)
|
|
68
|
+
## Development
|
|
133
69
|
|
|
134
|
-
|
|
70
|
+
ghostty-web builds from Ghostty's source with a [patch](./patches/ghostty-wasm-api.patch) to expose additional
|
|
71
|
+
functionality.
|
|
135
72
|
|
|
136
|
-
|
|
137
|
-
functionality
|
|
73
|
+
> Requires Zig and Bun.
|
|
138
74
|
|
|
139
75
|
```bash
|
|
140
76
|
bun run build
|
|
141
77
|
```
|
|
78
|
+
|
|
79
|
+
Mitchell Hashimoto (author of Ghostty) has [been working](https://mitchellh.com/writing/libghostty-is-coming) on `libghostty` which makes this all possible. The patches are very minimal thanks to the work the Ghostty team has done, and we expect them to get smaller.
|
|
80
|
+
|
|
81
|
+
This library will eventually consume a native Ghostty WASM distribution once available, and will continue to provide an xterm.js compatible API.
|
|
82
|
+
|
|
83
|
+
At Coder we're big fans of Ghostty, so kudos to that team for all the amazing work.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
[MIT](./LICENSE)
|
package/dist/ghostty-vt.wasm
CHANGED
|
Binary file
|