spawn-term 1.0.1 → 1.0.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/Store.d.cts +11 -0
- package/dist/cjs/Store.d.ts +11 -0
- package/dist/cjs/Store.js +40 -0
- package/dist/cjs/Store.js.map +1 -0
- package/dist/cjs/components/App.d.cts +3 -1
- package/dist/cjs/components/App.d.ts +3 -1
- package/dist/cjs/components/App.js +8 -18
- package/dist/cjs/components/App.js.map +1 -1
- package/dist/cjs/components/ChildProcess.js +12 -14
- package/dist/cjs/components/ChildProcess.js.map +1 -1
- package/dist/cjs/createApp.d.cts +3 -1
- package/dist/cjs/createApp.d.ts +3 -1
- package/dist/cjs/createApp.js +27 -83
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/types.d.cts +0 -11
- package/dist/cjs/types.d.ts +0 -11
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/worker.js +7 -7
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/Store.d.ts +11 -0
- package/dist/esm/Store.js +19 -0
- package/dist/esm/Store.js.map +1 -0
- package/dist/esm/components/App.d.ts +3 -1
- package/dist/esm/components/App.js +6 -17
- package/dist/esm/components/App.js.map +1 -1
- package/dist/esm/components/ChildProcess.js +12 -14
- package/dist/esm/components/ChildProcess.js.map +1 -1
- package/dist/esm/createApp.d.ts +3 -1
- package/dist/esm/createApp.js +25 -51
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/types.d.ts +0 -11
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/worker.js +7 -7
- package/dist/esm/worker.js.map +1 -1
- package/package.json +3 -4
- package/dist/cjs/contexts/Store.d.cts +0 -3
- package/dist/cjs/contexts/Store.d.ts +0 -3
- package/dist/cjs/contexts/Store.js +0 -13
- package/dist/cjs/contexts/Store.js.map +0 -1
- package/dist/esm/contexts/Store.d.ts +0 -3
- package/dist/esm/contexts/Store.js +0 -2
- package/dist/esm/contexts/Store.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChildProcess } from './types.ts';
|
|
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.ts';
|
|
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/Store.ts"],"sourcesContent":["import type { ChildProcess } from './types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","onRender","Error","processes","data","addProcess","process","push","updateProcess","map","x","id"],"mappings":";;;;;;;eAKqBA;;;;;;;;AAAN,IAAA,AAAMA,sBAAN;;aAAMA,MAIPC,QAAwB;gCAJjBD;QAKjB,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM;QAC/B,IAAI,CAACC,SAAS,GAAG,EAAE;QACnB,IAAI,CAACF,QAAQ,GAAGA;;iBAPCD;IAUnBI,OAAAA,IAEC,GAFDA,SAAAA;QACE,OAAO,IAAI,CAACD,SAAS;IACvB;IAEAE,OAAAA,UAGC,GAHDA,SAAAA,WAAWC,OAAqB;QAC9B,IAAI,CAACH,SAAS,CAACI,IAAI,CAACD;QACpB,IAAI,CAACL,QAAQ;IACf;IAEAO,OAAAA,aAGC,GAHDA,SAAAA,cAAcF,OAAqB;QACjC,IAAI,CAACH,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,SAACC;mBAAOA,EAAEC,EAAE,KAAKL,QAAQK,EAAE,GAAGL,UAAUI;;QAC5E,IAAI,CAACT,QAAQ;IACf;WAtBmBD"}
|
|
@@ -10,30 +10,20 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
12
12
|
var _ink = require("ink");
|
|
13
|
-
var _react = require("react");
|
|
14
|
-
var _zustand = require("zustand");
|
|
15
|
-
var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.js"));
|
|
16
13
|
var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.js"));
|
|
17
14
|
function _interop_require_default(obj) {
|
|
18
15
|
return obj && obj.__esModule ? obj : {
|
|
19
16
|
default: obj
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
function App() {
|
|
23
|
-
var store =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
|
|
31
|
-
flexDirection: "column",
|
|
32
|
-
children: appState.processes.map(function(item) {
|
|
33
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default, {
|
|
34
|
-
item: item
|
|
35
|
-
}, item.id);
|
|
36
|
-
})
|
|
19
|
+
function App(param) {
|
|
20
|
+
var store = param.store;
|
|
21
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
|
|
22
|
+
flexDirection: "column",
|
|
23
|
+
children: store.processes.map(function(item) {
|
|
24
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default, {
|
|
25
|
+
item: item
|
|
26
|
+
}, item.id);
|
|
37
27
|
})
|
|
38
28
|
});
|
|
39
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"}
|
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
-
var _ansicolors = /*#__PURE__*/ _interop_require_default(require("ansi-colors"));
|
|
13
12
|
var _ink = require("ink");
|
|
14
13
|
var _react = require("react");
|
|
15
14
|
var _ansiRegex = /*#__PURE__*/ _interop_require_default(require("../lib/ansiRegex.js"));
|
|
@@ -71,13 +70,13 @@ var SPINNER = {
|
|
|
71
70
|
]
|
|
72
71
|
};
|
|
73
72
|
var ICONS = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
children:
|
|
73
|
+
error: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
|
|
74
|
+
color: "red",
|
|
75
|
+
children: _figures.default.cross
|
|
77
76
|
}),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
children:
|
|
77
|
+
success: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
|
|
78
|
+
color: "green",
|
|
79
|
+
children: _figures.default.tick
|
|
81
80
|
}),
|
|
82
81
|
running: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Spinner.default, _object_spread({}, SPINNER))
|
|
83
82
|
};
|
|
@@ -110,13 +109,12 @@ var RunningSummary = /*#__PURE__*/ (0, _react.memo)(function RunningSummary(para
|
|
|
110
109
|
});
|
|
111
110
|
});
|
|
112
111
|
var renderLine = function(line, index) {
|
|
113
|
-
return(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}, index));
|
|
112
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
|
|
113
|
+
minHeight: 1,
|
|
114
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
|
|
115
|
+
children: line.text
|
|
116
|
+
})
|
|
117
|
+
}, index);
|
|
120
118
|
};
|
|
121
119
|
var Lines = /*#__PURE__*/ (0, _react.memo)(function Lines(param) {
|
|
122
120
|
var lines = param.lines;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import
|
|
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,MAAM;AAAG;AAErD,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,qBAACC,SAAI;QAACC,OAAM;kBAAOC,gBAAO,CAACC,KAAK;;IACvCC,uBAAS,qBAACJ,SAAI;QAACC,OAAM;kBAASC,gBAAO,CAACG,IAAI;;IAC1CC,uBAAS,qBAACC,gBAAO,qBAAKZ;AACxB;AAYA,IAAMa,uBAASC,IAAAA,WAAI,EAC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BAAEC,OAAOmB,KAAKnB,KAAK;;0BAC/D,qBAACc;gBAAMC,OAAOA;;;;AAGpB;AAEA,IAAMK,2BAAavB,IAAAA,WAAI,EAAC,SAASuB,WAAW,KAAmB;QAAnB,AAAED,OAAF,MAAEA;IAC5C,IAAQnB,QAAiBmB,KAAjBnB,OAAOe,QAAUI,KAAVJ;IAEf,iDAAiD;IACjD,IAAMM,SAASC,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAACf;mBAASA,KAAK7B,IAAI,KAAKC,eAAQ,CAAC4C,MAAM;;OAAG;QAACT;KAAM;IAC3F,IAAMU,UAAUH,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAACf;mBAASA,KAAK1B,IAAI,CAAC4C,MAAM,GAAG,KAAKL,OAAOM,OAAO,CAACnB,QAAQ;WAAGoB,GAAG;OAAI;QAACb;QAAOM;KAAO;IAE7H,qBACE,sBAACnB,QAAG;QAACc,eAAc;;0BACjB,qBAACpB;gBAAOE,OAAOqB,KAAKrB,KAAK;gBAAEC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;;YAC9DA,UAAU,2BAAa,qBAACO;gBAAeC,MAAMiB,WAAW/C;;YACxD2C,OAAOK,MAAM,GAAG,mBAAK,qBAACZ;gBAAMC,OAAOM;;;;AAG1C;IAEA,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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { default as Store } from './Store.js';
|
|
2
|
+
export type RetainCallback = (app: Store) => undefined;
|
|
3
|
+
export type ReleaseCallback = () => undefined;
|
|
2
4
|
export default function createApp(): {
|
|
3
5
|
retain(fn: RetainCallback): undefined;
|
|
4
6
|
release(cb: ReleaseCallback): undefined;
|
package/dist/cjs/createApp.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { default as Store } from './Store.js';
|
|
2
|
+
export type RetainCallback = (app: Store) => undefined;
|
|
3
|
+
export type ReleaseCallback = () => undefined;
|
|
2
4
|
export default function createApp(): {
|
|
3
5
|
retain(fn: RetainCallback): undefined;
|
|
4
6
|
release(cb: ReleaseCallback): undefined;
|
package/dist/cjs/createApp.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
@@ -11,105 +10,50 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
});
|
|
12
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
13
12
|
var _ink = require("ink");
|
|
14
|
-
var
|
|
13
|
+
var _lodashthrottle = /*#__PURE__*/ _interop_require_default(require("lodash.throttle"));
|
|
15
14
|
var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.js"));
|
|
16
|
-
var _Store = /*#__PURE__*/ _interop_require_default(require("./
|
|
17
|
-
function _array_like_to_array(arr, len) {
|
|
18
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
20
|
-
return arr2;
|
|
21
|
-
}
|
|
22
|
-
function _array_without_holes(arr) {
|
|
23
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
24
|
-
}
|
|
15
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("./Store.js"));
|
|
25
16
|
function _interop_require_default(obj) {
|
|
26
17
|
return obj && obj.__esModule ? obj : {
|
|
27
18
|
default: obj
|
|
28
19
|
};
|
|
29
20
|
}
|
|
30
|
-
|
|
31
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
32
|
-
}
|
|
33
|
-
function _non_iterable_spread() {
|
|
34
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
-
}
|
|
36
|
-
function _to_consumable_array(arr) {
|
|
37
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
38
|
-
}
|
|
39
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
|
-
if (!o) return;
|
|
41
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
|
-
}
|
|
21
|
+
var THROTTLE = 100;
|
|
47
22
|
function createApp() {
|
|
48
23
|
var refCount = 0;
|
|
49
24
|
var store = null;
|
|
50
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);
|
|
51
36
|
return {
|
|
52
37
|
retain: function retain(fn) {
|
|
53
38
|
if (++refCount > 1) return fn(store);
|
|
54
39
|
if (store) throw new Error('Not expecting store');
|
|
55
|
-
store =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
set(function(state) {
|
|
61
|
-
return {
|
|
62
|
-
processes: _to_consumable_array(state.processes).concat([
|
|
63
|
-
process1
|
|
64
|
-
])
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
updateProcess: function(process1) {
|
|
69
|
-
store.nextRenders = store.renders + 1;
|
|
70
|
-
set(function(state) {
|
|
71
|
-
return {
|
|
72
|
-
processes: state.processes.map(function(x) {
|
|
73
|
-
return x.id === process1.id ? process1 : x;
|
|
74
|
-
})
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
store.nextRenders = 0;
|
|
81
|
-
store.renders = 0;
|
|
82
|
-
store.waiting = [];
|
|
83
|
-
store.onRender = function() {
|
|
84
|
-
store.renders++;
|
|
85
|
-
if (store.renders === store.nextRenders) {
|
|
86
|
-
while(store === null || store === void 0 ? void 0 : store.waiting.length)store.waiting.pop()();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Store.default.Provider, {
|
|
90
|
-
value: store,
|
|
91
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {})
|
|
92
|
-
}), {
|
|
93
|
-
patchConsole: false
|
|
94
|
-
});
|
|
95
|
-
return fn(store);
|
|
40
|
+
store = new _Store.default(rerenderThrottled);
|
|
41
|
+
inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
|
|
42
|
+
store: store
|
|
43
|
+
}));
|
|
44
|
+
fn(store);
|
|
96
45
|
},
|
|
97
46
|
release: function release(cb) {
|
|
98
|
-
if (--refCount > 0)
|
|
99
|
-
if (store.renders === store.nextRenders) cb();
|
|
100
|
-
else store.waiting.push(cb);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
47
|
+
if (--refCount > 0) return cb();
|
|
103
48
|
if (!store) throw new Error('Expecting store');
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
else store.waiting.push(done);
|
|
49
|
+
rerender();
|
|
50
|
+
inkApp.waitUntilExit().then(function() {
|
|
51
|
+
return cb();
|
|
52
|
+
}).catch(cb);
|
|
53
|
+
inkApp.unmount();
|
|
54
|
+
inkApp = null;
|
|
55
|
+
store = null;
|
|
56
|
+
process.stdout.write('\x1b[?25h'); // show cursor
|
|
113
57
|
}
|
|
114
58
|
};
|
|
115
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["
|
|
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 './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"}
|
package/dist/cjs/types.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { StoreApi } from 'zustand';
|
|
2
1
|
export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';
|
|
3
2
|
import type { SpawnError, SpawnResult } from 'cross-spawn-cb';
|
|
4
3
|
export type TerminalOptions = {
|
|
@@ -23,13 +22,3 @@ export type ChildProcess = {
|
|
|
23
22
|
lines: Line[];
|
|
24
23
|
expanded?: boolean;
|
|
25
24
|
};
|
|
26
|
-
export interface AppState {
|
|
27
|
-
processes: ChildProcess[];
|
|
28
|
-
addProcess: (process: ChildProcess) => void;
|
|
29
|
-
updateProcess: (process: ChildProcess) => void;
|
|
30
|
-
}
|
|
31
|
-
export interface Store extends StoreApi<AppState> {
|
|
32
|
-
onRender: () => undefined;
|
|
33
|
-
}
|
|
34
|
-
export type RetainCallback = (app: Store) => undefined;
|
|
35
|
-
export type ReleaseCallback = () => undefined;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { StoreApi } from 'zustand';
|
|
2
1
|
export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';
|
|
3
2
|
import type { SpawnError, SpawnResult } from 'cross-spawn-cb';
|
|
4
3
|
export type TerminalOptions = {
|
|
@@ -23,13 +22,3 @@ export type ChildProcess = {
|
|
|
23
22
|
lines: Line[];
|
|
24
23
|
expanded?: boolean;
|
|
25
24
|
};
|
|
26
|
-
export interface AppState {
|
|
27
|
-
processes: ChildProcess[];
|
|
28
|
-
addProcess: (process: ChildProcess) => void;
|
|
29
|
-
updateProcess: (process: ChildProcess) => void;
|
|
30
|
-
}
|
|
31
|
-
export interface Store extends StoreApi<AppState> {
|
|
32
|
-
onRender: () => undefined;
|
|
33
|
-
}
|
|
34
|
-
export type RetainCallback = (app: Store) => undefined;
|
|
35
|
-
export type ReleaseCallback = () => undefined;
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["
|
|
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
|
|
@@ -167,10 +167,10 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
167
167
|
var queue = new _queuecb.default();
|
|
168
168
|
if (cp.stdout) {
|
|
169
169
|
outputs.stdout = (0, _addLines.default)(function(lines) {
|
|
170
|
-
var item = store.
|
|
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,
|
|
@@ -188,10 +188,10 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
188
188
|
}
|
|
189
189
|
if (cp.stderr) {
|
|
190
190
|
outputs.stderr = (0, _addLines.default)(function(lines) {
|
|
191
|
-
var item = store.
|
|
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,
|
|
@@ -219,10 +219,10 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
219
219
|
res.stderr,
|
|
220
220
|
null
|
|
221
221
|
];
|
|
222
|
-
var item = store.
|
|
222
|
+
var item = store.processes.find(function(x) {
|
|
223
223
|
return x.id === id;
|
|
224
224
|
});
|
|
225
|
-
store.
|
|
225
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
226
226
|
state: err ? 'error' : 'success'
|
|
227
227
|
}));
|
|
228
228
|
// ensure rendering completes
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,kBAAS;AAEX,SAASF,cA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;
|
|
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,19 @@
|
|
|
1
|
+
class Store {
|
|
2
|
+
data() {
|
|
3
|
+
return this.processes;
|
|
4
|
+
}
|
|
5
|
+
addProcess(process) {
|
|
6
|
+
this.processes.push(process);
|
|
7
|
+
this.onRender();
|
|
8
|
+
}
|
|
9
|
+
updateProcess(process) {
|
|
10
|
+
this.processes = this.processes.map((x)=>x.id === process.id ? process : x);
|
|
11
|
+
this.onRender();
|
|
12
|
+
}
|
|
13
|
+
constructor(onRender){
|
|
14
|
+
if (!onRender) throw new Error('missing on render');
|
|
15
|
+
this.processes = [];
|
|
16
|
+
this.onRender = onRender;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { Store as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/Store.ts"],"sourcesContent":["import type { ChildProcess } from './types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","data","processes","addProcess","process","push","onRender","updateProcess","map","x","id","Error"],"mappings":"AAKe,MAAMA;IAUnBC,OAAkB;QAChB,OAAO,IAAI,CAACC,SAAS;IACvB;IAEAC,WAAWC,OAAqB,EAAQ;QACtC,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACE,QAAQ;IACf;IAEAC,cAAcH,OAAqB,EAAQ;QACzC,IAAI,CAACF,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKN,QAAQM,EAAE,GAAGN,UAAUK;QAC5E,IAAI,CAACH,QAAQ;IACf;IAlBA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIK,MAAM;QAC/B,IAAI,CAACT,SAAS,GAAG,EAAE;QACnB,IAAI,CAACI,QAAQ,GAAGA;IAClB;AAeF;AAvBA,SAAqBN,mBAuBpB"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from 'ink';
|
|
3
|
-
import { Profiler, useContext } from 'react';
|
|
4
|
-
import { useStore } from 'zustand';
|
|
5
|
-
import StoreContext from '../contexts/Store.js';
|
|
6
3
|
import ChildProcess from './ChildProcess.js';
|
|
7
|
-
export default function App() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (phase === 'update') store === null || store === void 0 ? void 0 : store.onRender();
|
|
14
|
-
},
|
|
15
|
-
children: /*#__PURE__*/ _jsx(Box, {
|
|
16
|
-
flexDirection: "column",
|
|
17
|
-
children: appState.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, {
|
|
18
|
-
item: item
|
|
19
|
-
}, item.id))
|
|
20
|
-
})
|
|
4
|
+
export default function App({ store }) {
|
|
5
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
6
|
+
flexDirection: "column",
|
|
7
|
+
children: store.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, {
|
|
8
|
+
item: item
|
|
9
|
+
}, item.id))
|
|
21
10
|
});
|
|
22
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"}
|
|
@@ -27,7 +27,6 @@ function _object_spread(target) {
|
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
|
-
import c from 'ansi-colors';
|
|
31
30
|
import { Box, Text } from 'ink';
|
|
32
31
|
import { memo, useMemo } from 'react';
|
|
33
32
|
import ansiRegex from '../lib/ansiRegex.js';
|
|
@@ -56,13 +55,13 @@ const SPINNER = {
|
|
|
56
55
|
]
|
|
57
56
|
};
|
|
58
57
|
const ICONS = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
children:
|
|
58
|
+
error: /*#__PURE__*/ _jsx(Text, {
|
|
59
|
+
color: "red",
|
|
60
|
+
children: figures.cross
|
|
62
61
|
}),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
children:
|
|
62
|
+
success: /*#__PURE__*/ _jsx(Text, {
|
|
63
|
+
color: "green",
|
|
64
|
+
children: figures.tick
|
|
66
65
|
}),
|
|
67
66
|
running: /*#__PURE__*/ _jsx(Spinner, _object_spread({}, SPINNER))
|
|
68
67
|
};
|
|
@@ -91,13 +90,12 @@ const RunningSummary = /*#__PURE__*/ memo(function RunningSummary({ line }) {
|
|
|
91
90
|
});
|
|
92
91
|
});
|
|
93
92
|
const renderLine = (line, index)=>{
|
|
94
|
-
return(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
}, index));
|
|
93
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
94
|
+
minHeight: 1,
|
|
95
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
96
|
+
children: line.text
|
|
97
|
+
})
|
|
98
|
+
}, index);
|
|
101
99
|
};
|
|
102
100
|
const Lines = /*#__PURE__*/ memo(function Lines({ lines }) {
|
|
103
101
|
return /*#__PURE__*/ _jsx(Box, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import
|
|
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":["Box","Text","memo","useMemo","ansiRegex","figures","LineType","Spinner","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","color","cross","success","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AACtC,OAAOC,eAAe,sBAAsB;AAC5C,OAAOC,aAAa,oBAAoB;AAExC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,aAAa,eAAe;AAEnC,MAAMC,aAAaJ;AACnB,MAAMK,aAAa;IAAEC,MAAMJ,SAASK,MAAM;IAAEC,MAAM;AAAG;AAErD,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,KAAChB;QAAKiB,OAAM;kBAAOb,QAAQc,KAAK;;IACvCC,uBAAS,KAACnB;QAAKiB,OAAM;kBAASb,QAAQgB,IAAI;;IAC1CC,uBAAS,KAACf,4BAAYM;AACxB;AAYA,MAAMU,uBAASrB,KACb,SAASqB,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAe;IAClD,MAAMC,OAAOX,KAAK,CAACU,MAAM;IAEzB,qBACE,MAAC1B;;YACE2B;YACAH,uBAAS,KAACvB;gBAAK2B,IAAI;0BAAE,GAAGJ,QAAQnB,QAAQwB,OAAO,CAAC,CAAC,CAAC;;0BACnD,KAAC5B;0BA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AAKrB,IAAI,CAACsC,MAAM,GAAG,KAAKJ,OAAOK,OAAO,CAAClB,QAAQ,GAAGmB,GAAG,IAAI;QAACZ;QAAOM;KAAO;IAE7H,qBACE,MAAC9C;QAAIyC,eAAc;;0BACjB,KAAClB;gBAAOC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;gBAAEC,OAAOkB,KAAKlB,KAAK;;YAC9DA,UAAU,2BAAa,KAACM;gBAAeC,MAAMgB,WAAWxC;;YACxDqC,OAAOI,MAAM,GAAG,mBAAK,KAACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAe5C,KAAK,SAASmD,aAAa,EAAET,IAAI,EAAa;IAC3D,MAAM,EAAEU,QAAQ,EAAE,GAAGV;IACrB,OAAOU,yBAAW,KAACX;QAASC,MAAMA;uBAAW,KAACC;QAAWD,MAAMA;;AACjE,GAAG"}
|
package/dist/esm/createApp.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { default as Store } from './Store.js';
|
|
2
|
+
export type RetainCallback = (app: Store) => undefined;
|
|
3
|
+
export type ReleaseCallback = () => undefined;
|
|
2
4
|
export default function createApp(): {
|
|
3
5
|
retain(fn: RetainCallback): undefined;
|
|
4
6
|
release(cb: ReleaseCallback): undefined;
|
package/dist/esm/createApp.js
CHANGED
|
@@ -1,68 +1,42 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { render } from 'ink';
|
|
4
|
-
import
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
5
4
|
import App from './components/App.js';
|
|
6
|
-
import
|
|
5
|
+
import { default as Store } from './Store.js';
|
|
6
|
+
const THROTTLE = 100;
|
|
7
7
|
export default function createApp() {
|
|
8
8
|
let refCount = 0;
|
|
9
9
|
let store = null;
|
|
10
10
|
let inkApp = null;
|
|
11
|
+
let previousData = null;
|
|
12
|
+
const rerender = ()=>{
|
|
13
|
+
if (!inkApp || !store) return;
|
|
14
|
+
if (store.data() === previousData) return;
|
|
15
|
+
previousData = store.data();
|
|
16
|
+
inkApp.rerender(/*#__PURE__*/ _jsx(App, {
|
|
17
|
+
store: store
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
const rerenderThrottled = throttle(rerender, THROTTLE);
|
|
11
21
|
return {
|
|
12
22
|
retain (fn) {
|
|
13
23
|
if (++refCount > 1) return fn(store);
|
|
14
24
|
if (store) throw new Error('Not expecting store');
|
|
15
|
-
store =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
processes: [
|
|
21
|
-
...state.processes,
|
|
22
|
-
process1
|
|
23
|
-
]
|
|
24
|
-
}));
|
|
25
|
-
},
|
|
26
|
-
updateProcess: (process1)=>{
|
|
27
|
-
store.nextRenders = store.renders + 1;
|
|
28
|
-
set((state)=>({
|
|
29
|
-
processes: state.processes.map((x)=>x.id === process1.id ? process1 : x)
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
store.nextRenders = 0;
|
|
34
|
-
store.renders = 0;
|
|
35
|
-
store.waiting = [];
|
|
36
|
-
store.onRender = ()=>{
|
|
37
|
-
store.renders++;
|
|
38
|
-
if (store.renders === store.nextRenders) {
|
|
39
|
-
while(store === null || store === void 0 ? void 0 : store.waiting.length)store.waiting.pop()();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
inkApp = render(/*#__PURE__*/ _jsx(StoreContext.Provider, {
|
|
43
|
-
value: store,
|
|
44
|
-
children: /*#__PURE__*/ _jsx(App, {})
|
|
45
|
-
}), {
|
|
46
|
-
patchConsole: false
|
|
47
|
-
});
|
|
48
|
-
return fn(store);
|
|
25
|
+
store = new Store(rerenderThrottled);
|
|
26
|
+
inkApp = render(/*#__PURE__*/ _jsx(App, {
|
|
27
|
+
store: store
|
|
28
|
+
}));
|
|
29
|
+
fn(store);
|
|
49
30
|
},
|
|
50
31
|
release (cb) {
|
|
51
|
-
if (--refCount > 0)
|
|
52
|
-
if (store.renders === store.nextRenders) cb();
|
|
53
|
-
else store.waiting.push(cb);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
32
|
+
if (--refCount > 0) return cb();
|
|
56
33
|
if (!store) throw new Error('Expecting store');
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
if (store.renders === store.nextRenders) done();
|
|
65
|
-
else store.waiting.push(done);
|
|
34
|
+
rerender();
|
|
35
|
+
inkApp.waitUntilExit().then(()=>cb()).catch(cb);
|
|
36
|
+
inkApp.unmount();
|
|
37
|
+
inkApp = null;
|
|
38
|
+
store = null;
|
|
39
|
+
process.stdout.write('\x1b[?25h'); // show cursor
|
|
66
40
|
}
|
|
67
41
|
};
|
|
68
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["
|
|
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 './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":["render","throttle","App","default","Store","THROTTLE","createApp","refCount","store","inkApp","previousData","rerender","data","rerenderThrottled","retain","fn","Error","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,SAASC,WAAWC,KAAK,QAAwB,aAAa;AAK9D,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,MAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,KAACT;YAAIM,OAAOA;;IAC9B;IACA,MAAMK,oBAAoBZ,SAASU,UAAUN;IAE7C,OAAO;QACLS,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMS;YAClBJ,SAAST,qBAAO,KAACE;gBAAIM,OAAOA;;YAC5BO,GAAGP;QACL;QACAS,SAAQC,EAAmB;YACzB,IAAI,EAAEX,WAAW,GAAG,OAAOW;YAC3B,IAAI,CAACV,OAAO,MAAM,IAAIQ,MAAM;YAE5BL;YACAF,OACGU,aAAa,GACbC,IAAI,CAAC,IAAMF,MACXG,KAAK,CAACH;YACTT,OAAOa,OAAO;YACdb,SAAS;YACTD,QAAQ;YACRe,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { StoreApi } from 'zustand';
|
|
2
1
|
export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';
|
|
3
2
|
import type { SpawnError, SpawnResult } from 'cross-spawn-cb';
|
|
4
3
|
export type TerminalOptions = {
|
|
@@ -23,13 +22,3 @@ export type ChildProcess = {
|
|
|
23
22
|
lines: Line[];
|
|
24
23
|
expanded?: boolean;
|
|
25
24
|
};
|
|
26
|
-
export interface AppState {
|
|
27
|
-
processes: ChildProcess[];
|
|
28
|
-
addProcess: (process: ChildProcess) => void;
|
|
29
|
-
updateProcess: (process: ChildProcess) => void;
|
|
30
|
-
}
|
|
31
|
-
export interface Store extends StoreApi<AppState> {
|
|
32
|
-
onRender: () => undefined;
|
|
33
|
-
}
|
|
34
|
-
export type RetainCallback = (app: Store) => undefined;
|
|
35
|
-
export type ReleaseCallback = () => undefined;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["
|
|
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":"AAWA,OAAO,MAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV,EAAW"}
|
package/dist/esm/worker.js
CHANGED
|
@@ -95,7 +95,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
95
95
|
if (stdio === 'inherit') {
|
|
96
96
|
terminal.retain((store)=>{
|
|
97
97
|
const id = crypto.randomUUID();
|
|
98
|
-
store.
|
|
98
|
+
store.addProcess(_object_spread({
|
|
99
99
|
id,
|
|
100
100
|
title: [
|
|
101
101
|
command
|
|
@@ -111,8 +111,8 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
111
111
|
const queue = new Queue();
|
|
112
112
|
if (cp.stdout) {
|
|
113
113
|
outputs.stdout = addLines((lines)=>{
|
|
114
|
-
const item = store.
|
|
115
|
-
store.
|
|
114
|
+
const item = store.processes.find((x)=>x.id === id);
|
|
115
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
116
116
|
lines: item.lines.concat(lines.map((text)=>({
|
|
117
117
|
type: LineType.stdout,
|
|
118
118
|
text
|
|
@@ -128,8 +128,8 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
128
128
|
}
|
|
129
129
|
if (cp.stderr) {
|
|
130
130
|
outputs.stderr = addLines((lines)=>{
|
|
131
|
-
const item = store.
|
|
132
|
-
store.
|
|
131
|
+
const item = store.processes.find((x)=>x.id === id);
|
|
132
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
133
133
|
lines: item.lines.concat(lines.map((text)=>({
|
|
134
134
|
type: LineType.stderr,
|
|
135
135
|
text
|
|
@@ -155,8 +155,8 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
155
155
|
res.stderr,
|
|
156
156
|
null
|
|
157
157
|
];
|
|
158
|
-
const item = store.
|
|
159
|
-
store.
|
|
158
|
+
const item = store.processes.find((x)=>x.id === id);
|
|
159
|
+
store.updateProcess(_object_spread_props(_object_spread({}, item), {
|
|
160
160
|
state: err ? 'error' : 'success'
|
|
161
161
|
}));
|
|
162
162
|
// ensure rendering completes
|
package/dist/esm/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.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":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,iBAAiB;AACvC,OAAOC,cAAc,oBAAoB;AACzC,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AAGvD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAgB,GAAGJ,cAAdK,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,CAACC;YACf,MAAMC,KAAKpB,OAAOqB,UAAU;YAC5BF,MAAMG,UAAU,CAAC;gBAAEF;gBAAIG,OAAO;oBAACb;iBAAQ,CAACc,MAAM,CAAClB,gBAAgBK,OAAOc,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKd;YAEjH,MAAMe,KAAK7B,WAAWW,SAASC,MAA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GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACAC,MAAMS,KAAK,CAAC3C,MAAM8C,MAAM,CAACF,IAAI,CAAC,MAAMd,IAAI,wCAAKX;YAAWF,UAAUA,YAAY;;QAC9EiB,MAAMa,KAAK,CAAC,CAACC;YACX,MAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAIjB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACkB,MAAM,GAAG;YACtDD,IAAIhB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACiB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIjB,MAAM;gBAAEiB,IAAIhB,MAAM;gBAAE;aAAK;YAC3Ce,MAAMhC,SAASgC,OAAOhC,SAAS,MAAMiC;QACvC;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -40,13 +40,12 @@
|
|
|
40
40
|
"version": "tsds version"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"ansi-colors": "^4.1.3",
|
|
44
43
|
"cross-spawn-cb": "^2.2.9",
|
|
45
44
|
"ink": "^6.0.0",
|
|
45
|
+
"lodash.throttle": "^4.1.1",
|
|
46
46
|
"on-one": "^0.1.8",
|
|
47
47
|
"queue-cb": "^1.5.3",
|
|
48
|
-
"react": "^19.1.0"
|
|
49
|
-
"zustand": "^5.0.5"
|
|
48
|
+
"react": "^19.1.0"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@types/mocha": "*",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _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; }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/contexts/Store.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { Store } from '../types.js';\n\nexport default createContext<Store>(undefined);\n"],"names":["createContext","undefined"],"mappings":";;;;+BAGA;;;eAAA;;;qBAH8B;IAG9B,yBAAeA,IAAAA,oBAAa,EAAQC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/contexts/Store.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { Store } from '../types.js';\n\nexport default createContext<Store>(undefined);\n"],"names":["createContext","undefined"],"mappings":"AAAA,SAASA,aAAa,QAAQ,QAAQ;AAGtC,6BAAeA,cAAqBC,WAAW"}
|