spawn-term 0.1.52 → 0.1.54
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/assets/ink.cjs +1 -1
- package/assets/intl-adapter.cjs +1 -1
- package/dist/cjs/components/{App.cjs → App.js} +3 -3
- package/dist/cjs/components/App.js.map +1 -0
- package/dist/cjs/components/ChildProcess.d.cts +1 -1
- package/dist/{esm/components/ChildProcess.d.mts → cjs/components/ChildProcess.d.ts} +1 -1
- package/dist/cjs/components/{ChildProcess.cjs → ChildProcess.js} +5 -5
- package/dist/cjs/components/ChildProcess.js.map +1 -0
- package/dist/cjs/components/{Spinner.cjs → Spinner.js} +1 -1
- package/dist/cjs/components/Spinner.js.map +1 -0
- package/dist/cjs/{createApp.cjs → createApp.js} +3 -3
- package/dist/cjs/createApp.js.map +1 -0
- package/dist/cjs/index-cjs.d.cts +1 -1
- package/dist/{esm/index-cjs.d.mts → cjs/index-cjs.d.ts} +1 -1
- package/dist/cjs/{index-cjs.cjs → index-cjs.js} +4 -4
- package/dist/cjs/index-cjs.js.map +1 -0
- package/dist/cjs/index-esm.d.cts +4 -4
- package/dist/cjs/index-esm.d.ts +7 -0
- package/dist/cjs/{index-esm.cjs → index-esm.js} +4 -4
- package/dist/cjs/index-esm.js.map +1 -0
- package/dist/cjs/ink.d.cts +7 -0
- package/dist/cjs/ink.d.ts +7 -0
- package/dist/cjs/ink.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/worker.d.cts +1 -1
- package/dist/{esm/worker.d.mts → cjs/worker.d.ts} +1 -1
- package/dist/cjs/{worker.cjs → worker.js} +5 -5
- package/dist/cjs/worker.js.map +1 -0
- package/dist/esm/components/App.d.ts +1 -0
- package/dist/esm/components/{App.mjs → App.js} +3 -3
- package/dist/esm/components/App.js.map +1 -0
- package/dist/esm/components/ChildProcess.d.ts +6 -0
- package/dist/esm/components/{ChildProcess.mjs → ChildProcess.js} +5 -5
- package/dist/esm/components/ChildProcess.js.map +1 -0
- package/dist/esm/components/Spinner.d.ts +5 -0
- package/dist/esm/components/{Spinner.mjs → Spinner.js} +1 -1
- package/dist/esm/components/Spinner.js.map +1 -0
- package/dist/esm/contexts/Store.d.ts +2 -0
- package/dist/esm/createApp.d.ts +4 -0
- package/dist/esm/{createApp.mjs → createApp.js} +3 -3
- package/dist/esm/createApp.js.map +1 -0
- package/dist/esm/{index-esm.d.mts → index-cjs.d.ts} +2 -2
- package/dist/esm/{index-esm.mjs → index-cjs.js} +4 -4
- package/dist/esm/index-cjs.js.map +1 -0
- package/dist/esm/index-esm.d.ts +7 -0
- package/dist/esm/{index-cjs.mjs → index-esm.js} +4 -4
- package/dist/esm/index-esm.js.map +1 -0
- package/dist/esm/ink.d.ts +7 -0
- package/dist/esm/{ink.mjs → ink.js} +1 -0
- package/dist/esm/ink.js.map +1 -0
- package/dist/esm/lib/addLines.d.ts +1 -0
- package/dist/esm/lib/ansiRegex.d.ts +3 -0
- package/dist/esm/lib/concatWritable.d.ts +1 -0
- package/dist/esm/lib/figures.d.ts +10 -0
- package/dist/esm/lib/formatArguments.d.ts +2 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +27 -0
- package/dist/esm/worker.d.ts +2 -0
- package/dist/esm/{worker.mjs → worker.js} +5 -5
- package/dist/esm/worker.js.map +1 -0
- package/package.json +7 -7
- package/dist/cjs/components/App.cjs.map +0 -1
- package/dist/cjs/components/ChildProcess.cjs.map +0 -1
- package/dist/cjs/components/Spinner.cjs.map +0 -1
- package/dist/cjs/createApp.cjs.map +0 -1
- package/dist/cjs/index-cjs.cjs.map +0 -1
- package/dist/cjs/index-esm.cjs.map +0 -1
- package/dist/cjs/ink.cjs.map +0 -1
- package/dist/cjs/worker.cjs.map +0 -1
- package/dist/esm/components/App.mjs.map +0 -1
- package/dist/esm/components/ChildProcess.mjs.map +0 -1
- package/dist/esm/components/Spinner.mjs.map +0 -1
- package/dist/esm/createApp.mjs.map +0 -1
- package/dist/esm/index-cjs.mjs.map +0 -1
- package/dist/esm/index-esm.mjs.map +0 -1
- package/dist/esm/ink.mjs.map +0 -1
- package/dist/esm/worker.mjs.map +0 -1
- /package/dist/{esm/components/App.d.mts → cjs/components/App.d.ts} +0 -0
- /package/dist/{esm/components/Spinner.d.mts → cjs/components/Spinner.d.ts} +0 -0
- /package/dist/{esm/contexts/Store.d.mts → cjs/contexts/Store.d.ts} +0 -0
- /package/dist/cjs/contexts/{Store.cjs → Store.js} +0 -0
- /package/dist/cjs/contexts/{Store.cjs.map → Store.js.map} +0 -0
- /package/dist/{esm/createApp.d.mts → cjs/createApp.d.ts} +0 -0
- /package/dist/cjs/{ink.cjs → ink.js} +0 -0
- /package/dist/{esm/lib/addLines.d.mts → cjs/lib/addLines.d.ts} +0 -0
- /package/dist/cjs/lib/{addLines.cjs → addLines.js} +0 -0
- /package/dist/cjs/lib/{addLines.cjs.map → addLines.js.map} +0 -0
- /package/dist/{esm/lib/ansiRegex.d.mts → cjs/lib/ansiRegex.d.ts} +0 -0
- /package/dist/cjs/lib/{ansiRegex.cjs → ansiRegex.js} +0 -0
- /package/dist/cjs/lib/{ansiRegex.cjs.map → ansiRegex.js.map} +0 -0
- /package/dist/{esm/lib/concatWritable.d.mts → cjs/lib/concatWritable.d.ts} +0 -0
- /package/dist/cjs/lib/{concatWritable.cjs → concatWritable.js} +0 -0
- /package/dist/cjs/lib/{concatWritable.cjs.map → concatWritable.js.map} +0 -0
- /package/dist/{esm/lib/figures.d.mts → cjs/lib/figures.d.ts} +0 -0
- /package/dist/cjs/lib/{figures.cjs → figures.js} +0 -0
- /package/dist/cjs/lib/{figures.cjs.map → figures.js.map} +0 -0
- /package/dist/{esm/lib/formatArguments.d.mts → cjs/lib/formatArguments.d.ts} +0 -0
- /package/dist/cjs/lib/{formatArguments.cjs → formatArguments.js} +0 -0
- /package/dist/cjs/lib/{formatArguments.cjs.map → formatArguments.js.map} +0 -0
- /package/dist/{esm/types.d.mts → cjs/types.d.ts} +0 -0
- /package/dist/cjs/{types.cjs → types.js} +0 -0
- /package/dist/cjs/{types.cjs.map → types.js.map} +0 -0
- /package/dist/esm/contexts/{Store.mjs → Store.js} +0 -0
- /package/dist/esm/contexts/{Store.mjs.map → Store.js.map} +0 -0
- /package/dist/esm/lib/{addLines.mjs → addLines.js} +0 -0
- /package/dist/esm/lib/{addLines.mjs.map → addLines.js.map} +0 -0
- /package/dist/esm/lib/{ansiRegex.mjs → ansiRegex.js} +0 -0
- /package/dist/esm/lib/{ansiRegex.mjs.map → ansiRegex.js.map} +0 -0
- /package/dist/esm/lib/{concatWritable.mjs → concatWritable.js} +0 -0
- /package/dist/esm/lib/{concatWritable.mjs.map → concatWritable.js.map} +0 -0
- /package/dist/esm/lib/{figures.mjs → figures.js} +0 -0
- /package/dist/esm/lib/{figures.mjs.map → figures.js.map} +0 -0
- /package/dist/esm/lib/{formatArguments.mjs → formatArguments.js} +0 -0
- /package/dist/esm/lib/{formatArguments.mjs.map → formatArguments.js.map} +0 -0
- /package/dist/esm/{types.mjs → types.js} +0 -0
- /package/dist/esm/{types.mjs.map → types.js.map} +0 -0
package/assets/ink.cjs
CHANGED
|
@@ -30570,4 +30570,4 @@ var parseKeypress = function () {
|
|
|
30570
30570
|
};
|
|
30571
30571
|
};
|
|
30572
30572
|
|
|
30573
|
-
|
|
30573
|
+
//* 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; }
|
package/assets/intl-adapter.cjs
CHANGED
|
@@ -1080,4 +1080,4 @@ function requireIntlAdapter() {
|
|
|
1080
1080
|
var intlAdapterExports = requireIntlAdapter();
|
|
1081
1081
|
var intlAdapter = /*@__PURE__*/ getDefaultExportFromCjs(intlAdapterExports);
|
|
1082
1082
|
|
|
1083
|
-
|
|
1083
|
+
//* 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; }
|
|
@@ -10,9 +10,9 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
var _zustand = require("zustand");
|
|
13
|
-
var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.
|
|
14
|
-
var _ink = require("../ink.
|
|
15
|
-
var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.
|
|
13
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.js"));
|
|
14
|
+
var _ink = require("../ink.js");
|
|
15
|
+
var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.js"));
|
|
16
16
|
function _interop_require_default(obj) {
|
|
17
17
|
return obj && obj.__esModule ? obj : {
|
|
18
18
|
default: obj
|
|
@@ -0,0 +1 @@
|
|
|
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.js';\nimport { Box } from '../ink.js';\nimport type { AppState, ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App() {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n\n return (\n <Box flexDirection=\"column\">\n {appState.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["App","store","useContext","StoreContext","appState","useStore","Box","flexDirection","processes","map","item","ChildProcess","key","id"],"mappings":";;;;+BAOA;;;eAAwBA;;;6DAPU;uBACT;4DACA;mBACL;mEAEK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,SAASA;IACtB,IAAMC,QAAQC,IAAAA,iBAAU,EAACC,cAAY;IACrC,IAAMC,WAAWC,IAAAA,iBAAQ,EAACJ;IAE1B,qBACE,6BAACK,QAAG;QAACC,eAAc;OAChBH,SAASI,SAAS,CAACC,GAAG,CAAC,SAACC;6BACvB,6BAACC,qBAAY;YAACC,KAAKF,KAAKG,EAAE;YAAEH,MAAMA;;;AAI1C"}
|
|
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _ansicolors = /*#__PURE__*/ _interop_require_default(require("ansi-colors"));
|
|
12
12
|
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
-
var _ink = require("../ink.
|
|
14
|
-
var _ansiRegex = /*#__PURE__*/ _interop_require_default(require("../lib/ansiRegex.
|
|
15
|
-
var _figures = /*#__PURE__*/ _interop_require_default(require("../lib/figures.
|
|
16
|
-
var _Spinner = /*#__PURE__*/ _interop_require_default(require("./Spinner.
|
|
17
|
-
var _types = require("../types.
|
|
13
|
+
var _ink = require("../ink.js");
|
|
14
|
+
var _ansiRegex = /*#__PURE__*/ _interop_require_default(require("../lib/ansiRegex.js"));
|
|
15
|
+
var _figures = /*#__PURE__*/ _interop_require_default(require("../lib/figures.js"));
|
|
16
|
+
var _Spinner = /*#__PURE__*/ _interop_require_default(require("./Spinner.js"));
|
|
17
|
+
var _types = require("../types.js");
|
|
18
18
|
function _interop_require_default(obj) {
|
|
19
19
|
return obj && obj.__esModule ? obj : {
|
|
20
20
|
default: obj
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport React, { memo, useMemo } from 'react';\nimport { Box, Text } from '../ink.js';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport Spinner from './Spinner.js';\n\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-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 // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\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","ink-text","c","red","figures","cross","success","green","tick","running","Spinner","Header","memo","group","title","state","icon","Box","Text","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","key","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BAiHA;;;eAAA;;;iEAjHc;6DACuB;mBACX;gEACJ;8DACF;8DACA;qBAGK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,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;IACZ,aAAa;IACbC,qBAAO,6BAACC,kBAAUC,mBAAC,CAACC,GAAG,CAACC,gBAAO,CAACC,KAAK;IACrC,aAAa;IACbC,uBAAS,6BAACL,kBAAUC,mBAAC,CAACK,KAAK,CAACH,gBAAO,CAACI,IAAI;IACxCC,uBAAS,6BAACC,gBAAO,EAAKd;AACxB;AAYA,IAAMe,uBAASC,IAAAA,WA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C,OAAOuB,KAAKvB,KAAK;sBAC/D,6BAACkB;QAAMC,OAAOA;;AAGpB;AAEA,IAAMK,2BAAa3B,IAAAA,WAAI,EAAC,SAAS2B,WAAW,KAAmB;QAAnB,AAAED,OAAF,MAAEA;IAC5C,IAAQvB,QAAiBuB,KAAjBvB,OAAOmB,QAAUI,KAAVJ;IAEf,iDAAiD;IACjD,IAAMM,SAASC,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAAClB;mBAASA,KAAKhC,IAAI,KAAKC,eAAQ,CAACkD,MAAM;;OAAG;QAACT;KAAM;IAC3F,IAAMU,UAAUH,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAAClB;mBAASA,KAAK7B,IAAI,CAACkD,MAAM,GAAG,KAAKL,OAAOM,OAAO,CAACtB,QAAQ;WAAGuB,GAAG;OAAI;QAACb;QAAOM;KAAO;IAE7H,qBACE,6BAACvB,QAAG;QAACkB,eAAc;qBACjB,6BAACxB;QAAOE,OAAOyB,KAAKzB,KAAK;QAAEC,OAAOwB,KAAKxB,KAAK;QAAEC,OAAOuB,KAAKvB,KAAK;QAC9DA,UAAU,2BAAa,6BAACQ;QAAeC,MAAMoB,WAAWrD;QACxDiD,OAAOK,MAAM,GAAG,mBAAK,6BAACZ;QAAMC,OAAOM;;AAG1C;IAEA,yBAAe5B,IAAAA,WAAI,EAAC,SAASoC,aAAa,KAAmB;QAAnB,AAAEV,OAAF,MAAEA;IAC1C,IAAM,AAAEW,WAAaX,KAAbW;IACR,OAAOA,yBAAW,6BAACZ;QAASC,MAAMA;uBAAW,6BAACC;QAAWD,MAAMA;;AACjE"}
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
var _ink = require("../ink.
|
|
12
|
+
var _ink = require("../ink.js");
|
|
13
13
|
function _array_like_to_array(arr, len) {
|
|
14
14
|
if (len == null || len > arr.length) len = arr.length;
|
|
15
15
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Text } from '../ink.js';\n\nexport type SpinnerProps = {\n interval: number;\n frames: string[];\n};\n\nexport default function Spinner({ interval, frames }: SpinnerProps) {\n const [index, setIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setIndex((index) => (index === frames.length - 1 ? 0 : index + 1));\n }, interval);\n return () => {\n clearInterval(timer);\n };\n }, [interval, frames]);\n\n return <Text>{`${frames[index]} `}</Text>;\n}\n"],"names":["Spinner","interval","frames","useState","index","setIndex","useEffect","timer","setInterval","length","clearInterval","Text"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DARmB;mBACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAON,SAASA,QAAQ,KAAkC;QAAhCC,WAAF,MAAEA,UAAUC,SAAZ,MAAYA;IAC1C,IAA0BC,6BAAAA,IAAAA,eAAQ,EAAC,QAA5BC,QAAmBD,cAAZE,WAAYF;IAE1BG,IAAAA,gBAAS,EAAC;QACR,IAAMC,QAAQC,YAAY;YACxBH,SAAS,SAACD;uBAAWA,UAAUF,OAAOO,MAAM,GAAG,IAAI,IAAIL,QAAQ;;QACjE,GAAGH;QACH,OAAO;YACLS,cAAcH;QAChB;IACF,GAAG;QAACN;QAAUC;KAAO;IAErB,qBAAO,6BAACS,SAAI,QAAE,AAAC,GAAgB,OAAdT,MAAM,CAACE,MAAM,EAAC;AACjC"}
|
|
@@ -10,9 +10,9 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
12
|
var _zustand = require("zustand");
|
|
13
|
-
var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.
|
|
14
|
-
var _Store = /*#__PURE__*/ _interop_require_default(require("./contexts/Store.
|
|
15
|
-
var _ink = require("./ink.
|
|
13
|
+
var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.js"));
|
|
14
|
+
var _Store = /*#__PURE__*/ _interop_require_default(require("./contexts/Store.js"));
|
|
15
|
+
var _ink = require("./ink.js");
|
|
16
16
|
function _array_like_to_array(arr, len) {
|
|
17
17
|
if (len == null || len > arr.length) len = arr.length;
|
|
18
18
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -0,0 +1 @@
|
|
|
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.js';\nimport StoreContext from './contexts/Store.js';\n\n// @ts-ignore\nimport { type Instance, initialize, render } from './ink.js';\nimport type { AppState } from './types.js';\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n return {\n retain(fn) {\n initialize(() => {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\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 fn(store);\n });\n },\n release() {\n if (--refCount > 0) return;\n if (!store) throw new Error('Expecting store');\n store = null;\n inkApp.unmount();\n inkApp = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","refCount","store","inkApp","retain","fn","initialize","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;mBAGyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGnC,SAASA;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC,QAAAA,SAAAA,OAAOC,EAAE;YACPC,IAAAA,eAAU,EAAC;gBACT,IAAI,EAAEL,WAAW,GAAG,OAAOI,GAAGH;gBAC9B,IAAIA,OAAO,MAAM,IAAIK,MAAM;gBAC3BL,QAAQM,IAAAA,oBAAW,IAAa,SAACC;2BAAS;wBACxCC,WAAW,EAAE;wBACbC,YAAY,SAACC;mCAAYH,IAAI,SAACI;uCAAW;oCAAEH,WAAW,AAAC,qBAAGG,MAAMH,SAAS,SAAnB;wCAAqBE;qCAAQ;gCAAC;;;wBACpFE,eAAe,SAACF;mCAAYH,IAAI,SAACI;uCAAW;oCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,SAACC;+CAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;;gCAAI;;;oBAC3H;;gBACAb,SAASe,IAAAA,WAAM,gBACb,6BAACC,cAAY,CAACC,QAAQ;oBAACC,OAAOnB;iCAC5B,6BAACoB,YAAG,UAEN;oBAAEC,cAAc;gBAAM;gBAExB,OAAOlB,GAAGH;YACZ;QACF;QACAsB,SAAAA,SAAAA;YACE,IAAI,EAAEvB,WAAW,GAAG;YACpB,IAAI,CAACC,OAAO,MAAM,IAAIK,MAAM;YAC5BL,QAAQ;YACRC,OAAOsB,OAAO;YACdtB,SAAS;YACTS,QAAQc,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
package/dist/cjs/index-cjs.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
2
|
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): any;
|
|
3
3
|
export * from './types';
|
|
4
4
|
export { default as figures } from './lib/figures';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
2
|
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): any;
|
|
3
3
|
export * from './types';
|
|
4
4
|
export { default as figures } from './lib/figures';
|
|
@@ -19,9 +19,9 @@ _export(exports, {
|
|
|
19
19
|
return _formatArguments.default;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
_export_star(require("./types
|
|
23
|
-
var _figures = /*#__PURE__*/ _interop_require_default(require("./lib/figures
|
|
24
|
-
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments
|
|
22
|
+
_export_star(require("./types"), exports);
|
|
23
|
+
var _figures = /*#__PURE__*/ _interop_require_default(require("./lib/figures"));
|
|
24
|
+
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments"));
|
|
25
25
|
function _export_star(from, to) {
|
|
26
26
|
Object.keys(from).forEach(function(k) {
|
|
27
27
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -41,7 +41,7 @@ function _interop_require_default(obj) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
44
|
-
var worker = require('./worker.
|
|
44
|
+
var worker = require('./worker.js');
|
|
45
45
|
if (typeof options === 'function') {
|
|
46
46
|
callback = options;
|
|
47
47
|
options = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-cjs.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n const worker = require('./worker.js');\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["figures","formatArguments","spawnTerminal","command","args","spawnOptions","options","callback","worker","require","Promise","resolve","reject","err","result","major","process","versions","node","split","undefined"],"mappings":";;;;;;;;;;;IAoBA,OAAsD;eAAtD;;IAFoBA,OAAO;eAAPA,gBAAO;;IACPC,eAAe;eAAfA,wBAAe;;;qBAFrB;8DACqB;sEACQ;;;;;;;;;;;;;;;;;;;AAjB3C,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAMC,SAASC,QAAQ;IAEvB,IAAI,OAAOH,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIG,QAAQ,SAACC,SAASC;eAAWJ,OAAOL,SAASC,MAAMC,cAAcC,SAAS,SAACO,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI;AAEA,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAKlD,WAAeJ,QAAQ,KAAKb,gBAAgBkB"}
|
package/dist/cjs/index-esm.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
2
|
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): void | Promise<unknown>;
|
|
3
|
-
export * from './types';
|
|
4
|
-
export { default as figures } from './lib/figures';
|
|
5
|
-
export { default as formatArguments } from './lib/formatArguments';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { default as figures } from './lib/figures.js';
|
|
5
|
+
export { default as formatArguments } from './lib/formatArguments.js';
|
|
6
6
|
declare const _default: typeof spawnTerminal;
|
|
7
7
|
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
|
+
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): void | Promise<unknown>;
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { default as figures } from './lib/figures.js';
|
|
5
|
+
export { default as formatArguments } from './lib/formatArguments.js';
|
|
6
|
+
declare const _default: typeof spawnTerminal;
|
|
7
|
+
export default _default;
|
|
@@ -19,10 +19,10 @@ _export(exports, {
|
|
|
19
19
|
return _formatArguments.default;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
var _worker = /*#__PURE__*/ _interop_require_default(require("./worker.
|
|
23
|
-
_export_star(require("./types.
|
|
24
|
-
var _figures = /*#__PURE__*/ _interop_require_default(require("./lib/figures.
|
|
25
|
-
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments.
|
|
22
|
+
var _worker = /*#__PURE__*/ _interop_require_default(require("./worker.js"));
|
|
23
|
+
_export_star(require("./types.js"), exports);
|
|
24
|
+
var _figures = /*#__PURE__*/ _interop_require_default(require("./lib/figures.js"));
|
|
25
|
+
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments.js"));
|
|
26
26
|
function _export_star(from, to) {
|
|
27
27
|
Object.keys(from).forEach(function(k) {
|
|
28
28
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["import worker from './worker.js';\n\nimport type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types.js';\nexport { default as figures } from './lib/figures.js';\nexport { default as formatArguments } from './lib/formatArguments.js';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["figures","formatArguments","spawnTerminal","command","args","spawnOptions","options","callback","worker","Promise","resolve","reject","err","result","major","process","versions","node","split","undefined"],"mappings":";;;;;;;;;;;IAoBA,OAAsD;eAAtD;;IAFoBA,OAAO;eAAPA,gBAAO;;IACPC,eAAe;eAAfA,wBAAe;;;6DAnBhB;qBAiBL;8DACqB;sEACQ;;;;;;;;;;;;;;;;;;;AAf3C,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,eAAM,EAACL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIE,QAAQ,SAACC,SAASC;eAAWH,IAAAA,eAAM,EAACL,SAASC,MAAMC,cAAcC,SAAS,SAACM,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI;AAEA,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAKlD,WAAeJ,QAAQ,KAAKZ,gBAAgBiB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'core-js/actual/array/at.js';
|
|
2
|
+
import 'core-js/actual/object/has-own.js';
|
|
3
|
+
import 'core-js/actual/object/values.js';
|
|
4
|
+
import 'core-js/actual/string/replace-all.js';
|
|
5
|
+
import 'core-js/actual/string/trim-end.js';
|
|
6
|
+
declare const Box: any, Newline: any, Spacer: any, Static: any, Text: any, Transform: any, measureElement: any, render: any, useApp: any, useFocus: any, useFocusManager: any, useInput: any, useStderr: any, useStdin: any, useStdout: any, initialize: any;
|
|
7
|
+
export { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'core-js/actual/array/at.js';
|
|
2
|
+
import 'core-js/actual/object/has-own.js';
|
|
3
|
+
import 'core-js/actual/object/values.js';
|
|
4
|
+
import 'core-js/actual/string/replace-all.js';
|
|
5
|
+
import 'core-js/actual/string/trim-end.js';
|
|
6
|
+
declare const Box: any, Newline: any, Spacer: any, Static: any, Text: any, Transform: any, measureElement: any, render: any, useApp: any, useFocus: any, useFocusManager: any, useInput: any, useStderr: any, useStdin: any, useStdout: any, initialize: any;
|
|
7
|
+
export { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/ink.ts"],"sourcesContent":["import 'core-js/actual/array/at.js';\nimport 'core-js/actual/object/has-own.js';\nimport 'core-js/actual/object/values.js';\nimport 'core-js/actual/string/replace-all.js';\nimport 'core-js/actual/string/trim-end.js';\nif (typeof process.stdout.off === 'undefined') process.stdout.off = (name, fn) => process.stdout.removeListener(name, fn);\nif (typeof process.stderr.off === 'undefined') process.stderr.off = (name, fn) => process.stderr.removeListener(name, fn);\n\n// @ts-ignore\nimport * as ink from '../../assets/ink.cjs';\nconst { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize } = ink.default || ink;\nexport { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };\n"],"names":["Box","Newline","Spacer","Static","Text","Transform","initialize","measureElement","render","useApp","useFocus","useFocusManager","useInput","useStderr","useStdin","useStdout","process","stdout","off","name","fn","removeListener","stderr","ink","default"],"mappings":";;;;;;;;;;;IAWSA,GAAG;eAAHA;;IAAKC,OAAO;eAAPA;;IAASC,MAAM;eAANA;;IAAQC,MAAM;eAANA;;IAAQC,IAAI;eAAJA;;IAAMC,SAAS;eAATA;;IAAgHC,UAAU;eAAVA;;IAArGC,cAAc;eAAdA;;IAAgBC,MAAM;eAANA;;IAAQC,MAAM;eAANA;;IAAQC,QAAQ;eAARA;;IAAUC,eAAe;eAAfA;;IAAiBC,QAAQ;eAARA;;IAAUC,SAAS;eAATA;;IAAWC,QAAQ;eAARA;;IAAUC,SAAS;eAATA;;;QAX3I;QACA;QACA;QACA;QACA;8DAKc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJrB,IAAI,OAAOC,QAAQC,MAAM,CAACC,GAAG,KAAK,aAAaF,QAAQC,MAAM,CAACC,GAAG,GAAG,SAACC,MAAMC;WAAOJ,QAAQC,MAAM,CAACI,cAAc,CAACF,MAAMC;;AACtH,IAAI,OAAOJ,QAAQM,MAAM,CAACJ,GAAG,KAAK,aAAaF,QAAQM,MAAM,CAACJ,GAAG,GAAG,SAACC,MAAMC;WAAOJ,QAAQM,MAAM,CAACD,cAAc,CAACF,MAAMC;;AAItH,IAA2KG,OAAAA,QAAIC,OAAO,IAAID,SAAlLvB,MAAmKuB,KAAnKvB,KAAKC,UAA8JsB,KAA9JtB,SAASC,SAAqJqB,KAArJrB,QAAQC,SAA6IoB,KAA7IpB,QAAQC,OAAqImB,KAArInB,MAAMC,YAA+HkB,KAA/HlB,WAAWE,iBAAoHgB,KAApHhB,gBAAgBC,SAAoGe,KAApGf,QAAQC,SAA4Fc,KAA5Fd,QAAQC,WAAoFa,KAApFb,UAAUC,kBAA0EY,KAA1EZ,iBAAiBC,WAAyDW,KAAzDX,UAAUC,YAA+CU,KAA/CV,WAAWC,WAAoCS,KAApCT,UAAUC,YAA0BQ,KAA1BR,WAAWT,aAAeiB,KAAfjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
package/dist/cjs/worker.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SpawnOptions, TerminalOptions } from './types';
|
|
1
|
+
import type { SpawnOptions, TerminalOptions } from './types.js';
|
|
2
2
|
export default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: any): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SpawnOptions, TerminalOptions } from './types';
|
|
1
|
+
import type { SpawnOptions, TerminalOptions } from './types.js';
|
|
2
2
|
export default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: any): void;
|
|
@@ -13,11 +13,11 @@ var _crossspawncb = /*#__PURE__*/ _interop_require_wildcard(require("cross-spawn
|
|
|
13
13
|
var _liluuid = /*#__PURE__*/ _interop_require_default(require("lil-uuid"));
|
|
14
14
|
var _onone = /*#__PURE__*/ _interop_require_default(require("on-one"));
|
|
15
15
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
16
|
-
var _createApp = /*#__PURE__*/ _interop_require_default(require("./createApp.
|
|
17
|
-
var _addLines = /*#__PURE__*/ _interop_require_default(require("./lib/addLines.
|
|
18
|
-
var _concatWritable = /*#__PURE__*/ _interop_require_default(require("./lib/concatWritable.
|
|
19
|
-
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments.
|
|
20
|
-
var _types = require("./types.
|
|
16
|
+
var _createApp = /*#__PURE__*/ _interop_require_default(require("./createApp.js"));
|
|
17
|
+
var _addLines = /*#__PURE__*/ _interop_require_default(require("./lib/addLines.js"));
|
|
18
|
+
var _concatWritable = /*#__PURE__*/ _interop_require_default(require("./lib/concatWritable.js"));
|
|
19
|
+
var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments.js"));
|
|
20
|
+
var _types = require("./types.js");
|
|
21
21
|
function _define_property(obj, key, value) {
|
|
22
22
|
if (key in obj) {
|
|
23
23
|
Object.defineProperty(obj, key, {
|
|
@@ -0,0 +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 uuid from 'lil-uuid';\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 { SpawnOptions, 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) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = uuid();\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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) => {\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\n // let rendering complete\n setTimeout(() => {\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) => {\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","uuid","getState","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","setTimeout","release","concatWritable","toString"],"mappings":"AAAA,aAAa;;;;;+BAgBb;;;eAAwBA;;;oEAf4B;8DACnC;4DACF;8DACG;gEAEI;+DACD;qEACM;sEACC;qBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,kBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAAQ;IACnI,IAAQC,WAAkCH,aAAlCG,UAAUC,QAAwBJ,aAAxBI,OAAUC,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,SAACC;YACf,IAAMC,KAAKC,IAAAA,gBAAI;YACfF,MAAMG,QAAQ,GAAGC,UAAU,CAAC;gBAAEH,IAAAA;gBAAII,OAAO;oBAACd;iBAAQ,CAACe,MAAM,CAACC,IAAAA,wBAAe,EAACf,OAAOgB,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKhB;YAE5H,IAAMiB,KAAKC,IAA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,EAAE;YACbF,QAAQE,MAAM,GAAGyB,IAAAA,uBAAc,EAAC,SAACH;gBAC/BxB,QAAQE,MAAM,CAACsB,MAAM,GAAGA,OAAOI,QAAQ,CAAC7C,YAAY;YACtD;YACAoB,MAAMY,KAAK,CAACC,cAAE,CAACC,IAAI,CAAC,MAAMnB,GAAGI,MAAM,CAACgB,IAAI,CAAClB,QAAQE,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACAC,MAAMY,KAAK,CAACI,qBAAK,CAACC,MAAM,CAACH,IAAI,CAAC,MAAMnB,IAAI,wCAAKb;YAAWF,UAAUA,YAAY;;QAC9EoB,MAAMkB,KAAK,CAAC,SAACC;YACX,IAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAItB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACuB,MAAM,GAAG;YACtDD,IAAIrB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACsB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAItB,MAAM;gBAAEsB,IAAIrB,MAAM;gBAAE;aAAK;YAC3CoB,MAAMxC,SAASwC,OAAOxC,SAAS,MAAMyC;QACvC;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function App(): any;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import { useStore } from 'zustand';
|
|
3
|
-
import StoreContext from '../contexts/Store.
|
|
4
|
-
import { Box } from '../ink.
|
|
5
|
-
import ChildProcess from './ChildProcess.
|
|
3
|
+
import StoreContext from '../contexts/Store.js';
|
|
4
|
+
import { Box } from '../ink.js';
|
|
5
|
+
import ChildProcess from './ChildProcess.js';
|
|
6
6
|
export default function App() {
|
|
7
7
|
const store = useContext(StoreContext);
|
|
8
8
|
const appState = useStore(store);
|
|
@@ -0,0 +1 @@
|
|
|
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.js';\nimport { Box } from '../ink.js';\nimport type { AppState, ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App() {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n\n return (\n <Box flexDirection=\"column\">\n {appState.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["React","useContext","useStore","StoreContext","Box","ChildProcess","App","store","appState","flexDirection","processes","map","item","key","id"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAAQ,QAAQ;AAC1C,SAASC,QAAQ,QAAQ,UAAU;AACnC,OAAOC,kBAAkB,uBAAuB;AAChD,SAASC,GAAG,QAAQ,YAAY;AAEhC,OAAOC,kBAAkB,oBAAoB;AAE7C,eAAe,SAASC;IACtB,MAAMC,QAAQN,WAAWE;IACzB,MAAMK,WAAWN,SAASK;IAE1B,qBACE,oBAACH;QAAIK,eAAc;OAChBD,SAASE,SAAS,CAACC,GAAG,CAAC,CAACC,qBACvB,oBAACP;YAAaQ,KAAKD,KAAKE,EAAE;YAAEF,MAAMA;;AAI1C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import c from 'ansi-colors';
|
|
2
2
|
import React, { memo, useMemo } from 'react';
|
|
3
|
-
import { Box, Text } from '../ink.
|
|
4
|
-
import ansiRegex from '../lib/ansiRegex.
|
|
5
|
-
import figures from '../lib/figures.
|
|
6
|
-
import Spinner from './Spinner.
|
|
7
|
-
import { LineType } from '../types.
|
|
3
|
+
import { Box, Text } from '../ink.js';
|
|
4
|
+
import ansiRegex from '../lib/ansiRegex.js';
|
|
5
|
+
import figures from '../lib/figures.js';
|
|
6
|
+
import Spinner from './Spinner.js';
|
|
7
|
+
import { LineType } from '../types.js';
|
|
8
8
|
const REGEX_ANSI = ansiRegex();
|
|
9
9
|
const BLANK_LINE = {
|
|
10
10
|
type: LineType.stdout,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport React, { memo, useMemo } from 'react';\nimport { Box, Text } from '../ink.js';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport Spinner from './Spinner.js';\n\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-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 // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\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":["c","React","memo","useMemo","Box","Text","ansiRegex","figures","Spinner","LineType","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","ink-text","red","cross","success","green","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","key","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":"AAAA,OAAOA,OAAO,cAAc;AAC5B,OAAOC,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAASC,GAAG,EAAEC,IAAI,QAAQ,YAAY;AACtC,OAAOC,eAAe,sBAAsB;AAC5C,OAAOC,aAAa,oBAAoB;AACxC,OAAOC,aAAa,eAAe;AAG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MA;uBAAW,oBAACC;QAAWD,MAAMA;;AACjE,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Text } from '../ink.js';\n\nexport type SpinnerProps = {\n interval: number;\n frames: string[];\n};\n\nexport default function Spinner({ interval, frames }: SpinnerProps) {\n const [index, setIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setIndex((index) => (index === frames.length - 1 ? 0 : index + 1));\n }, interval);\n return () => {\n clearInterval(timer);\n };\n }, [interval, frames]);\n\n return <Text>{`${frames[index]} `}</Text>;\n}\n"],"names":["React","useState","useEffect","Text","Spinner","interval","frames","index","setIndex","timer","setInterval","length","clearInterval"],"mappings":"AAAA,OAAOA,SAASC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AACnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,eAAe,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAgB;IAChE,MAAM,CAACC,OAAOC,SAAS,GAAGP,SAAS;IAEnCC,UAAU;QACR,MAAMO,QAAQC,YAAY;YACxBF,SAAS,CAACD,QAAWA,UAAUD,OAAOK,MAAM,GAAG,IAAI,IAAIJ,QAAQ;QACjE,GAAGF;QACH,OAAO;YACLO,cAAcH;QAChB;IACF,GAAG;QAACJ;QAAUC;KAAO;IAErB,qBAAO,oBAACH,YAAM,GAAGG,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC;AACnC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createStore } from 'zustand';
|
|
3
|
-
import App from './components/App.
|
|
4
|
-
import StoreContext from './contexts/Store.
|
|
3
|
+
import App from './components/App.js';
|
|
4
|
+
import StoreContext from './contexts/Store.js';
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import { initialize, render } from './ink.
|
|
6
|
+
import { initialize, render } from './ink.js';
|
|
7
7
|
export default function createApp() {
|
|
8
8
|
let refCount = 0;
|
|
9
9
|
let store = null;
|
|
@@ -0,0 +1 @@
|
|
|
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.js';\nimport StoreContext from './contexts/Store.js';\n\n// @ts-ignore\nimport { type Instance, initialize, render } from './ink.js';\nimport type { AppState } from './types.js';\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n return {\n retain(fn) {\n initialize(() => {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\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 fn(store);\n });\n },\n release() {\n if (--refCount > 0) return;\n if (!store) throw new Error('Expecting store');\n store = null;\n inkApp.unmount();\n inkApp = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["React","createStore","App","StoreContext","initialize","render","createApp","refCount","store","inkApp","retain","fn","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,sBAAsB;AACtC,OAAOC,kBAAkB,sBAAsB;AAE/C,aAAa;AACb,SAAwBC,UAAU,EAAEC,MAAM,QAAQ,WAAW;AAG7D,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC,QAAOC,EAAE;YACPP,WAAW;gBACT,IAAI,EAAEG,WAAW,GAAG,OAAOI,GAAGH;gBAC9B,IAAIA,OAAO,MAAM,IAAII,MAAM;gBAC3BJ,QAAQP,cAAwB,CAACY,MAAS,CAAA;wBACxCC,WAAW,EAAE;wBACbC,YAAY,CAACC,WAAYH,IAAI,CAACI,QAAW,CAAA;oCAAEH,WAAW;2CAAIG,MAAMH,SAAS;wCAAEE;qCAAQ;gCAAC,CAAA;wBACpFE,eAAe,CAACF,WAAYH,IAAI,CAACI,QAAW,CAAA;oCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;gCAAI,CAAA;oBAC3H,CAAA;gBACAX,SAASJ,qBACP,oBAACF,aAAamB,QAAQ;oBAACC,OAAOf;iCAC5B,oBAACN,aAEH;oBAAEsB,cAAc;gBAAM;gBAExB,OAAOb,GAAGH;YACZ;QACF;QACAiB;YACE,IAAI,EAAElB,WAAW,GAAG;YACpB,IAAI,CAACC,OAAO,MAAM,IAAII,MAAM;YAC5BJ,QAAQ;YACRC,OAAOiB,OAAO;YACdjB,SAAS;YACTO,QAAQW,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';
|
|
2
|
-
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback):
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
|
+
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): any;
|
|
3
3
|
export * from './types';
|
|
4
4
|
export { default as figures } from './lib/figures';
|
|
5
5
|
export { default as formatArguments } from './lib/formatArguments';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import worker from './worker.mjs';
|
|
2
1
|
function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
2
|
+
const worker = require('./worker.js');
|
|
3
3
|
if (typeof options === 'function') {
|
|
4
4
|
callback = options;
|
|
5
5
|
options = {};
|
|
@@ -9,7 +9,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
9
9
|
return new Promise((resolve, reject)=>worker(command, args, spawnOptions, options, (err, result)=>err ? reject(err) : resolve(result)));
|
|
10
10
|
}
|
|
11
11
|
const major = +process.versions.node.split('.')[0];
|
|
12
|
-
export * from './types
|
|
13
|
-
export { default as figures } from './lib/figures
|
|
14
|
-
export { default as formatArguments } from './lib/formatArguments
|
|
12
|
+
export * from './types';
|
|
13
|
+
export { default as figures } from './lib/figures';
|
|
14
|
+
export { default as formatArguments } from './lib/formatArguments';
|
|
15
15
|
export default major > 10 ? spawnTerminal : undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-cjs.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n const worker = require('./worker.js');\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["spawnTerminal","command","args","spawnOptions","options","callback","worker","require","Promise","resolve","reject","err","result","major","process","versions","node","split","default","figures","formatArguments","undefined"],"mappings":"AAEA,SAASA,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,MAAMC,SAASC,QAAQ;IAEvB,IAAI,OAAOH,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIG,QAAQ,CAACC,SAASC,SAAWJ,OAAOL,SAASC,MAAMC,cAAcC,SAAS,CAACO,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI;AAEA,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,cAAc,UAAU;AACxB,SAASC,WAAWC,OAAO,QAAQ,gBAAgB;AACnD,SAASD,WAAWE,eAAe,QAAQ,wBAAwB;AACnE,eAAeP,QAAQ,KAAKb,gBAAgBqB,UAAU"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';
|
|
2
|
+
declare function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback): void | Promise<unknown>;
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { default as figures } from './lib/figures.js';
|
|
5
|
+
export { default as formatArguments } from './lib/formatArguments.js';
|
|
6
|
+
declare const _default: typeof spawnTerminal;
|
|
7
|
+
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import worker from './worker.js';
|
|
1
2
|
function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
2
|
-
const worker = require('./worker.cjs');
|
|
3
3
|
if (typeof options === 'function') {
|
|
4
4
|
callback = options;
|
|
5
5
|
options = {};
|
|
@@ -9,7 +9,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
|
9
9
|
return new Promise((resolve, reject)=>worker(command, args, spawnOptions, options, (err, result)=>err ? reject(err) : resolve(result)));
|
|
10
10
|
}
|
|
11
11
|
const major = +process.versions.node.split('.')[0];
|
|
12
|
-
export * from './types.
|
|
13
|
-
export { default as figures } from './lib/figures.
|
|
14
|
-
export { default as formatArguments } from './lib/formatArguments.
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
export { default as figures } from './lib/figures.js';
|
|
14
|
+
export { default as formatArguments } from './lib/formatArguments.js';
|
|
15
15
|
export default major > 10 ? spawnTerminal : undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["import worker from './worker.js';\n\nimport type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types.js';\nexport { default as figures } from './lib/figures.js';\nexport { default as formatArguments } from './lib/formatArguments.js';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["worker","spawnTerminal","command","args","spawnOptions","options","callback","Promise","resolve","reject","err","result","major","process","versions","node","split","default","figures","formatArguments","undefined"],"mappings":"AAAA,OAAOA,YAAY,cAAc;AAIjC,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAON,OAAOE,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWT,OAAOE,SAASC,MAAMC,cAAcC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI;AAEA,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,cAAc,aAAa;AAC3B,SAASC,WAAWC,OAAO,QAAQ,mBAAmB;AACtD,SAASD,WAAWE,eAAe,QAAQ,2BAA2B;AACtE,eAAeP,QAAQ,KAAKX,gBAAgBmB,UAAU"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'core-js/actual/array/at.js';
|
|
2
|
+
import 'core-js/actual/object/has-own.js';
|
|
3
|
+
import 'core-js/actual/object/values.js';
|
|
4
|
+
import 'core-js/actual/string/replace-all.js';
|
|
5
|
+
import 'core-js/actual/string/trim-end.js';
|
|
6
|
+
declare const Box: any, Newline: any, Spacer: any, Static: any, Text: any, Transform: any, measureElement: any, render: any, useApp: any, useFocus: any, useFocusManager: any, useInput: any, useStderr: any, useStdin: any, useStdout: any, initialize: any;
|
|
7
|
+
export { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };
|
|
@@ -5,6 +5,7 @@ import 'core-js/actual/string/replace-all.js';
|
|
|
5
5
|
import 'core-js/actual/string/trim-end.js';
|
|
6
6
|
if (typeof process.stdout.off === 'undefined') process.stdout.off = (name, fn)=>process.stdout.removeListener(name, fn);
|
|
7
7
|
if (typeof process.stderr.off === 'undefined') process.stderr.off = (name, fn)=>process.stderr.removeListener(name, fn);
|
|
8
|
+
// @ts-ignore
|
|
8
9
|
import * as ink from '../../assets/ink.cjs';
|
|
9
10
|
const { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize } = ink.default || ink;
|
|
10
11
|
export { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/ink.ts"],"sourcesContent":["import 'core-js/actual/array/at.js';\nimport 'core-js/actual/object/has-own.js';\nimport 'core-js/actual/object/values.js';\nimport 'core-js/actual/string/replace-all.js';\nimport 'core-js/actual/string/trim-end.js';\nif (typeof process.stdout.off === 'undefined') process.stdout.off = (name, fn) => process.stdout.removeListener(name, fn);\nif (typeof process.stderr.off === 'undefined') process.stderr.off = (name, fn) => process.stderr.removeListener(name, fn);\n\n// @ts-ignore\nimport * as ink from '../../assets/ink.cjs';\nconst { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize } = ink.default || ink;\nexport { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };\n"],"names":["process","stdout","off","name","fn","removeListener","stderr","ink","Box","Newline","Spacer","Static","Text","Transform","measureElement","render","useApp","useFocus","useFocusManager","useInput","useStderr","useStdin","useStdout","initialize","default"],"mappings":"AAAA,OAAO,6BAA6B;AACpC,OAAO,mCAAmC;AAC1C,OAAO,kCAAkC;AACzC,OAAO,uCAAuC;AAC9C,OAAO,oCAAoC;AAC3C,IAAI,OAAOA,QAAQC,MAAM,CAACC,GAAG,KAAK,aAAaF,QAAQC,MAAM,CAACC,GAAG,GAAG,CAACC,MAAMC,KAAOJ,QAAQC,MAAM,CAACI,cAAc,CAACF,MAAMC;AACtH,IAAI,OAAOJ,QAAQM,MAAM,CAACJ,GAAG,KAAK,aAAaF,QAAQM,MAAM,CAACJ,GAAG,GAAG,CAACC,MAAMC,KAAOJ,QAAQM,MAAM,CAACD,cAAc,CAACF,MAAMC;AAEtH,aAAa;AACb,YAAYG,SAAS,uBAAuB;AAC5C,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGhB,IAAIiB,OAAO,IAAIjB;AAC1L,SAASC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function addLines(fn: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function concatWritable(callback: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';
|
|
2
|
+
export type TerminalOptions = {
|
|
3
|
+
group?: string;
|
|
4
|
+
expanded?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const LineType: {
|
|
7
|
+
readonly stdout: 1;
|
|
8
|
+
readonly stderr: 2;
|
|
9
|
+
};
|
|
10
|
+
export type Line = {
|
|
11
|
+
type: (typeof LineType)[keyof typeof LineType];
|
|
12
|
+
text: string;
|
|
13
|
+
};
|
|
14
|
+
export type State = 'running' | 'error' | 'success';
|
|
15
|
+
export type ChildProcess = {
|
|
16
|
+
id: string;
|
|
17
|
+
group?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
state: State;
|
|
20
|
+
lines: Line[];
|
|
21
|
+
expanded?: string;
|
|
22
|
+
};
|
|
23
|
+
export interface AppState {
|
|
24
|
+
processes: ChildProcess[];
|
|
25
|
+
addProcess: (process: ChildProcess) => void;
|
|
26
|
+
updateProcess: (process: ChildProcess) => void;
|
|
27
|
+
}
|
|
@@ -82,11 +82,11 @@ import spawn, { crossSpawn } from 'cross-spawn-cb';
|
|
|
82
82
|
import uuid from 'lil-uuid';
|
|
83
83
|
import oo from 'on-one';
|
|
84
84
|
import Queue from 'queue-cb';
|
|
85
|
-
import createApp from './createApp.
|
|
86
|
-
import addLines from './lib/addLines.
|
|
87
|
-
import concatWritable from './lib/concatWritable.
|
|
88
|
-
import formatArguments from './lib/formatArguments.
|
|
89
|
-
import { LineType } from './types.
|
|
85
|
+
import createApp from './createApp.js';
|
|
86
|
+
import addLines from './lib/addLines.js';
|
|
87
|
+
import concatWritable from './lib/concatWritable.js';
|
|
88
|
+
import formatArguments from './lib/formatArguments.js';
|
|
89
|
+
import { LineType } from './types.js';
|
|
90
90
|
const terminal = createApp();
|
|
91
91
|
export default function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
92
92
|
const { encoding, stdio } = spawnOptions, csOptions = _object_without_properties(spawnOptions, [
|
|
@@ -0,0 +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 uuid from 'lil-uuid';\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 { SpawnOptions, 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) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = uuid();\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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) => {\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\n // let rendering complete\n setTimeout(() => {\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) => {\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","uuid","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","getState","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","setTimeout","release","toString"],"mappings":"AAAA,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,UAAU,WAAW;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,QAAQ;IACnI,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAgB,GAAGJ,cAAdK,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,CAACC;YACf,MAAMC,KAAKpB;YACXmB,MAAME,QAAQ,GAAGC,UAAU,CAAC;gBAAEF;gBAAIG,OAAO;oBAACb;iBAAQ,CAACc,MAAM,CAAClB,gBAAgBK,OAAOc,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKd;YAE5H,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Q,CAACpC,YAAY;YACtD;YACAiB,MAAMS,KAAK,CAACxC,GAAGyC,IAAI,CAAC,MAAMd,GAAGG,MAAM,CAACY,IAAI,CAACd,QAAQE,MAAM,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": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"import": "./dist/esm/index-esm.
|
|
25
|
-
"require": "./dist/cjs/index-cjs.
|
|
24
|
+
"import": "./dist/esm/index-esm.js",
|
|
25
|
+
"require": "./dist/cjs/index-cjs.js"
|
|
26
26
|
},
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
|
-
"main": "dist/cjs/index-cjs.
|
|
29
|
+
"main": "dist/cjs/index-cjs.js",
|
|
30
30
|
"types": "dist/cjs/index-cjs.d.cts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"ansi-colors": "^4.1.3",
|
|
44
44
|
"core-js": "^3.42.0",
|
|
45
|
-
"cross-spawn-cb": "^2.
|
|
45
|
+
"cross-spawn-cb": "^2.2.2",
|
|
46
46
|
"lil-uuid": "^0.1.1",
|
|
47
|
-
"on-one": "^0.1.
|
|
48
|
-
"queue-cb": "^1.
|
|
47
|
+
"on-one": "^0.1.6",
|
|
48
|
+
"queue-cb": "^1.5.0",
|
|
49
49
|
"react": "^18.3.1",
|
|
50
50
|
"readable-stream": "^2.3.8",
|
|
51
51
|
"yoga-wasm-web": "^0.3.3",
|
|
@@ -1 +0,0 @@
|
|
|
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\n return (\n <Box flexDirection=\"column\">\n {appState.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["App","store","useContext","StoreContext","appState","useStore","Box","flexDirection","processes","map","item","ChildProcess","key","id"],"mappings":";;;;+BAOA;;;eAAwBA;;;6DAPU;uBACT;4DACA;mBACL;mEAEK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,SAASA;IACtB,IAAMC,QAAQC,IAAAA,iBAAU,EAACC,cAAY;IACrC,IAAMC,WAAWC,IAAAA,iBAAQ,EAACJ;IAE1B,qBACE,6BAACK,QAAG;QAACC,eAAc;OAChBH,SAASI,SAAS,CAACC,GAAG,CAAC,SAACC;6BACvB,6BAACC,qBAAY;YAACC,KAAKF,KAAKG,EAAE;YAAEH,MAAMA;;;AAI1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport React, { memo, useMemo } from 'react';\nimport { Box, Text } from '../ink.mjs';\nimport ansiRegex from '../lib/ansiRegex';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types';\nimport { LineType } from '../types';\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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-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 // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\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","ink-text","c","red","figures","cross","success","green","tick","running","Spinner","Header","memo","group","title","state","icon","Box","Text","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","key","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BAiHA;;;eAAA;;;iEAjHc;6DACuB;mBACX;gEACJ;8DACF;8DACA;qBAGK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMA,aAAaC,IAAAA,kBAAS;AAC5B,IAAMC,aAAa;IAAEC,MAAMC,eAAQ,C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QAAMC,OAAOM;;AAG1C;IAEA,yBAAe5B,IAAAA,WAAI,EAAC,SAASoC,aAAa,KAAmB;QAAnB,AAAEV,OAAF,MAAEA;IAC1C,IAAM,AAAEW,WAAaX,KAAbW;IACR,OAAOA,yBAAW,6BAACZ;QAASC,MAAMA;uBAAW,6BAACC;QAAWD,MAAMA;;AACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Text } from '../ink.mjs';\n\nexport type SpinnerProps = {\n interval: number;\n frames: string[];\n};\n\nexport default function Spinner({ interval, frames }: SpinnerProps) {\n const [index, setIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setIndex((index) => (index === frames.length - 1 ? 0 : index + 1));\n }, interval);\n return () => {\n clearInterval(timer);\n };\n }, [interval, frames]);\n\n return <Text>{`${frames[index]} `}</Text>;\n}\n"],"names":["Spinner","interval","frames","useState","index","setIndex","useEffect","timer","setInterval","length","clearInterval","Text"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DARmB;mBACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAON,SAASA,QAAQ,KAAkC;QAAhCC,WAAF,MAAEA,UAAUC,SAAZ,MAAYA;IAC1C,IAA0BC,6BAAAA,IAAAA,eAAQ,EAAC,QAA5BC,QAAmBD,cAAZE,WAAYF;IAE1BG,IAAAA,gBAAS,EAAC;QACR,IAAMC,QAAQC,YAAY;YACxBH,SAAS,SAACD;uBAAWA,UAAUF,OAAOO,MAAM,GAAG,IAAI,IAAIL,QAAQ;;QACjE,GAAGH;QACH,OAAO;YACLS,cAAcH;QAChB;IACF,GAAG;QAACN;QAAUC;KAAO;IAErB,qBAAO,6BAACS,SAAI,QAAE,AAAC,GAAgB,OAAdT,MAAM,CAACE,MAAM,EAAC;AACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
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, initialize, 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(fn) {\n initialize(() => {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\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 fn(store);\n });\n },\n release() {\n if (--refCount > 0) return;\n if (!store) throw new Error('Expecting store');\n store = null;\n inkApp.unmount();\n inkApp = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","refCount","store","inkApp","retain","fn","initialize","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;mBAGyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGnC,SAASA;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC,QAAAA,SAAAA,OAAOC,EAAE;YACPC,IAAAA,eAAU,EAAC;gBACT,IAAI,EAAEL,WAAW,GAAG,OAAOI,GAAGH;gBAC9B,IAAIA,OAAO,MAAM,IAAIK,MAAM;gBAC3BL,QAAQM,IAAAA,oBAAW,IAAa,SAACC;2BAAS;wBACxCC,WAAW,EAAE;wBACbC,YAAY,SAACC;mCAAYH,IAAI,SAACI;uCAAW;oCAAEH,WAAW,AAAC,qBAAGG,MAAMH,SAAS,SAAnB;wCAAqBE;qCAAQ;gCAAC;;;wBACpFE,eAAe,SAACF;mCAAYH,IAAI,SAACI;uCAAW;oCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,SAACC;+CAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;;gCAAI;;;oBAC3H;;gBACAb,SAASe,IAAAA,WAAM,gBACb,6BAACC,cAAY,CAACC,QAAQ;oBAACC,OAAOnB;iCAC5B,6BAACoB,YAAG,UAEN;oBAAEC,cAAc;gBAAM;gBAExB,OAAOlB,GAAGH;YACZ;QACF;QACAsB,SAAAA,SAAAA;YACE,IAAI,EAAEvB,WAAW,GAAG;YACpB,IAAI,CAACC,OAAO,MAAM,IAAIK,MAAM;YAC5BL,QAAQ;YACRC,OAAOsB,OAAO;YACdtB,SAAS;YACTS,QAAQc,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-cjs.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n const worker = require('./worker.cjs');\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["figures","formatArguments","spawnTerminal","command","args","spawnOptions","options","callback","worker","require","Promise","resolve","reject","err","result","major","process","versions","node","split","undefined"],"mappings":";;;;;;;;;;;IAoBA,OAAsD;eAAtD;;IAFoBA,OAAO;eAAPA,gBAAO;;IACPC,eAAe;eAAfA,wBAAe;;;qBAFrB;8DACqB;sEACQ;;;;;;;;;;;;;;;;;;;AAjB3C,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAMC,SAASC,QAAQ;IAEvB,IAAI,OAAOH,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIG,QAAQ,SAACC,SAASC;eAAWJ,OAAOL,SAASC,MAAMC,cAAcC,SAAS,SAACO,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI;AAEA,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAKlD,WAAeJ,QAAQ,KAAKb,gBAAgBkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["import worker from './worker';\n\nimport type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["figures","formatArguments","spawnTerminal","command","args","spawnOptions","options","callback","worker","Promise","resolve","reject","err","result","major","process","versions","node","split","undefined"],"mappings":";;;;;;;;;;;IAoBA,OAAsD;eAAtD;;IAFoBA,OAAO;eAAPA,gBAAO;;IACPC,eAAe;eAAfA,wBAAe;;;6DAnBhB;qBAiBL;8DACqB;sEACQ;;;;;;;;;;;;;;;;;;;AAf3C,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,eAAM,EAACL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIE,QAAQ,SAACC,SAASC;eAAWH,IAAAA,eAAM,EAACL,SAASC,MAAMC,cAAcC,SAAS,SAACM,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI;AAEA,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAKlD,WAAeJ,QAAQ,KAAKZ,gBAAgBiB"}
|
package/dist/cjs/ink.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/ink.mjs"],"sourcesContent":["import 'core-js/actual/array/at.js';\nimport 'core-js/actual/object/has-own.js';\nimport 'core-js/actual/object/values.js';\nimport 'core-js/actual/string/replace-all.js';\nimport 'core-js/actual/string/trim-end.js';\nif (typeof process.stdout.off === 'undefined') process.stdout.off = (name, fn) => process.stdout.removeListener(name, fn);\nif (typeof process.stderr.off === 'undefined') process.stderr.off = (name, fn) => process.stderr.removeListener(name, fn);\n\nimport * as ink from '../../assets/ink.cjs';\nconst { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize } = ink.default || ink;\nexport { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };\n"],"names":["Box","Newline","Spacer","Static","Text","Transform","initialize","measureElement","render","useApp","useFocus","useFocusManager","useInput","useStderr","useStdin","useStdout","process","stdout","off","name","fn","removeListener","stderr","ink","default"],"mappings":";;;;;;;;;;;IAUSA,GAAG;eAAHA;;IAAKC,OAAO;eAAPA;;IAASC,MAAM;eAANA;;IAAQC,MAAM;eAANA;;IAAQC,IAAI;eAAJA;;IAAMC,SAAS;eAATA;;IAAgHC,UAAU;eAAVA;;IAArGC,cAAc;eAAdA;;IAAgBC,MAAM;eAANA;;IAAQC,MAAM;eAANA;;IAAQC,QAAQ;eAARA;;IAAUC,eAAe;eAAfA;;IAAiBC,QAAQ;eAARA;;IAAUC,SAAS;eAATA;;IAAWC,QAAQ;eAARA;;IAAUC,SAAS;eAATA;;;QAV3I;QACA;QACA;QACA;QACA;8DAIc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHrB,IAAI,OAAOC,QAAQC,MAAM,CAACC,GAAG,KAAK,aAAaF,QAAQC,MAAM,CAACC,GAAG,GAAG,SAACC,MAAMC;WAAOJ,QAAQC,MAAM,CAACI,cAAc,CAACF,MAAMC;;AACtH,IAAI,OAAOJ,QAAQM,MAAM,CAACJ,GAAG,KAAK,aAAaF,QAAQM,MAAM,CAACJ,GAAG,GAAG,SAACC,MAAMC;WAAOJ,QAAQM,MAAM,CAACD,cAAc,CAACF,MAAMC;;AAGtH,IAA2KG,OAAAA,QAAIC,OAAO,IAAID,SAAlLvB,MAAmKuB,KAAnKvB,KAAKC,UAA8JsB,KAA9JtB,SAASC,SAAqJqB,KAArJrB,QAAQC,SAA6IoB,KAA7IpB,QAAQC,OAAqImB,KAArInB,MAAMC,YAA+HkB,KAA/HlB,WAAWE,iBAAoHgB,KAApHhB,gBAAgBC,SAAoGe,KAApGf,QAAQC,SAA4Fc,KAA5Fd,QAAQC,WAAoFa,KAApFb,UAAUC,kBAA0EY,KAA1EZ,iBAAiBC,WAAyDW,KAAzDX,UAAUC,YAA+CU,KAA/CV,WAAWC,WAAoCS,KAApCT,UAAUC,YAA0BQ,KAA1BR,WAAWT,aAAeiB,KAAfjB"}
|
package/dist/cjs/worker.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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';\nimport formatArguments from './lib/formatArguments';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = uuid();\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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) => {\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\n // let rendering complete\n setTimeout(() => {\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) => {\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","uuid","getState","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","setTimeout","release","concatWritable","toString"],"mappings":"AAAA,aAAa;;;;;+BAgBb;;;eAAwBA;;;oEAf4B;8DACnC;4DACF;8DACG;gEAEI;+DACD;qEACM;sEACC;qBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,kBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAAQ;IACnI,IAAQC,WAAkCH,aAAlCG,UAAUC,QAAwBJ,aAAxBI,OAAUC,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,SAACC;YACf,IAAMC,KAAKC,IAAAA,gBAAI;YACfF,MAAMG,QAAQ,GAAGC,UAAU,CAAC;gBAAEH,IAAAA;gBAAII,OAAO;oBAACd;iBAAQ,CAACe,MAAM,CAACC,IAAAA,wBAAe,EAACf,OAAOgB,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKhB;YAE5H,IAAMiB,KAAKC,IAAAA,wBAAU,EAACrB,SAASC,MAAMM;YACrC,IAAMe,UAAU;gBAAEC,QAAQ;gBAAMC,QAAQ;YAAK;YAE7C,IAAMC,QAAQ,IAAIC,gBAAK;YACvB,IAAIN,GAAGG,MAAM,EAAE;gBACbD,QAAQC,MAAM,GAAGI,IAAAA,iBAAQ,EAAC,SAACR;oBACzB,IAAMS,OAAOnB,MAAMG,QAAQ,GAAGiB,SAAS,CAACC,IAAI,CAAC,SAACC;+BAAMA,EAAErB,EAAE,KAAKA;;oBAC7DD,MAAMG,QAAQ,GAAGoB,aAAa,CAAC,wCAAKJ;wBAAM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b;YAAWF,UAAUA,YAAY;;QAC9EoB,MAAMkB,KAAK,CAAC,SAACC;YACX,IAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAItB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACuB,MAAM,GAAG;YACtDD,IAAIrB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACsB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAItB,MAAM;gBAAEsB,IAAIrB,MAAM;gBAAE;aAAK;YAC3CoB,MAAMxC,SAASwC,OAAOxC,SAAS,MAAMyC;QACvC;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
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\n return (\n <Box flexDirection=\"column\">\n {appState.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["React","useContext","useStore","StoreContext","Box","ChildProcess","App","store","appState","flexDirection","processes","map","item","key","id"],"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;IAE1B,qBACE,oBAACH;QAAIK,eAAc;OAChBD,SAASE,SAAS,CAACC,GAAG,CAAC,CAACC,qBACvB,oBAACP;YAAaQ,KAAKD,KAAKE,EAAE;YAAEF,MAAMA;;AAI1C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport React, { memo, useMemo } from 'react';\nimport { Box, Text } from '../ink.mjs';\nimport ansiRegex from '../lib/ansiRegex';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types';\nimport { LineType } from '../types';\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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-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 // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\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":["c","React","memo","useMemo","Box","Text","ansiRegex","figures","Spinner","LineType","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","ink-text","red","cross","success","green","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","key","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":"AAAA,OAAOA,OAAO,cAAc;AAC5B,OAAOC,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAASC,GAAG,EAAEC,IAAI,QAAQ,aAAa;AACvC,OAAOC,eAAe,mBAAmB;AACzC,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,aAAa,YAAY;AAGhC,SAASC,QAAQ,QAAQ,WAAW;AAEpC,MAA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AAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Text } from '../ink.mjs';\n\nexport type SpinnerProps = {\n interval: number;\n frames: string[];\n};\n\nexport default function Spinner({ interval, frames }: SpinnerProps) {\n const [index, setIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setIndex((index) => (index === frames.length - 1 ? 0 : index + 1));\n }, interval);\n return () => {\n clearInterval(timer);\n };\n }, [interval, frames]);\n\n return <Text>{`${frames[index]} `}</Text>;\n}\n"],"names":["React","useState","useEffect","Text","Spinner","interval","frames","index","setIndex","timer","setInterval","length","clearInterval"],"mappings":"AAAA,OAAOA,SAASC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AACnD,SAASC,IAAI,QAAQ,aAAa;AAOlC,eAAe,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAgB;IAChE,MAAM,CAACC,OAAOC,SAAS,GAAGP,SAAS;IAEnCC,UAAU;QACR,MAAMO,QAAQC,YAAY;YACxBF,SAAS,CAACD,QAAWA,UAAUD,OAAOK,MAAM,GAAG,IAAI,IAAIJ,QAAQ;QACjE,GAAGF;QACH,OAAO;YACLO,cAAcH;QAChB;IACF,GAAG;QAACJ;QAAUC;KAAO;IAErB,qBAAO,oBAACH,YAAM,GAAGG,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC;AACnC"}
|
|
@@ -1 +0,0 @@
|
|
|
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, initialize, 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(fn) {\n initialize(() => {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\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 fn(store);\n });\n },\n release() {\n if (--refCount > 0) return;\n if (!store) throw new Error('Expecting store');\n store = null;\n inkApp.unmount();\n inkApp = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["React","createStore","App","StoreContext","initialize","render","createApp","refCount","store","inkApp","retain","fn","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,UAAU,EAAEC,MAAM,QAAQ,YAAY;AAG9D,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,OAAO;QACLC,QAAOC,EAAE;YACPP,WAAW;gBACT,IAAI,EAAEG,WAAW,GAAG,OAAOI,GAAGH;gBAC9B,IAAIA,OAAO,MAAM,IAAII,MAAM;gBAC3BJ,QAAQP,cAAwB,CAACY,MAAS,CAAA;wBACxCC,WAAW,EAAE;wBACbC,YAAY,CAACC,WAAYH,IAAI,CAACI,QAAW,CAAA;oCAAEH,WAAW;2CAAIG,MAAMH,SAAS;wCAAEE;qCAAQ;gCAAC,CAAA;wBACpFE,eAAe,CAACF,WAAYH,IAAI,CAACI,QAAW,CAAA;oCAAEH,WAAWG,MAAMH,SAAS,CAACK,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKL,SAAQK,EAAE,GAAGL,WAAUI;gCAAI,CAAA;oBAC3H,CAAA;gBACAX,SAASJ,qBACP,oBAACF,aAAamB,QAAQ;oBAACC,OAAOf;iCAC5B,oBAACN,aAEH;oBAAEsB,cAAc;gBAAM;gBAExB,OAAOb,GAAGH;YACZ;QACF;QACAiB;YACE,IAAI,EAAElB,WAAW,GAAG;YACpB,IAAI,CAACC,OAAO,MAAM,IAAII,MAAM;YAC5BJ,QAAQ;YACRC,OAAOiB,OAAO;YACdjB,SAAS;YACTO,QAAQW,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-cjs.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n const worker = require('./worker.cjs');\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["spawnTerminal","command","args","spawnOptions","options","callback","worker","require","Promise","resolve","reject","err","result","major","process","versions","node","split","default","figures","formatArguments","undefined"],"mappings":"AAEA,SAASA,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,MAAMC,SAASC,QAAQ;IAEvB,IAAI,OAAOH,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIG,QAAQ,CAACC,SAASC,SAAWJ,OAAOL,SAASC,MAAMC,cAAcC,SAAS,CAACO,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI;AAEA,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,cAAc,UAAU;AACxB,SAASC,WAAWC,OAAO,QAAQ,gBAAgB;AACnD,SAASD,WAAWE,eAAe,QAAQ,wBAAwB;AACnE,eAAeP,QAAQ,KAAKb,gBAAgBqB,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["import worker from './worker';\n\nimport type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport { default as formatArguments } from './lib/formatArguments';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["worker","spawnTerminal","command","args","spawnOptions","options","callback","Promise","resolve","reject","err","result","major","process","versions","node","split","default","figures","formatArguments","undefined"],"mappings":"AAAA,OAAOA,YAAY,WAAW;AAI9B,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAON,OAAOE,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWT,OAAOE,SAASC,MAAMC,cAAcC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI;AAEA,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,cAAc,UAAU;AACxB,SAASC,WAAWC,OAAO,QAAQ,gBAAgB;AACnD,SAASD,WAAWE,eAAe,QAAQ,wBAAwB;AACnE,eAAeP,QAAQ,KAAKX,gBAAgBmB,UAAU"}
|
package/dist/esm/ink.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/ink.mjs"],"sourcesContent":["import 'core-js/actual/array/at.js';\nimport 'core-js/actual/object/has-own.js';\nimport 'core-js/actual/object/values.js';\nimport 'core-js/actual/string/replace-all.js';\nimport 'core-js/actual/string/trim-end.js';\nif (typeof process.stdout.off === 'undefined') process.stdout.off = (name, fn) => process.stdout.removeListener(name, fn);\nif (typeof process.stderr.off === 'undefined') process.stderr.off = (name, fn) => process.stderr.removeListener(name, fn);\n\nimport * as ink from '../../assets/ink.cjs';\nconst { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize } = ink.default || ink;\nexport { Box, Newline, Spacer, Static, Text, Transform, measureElement, render, useApp, useFocus, useFocusManager, useInput, useStderr, useStdin, useStdout, initialize };\n"],"names":["process","stdout","off","name","fn","removeListener","stderr","ink","Box","Newline","Spacer","Static","Text","Transform","measureElement","render","useApp","useFocus","useFocusManager","useInput","useStderr","useStdin","useStdout","initialize","default"],"mappings":"AAAA,OAAO,6BAA6B;AACpC,OAAO,mCAAmC;AAC1C,OAAO,kCAAkC;AACzC,OAAO,uCAAuC;AAC9C,OAAO,oCAAoC;AAC3C,IAAI,OAAOA,QAAQC,MAAM,CAACC,GAAG,KAAK,aAAaF,QAAQC,MAAM,CAACC,GAAG,GAAG,CAACC,MAAMC,KAAOJ,QAAQC,MAAM,CAACI,cAAc,CAACF,MAAMC;AACtH,IAAI,OAAOJ,QAAQM,MAAM,CAACJ,GAAG,KAAK,aAAaF,QAAQM,MAAM,CAACJ,GAAG,GAAG,CAACC,MAAMC,KAAOJ,QAAQM,MAAM,CAACD,cAAc,CAACF,MAAMC;AAEtH,YAAYG,SAAS,uBAAuB;AAC5C,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGhB,IAAIiB,OAAO,IAAIjB;AAC1L,SAASC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,GAAG"}
|
package/dist/esm/worker.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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';\nimport formatArguments from './lib/formatArguments';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = uuid();\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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.getState().processes.find((x) => x.id === id);\n store.getState().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) => {\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\n // let rendering complete\n setTimeout(() => {\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) => {\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","uuid","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","getState","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","setTimeout","release","toString"],"mappings":"AAAA,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,UAAU,WAAW;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,cAAc;AACpC,OAAOC,cAAc,iBAAiB;AACtC,OAAOC,oBAAoB,uBAAuB;AAClD,OAAOC,qBAAqB,wBAAwB;AAGpD,SAASC,QAAQ,QAAQ,UAAU;AAEnC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAAQ;IACnI,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAgB,GAAGJ,cAAdK,uCAAcL;QAAlCG;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AAK,CAACxC,GAAGyC,IAAI,CAAC,MAAMd,GAAGE,MAAM,CAACa,IAAI,CAACd,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIF,GAAGG,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAG1B,eAAe,CAAC2C;gBAC/BnB,QAAQE,MAAM,CAACiB,MAAM,GAAGA,OAAOG,QAAQ,CAACpC,YAAY;YACtD;YACAiB,MAAMS,KAAK,CAACxC,GAAGyC,IAAI,CAAC,MAAMd,GAAGG,MAAM,CAACY,IAAI,CAACd,QAAQE,MAAM,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"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|