spawn-term 1.0.7 → 1.0.9
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.d.cts +3 -1
- package/dist/cjs/components/App.d.ts +3 -1
- package/dist/cjs/components/App.js +6 -33
- package/dist/cjs/components/App.js.map +1 -1
- package/dist/cjs/components/ChildProcess.d.cts +4 -1
- package/dist/cjs/components/ChildProcess.d.ts +4 -1
- package/dist/cjs/components/ChildProcess.js +20 -10
- package/dist/cjs/components/ChildProcess.js.map +1 -1
- package/dist/cjs/createApp.d.cts +1 -1
- package/dist/cjs/createApp.d.ts +1 -1
- package/dist/cjs/createApp.js +17 -10
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/state/Store.d.cts +11 -0
- package/dist/cjs/state/Store.d.ts +11 -0
- package/dist/cjs/state/Store.js +40 -0
- package/dist/cjs/state/Store.js.map +1 -0
- package/dist/cjs/types.d.cts +0 -7
- package/dist/cjs/types.d.ts +0 -7
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/worker.js +10 -7
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/components/App.d.ts +3 -1
- package/dist/esm/components/App.js +4 -32
- package/dist/esm/components/App.js.map +1 -1
- package/dist/esm/components/ChildProcess.d.ts +4 -1
- package/dist/esm/components/ChildProcess.js +17 -10
- package/dist/esm/components/ChildProcess.js.map +1 -1
- package/dist/esm/createApp.d.ts +1 -1
- package/dist/esm/createApp.js +17 -10
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/state/Store.d.ts +11 -0
- package/dist/esm/state/Store.js +19 -0
- package/dist/esm/state/Store.js.map +1 -0
- package/dist/esm/types.d.ts +0 -7
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/worker.js +8 -7
- package/dist/esm/worker.js.map +1 -1
- package/package.json +2 -1
- package/dist/cjs/state/ProcessContext.d.cts +0 -6
- package/dist/cjs/state/ProcessContext.d.ts +0 -6
- package/dist/cjs/state/ProcessContext.js +0 -139
- package/dist/cjs/state/ProcessContext.js.map +0 -1
- package/dist/cjs/state/ProcessStore.d.cts +0 -8
- package/dist/cjs/state/ProcessStore.d.ts +0 -8
- package/dist/cjs/state/ProcessStore.js +0 -100
- package/dist/cjs/state/ProcessStore.js.map +0 -1
- package/dist/esm/state/ProcessContext.d.ts +0 -6
- package/dist/esm/state/ProcessContext.js +0 -51
- package/dist/esm/state/ProcessContext.js.map +0 -1
- package/dist/esm/state/ProcessStore.d.ts +0 -8
- package/dist/esm/state/ProcessStore.js +0 -22
- package/dist/esm/state/ProcessStore.js.map +0 -1
|
@@ -10,47 +10,20 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
12
12
|
var _ink = require("ink");
|
|
13
|
-
var _ProcessContext = require("../state/ProcessContext.js");
|
|
14
13
|
var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.js"));
|
|
15
|
-
function _define_property(obj, key, value) {
|
|
16
|
-
if (key in obj) {
|
|
17
|
-
Object.defineProperty(obj, key, {
|
|
18
|
-
value: value,
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
obj[key] = value;
|
|
25
|
-
}
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
14
|
function _interop_require_default(obj) {
|
|
29
15
|
return obj && obj.__esModule ? obj : {
|
|
30
16
|
default: obj
|
|
31
17
|
};
|
|
32
18
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
36
|
-
var ownKeys = Object.keys(source);
|
|
37
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
38
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
39
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
ownKeys.forEach(function(key) {
|
|
43
|
-
_define_property(target, key, source[key]);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return target;
|
|
47
|
-
}
|
|
48
|
-
function App() {
|
|
49
|
-
var processes = (0, _ProcessContext.useProcesses)();
|
|
19
|
+
function App(param) {
|
|
20
|
+
var store = param.store;
|
|
50
21
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
|
|
51
22
|
flexDirection: "column",
|
|
52
|
-
children: processes.map(function(item) {
|
|
53
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default,
|
|
23
|
+
children: store.processes.map(function(item) {
|
|
24
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default, {
|
|
25
|
+
item: item
|
|
26
|
+
}, item.id);
|
|
54
27
|
})
|
|
55
28
|
});
|
|
56
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["App","store","Box","flexDirection","processes","map","item","ChildProcess","id"],"mappings":";;;;+BAIA;;;eAAwBA;;;;mBAJJ;mEAEK;;;;;;AAEV,SAASA,IAAI,KAAS;QAAT,AAAEC,QAAF,MAAEA;IAC5B,qBACE,qBAACC,QAAG;QAACC,eAAc;kBAChBF,MAAMG,SAAS,CAACC,GAAG,CAAC,SAACC;iCACpB,qBAACC,qBAAY;gBAAeD,MAAMA;eAAfA,KAAKE,EAAE;;;AAIlC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { ChildProcess as ChildProcessT } from '../types.js';
|
|
2
|
-
|
|
2
|
+
type ItemProps = {
|
|
3
|
+
item: ChildProcessT;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("react").NamedExoticComponent<ItemProps>;
|
|
3
6
|
export default _default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { ChildProcess as ChildProcessT } from '../types.js';
|
|
2
|
-
|
|
2
|
+
type ItemProps = {
|
|
3
|
+
item: ChildProcessT;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("react").NamedExoticComponent<ItemProps>;
|
|
3
6
|
export default _default;
|
|
@@ -124,7 +124,9 @@ var Lines = /*#__PURE__*/ (0, _react.memo)(function Lines(param) {
|
|
|
124
124
|
children: lines.map(renderLine)
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(
|
|
127
|
+
var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(param) {
|
|
128
|
+
var item = param.item;
|
|
129
|
+
var lines = item.lines;
|
|
128
130
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ink.Box, {
|
|
129
131
|
flexDirection: "column",
|
|
130
132
|
children: [
|
|
@@ -134,26 +136,28 @@ var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(item) {
|
|
|
134
136
|
state: item.state
|
|
135
137
|
}),
|
|
136
138
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(Lines, {
|
|
137
|
-
lines:
|
|
139
|
+
lines: lines
|
|
138
140
|
})
|
|
139
141
|
]
|
|
140
142
|
});
|
|
141
143
|
});
|
|
142
|
-
var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(
|
|
144
|
+
var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(param) {
|
|
145
|
+
var item = param.item;
|
|
146
|
+
var state = item.state, lines = item.lines;
|
|
143
147
|
// remove ansi codes when displaying single lines
|
|
144
148
|
var errors = (0, _react.useMemo)(function() {
|
|
145
|
-
return
|
|
149
|
+
return lines.filter(function(line) {
|
|
146
150
|
return line.type === _types.LineType.stderr;
|
|
147
151
|
});
|
|
148
152
|
}, [
|
|
149
|
-
|
|
153
|
+
lines
|
|
150
154
|
]);
|
|
151
155
|
var summary = (0, _react.useMemo)(function() {
|
|
152
|
-
return
|
|
156
|
+
return lines.filter(function(line) {
|
|
153
157
|
return line.text.length > 0 && errors.indexOf(line) < 0;
|
|
154
158
|
}).pop();
|
|
155
159
|
}, [
|
|
156
|
-
|
|
160
|
+
lines,
|
|
157
161
|
errors
|
|
158
162
|
]);
|
|
159
163
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ink.Box, {
|
|
@@ -164,7 +168,7 @@ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(item) {
|
|
|
164
168
|
title: item.title,
|
|
165
169
|
state: item.state
|
|
166
170
|
}),
|
|
167
|
-
|
|
171
|
+
state === 'running' && /*#__PURE__*/ (0, _jsxruntime.jsx)(RunningSummary, {
|
|
168
172
|
line: summary || BLANK_LINE
|
|
169
173
|
}),
|
|
170
174
|
errors.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(Lines, {
|
|
@@ -173,7 +177,13 @@ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(item) {
|
|
|
173
177
|
]
|
|
174
178
|
});
|
|
175
179
|
});
|
|
176
|
-
var _default = /*#__PURE__*/ (0, _react.memo)(function ChildProcess(
|
|
177
|
-
|
|
180
|
+
var _default = /*#__PURE__*/ (0, _react.memo)(function ChildProcess(param) {
|
|
181
|
+
var item = param.item;
|
|
182
|
+
var expanded = item.expanded;
|
|
183
|
+
return expanded ? /*#__PURE__*/ (0, _jsxruntime.jsx)(Expanded, {
|
|
184
|
+
item: item
|
|
185
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(Contracted, {
|
|
186
|
+
item: item
|
|
187
|
+
});
|
|
178
188
|
});
|
|
179
189
|
/* 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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded(item:
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { lines } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, lines } = item;\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === LineType.stderr), [lines]);\n const summary = useMemo(() => lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && <RunningSummary line={summary || BLANK_LINE} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n});\n\nexport default memo(function ChildProcess({ item }: ItemProps) {\n const { expanded } = item;\n return expanded ? <Expanded item={item} /> : <Contracted item={item} />;\n});\n"],"names":["REGEX_ANSI","ansiRegex","BLANK_LINE","type","LineType","stdout","text","SPINNER","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","Header","memo","group","title","state","icon","Box","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BA2GA;;;eAAA;;;;mBA3G0B;qBACI;gEACR;8DACF;qBAEK;8DACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,IAAMA,aAAaC,IAAAA,kBAAS;AAC5B,IAAMC,aAAa;IAAEC,MAAMC,eAAQ,CAACC,MAAM;IAAEC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,yBAAexB,IAAAA,WAAI,EAAC,SAASgC,aAAa,KAAmB;QAAnB,AAAEV,OAAF,MAAEA;IAC1C,IAAM,AAAEW,WAAaX,KAAbW;IACR,OAAOA,yBAAW,qBAACZ;QAASC,MAAMA;uBAAW,qBAACC;QAAWD,MAAMA;;AACjE"}
|
package/dist/cjs/createApp.d.cts
CHANGED
package/dist/cjs/createApp.d.ts
CHANGED
package/dist/cjs/createApp.js
CHANGED
|
@@ -10,36 +10,43 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
12
12
|
var _ink = require("ink");
|
|
13
|
+
var _lodashthrottle = /*#__PURE__*/ _interop_require_default(require("lodash.throttle"));
|
|
13
14
|
var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.js"));
|
|
14
|
-
var
|
|
15
|
-
var _ProcessStore = /*#__PURE__*/ _interop_require_default(require("./state/ProcessStore.js"));
|
|
15
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("./state/Store.js"));
|
|
16
16
|
function _interop_require_default(obj) {
|
|
17
17
|
return obj && obj.__esModule ? obj : {
|
|
18
18
|
default: obj
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
var THROTTLE = 100;
|
|
21
22
|
function createApp() {
|
|
22
23
|
var refCount = 0;
|
|
23
24
|
var store = null;
|
|
24
25
|
var inkApp = null;
|
|
26
|
+
var previousData = null;
|
|
27
|
+
var rerender = function() {
|
|
28
|
+
if (!inkApp || !store) return;
|
|
29
|
+
if (store.data() === previousData) return;
|
|
30
|
+
previousData = store.data();
|
|
31
|
+
inkApp.rerender(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
|
|
32
|
+
store: store
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
var rerenderThrottled = (0, _lodashthrottle.default)(rerender, THROTTLE);
|
|
25
36
|
return {
|
|
26
37
|
retain: function retain(fn) {
|
|
27
38
|
if (++refCount > 1) return fn(store);
|
|
28
39
|
if (store) throw new Error('Not expecting store');
|
|
29
|
-
store = new
|
|
30
|
-
inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
31
|
-
store: store
|
|
32
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {})
|
|
40
|
+
store = new _Store.default(rerenderThrottled);
|
|
41
|
+
inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
|
|
42
|
+
store: store
|
|
33
43
|
}));
|
|
34
44
|
fn(store);
|
|
35
45
|
},
|
|
36
46
|
release: function release(cb) {
|
|
37
47
|
if (--refCount > 0) return cb();
|
|
38
48
|
if (!store) throw new Error('Expecting store');
|
|
39
|
-
|
|
40
|
-
store: store,
|
|
41
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {})
|
|
42
|
-
}));
|
|
49
|
+
rerender();
|
|
43
50
|
inkApp.waitUntilExit().then(function() {
|
|
44
51
|
return cb();
|
|
45
52
|
}).catch(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.js';\nimport { default as Store, type StoreData } from './state/Store.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","THROTTLE","refCount","store","inkApp","previousData","rerender","data","App","rerenderThrottled","throttle","retain","fn","Error","Store","render","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";;;;+BAUA;;;eAAwBA;;;;mBAVc;qEACjB;0DACL;4DACiC;;;;;;AAKjD,IAAMC,WAAW;AAEF,SAASD;IACtB,IAAIE,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,IAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,qBAACE,YAAG;YAACL,OAAOA;;IAC9B;IACA,IAAMM,oBAAoBC,IAAAA,uBAAQ,EAACJ,UAAUL;IAE7C,OAAO;QACLU,QAAAA,SAAAA,OAAOC,EAAkB;YACvB,IAAI,EAAEV,WAAW,GAAG,OAAOU,GAAGT;YAC9B,IAAIA,OAAO,MAAM,IAAIU,MAAM;YAE3BV,QAAQ,IAAIW,cAAK,CAACL;YAClBL,SAASW,IAAAA,WAAM,gBAAC,qBAACP,YAAG;gBAACL,OAAOA;;YAC5BS,GAAGT;QACL;QACAa,SAAAA,SAAAA,QAAQC,EAAmB;YACzB,IAAI,EAAEf,WAAW,GAAG,OAAOe;YAC3B,IAAI,CAACd,OAAO,MAAM,IAAIU,MAAM;YAE5BP;YACAF,OACGc,aAAa,GACbC,IAAI,CAAC;uBAAMF;eACXG,KAAK,CAACH;YACTb,OAAOiB,OAAO;YACdjB,SAAS;YACTD,QAAQ;YACRmB,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.js';\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"}
|
package/dist/cjs/types.d.cts
CHANGED
package/dist/cjs/types.d.ts
CHANGED
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":";;;;+BAWaA;;;eAAAA;;;AAAN,IAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV"}
|
package/dist/cjs/worker.js
CHANGED
|
@@ -151,7 +151,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
151
151
|
if (stdio === 'inherit') {
|
|
152
152
|
terminal.retain(function(store) {
|
|
153
153
|
var id = _crypto.default.randomUUID();
|
|
154
|
-
store.
|
|
154
|
+
store.addProcess(_object_spread({
|
|
155
155
|
id: id,
|
|
156
156
|
title: [
|
|
157
157
|
command
|
|
@@ -170,14 +170,14 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
170
170
|
var item = store.processes.find(function(x) {
|
|
171
171
|
return x.id === id;
|
|
172
172
|
});
|
|
173
|
-
store.
|
|
173
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
174
174
|
lines: item.lines.concat(lines.map(function(text) {
|
|
175
175
|
return {
|
|
176
176
|
type: _types.LineType.stdout,
|
|
177
177
|
text: text
|
|
178
178
|
};
|
|
179
179
|
}))
|
|
180
|
-
});
|
|
180
|
+
}));
|
|
181
181
|
});
|
|
182
182
|
queue.defer(_onone.default.bind(null, cp.stdout.pipe(outputs.stdout), [
|
|
183
183
|
'error',
|
|
@@ -191,14 +191,14 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
191
191
|
var item = store.processes.find(function(x) {
|
|
192
192
|
return x.id === id;
|
|
193
193
|
});
|
|
194
|
-
store.
|
|
194
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
195
195
|
lines: item.lines.concat(lines.map(function(text) {
|
|
196
196
|
return {
|
|
197
197
|
type: _types.LineType.stderr,
|
|
198
198
|
text: text
|
|
199
199
|
};
|
|
200
200
|
}))
|
|
201
|
-
});
|
|
201
|
+
}));
|
|
202
202
|
});
|
|
203
203
|
queue.defer(_onone.default.bind(null, cp.stderr.pipe(outputs.stderr), [
|
|
204
204
|
'error',
|
|
@@ -219,9 +219,12 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
219
219
|
res.stderr,
|
|
220
220
|
null
|
|
221
221
|
];
|
|
222
|
-
store.
|
|
223
|
-
|
|
222
|
+
var item = store.processes.find(function(x) {
|
|
223
|
+
return x.id === id;
|
|
224
224
|
});
|
|
225
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
226
|
+
state: err ? 'error' : 'success'
|
|
227
|
+
}));
|
|
225
228
|
// ensure rendering completes
|
|
226
229
|
terminal.release(function() {
|
|
227
230
|
err ? callback(err) : callback(null, res);
|
package/dist/cjs/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.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\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((store) => {\n const id = crypto.randomUUID();\n store.
|
|
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.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\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((store) => {\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 const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\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 const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\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, encoding: 'utf8' }));\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 const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\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, encoding: encoding || 'utf8' }));\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":["spawnTerminal","terminal","createApp","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","crypto","randomUUID","addProcess","title","concat","formatArguments","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addLines","item","processes","find","x","updateProcess","map","text","type","LineType","defer","oo","bind","pipe","spawn","worker","await","err","res","output","release","concatWritable","toString"],"mappings":";;;;+BAeA;;;eAAwBA;;;oEAf4B;6DACjC;4DACJ;8DACG;gEAEI;+DACD;qEACM;sEACC;qBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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@@ -1,39 +1,11 @@
|
|
|
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
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
2
|
import { Box } from 'ink';
|
|
31
|
-
import { useProcesses } from '../state/ProcessContext.js';
|
|
32
3
|
import ChildProcess from './ChildProcess.js';
|
|
33
|
-
export default function App() {
|
|
34
|
-
const processes = useProcesses();
|
|
4
|
+
export default function App({ store }) {
|
|
35
5
|
return /*#__PURE__*/ _jsx(Box, {
|
|
36
6
|
flexDirection: "column",
|
|
37
|
-
children: processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess,
|
|
7
|
+
children: store.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, {
|
|
8
|
+
item: item
|
|
9
|
+
}, item.id))
|
|
38
10
|
});
|
|
39
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ChildProcess","App","store","flexDirection","processes","map","item","id"],"mappings":";AAAA,SAASA,GAAG,QAAQ,MAAM;AAE1B,OAAOC,kBAAkB,oBAAoB;AAE7C,eAAe,SAASC,IAAI,EAAEC,KAAK,EAAE;IACnC,qBACE,KAACH;QAAII,eAAc;kBAChBD,MAAME,SAAS,CAACC,GAAG,CAAC,CAACC,qBACpB,KAACN;gBAA2BM,MAAMA;eAAfA,KAAKC,EAAE;;AAIlC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { ChildProcess as ChildProcessT } from '../types.js';
|
|
2
|
-
|
|
2
|
+
type ItemProps = {
|
|
3
|
+
item: ChildProcessT;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("react").NamedExoticComponent<ItemProps>;
|
|
3
6
|
export default _default;
|
|
@@ -104,7 +104,8 @@ const Lines = /*#__PURE__*/ memo(function Lines({ lines }) {
|
|
|
104
104
|
children: lines.map(renderLine)
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
|
-
const Expanded = /*#__PURE__*/ memo(function Expanded(item) {
|
|
107
|
+
const Expanded = /*#__PURE__*/ memo(function Expanded({ item }) {
|
|
108
|
+
const { lines } = item;
|
|
108
109
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
109
110
|
flexDirection: "column",
|
|
110
111
|
children: [
|
|
@@ -114,18 +115,19 @@ const Expanded = /*#__PURE__*/ memo(function Expanded(item) {
|
|
|
114
115
|
state: item.state
|
|
115
116
|
}),
|
|
116
117
|
/*#__PURE__*/ _jsx(Lines, {
|
|
117
|
-
lines:
|
|
118
|
+
lines: lines
|
|
118
119
|
})
|
|
119
120
|
]
|
|
120
121
|
});
|
|
121
122
|
});
|
|
122
|
-
const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
|
|
123
|
+
const Contracted = /*#__PURE__*/ memo(function Contracted({ item }) {
|
|
124
|
+
const { state, lines } = item;
|
|
123
125
|
// remove ansi codes when displaying single lines
|
|
124
|
-
const errors = useMemo(()=>
|
|
125
|
-
|
|
126
|
+
const errors = useMemo(()=>lines.filter((line)=>line.type === LineType.stderr), [
|
|
127
|
+
lines
|
|
126
128
|
]);
|
|
127
|
-
const summary = useMemo(()=>
|
|
128
|
-
|
|
129
|
+
const summary = useMemo(()=>lines.filter((line)=>line.text.length > 0 && errors.indexOf(line) < 0).pop(), [
|
|
130
|
+
lines,
|
|
129
131
|
errors
|
|
130
132
|
]);
|
|
131
133
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
@@ -136,7 +138,7 @@ const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
|
|
|
136
138
|
title: item.title,
|
|
137
139
|
state: item.state
|
|
138
140
|
}),
|
|
139
|
-
|
|
141
|
+
state === 'running' && /*#__PURE__*/ _jsx(RunningSummary, {
|
|
140
142
|
line: summary || BLANK_LINE
|
|
141
143
|
}),
|
|
142
144
|
errors.length > 0 && /*#__PURE__*/ _jsx(Lines, {
|
|
@@ -145,6 +147,11 @@ const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
|
|
|
145
147
|
]
|
|
146
148
|
});
|
|
147
149
|
});
|
|
148
|
-
export default /*#__PURE__*/ memo(function ChildProcess(item) {
|
|
149
|
-
|
|
150
|
+
export default /*#__PURE__*/ memo(function ChildProcess({ item }) {
|
|
151
|
+
const { expanded } = item;
|
|
152
|
+
return expanded ? /*#__PURE__*/ _jsx(Expanded, {
|
|
153
|
+
item: item
|
|
154
|
+
}) : /*#__PURE__*/ _jsx(Contracted, {
|
|
155
|
+
item: item
|
|
156
|
+
});
|
|
150
157
|
});
|