@fusion.dev/helix-terminal 0.0.0-dev

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fusion Development Group
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @fusion.dev/helix-terminal
2
+
3
+ Connects the Helix `Terminal` frame to the emulator that draws it: xterm.js,
4
+ or a driver of your own, themed from your tokens.
5
+
6
+ ```sh
7
+ bun add @fusion.dev/helix @fusion.dev/helix-terminal @xterm/xterm @xterm/addon-fit @xterm/addon-search @xterm/addon-web-links
8
+ ```
9
+
10
+ **The guide is [Terminals](https://fusion.dev/helix/docs/terminals)**:
11
+ connecting a process, keeping up with a fast one, exits and restarts, the
12
+ theme and its colors, read-only output, links, the keyboard and screen
13
+ readers, and writing a driver. The element itself is on the
14
+ [Terminal reference](https://fusion.dev/helix/components/terminal).
15
+
16
+ ```js
17
+ import '@fusion.dev/helix/terminal'
18
+ import '@xterm/xterm/css/xterm.css'
19
+ import { connectTerminal, terminalThemeReady } from '@fusion.dev/helix-terminal'
20
+ import { xtermDriver, xtermOptions } from '@fusion.dev/helix-terminal/xterm'
21
+ import { FitAddon } from '@xterm/addon-fit'
22
+ import { SearchAddon } from '@xterm/addon-search'
23
+ import { Terminal } from '@xterm/xterm'
24
+
25
+ const frame = document.querySelector('helix-terminal')
26
+ const terminal = new Terminal(xtermOptions(await terminalThemeReady(frame)))
27
+ terminal.open(frame.querySelector('div'))
28
+
29
+ const connection = connectTerminal(
30
+ frame,
31
+ xtermDriver(terminal, { fit: new FitAddon(), search: new SearchAddon() }),
32
+ )
33
+
34
+ // The process is yours: write its output, and send it what the reader types.
35
+ pty.onData((bytes) => frame.write(bytes))
36
+ frame.addEventListener('helix-terminal-input', (event) => pty.write(event.detail.data))
37
+ frame.addEventListener('helix-terminal-resize', (event) => pty.resize(event.detail))
38
+ ```
39
+
40
+ Helix starts no process and opens no pseudo-terminal. The frame takes output
41
+ through `write()` and sends `helix-terminal-input` and `helix-terminal-resize`
42
+ for you to answer.
43
+
44
+ ## What it exports
45
+
46
+ | Import | What |
47
+ |---|---|
48
+ | `@fusion.dev/helix-terminal` | `connectTerminal`, `terminalThemeFrom`, `terminalThemeNow`, `terminalThemeReady`, and the types `ConnectTerminalOptions`, `TerminalColors`, `TerminalConnection`, `TerminalDriver`, `TerminalFont`, `TerminalGrid`, `TerminalMatches`, `TerminalOptions`, `TerminalSearchOptions`, and `TerminalTheme` |
49
+ | `@fusion.dev/helix-terminal/xterm` | `xtermDriver(terminal, addons)`, `xtermOptions(theme)`, and the types `XtermAddons`, `XtermFit`, `XtermSearch`, `XtermTerminal`, and `XtermWebLinks` |
50
+
51
+ **xterm.js is not a dependency.** The driver types the terminal and the
52
+ addons it takes by the calls it makes on them, so a page brings the version it
53
+ has. A spec holds those shapes to the real classes, so a renamed method fails
54
+ a typecheck here before it reaches a page.
55
+
56
+ | `connectTerminal` option | Default | What else it takes |
57
+ |---|---|---|
58
+ | `contrast` | `4.5` | The contrast every cell's text keeps against its ground, from `1`, which draws every color as the program wrote it, to `21` |
59
+
60
+ ## Working on it
61
+
62
+ ```sh
63
+ bun run --filter @fusion.dev/helix-terminal build
64
+ bun run --filter @fusion.dev/helix-terminal test
65
+ ```
66
+
67
+ The specs drive the driver twice. A stand-in for xterm.js records what the
68
+ driver asks of it, under `bun test`. The browser specs, run with
69
+ `bun run specs:browser terminal`, connect a frame to the real xterm.js, write
70
+ output, type, search, and check what the frame said.
71
+
72
+ MIT
@@ -0,0 +1,138 @@
1
+ import { type TerminalTheme } from '../theme/terminal-theme.js';
2
+ /** A grid's size in character cells. */
3
+ export interface TerminalGrid {
4
+ columns: number;
5
+ rows: number;
6
+ }
7
+ /** What the connector asks a renderer to apply, whatever renderer it is. */
8
+ export interface TerminalOptions {
9
+ /**
10
+ * The contrast every cell's text keeps against its ground, which the
11
+ * renderer holds by adjusting the text's color, from `1`, which leaves
12
+ * every color as the program wrote it, to `21`.
13
+ */
14
+ contrast: number;
15
+ /** Whether the cursor is drawn. */
16
+ cursor: boolean;
17
+ /** Whether the reader's keys reach the program. */
18
+ input: boolean;
19
+ /**
20
+ * Whether the renderer may move by itself: blink its cursor and scroll
21
+ * smoothly, where it was set to. Off when the reader asks for reduced motion.
22
+ */
23
+ motion: boolean;
24
+ /** Whether the renderer keeps an accessible copy of the grid and says new output. */
25
+ screenReader: boolean;
26
+ }
27
+ /** How a search through the output moves. */
28
+ export interface TerminalSearchOptions {
29
+ /** Toward the top of the output, for the previous match. */
30
+ backward: boolean;
31
+ /** Whether the reader is still typing, so the match in hand stays where it still matches. */
32
+ incremental: boolean;
33
+ }
34
+ /**
35
+ * What a renderer has to answer for the frame to drive it, and nothing that is
36
+ * the same for every renderer: that is the connector's.
37
+ *
38
+ * **Two methods are required**, writing output and hearing input, which is
39
+ * the whole of a terminal. Each other method turns on what it is named for,
40
+ * and the frame leaves out the control a renderer cannot answer.
41
+ */
42
+ export interface TerminalDriver {
43
+ /** Clears the scrollback, keeping the line the cursor is on. */
44
+ clear?(): void;
45
+ /**
46
+ * The element the renderer draws in, whose size the grid follows: the
47
+ * connector refits the grid whenever it changes size.
48
+ */
49
+ element?(): HTMLElement | null | undefined;
50
+ /** Fits the grid to the renderer's element, as many cells as fit. The new size arrives through `onResize`. */
51
+ fit?(): void;
52
+ /** Focuses the renderer's input. */
53
+ focus?(): void;
54
+ /** The element that takes the reader's keys, which the frame names for a screen reader. */
55
+ input?(): HTMLElement | null | undefined;
56
+ /** Hears the bell, and returns what stops it. */
57
+ onBell?(rang: () => void): () => void;
58
+ /**
59
+ * Hears what the reader types or pastes, encoded for the program, and
60
+ * returns what stops it. `binary` marks data that holds one byte per
61
+ * character.
62
+ */
63
+ onInput(input: (data: string, binary: boolean) => void): () => void;
64
+ /** Hears a link in the output activated, and returns what stops it and puts the renderer's own handling back. */
65
+ onLink?(activated: (href: string) => void): () => void;
66
+ /** Hears the grid change size, and returns what stops it. */
67
+ onResize?(resized: (grid: TerminalGrid) => void): () => void;
68
+ /** Hears the selection change, and returns what stops it. */
69
+ onSelection?(changed: () => void): () => void;
70
+ /** Hears the program set its title, and returns what stops it. */
71
+ onTitle?(changed: (title: string) => void): () => void;
72
+ /** Applies what the connector asks, as the frame's settings and the reader's preferences stand. */
73
+ options?(options: TerminalOptions): void;
74
+ /** Inputs text as a paste does, in bracketed paste mode where the program asked for it. */
75
+ paste?(text: string): void;
76
+ /** The grid's size in CSS pixels, which a pseudo-terminal's size takes beside its cells. */
77
+ pixels?(): {
78
+ height: number;
79
+ width: number;
80
+ } | undefined;
81
+ /** Puts back everything the driver changed on the renderer. Called last, on disconnect. */
82
+ release?(): void;
83
+ /** Resets the emulator: its modes, its colors, and its screen. */
84
+ reset?(): void;
85
+ /** Sets the grid's size in cells, for a frame with `columns` and `rows`. */
86
+ resize?(columns: number, rows: number): void;
87
+ /** Searches the output, highlighting the matches in `matches`' colors. */
88
+ search?: {
89
+ /** Takes the highlights off. */
90
+ end(): void;
91
+ /** Finds the next or the previous match for `query`. */
92
+ find(query: string, options: TerminalSearchOptions, matches: TerminalTheme['matches']): void;
93
+ /** Hears the matches change: the current one, counting from `0` or `-1` for none, and how many. */
94
+ onResults(found: (index: number, count: number) => void): () => void;
95
+ };
96
+ /** The text selected in the grid, or an empty string. */
97
+ selection?(): string;
98
+ /** The grid's size in cells now. */
99
+ size?(): TerminalGrid;
100
+ /** The grid as plain text: the lines on screen, or every line the scrollback holds. */
101
+ text?(scope: 'all' | 'screen'): string;
102
+ /** Draws in the page's theme: its colors, its face, and its search highlights. */
103
+ theme?(theme: TerminalTheme): void;
104
+ /** Writes the program's output, and calls `done` once it has been parsed. */
105
+ write(data: string | Uint8Array, done: () => void): void;
106
+ }
107
+ /** What a connection takes beyond the frame and the driver. */
108
+ export interface ConnectTerminalOptions {
109
+ /**
110
+ * The contrast every cell's text keeps against its ground: 4.5 by default,
111
+ * WCAG's AA for text, which VS Code's terminal also holds. `1` leaves every
112
+ * color as the program wrote it.
113
+ */
114
+ contrast?: number | undefined;
115
+ }
116
+ /** A connection, which is ended rather than left to leak. */
117
+ export interface TerminalConnection {
118
+ /** Stops answering the frame, detaches the renderer from it, and puts back everything connecting changed. */
119
+ disconnect(): void;
120
+ /** Fits the grid to the frame now, for a page that resized it some way the connector cannot see. */
121
+ fit(): void;
122
+ }
123
+ /**
124
+ * Connects a Terminal frame to a renderer through its driver.
125
+ *
126
+ * **Everything that is the same for every renderer happens here**, once: the
127
+ * frame's output reaches the renderer and the reader's input reaches the
128
+ * frame; the grid is fitted to the frame and refitted as it changes size,
129
+ * and the frame says the new size; the renderer is themed from the page's
130
+ * tokens and themed again when the page's theme moves; the reader's request
131
+ * for reduced motion stops the cursor blinking; and every cell keeps a
132
+ * contrast floor against its ground.
133
+ *
134
+ * The frame is `helix-terminal` or `helix-headless-terminal`, and the driver is
135
+ * `xtermDriver` or one of the page's own.
136
+ */
137
+ export declare const connectTerminal: (frame: HTMLElement, driver: TerminalDriver, options?: ConnectTerminalOptions) => TerminalConnection;
138
+ //# sourceMappingURL=connect-terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-terminal.d.ts","sourceRoot":"","sources":["../../src/connect-terminal/connect-terminal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,4BAA4B,CAAA;AAEjF,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,MAAM,EAAE,OAAO,CAAA;IACf,mDAAmD;IACnD,KAAK,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,qFAAqF;IACrF,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,6CAA6C;AAC7C,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAA;IACjB,6FAA6F;IAC7F,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,KAAK,CAAC,IAAI,IAAI,CAAA;IACd;;;OAGG;IACH,OAAO,CAAC,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1C,8GAA8G;IAC9G,GAAG,CAAC,IAAI,IAAI,CAAA;IACZ,oCAAoC;IACpC,KAAK,CAAC,IAAI,IAAI,CAAA;IACd,2FAA2F;IAC3F,KAAK,CAAC,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IACxC,iDAAiD;IACjD,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG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,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;QAC5F,mGAAmG;QACnG,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;KACrE,CAAA;IACD,yDAAyD;IACzD,SAAS,CAAC,IAAI,MAAM,CAAA;IACpB,oCAAoC;IACpC,IAAI,CAAC,IAAI,YAAY,CAAA;IACrB,uFAAuF;IACvF,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IACtC,kFAAkF;IAClF,KAAK,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAClC,6EAA6E;IAC7E,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;CACzD;AAED,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AAED,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC,6GAA6G;IAC7G,UAAU,IAAI,IAAI,CAAA;IAClB,oGAAoG;IACpG,GAAG,IAAI,IAAI,CAAA;CACZ;AAkDD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,UACnB,WAAW,UACV,cAAc,YACb,sBAAsB,KAC9B,kBA+LF,CAAA"}
@@ -0,0 +1,171 @@
1
+ import { reducedMotion, watchTheme } from '@fusion.dev/helix-core';
2
+ import { terminalThemeNow } from '../theme/terminal-theme.js';
3
+ const isFrame = (element) => typeof element.attach === 'function';
4
+ const CONTRAST = 4.5;
5
+ export const connectTerminal = (frame, driver, options = {}) => {
6
+ if (!isFrame(frame)) {
7
+ throw new Error(`connectTerminal: <${frame.localName}> is not a terminal frame. Import @fusion.dev/helix/terminal, and connect once the element is defined.`);
8
+ }
9
+ const contrast = options.contrast ?? CONTRAST;
10
+ let live = true;
11
+ let starting = true;
12
+ let settings;
13
+ let theme = null;
14
+ const stops = [];
15
+ const applyOptions = () => {
16
+ if (!settings) {
17
+ return;
18
+ }
19
+ driver.options?.({
20
+ contrast,
21
+ cursor: settings.cursor,
22
+ input: settings.input,
23
+ motion: !reducedMotion(),
24
+ screenReader: settings.screenReader,
25
+ });
26
+ };
27
+ const fixed = () => settings?.columns !== undefined && settings.rows !== undefined
28
+ ? { columns: settings.columns, rows: settings.rows }
29
+ : undefined;
30
+ const size = () => {
31
+ const grid = fixed();
32
+ if (grid && driver.resize) {
33
+ driver.resize(grid.columns, grid.rows);
34
+ }
35
+ else {
36
+ driver.fit?.();
37
+ }
38
+ };
39
+ const pixels = () => {
40
+ const measured = driver.pixels?.();
41
+ if (measured) {
42
+ return measured;
43
+ }
44
+ const box = driver.element?.()?.getBoundingClientRect();
45
+ return { height: Math.round(box?.height ?? 0), width: Math.round(box?.width ?? 0) };
46
+ };
47
+ const renderer = {
48
+ settings: (next) => {
49
+ settings = next;
50
+ applyOptions();
51
+ if (live && !starting) {
52
+ size();
53
+ }
54
+ },
55
+ write: (data, done) => driver.write(data, done),
56
+ };
57
+ if (driver.clear) {
58
+ renderer.clear = () => driver.clear?.();
59
+ }
60
+ if (driver.focus) {
61
+ renderer.focus = () => driver.focus?.();
62
+ }
63
+ if (driver.input) {
64
+ renderer.input = () => driver.input?.();
65
+ }
66
+ if (driver.paste) {
67
+ renderer.paste = (text) => driver.paste?.(text);
68
+ }
69
+ if (driver.reset) {
70
+ renderer.reset = () => driver.reset?.();
71
+ }
72
+ if (driver.selection) {
73
+ renderer.selection = () => driver.selection?.() ?? '';
74
+ }
75
+ if (driver.text) {
76
+ renderer.text = (scope) => driver.text?.(scope) ?? '';
77
+ }
78
+ const search = driver.search;
79
+ if (search) {
80
+ renderer.find = (query, how) => {
81
+ if (theme) {
82
+ search.find(query, how, theme.matches);
83
+ }
84
+ };
85
+ renderer.findEnd = () => search.end();
86
+ }
87
+ const sink = frame.attach(renderer);
88
+ stops.push(driver.onInput((data, binary) => sink.input(data, binary)));
89
+ if (driver.onBell) {
90
+ stops.push(driver.onBell(() => sink.bell()));
91
+ }
92
+ if (driver.onTitle) {
93
+ stops.push(driver.onTitle((title) => sink.title(title)));
94
+ }
95
+ if (driver.onLink) {
96
+ stops.push(driver.onLink((href) => sink.link(href)));
97
+ }
98
+ if (driver.onSelection) {
99
+ stops.push(driver.onSelection(() => sink.selected((driver.selection?.() ?? '') !== '')));
100
+ }
101
+ if (search) {
102
+ stops.push(search.onResults((index, count) => sink.found(index, count)));
103
+ }
104
+ const report = (grid) => sink.resized({ ...grid, ...pixels() });
105
+ if (driver.onResize) {
106
+ stops.push(driver.onResize(report));
107
+ }
108
+ let pending = 0;
109
+ const restyle = () => {
110
+ theme = terminalThemeNow(frame) ?? theme;
111
+ if (theme) {
112
+ driver.theme?.(theme);
113
+ }
114
+ size();
115
+ };
116
+ const schedule = () => {
117
+ cancelAnimationFrame(pending);
118
+ pending = requestAnimationFrame(() => {
119
+ if (live) {
120
+ restyle();
121
+ }
122
+ });
123
+ };
124
+ stops.push(watchTheme(frame, schedule));
125
+ const motion = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : undefined;
126
+ motion?.addEventListener('change', applyOptions);
127
+ stops.push(() => motion?.removeEventListener('change', applyOptions));
128
+ const element = driver.element?.();
129
+ if (element && typeof ResizeObserver === 'function') {
130
+ let fitting = 0;
131
+ const observer = new ResizeObserver(() => {
132
+ cancelAnimationFrame(fitting);
133
+ fitting = requestAnimationFrame(() => {
134
+ if (live && !fixed()) {
135
+ driver.fit?.();
136
+ }
137
+ });
138
+ });
139
+ observer.observe(element);
140
+ stops.push(() => {
141
+ cancelAnimationFrame(fitting);
142
+ observer.disconnect();
143
+ });
144
+ }
145
+ starting = false;
146
+ restyle();
147
+ const grid = driver.size?.();
148
+ if (grid) {
149
+ report(grid);
150
+ }
151
+ return {
152
+ disconnect: () => {
153
+ if (!live) {
154
+ return;
155
+ }
156
+ live = false;
157
+ cancelAnimationFrame(pending);
158
+ for (const stop of stops.splice(0)) {
159
+ stop();
160
+ }
161
+ sink.detach();
162
+ driver.release?.();
163
+ },
164
+ fit: () => {
165
+ if (live) {
166
+ size();
167
+ }
168
+ },
169
+ };
170
+ };
171
+ //# sourceMappingURL=connect-terminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-terminal.js","sourceRoot":"","sources":["../../src/connect-terminal/connect-terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAwKjF,MAAM,OAAO,GAAG,CAAC,OAAoB,EAAoB,EAAE,CACzD,OAAQ,OAA0B,CAAC,MAAM,KAAK,UAAU,CAAA;AAG1D,MAAM,QAAQ,GAAG,GAAG,CAAA;AAgBpB,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAkB,EAClB,MAAsB,EACtB,OAAO,GAA2B,EAAE,EAChB,EAAE;IACtB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,qBAAqB,KAAK,CAAC,SAAS,wGAAwG,CAC7I,CAAA;IACH,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAA;IAC7C,IAAI,IAAI,GAAG,IAAI,CAAA;IAGf,IAAI,QAAQ,GAAG,IAAI,CAAA;IACnB,IAAI,QAA8B,CAAA;IAClC,IAAI,KAAK,GAAyB,IAAI,CAAA;IACtC,MAAM,KAAK,GAAmB,EAAE,CAAA;IAEhC,MAAM,YAAY,GAAG,GAAS,EAAE;QAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAM;QACR,CAAC;QACD,MAAM,CAAC,OAAO,EAAE,CAAC;YACf,QAAQ;YACR,MAAM,EAAE,QAA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AAE,GAAG,EAAE;YACf,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAM;YACR,CAAC;YACD,IAAI,GAAG,KAAK,CAAA;YACZ,oBAAoB,CAAC,OAAO,CAAC,CAAA;YAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,IAAI,EAAE,CAAA;YACR,CAAC;YACD,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,MAAM,CAAC,OAAO,EAAE,EAAE,CAAA;QACpB,CAAC;QACD,GAAG,EAAE,GAAG,EAAE;YACR,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,EAAE,CAAA;YACR,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type { ConnectTerminalOptions, TerminalConnection, TerminalDriver, TerminalGrid, TerminalOptions, TerminalSearchOptions, } from './connect-terminal.js';
2
+ export { connectTerminal } from './connect-terminal.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connect-terminal/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,qBAAqB,GACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { connectTerminal } from './connect-terminal.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connect-terminal/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export type { ConnectTerminalOptions, TerminalConnection, TerminalDriver, TerminalGrid, TerminalOptions, TerminalSearchOptions, } from './connect-terminal/index.js';
2
+ export { connectTerminal } from './connect-terminal/index.js';
3
+ export type { TerminalColors, TerminalFont, TerminalMatches, TerminalTheme, } from './theme/index.js';
4
+ export { terminalThemeFrom, terminalThemeNow, terminalThemeReady } from './theme/index.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,qBAAqB,GACtB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,YAAY,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { connectTerminal } from './connect-terminal/index.js';
2
+ export { terminalThemeFrom, terminalThemeNow, terminalThemeReady } from './theme/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAO7D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type { TerminalColors, TerminalFont, TerminalMatches, TerminalTheme, } from './terminal-theme.js';
2
+ export { terminalThemeFrom, terminalThemeNow, terminalThemeReady } from './terminal-theme.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { terminalThemeFrom, terminalThemeNow, terminalThemeReady } from './terminal-theme.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The colors a terminal is drawn in, each `#rrggbb`, or `rgba()` where it is
3
+ * see-through, by the names xterm.js's theme gives them, which other
4
+ * emulators' themes share. A color the frame does not set is left out, and
5
+ * the renderer keeps its own.
6
+ */
7
+ export interface TerminalColors {
8
+ background?: string;
9
+ black?: string;
10
+ blue?: string;
11
+ brightBlack?: string;
12
+ brightBlue?: string;
13
+ brightCyan?: string;
14
+ brightGreen?: string;
15
+ brightMagenta?: string;
16
+ brightRed?: string;
17
+ brightWhite?: string;
18
+ brightYellow?: string;
19
+ cursor?: string;
20
+ /** The character under a block cursor, which is the ground. */
21
+ cursorAccent?: string;
22
+ cyan?: string;
23
+ foreground?: string;
24
+ green?: string;
25
+ magenta?: string;
26
+ red?: string;
27
+ scrollbarSliderActiveBackground?: string;
28
+ scrollbarSliderBackground?: string;
29
+ scrollbarSliderHoverBackground?: string;
30
+ selectionBackground?: string;
31
+ /** The selection while the terminal does not have focus: the same ground, quieter. */
32
+ selectionInactiveBackground?: string;
33
+ white?: string;
34
+ yellow?: string;
35
+ }
36
+ /** The face a terminal is drawn in. */
37
+ export interface TerminalFont {
38
+ /** The family, as a CSS font stack. */
39
+ family: string;
40
+ /** The size of the text, in CSS pixels. */
41
+ size: number;
42
+ }
43
+ /** The colors a search highlights its matches in, each `#rrggbb`, which is all xterm.js takes for them. */
44
+ export interface TerminalMatches {
45
+ /** The ground of the current match, where the frame sets one. */
46
+ activeBackground?: string | undefined;
47
+ /** The edge of the current match. */
48
+ activeBorder: string;
49
+ /** The ground of every other match, where the frame sets one. */
50
+ background?: string | undefined;
51
+ /** Where each match is marked beside the scrollbar. */
52
+ ruler: string;
53
+ }
54
+ /** Everything a terminal is themed with: its colors, its face, and its search highlights. */
55
+ export interface TerminalTheme {
56
+ colors: TerminalColors;
57
+ /** The viewport's face, where the frame has one to read. */
58
+ font: TerminalFont | undefined;
59
+ matches: TerminalMatches;
60
+ }
61
+ /**
62
+ * The theme a terminal frame asks for, read from the `--terminal-*` properties
63
+ * where it is: on the styled tier, every color from your tokens, and on the
64
+ * headless tier, whatever your page sets.
65
+ *
66
+ * **Resolved by the browser and then by a canvas**, as Map's colors are: a
67
+ * token is `light-dark()` or a `color-mix()` that only the browser can settle
68
+ * for the frame's color scheme, and what it settles to may be `oklch()`. Read
69
+ * inside the frame, so a terminal in a dark pane of a light page is themed
70
+ * dark.
71
+ */
72
+ export declare const terminalThemeFrom: (frame: Element) => TerminalTheme;
73
+ /**
74
+ * The theme where it can be read, or `null` while it cannot, which is before
75
+ * the frame is defined.
76
+ */
77
+ export declare const terminalThemeNow: (frame: Element) => TerminalTheme | null;
78
+ /**
79
+ * The theme once the frame is defined and its face is loaded, which is what
80
+ * to create the renderer with: an emulator measures its cells in the face it
81
+ * is given when it opens, and a cell measured in the fallback face stays the
82
+ * fallback's size.
83
+ */
84
+ export declare const terminalThemeReady: (frame: Element) => Promise<TerminalTheme>;
85
+ //# sourceMappingURL=terminal-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-theme.d.ts","sourceRoot":"","sources":["../../src/theme/terminal-theme.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd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D,KAAK,EAAE,MAAM,CAAA;CACd;AAED,6FAA6F;AAC7F,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAA;IACtB,4DAA4D;IAC5D,IAAI,EAAE,YAAY,GAAG,SAAS,CAAA;IAC9B,OAAO,EAAE,eAAe,CAAA;CACzB;AAyDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,aA0ClD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,aAAa,GAAG,IAMjE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAiB,OAAO,KAAG,OAAO,CAAC,aAAa,CAe9E,CAAA"}
@@ -0,0 +1,94 @@
1
+ import { readColorAlpha } from '@fusion.dev/helix-core';
2
+ const isFrame = (element) => typeof element.look === 'function';
3
+ const hex = (byte) => Math.round(byte).toString(16).padStart(2, '0');
4
+ const settled = (computed, opaque = false, alpha = 1) => {
5
+ const read = readColorAlpha(computed);
6
+ if (!read) {
7
+ return computed;
8
+ }
9
+ const [red, green, blue, own] = read;
10
+ const scaled = Math.round(own * alpha * 1000) / 1000;
11
+ return scaled === 1 || opaque
12
+ ? `#${hex(red)}${hex(green)}${hex(blue)}`
13
+ : `rgba(${red}, ${green}, ${blue}, ${scaled})`;
14
+ };
15
+ const STRAIGHT = [
16
+ 'background',
17
+ 'black',
18
+ 'blue',
19
+ 'brightBlack',
20
+ 'brightBlue',
21
+ 'brightCyan',
22
+ 'brightGreen',
23
+ 'brightMagenta',
24
+ 'brightRed',
25
+ 'brightWhite',
26
+ 'brightYellow',
27
+ 'cursor',
28
+ 'cyan',
29
+ 'foreground',
30
+ 'green',
31
+ 'magenta',
32
+ 'red',
33
+ 'white',
34
+ 'yellow',
35
+ ];
36
+ export const terminalThemeFrom = (frame) => {
37
+ if (!isFrame(frame)) {
38
+ throw new Error(`terminalThemeFrom: <${frame.localName}> is not a terminal frame. Import @fusion.dev/helix/terminal, and read the theme once the element is defined.`);
39
+ }
40
+ const { colors: read, font } = frame.look();
41
+ const colors = {};
42
+ for (const name of STRAIGHT) {
43
+ const color = read[name];
44
+ if (color) {
45
+ colors[name] = settled(color);
46
+ }
47
+ }
48
+ if (colors.background) {
49
+ colors.cursorAccent = colors.background;
50
+ }
51
+ if (read.selection) {
52
+ colors.selectionBackground = settled(read.selection);
53
+ colors.selectionInactiveBackground = settled(read.selection, false, 0.6);
54
+ }
55
+ if (read.scrollbar) {
56
+ const thumb = settled(read.scrollbar);
57
+ colors.scrollbarSliderActiveBackground = thumb;
58
+ colors.scrollbarSliderBackground = thumb;
59
+ colors.scrollbarSliderHoverBackground = thumb;
60
+ }
61
+ const edge = read.activeMatchBorder ?? read.foreground;
62
+ const activeBorder = edge ? settled(edge, true) : '#808080';
63
+ return {
64
+ colors,
65
+ font,
66
+ matches: {
67
+ activeBackground: read.activeMatch ? settled(read.activeMatch, true) : undefined,
68
+ activeBorder,
69
+ background: read.match ? settled(read.match, true) : undefined,
70
+ ruler: activeBorder,
71
+ },
72
+ };
73
+ };
74
+ export const terminalThemeNow = (frame) => {
75
+ try {
76
+ return terminalThemeFrom(frame);
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ };
82
+ export const terminalThemeReady = async (frame) => {
83
+ if (!isFrame(frame) && typeof customElements !== 'undefined') {
84
+ await customElements.whenDefined(frame.localName);
85
+ }
86
+ await frame.updateComplete;
87
+ const theme = terminalThemeFrom(frame);
88
+ const font = theme.font;
89
+ if (font && typeof document !== 'undefined' && document.fonts) {
90
+ await Promise.all(['400', '700'].map((weight) => document.fonts.load(`${weight} ${font.size}px ${font.family}`).catch(() => [])));
91
+ }
92
+ return theme;
93
+ };
94
+ //# sourceMappingURL=terminal-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-theme.js","sourceRoot":"","sources":["../../src/theme/terminal-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAA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QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAC/E,CACF,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type { XtermAddons, XtermFit, XtermSearch, XtermTerminal, XtermWebLinks, } from './xterm-driver.js';
2
+ export { xtermDriver, xtermOptions } from './xterm-driver.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xterm/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { xtermDriver, xtermOptions } from './xterm-driver.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xterm/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,13 @@
1
+ /** One row of a terminal's buffer, as text, and whether it carries on the row above. */
2
+ export interface BufferRow {
3
+ text: string;
4
+ /** Whether the row is the row above run past the grid's edge, which reads as one line. */
5
+ wrapped: boolean;
6
+ }
7
+ /**
8
+ * Rows as the lines a reader would copy: a row that wraps joined to the one
9
+ * above it, and the empty rows under the last line dropped, which are the
10
+ * screen's unwritten space rather than anything the program wrote.
11
+ */
12
+ export declare const linesOf: (rows: readonly BufferRow[]) => string;
13
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/xterm/lines.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,0FAA0F;IAC1F,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,SAAU,SAAS,SAAS,EAAE,KAAG,MAapD,CAAA"}
@@ -0,0 +1,16 @@
1
+ export const linesOf = (rows) => {
2
+ const lines = [];
3
+ for (const row of rows) {
4
+ if (row.wrapped && lines.length > 0) {
5
+ lines[lines.length - 1] += row.text;
6
+ }
7
+ else {
8
+ lines.push(row.text);
9
+ }
10
+ }
11
+ while (lines.length > 0 && lines[lines.length - 1] === '') {
12
+ lines.pop();
13
+ }
14
+ return lines.join('\n');
15
+ };
16
+ //# sourceMappingURL=lines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.js","sourceRoot":"","sources":["../../src/xterm/lines.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAA0B,EAAU,EAAE;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1D,KAAK,CAAC,GAAG,EAAE,CAAA;IACb,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA"}
@@ -0,0 +1,124 @@
1
+ import type { TerminalDriver } from '../connect-terminal/connect-terminal.js';
2
+ import type { TerminalTheme } from '../theme/terminal-theme.js';
3
+ /** What xterm.js hands back from every listener, to stop it. */
4
+ interface Disposable {
5
+ dispose(): void;
6
+ }
7
+ /** An xterm.js addon, as `loadAddon` takes one. */
8
+ interface Addon extends Disposable {
9
+ activate(terminal: never): void;
10
+ }
11
+ /**
12
+ * xterm.js's `Terminal`, as far as the driver calls it, so this package
13
+ * depends on no version of it: the page brings its own. A spec holds this to
14
+ * the real class.
15
+ */
16
+ export interface XtermTerminal {
17
+ readonly buffer: {
18
+ readonly active: {
19
+ getLine(y: number): {
20
+ readonly isWrapped: boolean;
21
+ translateToString(trimRight?: boolean): string;
22
+ } | undefined;
23
+ readonly length: number;
24
+ readonly viewportY: number;
25
+ };
26
+ };
27
+ clear(): void;
28
+ readonly cols: number;
29
+ readonly element: HTMLElement | undefined;
30
+ focus(): void;
31
+ getSelection(): string;
32
+ loadAddon(addon: never): void;
33
+ onBell(listener: () => void): Disposable;
34
+ onBinary(listener: (data: string) => void): Disposable;
35
+ onData(listener: (data: string) => void): Disposable;
36
+ onResize(listener: (size: {
37
+ cols: number;
38
+ rows: number;
39
+ }) => void): Disposable;
40
+ onSelectionChange(listener: () => void): Disposable;
41
+ onTitleChange(listener: (title: string) => void): Disposable;
42
+ options: {
43
+ allowProposedApi?: boolean | undefined;
44
+ cursorBlink?: boolean | undefined;
45
+ disableStdin?: boolean | undefined;
46
+ fontFamily?: string | undefined;
47
+ fontSize?: number | undefined;
48
+ linkHandler?: {
49
+ activate(event: MouseEvent, text: string, range: never): void;
50
+ allowNonHttpProtocols?: boolean | undefined;
51
+ } | null | undefined;
52
+ minimumContrastRatio?: number | undefined;
53
+ screenReaderMode?: boolean | undefined;
54
+ smoothScrollDuration?: number | undefined;
55
+ theme?: object | undefined;
56
+ };
57
+ paste(data: string): void;
58
+ reset(): void;
59
+ resize(columns: number, rows: number): void;
60
+ readonly rows: number;
61
+ readonly textarea: HTMLTextAreaElement | undefined;
62
+ write(data: string | Uint8Array, callback?: () => void): void;
63
+ }
64
+ /** `@xterm/addon-fit`'s `FitAddon`, as far as the driver calls it. */
65
+ export interface XtermFit extends Addon {
66
+ fit(): void;
67
+ }
68
+ /** `@xterm/addon-search`'s `SearchAddon`, as far as the driver calls it. */
69
+ export interface XtermSearch extends Addon {
70
+ clearDecorations(): void;
71
+ findNext(term: string, options?: XtermSearchOptions): boolean;
72
+ findPrevious(term: string, options?: XtermSearchOptions): boolean;
73
+ onDidChangeResults(listener: (results: {
74
+ resultCount: number;
75
+ resultIndex: number;
76
+ }) => void): Disposable;
77
+ }
78
+ /** The search options the driver passes, which are what turn on the result count. */
79
+ interface XtermSearchOptions {
80
+ decorations?: {
81
+ activeMatchBackground?: string;
82
+ activeMatchBorder?: string;
83
+ activeMatchColorOverviewRuler: string;
84
+ matchBackground?: string;
85
+ matchOverviewRuler: string;
86
+ };
87
+ incremental?: boolean;
88
+ }
89
+ /** `@xterm/addon-web-links`'s `WebLinksAddon` class, which the driver makes with its own handler. */
90
+ export type XtermWebLinks = new (handler: (event: MouseEvent, uri: string) => void) => Addon;
91
+ /**
92
+ * The addons a driver can use, each one of the page's own, unloaded: the
93
+ * driver loads them. Each turns on what it is named for.
94
+ */
95
+ export interface XtermAddons {
96
+ /** A `FitAddon`, which fits the grid to the frame. Without it the grid keeps the size it was made with. */
97
+ fit?: XtermFit | undefined;
98
+ /** A `SearchAddon`, which the find bar searches with. Without it the frame draws no find control. */
99
+ search?: XtermSearch | undefined;
100
+ /**
101
+ * The `WebLinksAddon` class, which finds addresses in the text and makes
102
+ * them links. Links a program writes as hyperlinks work without it.
103
+ */
104
+ webLinks?: XtermWebLinks | undefined;
105
+ }
106
+ /**
107
+ * A driver for xterm.js 6. Open the terminal in the frame's element first,
108
+ * then connect.
109
+ *
110
+ * The addons are optional and the page's own, so it brings the versions it
111
+ * has. The driver loads them; pass each one new.
112
+ */
113
+ export declare const xtermDriver: (terminal: XtermTerminal, addons?: XtermAddons) => TerminalDriver;
114
+ /**
115
+ * The terminal options a theme sets, for creating the terminal already in it:
116
+ * `new Terminal(xtermOptions(await terminalThemeReady(frame)))`.
117
+ */
118
+ export declare const xtermOptions: (theme: TerminalTheme) => {
119
+ fontFamily?: string;
120
+ fontSize?: number;
121
+ theme: TerminalTheme['colors'];
122
+ };
123
+ export {};
124
+ //# sourceMappingURL=xterm-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xterm-driver.d.ts","sourceRoot":"","sources":["../../src/xterm/xterm-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAG/D,gEAAgE;AAChE,UAAU,UAAU;IAClB,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,mDAAmD;AACnD,UAAU,KAAM,SAAQ,UAAU;IAChC,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,MAAM,EAAE;YACf,OAAO,CACL,CAAC,EAAE,MAAM,GACR;gBAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;aAAE,GAAG,SAAS,CAAA;YAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;YACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;SAC3B,CAAA;KACF,CAAA;IACD,KAAK,IAAI,IAAI,CAAA;IACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAA;IACzC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W,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,qGAAqG;AACrG,MAAM,MAAM,aAAa,GAAG,KAAK,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,KAAK,KAAK,CAAA;AAE5F;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,2GAA2G;IAC3G,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACrC;AAYD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAAc,aAAa,WAAU,WAAW,KAAQ,cA6J/E,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,UAChB,aAAa,KACnB;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;CAGzE,CAAA"}
@@ -0,0 +1,151 @@
1
+ import { linesOf } from './lines.js';
2
+ const stopping = (disposable) => () => disposable.dispose();
3
+ const SHOW_CURSOR = '\u001b[?25h';
4
+ const HIDE_CURSOR = '\u001b[?25l';
5
+ export const xtermDriver = (terminal, addons = {}) => {
6
+ const made = {
7
+ allowProposedApi: terminal.options.allowProposedApi ?? false,
8
+ cursorBlink: terminal.options.cursorBlink ?? false,
9
+ disableStdin: terminal.options.disableStdin ?? false,
10
+ linkHandler: terminal.options.linkHandler ?? null,
11
+ minimumContrastRatio: terminal.options.minimumContrastRatio ?? 1,
12
+ screenReaderMode: terminal.options.screenReaderMode ?? false,
13
+ smoothScrollDuration: terminal.options.smoothScrollDuration ?? 0,
14
+ };
15
+ let cursorShown = true;
16
+ const { fit, search, webLinks } = addons;
17
+ if (fit) {
18
+ terminal.loadAddon(fit);
19
+ }
20
+ if (search) {
21
+ terminal.options.allowProposedApi = true;
22
+ terminal.loadAddon(search);
23
+ }
24
+ const driver = {
25
+ clear: () => terminal.clear(),
26
+ element: () => terminal.element?.parentElement ?? null,
27
+ focus: () => terminal.focus(),
28
+ input: () => terminal.textarea ?? null,
29
+ onBell: (rang) => stopping(terminal.onBell(() => rang())),
30
+ onInput: (input) => {
31
+ const typed = terminal.onData((data) => input(data, false));
32
+ const bytes = terminal.onBinary((data) => input(data, true));
33
+ return () => {
34
+ typed.dispose();
35
+ bytes.dispose();
36
+ };
37
+ },
38
+ onLink: (activated) => {
39
+ terminal.options.linkHandler = {
40
+ activate: (_event, text) => activated(text),
41
+ allowNonHttpProtocols: true,
42
+ };
43
+ const found = webLinks ? new webLinks((_event, uri) => activated(uri)) : undefined;
44
+ if (found) {
45
+ terminal.loadAddon(found);
46
+ }
47
+ return () => {
48
+ terminal.options.linkHandler = made.linkHandler;
49
+ found?.dispose();
50
+ };
51
+ },
52
+ onResize: (resized) => stopping(terminal.onResize(({ cols, rows }) => resized({ columns: cols, rows }))),
53
+ onSelection: (changed) => stopping(terminal.onSelectionChange(() => changed())),
54
+ onTitle: (changed) => stopping(terminal.onTitleChange((title) => changed(title))),
55
+ options: (options) => {
56
+ terminal.options.disableStdin = !options.input;
57
+ terminal.options.minimumContrastRatio = options.contrast;
58
+ terminal.options.screenReaderMode = options.screenReader;
59
+ terminal.options.cursorBlink = options.motion && made.cursorBlink;
60
+ terminal.options.smoothScrollDuration = options.motion ? made.smoothScrollDuration : 0;
61
+ if (options.cursor !== cursorShown) {
62
+ cursorShown = options.cursor;
63
+ terminal.write(cursorShown ? SHOW_CURSOR : HIDE_CURSOR);
64
+ }
65
+ },
66
+ paste: (text) => terminal.paste(text),
67
+ pixels: () => {
68
+ const box = terminal.element?.querySelector('.xterm-screen')?.getBoundingClientRect();
69
+ return box && box.width > 0
70
+ ? { height: Math.round(box.height), width: Math.round(box.width) }
71
+ : undefined;
72
+ },
73
+ release: () => {
74
+ terminal.options.allowProposedApi = made.allowProposedApi;
75
+ terminal.options.cursorBlink = made.cursorBlink;
76
+ terminal.options.disableStdin = made.disableStdin;
77
+ terminal.options.minimumContrastRatio = made.minimumContrastRatio;
78
+ terminal.options.screenReaderMode = made.screenReaderMode;
79
+ terminal.options.smoothScrollDuration = made.smoothScrollDuration;
80
+ if (!cursorShown) {
81
+ cursorShown = true;
82
+ terminal.write(SHOW_CURSOR);
83
+ }
84
+ },
85
+ reset: () => terminal.reset(),
86
+ resize: (columns, rows) => terminal.resize(columns, rows),
87
+ selection: () => terminal.getSelection(),
88
+ size: () => ({ columns: terminal.cols, rows: terminal.rows }),
89
+ text: (scope) => {
90
+ const buffer = terminal.buffer.active;
91
+ const from = scope === 'all' ? 0 : buffer.viewportY;
92
+ const to = scope === 'all' ? buffer.length : buffer.viewportY + terminal.rows;
93
+ const lines = [];
94
+ for (let y = from; y < to; y++) {
95
+ const line = buffer.getLine(y);
96
+ if (line) {
97
+ lines.push({ text: line.translateToString(true), wrapped: line.isWrapped });
98
+ }
99
+ }
100
+ return linesOf(lines);
101
+ },
102
+ theme: (theme) => {
103
+ terminal.options.theme = { ...theme.colors };
104
+ if (theme.font) {
105
+ terminal.options.fontFamily = theme.font.family;
106
+ terminal.options.fontSize = theme.font.size;
107
+ }
108
+ },
109
+ write: (data, done) => terminal.write(data, done),
110
+ };
111
+ if (fit) {
112
+ driver.fit = () => {
113
+ const box = terminal.element?.parentElement?.getBoundingClientRect();
114
+ if (box && box.width > 0 && box.height > 0) {
115
+ fit.fit();
116
+ }
117
+ };
118
+ }
119
+ if (search) {
120
+ driver.search = {
121
+ end: () => search.clearDecorations(),
122
+ find: (query, { backward, incremental }, matches) => {
123
+ const options = {
124
+ decorations: {
125
+ activeMatchBorder: matches.activeBorder,
126
+ activeMatchColorOverviewRuler: matches.ruler,
127
+ matchOverviewRuler: matches.ruler,
128
+ ...(matches.activeBackground
129
+ ? { activeMatchBackground: matches.activeBackground }
130
+ : {}),
131
+ ...(matches.background ? { matchBackground: matches.background } : {}),
132
+ },
133
+ incremental,
134
+ };
135
+ if (backward) {
136
+ search.findPrevious(query, options);
137
+ }
138
+ else {
139
+ search.findNext(query, options);
140
+ }
141
+ },
142
+ onResults: (found) => stopping(search.onDidChangeResults(({ resultCount, resultIndex }) => found(resultIndex, resultCount))),
143
+ };
144
+ }
145
+ return driver;
146
+ };
147
+ export const xtermOptions = (theme) => ({
148
+ ...(theme.font ? { fontFamily: theme.font.family, fontSize: theme.font.size } : {}),
149
+ theme: { ...theme.colors },
150
+ });
151
+ //# sourceMappingURL=xterm-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xterm-driver.js","sourceRoot":"","sources":["../../src/xterm/xterm-driver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAgHpC,MAAM,QAAQ,GACZ,CAAC,UAAsB,EAAgB,EAAE,CACzC,GAAG,EAAE,CACH,UAAU,CAAC,OAAO,EAAE,CAAA;AAGxB,MAAM,WAAW,GAAG,aAAa,CAAA;AACjC,MAAM,WAAW,GAAG,aAAa,CAAA;AASjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAuB,EAAE,MAAM,GAAgB,EAAE,EAAkB,EAAE;IAE/F,MAAM,IAAI,GAAG;QACX,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,IAAI,KAAK;QAC5D,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,IAAI,KAAK;QAClD,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,KAAK;QACpD,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI;QACjD,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,oBAAoB,IAAI,CAAC;QAChE,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,IAAI,KAAK;QAC5D,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,o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IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@fusion.dev/helix-terminal",
3
+ "description": "Connects the Helix Terminal frame to a terminal emulator: xterm.js, or a driver of your own, themed with your tokens.",
4
+ "version": "0.0.0-dev",
5
+ "license": "MIT",
6
+ "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
+ "repository": {
8
+ "directory": "helix/terminal",
9
+ "type": "git",
10
+ "url": "git+https://github.com/project-fusion/fusion.git"
11
+ },
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json",
21
+ "./xterm": {
22
+ "types": "./dist/xterm/index.d.ts",
23
+ "default": "./dist/xterm/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "sideEffects": false,
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.types.json",
32
+ "test": "bun run test:pure && bun run test:dom",
33
+ "test:dom": "bun test dom.spec",
34
+ "test:pure": "bun test pure.spec",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit"
36
+ },
37
+ "bugs": "https://github.com/project-fusion/fusion/issues",
38
+ "dependencies": {
39
+ "@fusion.dev/helix-core": "0.208.1"
40
+ },
41
+ "devDependencies": {
42
+ "@fusion.dev/helix-headless": "0.208.1",
43
+ "@fusion.dev/helix-testing": "0.208.1",
44
+ "@types/bun": "^1.4.2",
45
+ "@xterm/addon-fit": "^0.11.0",
46
+ "@xterm/addon-search": "^0.16.0",
47
+ "@xterm/addon-web-links": "^0.12.0",
48
+ "@xterm/xterm": "^6.0.0"
49
+ },
50
+ "homepage": "https://fusion.dev",
51
+ "keywords": [
52
+ "terminal",
53
+ "xterm",
54
+ "pty",
55
+ "pseudo-terminal"
56
+ ],
57
+ "publishConfig": {
58
+ "access": "restricted"
59
+ }
60
+ }