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.
Files changed (2) hide show
  1. package/README.md +91 -70
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,110 +6,131 @@
6
6
  [![Discord](https://img.shields.io/badge/-Discord-5865F2?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/zemMZtrkSb)
7
7
  [![Support me](https://img.shields.io/badge/-Support%20me-ff69b4?style=flat-square&logo=githubsponsors&logoColor=white)](https://github.com/sponsors/vivy-company)
8
8
 
9
- Experimental project: browser terminal rendering with a WASM terminal core, GPU rendering (WebGPU + WebGL2 fallback), and TypeScript text shaping.
9
+ Powerful, lightweight browser terminal. Batteries included.
10
10
 
11
- restty combines a Zig/WASM VT engine, modern browser rendering pipelines, and a local playground + PTY server to iterate quickly on terminal behavior.
11
+ Powered by:
12
+ - `libghostty-vt` (WASM terminal core)
13
+ - `WebGPU` (with WebGL2 fallback)
14
+ - `text-shaper` (shaping + raster)
12
15
 
13
- ## Why
16
+ ## Install
14
17
 
15
- - Build a browser terminal stack with explicit control over rendering and input.
16
- - Keep terminal state logic in WASM while using TS/JS for browser integration.
17
- - Validate behavior with focused tests (input mapping, UTF-8 handling, kitty graphics, glyph rendering).
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
- - Start here: `docs/README.md`
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
- ## App integration
24
+ `restty` ships with built-in text shaping and embedded WASM. You only need a canvas (and optional IME textarea).
37
25
 
38
- Simple usage (built-in `text-shaper` is used automatically):
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("screen") as HTMLCanvasElement,
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
- ## Repository layout
43
+ ## Common examples
49
44
 
50
- - `src/` - Main library/runtime code (renderer, input, PTY bridge, app integration).
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
- ## Requirements
47
+ ```ts
48
+ app.connectPty("ws://localhost:8787/pty");
49
+ ```
62
50
 
63
- - Bun `>=1.2.0`
64
- - Git with submodule support
65
- - Optional: Zig (if rebuilding WASM artifacts from source)
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
- ## Quick start
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
- # Run all tests
83
- bun run test
84
-
85
- # Start PTY websocket server (default ws://localhost:8787/pty)
86
- bun run pty
87
-
88
- # Build playground/runtime bundles
89
- bun run build:assets
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
- ## Testing
124
+ ## Acknowledgements
103
125
 
104
- Current suite covers:
126
+ Huge thanks to the Ghostty project and contributors for `libghostty-vt`, which powers restty's terminal core.
105
127
 
106
- - key/input encoding (`tests/input-keymap.test.ts`, `tests/input-kitty.test.ts`)
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
- ## Notes
130
+ ## Docs
112
131
 
113
- - `tests/webgpu-glyph.test.ts` can bootstrap polyfill artifacts via `scripts/setup-wgpu-polyfill.ts`.
114
- - Built-in themes are embedded in `src/theme/builtin-themes.ts` (generated via `scripts/generate-builtin-themes.ts`).
115
- - Some generated playground assets are intentionally committed for reproducible local runs.
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "restty",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Browser terminal rendering library powered by WASM, WebGPU/WebGL2, and TypeScript text shaping.",
5
5
  "repository": {
6
6
  "type": "git",