spawn-term 1.1.7 → 2.0.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/dist/cjs/components/App.js +110 -9
- package/dist/cjs/components/App.js.map +1 -1
- package/dist/cjs/components/CompactProcessLine.js +153 -0
- package/dist/cjs/components/CompactProcessLine.js.map +1 -0
- package/dist/cjs/components/Divider.js +24 -0
- package/dist/cjs/components/Divider.js.map +1 -0
- package/dist/cjs/components/ErrorDetailModal.js +115 -0
- package/dist/cjs/components/ErrorDetailModal.js.map +1 -0
- package/dist/cjs/components/ErrorListModal.js +135 -0
- package/dist/cjs/components/ErrorListModal.js.map +1 -0
- package/dist/cjs/components/StatusBar.js +104 -0
- package/dist/cjs/components/StatusBar.js.map +1 -0
- package/dist/cjs/createApp.js +30 -33
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/lib/figures.js +1 -1
- package/dist/cjs/lib/figures.js.map +1 -1
- package/dist/cjs/src/components/App.d.ts +1 -5
- package/dist/cjs/src/components/CompactProcessLine.d.ts +6 -0
- package/dist/cjs/src/components/Divider.d.ts +2 -0
- package/dist/cjs/src/components/ErrorDetailModal.d.ts +8 -0
- package/dist/cjs/src/components/ErrorListModal.d.ts +8 -0
- package/dist/cjs/src/components/StatusBar.d.ts +8 -0
- package/dist/cjs/src/createApp.d.ts +4 -5
- package/dist/cjs/src/state/processStore.d.ts +38 -0
- package/dist/cjs/state/processStore.js +241 -0
- package/dist/cjs/state/processStore.js.map +1 -0
- package/dist/cjs/worker.js +70 -108
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/components/App.js +108 -8
- package/dist/esm/components/App.js.map +1 -1
- package/dist/esm/components/CompactProcessLine.js +134 -0
- package/dist/esm/components/CompactProcessLine.js.map +1 -0
- package/dist/esm/components/Divider.js +13 -0
- package/dist/esm/components/Divider.js.map +1 -0
- package/dist/esm/components/ErrorDetailModal.js +99 -0
- package/dist/esm/components/ErrorDetailModal.js.map +1 -0
- package/dist/esm/components/ErrorListModal.js +116 -0
- package/dist/esm/components/ErrorListModal.js.map +1 -0
- package/dist/esm/components/StatusBar.js +87 -0
- package/dist/esm/components/StatusBar.js.map +1 -0
- package/dist/esm/createApp.js +31 -32
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/src/components/App.d.ts +1 -5
- package/dist/esm/src/components/CompactProcessLine.d.ts +6 -0
- package/dist/esm/src/components/Divider.d.ts +2 -0
- package/dist/esm/src/components/ErrorDetailModal.d.ts +8 -0
- package/dist/esm/src/components/ErrorListModal.d.ts +8 -0
- package/dist/esm/src/components/StatusBar.d.ts +8 -0
- package/dist/esm/src/createApp.d.ts +4 -5
- package/dist/esm/src/state/processStore.d.ts +38 -0
- package/dist/esm/state/processStore.js +149 -0
- package/dist/esm/state/processStore.js.map +1 -0
- package/dist/esm/worker.js +59 -91
- package/dist/esm/worker.js.map +1 -1
- package/package.json +1 -2
- package/dist/cjs/src/state/Store.d.ts +0 -11
- package/dist/cjs/state/Store.js +0 -40
- package/dist/cjs/state/Store.js.map +0 -1
- package/dist/esm/src/state/Store.d.ts +0 -11
- package/dist/esm/state/Store.js +0 -19
- package/dist/esm/state/Store.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
import { LineType } from '../types.js';
|
|
30
|
+
class ProcessStore {
|
|
31
|
+
// Mutations - Ink handles render throttling at 30 FPS
|
|
32
|
+
addProcess(process) {
|
|
33
|
+
this.processes = [
|
|
34
|
+
...this.processes,
|
|
35
|
+
process
|
|
36
|
+
];
|
|
37
|
+
this.notify();
|
|
38
|
+
}
|
|
39
|
+
updateProcess(id, update) {
|
|
40
|
+
const oldProcess = this.processes.find((p)=>p.id === id);
|
|
41
|
+
const wasRunning = (oldProcess === null || oldProcess === void 0 ? void 0 : oldProcess.state) === 'running';
|
|
42
|
+
const isNowComplete = update.state && update.state !== 'running';
|
|
43
|
+
this.processes = this.processes.map((p)=>p.id === id ? _object_spread({}, p, update) : p);
|
|
44
|
+
// Track completion order
|
|
45
|
+
if (wasRunning && isNowComplete && !this.completedIds.includes(id)) {
|
|
46
|
+
this.completedIds = [
|
|
47
|
+
...this.completedIds,
|
|
48
|
+
id
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
this.notify();
|
|
52
|
+
}
|
|
53
|
+
appendLines(id, newLines) {
|
|
54
|
+
const process = this.processes.find((p)=>p.id === id);
|
|
55
|
+
if (process) {
|
|
56
|
+
this.updateProcess(id, {
|
|
57
|
+
lines: process.lines.concat(newLines)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getProcess(id) {
|
|
62
|
+
return this.processes.find((p)=>p.id === id);
|
|
63
|
+
}
|
|
64
|
+
// UI state mutations
|
|
65
|
+
setMode(mode) {
|
|
66
|
+
this.mode = mode;
|
|
67
|
+
if (mode === 'errorList') {
|
|
68
|
+
this.selectedErrorIndex = 0;
|
|
69
|
+
}
|
|
70
|
+
this.notify();
|
|
71
|
+
}
|
|
72
|
+
selectNextError() {
|
|
73
|
+
const failed = this.getFailedProcesses();
|
|
74
|
+
if (failed.length > 0) {
|
|
75
|
+
this.selectedErrorIndex = (this.selectedErrorIndex + 1) % failed.length;
|
|
76
|
+
this.notify();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
selectPrevError() {
|
|
80
|
+
const failed = this.getFailedProcesses();
|
|
81
|
+
if (failed.length > 0) {
|
|
82
|
+
this.selectedErrorIndex = (this.selectedErrorIndex - 1 + failed.length) % failed.length;
|
|
83
|
+
this.notify();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getSelectedError() {
|
|
87
|
+
const failed = this.getFailedProcesses();
|
|
88
|
+
return failed[this.selectedErrorIndex];
|
|
89
|
+
}
|
|
90
|
+
// Exit signaling
|
|
91
|
+
signalExit(callback) {
|
|
92
|
+
this.shouldExit = true;
|
|
93
|
+
this.exitCallback = callback;
|
|
94
|
+
this.notify();
|
|
95
|
+
}
|
|
96
|
+
reset() {
|
|
97
|
+
this.processes = [];
|
|
98
|
+
this.completedIds = [];
|
|
99
|
+
this.shouldExit = false;
|
|
100
|
+
this.exitCallback = null;
|
|
101
|
+
this.mode = 'normal';
|
|
102
|
+
this.selectedErrorIndex = 0;
|
|
103
|
+
}
|
|
104
|
+
notify() {
|
|
105
|
+
this.listeners.forEach((l)=>{
|
|
106
|
+
l();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
constructor(){
|
|
110
|
+
this.processes = [];
|
|
111
|
+
this.completedIds = []; // Track completion order
|
|
112
|
+
this.listeners = new Set();
|
|
113
|
+
this.shouldExit = false;
|
|
114
|
+
this.exitCallback = null;
|
|
115
|
+
// UI state
|
|
116
|
+
this.mode = 'normal';
|
|
117
|
+
this.selectedErrorIndex = 0;
|
|
118
|
+
// useSyncExternalStore API
|
|
119
|
+
this.subscribe = (listener)=>{
|
|
120
|
+
this.listeners.add(listener);
|
|
121
|
+
return ()=>this.listeners.delete(listener);
|
|
122
|
+
};
|
|
123
|
+
this.getSnapshot = ()=>this.processes;
|
|
124
|
+
// Filtered getters
|
|
125
|
+
this.getRunningProcesses = ()=>{
|
|
126
|
+
return this.processes.filter((p)=>p.state === 'running');
|
|
127
|
+
};
|
|
128
|
+
this.getCompletedProcesses = ()=>{
|
|
129
|
+
// Return in completion order
|
|
130
|
+
return this.completedIds.map((id)=>this.processes.find((p)=>p.id === id)).filter((p)=>p !== undefined);
|
|
131
|
+
};
|
|
132
|
+
this.getFailedProcesses = ()=>{
|
|
133
|
+
return this.processes.filter((p)=>p.state === 'error');
|
|
134
|
+
};
|
|
135
|
+
// Counts
|
|
136
|
+
this.getRunningCount = ()=>this.processes.filter((p)=>p.state === 'running').length;
|
|
137
|
+
this.getDoneCount = ()=>this.processes.filter((p)=>p.state !== 'running').length;
|
|
138
|
+
this.getErrorCount = ()=>this.processes.filter((p)=>p.state === 'error').length;
|
|
139
|
+
this.getErrorLineCount = ()=>{
|
|
140
|
+
return this.processes.filter((p)=>p.state === 'error').reduce((total, p)=>total + p.lines.filter((l)=>l.type === LineType.stderr).length, 0);
|
|
141
|
+
};
|
|
142
|
+
// UI state getters
|
|
143
|
+
this.getMode = ()=>this.mode;
|
|
144
|
+
this.getSelectedErrorIndex = ()=>this.selectedErrorIndex;
|
|
145
|
+
this.getShouldExit = ()=>this.shouldExit;
|
|
146
|
+
this.getExitCallback = ()=>this.exitCallback;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export const processStore = new ProcessStore();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/processStore.ts"],"sourcesContent":["import type { ChildProcess, Line } from '../types.ts';\nimport { LineType } from '../types.ts';\n\ntype Listener = () => void;\ntype Mode = 'normal' | 'errorList' | 'errorDetail';\n\nclass ProcessStore {\n private processes: ChildProcess[] = [];\n private completedIds: string[] = []; // Track completion order\n private listeners = new Set<Listener>();\n private shouldExit = false;\n private exitCallback: (() => void) | null = null;\n\n // UI state\n private mode: Mode = 'normal';\n private selectedErrorIndex = 0;\n\n // useSyncExternalStore API\n subscribe = (listener: Listener): (() => void) => {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n };\n\n getSnapshot = (): ChildProcess[] => this.processes;\n\n // Filtered getters\n getRunningProcesses = (): ChildProcess[] => {\n return this.processes.filter((p) => p.state === 'running');\n };\n\n getCompletedProcesses = (): ChildProcess[] => {\n // Return in completion order\n return this.completedIds.map((id) => this.processes.find((p) => p.id === id)).filter((p): p is ChildProcess => p !== undefined);\n };\n\n getFailedProcesses = (): ChildProcess[] => {\n return this.processes.filter((p) => p.state === 'error');\n };\n\n // Counts\n getRunningCount = (): number => this.processes.filter((p) => p.state === 'running').length;\n getDoneCount = (): number => this.processes.filter((p) => p.state !== 'running').length;\n getErrorCount = (): number => this.processes.filter((p) => p.state === 'error').length;\n getErrorLineCount = (): number => {\n return this.processes.filter((p) => p.state === 'error').reduce((total, p) => total + p.lines.filter((l) => l.type === LineType.stderr).length, 0);\n };\n\n // UI state getters\n getMode = (): Mode => this.mode;\n getSelectedErrorIndex = (): number => this.selectedErrorIndex;\n\n // Mutations - Ink handles render throttling at 30 FPS\n addProcess(process: ChildProcess): void {\n this.processes = [...this.processes, process];\n this.notify();\n }\n\n updateProcess(id: string, update: Partial<ChildProcess>): void {\n const oldProcess = this.processes.find((p) => p.id === id);\n const wasRunning = oldProcess?.state === 'running';\n const isNowComplete = update.state && update.state !== 'running';\n\n this.processes = this.processes.map((p) => (p.id === id ? { ...p, ...update } : p));\n\n // Track completion order\n if (wasRunning && isNowComplete && !this.completedIds.includes(id)) {\n this.completedIds = [...this.completedIds, id];\n }\n\n this.notify();\n }\n\n appendLines(id: string, newLines: Line[]): void {\n const process = this.processes.find((p) => p.id === id);\n if (process) {\n this.updateProcess(id, { lines: process.lines.concat(newLines) });\n }\n }\n\n getProcess(id: string): ChildProcess | undefined {\n return this.processes.find((p) => p.id === id);\n }\n\n // UI state mutations\n setMode(mode: Mode): void {\n this.mode = mode;\n if (mode === 'errorList') {\n this.selectedErrorIndex = 0;\n }\n this.notify();\n }\n\n selectNextError(): void {\n const failed = this.getFailedProcesses();\n if (failed.length > 0) {\n this.selectedErrorIndex = (this.selectedErrorIndex + 1) % failed.length;\n this.notify();\n }\n }\n\n selectPrevError(): void {\n const failed = this.getFailedProcesses();\n if (failed.length > 0) {\n this.selectedErrorIndex = (this.selectedErrorIndex - 1 + failed.length) % failed.length;\n this.notify();\n }\n }\n\n getSelectedError(): ChildProcess | undefined {\n const failed = this.getFailedProcesses();\n return failed[this.selectedErrorIndex];\n }\n\n // Exit signaling\n signalExit(callback: () => void): void {\n this.shouldExit = true;\n this.exitCallback = callback;\n this.notify();\n }\n\n getShouldExit = (): boolean => this.shouldExit;\n getExitCallback = (): (() => void) | null => this.exitCallback;\n\n reset(): void {\n this.processes = [];\n this.completedIds = [];\n this.shouldExit = false;\n this.exitCallback = null;\n this.mode = 'normal';\n this.selectedErrorIndex = 0;\n }\n\n private notify(): void {\n this.listeners.forEach((l) => {\n l();\n });\n }\n}\n\nexport const processStore = new ProcessStore();\nexport type { ProcessStore };\n"],"names":["LineType","ProcessStore","addProcess","process","processes","notify","updateProcess","id","update","oldProcess","find","p","wasRunning","state","isNowComplete","map","completedIds","includes","appendLines","newLines","lines","concat","getProcess","setMode","mode","selectedErrorIndex","selectNextError","failed","getFailedProcesses","length","selectPrevError","getSelectedError","signalExit","callback","shouldExit","exitCallback","reset","listeners","forEach","l","Set","subscribe","listener","add","delete","getSnapshot","getRunningProcesses","filter","getCompletedProcesses","undefined","getRunningCount","getDoneCount","getErrorCount","getErrorLineCount","reduce","total","type","stderr","getMode","getSelectedErrorIndex","getShouldExit","getExitCallback","processStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,QAAQ,QAAQ,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QAClJ;QAEA,mBAAmB;aACnB6B,UAAU,IAAY,IAAI,CAAClC,IAAI;aAC/BmC,wBAAwB,IAAc,IAAI,CAAClC,kBAAkB;aAuE7DmC,gBAAgB,IAAe,IAAI,CAAC1B,UAAU;aAC9C2B,kBAAkB,IAA2B,IAAI,CAAC1B,YAAY;;AAgBhE;AAEA,OAAO,MAAM2B,eAAe,IAAI7D,eAAe"}
|
package/dist/esm/worker.js
CHANGED
|
@@ -26,30 +26,6 @@ function _object_spread(target) {
|
|
|
26
26
|
}
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
|
-
function ownKeys(object, enumerableOnly) {
|
|
30
|
-
var keys = Object.keys(object);
|
|
31
|
-
if (Object.getOwnPropertySymbols) {
|
|
32
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
-
if (enumerableOnly) {
|
|
34
|
-
symbols = symbols.filter(function(sym) {
|
|
35
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
keys.push.apply(keys, symbols);
|
|
39
|
-
}
|
|
40
|
-
return keys;
|
|
41
|
-
}
|
|
42
|
-
function _object_spread_props(target, source) {
|
|
43
|
-
source = source != null ? source : {};
|
|
44
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
-
} else {
|
|
47
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return target;
|
|
52
|
-
}
|
|
53
29
|
function _object_without_properties(source, excluded) {
|
|
54
30
|
if (source == null) return {};
|
|
55
31
|
var target = _object_without_properties_loose(source, excluded);
|
|
@@ -93,73 +69,65 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
93
69
|
"stdio"
|
|
94
70
|
]);
|
|
95
71
|
if (stdio === 'inherit') {
|
|
96
|
-
terminal.retain(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
];
|
|
156
|
-
const item = store.processes.find((x)=>x.id === id);
|
|
157
|
-
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
158
|
-
state: err ? 'error' : 'success'
|
|
159
|
-
}));
|
|
160
|
-
terminal.release(()=>{
|
|
161
|
-
err ? callback(err) : callback(null, res);
|
|
162
|
-
});
|
|
72
|
+
const store = terminal.retain();
|
|
73
|
+
const id = crypto.randomUUID();
|
|
74
|
+
store.addProcess(_object_spread({
|
|
75
|
+
id,
|
|
76
|
+
title: [
|
|
77
|
+
command
|
|
78
|
+
].concat(formatArguments(args)).join(' '),
|
|
79
|
+
state: 'running',
|
|
80
|
+
lines: []
|
|
81
|
+
}, options));
|
|
82
|
+
const cp = crossSpawn(command, args, csOptions);
|
|
83
|
+
const outputs = {
|
|
84
|
+
stdout: null,
|
|
85
|
+
stderr: null
|
|
86
|
+
};
|
|
87
|
+
const queue = new Queue();
|
|
88
|
+
if (cp.stdout) {
|
|
89
|
+
outputs.stdout = addLines((lines)=>{
|
|
90
|
+
store.appendLines(id, lines.map((text)=>({
|
|
91
|
+
type: LineType.stdout,
|
|
92
|
+
text
|
|
93
|
+
})));
|
|
94
|
+
});
|
|
95
|
+
queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), [
|
|
96
|
+
'error',
|
|
97
|
+
'end',
|
|
98
|
+
'close',
|
|
99
|
+
'finish'
|
|
100
|
+
]));
|
|
101
|
+
}
|
|
102
|
+
if (cp.stderr) {
|
|
103
|
+
outputs.stderr = addLines((lines)=>{
|
|
104
|
+
store.appendLines(id, lines.map((text)=>({
|
|
105
|
+
type: LineType.stderr,
|
|
106
|
+
text
|
|
107
|
+
})));
|
|
108
|
+
});
|
|
109
|
+
queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), [
|
|
110
|
+
'error',
|
|
111
|
+
'end',
|
|
112
|
+
'close',
|
|
113
|
+
'finish'
|
|
114
|
+
]));
|
|
115
|
+
}
|
|
116
|
+
queue.defer(spawn.worker.bind(null, cp, csOptions));
|
|
117
|
+
queue.await((err)=>{
|
|
118
|
+
const res = err ? err : {};
|
|
119
|
+
res.stdout = outputs.stdout ? outputs.stdout.output : null;
|
|
120
|
+
res.stderr = outputs.stderr ? outputs.stderr.output : null;
|
|
121
|
+
res.output = [
|
|
122
|
+
res.stdout,
|
|
123
|
+
res.stderr,
|
|
124
|
+
null
|
|
125
|
+
];
|
|
126
|
+
store.updateProcess(id, {
|
|
127
|
+
state: err ? 'error' : 'success'
|
|
128
|
+
});
|
|
129
|
+
terminal.release(()=>{
|
|
130
|
+
err ? callback(err) : callback(null, res);
|
|
163
131
|
});
|
|
164
132
|
});
|
|
165
133
|
} else {
|
package/dist/esm/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain(
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n const store = terminal.retain();\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n store.appendLines(\n id,\n lines.map((text) => ({ type: LineType.stdout, text }))\n );\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n store.appendLines(\n id,\n lines.map((text) => ({ type: LineType.stderr, text }))\n );\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n store.updateProcess(id, { state: err ? 'error' : 'success' });\n\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","store","retain","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","appendLines","map","text","type","defer","bind","pipe","worker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YAAY;YACtD;YACAiB,MAAMK,KAAK,CAACpC,GAAGqC,IAAI,CAAC,MAAMV,GAAGE,MAAM,CAACS,IAAI,CAACV,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIF,GAAGG,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAG1B,eAAe,CAACuC;gBAC/Bf,QAAQE,MAAM,CAACa,MAAM,GAAGA,OAAOG,QAAQ,CAAChC,YAAY;YACtD;YACAiB,MAAMK,KAAK,CAACpC,GAAGqC,IAAI,CAAC,MAAMV,GAAGG,MAAM,CAACQ,IAAI,CAACV,QAAQE,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACAC,MAAMK,KAAK,CAACvC,MAAM0C,MAAM,CAACF,IAAI,CAAC,MAAMV,IAAIX;QACxCe,MAAMS,KAAK,CAAC,CAACC;YACX,MAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAIb,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACc,MAAM,GAAG;YACtDD,IAAIZ,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACa,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIb,MAAM;gBAAEa,IAAIZ,MAAM;gBAAE;aAAK;YAC3CW,MAAM5B,SAAS4B,OAAO5B,SAAS,MAAM6B;QACvC;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"cross-spawn-cb": "*",
|
|
45
45
|
"ink": "*",
|
|
46
|
-
"lodash.throttle": "*",
|
|
47
46
|
"on-one": "*",
|
|
48
47
|
"queue-cb": "*",
|
|
49
48
|
"react": "*"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ChildProcess } from '../types.js';
|
|
2
|
-
export type RenderFunction = () => void;
|
|
3
|
-
export type StoreData = ChildProcess[];
|
|
4
|
-
export default class Store {
|
|
5
|
-
processes: ChildProcess[];
|
|
6
|
-
onRender: RenderFunction;
|
|
7
|
-
constructor(onRender: RenderFunction);
|
|
8
|
-
data(): StoreData;
|
|
9
|
-
addProcess(process: ChildProcess): void;
|
|
10
|
-
updateProcess(process: ChildProcess): void;
|
|
11
|
-
}
|
package/dist/cjs/state/Store.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return Store;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
function _class_call_check(instance, Constructor) {
|
|
12
|
-
if (!(instance instanceof Constructor)) {
|
|
13
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
var Store = /*#__PURE__*/ function() {
|
|
17
|
-
"use strict";
|
|
18
|
-
function Store(onRender) {
|
|
19
|
-
_class_call_check(this, Store);
|
|
20
|
-
if (!onRender) throw new Error('missing on render');
|
|
21
|
-
this.processes = [];
|
|
22
|
-
this.onRender = onRender;
|
|
23
|
-
}
|
|
24
|
-
var _proto = Store.prototype;
|
|
25
|
-
_proto.data = function data() {
|
|
26
|
-
return this.processes;
|
|
27
|
-
};
|
|
28
|
-
_proto.addProcess = function addProcess(process) {
|
|
29
|
-
this.processes.push(process);
|
|
30
|
-
this.onRender();
|
|
31
|
-
};
|
|
32
|
-
_proto.updateProcess = function updateProcess(process) {
|
|
33
|
-
this.processes = this.processes.map(function(x) {
|
|
34
|
-
return x.id === process.id ? process : x;
|
|
35
|
-
});
|
|
36
|
-
this.onRender();
|
|
37
|
-
};
|
|
38
|
-
return Store;
|
|
39
|
-
}();
|
|
40
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","onRender","Error","processes","data","addProcess","process","push","updateProcess","map","x","id"],"mappings":";;;;;;;eAKqBA;;;;;;;;AAAN,IAAA,AAAMA,sBAAN;;aAAMA,MAIPC,QAAwB;gCAJjBD;QAKjB,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM;QAC/B,IAAI,CAACC,SAAS,GAAG,EAAE;QACnB,IAAI,CAACF,QAAQ,GAAGA;;iBAPCD;IAUnBI,OAAAA,IAEC,GAFDA,SAAAA;QACE,OAAO,IAAI,CAACD,SAAS;IACvB;IAEAE,OAAAA,UAGC,GAHDA,SAAAA,WAAWC,OAAqB;QAC9B,IAAI,CAACH,SAAS,CAACI,IAAI,CAACD;QACpB,IAAI,CAACL,QAAQ;IACf;IAEAO,OAAAA,aAGC,GAHDA,SAAAA,cAAcF,OAAqB;QACjC,IAAI,CAACH,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,SAACC;mBAAOA,EAAEC,EAAE,KAAKL,QAAQK,EAAE,GAAGL,UAAUI;;QAC5E,IAAI,CAACT,QAAQ;IACf;WAtBmBD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ChildProcess } from '../types.js';
|
|
2
|
-
export type RenderFunction = () => void;
|
|
3
|
-
export type StoreData = ChildProcess[];
|
|
4
|
-
export default class Store {
|
|
5
|
-
processes: ChildProcess[];
|
|
6
|
-
onRender: RenderFunction;
|
|
7
|
-
constructor(onRender: RenderFunction);
|
|
8
|
-
data(): StoreData;
|
|
9
|
-
addProcess(process: ChildProcess): void;
|
|
10
|
-
updateProcess(process: ChildProcess): void;
|
|
11
|
-
}
|
package/dist/esm/state/Store.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
class Store {
|
|
2
|
-
data() {
|
|
3
|
-
return this.processes;
|
|
4
|
-
}
|
|
5
|
-
addProcess(process) {
|
|
6
|
-
this.processes.push(process);
|
|
7
|
-
this.onRender();
|
|
8
|
-
}
|
|
9
|
-
updateProcess(process) {
|
|
10
|
-
this.processes = this.processes.map((x)=>x.id === process.id ? process : x);
|
|
11
|
-
this.onRender();
|
|
12
|
-
}
|
|
13
|
-
constructor(onRender){
|
|
14
|
-
if (!onRender) throw new Error('missing on render');
|
|
15
|
-
this.processes = [];
|
|
16
|
-
this.onRender = onRender;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export { Store as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","data","processes","addProcess","process","push","onRender","updateProcess","map","x","id","Error"],"mappings":"AAKe,MAAMA;IAUnBC,OAAkB;QAChB,OAAO,IAAI,CAACC,SAAS;IACvB;IAEAC,WAAWC,OAAqB,EAAQ;QACtC,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACE,QAAQ;IACf;IAEAC,cAAcH,OAAqB,EAAQ;QACzC,IAAI,CAACF,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKN,QAAQM,EAAE,GAAGN,UAAUK;QAC5E,IAAI,CAACH,QAAQ;IACf;IAlBA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIK,MAAM;QAC/B,IAAI,CAACT,SAAS,GAAG,EAAE;QACnB,IAAI,CAACI,QAAQ,GAAGA;IAClB;AAeF;AAvBA,SAAqBN,mBAuBpB"}
|