@pokit/tabs-core 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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAWxD,eAAO,MAAM,eAAe,KAAK,CAAC;AAMlC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,2DAA2D;IAC3D,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzD,2CAA2C;IAC3C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9E,gDAAgD;IAChD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,kCAAkC;IAClC,SAAS,EAAE,uBAAuB,CAAC;CACpC,CAAC;AAUF;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAS;gBAEd,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,qBAAqB;IAM5D;;OAEG;IACH,cAAc,IAAI,UAAU,EAAE;IAU9B;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAyB5B;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQzB;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf;;OAEG;IACH,OAAO,IAAI,IAAI;IAUf,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,WAAW;CAcpB"}
|
package/dist/process-manager.js
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
* Framework-agnostic - provides callbacks for UI frameworks to consume.
|
|
6
6
|
*/
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
|
+
function killProcessTree(proc) {
|
|
9
|
+
if (proc.killed || proc.pid == null)
|
|
10
|
+
return;
|
|
11
|
+
try {
|
|
12
|
+
process.kill(-proc.pid, 'SIGTERM');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Process may have already exited
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
export const OUTPUT_BATCH_MS = 16;
|
|
9
19
|
// =============================================================================
|
|
10
20
|
// ProcessManager Class
|
|
@@ -62,9 +72,8 @@ export class ProcessManager {
|
|
|
62
72
|
return;
|
|
63
73
|
// Kill existing process
|
|
64
74
|
const existingProc = this.processes[index];
|
|
65
|
-
if (existingProc
|
|
66
|
-
existingProc
|
|
67
|
-
}
|
|
75
|
+
if (existingProc)
|
|
76
|
+
killProcessTree(existingProc);
|
|
68
77
|
// Clear output buffer
|
|
69
78
|
this.outputBuffers.delete(index);
|
|
70
79
|
// Notify UI to show "Restarting..."
|
|
@@ -82,9 +91,8 @@ export class ProcessManager {
|
|
|
82
91
|
*/
|
|
83
92
|
kill(index) {
|
|
84
93
|
const proc = this.processes[index];
|
|
85
|
-
if (proc
|
|
86
|
-
proc
|
|
87
|
-
}
|
|
94
|
+
if (proc)
|
|
95
|
+
killProcessTree(proc);
|
|
88
96
|
this.options.callbacks.onOutputUpdate(index, ['', 'Stopped']);
|
|
89
97
|
this.options.callbacks.onStatusChange(index, 'stopped');
|
|
90
98
|
}
|
|
@@ -93,9 +101,8 @@ export class ProcessManager {
|
|
|
93
101
|
*/
|
|
94
102
|
killAll() {
|
|
95
103
|
for (const proc of this.processes) {
|
|
96
|
-
if (proc
|
|
97
|
-
proc
|
|
98
|
-
}
|
|
104
|
+
if (proc)
|
|
105
|
+
killProcessTree(proc);
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
@@ -120,6 +127,7 @@ export class ProcessManager {
|
|
|
120
127
|
FORCE_COLOR: '1',
|
|
121
128
|
},
|
|
122
129
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
130
|
+
detached: true,
|
|
123
131
|
});
|
|
124
132
|
this.processes[index] = proc;
|
|
125
133
|
const handleData = (data) => this.appendOutput(index, data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pokit/tabs-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "Core tab management utilities for pok CLI applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
48
|
-
"@pokit/core": "0.0.
|
|
48
|
+
"@pokit/core": "0.0.40"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"react": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/bun": "latest",
|
|
57
57
|
"@types/react": "^19.2.0",
|
|
58
58
|
"react": "^19.2.0",
|
|
59
|
-
"@pokit/core": "0.0.
|
|
59
|
+
"@pokit/core": "0.0.40"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"bun": ">=1.0.0"
|
package/src/process-manager.ts
CHANGED
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
import { spawn, type ChildProcess } from 'node:child_process';
|
|
9
9
|
import type { TabStatus, TabProcess } from './types.js';
|
|
10
10
|
|
|
11
|
+
function killProcessTree(proc: ChildProcess): void {
|
|
12
|
+
if (proc.killed || proc.pid == null) return;
|
|
13
|
+
try {
|
|
14
|
+
process.kill(-proc.pid, 'SIGTERM');
|
|
15
|
+
} catch {
|
|
16
|
+
// Process may have already exited
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
export const OUTPUT_BATCH_MS = 16;
|
|
12
21
|
|
|
13
22
|
// =============================================================================
|
|
@@ -106,9 +115,7 @@ export class ProcessManager {
|
|
|
106
115
|
|
|
107
116
|
// Kill existing process
|
|
108
117
|
const existingProc = this.processes[index];
|
|
109
|
-
if (existingProc
|
|
110
|
-
existingProc.kill('SIGTERM');
|
|
111
|
-
}
|
|
118
|
+
if (existingProc) killProcessTree(existingProc);
|
|
112
119
|
|
|
113
120
|
// Clear output buffer
|
|
114
121
|
this.outputBuffers.delete(index);
|
|
@@ -130,9 +137,7 @@ export class ProcessManager {
|
|
|
130
137
|
*/
|
|
131
138
|
kill(index: number): void {
|
|
132
139
|
const proc = this.processes[index];
|
|
133
|
-
if (proc
|
|
134
|
-
proc.kill('SIGTERM');
|
|
135
|
-
}
|
|
140
|
+
if (proc) killProcessTree(proc);
|
|
136
141
|
|
|
137
142
|
this.options.callbacks.onOutputUpdate(index, ['', 'Stopped']);
|
|
138
143
|
this.options.callbacks.onStatusChange(index, 'stopped');
|
|
@@ -143,9 +148,7 @@ export class ProcessManager {
|
|
|
143
148
|
*/
|
|
144
149
|
killAll(): void {
|
|
145
150
|
for (const proc of this.processes) {
|
|
146
|
-
if (proc
|
|
147
|
-
proc.kill('SIGTERM');
|
|
148
|
-
}
|
|
151
|
+
if (proc) killProcessTree(proc);
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -173,6 +176,7 @@ export class ProcessManager {
|
|
|
173
176
|
FORCE_COLOR: '1',
|
|
174
177
|
} as NodeJS.ProcessEnv,
|
|
175
178
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
179
|
+
detached: true,
|
|
176
180
|
});
|
|
177
181
|
|
|
178
182
|
this.processes[index] = proc;
|