@cplieger/web-terminal-ui 2.1.4 → 3.0.1

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
@@ -11,18 +11,25 @@ The reference touch-first browser UI for
11
11
  that turns the engine's render/scroll/connection/keyboard modules into a
12
12
  usable terminal on a phone as well as a desktop.
13
13
 
14
- One `mount(root)` call builds the entire terminal UI inside a single container
15
- element you provide and owns everything above the raw terminal:
14
+ One `createTerminal(root, { features })` call builds the entire terminal UI
15
+ inside a single container element you provide. A small always-present kernel
16
+ (the display output, the hidden keyboard textarea, IME, engine wiring, the
17
+ sanitizing input funnel, connection-state, and named layout regions) composes
18
+ with opt-in feature modules that own everything above the raw terminal:
16
19
 
17
20
  - a **display-only** terminal output (native text selection survives redraws)
18
- - a hidden `<textarea>` that owns the keyboard, the local typing buffer, and IME
21
+ and a hidden `<textarea>` that owns the keyboard and IME (the kernel)
22
+ - **tabs**: multiple independent terminals with a desktop strip, a mobile
23
+ bottom switcher, and a modal overview sheet
24
+ - an **activity monitor** that drives per-tab status dots (working / idle /
25
+ needs-input / exited) from the server's status stream
19
26
  - a **mobile key toolbar** (Tab / Esc / arrows / Enter / sticky-Ctrl) and a
20
27
  scroll-to-bottom control
21
- - a **viewport-clamped context menu** (Copy / Select All / Paste)
22
- - **predictive local echo** so the cursor moves on keypress even on a slow link
23
- - **IME / composition** handling (CJK, dictation, autocorrect)
24
- - **viewport + keyboard-inset** handling for the iOS soft keyboard, rotation,
25
- and font-load reflows
28
+ - a **context menu** (Copy / Select All / Paste), reachable by right-click and
29
+ by long-press on touch
30
+ - **predictive local echo**, **IME / composition** (CJK, dictation,
31
+ autocorrect), and **viewport + keyboard-inset** handling for the iOS soft
32
+ keyboard, rotation, and font-load reflows
26
33
  - a connection-status banner and a copy toast
27
34
 
28
35
  It is published as TypeScript source (no build step) to npm and JSR, alongside
@@ -43,8 +50,9 @@ pins the engine version explicitly.
43
50
 
44
51
  Serve the bundled CSS (`css/` concatenated per `css/MANIFEST` into the
45
52
  `style.css` your page links) plus a minimal HTML page that has one empty
46
- container element for the terminal, then call `mount(root)` from your entry
47
- module:
53
+ container element for the terminal, then call `createTerminal(root, { features })`
54
+ from your entry module. Feature bundles (presets) live at the `./presets`
55
+ sub-path:
48
56
 
49
57
  ```html
50
58
  <div id="terminal"></div>
@@ -53,45 +61,62 @@ module:
53
61
  {
54
62
  "imports": {
55
63
  "@cplieger/web-terminal-engine": "/vendor/cplieger-web-terminal-engine/index.js",
56
- "@cplieger/web-terminal-ui": "/vendor/cplieger-web-terminal-ui/index.js"
64
+ "@cplieger/web-terminal-ui": "/vendor/cplieger-web-terminal-ui/index.js",
65
+ "@cplieger/web-terminal-ui/presets": "/vendor/cplieger-web-terminal-ui/presets.js"
57
66
  }
58
67
  }
59
68
  </script>
60
69
  <script type="module">
61
- import { mount } from "@cplieger/web-terminal-ui";
62
- mount(document.getElementById("terminal"), {
70
+ import { createTerminal } from "@cplieger/web-terminal-ui";
71
+ import { presetTabbed } from "@cplieger/web-terminal-ui/presets";
72
+ createTerminal(document.getElementById("terminal"), {
73
+ features: presetTabbed(),
63
74
  loading: document.getElementById("loading"),
64
75
  });
65
76
  // or, for a server that exposes the WebSocket elsewhere / a custom font:
66
- // mount(root, { wsPath: "/api/shell/ws", fontReady: '14px "MyMono"' });
77
+ // createTerminal(root, { features: presetTabbed(), wsPath: "/api/shell/ws", fontReady: '14px "MyMono"' });
67
78
  </script>
68
79
  ```
