restty 0.1.34 → 0.2.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.
Files changed (194) hide show
  1. package/README.md +49 -318
  2. package/dist/chunk-30px21q2.js +0 -0
  3. package/dist/chunk-db9dt7pr.js +55226 -0
  4. package/dist/chunk-s26trws6.js +9136 -0
  5. package/dist/chunk-wdme6j9c.js +1776 -0
  6. package/dist/chunk-xykzfd81.js +0 -0
  7. package/dist/chunk-y6hfk43b.js +1690 -0
  8. package/dist/fonts/local-font-access.types.d.ts +19 -0
  9. package/dist/fonts/manager/entries.d.ts +7 -0
  10. package/dist/headless.d.ts +102 -0
  11. package/dist/headless.js +350 -0
  12. package/dist/ime/ime.d.ts +4 -4
  13. package/dist/index.d.ts +8 -2
  14. package/dist/input/keymap/default-mapping.d.ts +1 -0
  15. package/dist/input/mouse.d.ts +13 -0
  16. package/dist/input/types.d.ts +10 -1
  17. package/dist/internal/runtime.d.ts +4 -0
  18. package/dist/internal/runtime.js +12 -0
  19. package/dist/internal/surface.d.ts +6 -0
  20. package/dist/internal/surface.js +15 -0
  21. package/dist/internal.d.ts +2 -4
  22. package/dist/internal.js +23 -5
  23. package/dist/restty.esm.js +10949 -0
  24. package/dist/restty.js +8 -2
  25. package/dist/runtime/core/api.d.ts +112 -0
  26. package/dist/runtime/core/config.d.ts +133 -0
  27. package/dist/runtime/core/lifecycle.d.ts +1 -0
  28. package/dist/runtime/core/models.d.ts +124 -0
  29. package/dist/runtime/core/resources.d.ts +50 -0
  30. package/dist/runtime/core/runtime-events.d.ts +28 -0
  31. package/dist/runtime/core/session.d.ts +9 -0
  32. package/dist/runtime/{codepoint-utils.d.ts → create-runtime/codepoint-utils.d.ts} +1 -1
  33. package/dist/runtime/create-runtime/{color-glyph-atlas.d.ts → font-runtime/color-glyph-atlas.d.ts} +2 -2
  34. package/dist/runtime/create-runtime/font-runtime/grid.d.ts +6 -0
  35. package/dist/runtime/create-runtime/font-runtime/grid.types.d.ts +22 -0
  36. package/dist/runtime/create-runtime/font-runtime/index.d.ts +15 -0
  37. package/dist/runtime/create-runtime/font-runtime/text.d.ts +12 -0
  38. package/dist/runtime/create-runtime/font-runtime/text.types.d.ts +10 -0
  39. package/dist/runtime/create-runtime/{font-runtime-helpers.types.d.ts → font-runtime/types.d.ts} +6 -8
  40. package/dist/runtime/create-runtime/font-runtime/webgpu-atlas.d.ts +7 -0
  41. package/dist/runtime/create-runtime/font-runtime/webgpu-atlas.types.d.ts +23 -0
  42. package/dist/runtime/create-runtime/highlight-terminal-color-utils.d.ts +6 -0
  43. package/dist/runtime/create-runtime/highlight-terminal-color-utils.types.d.ts +9 -0
  44. package/dist/runtime/create-runtime/input-hooks.d.ts +2 -12
  45. package/dist/runtime/create-runtime/input-hooks.types.d.ts +10 -0
  46. package/dist/runtime/create-runtime/interaction-runtime/bind-ime-events.d.ts +2 -1
  47. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-aux-handlers.d.ts +2 -3
  48. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-events.d.ts +5 -10
  49. package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-up-handler.d.ts +3 -2
  50. package/dist/runtime/create-runtime/interaction-runtime/desktop-word-selection.d.ts +8 -0
  51. package/dist/runtime/create-runtime/{interaction-runtime.d.ts → interaction-runtime/index.d.ts} +3 -2
  52. package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.d.ts +2 -17
  53. package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.types.d.ts +17 -0
  54. package/dist/runtime/create-runtime/interaction-runtime/{types.d.ts → runtime.types.d.ts} +4 -50
  55. package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.d.ts +1 -29
  56. package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.types.d.ts +23 -0
  57. package/dist/runtime/create-runtime/interaction-runtime/state.types.d.ts +47 -0
  58. package/dist/runtime/create-runtime/kitty-render-runtime.d.ts +2 -36
  59. package/dist/runtime/create-runtime/kitty-render-runtime.types.d.ts +33 -0
  60. package/dist/runtime/create-runtime/{lifecycle-theme-size-canvas.d.ts → lifecycle-theme-size/canvas.d.ts} +1 -1
  61. package/dist/runtime/create-runtime/{lifecycle-theme-size.d.ts → lifecycle-theme-size/index.d.ts} +3 -3
  62. package/dist/runtime/create-runtime/lifecycle-theme-size/theme.d.ts +6 -0
  63. package/dist/runtime/create-runtime/{lifecycle-theme-size.types.d.ts → lifecycle-theme-size/types.d.ts} +13 -7
  64. package/dist/runtime/create-runtime/ligature-runs.d.ts +52 -0
  65. package/dist/runtime/{max-scrollback.d.ts → create-runtime/max-scrollback.d.ts} +2 -5
  66. package/dist/runtime/create-runtime/max-scrollback.types.d.ts +4 -0
  67. package/dist/runtime/create-runtime/native-scrollbar-host.d.ts +2 -0
  68. package/dist/runtime/create-runtime/native-scrollbar-host.types.d.ts +13 -0
  69. package/dist/runtime/create-runtime/overlay-scrollbar.d.ts +6 -0
  70. package/dist/runtime/create-runtime/overlay-scrollbar.types.d.ts +12 -0
  71. package/dist/runtime/create-runtime/pty-input-runtime.d.ts +2 -46
  72. package/dist/runtime/create-runtime/pty-input-runtime.types.d.ts +41 -0
  73. package/dist/runtime/{render-color-utils.d.ts → create-runtime/render-color-utils.d.ts} +1 -1
  74. package/dist/runtime/{render-stage-runtime.d.ts → create-runtime/render-stage-runtime.d.ts} +2 -2
  75. package/dist/runtime/{create-app-types.d.ts → create-runtime/render-stage-runtime.types.d.ts} +1 -29
  76. package/dist/runtime/create-runtime/render-tick-webgl-overlays.d.ts +1 -1
  77. package/dist/runtime/create-runtime/render-tick-webgl-scene.d.ts +1 -1
  78. package/dist/runtime/create-runtime/render-tick-webgl.types.d.ts +2 -5
  79. package/dist/runtime/create-runtime/render-tick-webgpu-cell-pass.d.ts +1 -1
  80. package/dist/runtime/create-runtime/render-tick-webgpu.types.d.ts +15 -11
  81. package/dist/runtime/create-runtime/runtime-controller.api.types.d.ts +96 -0
  82. package/dist/runtime/create-runtime/runtime-controller.clipboard.d.ts +10 -0
  83. package/dist/runtime/create-runtime/runtime-controller.d.ts +3 -0
  84. package/dist/runtime/create-runtime/runtime-controller.input.d.ts +24 -0
  85. package/dist/runtime/create-runtime/runtime-controller.keyboard.d.ts +19 -0
  86. package/dist/runtime/create-runtime/runtime-controller.lifecycle.d.ts +50 -0
  87. package/dist/runtime/create-runtime/runtime-controller.public-api.capabilities.d.ts +57 -0
  88. package/dist/runtime/create-runtime/runtime-controller.public-api.d.ts +28 -0
  89. package/dist/runtime/create-runtime/runtime-controller.render-loop.d.ts +20 -0
  90. package/dist/runtime/create-runtime/runtime-controller.state.types.d.ts +24 -0
  91. package/dist/runtime/create-runtime/runtime-reporting.d.ts +3 -21
  92. package/dist/runtime/create-runtime/runtime-reporting.types.d.ts +18 -0
  93. package/dist/runtime/{create-app-symbols.d.ts → create-runtime/runtime-symbols.d.ts} +2 -2
  94. package/dist/runtime/create-runtime/search-highlight-utils.d.ts +21 -0
  95. package/dist/runtime/create-runtime/search-runtime/index.d.ts +2 -0
  96. package/dist/runtime/create-runtime/search-runtime/types.d.ts +25 -0
  97. package/dist/runtime/create-runtime/shader-stage-runtime.d.ts +2 -29
  98. package/dist/runtime/create-runtime/shader-stage-runtime.types.d.ts +27 -0
  99. package/dist/runtime/{text-decoration.d.ts → create-runtime/text-decoration.d.ts} +1 -1
  100. package/dist/runtime/create-runtime.d.ts +7 -7
  101. package/dist/runtime/font-atlas-utils/glyph-atlas-builder.d.ts +1 -1
  102. package/dist/runtime/font-atlas-utils/nerd-metrics-utils.d.ts +1 -1
  103. package/dist/runtime/{atlas-builder.d.ts → fonts/atlas-builder.d.ts} +1 -1
  104. package/dist/runtime/{font-resource-store.d.ts → fonts/font-resource-store.d.ts} +3 -2
  105. package/dist/runtime/fonts/font-sources.d.ts +4 -0
  106. package/dist/runtime/shader-stages.d.ts +1 -1
  107. package/dist/runtime/types.d.ts +6 -365
  108. package/dist/surface/{panes-context-menu.d.ts → panes/context-menu.d.ts} +1 -1
  109. package/dist/surface/panes/default-context-menu-items.d.ts +2 -2
  110. package/dist/surface/panes/layout.d.ts +1 -1
  111. package/dist/surface/panes/managed-pane-create.d.ts +3 -0
  112. package/dist/surface/panes/managed-pane-create.types.d.ts +17 -0
  113. package/dist/surface/panes/managed-pane-dom.d.ts +13 -0
  114. package/dist/surface/panes/managed-pane-manager.d.ts +6 -0
  115. package/dist/surface/panes/managed-pane-options.d.ts +6 -0
  116. package/dist/surface/panes/managed-pane-options.types.d.ts +7 -0
  117. package/dist/surface/panes/managed-pane-runtime-config.d.ts +3 -0
  118. package/dist/surface/panes/managed-pane-runtime-config.types.d.ts +9 -0
  119. package/dist/surface/panes/managed-pane-runtime.d.ts +3 -0
  120. package/dist/surface/panes/managed-pane-runtime.types.d.ts +10 -0
  121. package/dist/surface/panes/managed-pane-search-ui.d.ts +9 -0
  122. package/dist/surface/panes/managed-pane-types.d.ts +102 -0
  123. package/dist/surface/panes/manager.d.ts +1 -1
  124. package/dist/surface/panes/pane-interactions.d.ts +2 -2
  125. package/dist/surface/{panes-styles.d.ts → panes/styles.d.ts} +1 -1
  126. package/dist/surface/{panes-types.d.ts → panes/types.d.ts} +48 -7
  127. package/dist/surface/panes/window-events.d.ts +1 -1
  128. package/dist/surface/{restty-plugin-types.d.ts → plugins/context.types.d.ts} +32 -88
  129. package/dist/surface/{restty/plugin-dispatcher.d.ts → plugins/dispatcher.d.ts} +4 -13
  130. package/dist/surface/plugins/dispatcher.types.d.ts +6 -0
  131. package/dist/surface/{restty/plugin-ops.d.ts → plugins/host.d.ts} +4 -3
  132. package/dist/surface/plugins/runtime.d.ts +18 -0
  133. package/dist/surface/plugins/runtime.types.d.ts +47 -0
  134. package/dist/surface/plugins/types.d.ts +83 -0
  135. package/dist/surface/restty/active-pane-api.d.ts +34 -16
  136. package/dist/surface/restty/assembly.d.ts +23 -0
  137. package/dist/surface/restty/bootstrap.d.ts +21 -0
  138. package/dist/surface/restty/config.d.ts +46 -0
  139. package/dist/surface/restty/controller.d.ts +45 -0
  140. package/dist/surface/restty/events.d.ts +14 -0
  141. package/dist/surface/restty/manager-options.d.ts +4 -23
  142. package/dist/surface/restty/manager-options.types.d.ts +32 -0
  143. package/dist/surface/restty/pane-command-ops.d.ts +37 -0
  144. package/dist/surface/restty/pane-handle-ops.d.ts +24 -0
  145. package/dist/surface/restty/pane-handle.d.ts +107 -0
  146. package/dist/surface/restty/pane-lookup.d.ts +22 -0
  147. package/dist/surface/restty/pane-manager-assembly.d.ts +18 -0
  148. package/dist/surface/restty/pane-ops.d.ts +3 -42
  149. package/dist/surface/restty/pane-style-ops.d.ts +6 -0
  150. package/dist/surface/restty/plugin-surface.d.ts +5 -0
  151. package/dist/surface/restty/shader-ops.d.ts +6 -5
  152. package/dist/surface/restty.d.ts +30 -49
  153. package/dist/surface/search-ui/controller.d.ts +2 -0
  154. package/dist/surface/search-ui/index.d.ts +2 -0
  155. package/dist/surface/search-ui/styles.d.ts +5 -0
  156. package/dist/surface/search-ui/types.d.ts +96 -0
  157. package/dist/theme/ghostty.d.ts +13 -2
  158. package/dist/wasm/embedded.d.ts +1 -1
  159. package/dist/wasm/index.d.ts +1 -1
  160. package/dist/wasm/runtime/restty-wasm.d.ts +15 -1
  161. package/dist/wasm/runtime/types.d.ts +24 -6
  162. package/dist/xterm/compat-services.d.ts +2 -0
  163. package/dist/xterm.d.ts +4 -3
  164. package/dist/xterm.js +14 -8
  165. package/package.json +59 -24
  166. package/dist/chunk-meqn8xtd.js +0 -66867
  167. package/dist/runtime/create-runtime/debug-tools/create-dump-glyph-render.d.ts +0 -2
  168. package/dist/runtime/create-runtime/debug-tools/diagnose-codepoint.d.ts +0 -2
  169. package/dist/runtime/create-runtime/debug-tools/dump-atlas-for-codepoint.d.ts +0 -2
  170. package/dist/runtime/create-runtime/debug-tools/read-texture-to-image-data.d.ts +0 -1
  171. package/dist/runtime/create-runtime/debug-tools/setup-debug-expose.d.ts +0 -2
  172. package/dist/runtime/create-runtime/debug-tools/types.d.ts +0 -63
  173. package/dist/runtime/create-runtime/debug-tools.d.ts +0 -6
  174. package/dist/runtime/create-runtime/font-runtime-grid-helpers.d.ts +0 -30
  175. package/dist/runtime/create-runtime/font-runtime-helpers.d.ts +0 -15
  176. package/dist/runtime/create-runtime/font-runtime-text-helpers.d.ts +0 -21
  177. package/dist/runtime/create-runtime/font-runtime-webgpu-atlas.d.ts +0 -29
  178. package/dist/runtime/create-runtime/lifecycle-theme-size-theme.d.ts +0 -6
  179. package/dist/runtime/create-runtime/runtime-app-api.d.ts +0 -105
  180. package/dist/runtime/create-runtime/runtime-logger.d.ts +0 -17
  181. package/dist/runtime/font-sources.d.ts +0 -5
  182. package/dist/runtime/overlay-scrollbar.d.ts +0 -24
  183. package/dist/runtime/pty-output-buffer.d.ts +0 -12
  184. package/dist/runtime/session.d.ts +0 -9
  185. package/dist/surface/app-factory.d.ts +0 -3
  186. package/dist/surface/pane-app-manager.d.ts +0 -89
  187. package/dist/surface/restty-pane-handle.d.ts +0 -70
  188. package/dist/surface/restty-plugin-runtime.d.ts +0 -57
  189. package/dist/xterm/app-options.d.ts +0 -2
  190. /package/dist/runtime/create-runtime/{atlas-debug-utils.d.ts → atlas-bitmap-utils.d.ts} +0 -0
  191. /package/dist/runtime/{clipboard-paste.d.ts → create-runtime/clipboard-paste.d.ts} +0 -0
  192. /package/dist/runtime/{render-stage-shaders.d.ts → create-runtime/render-stage-shaders.d.ts} +0 -0
  193. /package/dist/runtime/{create-app-io-utils.d.ts → create-runtime/runtime-io-utils.d.ts} +0 -0
  194. /package/dist/surface/{restty-plugin-utils.d.ts → plugins/utils.d.ts} +0 -0
