@floegence/floeterm-terminal-web 0.4.32 → 0.5.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.
- package/README.md +86 -56
- package/dist/core/TerminalCore.d.ts +8 -1
- package/dist/core/TerminalCore.d.ts.map +1 -1
- package/dist/core/TerminalCore.js +76 -0
- package/dist/core/TerminalCore.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/manager/TerminalInstanceController.d.ts +70 -0
- package/dist/manager/TerminalInstanceController.d.ts.map +1 -0
- package/dist/manager/TerminalInstanceController.js +633 -0
- package/dist/manager/TerminalInstanceController.js.map +1 -0
- package/dist/types.d.ts +45 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -12
- package/dist/hooks/useTerminalInstance.d.ts +0 -3
- package/dist/hooks/useTerminalInstance.d.ts.map +0 -1
- package/dist/hooks/useTerminalInstance.js +0 -544
- package/dist/hooks/useTerminalInstance.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,44 +1,70 @@
|
|
|
1
1
|
# terminal-web
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`useTerminalInstance` without UI components.
|
|
3
|
+
Framework-neutral ghostty-web (xterm.js API-compatible) integration with terminal core, session, and data flow utilities.
|
|
5
4
|
|
|
6
5
|
## Install
|
|
6
|
+
|
|
7
7
|
```bash
|
|
8
8
|
npm i @floegence/floeterm-terminal-web
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Usage
|
|
12
|
-
```tsx
|
|
13
|
-
import { useTerminalInstance } from '@floegence/floeterm-terminal-web';
|
|
11
|
+
## Usage
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
const { containerRef } = useTerminalInstance({
|
|
17
|
-
sessionId: 'session-1',
|
|
18
|
-
isActive: true,
|
|
19
|
-
transport: myTransport,
|
|
20
|
-
eventSource: myEventSource
|
|
21
|
-
});
|
|
13
|
+
Use the managed controller when you want attach, reconnect-friendly replay, ordered writes, resize, and action helpers handled for you:
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
}
|
|
15
|
+
```ts
|
|
16
|
+
import { createTerminalInstance } from '@floegence/floeterm-terminal-web';
|
|
17
|
+
|
|
18
|
+
const controller = createTerminalInstance({
|
|
19
|
+
sessionId: 'session-1',
|
|
20
|
+
isActive: true,
|
|
21
|
+
transport: myTransport,
|
|
22
|
+
eventSource: myEventSource,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const unsubscribe = controller.subscribe((snapshot) => {
|
|
26
|
+
console.log(snapshot.connection.state, snapshot.loadingMessage);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
await controller.mount(container);
|
|
30
|
+
|
|
31
|
+
// Later:
|
|
32
|
+
controller.actions.copySelection('command');
|
|
33
|
+
unsubscribe();
|
|
34
|
+
controller.dispose();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use `TerminalCore` directly when the host product owns its own session lifecycle, paging, shell integration, or workbench coordination:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { TerminalCore, getDefaultTerminalConfig } from '@floegence/floeterm-terminal-web';
|
|
41
|
+
|
|
42
|
+
const core = new TerminalCore(
|
|
43
|
+
container,
|
|
44
|
+
getDefaultTerminalConfig('dark', { clipboard: { copyOnSelect: false } }),
|
|
45
|
+
{
|
|
46
|
+
onData: data => transport.sendInput(sessionId, data),
|
|
47
|
+
onResize: size => transport.resize(sessionId, size.cols, size.rows),
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
await core.initialize();
|
|
25
52
|
```
|
|
26
53
|
|
|
27
54
|
## Notes
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
- `
|
|
55
|
+
|
|
56
|
+
- You must provide a `TerminalTransport` and `TerminalEventSource` for the managed controller.
|
|
57
|
+
- `ghostty-web` needs a one-time `init()`; `TerminalCore` handles that internally.
|
|
58
|
+
- `TerminalCore` bridges the hidden textarea used by `ghostty-web`, so soft-keyboard and composition input continue to work on touch devices.
|
|
31
59
|
- Explicit terminal copy is handled through shared selection-copy APIs, so keyboard shortcuts, native app menus, and product context menus can reuse the same selection logic.
|
|
32
|
-
- `TerminalCore`
|
|
33
|
-
- Multiple live `TerminalCore` instances share one render scheduler, so large terminal grids coalesce demand-driven canvas work into browser frames
|
|
60
|
+
- `TerminalCore` exposes runtime appearance updates, shell bell/title events, custom terminal link providers, buffer line reads, and touch-scroll helpers without requiring consumers to reach into private runtime objects.
|
|
61
|
+
- Multiple live `TerminalCore` instances share one render scheduler, so large terminal grids coalesce demand-driven canvas work into browser frames.
|
|
34
62
|
|
|
35
|
-
## Responsive
|
|
36
|
-
When the same remote terminal session can be displayed in multiple views (e.g. a Deck widget and a dedicated Terminal page),
|
|
37
|
-
enable the responsive options so the focused terminal re-syncs cols/rows to the remote PTY:
|
|
63
|
+
## Responsive Resize
|
|
38
64
|
|
|
39
|
-
|
|
40
|
-
import { TerminalCore } from '@floegence/floeterm-terminal-web';
|
|
65
|
+
When the same remote terminal session can be displayed in multiple views, enable responsive options so the focused terminal re-syncs cols/rows to the remote PTY:
|
|
41
66
|
|
|
67
|
+
```ts
|
|
42
68
|
const core = new TerminalCore(container, {
|
|
43
69
|
responsive: {
|
|
44
70
|
fitOnFocus: true,
|
|
@@ -48,21 +74,18 @@ const core = new TerminalCore(container, {
|
|
|
48
74
|
});
|
|
49
75
|
```
|
|
50
76
|
|
|
51
|
-
Passive mirrors of a remote PTY can render with the session owner's current dimensions
|
|
52
|
-
container:
|
|
77
|
+
Passive mirrors of a remote PTY can render with the session owner's current dimensions:
|
|
53
78
|
|
|
54
79
|
```ts
|
|
55
80
|
const core = new TerminalCore(container, {
|
|
56
81
|
fixedDimensions: { cols: 100, rows: 30 },
|
|
57
82
|
});
|
|
58
83
|
|
|
59
|
-
// Later, when this surface becomes the active geometry owner:
|
|
60
84
|
core.setFixedDimensions(null);
|
|
61
85
|
core.forceResize();
|
|
62
86
|
```
|
|
63
87
|
|
|
64
|
-
Hosts with overlay scrollbars can remove the default ghostty-web scrollbar reserve
|
|
65
|
-
terminal surface:
|
|
88
|
+
Hosts with overlay scrollbars can remove the default ghostty-web scrollbar reserve:
|
|
66
89
|
|
|
67
90
|
```ts
|
|
68
91
|
const core = new TerminalCore(container, {
|
|
@@ -72,13 +95,11 @@ const core = new TerminalCore(container, {
|
|
|
72
95
|
});
|
|
73
96
|
```
|
|
74
97
|
|
|
75
|
-
## Clipboard
|
|
76
|
-
By default, upstream mouse selection keeps the `ghostty-web` behavior and copies immediately on selection.
|
|
77
|
-
Consumers that want explicit copy commands only can disable that side effect:
|
|
98
|
+
## Clipboard
|
|
78
99
|
|
|
79
|
-
|
|
80
|
-
import { TerminalCore } from '@floegence/floeterm-terminal-web';
|
|
100
|
+
By default, upstream mouse selection keeps the `ghostty-web` behavior and copies immediately on selection. Consumers that want explicit copy commands only can disable that side effect:
|
|
81
101
|
|
|
102
|
+
```ts
|
|
82
103
|
const core = new TerminalCore(container, {
|
|
83
104
|
clipboard: {
|
|
84
105
|
copyOnSelect: false,
|
|
@@ -92,9 +113,10 @@ With `copyOnSelect: false`, `TerminalCore` keeps selection explicit:
|
|
|
92
113
|
- `core.copySelection()` writes the current terminal selection to the clipboard.
|
|
93
114
|
- `Cmd+C` / `Ctrl+C` only claims the shortcut when the terminal currently has a selection. Otherwise the shortcut falls through unchanged.
|
|
94
115
|
|
|
95
|
-
|
|
116
|
+
The managed controller exposes the same helpers through `controller.actions`.
|
|
117
|
+
|
|
118
|
+
## Link Providers And Buffer Reads
|
|
96
119
|
|
|
97
|
-
## Link providers and shell events
|
|
98
120
|
`TerminalCore` forwards shell lifecycle events and lets consumers register custom links over rendered terminal rows:
|
|
99
121
|
|
|
100
122
|
```ts
|
|
@@ -102,26 +124,40 @@ import { TerminalCore, type TerminalLinkProvider } from '@floegence/floeterm-ter
|
|
|
102
124
|
|
|
103
125
|
const linkProvider: TerminalLinkProvider = {
|
|
104
126
|
provideLinks(y, callback) {
|
|
105
|
-
|
|
127
|
+
const line = core.readBufferLine(y);
|
|
128
|
+
void line;
|
|
106
129
|
callback(undefined);
|
|
107
130
|
},
|
|
108
131
|
};
|
|
109
132
|
|
|
110
133
|
const core = new TerminalCore(container, {}, {
|
|
111
134
|
onBell: () => console.log('bell'),
|
|
112
|
-
onTitleChange:
|
|
135
|
+
onTitleChange: title => console.log('title', title),
|
|
113
136
|
});
|
|
114
137
|
|
|
115
138
|
await core.initialize();
|
|
116
139
|
core.registerLinkProvider(linkProvider);
|
|
117
140
|
```
|
|
118
141
|
|
|
119
|
-
This is the intended extension point for product features such as modifier-click file navigation,
|
|
120
|
-
build-log deep links, or shell attention badges driven by bell events.
|
|
142
|
+
This is the intended extension point for product features such as modifier-click file navigation, build-log deep links, or shell attention badges driven by bell events.
|
|
121
143
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
|
|
144
|
+
## Touch Scroll Helpers
|
|
145
|
+
|
|
146
|
+
Hosts with custom mobile input surfaces can ask `TerminalCore` for a safe touch-scroll facade instead of reaching into the underlying runtime:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const touch = core.getTouchScrollRuntime();
|
|
150
|
+
|
|
151
|
+
if (touch?.isAlternateScreen()) {
|
|
152
|
+
touch.sendAlternateScreenInput('\x1B[A');
|
|
153
|
+
} else {
|
|
154
|
+
touch?.scrollLines(-3);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Visual Work Suspension
|
|
159
|
+
|
|
160
|
+
Hosts that animate a surrounding workbench can temporarily suspend expensive terminal visual work while keeping PTY output and the terminal buffer live:
|
|
125
161
|
|
|
126
162
|
```ts
|
|
127
163
|
const suspend = core.beginVisualSuspend({ reason: 'workbench_widget_drag' });
|
|
@@ -133,16 +169,11 @@ try {
|
|
|
133
169
|
}
|
|
134
170
|
```
|
|
135
171
|
|
|
136
|
-
While suspended, `write()` continues to update terminal state. Rendering, fit, full repaint, and overlay refresh requests
|
|
137
|
-
are coalesced and reconciled when the final nested suspend handle is disposed.
|
|
172
|
+
While suspended, `write()` continues to update terminal state. Rendering, fit, full repaint, and overlay refresh requests are coalesced and reconciled when the final nested suspend handle is disposed.
|
|
138
173
|
|
|
139
|
-
## Multi-
|
|
140
|
-
`TerminalCore` keeps ghostty-web rendering demand-driven and routes visible terminal repaints through a shared scheduler.
|
|
141
|
-
The scheduler preserves live output for every terminal, dedupes repeated invalidations for the same terminal inside one
|
|
142
|
-
animation frame, and upgrades dirty-row renders to full repaints when a scrollback, viewport, font, theme, or geometry
|
|
143
|
-
change requires it.
|
|
174
|
+
## Multi-Terminal Render Scheduling
|
|
144
175
|
|
|
145
|
-
Demo or profiling surfaces can inspect the scheduler without reaching into private instances:
|
|
176
|
+
`TerminalCore` keeps ghostty-web rendering demand-driven and routes visible terminal repaints through a shared scheduler. Demo or profiling surfaces can inspect the scheduler without reaching into private instances:
|
|
146
177
|
|
|
147
178
|
```ts
|
|
148
179
|
import { getTerminalRenderSchedulerStats } from '@floegence/floeterm-terminal-web';
|
|
@@ -151,12 +182,11 @@ const stats = getTerminalRenderSchedulerStats();
|
|
|
151
182
|
console.log(stats.lastFrameRendered, stats.pending);
|
|
152
183
|
```
|
|
153
184
|
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
Product code should continue to interact with `TerminalCore` or the managed controller.
|
|
186
|
+
|
|
187
|
+
## Runtime Appearance Updates
|
|
156
188
|
|
|
157
|
-
|
|
158
|
-
Consumers that need to react to user preferences can update appearance without rebuilding the
|
|
159
|
-
terminal session:
|
|
189
|
+
Consumers that need to respond to user preferences can update appearance without rebuilding the terminal session:
|
|
160
190
|
|
|
161
191
|
```ts
|
|
162
192
|
import { getThemeColors } from '@floegence/floeterm-terminal-web';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TerminalState, type Logger, type TerminalConfig, type TerminalCopySelectionResult, type TerminalCopySelectionSource, type TerminalDimensions, type TerminalEventHandlers, type TerminalAppearance, type TerminalLinkProvider, type TerminalVisualSuspendHandle, type TerminalVisualSuspendOptions } from '../types';
|
|
1
|
+
import { TerminalState, type Logger, type TerminalConfig, type TerminalCopySelectionResult, type TerminalCopySelectionSource, type TerminalDimensions, type TerminalEventHandlers, type TerminalAppearance, type TerminalLinkProvider, type TerminalRuntimeLineSnapshot, type TerminalTouchScrollRuntime, type TerminalVisualSuspendHandle, type TerminalVisualSuspendOptions } from '../types';
|
|
2
2
|
export declare class TerminalCore {
|
|
3
3
|
private container;
|
|
4
4
|
private config;
|
|
@@ -110,6 +110,13 @@ export declare class TerminalCore {
|
|
|
110
110
|
cols: number;
|
|
111
111
|
bufferLength: number;
|
|
112
112
|
} | null;
|
|
113
|
+
readBufferLine(row: number, options?: {
|
|
114
|
+
trimRight?: boolean;
|
|
115
|
+
}): string;
|
|
116
|
+
readBufferLines(startRow: number, endRowInclusive: number, options?: {
|
|
117
|
+
trimRight?: boolean;
|
|
118
|
+
}): TerminalRuntimeLineSnapshot[];
|
|
119
|
+
getTouchScrollRuntime(): TerminalTouchScrollRuntime | null;
|
|
113
120
|
findNext(term: string, options?: {
|
|
114
121
|
caseSensitive?: boolean;
|
|
115
122
|
wholeWord?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalCore.d.ts","sourceRoot":"","sources":["../../src/core/TerminalCore.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,KAAK,MAAM,EAEX,KAAK,cAAc,EACnB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAGzB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EAElC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"TerminalCore.d.ts","sourceRoot":"","sources":["../../src/core/TerminalCore.ts"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B;IAIhC,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,6BAA6B;IAarC,OAAO,CAAC,uBAAuB;IAmC/B,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,iBAAiB;CA0C1B"}
|
|
@@ -1254,6 +1254,82 @@ export class TerminalCore {
|
|
|
1254
1254
|
bufferLength: this.terminal.buffer.active.length
|
|
1255
1255
|
};
|
|
1256
1256
|
}
|
|
1257
|
+
readBufferLine(row, options = {}) {
|
|
1258
|
+
if (!this.terminal) {
|
|
1259
|
+
return '';
|
|
1260
|
+
}
|
|
1261
|
+
const normalizedRow = Math.floor(Number(row));
|
|
1262
|
+
if (!Number.isFinite(normalizedRow) || normalizedRow < 0) {
|
|
1263
|
+
return '';
|
|
1264
|
+
}
|
|
1265
|
+
try {
|
|
1266
|
+
const line = this.terminal.buffer?.active?.getLine?.(normalizedRow);
|
|
1267
|
+
const text = line?.translateToString?.(options.trimRight ?? false);
|
|
1268
|
+
return typeof text === 'string' ? text : '';
|
|
1269
|
+
}
|
|
1270
|
+
catch {
|
|
1271
|
+
return '';
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
readBufferLines(startRow, endRowInclusive, options = {}) {
|
|
1275
|
+
const start = Math.floor(Number(startRow));
|
|
1276
|
+
const end = Math.floor(Number(endRowInclusive));
|
|
1277
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) {
|
|
1278
|
+
return [];
|
|
1279
|
+
}
|
|
1280
|
+
const lines = [];
|
|
1281
|
+
for (let row = Math.max(0, start); row <= end; row += 1) {
|
|
1282
|
+
const text = this.readBufferLine(row, options);
|
|
1283
|
+
if (text.length > 0) {
|
|
1284
|
+
lines.push({ row, text });
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return lines;
|
|
1288
|
+
}
|
|
1289
|
+
getTouchScrollRuntime() {
|
|
1290
|
+
const terminal = this.terminal;
|
|
1291
|
+
if (!terminal) {
|
|
1292
|
+
return null;
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
scrollLines: amount => {
|
|
1296
|
+
const normalizedAmount = Math.trunc(Number(amount));
|
|
1297
|
+
if (!Number.isFinite(normalizedAmount) || normalizedAmount === 0) {
|
|
1298
|
+
return false;
|
|
1299
|
+
}
|
|
1300
|
+
if (typeof terminal.scrollLines !== 'function') {
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
terminal.scrollLines(normalizedAmount);
|
|
1304
|
+
this.requestDemandRender(false);
|
|
1305
|
+
return true;
|
|
1306
|
+
},
|
|
1307
|
+
getScrollbackLength: () => {
|
|
1308
|
+
if (typeof terminal.getScrollbackLength !== 'function') {
|
|
1309
|
+
return 0;
|
|
1310
|
+
}
|
|
1311
|
+
const length = Number(terminal.getScrollbackLength());
|
|
1312
|
+
return Number.isFinite(length) && length > 0 ? length : 0;
|
|
1313
|
+
},
|
|
1314
|
+
isAlternateScreen: () => {
|
|
1315
|
+
if (typeof terminal.isAlternateScreen !== 'function') {
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
return Boolean(terminal.isAlternateScreen());
|
|
1319
|
+
},
|
|
1320
|
+
sendAlternateScreenInput: data => {
|
|
1321
|
+
const text = String(data ?? '');
|
|
1322
|
+
if (!text) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
if (typeof terminal.input === 'function') {
|
|
1326
|
+
terminal.input(text, true);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
this.eventHandlers.onData?.(text);
|
|
1330
|
+
},
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1257
1333
|
findNext(term, options) {
|
|
1258
1334
|
return this.findInternal(term, options, 1);
|
|
1259
1335
|
}
|