@pokit/tabs-opentui 0.0.38 → 0.0.40
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/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +3 -0
- package/dist/tabs-app.d.ts.map +1 -1
- package/dist/tabs-app.js +19 -12
- package/package.json +5 -5
- package/src/adapter.tsx +4 -0
- package/src/tabs-app.tsx +14 -12
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAwB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK/E;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAwB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK/E;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAkH/C;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,QAAQ,EACb,OAAO,GAAE,mBAAwB,GAChC;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA4GzB"}
|
package/dist/adapter.js
CHANGED
|
@@ -25,6 +25,9 @@ export function createTabsAdapter() {
|
|
|
25
25
|
if (items.length === 0) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
+
// Clear the main screen before switching to alternate screen buffer.
|
|
29
|
+
// This ensures the menu output is not visible when we return from alternate screen.
|
|
30
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
28
31
|
// Ensure stdin is not paused - previous CLI operations (prompts, spinners)
|
|
29
32
|
// may have left it in a paused state
|
|
30
33
|
if (process.stdin.isPaused()) {
|
package/dist/tabs-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-app.d.ts","sourceRoot":"","sources":["../src/tabs-app.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs-app.d.ts","sourceRoot":"","sources":["../src/tabs-app.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkB/C,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,CAAC;AAOF,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,GAAG,KAAK,CAAC,SAAS,CA6VjF"}
|
package/dist/tabs-app.js
CHANGED
|
@@ -9,6 +9,16 @@ import { spawn } from 'node:child_process';
|
|
|
9
9
|
import stripAnsi from 'strip-ansi';
|
|
10
10
|
import { TabbedView } from './tabbed-view.js';
|
|
11
11
|
import { OutputBuffer, MAX_OUTPUT_LINES, MAX_LINE_LENGTH, BUFFER_WARNING_THRESHOLD, } from '@pokit/tabs-core';
|
|
12
|
+
function killProcessTree(proc) {
|
|
13
|
+
if (proc.killed || proc.pid == null)
|
|
14
|
+
return;
|
|
15
|
+
try {
|
|
16
|
+
process.kill(-proc.pid, 'SIGTERM');
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Process may have already exited
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
const OUTPUT_BATCH_MS = 16;
|
|
13
23
|
/** How many pixels from bottom to consider "near bottom" for auto-scroll */
|
|
14
24
|
const NEAR_BOTTOM_THRESHOLD = 50;
|
|
@@ -156,6 +166,7 @@ export function TabsApp({ items, options, onExit }) {
|
|
|
156
166
|
FORCE_COLOR: '1',
|
|
157
167
|
},
|
|
158
168
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
169
|
+
detached: true,
|
|
159
170
|
});
|
|
160
171
|
const handleData = (data) => appendOutput(index, data);
|
|
161
172
|
proc.stdout?.on('data', handleData);
|
|
@@ -196,24 +207,21 @@ export function TabsApp({ items, options, onExit }) {
|
|
|
196
207
|
processesRef.current = procs;
|
|
197
208
|
return () => {
|
|
198
209
|
for (const proc of processesRef.current) {
|
|
199
|
-
if (proc
|
|
200
|
-
proc
|
|
201
|
-
}
|
|
210
|
+
if (proc)
|
|
211
|
+
killProcessTree(proc);
|
|
202
212
|
}
|
|
203
213
|
};
|
|
204
214
|
}, [items, spawnProcess]);
|
|
205
215
|
const killAll = useCallback(() => {
|
|
206
216
|
for (const proc of processesRef.current) {
|
|
207
|
-
if (proc
|
|
208
|
-
proc
|
|
209
|
-
}
|
|
217
|
+
if (proc)
|
|
218
|
+
killProcessTree(proc);
|
|
210
219
|
}
|
|
211
220
|
}, []);
|
|
212
221
|
const handleRestart = useCallback((index) => {
|
|
213
222
|
const existingProc = processesRef.current[index];
|
|
214
|
-
if (existingProc
|
|
215
|
-
existingProc
|
|
216
|
-
}
|
|
223
|
+
if (existingProc)
|
|
224
|
+
killProcessTree(existingProc);
|
|
217
225
|
// Clear both batch buffer and ring buffer
|
|
218
226
|
batchBuffersRef.current.delete(index);
|
|
219
227
|
const tabId = `tab-${index}`;
|
|
@@ -240,9 +248,8 @@ export function TabsApp({ items, options, onExit }) {
|
|
|
240
248
|
}, [spawnProcess, scrollToBottom]);
|
|
241
249
|
const handleKill = useCallback((index) => {
|
|
242
250
|
const proc = processesRef.current[index];
|
|
243
|
-
if (proc
|
|
244
|
-
proc
|
|
245
|
-
}
|
|
251
|
+
if (proc)
|
|
252
|
+
killProcessTree(proc);
|
|
246
253
|
setTabs((prev) => {
|
|
247
254
|
const next = [...prev];
|
|
248
255
|
const tab = next[index];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pokit/tabs-opentui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "OpenTUI-based tab renderer for pok CLI applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/bun": "latest",
|
|
55
55
|
"@types/react": "^19.2.0",
|
|
56
|
-
"@pokit/core": "0.0.
|
|
57
|
-
"@pokit/tabs-core": "0.0.
|
|
56
|
+
"@pokit/core": "0.0.40",
|
|
57
|
+
"@pokit/tabs-core": "0.0.40"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@pokit/core": "0.0.
|
|
61
|
-
"@pokit/tabs-core": "0.0.
|
|
60
|
+
"@pokit/core": "0.0.40",
|
|
61
|
+
"@pokit/tabs-core": "0.0.40"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"bun": ">=1.0.0"
|
package/src/adapter.tsx
CHANGED
|
@@ -31,6 +31,10 @@ export function createTabsAdapter(): TabsAdapter {
|
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Clear the main screen before switching to alternate screen buffer.
|
|
35
|
+
// This ensures the menu output is not visible when we return from alternate screen.
|
|
36
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
37
|
+
|
|
34
38
|
// Ensure stdin is not paused - previous CLI operations (prompts, spinners)
|
|
35
39
|
// may have left it in a paused state
|
|
36
40
|
if (process.stdin.isPaused()) {
|
package/src/tabs-app.tsx
CHANGED
|
@@ -18,6 +18,15 @@ import type { TabSpec, TabProcess } from '@pokit/tabs-core';
|
|
|
18
18
|
import type { TabsOptions } from '@pokit/core';
|
|
19
19
|
import type { ScrollBoxRenderable } from '@opentui/core';
|
|
20
20
|
|
|
21
|
+
function killProcessTree(proc: ChildProcess): void {
|
|
22
|
+
if (proc.killed || proc.pid == null) return;
|
|
23
|
+
try {
|
|
24
|
+
process.kill(-proc.pid, 'SIGTERM');
|
|
25
|
+
} catch {
|
|
26
|
+
// Process may have already exited
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
const OUTPUT_BATCH_MS = 16;
|
|
22
31
|
/** How many pixels from bottom to consider "near bottom" for auto-scroll */
|
|
23
32
|
const NEAR_BOTTOM_THRESHOLD = 50;
|
|
@@ -202,6 +211,7 @@ export function TabsApp({ items, options, onExit }: TabsAppProps): React.ReactNo
|
|
|
202
211
|
FORCE_COLOR: '1',
|
|
203
212
|
} as NodeJS.ProcessEnv,
|
|
204
213
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
214
|
+
detached: true,
|
|
205
215
|
});
|
|
206
216
|
|
|
207
217
|
const handleData = (data: Buffer) => appendOutput(index, data);
|
|
@@ -249,27 +259,21 @@ export function TabsApp({ items, options, onExit }: TabsAppProps): React.ReactNo
|
|
|
249
259
|
|
|
250
260
|
return () => {
|
|
251
261
|
for (const proc of processesRef.current) {
|
|
252
|
-
if (proc
|
|
253
|
-
proc.kill('SIGTERM');
|
|
254
|
-
}
|
|
262
|
+
if (proc) killProcessTree(proc);
|
|
255
263
|
}
|
|
256
264
|
};
|
|
257
265
|
}, [items, spawnProcess]);
|
|
258
266
|
|
|
259
267
|
const killAll = useCallback(() => {
|
|
260
268
|
for (const proc of processesRef.current) {
|
|
261
|
-
if (proc
|
|
262
|
-
proc.kill('SIGTERM');
|
|
263
|
-
}
|
|
269
|
+
if (proc) killProcessTree(proc);
|
|
264
270
|
}
|
|
265
271
|
}, []);
|
|
266
272
|
|
|
267
273
|
const handleRestart = useCallback(
|
|
268
274
|
(index: number) => {
|
|
269
275
|
const existingProc = processesRef.current[index];
|
|
270
|
-
if (existingProc
|
|
271
|
-
existingProc.kill('SIGTERM');
|
|
272
|
-
}
|
|
276
|
+
if (existingProc) killProcessTree(existingProc);
|
|
273
277
|
|
|
274
278
|
// Clear both batch buffer and ring buffer
|
|
275
279
|
batchBuffersRef.current.delete(index);
|
|
@@ -302,9 +306,7 @@ export function TabsApp({ items, options, onExit }: TabsAppProps): React.ReactNo
|
|
|
302
306
|
|
|
303
307
|
const handleKill = useCallback((index: number) => {
|
|
304
308
|
const proc = processesRef.current[index];
|
|
305
|
-
if (proc
|
|
306
|
-
proc.kill('SIGTERM');
|
|
307
|
-
}
|
|
309
|
+
if (proc) killProcessTree(proc);
|
|
308
310
|
|
|
309
311
|
setTabs((prev) => {
|
|
310
312
|
const next = [...prev];
|