package/README.md CHANGED
@@ -1,36 +1,20 @@
1
1
  # restty
2
2
 
3
3
  [![Version](https://img.shields.io/npm/v/restty?style=flat-square)](https://www.npmjs.com/package/restty)
4
- [![Downloads](https://img.shields.io/npm/dm/restty)](https://www.npmjs.com/package/restty)
5
- [![Package Size](https://img.shields.io/npm/unpacked-size/restty?style=flat-square)](https://www.npmjs.com/package/restty)
4
+ [![Downloads](https://img.shields.io/npm/dm/restty?style=flat-square)](https://www.npmjs.com/package/restty)
6
5
  [![CI](https://img.shields.io/github/actions/workflow/status/wiedymi/restty/ci.yml?branch=main&style=flat-square)](https://github.com/wiedymi/restty/actions/workflows/ci.yml)
7
- [![Publish](https://img.shields.io/github/actions/workflow/status/wiedymi/restty/publish.yml?style=flat-square&label=publish)](https://github.com/wiedymi/restty/actions/workflows/publish.yml)
8
6
  [![Demo](https://img.shields.io/badge/demo-restty.pages.dev-0ea5e9?style=flat-square)](https://restty.pages.dev/)
9
7
 
10
- [![GitHub](https://img.shields.io/badge/-GitHub-181717?style=flat-square&logo=github&logoColor=white)](https://github.com/wiedymi)
11
- [![Twitter](https://img.shields.io/badge/-Twitter-1DA1F2?style=flat-square&logo=twitter&logoColor=white)](https://x.com/wiedymi)
12
- [![Email](https://img.shields.io/badge/-Email-EA4335?style=flat-square&logo=gmail&logoColor=white)](mailto:contact@wiedymi.com)
13
- [![Discord](https://img.shields.io/badge/-Discord-5865F2?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/zemMZtrkSb)
14
- [![Support me](https://img.shields.io/badge/-Support%20me-ff69b4?style=flat-square&logo=githubsponsors&logoColor=white)](https://github.com/sponsors/vivy-company)
8
+ Browser terminal rendering for web apps, powered by `libghostty-vt` in WASM,
9
+ WebGPU with WebGL2 fallback, and TypeScript text shaping.
15
10
 
16
- Powerful, lightweight browser terminal. Batteries included.
11
+ - Demo: <https://restty.pages.dev/>
12
+ - Canonical docs: <https://restty.pages.dev/docs>
13
+ - npm: <https://www.npmjs.com/package/restty>
14
+ - Issues: <https://github.com/wiedymi/restty/issues>
17
15
 
18
- Live demo: `https://restty.pages.dev/`
19
-
20
- Powered by:
21
-
22
- - `libghostty-vt` (WASM terminal core)
23
- - `WebGPU` (with WebGL2 fallback)
24
- - `text-shaper` (shaping + raster)
25
-
26
- ## Release Status
27
-
28
- `restty` is in an early release stage.
29
-
30
- - Known issue: kitty image protocol handling can still fail in some edge cases.
31
- - API note: high-level APIs are usable now, but some APIs may still change to improve DX.
32
-
33
- If you hit an issue, please open one on GitHub with repro steps.
16
+ `restty` is early-release software. The high-level API is usable, but some APIs may still change
17
+ while the developer experience settles.
34
18
 
35
19
  ## Install
36
20
 
@@ -54,281 +38,36 @@ const restty = new Restty({
54
38
  restty.connectPty("ws://localhost:8787/pty");
55
39
  ```
56
40
 
57
- That is the primary API: `new Restty(...)`.
58
- `restty` creates pane DOM, canvas, and hidden IME input for you.
59
-
60
- ## Common Tasks
61
-
62
- ### Apply a built-in theme
63
-
64
- ```ts
65
- import { getBuiltinTheme } from "restty";
66
-
67
- const theme = getBuiltinTheme("Aizen Dark");
68
- if (theme) restty.applyTheme(theme);
69
- ```
70
-
71
- ### Parse and apply a Ghostty theme file
72
-
73
- ```ts
74
- import { parseGhosttyTheme } from "restty";
75
-
76
- const theme = parseGhosttyTheme(`
77
- foreground = #c0caf5
78
- background = #1a1b26
79
- cursor-color = #c0caf5
80
- `);
81
-
82
- restty.applyTheme(theme, "inline");
83
- ```
84
-
85
- ### Split panes and operate per pane
86
-
87
- ```ts
88
- restty.splitActivePane("vertical");
89
- restty.splitActivePane("horizontal");
41
+ `new Restty(...)` creates the pane DOM, canvas, and hidden IME input for you.
90
42
 
91
- for (const pane of restty.panes()) {
92
- pane.connectPty("ws://localhost:8787/pty");
93
- }
94
- ```
43
+ ## Main Entrypoints
95
44
 
96
- ### Use active-pane convenience methods
45
+ - `restty`: primary API (`Restty`, `createRestty`, themes, fonts, PTY helpers, plugin types).
46
+ - `restty/xterm`: focused xterm.js-style compatibility wrapper.
47
+ - `restty/headless`: DOM-free WASM terminal core wrapper for replay, tests, and backend-owned sessions.
48
+ - `restty/esm`: standalone browser ESM bundle for script/CDN usage.
49
+ - `restty/internal`, `restty/internal/runtime`, `restty/internal/surface`: unstable advanced modules.
97
50
 
98
- ```ts
99
- restty.setFontSize(15);
100
- restty.sendInput("ls -la\n");
101
- restty.copySelectionToClipboard();
102
- ```
51
+ See the canonical [API surface docs](https://restty.pages.dev/docs/api-surface) for the current
52
+ method and export list.
103
53
 
104
- ### Provide custom fonts
105
-
106
- By default, restty uses a local-first font preset with CDN fallback. To fully control fonts, disable the preset and pass `fontSources`.
107
-
108
- ```ts
109
- const restty = new Restty({
110
- root: document.getElementById("terminal") as HTMLElement,
111
- appOptions: {
112
- fontPreset: "none",
113
- },
114
- fontSources: [
115
- {
116
- type: "url",
117
- url: "https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/ttf/JetBrainsMono-Regular.ttf",
118
- label: "JetBrains Mono",
119
- },
120
- {
121
- type: "local",
122
- matchers: ["jetbrains mono nerd font", "fira code nerd font"],
123
- label: "Local fallback",
124
- },
125
- ],
126
- });
127
- ```
128
-
129
- Update fonts at runtime (all panes):
130
-
131
- ```ts
132
- await restty.setFontSources([
133
- { type: "local", matchers: ["sf mono"], required: true },
134
- {
135
- type: "url",
136
- url: "https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@v3.4.0/patched-fonts/NerdFontsSymbolsOnly/SymbolsNerdFontMono-Regular.ttf",
137
- },
138
- ]);
139
- ```
140
-
141
- ### Touch behavior (pan-first by default)
142
-
143
- On touch devices, restty defaults to pan-first scrolling with long-press selection.
144
-
145
- ```ts
146
- const restty = new Restty({
147
- root: document.getElementById("terminal") as HTMLElement,
148
- appOptions: {
149
- // "long-press" (default) | "drag" | "off"
150
- touchSelectionMode: "long-press",
151
- // Optional tuning knobs:
152
- touchSelectionLongPressMs: 450,
153
- touchSelectionMoveThresholdPx: 10,
154
- },
155
- });
156
- ```
157
-
158
- ### Plugin system (native)
159
-
160
- Use plugins when you want to extend restty behavior without patching core.
161
-
162
- ```ts
163
- import type { ResttyPlugin } from "restty";
54
+ ## Common Links
164
55
 
165
- const metricsPlugin: ResttyPlugin = {
166
- id: "example/metrics",
167
- apiVersion: 1,
168
- activate(ctx) {
169
- const paneCreated = ctx.on("pane:created", ({ paneId }) => {
170
- console.log("pane created", paneId);
171
- });
172
- const outgoing = ctx.addInputInterceptor(({ text }) => text.replace(/\t/g, " "));
173
- const lifecycle = ctx.addLifecycleHook(({ phase, action }) => {
174
- console.log("lifecycle", phase, action);
175
- });
176
- const stage = ctx.addRenderStage({
177
- id: "metrics/tint",
178
- mode: "after-main",
179
- uniforms: [0.12],
180
- shader: {
181
- wgsl: `
182
- fn resttyStage(color: vec4f, uv: vec2f, time: f32, params0: vec4f, params1: vec4f) -> vec4f {
183
- return vec4f(min(vec3f(1.0), color.rgb + vec3f(params0.x, 0.0, 0.0)), color.a);
184
- }
185
- `,
186
- },
187
- });
188
- return () => {
189
- paneCreated.dispose();
190
- outgoing.dispose();
191
- lifecycle.dispose();
192
- stage.dispose();
193
- };
194
- },
195
- };
196
-
197
- await restty.use(metricsPlugin, { sampleRate: 1 });
198
- console.log(restty.pluginInfo("example/metrics"));
199
- restty.unuse("example/metrics");
200
- ```
201
-
202
- Declarative loading (manifest + registry):
203
-
204
- ```ts
205
- await restty.loadPlugins(
206
- [{ id: "example/metrics", options: { sampleRate: 1 } }],
207
- {
208
- "example/metrics": () => metricsPlugin,
209
- },
210
- );
211
- ```
212
-
213
- See `docs/plugins.md` for full plugin authoring details.
214
-
215
- ### Shader stages
216
-
217
- Shader stages let you extend the final frame pipeline with WGSL/GLSL passes.
218
-
219
- Global stages:
220
-
221
- ```ts
222
- restty.setShaderStages([
223
- {
224
- id: "app/crt-lite",
225
- mode: "after-main",
226
- backend: "both",
227
- uniforms: [0.24, 0.12],
228
- shader: {
229
- wgsl: `
230
- fn resttyStage(color: vec4f, uv: vec2f, time: f32, params0: vec4f, params1: vec4f) -> vec4f {
231
- let v = clamp(params0.x, 0.0, 0.8);
232
- let centered = (uv - vec2f(0.5, 0.5)) * 2.0;
233
- let vignette = max(0.0, 1.0 - v * dot(centered, centered));
234
- return vec4f(color.rgb * vignette, color.a);
235
- }
236
- `,
237
- },
238
- },
239
- ]);
240
-
241
- const stage = restty.addShaderStage({
242
- id: "app/mono",
243
- mode: "after-main",
244
- uniforms: [1.0],
245
- shader: {
246
- wgsl: `
247
- fn resttyStage(color: vec4f, uv: vec2f, time: f32, params0: vec4f, params1: vec4f) -> vec4f {
248
- let l = dot(color.rgb, vec3f(0.2126, 0.7152, 0.0722));
249
- return vec4f(l * 0.12, l * 0.95, l * 0.35, color.a);
250
- }
251
- `,
252
- },
253
- });
254
-
255
- stage.setEnabled(false);
256
- restty.removeShaderStage("app/mono");
257
- ```
258
-
259
- ### xterm compatibility layer
260
-
261
- For migration from xterm.js-style app code, use `restty/xterm`:
262
-
263
- ```ts
264
- import { Terminal } from "restty/xterm";
265
-
266
- const term = new Terminal({ cols: 100, rows: 30 });
267
- term.open(document.getElementById("terminal") as HTMLElement);
268
-
269
- term.onData((data) => console.log("input", data));
270
- term.onResize(({ cols, rows }) => console.log("resize", cols, rows));
271
-
272
- term.write("hello");
273
- term.writeln(" world");
274
- term.resize(120, 40);
275
- term.loadAddon({
276
- activate() {},
277
- dispose() {},
278
- });
279
- ```
280
-
281
- Compatibility scope:
282
-
283
- - Good for common embed/migration flows.
284
- - Not full xterm internals parity (buffer/parser/marker ecosystem APIs are not all implemented).
285
- - Prefer native `Restty` API for long-term integrations.
286
-
287
- ## API Snapshot
288
-
289
- Primary class:
290
-
291
- - `new Restty({ root, ...options })`
292
- - `createRestty(options)`
293
-
294
- Xterm compatibility:
295
-
296
- - `import { Terminal } from "restty/xterm"`
297
- - Supports `open`, `write`, `writeln`, `resize`, `focus`, `blur`, `clear`, `reset`, `onData`, `onResize`, `options`, `loadAddon`, `dispose`
298
-
299
- Pane access:
300
-
301
- - `panes()` / `pane(id)` / `activePane()` / `focusedPane()` / `forEachPane(visitor)`
302
- - `splitActivePane("vertical" | "horizontal")` / `splitPane(id, direction)` / `closePane(id)`
303
-
304
- Active-pane convenience:
305
-
306
- - `connectPty(url)` / `disconnectPty()` / `isPtyConnected()`
307
- - `setRenderer("auto" | "webgpu" | "webgl2")`
308
- - `setFontSize(number)` / `setFontSources([...])`
309
- - `applyTheme(theme)` / `resetTheme()`
310
- - `setMouseMode("auto" | "on" | "off")`
311
- - `sendInput(text)` / `sendKeyInput(text)`
312
- - `copySelectionToClipboard()` / `pasteFromClipboard()`
313
- - `resize(cols, rows)` / `focus()` / `blur()`
314
- - `updateSize(force?)`
315
- - `destroy()`
316
-
317
- Plugin host:
318
-
319
- - `use(plugin, options?)` / `loadPlugins(manifest, registry)` / `unuse(pluginId)` / `plugins()` / `pluginInfo(pluginId?)`
320
- - plugin context supports `on(...)`, `addInputInterceptor(...)`, `addOutputInterceptor(...)`, `addLifecycleHook(...)`, `addRenderHook(...)`, `addRenderStage(...)`
321
-
322
- Shader stages:
323
-
324
- - `setShaderStages(stages)` / `getShaderStages()`
325
- - `addShaderStage(stage)` / `removeShaderStage(id)`
326
-
327
- ## Advanced / Internal Modules
328
-
329
- Use these only when you need lower-level control:
330
-
331
- - `restty/internal`: full internal barrel (unstable; includes low-level modules like WASM/input/pty helpers)
56
+ - [Getting started](https://restty.pages.dev/docs/getting-started)
57
+ - [Core concepts](https://restty.pages.dev/docs/core-concepts)
58
+ - [Surface and panes](https://restty.pages.dev/docs/surface-and-panes)
59
+ - [Configuration](https://restty.pages.dev/docs/configuration)
60
+ - [PTY backends](https://restty.pages.dev/docs/pty-backends)
61
+ - [Headless terminal](https://restty.pages.dev/docs/headless)
62
+ - [Search](https://restty.pages.dev/docs/search)
63
+ - [Playground examples](https://restty.pages.dev/docs/playground-examples)
64
+ - [Fonts](https://restty.pages.dev/docs/fonts)
65
+ - [Themes and shaders](https://restty.pages.dev/docs/themes)
66
+ - [Plugins](https://restty.pages.dev/docs/plugins)
67
+ - [xterm compatibility](https://restty.pages.dev/docs/xterm-compat)
68
+ - [Troubleshooting](https://restty.pages.dev/docs/troubleshooting)
69
+ - [Architecture](https://restty.pages.dev/docs/architecture)
70
+ - [Runnable examples](./examples)
332
71
 
333
72
  ## Local Development
334
73
 
@@ -343,31 +82,23 @@ bun run playground
343
82
 
344
83
  Open `http://localhost:5173`.
345
84
 
346
- ## Code Layout
347
-
348
- - `src/surface/`: public API (`Restty`), pane manager orchestration, plugin host, xterm shim.
349
- - `src/runtime/`: terminal runtime/render loop implementation.
350
- - `src/renderer/`, `src/input/`, `src/pty/`, `src/fonts/`, `src/theme/`, `src/wasm/`, `src/selection/`: subsystem modules.
351
- - `src/app/`: compatibility re-export layer while internals are refactored.
352
-
353
- ## Repository Commands
85
+ Useful checks:
354
86
 
355
87
  ```bash
356
- bun run build # build package output
357
- bun run test # full tests
358
- bun run test:ci # CI-safe test target
359
- bun run lint # lint
360
- bun run format:check # formatting check
361
- bun run build:assets # static playground bundle (playground/public/playground.js)
362
- bun run playground # one-command local dev (PTY + playground dev server)
363
- bun run pty # PTY websocket server only
88
+ bun run build
89
+ bun run test:ci
90
+ bun run lint
91
+ bun run format:check
92
+ bun run playground:build
364
93
  ```
365
94
 
366
- ## Documentation
95
+ Cloudflare Pages deployment settings:
96
+
97
+ - Framework preset: `None`
98
+ - Build command: `bun install --frozen-lockfile && bun run pages:build`
99
+ - Build output directory: `playground/dist`
100
+ - Root directory: leave blank
101
+ - Environment variables: set `SKIP_DEPENDENCY_INSTALL=1` when using the build command above.
367
102
 
368
- - `docs/README.md` - docs index
369
- - `docs/usage.md` - practical integration guide
370
- - `docs/xterm-compat.md` - xterm migration shim
371
- - `docs/how-it-works.md` - runtime flow
372
- - `docs/internals/` - implementation notes and architecture
373
- - `THIRD_PARTY_NOTICES.md` - third-party credits and notices
103
+ The hosted docs are sourced from `playground/content/docs/`. Repository notes under `docs/` are
104
+ legacy/internal references for development context.
File without changes