restty 0.1.25 → 0.1.27

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 CHANGED
@@ -173,10 +173,23 @@ const metricsPlugin: ResttyPlugin = {
173
173
  const lifecycle = ctx.addLifecycleHook(({ phase, action }) => {
174
174
  console.log("lifecycle", phase, action);
175
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
+ });
176
188
  return () => {
177
189
  paneCreated.dispose();
178
190
  outgoing.dispose();
179
191
  lifecycle.dispose();
192
+ stage.dispose();
180
193
  };
181
194
  },
182
195
  };
@@ -199,6 +212,50 @@ await restty.loadPlugins(
199
212
 
200
213
  See `docs/plugins.md` for full plugin authoring details.
201
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
+
202
259
  ### xterm compatibility layer
203
260
 
204
261
  For migration from xterm.js-style app code, use `restty/xterm`:
@@ -260,7 +317,12 @@ Active-pane convenience:
260
317
  Plugin host:
261
318
 
262
319
  - `use(plugin, options?)` / `loadPlugins(manifest, registry)` / `unuse(pluginId)` / `plugins()` / `pluginInfo(pluginId?)`
263
- - plugin context supports `on(...)`, `addInputInterceptor(...)`, `addOutputInterceptor(...)`, `addLifecycleHook(...)`, `addRenderHook(...)`
320
+ - plugin context supports `on(...)`, `addInputInterceptor(...)`, `addOutputInterceptor(...)`, `addLifecycleHook(...)`, `addRenderHook(...)`, `addRenderStage(...)`
321
+
322
+ Shader stages:
323
+
324
+ - `setShaderStages(stages)` / `getShaderStages()`
325
+ - `addShaderStage(stage)` / `removeShaderStage(id)`
264
326
 
265
327
  ## Advanced / Internal Modules
266
328
 
@@ -281,6 +343,13 @@ bun run playground
281
343
 
282
344
  Open `http://localhost:5173`.
283
345
 
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
+
284
353
  ## Repository Commands
285
354
 
286
355
  ```bash