restty 0.1.2 → 0.1.4
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 +91 -70
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,110 +6,131 @@
|
|
|
6
6
|
[](https://discord.gg/zemMZtrkSb)
|
|
7
7
|
[](https://github.com/sponsors/vivy-company)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Powerful, lightweight browser terminal. Batteries included.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Powered by:
|
|
12
|
+
- `libghostty-vt` (WASM terminal core)
|
|
13
|
+
- `WebGPU` (with WebGL2 fallback)
|
|
14
|
+
- `text-shaper` (shaping + raster)
|
|
12
15
|
|
|
13
|
-
##
|
|
16
|
+
## Install
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- Iterate visually via a local playground without heavy framework overhead.
|
|
19
|
-
|
|
20
|
-
## How it works
|
|
21
|
-
|
|
22
|
-
1. PTY output bytes are fed into the WASM terminal core.
|
|
23
|
-
2. WASM exposes render/cell state to the TypeScript runtime.
|
|
24
|
-
3. Text shaping and glyph atlas generation happen in TS.
|
|
25
|
-
4. Renderer draws frames via WebGPU (or WebGL2 fallback).
|
|
26
|
-
5. Input (keyboard/mouse/IME) is encoded and sent back to PTY.
|
|
27
|
-
|
|
28
|
-
## Documentation
|
|
18
|
+
```bash
|
|
19
|
+
npm i restty
|
|
20
|
+
```
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
- Initial goals and scope: `docs/goals.md`
|
|
32
|
-
- End-to-end runtime flow: `docs/how-it-works.md`
|
|
33
|
-
- Integration and usage: `docs/usage.md`
|
|
34
|
-
- Internal architecture notes: `docs/internals/`
|
|
22
|
+
## Minimal setup
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
`restty` ships with built-in text shaping and embedded WASM. You only need a canvas (and optional IME textarea).
|
|
37
25
|
|
|
38
|
-
|
|
26
|
+
```html
|
|
27
|
+
<canvas id="term"></canvas>
|
|
28
|
+
<textarea id="ime" style="position:absolute;left:-9999px;top:-9999px"></textarea>
|
|
29
|
+
```
|
|
39
30
|
|
|
40
31
|
```ts
|
|
41
32
|
import { createResttyApp } from "restty";
|
|
42
33
|
|
|
43
34
|
const app = createResttyApp({
|
|
44
|
-
canvas: document.getElementById("
|
|
35
|
+
canvas: document.getElementById("term") as HTMLCanvasElement,
|
|
36
|
+
imeInput: document.getElementById("ime") as HTMLTextAreaElement,
|
|
37
|
+
renderer: "auto", // "auto" | "webgpu" | "webgl2"
|
|
45
38
|
});
|
|
39
|
+
|
|
40
|
+
await app.init();
|
|
46
41
|
```
|
|
47
42
|
|
|
48
|
-
##
|
|
43
|
+
## Common examples
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
- `tests/` - Bun test suite.
|
|
52
|
-
- `playground/` - Browser playground app and local PTY websocket server.
|
|
53
|
-
- `playground/public/` - Playground static assets (fonts/wasm bundles).
|
|
54
|
-
- `assets/themes/` - Source-of-truth Ghostty theme files.
|
|
55
|
-
- `scripts/` - Setup helper scripts.
|
|
56
|
-
- `wasm/` - Zig source and build config for the WASM core.
|
|
57
|
-
- `docs/` - User docs, architecture notes, and development references.
|
|
58
|
-
- `reference/ghostty` - Upstream Ghostty reference (submodule).
|
|
59
|
-
- `reference/text-shaper` - Upstream text-shaper reference (submodule).
|
|
45
|
+
### Connect to a PTY websocket
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
```ts
|
|
48
|
+
app.connectPty("ws://localhost:8787/pty");
|
|
49
|
+
```
|
|
62
50
|
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
### Apply a built-in theme
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { getBuiltinTheme } from "restty";
|
|
55
|
+
|
|
56
|
+
const theme = getBuiltinTheme("Aizen Dark");
|
|
57
|
+
if (theme) app.applyTheme(theme);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Parse and apply a custom Ghostty theme
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { parseGhosttyTheme } from "restty";
|
|
64
|
+
|
|
65
|
+
const themeText = `
|
|
66
|
+
foreground = #c0caf5
|
|
67
|
+
background = #1a1b26
|
|
68
|
+
cursor-color = #c0caf5
|
|
69
|
+
`;
|
|
70
|
+
app.applyTheme(parseGhosttyTheme(themeText), "inline");
|
|
71
|
+
```
|
|
66
72
|
|
|
67
|
-
|
|
73
|
+
### Send input manually
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
app.sendInput("ls -la\n");
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## App API (high level)
|
|
80
|
+
|
|
81
|
+
Main methods:
|
|
82
|
+
- `init()`
|
|
83
|
+
- `destroy()`
|
|
84
|
+
- `connectPty(url)` / `disconnectPty()`
|
|
85
|
+
- `isPtyConnected()`
|
|
86
|
+
- `setRenderer("auto" | "webgpu" | "webgl2")`
|
|
87
|
+
- `setFontSize(number)`
|
|
88
|
+
- `applyTheme(theme)` / `resetTheme()`
|
|
89
|
+
- `setMouseMode("auto" | "on" | "off")`
|
|
90
|
+
- `sendInput(text)` / `sendKeyInput(text)`
|
|
91
|
+
- `copySelectionToClipboard()` / `pasteFromClipboard()`
|
|
92
|
+
- `updateSize(force?)`
|
|
93
|
+
|
|
94
|
+
Low-level ABI access is also available via `loadResttyWasm()` if you need direct render-state integration.
|
|
95
|
+
|
|
96
|
+
## Local development
|
|
68
97
|
|
|
69
98
|
```bash
|
|
99
|
+
git clone https://github.com/wiedymi/restty.git
|
|
100
|
+
cd restty
|
|
70
101
|
git submodule update --init --recursive
|
|
71
102
|
bun install
|
|
72
103
|
bun run build:themes
|
|
73
104
|
bun run build:assets
|
|
105
|
+
bun run pty
|
|
74
106
|
bun run playground
|
|
75
107
|
```
|
|
76
108
|
|
|
77
109
|
Open `http://localhost:5173`.
|
|
78
110
|
|
|
79
|
-
## Commands
|
|
111
|
+
## Commands (repo)
|
|
80
112
|
|
|
81
113
|
```bash
|
|
82
|
-
#
|
|
83
|
-
bun run test
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
bun run
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
bun run
|
|
90
|
-
|
|
91
|
-
# Regenerate embedded built-in theme catalog for the library
|
|
92
|
-
bun run build:themes
|
|
93
|
-
|
|
94
|
-
# Lint + format checks
|
|
95
|
-
bun run lint
|
|
96
|
-
bun run format:check
|
|
97
|
-
|
|
98
|
-
# Serve playground static files only
|
|
99
|
-
bun run playground:static
|
|
114
|
+
bun run build # build package output
|
|
115
|
+
bun run test # full tests
|
|
116
|
+
bun run test:ci # CI-safe test target
|
|
117
|
+
bun run lint # lint
|
|
118
|
+
bun run format:check # formatting check (src only)
|
|
119
|
+
bun run build:assets # playground bundles
|
|
120
|
+
bun run pty # local PTY server
|
|
121
|
+
bun run playground # playground dev server
|
|
100
122
|
```
|
|
101
123
|
|
|
102
|
-
##
|
|
124
|
+
## Acknowledgements
|
|
103
125
|
|
|
104
|
-
|
|
126
|
+
Huge thanks to the Ghostty project and contributors for `libghostty-vt`, which powers restty's terminal core.
|
|
105
127
|
|
|
106
|
-
-
|
|
107
|
-
- PTY UTF-8 stream behavior (`tests/pty-utf8.test.ts`)
|
|
108
|
-
- output filtering and kitty graphics (`tests/output-filter.test.ts`, `tests/kitty-*.test.ts`)
|
|
109
|
-
- renderer/glyph checks (`tests/box-drawing.test.ts`, `tests/webgpu-glyph.test.ts`)
|
|
128
|
+
`text-shaper` is my own library, and it also makes this project possible by handling shaping and glyph rasterization in the browser pipeline.
|
|
110
129
|
|
|
111
|
-
##
|
|
130
|
+
## Docs
|
|
112
131
|
|
|
113
|
-
- `
|
|
114
|
-
-
|
|
115
|
-
-
|
|
132
|
+
- `docs/README.md` - docs index
|
|
133
|
+
- `docs/usage.md` - integration details
|
|
134
|
+
- `docs/how-it-works.md` - runtime flow
|
|
135
|
+
- `docs/internals/` - architecture docs
|
|
136
|
+
- `THIRD_PARTY_NOTICES.md` - third-party credits and notices
|