restty 0.1.10 → 0.1.12
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 +61 -97
- package/dist/app/font-sources.d.ts +3 -0
- package/dist/app/index.js +55710 -0
- package/dist/app/panes-context-menu.d.ts +14 -0
- package/dist/app/panes-styles.d.ts +6 -0
- package/dist/app/panes-types.d.ts +86 -0
- package/dist/app/panes.d.ts +2 -86
- package/dist/app/restty.d.ts +61 -5
- package/dist/app/types.d.ts +4 -2
- package/dist/fonts/index.js +5333 -0
- package/dist/grid/index.js +71 -0
- package/dist/ime/index.js +84 -0
- package/dist/index.d.ts +5 -18
- package/dist/index.js +25266 -25236
- package/dist/input/ansi.d.ts +6 -0
- package/dist/input/index.js +1040 -0
- package/dist/internal.d.ts +18 -0
- package/dist/internal.js +55952 -0
- package/dist/pty/index.d.ts +1 -0
- package/dist/pty/index.js +338 -0
- package/dist/pty/kitty-media.d.ts +5 -0
- package/dist/pty/pty.d.ts +2 -2
- package/dist/pty/types.d.ts +3 -1
- package/dist/renderer/index.js +1612 -0
- package/dist/renderer/shaders.d.ts +2 -2
- package/dist/selection/index.js +226 -0
- package/dist/theme/index.js +11218 -0
- package/dist/wasm/index.js +6003 -0
- package/package.json +59 -4
package/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# restty
|
|
2
2
|
|
|
3
|
-
[](https://github.com/wiedymi)
|
|
4
|
-
[](https://x.com/wiedymi)
|
|
5
|
-
[](mailto:contact@wiedymi.com)
|
|
6
|
-
[](https://discord.gg/zemMZtrkSb)
|
|
7
|
-
[](https://github.com/sponsors/vivy-company)
|
|
8
|
-
|
|
9
3
|
Powerful, lightweight browser terminal. Batteries included.
|
|
10
4
|
|
|
11
5
|
Live demo: `https://restty.pages.dev/`
|
|
@@ -21,32 +15,27 @@ Powered by:
|
|
|
21
15
|
npm i restty
|
|
22
16
|
```
|
|
23
17
|
|
|
24
|
-
##
|
|
25
|
-
|
|
26
|
-
`restty` auto-creates panes, canvas, and hidden IME inputs for you.
|
|
18
|
+
## Quick Start
|
|
27
19
|
|
|
28
20
|
```html
|
|
29
|
-
<div id="
|
|
21
|
+
<div id="terminal"></div>
|
|
30
22
|
```
|
|
31
23
|
|
|
32
24
|
```ts
|
|
33
25
|
import { Restty } from "restty";
|
|
34
26
|
|
|
35
27
|
const restty = new Restty({
|
|
36
|
-
root: document.getElementById("
|
|
28
|
+
root: document.getElementById("terminal") as HTMLElement,
|
|
37
29
|
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
By default, `restty` loads fonts from CDN URLs. You can override them at init via typed `fontSources`.
|
|
41
|
-
|
|
42
|
-
## Common examples
|
|
43
|
-
|
|
44
|
-
### Connect to a PTY websocket
|
|
45
30
|
|
|
46
|
-
```ts
|
|
47
31
|
restty.connectPty("ws://localhost:8787/pty");
|
|
48
32
|
```
|
|
49
33
|
|
|
34
|
+
That is the primary API: `new Restty(...)`.
|
|
35
|
+
`restty` creates pane DOM, canvas, and hidden IME input for you.
|
|
36
|
+
|
|
37
|
+
## Common Tasks
|
|
38
|
+
|
|
50
39
|
### Apply a built-in theme
|
|
51
40
|
|
|
52
41
|
```ts
|
|
@@ -56,44 +45,65 @@ const theme = getBuiltinTheme("Aizen Dark");
|
|
|
56
45
|
if (theme) restty.applyTheme(theme);
|
|
57
46
|
```
|
|
58
47
|
|
|
59
|
-
### Parse and apply a
|
|
48
|
+
### Parse and apply a Ghostty theme file
|
|
60
49
|
|
|
61
50
|
```ts
|
|
62
51
|
import { parseGhosttyTheme } from "restty";
|
|
63
52
|
|
|
64
|
-
const
|
|
53
|
+
const theme = parseGhosttyTheme(`
|
|
65
54
|
foreground = #c0caf5
|
|
66
55
|
background = #1a1b26
|
|
67
56
|
cursor-color = #c0caf5
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
`);
|
|
58
|
+
|
|
59
|
+
restty.applyTheme(theme, "inline");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Split panes and operate per pane
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
restty.splitActivePane("vertical");
|
|
66
|
+
restty.splitActivePane("horizontal");
|
|
67
|
+
|
|
68
|
+
for (const pane of restty.panes()) {
|
|
69
|
+
pane.connectPty("ws://localhost:8787/pty");
|
|
70
|
+
}
|
|
70
71
|
```
|
|
71
72
|
|
|
72
|
-
###
|
|
73
|
+
### Use active-pane convenience methods
|
|
73
74
|
|
|
74
75
|
```ts
|
|
76
|
+
restty.setFontSize(15);
|
|
75
77
|
restty.sendInput("ls -la\n");
|
|
78
|
+
restty.copySelectionToClipboard();
|
|
76
79
|
```
|
|
77
80
|
|
|
78
|
-
### Provide custom fonts
|
|
81
|
+
### Provide custom fonts
|
|
82
|
+
|
|
83
|
+
By default, restty uses a CDN font preset. To fully control fonts, disable the preset and pass `fontSources`.
|
|
79
84
|
|
|
80
85
|
```ts
|
|
81
86
|
const restty = new Restty({
|
|
82
|
-
root: document.getElementById("
|
|
87
|
+
root: document.getElementById("terminal") as HTMLElement,
|
|
88
|
+
appOptions: {
|
|
89
|
+
fontPreset: "none",
|
|
90
|
+
},
|
|
83
91
|
fontSources: [
|
|
84
92
|
{
|
|
85
93
|
type: "url",
|
|
86
94
|
url: "https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/ttf/JetBrainsMono-Regular.ttf",
|
|
95
|
+
label: "JetBrains Mono",
|
|
87
96
|
},
|
|
88
97
|
{
|
|
89
98
|
type: "local",
|
|
90
99
|
matchers: ["jetbrains mono nerd font", "fira code nerd font"],
|
|
100
|
+
label: "Local fallback",
|
|
91
101
|
},
|
|
92
102
|
],
|
|
93
103
|
});
|
|
94
104
|
```
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
Update fonts at runtime (all panes):
|
|
97
107
|
|
|
98
108
|
```ts
|
|
99
109
|
await restty.setFontSources([
|
|
@@ -105,69 +115,36 @@ await restty.setFontSources([
|
|
|
105
115
|
]);
|
|
106
116
|
```
|
|
107
117
|
|
|
108
|
-
##
|
|
109
|
-
|
|
110
|
-
`restty` ships a pane manager and a default terminal context menu so you can add split panes quickly.
|
|
111
|
-
It auto-creates pane DOM, canvas, and hidden IME inputs for you.
|
|
112
|
-
Pane/split/divider styles are injected by the library (no separate CSS file required).
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
import {
|
|
116
|
-
Restty,
|
|
117
|
-
getBuiltinTheme,
|
|
118
|
-
} from "restty";
|
|
119
|
-
|
|
120
|
-
const root = document.getElementById("paneRoot") as HTMLElement;
|
|
121
|
-
|
|
122
|
-
const restty = new Restty({
|
|
123
|
-
root,
|
|
124
|
-
appOptions: {
|
|
125
|
-
renderer: "auto",
|
|
126
|
-
fontSize: 18,
|
|
127
|
-
callbacks: {
|
|
128
|
-
onLog: (line) => console.log(line),
|
|
129
|
-
},
|
|
130
|
-
elements: {},
|
|
131
|
-
},
|
|
132
|
-
defaultContextMenu: {
|
|
133
|
-
getPtyUrl: () => "ws://localhost:8787/pty",
|
|
134
|
-
},
|
|
135
|
-
paneStyles: {
|
|
136
|
-
inactivePaneOpacity: 0.82,
|
|
137
|
-
dividerThicknessPx: 1,
|
|
138
|
-
},
|
|
139
|
-
shortcuts: true,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const first = restty.getActivePane();
|
|
143
|
-
const theme = getBuiltinTheme("Aizen Dark");
|
|
144
|
-
if (theme && first) first.app.applyTheme(theme);
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Default split shortcuts are enabled:
|
|
148
|
-
- `Cmd/Ctrl + D` split right
|
|
149
|
-
- `Cmd/Ctrl + Shift + D` split down
|
|
150
|
-
|
|
151
|
-
## Restty API
|
|
118
|
+
## API Snapshot
|
|
152
119
|
|
|
153
|
-
|
|
120
|
+
Primary class:
|
|
154
121
|
- `new Restty({ root, ...options })`
|
|
155
|
-
- `
|
|
156
|
-
|
|
122
|
+
- `createRestty(options)`
|
|
123
|
+
|
|
124
|
+
Pane access:
|
|
125
|
+
- `panes()` / `pane(id)` / `activePane()` / `focusedPane()` / `forEachPane(visitor)`
|
|
157
126
|
- `splitActivePane("vertical" | "horizontal")` / `splitPane(id, direction)` / `closePane(id)`
|
|
158
|
-
|
|
127
|
+
|
|
128
|
+
Active-pane convenience:
|
|
159
129
|
- `connectPty(url)` / `disconnectPty()` / `isPtyConnected()`
|
|
160
130
|
- `setRenderer("auto" | "webgpu" | "webgl2")`
|
|
161
|
-
- `setFontSize(number)`
|
|
131
|
+
- `setFontSize(number)` / `setFontSources([...])`
|
|
162
132
|
- `applyTheme(theme)` / `resetTheme()`
|
|
163
133
|
- `setMouseMode("auto" | "on" | "off")`
|
|
164
134
|
- `sendInput(text)` / `sendKeyInput(text)`
|
|
165
135
|
- `copySelectionToClipboard()` / `pasteFromClipboard()`
|
|
166
136
|
- `updateSize(force?)`
|
|
137
|
+
- `destroy()`
|
|
167
138
|
|
|
168
|
-
|
|
139
|
+
## Advanced / Internal Modules
|
|
169
140
|
|
|
170
|
-
|
|
141
|
+
Use these only when you need lower-level control:
|
|
142
|
+
- `restty/wasm`: low-level WASM ABI wrapper (`loadResttyWasm`, `ResttyWasm`)
|
|
143
|
+
- `restty/input`: key/mouse/input encoding utilities
|
|
144
|
+
- `restty/pty`: PTY transport helpers
|
|
145
|
+
- `restty/internal`: full internal barrel (unstable)
|
|
146
|
+
|
|
147
|
+
## Local Development
|
|
171
148
|
|
|
172
149
|
```bash
|
|
173
150
|
git clone https://github.com/wiedymi/restty.git
|
|
@@ -182,36 +159,23 @@ bun run playground
|
|
|
182
159
|
|
|
183
160
|
Open `http://localhost:5173`.
|
|
184
161
|
|
|
185
|
-
|
|
186
|
-
- Build: `bun run build:assets`
|
|
187
|
-
- Output directory: `playground/public`
|
|
188
|
-
- Keep `_headers` in that folder for COOP/COEP (required by WebContainer mode).
|
|
189
|
-
|
|
190
|
-
## Commands (repo)
|
|
162
|
+
## Repository Commands
|
|
191
163
|
|
|
192
164
|
```bash
|
|
193
165
|
bun run build # build package output
|
|
194
166
|
bun run test # full tests
|
|
195
167
|
bun run test:ci # CI-safe test target
|
|
196
168
|
bun run lint # lint
|
|
197
|
-
bun run format:check # formatting check
|
|
169
|
+
bun run format:check # formatting check
|
|
198
170
|
bun run build:assets # playground bundles
|
|
199
|
-
bun run pty # local PTY server
|
|
171
|
+
bun run pty # local PTY websocket server
|
|
200
172
|
bun run playground # playground dev server
|
|
201
|
-
./test.sh # static terminal capability sweep
|
|
202
|
-
./demo.sh # animated terminal demo (good for WebContainer demos)
|
|
203
173
|
```
|
|
204
174
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
Huge thanks to the Ghostty project and contributors for `libghostty-vt`, which powers restty's terminal core.
|
|
208
|
-
|
|
209
|
-
`text-shaper` is my own library, and it also makes this project possible by handling shaping and glyph rasterization in the browser pipeline.
|
|
210
|
-
|
|
211
|
-
## Docs
|
|
175
|
+
## Documentation
|
|
212
176
|
|
|
213
177
|
- `docs/README.md` - docs index
|
|
214
|
-
- `docs/usage.md` - integration
|
|
178
|
+
- `docs/usage.md` - practical integration guide
|
|
215
179
|
- `docs/how-it-works.md` - runtime flow
|
|
216
|
-
- `docs/internals/` - architecture
|
|
180
|
+
- `docs/internals/` - implementation notes and architecture
|
|
217
181
|
- `THIRD_PARTY_NOTICES.md` - third-party credits and notices
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResttyFontPreset, ResttyFontSource } from "./types";
|
|
2
|
+
export declare const DEFAULT_FONT_SOURCES: ResttyFontSource[];
|
|
3
|
+
export declare function normalizeFontSources(sources: ResttyFontSource[] | undefined, preset: ResttyFontPreset | undefined): ResttyFontSource[];
|