spawn-term 0.1.2 → 0.1.3
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.cjs +54 -36
- package/dist/cjs/components/App.cjs.map +1 -1
- package/dist/cjs/components/ChildProcess.cjs +51 -2
- package/dist/cjs/components/ChildProcess.cjs.map +1 -1
- package/dist/cjs/contexts/Store.cjs +13 -0
- package/dist/cjs/contexts/Store.cjs.map +1 -0
- package/dist/cjs/createApp.cjs +55 -50
- package/dist/cjs/createApp.cjs.map +1 -1
- package/dist/cjs/lib/addLines.cjs +5 -5
- package/dist/cjs/lib/addLines.cjs.map +1 -1
- package/dist/cjs/types.cjs.map +1 -1
- package/dist/cjs/worker.cjs +43 -22
- package/dist/cjs/worker.cjs.map +1 -1
- package/dist/esm/components/App.mjs +16 -38
- package/dist/esm/components/App.mjs.map +1 -1
- package/dist/esm/components/ChildProcess.mjs +8 -2
- package/dist/esm/components/ChildProcess.mjs.map +1 -1
- package/dist/esm/contexts/Store.mjs +2 -0
- package/dist/esm/contexts/Store.mjs.map +1 -0
- package/dist/esm/createApp.mjs +21 -52
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/lib/addLines.mjs +5 -3
- package/dist/esm/lib/addLines.mjs.map +1 -1
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/worker.mjs +34 -23
- package/dist/esm/worker.mjs.map +1 -1
- package/dist/types/components/App.d.ts +1 -5
- package/dist/types/components/ChildProcess.d.ts +2 -6
- package/dist/types/contexts/Store.d.ts +2 -0
- package/dist/types/createApp.d.ts +1 -4
- package/dist/types/lib/addLines.d.ts +1 -1
- package/dist/types/types.d.ts +6 -0
- package/package.json +3 -3
|
@@ -8,50 +8,66 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return App;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var _react = /*#__PURE__*/
|
|
11
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
var _zustand = require("zustand");
|
|
13
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.cjs"));
|
|
12
14
|
var _ink = require("../ink.cjs");
|
|
13
15
|
var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.cjs"));
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
if (key in obj) {
|
|
16
|
-
Object.defineProperty(obj, key, {
|
|
17
|
-
value: value,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
obj[key] = value;
|
|
24
|
-
}
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
16
|
function _interop_require_default(obj) {
|
|
28
17
|
return obj && obj.__esModule ? obj : {
|
|
29
18
|
default: obj
|
|
30
19
|
};
|
|
31
20
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
22
|
+
if (typeof WeakMap !== "function") return null;
|
|
23
|
+
var cacheBabelInterop = new WeakMap();
|
|
24
|
+
var cacheNodeInterop = new WeakMap();
|
|
25
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
26
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
|
+
})(nodeInterop);
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
34
|
+
return {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
39
|
+
if (cache && cache.has(obj)) {
|
|
40
|
+
return cache.get(obj);
|
|
41
|
+
}
|
|
42
|
+
var newObj = {
|
|
43
|
+
__proto__: null
|
|
44
|
+
};
|
|
45
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
|
+
for(var key in obj){
|
|
47
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
48
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
49
|
+
if (desc && (desc.get || desc.set)) {
|
|
50
|
+
Object.defineProperty(newObj, key, desc);
|
|
51
|
+
} else {
|
|
52
|
+
newObj[key] = obj[key];
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
|
-
ownKeys.forEach(function(key) {
|
|
42
|
-
_define_property(target, key, source[key]);
|
|
43
|
-
});
|
|
44
55
|
}
|
|
45
|
-
|
|
56
|
+
newObj.default = obj;
|
|
57
|
+
if (cache) {
|
|
58
|
+
cache.set(obj, newObj);
|
|
59
|
+
}
|
|
60
|
+
return newObj;
|
|
46
61
|
}
|
|
47
|
-
function App(
|
|
48
|
-
var
|
|
49
|
-
var
|
|
62
|
+
function App() {
|
|
63
|
+
var store = (0, _react.useContext)(_Store.default);
|
|
64
|
+
var appState = (0, _zustand.useStore)(store);
|
|
65
|
+
var running = appState.processes.filter(function(x) {
|
|
50
66
|
return [
|
|
51
67
|
'running'
|
|
52
68
|
].indexOf(x.state) >= 0;
|
|
53
69
|
});
|
|
54
|
-
var done =
|
|
70
|
+
var done = appState.processes.filter(function(x) {
|
|
55
71
|
return [
|
|
56
72
|
'error',
|
|
57
73
|
'success'
|
|
@@ -60,9 +76,10 @@ function App(param) {
|
|
|
60
76
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_ink.Box, {
|
|
61
77
|
flexDirection: "column"
|
|
62
78
|
}, running.map(function(item) {
|
|
63
|
-
return /*#__PURE__*/ _react.default.createElement(_ChildProcess.default,
|
|
64
|
-
key: item.id
|
|
65
|
-
|
|
79
|
+
return /*#__PURE__*/ _react.default.createElement(_ChildProcess.default, {
|
|
80
|
+
key: item.id,
|
|
81
|
+
id: item.id
|
|
82
|
+
});
|
|
66
83
|
})), /*#__PURE__*/ _react.default.createElement(_ink.Box, {
|
|
67
84
|
flexDirection: "column",
|
|
68
85
|
borderStyle: "single",
|
|
@@ -74,9 +91,10 @@ function App(param) {
|
|
|
74
91
|
}), /*#__PURE__*/ _react.default.createElement(_ink.Box, {
|
|
75
92
|
flexDirection: "column"
|
|
76
93
|
}, done.map(function(item) {
|
|
77
|
-
return /*#__PURE__*/ _react.default.createElement(_ChildProcess.default,
|
|
78
|
-
key: item.id
|
|
79
|
-
|
|
94
|
+
return /*#__PURE__*/ _react.default.createElement(_ChildProcess.default, {
|
|
95
|
+
key: item.id,
|
|
96
|
+
id: item.id
|
|
97
|
+
});
|
|
80
98
|
})));
|
|
81
99
|
}
|
|
82
100
|
/* 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/App.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '../ink.mjs';\nimport type { ChildProcess as ChildProcessT } from '../types';\nimport ChildProcess from './ChildProcess';\n\nexport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box } from '../ink.mjs';\nimport type { AppState, ChildProcess as ChildProcessT } from '../types';\nimport ChildProcess from './ChildProcess';\n\nexport default function App() {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const running = appState.processes.filter((x) => ['running'].indexOf(x.state) >= 0);\n const done = appState.processes.filter((x) => ['error', 'success'].indexOf(x.state) >= 0);\n\n return (\n <>\n <Box flexDirection=\"column\">\n {running.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} id={item.id} />\n ))}\n </Box>\n <Box flexDirection=\"column\" borderStyle=\"single\" borderColor=\"black\" borderBottom={true} borderTop={false} borderLeft={false} borderRight={false} />\n <Box flexDirection=\"column\">\n {done.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} id={item.id} />\n ))}\n </Box>\n </>\n );\n}\n"],"names":["App","store","useContext","StoreContext","appState","useStore","running","processes","filter","x","indexOf","state","done","Box","flexDirection","map","item","ChildProcess","key","id","borderStyle","borderColor","borderBottom","borderTop","borderLeft","borderRight"],"mappings":";;;;+BAOA;;;eAAwBA;;;6DAPU;uBACT;4DACA;mBACL;mEAEK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,SAASA;IACtB,IAAMC,QAAQC,IAAAA,iBAAU,EAACC,cAAY;IACrC,IAAMC,WAAWC,IAAAA,iBAAQ,EAACJ;IAC1B,IAAMK,UAAUF,SAASG,SAAS,CAACC,MAAM,CAAC,SAACC;eAAM;YAAC;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;;IACjF,IAAMC,OAAOR,SAASG,SAAS,CAACC,MAAM,CAAC,SAACC;eAAM;YAAC;YAAS;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;;IAEvF,qBACE,0EACE,6BAACE,QAAG;QAACC,eAAc;OAChBR,QAAQS,GAAG,CAAC,SAACC;6BACZ,6BAACC,qBAAY;YAACC,KAAKF,KAAKG,EAAE;YAAEA,IAAIH,KAAKG,EAAE;;uBAG3C,6BAACN,QAAG;QAACC,eAAc;QAASM,aAAY;QAASC,aAAY;QAAQC,cAAc;QAAMC,WAAW;QAAOC,YAAY;QAAOC,aAAa;sBAC3I,6BAACZ,QAAG;QAACC,eAAc;OAChBF,KAAKG,GAAG,CAAC,SAACC;6BACT,6BAACC,qBAAY;YAACC,KAAKF,KAAKG,EAAE;YAAEA,IAAIH,KAAKG,EAAE;;;AAKjD"}
|
|
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return ChildProcess;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var _react = /*#__PURE__*/
|
|
11
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
var _zustand = require("zustand");
|
|
13
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.cjs"));
|
|
12
14
|
var _ink = require("../ink.cjs");
|
|
13
15
|
var _figures = /*#__PURE__*/ _interop_require_default(require("../lib/figures.cjs"));
|
|
14
16
|
var _Spinner = /*#__PURE__*/ _interop_require_default(require("./Spinner.cjs"));
|
|
@@ -18,6 +20,47 @@ function _interop_require_default(obj) {
|
|
|
18
20
|
default: obj
|
|
19
21
|
};
|
|
20
22
|
}
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
24
|
+
if (typeof WeakMap !== "function") return null;
|
|
25
|
+
var cacheBabelInterop = new WeakMap();
|
|
26
|
+
var cacheNodeInterop = new WeakMap();
|
|
27
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
28
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
29
|
+
})(nodeInterop);
|
|
30
|
+
}
|
|
31
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
32
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
36
|
+
return {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
41
|
+
if (cache && cache.has(obj)) {
|
|
42
|
+
return cache.get(obj);
|
|
43
|
+
}
|
|
44
|
+
var newObj = {
|
|
45
|
+
__proto__: null
|
|
46
|
+
};
|
|
47
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
|
+
for(var key in obj){
|
|
49
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
50
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
51
|
+
if (desc && (desc.get || desc.set)) {
|
|
52
|
+
Object.defineProperty(newObj, key, desc);
|
|
53
|
+
} else {
|
|
54
|
+
newObj[key] = obj[key];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
newObj.default = obj;
|
|
59
|
+
if (cache) {
|
|
60
|
+
cache.set(obj, newObj);
|
|
61
|
+
}
|
|
62
|
+
return newObj;
|
|
63
|
+
}
|
|
21
64
|
// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2
|
|
22
65
|
var spinner = {
|
|
23
66
|
interval: 80,
|
|
@@ -52,7 +95,13 @@ var POINTERS = {
|
|
|
52
95
|
}, _figures.default.pointer)
|
|
53
96
|
};
|
|
54
97
|
function ChildProcess(param) {
|
|
55
|
-
var
|
|
98
|
+
var id = param.id;
|
|
99
|
+
var store = (0, _react.useContext)(_Store.default);
|
|
100
|
+
var appState = (0, _zustand.useStore)(store);
|
|
101
|
+
var item = appState.processes.find(function(x) {
|
|
102
|
+
return x.id === id;
|
|
103
|
+
});
|
|
104
|
+
var title = item.title, state = item.state, lines = item.lines, isExpanded = item.isExpanded;
|
|
56
105
|
var icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];
|
|
57
106
|
var output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;
|
|
58
107
|
var errors = state !== 'running' ? lines.filter(function(line) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Text } from '../ink.mjs';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box, Text } from '../ink.mjs';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { AppState } from '../types';\nimport { LineType } from '../types';\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\nconst POINTERS = {\n error: <Text color=\"red\">{figures.pointer}</Text>,\n default: <Text color=\"yellow\">{figures.pointer}</Text>,\n};\n\ntype ChildProcessProps = {\n id: string;\n};\n\nexport default function ChildProcess({ id }: ChildProcessProps) {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const item = appState.processes.find((x) => x.id === id);\n const { title, state, lines, isExpanded } = item;\n\n const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];\n const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;\n const errors = state !== 'running' ? lines.filter((line) => line.type === LineType.stderr) : [];\n\n return (\n <Box flexDirection=\"column\">\n <Box>\n <Box marginRight={1}>\n <Text>{icon}</Text>\n </Box>\n <Text>{title}</Text>\n </Box>\n {output ? (\n <Box marginLeft={2}>\n <Text color=\"gray\">{`${figures.arrowRight} ${output.text}`}</Text>\n </Box>\n ) : undefined}\n {errors.length > 0 && (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text>{line.text}</Text>\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n}\n"],"names":["ChildProcess","spinner","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","POINTERS","pointer","default","id","store","useContext","StoreContext","appState","useStore","item","processes","find","x","title","state","lines","isExpanded","icon","output","length","undefined","errors","filter","line","type","LineType","stderr","Box","flexDirection","marginRight","marginLeft","arrowRight","text","map","index","key","height"],"mappings":";;;;+BA+BA;;;eAAwBA;;;6DA/BU;uBACT;4DACA;mBACC;8DACN;8DACA;qBAGK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,oHAAoH;AACpH,IAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,IAAMC,QAAQ;IACZC,qBAAO,6BAACC,SAAI;QAACC,OAAM;OAAOC,gBAAO,CAACC,KAAK;IACvCC,uBAAS,6BAACJ,SAAI;QAACC,OAAM;OAASC,gBAAO,CAACG,IAAI;IAC1CC,uBAAS,6BAACC,gBAAO,EAAKZ;AACxB;AAEA,IAAMa,WAAW;IACfT,qBAAO,6BAACC,SAAI;QAACC,OAAM;OAAOC,gBAAO,CAACO,OAAO;IACzCC,uBAAS,6BAACV,SAAI;QAACC,OAAM;OAAUC,gBAAO,CAACO,OAAO;AAChD;AAMe,SAASf,aAAa,KAAyB;QAAzB,AAAEiB,KAAF,MAAEA;IACrC,IAAMC,QAAQC,IAAAA,iBAAU,EAACC,cAAY;IACrC,IAAMC,WAAWC,IAAAA,iBAAQ,EAACJ;IAC1B,IAAMK,OAAOF,SAASG,SAAS,CAACC,IAAI,CAAC,SAACC;eAAMA,EAAET,EAAE,KAAKA;;IACrD,IAAQU,QAAoCJ,KAApCI,OAAOC,QAA6BL,KAA7BK,OAAOC,QAAsBN,KAAtBM,OAAOC,aAAeP,KAAfO;IAE7B,IAAMC,OAAOD,aAAahB,QAAQ,CAACc,MAAM,IAAId,SAASE,OAAO,GAAGZ,KAAK,CAACwB,MAAM;IAC5E,IAAMI,SAASJ,UAAU,aAAaC,MAAMI,MAAM,GAAGJ,KAAK,CAACA,MAAMI,MAAM,GAAG,EAAE,GAAGC;IAC/E,IAAMC,SAASP,UAAU,YAAYC,MAAMO,MAAM,CAAC,SAACC;eAASA,KAAKC,IAAI,KAAKC,eAAQ,CAACC,MAAM;SAAI,EAAE;IAE/F,qBACE,6BAACC,QAAG;QAACC,eAAc;qBACjB,6BAACD,QAAG,sBACF,6BAACA,QAAG;QAACE,aAAa;qBAChB,6BAACrC,SAAI,QAAEyB,sBAET,6BAACzB,SAAI,QAAEqB,SAERK,uBACC,6BAACS,QAAG;QAACG,YAAY;qBACf,6BAACtC,SAAI;QAACC,OAAM;OAAQ,AAAC,GAAwByB,OAAtBxB,gBAAO,CAACqC,UAAU,EAAC,KAAe,OAAZb,OAAOc,IAAI,MAExDZ,WACHC,OAAOF,MAAM,GAAG,mBACf,6BAACQ,QAAG;QAACC,eAAc;QAASE,YAAY;OACrCf,MAAMkB,GAAG,CAAC,SAACV,MAAMW;eAChB,8DAA8D;sBAC9D,6BAACP,QAAG;YAACQ,KAAKD;YAAON,eAAc;YAASQ,QAAQ;yBAC9C,6BAAC5C,SAAI,QAAE+B,KAAKS,IAAI;;AAO9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _default = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
13
|
+
/* 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/contexts/Store.tsx"],"sourcesContent":["import { createContext } from 'react';\nexport default createContext(undefined);\n"],"names":["createContext","undefined"],"mappings":";;;;+BACA;;;eAAA;;;qBAD8B;IAC9B,yBAAeA,IAAAA,oBAAa,EAACC"}
|
package/dist/cjs/createApp.cjs
CHANGED
|
@@ -8,80 +8,85 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createApp;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var _liluuid = /*#__PURE__*/ _interop_require_default(require("lil-uuid"));
|
|
12
11
|
var _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
|
+
var _zustand = require("zustand");
|
|
13
13
|
var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.cjs"));
|
|
14
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("./contexts/Store.cjs"));
|
|
14
15
|
var _ink = require("./ink.cjs");
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
obj[key] = value;
|
|
25
|
-
}
|
|
26
|
-
return obj;
|
|
16
|
+
function _array_like_to_array(arr, len) {
|
|
17
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
18
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
19
|
+
return arr2;
|
|
20
|
+
}
|
|
21
|
+
function _array_without_holes(arr) {
|
|
22
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
27
23
|
}
|
|
28
24
|
function _interop_require_default(obj) {
|
|
29
25
|
return obj && obj.__esModule ? obj : {
|
|
30
26
|
default: obj
|
|
31
27
|
};
|
|
32
28
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
function _iterable_to_array(iter) {
|
|
30
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
31
|
+
}
|
|
32
|
+
function _non_iterable_spread() {
|
|
33
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
34
|
+
}
|
|
35
|
+
function _to_consumable_array(arr) {
|
|
36
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
37
|
+
}
|
|
38
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
39
|
+
if (!o) return;
|
|
40
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
41
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
42
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
43
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
44
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
45
|
}
|
|
48
46
|
function createApp() {
|
|
49
47
|
var refCount = 0;
|
|
50
|
-
var
|
|
48
|
+
var store = null;
|
|
51
49
|
var inkApp = null;
|
|
52
50
|
return {
|
|
53
|
-
addItem: function addItem(data) {
|
|
54
|
-
if (!list) throw new Error('Expecting list');
|
|
55
|
-
var item = _object_spread({
|
|
56
|
-
id: (0, _liluuid.default)(),
|
|
57
|
-
title: '',
|
|
58
|
-
state: 'pending',
|
|
59
|
-
lines: []
|
|
60
|
-
}, data);
|
|
61
|
-
list.push(item);
|
|
62
|
-
return item;
|
|
63
|
-
},
|
|
64
|
-
rerender: function rerender() {
|
|
65
|
-
if (inkApp) inkApp.rerender(/*#__PURE__*/ _react.default.createElement(_App.default, {
|
|
66
|
-
list: list
|
|
67
|
-
}));
|
|
68
|
-
},
|
|
69
51
|
retain: function retain() {
|
|
70
|
-
if (++refCount > 1) return;
|
|
52
|
+
if (++refCount > 1) return store;
|
|
71
53
|
if (inkApp) throw new Error('Not expecting app');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
store = (0, _zustand.createStore)()(function(set) {
|
|
55
|
+
return {
|
|
56
|
+
processes: [],
|
|
57
|
+
addProcess: function(process1) {
|
|
58
|
+
return set(function(state) {
|
|
59
|
+
return {
|
|
60
|
+
processes: _to_consumable_array(state.processes).concat([
|
|
61
|
+
process1
|
|
62
|
+
])
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
updateProcess: function(process1) {
|
|
67
|
+
return set(function(state) {
|
|
68
|
+
return {
|
|
69
|
+
processes: state.processes.map(function(x) {
|
|
70
|
+
return x.id === process1.id ? process1 : x;
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
inkApp = (0, _ink.render)(/*#__PURE__*/ _react.default.createElement(_Store.default.Provider, {
|
|
78
|
+
value: store
|
|
79
|
+
}, /*#__PURE__*/ _react.default.createElement(_App.default, null)), {
|
|
76
80
|
patchConsole: false
|
|
77
81
|
});
|
|
82
|
+
return store;
|
|
78
83
|
},
|
|
79
84
|
release: function release() {
|
|
80
85
|
if (--refCount > 0) return;
|
|
81
86
|
if (!inkApp) throw new Error('Expecting app');
|
|
82
87
|
inkApp.unmount();
|
|
83
88
|
inkApp = null;
|
|
84
|
-
|
|
89
|
+
store = null;
|
|
85
90
|
process.stdout.write('\x1b[?25h'); // show cursor
|
|
86
91
|
}
|
|
87
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import React from 'react';\nimport { createStore } from 'zustand';\nimport App from './components/App';\nimport StoreContext from './contexts/Store';\n\n// @ts-ignore\nimport { type Instance, render } from './ink.mjs';\nimport type { AppState } from './types';\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n return {\n retain() {\n if (++refCount > 1) return store;\n if (inkApp) throw new Error('Not expecting app');\n store = createStore<AppState>()((set) => ({\n processes: [],\n addProcess: (process) => set((state) => ({ processes: [...state.processes, process] })),\n updateProcess: (process) => set((state) => ({ processes: state.processes.map((x) => (x.id === process.id ? process : x)) })),\n }));\n inkApp = render(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>,\n { patchConsole: false }\n );\n return store;\n },\n release() {\n if (--refCount > 0) return;\n if (!inkApp) throw new Error('Expecting app');\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","refCount","store","inkApp","retain","Error","createStore","set","processes","addProcess","process","state","updateProcess","map","x","id","render","StoreContext","Provider","value","App","patchConsole","release","unmount","stdout","write"],"mappings":";;;;+BASA;;;eAAwBA;;;4DATN;uBACU;0DACZ;4DACS;mBAGa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvB,SAASA;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC,QAAAA,SAAAA;YACE,IAAI,EAAEH,WAAW,GAAG,OAAOC;YAC3B,IAAIC,QAAQ,MAAM,IAAIE,MAAM;YAC5BH,QAAQI,IAAAA,oBAAW,IAAa,SAACC;uBAAS;oBACxCC,WAAW,EAAE;oBACbC,YAAY,SAACC;+BAAYH,IAAI,SAACI;mCAAW;gCAAEH,WAAW,AAAC,qBAAGG,MAAMH,SAAS,SAAnB;oCAAqBE;iCAAQ;4BAAC;;;oBACpFE,eAAe,SAACF;+BAAYH,IAAI,SAACI;mCAAW;gCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,SAACC;2CAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;;4BAAI;;;gBAC3H;;YACAX,SAASa,IAAAA,WAAM,gBACb,6BAACC,cAAY,CAACC,QAAQ;gBAACC,OAAOjB;6BAC5B,6BAACkB,YAAG,UAEN;gBAAEC,cAAc;YAAM;YAExB,OAAOnB;QACT;QACAoB,SAAAA,SAAAA;YACE,IAAI,EAAErB,WAAW,GAAG;YACpB,IAAI,CAACE,QAAQ,MAAM,IAAIE,MAAM;YAC7BF,OAAOoB,OAAO;YACdpB,SAAS;YACTD,QAAQ;YACRQ,QAAQc,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -10,21 +10,21 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _readablestream = require("readable-stream");
|
|
12
12
|
var regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
|
|
13
|
-
function addLines(
|
|
13
|
+
function addLines(fn) {
|
|
14
14
|
var last = '';
|
|
15
15
|
var stream = new _readablestream.Writable({
|
|
16
16
|
write: function write(chunk, _enc, callback) {
|
|
17
17
|
var more = last + chunk.toString('utf8');
|
|
18
18
|
var lines = more.split(regEx);
|
|
19
19
|
last = lines.pop();
|
|
20
|
-
lines.
|
|
21
|
-
return addLine(line);
|
|
22
|
-
});
|
|
20
|
+
if (lines.length) fn(lines);
|
|
23
21
|
callback();
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
stream.on('finish', function() {
|
|
27
|
-
if (last.length)
|
|
25
|
+
if (last.length) fn([
|
|
26
|
+
last
|
|
27
|
+
]);
|
|
28
28
|
last = '';
|
|
29
29
|
});
|
|
30
30
|
return stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(regEx);\n last = lines.pop();\n if (lines.length) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["addLines","regEx","fn","last","stream","Writable","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":";;;;+BAIA;;;eAAwBA;;;8BAJC;AAEzB,IAAMC,QAAQ;AAEC,SAASD,SAASE,EAAE;IACjC,IAAIC,OAAO;IAEX,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,IAAMC,OAAOP,OAAOI,MAAMI,QAAQ,CAAC;YACnC,IAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBE,OAAOS,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,EAAEb,GAAGU;YACrBH;QACF;IACF;IACAL,OAAOY,EAAE,CAAC,UAAU;QAClB,IAAIb,KAAKY,MAAM,EAAEb,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
|
package/dist/cjs/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n};\n"],"names":["LineType"],"mappings":"AAAA,aAAa;;;;;+BAODA;;;eAAAA;;;AAAL,IAAA,AAAKA,kCAAAA;;;WAAAA"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n isExpanded: boolean;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["LineType"],"mappings":"AAAA,aAAa;;;;;+BAODA;;;eAAAA;;;AAAL,IAAA,AAAKA,kCAAAA;;;WAAAA"}
|
package/dist/cjs/worker.cjs
CHANGED
|
@@ -3,20 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports,
|
|
6
|
+
Object.defineProperty(exports, // import throttle from 'lodash.throttle';
|
|
7
|
+
// const THROTTLE = 100;
|
|
8
|
+
// const rerender = throttle(() => {
|
|
9
|
+
// terminal.rerender();
|
|
10
|
+
// }, THROTTLE);
|
|
11
|
+
"default", {
|
|
7
12
|
enumerable: true,
|
|
8
13
|
get: function() {
|
|
9
14
|
return spawnTerminal;
|
|
10
15
|
}
|
|
11
16
|
});
|
|
12
17
|
var _crossspawncb = /*#__PURE__*/ _interop_require_wildcard(require("cross-spawn-cb"));
|
|
18
|
+
var _liluuid = /*#__PURE__*/ _interop_require_default(require("lil-uuid"));
|
|
13
19
|
var _onone = /*#__PURE__*/ _interop_require_default(require("on-one"));
|
|
14
20
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
15
21
|
var _createApp = /*#__PURE__*/ _interop_require_default(require("./createApp.cjs"));
|
|
16
22
|
var _addLines = /*#__PURE__*/ _interop_require_default(require("./lib/addLines.cjs"));
|
|
17
23
|
var _concatWritable = /*#__PURE__*/ _interop_require_default(require("./lib/concatWritable.cjs"));
|
|
18
24
|
var _types = require("./types.cjs");
|
|
19
|
-
var _lodashthrottle = /*#__PURE__*/ _interop_require_default(require("lodash.throttle"));
|
|
20
25
|
function _define_property(obj, key, value) {
|
|
21
26
|
if (key in obj) {
|
|
22
27
|
Object.defineProperty(obj, key, {
|
|
@@ -143,23 +148,21 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
143
148
|
return target;
|
|
144
149
|
}
|
|
145
150
|
var terminal = (0, _createApp.default)();
|
|
146
|
-
var THROTTLE = 100;
|
|
147
|
-
var rerender = (0, _lodashthrottle.default)(function() {
|
|
148
|
-
terminal.rerender();
|
|
149
|
-
}, THROTTLE);
|
|
150
151
|
function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
151
152
|
var encoding = spawnOptions.encoding, stdio = spawnOptions.stdio, csOptions = _object_without_properties(spawnOptions, [
|
|
152
153
|
"encoding",
|
|
153
154
|
"stdio"
|
|
154
155
|
]);
|
|
155
|
-
terminal.retain();
|
|
156
|
-
var
|
|
156
|
+
var store = terminal.retain();
|
|
157
|
+
var id = (0, _liluuid.default)();
|
|
158
|
+
store.getState().addProcess({
|
|
159
|
+
id: id,
|
|
157
160
|
title: [
|
|
158
161
|
command
|
|
159
162
|
].concat(args).join(' '),
|
|
160
|
-
state: 'running'
|
|
163
|
+
state: 'running',
|
|
164
|
+
lines: []
|
|
161
165
|
});
|
|
162
|
-
terminal.rerender();
|
|
163
166
|
var cp = (0, _crossspawncb.crossSpawn)(command, args, csOptions);
|
|
164
167
|
var outputs = {
|
|
165
168
|
stdout: null,
|
|
@@ -172,12 +175,19 @@ function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
|
172
175
|
var queue = new _queuecb.default();
|
|
173
176
|
if (cp.stdout) {
|
|
174
177
|
if (stdio === 'inherit') {
|
|
175
|
-
outputs.stdout = (0, _addLines.default)(function(
|
|
176
|
-
item.
|
|
177
|
-
|
|
178
|
-
text: text
|
|
178
|
+
outputs.stdout = (0, _addLines.default)(function(texts) {
|
|
179
|
+
var item = store.getState().processes.find(function(x) {
|
|
180
|
+
return x.id === id;
|
|
179
181
|
});
|
|
180
|
-
|
|
182
|
+
var lines = item.lines.concat(texts.map(function(text) {
|
|
183
|
+
return {
|
|
184
|
+
type: _types.LineType.stdout,
|
|
185
|
+
text: text
|
|
186
|
+
};
|
|
187
|
+
}));
|
|
188
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
189
|
+
lines: lines
|
|
190
|
+
}));
|
|
181
191
|
});
|
|
182
192
|
} else {
|
|
183
193
|
outputs.stdout = (0, _concatWritable.default)(function(output) {
|
|
@@ -193,12 +203,19 @@ function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
|
193
203
|
}
|
|
194
204
|
if (cp.stderr) {
|
|
195
205
|
if (stdio === 'inherit') {
|
|
196
|
-
outputs.stderr = (0, _addLines.default)(function(
|
|
197
|
-
item.
|
|
198
|
-
|
|
199
|
-
text: text
|
|
206
|
+
outputs.stderr = (0, _addLines.default)(function(texts) {
|
|
207
|
+
var item = store.getState().processes.find(function(x) {
|
|
208
|
+
return x.id === id;
|
|
200
209
|
});
|
|
201
|
-
|
|
210
|
+
var lines = item.lines.concat(texts.map(function(text) {
|
|
211
|
+
return {
|
|
212
|
+
type: _types.LineType.stderr,
|
|
213
|
+
text: text
|
|
214
|
+
};
|
|
215
|
+
}));
|
|
216
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
217
|
+
lines: lines
|
|
218
|
+
}));
|
|
202
219
|
});
|
|
203
220
|
} else {
|
|
204
221
|
outputs.stderr = (0, _concatWritable.default)(function(output) {
|
|
@@ -228,8 +245,12 @@ function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
|
228
245
|
res.stderr,
|
|
229
246
|
null
|
|
230
247
|
];
|
|
231
|
-
item
|
|
232
|
-
|
|
248
|
+
var item = store.getState().processes.find(function(x) {
|
|
249
|
+
return x.id === id;
|
|
250
|
+
});
|
|
251
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
252
|
+
state: err ? 'error' : 'success'
|
|
253
|
+
}));
|
|
233
254
|
terminal.release();
|
|
234
255
|
err ? callback(err) : callback(null, res);
|
|
235
256
|
});
|
package/dist/cjs/worker.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp';\nimport addLines from './lib/addLines';\nimport concatWritable from './lib/concatWritable';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport uuid from 'lil-uuid';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp';\nimport addLines from './lib/addLines';\nimport concatWritable from './lib/concatWritable';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\n// import throttle from 'lodash.throttle';\n// const THROTTLE = 100;\n// const rerender = throttle(() => {\n// terminal.rerender();\n// }, THROTTLE);\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, _options: TerminalOptions, callback) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n const store = terminal.retain();\n const id = uuid();\n store.getState().addProcess({ id, title: [command].concat(args).join(' '), state: 'running', lines: [] });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') {\n outputs.stdout = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stdout, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n } else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n }\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n if (stdio === 'inherit') {\n outputs.stderr = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stderr, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n } else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\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, encoding: 'utf8' }));\n queue.await((err) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\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.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, state: err ? 'error' : 'success' });\n terminal.release();\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawnTerminal","terminal","createApp","command","args","spawnOptions","_options","callback","encoding","stdio","csOptions","store","retain","id","uuid","getState","addProcess","title","concat","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","Queue","addLines","texts","item","processes","find","x","map","text","type","LineType","updateProcess","concatWritable","output","toString","defer","oo","bind","pipe","spawn","worker","await","err","res","release"],"mappings":"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"}
|
|
@@ -1,47 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { useStore } from 'zustand';
|
|
3
|
+
import StoreContext from '../contexts/Store.mjs';
|
|
30
4
|
import { Box } from '../ink.mjs';
|
|
31
5
|
import ChildProcess from './ChildProcess.mjs';
|
|
32
|
-
export default function App(
|
|
33
|
-
const
|
|
6
|
+
export default function App() {
|
|
7
|
+
const store = useContext(StoreContext);
|
|
8
|
+
const appState = useStore(store);
|
|
9
|
+
const running = appState.processes.filter((x)=>[
|
|
34
10
|
'running'
|
|
35
11
|
].indexOf(x.state) >= 0);
|
|
36
|
-
const done =
|
|
12
|
+
const done = appState.processes.filter((x)=>[
|
|
37
13
|
'error',
|
|
38
14
|
'success'
|
|
39
15
|
].indexOf(x.state) >= 0);
|
|
40
16
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Box, {
|
|
41
17
|
flexDirection: "column"
|
|
42
|
-
}, running.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess,
|
|
43
|
-
key: item.id
|
|
44
|
-
|
|
18
|
+
}, running.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, {
|
|
19
|
+
key: item.id,
|
|
20
|
+
id: item.id
|
|
21
|
+
}))), /*#__PURE__*/ React.createElement(Box, {
|
|
45
22
|
flexDirection: "column",
|
|
46
23
|
borderStyle: "single",
|
|
47
24
|
borderColor: "black",
|
|
@@ -51,7 +28,8 @@ export default function App({ list }) {
|
|
|
51
28
|
borderRight: false
|
|
52
29
|
}), /*#__PURE__*/ React.createElement(Box, {
|
|
53
30
|
flexDirection: "column"
|
|
54
|
-
}, done.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess,
|
|
55
|
-
key: item.id
|
|
56
|
-
|
|
31
|
+
}, done.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, {
|
|
32
|
+
key: item.id,
|
|
33
|
+
id: item.id
|
|
34
|
+
}))));
|
|
57
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '../ink.mjs';\nimport type { ChildProcess as ChildProcessT } from '../types';\nimport ChildProcess from './ChildProcess';\n\nexport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box } from '../ink.mjs';\nimport type { AppState, ChildProcess as ChildProcessT } from '../types';\nimport ChildProcess from './ChildProcess';\n\nexport default function App() {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const running = appState.processes.filter((x) => ['running'].indexOf(x.state) >= 0);\n const done = appState.processes.filter((x) => ['error', 'success'].indexOf(x.state) >= 0);\n\n return (\n <>\n <Box flexDirection=\"column\">\n {running.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} id={item.id} />\n ))}\n </Box>\n <Box flexDirection=\"column\" borderStyle=\"single\" borderColor=\"black\" borderBottom={true} borderTop={false} borderLeft={false} borderRight={false} />\n <Box flexDirection=\"column\">\n {done.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} id={item.id} />\n ))}\n </Box>\n </>\n );\n}\n"],"names":["React","useContext","useStore","StoreContext","Box","ChildProcess","App","store","appState","running","processes","filter","x","indexOf","state","done","flexDirection","map","item","key","id","borderStyle","borderColor","borderBottom","borderTop","borderLeft","borderRight"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAAQ,QAAQ;AAC1C,SAASC,QAAQ,QAAQ,UAAU;AACnC,OAAOC,kBAAkB,oBAAoB;AAC7C,SAASC,GAAG,QAAQ,aAAa;AAEjC,OAAOC,kBAAkB,iBAAiB;AAE1C,eAAe,SAASC;IACtB,MAAMC,QAAQN,WAAWE;IACzB,MAAMK,WAAWN,SAASK;IAC1B,MAAME,UAAUD,SAASE,SAAS,CAACC,MAAM,CAAC,CAACC,IAAM;YAAC;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IACjF,MAAMC,OAAOP,SAASE,SAAS,CAACC,MAAM,CAAC,CAACC,IAAM;YAAC;YAAS;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IAEvF,qBACE,wDACE,oBAACV;QAAIY,eAAc;OAChBP,QAAQQ,GAAG,CAAC,CAACC,qBACZ,oBAACb;YAAac,KAAKD,KAAKE,EAAE;YAAEA,IAAIF,KAAKE,EAAE;4BAG3C,oBAAChB;QAAIY,eAAc;QAASK,aAAY;QAASC,aAAY;QAAQC,cAAc;QAAMC,WAAW;QAAOC,YAAY;QAAOC,aAAa;sBAC3I,oBAACtB;QAAIY,eAAc;OAChBD,KAAKE,GAAG,CAAC,CAACC,qBACT,oBAACb;YAAac,KAAKD,KAAKE,EAAE;YAAEA,IAAIF,KAAKE,EAAE;;AAKjD"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { useStore } from 'zustand';
|
|
3
|
+
import StoreContext from '../contexts/Store.mjs';
|
|
2
4
|
import { Box, Text } from '../ink.mjs';
|
|
3
5
|
import figures from '../lib/figures.mjs';
|
|
4
6
|
import Spinner from './Spinner.mjs';
|
|
@@ -36,7 +38,11 @@ const POINTERS = {
|
|
|
36
38
|
color: "yellow"
|
|
37
39
|
}, figures.pointer)
|
|
38
40
|
};
|
|
39
|
-
export default function ChildProcess({
|
|
41
|
+
export default function ChildProcess({ id }) {
|
|
42
|
+
const store = useContext(StoreContext);
|
|
43
|
+
const appState = useStore(store);
|
|
44
|
+
const item = appState.processes.find((x)=>x.id === id);
|
|
45
|
+
const { title, state, lines, isExpanded } = item;
|
|
40
46
|
const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];
|
|
41
47
|
const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;
|
|
42
48
|
const errors = state !== 'running' ? lines.filter((line)=>line.type === LineType.stderr) : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Text } from '../ink.mjs';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box, Text } from '../ink.mjs';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { AppState } from '../types';\nimport { LineType } from '../types';\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\nconst POINTERS = {\n error: <Text color=\"red\">{figures.pointer}</Text>,\n default: <Text color=\"yellow\">{figures.pointer}</Text>,\n};\n\ntype ChildProcessProps = {\n id: string;\n};\n\nexport default function ChildProcess({ id }: ChildProcessProps) {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const item = appState.processes.find((x) => x.id === id);\n const { title, state, lines, isExpanded } = item;\n\n const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];\n const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;\n const errors = state !== 'running' ? lines.filter((line) => line.type === LineType.stderr) : [];\n\n return (\n <Box flexDirection=\"column\">\n <Box>\n <Box marginRight={1}>\n <Text>{icon}</Text>\n </Box>\n <Text>{title}</Text>\n </Box>\n {output ? (\n <Box marginLeft={2}>\n <Text color=\"gray\">{`${figures.arrowRight} ${output.text}`}</Text>\n </Box>\n ) : undefined}\n {errors.length > 0 && (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text>{line.text}</Text>\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n}\n"],"names":["React","useContext","useStore","StoreContext","Box","Text","figures","Spinner","LineType","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","POINTERS","pointer","default","ChildProcess","id","store","appState","item","processes","find","x","title","state","lines","isExpanded","icon","output","length","undefined","errors","filter","line","type","stderr","flexDirection","marginRight","marginLeft","arrowRight","text","map","index","key","height"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAAQ,QAAQ;AAC1C,SAASC,QAAQ,QAAQ,UAAU;AACnC,OAAOC,kBAAkB,oBAAoB;AAC7C,SAASC,GAAG,EAAEC,IAAI,QAAQ,aAAa;AACvC,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,aAAa,YAAY;AAGhC,SAASC,QAAQ,QAAQ,WAAW;AAEpC,oHAAoH;AACpH,MAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,MAAMC,QAAQ;IACZC,qBAAO,oBAACR;QAAKS,OAAM;OAAOR,QAAQS,KAAK;IACvCC,uBAAS,oBAACX;QAAKS,OAAM;OAASR,QAAQW,IAAI;IAC1CC,uBAAS,oBAACX,SAAYE;AACxB;AAEA,MAAMU,WAAW;IACfN,qBAAO,oBAACR;QAAKS,OAAM;OAAOR,QAAQc,OAAO;IACzCC,uBAAS,oBAAChB;QAAKS,OAAM;OAAUR,QAAQc,OAAO;AAChD;AAMA,eAAe,SAASE,aAAa,EAAEC,EAAE,EAAqB;IAC5D,MAAMC,QAAQvB,WAAWE;IACzB,MAAMsB,WAAWvB,SAASsB;IAC1B,MAAME,OAAOD,SAASE,SAAS,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEN,EAAE,KAAKA;IACrD,MAAM,EAAEO,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGP;IAE5C,MAAMQ,OAAOD,aAAad,QAAQ,CAACY,MAAM,IAAIZ,SAASE,OAAO,GAAGT,KAAK,CAACmB,MAAM;IAC5E,MAAMI,SAASJ,UAAU,aAAaC,MAAMI,MAAM,GAAGJ,KAAK,CAACA,MAAMI,MAAM,GAAG,EAAE,GAAGC;IAC/E,MAAMC,SAASP,UAAU,YAAYC,MAAMO,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAKjC,SAASkC,MAAM,IAAI,EAAE;IAE/F,qBACE,oBAACtC;QAAIuC,eAAc;qBACjB,oBAACvC,yBACC,oBAACA;QAAIwC,aAAa;qBAChB,oBAACvC,YAAM6B,sBAET,oBAAC7B,YAAMyB,SAERK,uBACC,oBAAC/B;QAAIyC,YAAY;qBACf,oBAACxC;QAAKS,OAAM;OAAQ,GAAGR,QAAQwC,UAAU,CAAC,CAAC,EAAEX,OAAOY,IAAI,EAAE,KAE1DV,WACHC,OAAOF,MAAM,GAAG,mBACf,oBAAChC;QAAIuC,eAAc;QAASE,YAAY;OACrCb,MAAMgB,GAAG,CAAC,CAACR,MAAMS,QAChB,8DAA8D;sBAC9D,oBAAC7C;YAAI8C,KAAKD;YAAON,eAAc;YAASQ,QAAQ;yBAC9C,oBAAC9C,YAAMmC,KAAKO,IAAI;AAO9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/contexts/Store.tsx"],"sourcesContent":["import { createContext } from 'react';\nexport default createContext(undefined);\n"],"names":["createContext","undefined"],"mappings":"AAAA,SAASA,aAAa,QAAQ,QAAQ;AACtC,6BAAeA,cAAcC,WAAW"}
|
package/dist/esm/createApp.mjs
CHANGED
|
@@ -1,73 +1,42 @@
|
|
|
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 uuid from 'lil-uuid';
|
|
30
1
|
import React from 'react';
|
|
2
|
+
import { createStore } from 'zustand';
|
|
31
3
|
import App from './components/App.mjs';
|
|
4
|
+
import StoreContext from './contexts/Store.mjs';
|
|
32
5
|
// @ts-ignore
|
|
33
6
|
import { render } from './ink.mjs';
|
|
34
7
|
export default function createApp() {
|
|
35
8
|
let refCount = 0;
|
|
36
|
-
let
|
|
9
|
+
let store = null;
|
|
37
10
|
let inkApp = null;
|
|
38
11
|
return {
|
|
39
|
-
addItem (data) {
|
|
40
|
-
if (!list) throw new Error('Expecting list');
|
|
41
|
-
const item = _object_spread({
|
|
42
|
-
id: uuid(),
|
|
43
|
-
title: '',
|
|
44
|
-
state: 'pending',
|
|
45
|
-
lines: []
|
|
46
|
-
}, data);
|
|
47
|
-
list.push(item);
|
|
48
|
-
return item;
|
|
49
|
-
},
|
|
50
|
-
rerender () {
|
|
51
|
-
if (inkApp) inkApp.rerender(/*#__PURE__*/ React.createElement(App, {
|
|
52
|
-
list: list
|
|
53
|
-
}));
|
|
54
|
-
},
|
|
55
12
|
retain () {
|
|
56
|
-
if (++refCount > 1) return;
|
|
13
|
+
if (++refCount > 1) return store;
|
|
57
14
|
if (inkApp) throw new Error('Not expecting app');
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
15
|
+
store = createStore()((set)=>({
|
|
16
|
+
processes: [],
|
|
17
|
+
addProcess: (process1)=>set((state)=>({
|
|
18
|
+
processes: [
|
|
19
|
+
...state.processes,
|
|
20
|
+
process1
|
|
21
|
+
]
|
|
22
|
+
})),
|
|
23
|
+
updateProcess: (process1)=>set((state)=>({
|
|
24
|
+
processes: state.processes.map((x)=>x.id === process1.id ? process1 : x)
|
|
25
|
+
}))
|
|
26
|
+
}));
|
|
27
|
+
inkApp = render(/*#__PURE__*/ React.createElement(StoreContext.Provider, {
|
|
28
|
+
value: store
|
|
29
|
+
}, /*#__PURE__*/ React.createElement(App, null)), {
|
|
62
30
|
patchConsole: false
|
|
63
31
|
});
|
|
32
|
+
return store;
|
|
64
33
|
},
|
|
65
34
|
release () {
|
|
66
35
|
if (--refCount > 0) return;
|
|
67
36
|
if (!inkApp) throw new Error('Expecting app');
|
|
68
37
|
inkApp.unmount();
|
|
69
38
|
inkApp = null;
|
|
70
|
-
|
|
39
|
+
store = null;
|
|
71
40
|
process.stdout.write('\x1b[?25h'); // show cursor
|
|
72
41
|
}
|
|
73
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import React from 'react';\nimport { createStore } from 'zustand';\nimport App from './components/App';\nimport StoreContext from './contexts/Store';\n\n// @ts-ignore\nimport { type Instance, render } from './ink.mjs';\nimport type { AppState } from './types';\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n return {\n retain() {\n if (++refCount > 1) return store;\n if (inkApp) throw new Error('Not expecting app');\n store = createStore<AppState>()((set) => ({\n processes: [],\n addProcess: (process) => set((state) => ({ processes: [...state.processes, process] })),\n updateProcess: (process) => set((state) => ({ processes: state.processes.map((x) => (x.id === process.id ? process : x)) })),\n }));\n inkApp = render(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>,\n { patchConsole: false }\n );\n return store;\n },\n release() {\n if (--refCount > 0) return;\n if (!inkApp) throw new Error('Expecting app');\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["React","createStore","App","StoreContext","render","createApp","refCount","store","inkApp","retain","Error","set","processes","addProcess","process","state","updateProcess","map","x","id","Provider","value","patchConsole","release","unmount","stdout","write"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,WAAW,QAAQ,UAAU;AACtC,OAAOC,SAAS,mBAAmB;AACnC,OAAOC,kBAAkB,mBAAmB;AAE5C,aAAa;AACb,SAAwBC,MAAM,QAAQ,YAAY;AAGlD,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC;YACE,IAAI,EAAEH,WAAW,GAAG,OAAOC;YAC3B,IAAIC,QAAQ,MAAM,IAAIE,MAAM;YAC5BH,QAAQN,cAAwB,CAACU,MAAS,CAAA;oBACxCC,WAAW,EAAE;oBACbC,YAAY,CAACC,WAAYH,IAAI,CAACI,QAAW,CAAA;gCAAEH,WAAW;uCAAIG,MAAMH,SAAS;oCAAEE;iCAAQ;4BAAC,CAAA;oBACpFE,eAAe,CAACF,WAAYH,IAAI,CAACI,QAAW,CAAA;gCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;4BAAI,CAAA;gBAC3H,CAAA;YACAV,SAASJ,qBACP,oBAACD,aAAaiB,QAAQ;gBAACC,OAAOd;6BAC5B,oBAACL,aAEH;gBAAEoB,cAAc;YAAM;YAExB,OAAOf;QACT;QACAgB;YACE,IAAI,EAAEjB,WAAW,GAAG;YACpB,IAAI,CAACE,QAAQ,MAAM,IAAIE,MAAM;YAC7BF,OAAOgB,OAAO;YACdhB,SAAS;YACTD,QAAQ;YACRO,QAAQW,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { Writable } from 'readable-stream';
|
|
2
2
|
const regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
|
|
3
|
-
export default function addLines(
|
|
3
|
+
export default function addLines(fn) {
|
|
4
4
|
let last = '';
|
|
5
5
|
const stream = new Writable({
|
|
6
6
|
write (chunk, _enc, callback) {
|
|
7
7
|
const more = last + chunk.toString('utf8');
|
|
8
8
|
const lines = more.split(regEx);
|
|
9
9
|
last = lines.pop();
|
|
10
|
-
lines.
|
|
10
|
+
if (lines.length) fn(lines);
|
|
11
11
|
callback();
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
stream.on('finish', ()=>{
|
|
15
|
-
if (last.length)
|
|
15
|
+
if (last.length) fn([
|
|
16
|
+
last
|
|
17
|
+
]);
|
|
16
18
|
last = '';
|
|
17
19
|
});
|
|
18
20
|
return stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(regEx);\n last = lines.pop();\n if (lines.length) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["Writable","regEx","addLines","fn","last","stream","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAE3C,MAAMC,QAAQ;AAEd,eAAe,SAASC,SAASC,EAAE;IACjC,IAAIC,OAAO;IAEX,MAAMC,SAAS,IAAIL,SAAS;QAC1BM,OAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,MAAMC,OAAON,OAAOG,MAAMI,QAAQ,CAAC;YACnC,MAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBG,OAAOQ,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,EAAEZ,GAAGS;YACrBH;QACF;IACF;IACAJ,OAAOW,EAAE,CAAC,UAAU;QAClB,IAAIZ,KAAKW,MAAM,EAAEZ,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
|
package/dist/esm/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n};\n"],"names":["LineType"],"mappings":"AAAA,aAAa;AAOb,OAAO,IAAA,AAAKA,kCAAAA;;;WAAAA;MAGX"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n isExpanded: boolean;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["LineType"],"mappings":"AAAA,aAAa;AAOb,OAAO,IAAA,AAAKA,kCAAAA;;;WAAAA;MAGX"}
|
package/dist/esm/worker.mjs
CHANGED
|
@@ -79,6 +79,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
79
79
|
return target;
|
|
80
80
|
}
|
|
81
81
|
import spawn, { crossSpawn } from 'cross-spawn-cb';
|
|
82
|
+
import uuid from 'lil-uuid';
|
|
82
83
|
import oo from 'on-one';
|
|
83
84
|
import Queue from 'queue-cb';
|
|
84
85
|
import createApp from './createApp.mjs';
|
|
@@ -86,24 +87,26 @@ import addLines from './lib/addLines.mjs';
|
|
|
86
87
|
import concatWritable from './lib/concatWritable.mjs';
|
|
87
88
|
import { LineType } from './types.mjs';
|
|
88
89
|
const terminal = createApp();
|
|
89
|
-
import throttle from 'lodash.throttle';
|
|
90
|
-
const THROTTLE = 100;
|
|
91
|
-
const rerender = throttle(()=>{
|
|
92
|
-
|
|
93
|
-
}, THROTTLE);
|
|
90
|
+
// import throttle from 'lodash.throttle';
|
|
91
|
+
// const THROTTLE = 100;
|
|
92
|
+
// const rerender = throttle(() => {
|
|
93
|
+
// terminal.rerender();
|
|
94
|
+
// }, THROTTLE);
|
|
94
95
|
export default function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
95
96
|
const { encoding, stdio } = spawnOptions, csOptions = _object_without_properties(spawnOptions, [
|
|
96
97
|
"encoding",
|
|
97
98
|
"stdio"
|
|
98
99
|
]);
|
|
99
|
-
terminal.retain();
|
|
100
|
-
const
|
|
100
|
+
const store = terminal.retain();
|
|
101
|
+
const id = uuid();
|
|
102
|
+
store.getState().addProcess({
|
|
103
|
+
id,
|
|
101
104
|
title: [
|
|
102
105
|
command
|
|
103
106
|
].concat(args).join(' '),
|
|
104
|
-
state: 'running'
|
|
107
|
+
state: 'running',
|
|
108
|
+
lines: []
|
|
105
109
|
});
|
|
106
|
-
terminal.rerender();
|
|
107
110
|
const cp = crossSpawn(command, args, csOptions);
|
|
108
111
|
const outputs = {
|
|
109
112
|
stdout: null,
|
|
@@ -116,12 +119,15 @@ export default function spawnTerminal(command, args, spawnOptions, _options, cal
|
|
|
116
119
|
const queue = new Queue();
|
|
117
120
|
if (cp.stdout) {
|
|
118
121
|
if (stdio === 'inherit') {
|
|
119
|
-
outputs.stdout = addLines((
|
|
120
|
-
item.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
outputs.stdout = addLines((texts)=>{
|
|
123
|
+
const item = store.getState().processes.find((x)=>x.id === id);
|
|
124
|
+
const lines = item.lines.concat(texts.map((text)=>({
|
|
125
|
+
type: LineType.stdout,
|
|
126
|
+
text
|
|
127
|
+
})));
|
|
128
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
129
|
+
lines
|
|
130
|
+
}));
|
|
125
131
|
});
|
|
126
132
|
} else {
|
|
127
133
|
outputs.stdout = concatWritable((output)=>{
|
|
@@ -137,12 +143,15 @@ export default function spawnTerminal(command, args, spawnOptions, _options, cal
|
|
|
137
143
|
}
|
|
138
144
|
if (cp.stderr) {
|
|
139
145
|
if (stdio === 'inherit') {
|
|
140
|
-
outputs.stderr = addLines((
|
|
141
|
-
item.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
outputs.stderr = addLines((texts)=>{
|
|
147
|
+
const item = store.getState().processes.find((x)=>x.id === id);
|
|
148
|
+
const lines = item.lines.concat(texts.map((text)=>({
|
|
149
|
+
type: LineType.stderr,
|
|
150
|
+
text
|
|
151
|
+
})));
|
|
152
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
153
|
+
lines
|
|
154
|
+
}));
|
|
146
155
|
});
|
|
147
156
|
} else {
|
|
148
157
|
outputs.stderr = concatWritable((output)=>{
|
|
@@ -172,8 +181,10 @@ export default function spawnTerminal(command, args, spawnOptions, _options, cal
|
|
|
172
181
|
res.stderr,
|
|
173
182
|
null
|
|
174
183
|
];
|
|
175
|
-
item
|
|
176
|
-
|
|
184
|
+
const item = store.getState().processes.find((x)=>x.id === id);
|
|
185
|
+
store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
186
|
+
state: err ? 'error' : 'success'
|
|
187
|
+
}));
|
|
177
188
|
terminal.release();
|
|
178
189
|
err ? callback(err) : callback(null, res);
|
|
179
190
|
});
|
package/dist/esm/worker.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp';\nimport addLines from './lib/addLines';\nimport concatWritable from './lib/concatWritable';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport uuid from 'lil-uuid';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp';\nimport addLines from './lib/addLines';\nimport concatWritable from './lib/concatWritable';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\n// import throttle from 'lodash.throttle';\n// const THROTTLE = 100;\n// const rerender = throttle(() => {\n// terminal.rerender();\n// }, THROTTLE);\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, _options: TerminalOptions, callback) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n const store = terminal.retain();\n const id = uuid();\n store.getState().addProcess({ id, title: [command].concat(args).join(' '), state: 'running', lines: [] });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') {\n outputs.stdout = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stdout, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n } else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n }\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n if (stdio === 'inherit') {\n outputs.stderr = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stderr, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n } else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\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, encoding: 'utf8' }));\n queue.await((err) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\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.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, state: err ? 'error' : 'success' });\n terminal.release();\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawn","crossSpawn","uuid","oo","Queue","createApp","addLines","concatWritable","LineType","terminal","spawnTerminal","command","args","spawnOptions","_options","callback","encoding","stdio","csOptions","store","retain","id","getState","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","texts","item","processes","find","x","map","text","type","updateProcess","output","toString","defer","bind","pipe","worker","await","err","res","release"],"mappings":"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"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Line, State } from '../types';
|
|
2
1
|
type ChildProcessProps = {
|
|
3
|
-
|
|
4
|
-
state: State;
|
|
5
|
-
lines: Line[];
|
|
6
|
-
isExpanded?: boolean;
|
|
2
|
+
id: string;
|
|
7
3
|
};
|
|
8
|
-
export default function ChildProcess({
|
|
4
|
+
export default function ChildProcess({ id }: ChildProcessProps): any;
|
|
9
5
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function addLines(
|
|
1
|
+
export default function addLines(fn: any): any;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -16,4 +16,10 @@ export type ChildProcess = {
|
|
|
16
16
|
title: string;
|
|
17
17
|
state: State;
|
|
18
18
|
lines: Line[];
|
|
19
|
+
isExpanded: boolean;
|
|
19
20
|
};
|
|
21
|
+
export interface AppState {
|
|
22
|
+
processes: ChildProcess[];
|
|
23
|
+
addProcess: (process: ChildProcess) => void;
|
|
24
|
+
updateProcess: (process: ChildProcess) => void;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"core-js": "^3.40.0",
|
|
43
43
|
"cross-spawn-cb": "^2.1.22",
|
|
44
44
|
"lil-uuid": "^0.1.1",
|
|
45
|
-
"lodash.throttle": "^4.1.1",
|
|
46
45
|
"on-one": "^0.1.4",
|
|
47
46
|
"queue-cb": "^1.4.16",
|
|
48
47
|
"react": "^18.3.1",
|
|
49
48
|
"readable-stream": "^2.3.8",
|
|
50
|
-
"yoga-wasm-web": "^0.3.3"
|
|
49
|
+
"yoga-wasm-web": "^0.3.3",
|
|
50
|
+
"zustand": "^5.0.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/mocha": "*",
|