@pokit/tabs-core 0.0.40 → 0.0.42
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;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,c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,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,aAAa,CAAqB;IAC1C,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;IA4B5B;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWzB;;OAEG;IACH,OAAO,IAAI,IAAI;IASf;;OAEG;IACH,OAAO,IAAI,IAAI;IAUf,OAAO,CAAC,YAAY;IAwCpB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,WAAW;CAcpB"}
|
package/dist/process-manager.js
CHANGED
|
@@ -32,6 +32,7 @@ export class ProcessManager {
|
|
|
32
32
|
options;
|
|
33
33
|
processes = [];
|
|
34
34
|
outputBuffers = new Map();
|
|
35
|
+
expectedStops = new Set();
|
|
35
36
|
flushScheduled = false;
|
|
36
37
|
destroyed = false;
|
|
37
38
|
constructor(items, options) {
|
|
@@ -72,8 +73,10 @@ export class ProcessManager {
|
|
|
72
73
|
return;
|
|
73
74
|
// Kill existing process
|
|
74
75
|
const existingProc = this.processes[index];
|
|
75
|
-
if (existingProc)
|
|
76
|
+
if (existingProc) {
|
|
77
|
+
this.expectedStops.add(index);
|
|
76
78
|
killProcessTree(existingProc);
|
|
79
|
+
}
|
|
77
80
|
// Clear output buffer
|
|
78
81
|
this.outputBuffers.delete(index);
|
|
79
82
|
// Notify UI to show "Restarting..."
|
|
@@ -91,8 +94,10 @@ export class ProcessManager {
|
|
|
91
94
|
*/
|
|
92
95
|
kill(index) {
|
|
93
96
|
const proc = this.processes[index];
|
|
94
|
-
if (proc)
|
|
97
|
+
if (proc) {
|
|
98
|
+
this.expectedStops.add(index);
|
|
95
99
|
killProcessTree(proc);
|
|
100
|
+
}
|
|
96
101
|
this.options.callbacks.onOutputUpdate(index, ['', 'Stopped']);
|
|
97
102
|
this.options.callbacks.onStatusChange(index, 'stopped');
|
|
98
103
|
}
|
|
@@ -100,9 +105,11 @@ export class ProcessManager {
|
|
|
100
105
|
* Kill all processes
|
|
101
106
|
*/
|
|
102
107
|
killAll() {
|
|
103
|
-
for (const proc of this.processes) {
|
|
104
|
-
if (proc)
|
|
108
|
+
for (const [index, proc] of this.processes.entries()) {
|
|
109
|
+
if (proc) {
|
|
110
|
+
this.expectedStops.add(index);
|
|
105
111
|
killProcessTree(proc);
|
|
112
|
+
}
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
115
|
/**
|
|
@@ -135,6 +142,11 @@ export class ProcessManager {
|
|
|
135
142
|
proc.stderr?.on('data', handleData);
|
|
136
143
|
proc.on('close', (code) => {
|
|
137
144
|
this.flushOutput();
|
|
145
|
+
this.processes[index] = null;
|
|
146
|
+
// Ignore close transitions for intentional stops (kill/restart/destroy).
|
|
147
|
+
if (this.expectedStops.delete(index)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
138
150
|
const status = code === 0 ? 'done' : 'error';
|
|
139
151
|
this.options.callbacks.onStatusChange(index, status, code ?? undefined);
|
|
140
152
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pokit/tabs-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
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.42"
|
|
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.42"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"bun": ">=1.0.0"
|
package/src/process-manager.ts
CHANGED
|
@@ -71,6 +71,7 @@ export class ProcessManager {
|
|
|
71
71
|
private options: ProcessManagerOptions;
|
|
72
72
|
private processes: (ChildProcess | null)[] = [];
|
|
73
73
|
private outputBuffers: Map<number, OutputBuffer> = new Map();
|
|
74
|
+
private expectedStops = new Set<number>();
|
|
74
75
|
private flushScheduled = false;
|
|
75
76
|
private destroyed = false;
|
|
76
77
|
|
|
@@ -115,7 +116,10 @@ export class ProcessManager {
|
|
|
115
116
|
|
|
116
117
|
// Kill existing process
|
|
117
118
|
const existingProc = this.processes[index];
|
|
118
|
-
if (existingProc)
|
|
119
|
+
if (existingProc) {
|
|
120
|
+
this.expectedStops.add(index);
|
|
121
|
+
killProcessTree(existingProc);
|
|
122
|
+
}
|
|
119
123
|
|
|
120
124
|
// Clear output buffer
|
|
121
125
|
this.outputBuffers.delete(index);
|
|
@@ -137,7 +141,10 @@ export class ProcessManager {
|
|
|
137
141
|
*/
|
|
138
142
|
kill(index: number): void {
|
|
139
143
|
const proc = this.processes[index];
|
|
140
|
-
if (proc)
|
|
144
|
+
if (proc) {
|
|
145
|
+
this.expectedStops.add(index);
|
|
146
|
+
killProcessTree(proc);
|
|
147
|
+
}
|
|
141
148
|
|
|
142
149
|
this.options.callbacks.onOutputUpdate(index, ['', 'Stopped']);
|
|
143
150
|
this.options.callbacks.onStatusChange(index, 'stopped');
|
|
@@ -147,8 +154,11 @@ export class ProcessManager {
|
|
|
147
154
|
* Kill all processes
|
|
148
155
|
*/
|
|
149
156
|
killAll(): void {
|
|
150
|
-
for (const proc of this.processes) {
|
|
151
|
-
if (proc)
|
|
157
|
+
for (const [index, proc] of this.processes.entries()) {
|
|
158
|
+
if (proc) {
|
|
159
|
+
this.expectedStops.add(index);
|
|
160
|
+
killProcessTree(proc);
|
|
161
|
+
}
|
|
152
162
|
}
|
|
153
163
|
}
|
|
154
164
|
|
|
@@ -188,6 +198,13 @@ export class ProcessManager {
|
|
|
188
198
|
|
|
189
199
|
proc.on('close', (code) => {
|
|
190
200
|
this.flushOutput();
|
|
201
|
+
this.processes[index] = null;
|
|
202
|
+
|
|
203
|
+
// Ignore close transitions for intentional stops (kill/restart/destroy).
|
|
204
|
+
if (this.expectedStops.delete(index)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
191
208
|
const status: TabStatus = code === 0 ? 'done' : 'error';
|
|
192
209
|
this.options.callbacks.onStatusChange(index, status, code ?? undefined);
|
|
193
210
|
});
|