69
80
 
70
- `mount(root, opts?)` builds the entire terminal subtree (the display output,
71
- the hidden keyboard textarea, the mobile key toolbar, the status banner, and
72
- the context menu) inside `root` itself — there is no element-id contract for
73
- the host page to reproduce. Call it exactly once; the module state is
74
- single-instance per page. `scaffold/index.html` is a complete reference page to
75
- copy and adapt.
81
+ `createTerminal(root, opts?)` builds the entire terminal subtree (the kernel
82
+ plus every feature's chrome) inside `root` itself — there is no element-id
83
+ contract for the host page to reproduce. Call it exactly once; the engine's
84
+ render/connection/scroll modules are single-instance per page (tabs multiplex
85
+ sessions over the one kernel). `scaffold/index.html` is a complete reference page
86
+ to copy and adapt.
87
+
88
+ Three presets are provided (import from `@cplieger/web-terminal-ui/presets`); each
89
+ is a plain feature-array factory, so you can spread and edit it, or hand-pick
90
+ individual features instead:
91
+
92
+ - `presetSingle()` — single-pane desktop UI (context menu, clipboard,
93
+ scroll-to-bottom, predictive echo, connection banner).
94
+ - `presetTouch()` — `presetSingle()` plus the mobile key toolbar.
95
+ - `presetTabbed()` — the full reference UI: `presetTouch()` plus tabs, the
96
+ activity monitor, and animations. Requires a server that speaks the session
97
+ API (`/api/sessions`, the status SSE, and `/ws?session=`), such as
98
+ `web-terminal-server` or `vibecli`.
76
99
 
77
100
  ### Options
78
101
 
79
- | Option | Default | Purpose |
80
- | ----------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
81
- | `wsPath` | `"/ws"` | WebSocket endpoint path the engine connects to. |
82
- | `fontReady` | `'14px "MonaspiceNe NFM"'` | CSS font shorthand awaited before the first resize, so the server is sized against the real web font's cell metrics rather than a fallback. |
83
- | `loading` | _(none)_ | A pre-JS loading overlay element (kept in your served HTML so it paints before this module loads); mount fades it out and removes it once the first frame renders. |
102
+ | Option | Default | Purpose |
103
+ | ----------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
104
+ | `features` | _(none — bare kernel)_ | The feature list. Omitted or empty builds only the terminal (no chrome). Use a preset from `./presets` or a hand-picked array. |
105
+ | `wsPath` | `"/ws"` | WebSocket endpoint path the engine connects to. |
106
+ | `fontReady` | `'14px "MonaspiceNe NFM"'` | CSS font shorthand awaited before the first resize, so the server is sized against the real web font's cell metrics rather than a fallback. |
107
+ | `loading` | _(none)_ | A pre-JS loading overlay element (kept in your served HTML so it paints before this module loads); it is faded out and removed once the first frame renders. |
84
108
 
85
- `mount()` returns a small handle: `{ focus() }` re-focuses the terminal input
86
- (and opens the soft keyboard on touch).
109
+ `createTerminal()` returns a handle: `focus()` re-focuses the terminal input
110
+ (and opens the soft keyboard on touch), and `destroy()` tears every feature down
111
+ and releases the kernel.
87
112
 
88
113
  ## What ships
89
114
 
90
- | Path | Purpose |
91
- | ------------------------ | --------------------------------------------------------------------- |
92
- | `src/*.ts` | The UI modules (`mount`, IME, predictive echo, viewport, status). |
93
- | `css/*.css` + `MANIFEST` | The default theme + layout; concatenate in MANIFEST order. |
94
- | `scaffold/index.html` | A reference HTML page: `<head>` + one empty root element + importmap. |
115
+ | Path | Purpose |
116
+ | ------------------------ | --------------------------------------------------------------------------------------------------------------- |
117
+ | `src/**/*.ts` | The UI modules: the kernel (`kernel/`), opt-in features (`features/`), presets, IME, predictive echo, viewport. |
118
+ | `css/*.css` + `MANIFEST` | The default theme + layout; concatenate in MANIFEST order. |
119
+ | `scaffold/index.html` | A reference HTML page: `<head>` + one empty root element + importmap. |
95
120
 
96
121
  ## Related projects
97
122