spawn-term 0.1.24 → 0.1.26

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.
@@ -67,7 +67,7 @@ function App() {
67
67
  }, appState.processes.map(function(item) {
68
68
  return /*#__PURE__*/ _react.default.createElement(_ChildProcess.default, {
69
69
  key: item.id,
70
- id: item.id
70
+ item: item
71
71
  });
72
72
  }));
73
73
  }
@@ -1 +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';\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} id={item.id} />\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;YAAEA,IAAIH,KAAKG,EAAE;;;AAI/C"}
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"}
@@ -5,12 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return ChildProcess;
8
+ return _default;
9
9
  }
10
10
  });
11
11
  var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
- var _zustand = require("zustand");
13
- var _Store = /*#__PURE__*/ _interop_require_default(require("../contexts/Store.cjs"));
14
12
  var _ink = require("../ink.cjs");
15
13
  var _ansiRegex = /*#__PURE__*/ _interop_require_default(require("../lib/ansiRegex.cjs"));
16
14
  var _figures = /*#__PURE__*/ _interop_require_default(require("../lib/figures.cjs"));
@@ -62,7 +60,6 @@ function _interop_require_wildcard(obj, nodeInterop) {
62
60
  }
63
61
  return newObj;
64
62
  }
65
- var ansiRegex = (0, _ansiRegex.default)();
66
63
  // From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2
67
64
  var spinner = {
68
65
  interval: 80,
@@ -88,25 +85,26 @@ var ICONS = {
88
85
  }, _figures.default.tick),
89
86
  running: /*#__PURE__*/ _react.default.createElement(_Spinner.default, spinner)
90
87
  };
91
- function Header(param) {
92
- var item = param.item;
93
- var group = item.group, title = item.title, state = item.state;
88
+ var Header = /*#__PURE__*/ (0, _react.memo)(function Header(param) {
89
+ var group = param.group, title = param.title, state = param.state;
94
90
  var icon = ICONS[state];
95
91
  return /*#__PURE__*/ _react.default.createElement(_ink.Box, null, /*#__PURE__*/ _react.default.createElement(_ink.Box, {
96
92
  marginRight: 1
97
93
  }, icon), group && /*#__PURE__*/ _react.default.createElement(_ink.Text, {
98
94
  bold: true
99
95
  }, "".concat(group).concat(_figures.default.pointer, " ")), /*#__PURE__*/ _react.default.createElement(_ink.Text, null, title));
100
- }
101
- function Output(param) {
96
+ }, function(a, b) {
97
+ return a.group === b.group && a.title === b.title && a.state === b.state;
98
+ });
99
+ var Output = /*#__PURE__*/ (0, _react.memo)(function Output(param) {
102
100
  var output = param.output;
103
101
  return /*#__PURE__*/ _react.default.createElement(_ink.Box, {
104
102
  marginLeft: 2
105
103
  }, /*#__PURE__*/ _react.default.createElement(_ink.Text, {
106
104
  color: "gray"
107
105
  }, output.text));
108
- }
109
- function Lines(param) {
106
+ });
107
+ var Lines = /*#__PURE__*/ (0, _react.memo)(function Lines(param) {
110
108
  var lines = param.lines;
111
109
  return /*#__PURE__*/ _react.default.createElement(_ink.Box, {
112
110
  flexDirection: "column",
@@ -115,51 +113,78 @@ function Lines(param) {
115
113
  return(// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
116
114
  /*#__PURE__*/ _react.default.createElement(_ink.Box, {
117
115
  key: index,
118
- flexDirection: "column",
119
- height: 1
116
+ flexDirection: "column"
120
117
  }, /*#__PURE__*/ _react.default.createElement(_ink.Text, {
121
- color: line.type === _types.LineType.stderr ? 'red' : 'black'
118
+ color: line.type === _types.DataType.stderr ? 'red' : 'black'
122
119
  }, line.text)));
123
120
  }));
124
- }
125
- function ChildProcess(param) {
126
- var id = param.id;
127
- var store = (0, _react.useContext)(_Store.default);
128
- var appState = (0, _zustand.useStore)(store);
129
- var item = appState.processes.find(function(x) {
130
- return x.id === id;
131
- });
132
- var state = item.state, lines = item.lines, expanded = item.expanded;
133
- if (expanded) {
134
- return /*#__PURE__*/ _react.default.createElement(_ink.Box, {
135
- flexDirection: "column"
136
- }, /*#__PURE__*/ _react.default.createElement(Header, {
137
- item: item
138
- }), /*#__PURE__*/ _react.default.createElement(Lines, {
139
- lines: lines
140
- }));
141
- }
121
+ });
122
+ var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(param) {
123
+ var item = param.item;
124
+ var data = item.data;
125
+ return /*#__PURE__*/ _react.default.createElement(_ink.Box, {
126
+ flexDirection: "column"
127
+ }, /*#__PURE__*/ _react.default.createElement(Header, {
128
+ group: item.group,
129
+ title: item.title,
130
+ state: item.state
131
+ }), /*#__PURE__*/ _react.default.createElement(Lines, {
132
+ lines: data
133
+ }));
134
+ });
135
+ var linesRegex = /\r\n|\n/g;
136
+ var ansiRegex = (0, _ansiRegex.default)();
137
+ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(param) {
138
+ var item = param.item;
139
+ var state = item.state, data = item.data;
140
+ var lines = (0, _react.useMemo)(function() {
141
+ var lines = [];
142
+ data.forEach(function(x) {
143
+ x.text.split(linesRegex).forEach(function(text) {
144
+ return lines.push({
145
+ type: x.type,
146
+ text: text.replace(ansiRegex, '')
147
+ });
148
+ });
149
+ });
150
+ return lines;
151
+ }, [
152
+ data
153
+ ]);
142
154
  // remove ansi codes when displaying single lines
143
- var cleaned = lines.map(function(x) {
144
- return {
145
- type: x.type,
146
- text: x.text.replace(ansiRegex, '')
147
- };
148
- });
149
- var errors = cleaned.filter(function(line) {
150
- return line.type === _types.LineType.stderr;
151
- });
152
- var output = cleaned.filter(function(line) {
153
- return line.text.length > 0;
154
- }).pop();
155
+ var errors = (0, _react.useMemo)(function() {
156
+ return lines.filter(function(line) {
157
+ return line.type === _types.DataType.stderr;
158
+ });
159
+ }, [
160
+ lines
161
+ ]);
162
+ var output = (0, _react.useMemo)(function() {
163
+ return lines.filter(function(line) {
164
+ return line.text.length > 0;
165
+ }).pop();
166
+ }, [
167
+ lines
168
+ ]);
155
169
  return /*#__PURE__*/ _react.default.createElement(_ink.Box, {
156
170
  flexDirection: "column"
157
171
  }, /*#__PURE__*/ _react.default.createElement(Header, {
158
- item: item
172
+ group: item.group,
173
+ title: item.title,
174
+ state: item.state
159
175
  }), state === 'running' && output && /*#__PURE__*/ _react.default.createElement(Output, {
160
176
  output: output
161
177
  }), errors.length > 0 && /*#__PURE__*/ _react.default.createElement(Lines, {
162
178
  lines: errors
163
179
  }));
164
- }
180
+ });
181
+ var _default = /*#__PURE__*/ (0, _react.memo)(function ChildProcess(param) {
182
+ var item = param.item;
183
+ var expanded = item.expanded;
184
+ return expanded ? /*#__PURE__*/ _react.default.createElement(Expanded, {
185
+ item: item
186
+ }) : /*#__PURE__*/ _react.default.createElement(Contracted, {
187
+ item: item
188
+ });
189
+ });
165
190
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box, Text } from '../ink.mjs';\nimport _ansiRegex from '../lib/ansiRegex';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { AppState } from '../types';\nimport { LineType } from '../types';\n\nconst ansiRegex = _ansiRegex();\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst spinner = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...spinner} />,\n};\n\ntype ChildProcessProps = {\n id: string;\n};\n\nfunction Header({ item }) {\n const { group, title, state } = item;\n const icon = ICONS[state];\n\n return (\n <Box>\n <Box marginRight={1}>{icon}</Box>\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n}\n\nfunction Output({ output }) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{output.text}</Text>\n </Box>\n );\n}\n\nfunction Lines({ lines }) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text color={line.type === LineType.stderr ? 'red' : 'black'}>{line.text}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nexport default function ChildProcess({ id }: ChildProcessProps) {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const item = appState.processes.find((x) => x.id === id);\n const { state, lines, expanded } = item;\n\n if (expanded) {\n return (\n <Box flexDirection=\"column\">\n <Header item={item} />\n <Lines lines={lines} />\n </Box>\n );\n }\n // remove ansi codes when displaying single lines\n const cleaned = lines.map((x) => ({ type: x.type, text: x.text.replace(ansiRegex, '') }));\n const errors = cleaned.filter((line) => line.type === LineType.stderr);\n const output = cleaned.filter((line) => line.text.length > 0).pop();\n\n return (\n <Box flexDirection=\"column\">\n <Header item={item} />\n {state === 'running' && output && <Output output={output} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n}\n"],"names":["ChildProcess","ansiRegex","_ansiRegex","spinner","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","Header","item","group","title","state","icon","Box","marginRight","bold","pointer","Output","output","marginLeft","text","Lines","lines","flexDirection","map","line","index","key","height","type","LineType","stderr","id","store","useContext","StoreContext","appState","useStore","processes","find","x","expanded","cleaned","replace","errors","filter","length","pop"],"mappings":";;;;+BA+DA;;;eAAwBA;;;6DA/DU;uBACT;4DACA;mBACC;gEACH;8DACH;8DACA;qBAGK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,YAAYC,IAAAA,kBAAU;AAE5B,oHAAoH;AACpH,IAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,IAAMC,QAAQ;IACZC,qBAAO,6BAACC,SAAI;QAACC,OAAM;OAAOC,gBAAO,CAACC,KAAK;IACvCC,uBAAS,6BAACJ,SAAI;QAACC,OAAM;OAASC,gBAAO,CAACG,IAAI;IAC1CC,uBAAS,6BAACC,gBAAO,EAAKZ;AACxB;AAMA,SAASa,OAAO,KAAQ;QAAR,AAAEC,OAAF,MAAEA;IAChB,IAAQC,QAAwBD,KAAxBC,OAAOC,QAAiBF,KAAjBE,OAAOC,QAAUH,KAAVG;IACtB,IAAMC,OAAOf,KAAK,CAACc,MAAM;IAEzB,qBACE,6BAACE,QAAG,sBACF,6BAACA,QAAG;QAACC,aAAa;OAAIF,OACrBH,uBAAS,6BAACV,SAAI;QAACgB,MAAAA;OAAM,AAAC,GAAUd,OAARQ,OAAwB,OAAhBR,gBAAO,CAACe,OAAO,EAAC,qBACjD,6BAACjB,SAAI,QAAEW;AAGb;AAEA,SAASO,OAAO,KAAU;QAAV,AAAEC,SAAF,MAAEA;IAChB,qBACE,6BAACL,QAAG;QAACM,YAAY;qBACf,6BAACpB,SAAI;QAACC,OAAM;OAAQkB,OAAOE,IAAI;AAGrC;AAEA,SAASC,MAAM,KAAS;QAAT,AAAEC,QAAF,MAAEA;IACf,qBACE,6BA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OsB;;AAG1C"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import 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, Data, State } from '../types';\nimport { DataType } from '../types';\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst spinner = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...spinner} />,\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n <Box marginRight={1}>{icon}</Box>\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 OutputProps = {\n output: Data;\n};\n\nconst Output = memo(function Output({ output }: OutputProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{output.text}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Data[];\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\">\n <Text color={line.type === DataType.stderr ? 'red' : 'black'}>{line.text}</Text>\n </Box>\n ))}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { data } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={data} />\n </Box>\n );\n});\n\nconst linesRegex = /\\r\\n|\\n/g;\nconst ansiRegex = _ansiRegex();\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, data } = item;\n\n const lines = useMemo(() => {\n const lines = [];\n data.forEach((x) => {\n x.text.split(linesRegex).forEach((text) => lines.push({ type: x.type, text: text.replace(ansiRegex, '') }));\n });\n return lines;\n }, [data]);\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === DataType.stderr), [lines]);\n const output = useMemo(() => lines.filter((line) => line.text.length > 0).pop(), [lines]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && output && <Output output={output} />}\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":["spinner","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","Header","memo","group","title","state","icon","Box","marginRight","bold","pointer","a","b","Output","output","marginLeft","text","Lines","lines","flexDirection","map","line","index","key","type","DataType","stderr","Expanded","item","data","linesRegex","ansiRegex","_ansiRegex","Contracted","useMemo","forEach","x","split","push","replace","errors","filter","length","pop","ChildProcess","expanded"],"mappings":";;;;+BAiHA;;;eAAA;;;6DAjHqC;mBACX;gEACH;8DACH;8DACA;qBAGK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMzB,oHAAoH;AACpH,IAAMA,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,IAAMC,QAAQ;IACZC,qBAAO,6BAACC,SAAI;QAACC,OAAM;OAAOC,gBAAO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UAAU,aAAaS,wBAAU,6BAACD;QAAOC,QAAQA;QACjD0B,OAAOE,MAAM,GAAG,mBAAK,6BAACzB;QAAMC,OAAOsB;;AAG1C;IAEA,yBAAetC,IAAAA,WAAI,EAAC,SAAS0C,aAAa,KAAmB;QAAnB,AAAEhB,OAAF,MAAEA;IAC1C,IAAM,AAAEiB,WAAajB,KAAbiB;IACR,OAAOA,yBAAW,6BAAClB;QAASC,MAAMA;uBAAW,6BAACK;QAAWL,MAAMA;;AACjE"}
@@ -9,24 +9,13 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _readablestream = require("readable-stream");
12
- var regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
13
12
  function addLines(fn) {
14
- var last = '';
15
13
  var stream = new _readablestream.Writable({
16
- write: function write(chunk, _enc, callback) {
17
- var more = last + chunk.toString('utf8');
18
- var lines = more.split(regEx);
19
- last = lines.pop();
20
- if (lines.length) fn(lines);
14
+ write: function write(data, _enc, callback) {
15
+ fn(data);
21
16
  callback();
22
17
  }
23
18
  });
24
- stream.on('finish', function() {
25
- if (last.length) fn([
26
- last
27
- ]);
28
- last = '';
29
- });
30
19
  return stream;
31
20
  }
32
21
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addData.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nexport default function addLines(fn) {\n const stream = new Writable({\n write(data, _enc, callback) {\n fn(data);\n callback();\n },\n });\n return stream;\n}\n"],"names":["addLines","fn","stream","Writable","write","data","_enc","callback"],"mappings":";;;;+BAEA;;;eAAwBA;;;8BAFC;AAEV,SAASA,SAASC,EAAE;IACjC,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,IAAI,EAAEC,IAAI,EAAEC,QAAQ;YACxBN,GAAGI;YACHE;QACF;IACF;IACA,OAAOL;AACT"}
@@ -3,15 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "LineType", {
6
+ Object.defineProperty(exports, "DataType", {
7
7
  enumerable: true,
8
8
  get: function() {
9
- return LineType;
9
+ return DataType;
10
10
  }
11
11
  });
12
- var LineType = /*#__PURE__*/ function(LineType) {
13
- LineType[LineType["stdout"] = 1] = "stdout";
14
- LineType[LineType["stderr"] = 2] = "stderr";
15
- return LineType;
12
+ var DataType = /*#__PURE__*/ function(DataType) {
13
+ DataType[DataType["stdout"] = 1] = "stdout";
14
+ DataType[DataType["stderr"] = 2] = "stderr";
15
+ return DataType;
16
16
  }({});
17
17
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n group?: string;\n expanded?: string;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["LineType"],"mappings":"AAAA,aAAa;;;;;+BAQDA;;;eAAAA;;;AAAL,IAAA,AAAKA,kCAAAA;;;WAAAA"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: string;\n};\n\nexport enum DataType {\n stdout = 1,\n stderr = 2,\n}\nexport type Data = {\n type: DataType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n data: Data[];\n expanded?: string;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["DataType"],"mappings":"AAAA,aAAa;;;;;+BAQDA;;;eAAAA;;;AAAL,IAAA,AAAKA,kCAAAA;;;WAAAA"}
@@ -14,7 +14,7 @@ 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
16
  var _createApp = /*#__PURE__*/ _interop_require_default(require("./createApp.cjs"));
17
- var _addLines = /*#__PURE__*/ _interop_require_default(require("./lib/addLines.cjs"));
17
+ var _addData = /*#__PURE__*/ _interop_require_default(require("./lib/addData.cjs"));
18
18
  var _concatWritable = /*#__PURE__*/ _interop_require_default(require("./lib/concatWritable.cjs"));
19
19
  var _formatArguments = /*#__PURE__*/ _interop_require_default(require("./lib/formatArguments.cjs"));
20
20
  var _types = require("./types.cjs");
@@ -158,7 +158,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
158
158
  command
159
159
  ].concat((0, _formatArguments.default)(args)).join(' '),
160
160
  state: 'running',
161
- lines: []
161
+ data: []
162
162
  }, options));
163
163
  var cp = (0, _crossspawncb.crossSpawn)(command, args, csOptions);
164
164
  var outputs = {
@@ -167,18 +167,17 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
167
167
  };
168
168
  var queue = new _queuecb.default();
169
169
  if (cp.stdout) {
170
- outputs.stdout = (0, _addLines.default)(function(texts) {
170
+ outputs.stdout = (0, _addData.default)(function(data) {
171
171
  var item = store.getState().processes.find(function(x) {
172
172
  return x.id === id;
173
173
  });
174
- var lines = item.lines.concat(texts.map(function(text) {
175
- return {
176
- type: _types.LineType.stdout,
177
- text: text
178
- };
179
- }));
180
174
  store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
181
- lines: lines
175
+ data: item.data.concat([
176
+ {
177
+ type: _types.DataType.stdout,
178
+ text: data.toString('utf8')
179
+ }
180
+ ])
182
181
  }));
183
182
  });
184
183
  queue.defer(_onone.default.bind(null, cp.stdout.pipe(outputs.stdout), [
@@ -189,18 +188,17 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
189
188
  ]));
190
189
  }
191
190
  if (cp.stderr) {
192
- outputs.stderr = (0, _addLines.default)(function(texts) {
191
+ outputs.stderr = (0, _addData.default)(function(data) {
193
192
  var item = store.getState().processes.find(function(x) {
194
193
  return x.id === id;
195
194
  });
196
- var lines = item.lines.concat(texts.map(function(text) {
197
- return {
198
- type: _types.LineType.stderr,
199
- text: text
200
- };
201
- }));
202
195
  store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
203
- lines: lines
196
+ data: item.data.concat([
197
+ {
198
+ type: _types.DataType.stderr,
199
+ text: data.toString('utf8')
200
+ }
201
+ ])
204
202
  }));
205
203
  });
206
204
  queue.defer(_onone.default.bind(null, cp.stderr.pipe(outputs.stderr), [
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport 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((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stdout, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stderr, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n 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","texts","item","processes","find","x","map","text","type","LineType","updateProcess","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,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CAAC9C,YAAY;YACtD;YACAoB,MAAMa,KAAK,CAACC,cAAE,CAACC,IAAI,CAAC,MAAMpB,GAAGG,MAAM,CAACkB,IAAI,CAACnB,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIH,GAAGI,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAG0B,IAAAA,uBAAc,EAAC,SAACH;gBAC/BzB,QAAQE,MAAM,CAACuB,MAAM,GAAGA,OAAOI,QAAQ,CAAC9C,YAAY;YACtD;YACAoB,MAAMa,KAAK,CAACC,cAAE,CAACC,IAAI,CAAC,MAAMpB,GAAGI,MAAM,CAACiB,IAAI,CAACnB,QAAQE,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACAC,MAAMa,KAAK,CAACI,qBAAK,CAACC,MAAM,CAACH,IAAI,CAAC,MAAMpB,IAAI,wCAAKb;YAAWF,UAAUA,YAAY;;QAC9EoB,MAAMmB,KAAK,CAAC,SAACC;YACX,IAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAIvB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACwB,MAAM,GAAG;YACtDD,IAAItB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACuB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIvB,MAAM;gBAAEuB,IAAItB,MAAM;gBAAE;aAAK;YAC3CqB,MAAMzC,SAASyC,OAAOzC,SAAS,MAAM0C;QACvC;IACF;AACF"}
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 addData from './lib/addData';\nimport concatWritable from './lib/concatWritable';\nimport formatArguments from './lib/formatArguments';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { DataType } 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', data: [], ...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 = addData((data) => {\n const item = store.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, data: item.data.concat([{ type: DataType.stdout, text: data.toString('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 = addData((data) => {\n const item = store.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, data: item.data.concat([{ type: DataType.stderr, text: data.toString('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: '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","data","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addData","item","processes","find","x","updateProcess","type","DataType","text","toString","defer","oo","bind","pipe","spawn","worker","await","err","res","output","setTimeout","release","concatWritable"],"mappings":"AAAA,aAAa;;;;;+BAgBb;;;eAAwBA;;;oEAf4B;8DACnC;4DACF;8DACG;gEAEI;8DACF;qEACO;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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AAQ,CAAC/B,YAAY;YACtD;YACAoB,MAAMY,KAAK,CAACC,cAAE,CAACC,IAAI,CAAC,MAAMnB,GAAGG,MAAM,CAACiB,IAAI,CAAClB,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIH,GAAGI,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAGyB,IAAAA,uBAAc,EAAC,SAACH;gBAC/BxB,QAAQE,MAAM,CAACsB,MAAM,GAAGA,OAAOV,QAAQ,CAAC/B,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"}
@@ -10,6 +10,6 @@ export default function App() {
10
10
  flexDirection: "column"
11
11
  }, appState.processes.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, {
12
12
  key: item.id,
13
- id: item.id
13
+ item: item
14
14
  })));
15
15
  }
@@ -1 +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';\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} id={item.id} />\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;YAAEA,IAAIF,KAAKE,EAAE;;AAI/C"}
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,12 +1,9 @@
1
- import React, { useContext } from 'react';
2
- import { useStore } from 'zustand';
3
- import StoreContext from '../contexts/Store.mjs';
1
+ import React, { memo, useMemo } from 'react';
4
2
  import { Box, Text } from '../ink.mjs';
5
3
  import _ansiRegex from '../lib/ansiRegex.mjs';
6
4
  import figures from '../lib/figures.mjs';
7
5
  import Spinner from './Spinner.mjs';
8
- import { LineType } from '../types.mjs';
9
- const ansiRegex = _ansiRegex();
6
+ import { DataType } from '../types.mjs';
10
7
  // From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2
11
8
  const spinner = {
12
9
  interval: 80,
@@ -32,63 +29,85 @@ const ICONS = {
32
29
  }, figures.tick),
33
30
  running: /*#__PURE__*/ React.createElement(Spinner, spinner)
34
31
  };
35
- function Header({ item }) {
36
- const { group, title, state } = item;
32
+ const Header = /*#__PURE__*/ memo(function Header({ group, title, state }) {
37
33
  const icon = ICONS[state];
38
34
  return /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Box, {
39
35
  marginRight: 1
40
36
  }, icon), group && /*#__PURE__*/ React.createElement(Text, {
41
37
  bold: true
42
38
  }, `${group}${figures.pointer} `), /*#__PURE__*/ React.createElement(Text, null, title));
43
- }
44
- function Output({ output }) {
39
+ }, (a, b)=>a.group === b.group && a.title === b.title && a.state === b.state);
40
+ const Output = /*#__PURE__*/ memo(function Output({ output }) {
45
41
  return /*#__PURE__*/ React.createElement(Box, {
46
42
  marginLeft: 2
47
43
  }, /*#__PURE__*/ React.createElement(Text, {
48
44
  color: "gray"
49
45
  }, output.text));
50
- }
51
- function Lines({ lines }) {
46
+ });
47
+ const Lines = /*#__PURE__*/ memo(function Lines({ lines }) {
52
48
  return /*#__PURE__*/ React.createElement(Box, {
53
49
  flexDirection: "column",
54
50
  marginLeft: 2
55
51
  }, lines.map((line, index)=>// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
56
52
  /*#__PURE__*/ React.createElement(Box, {
57
53
  key: index,
58
- flexDirection: "column",
59
- height: 1
54
+ flexDirection: "column"
60
55
  }, /*#__PURE__*/ React.createElement(Text, {
61
- color: line.type === LineType.stderr ? 'red' : 'black'
56
+ color: line.type === DataType.stderr ? 'red' : 'black'
62
57
  }, line.text))));
63
- }
64
- export default function ChildProcess({ id }) {
65
- const store = useContext(StoreContext);
66
- const appState = useStore(store);
67
- const item = appState.processes.find((x)=>x.id === id);
68
- const { state, lines, expanded } = item;
69
- if (expanded) {
70
- return /*#__PURE__*/ React.createElement(Box, {
71
- flexDirection: "column"
72
- }, /*#__PURE__*/ React.createElement(Header, {
73
- item: item
74
- }), /*#__PURE__*/ React.createElement(Lines, {
75
- lines: lines
76
- }));
77
- }
58
+ });
59
+ const Expanded = /*#__PURE__*/ memo(function Expanded({ item }) {
60
+ const { data } = item;
61
+ return /*#__PURE__*/ React.createElement(Box, {
62
+ flexDirection: "column"
63
+ }, /*#__PURE__*/ React.createElement(Header, {
64
+ group: item.group,
65
+ title: item.title,
66
+ state: item.state
67
+ }), /*#__PURE__*/ React.createElement(Lines, {
68
+ lines: data
69
+ }));
70
+ });
71
+ const linesRegex = /\r\n|\n/g;
72
+ const ansiRegex = _ansiRegex();
73
+ const Contracted = /*#__PURE__*/ memo(function Contracted({ item }) {
74
+ const { state, data } = item;
75
+ const lines = useMemo(()=>{
76
+ const lines = [];
77
+ data.forEach((x)=>{
78
+ x.text.split(linesRegex).forEach((text)=>lines.push({
79
+ type: x.type,
80
+ text: text.replace(ansiRegex, '')
81
+ }));
82
+ });
83
+ return lines;
84
+ }, [
85
+ data
86
+ ]);
78
87
  // remove ansi codes when displaying single lines
79
- const cleaned = lines.map((x)=>({
80
- type: x.type,
81
- text: x.text.replace(ansiRegex, '')
82
- }));
83
- const errors = cleaned.filter((line)=>line.type === LineType.stderr);
84
- const output = cleaned.filter((line)=>line.text.length > 0).pop();
88
+ const errors = useMemo(()=>lines.filter((line)=>line.type === DataType.stderr), [
89
+ lines
90
+ ]);
91
+ const output = useMemo(()=>lines.filter((line)=>line.text.length > 0).pop(), [
92
+ lines
93
+ ]);
85
94
  return /*#__PURE__*/ React.createElement(Box, {
86
95
  flexDirection: "column"
87
96
  }, /*#__PURE__*/ React.createElement(Header, {
88
- item: item
97
+ group: item.group,
98
+ title: item.title,
99
+ state: item.state
89
100
  }), state === 'running' && output && /*#__PURE__*/ React.createElement(Output, {
90
101
  output: output
91
102
  }), errors.length > 0 && /*#__PURE__*/ React.createElement(Lines, {
92
103
  lines: errors
93
104
  }));
94
- }
105
+ });
106
+ export default /*#__PURE__*/ memo(function ChildProcess({ item }) {
107
+ const { expanded } = item;
108
+ return expanded ? /*#__PURE__*/ React.createElement(Expanded, {
109
+ item: item
110
+ }) : /*#__PURE__*/ React.createElement(Contracted, {
111
+ item: item
112
+ });
113
+ });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useStore } from 'zustand';\nimport StoreContext from '../contexts/Store';\nimport { Box, Text } from '../ink.mjs';\nimport _ansiRegex from '../lib/ansiRegex';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { AppState } from '../types';\nimport { LineType } from '../types';\n\nconst ansiRegex = _ansiRegex();\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst spinner = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...spinner} />,\n};\n\ntype ChildProcessProps = {\n id: string;\n};\n\nfunction Header({ item }) {\n const { group, title, state } = item;\n const icon = ICONS[state];\n\n return (\n <Box>\n <Box marginRight={1}>{icon}</Box>\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n}\n\nfunction Output({ output }) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{output.text}</Text>\n </Box>\n );\n}\n\nfunction Lines({ lines }) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text color={line.type === LineType.stderr ? 'red' : 'black'}>{line.text}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nexport default function ChildProcess({ id }: ChildProcessProps) {\n const store = useContext(StoreContext);\n const appState = useStore(store) as AppState;\n const item = appState.processes.find((x) => x.id === id);\n const { state, lines, expanded } = item;\n\n if (expanded) {\n return (\n <Box flexDirection=\"column\">\n <Header item={item} />\n <Lines lines={lines} />\n </Box>\n );\n }\n // remove ansi codes when displaying single lines\n const cleaned = lines.map((x) => ({ type: x.type, text: x.text.replace(ansiRegex, '') }));\n const errors = cleaned.filter((line) => line.type === LineType.stderr);\n const output = cleaned.filter((line) => line.text.length > 0).pop();\n\n return (\n <Box flexDirection=\"column\">\n <Header item={item} />\n {state === 'running' && output && <Output output={output} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n}\n"],"names":["React","useContext","useStore","StoreContext","Box","Text","_ansiRegex","figures","Spinner","LineType","ansiRegex","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","Header","item","group","title","state","icon","marginRight","bold","pointer","Output","output","marginLeft","text","Lines","lines","flexDirection","map","line","index","key","height","type","stderr","ChildProcess","id","store","appState","processes","find","x","expanded","cleaned","replace","errors","filter","length","pop"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAAQ,QAAQ;AAC1C,SAASC,QAAQ,QAAQ,UAAU;AACnC,OAAOC,kBAAkB,oBAAoB;AAC7C,SAASC,GAAG,EAAEC,IAAI,QAAQ,aAAa;AACvC,OAAOC,gBAAgB,mBAAmB;AAC1C,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,aAAa,YAAY;AAGhC,SAASC,QAAQ,QAAQ,WAAW;AAEpC,MAAMC,YAAYJ;AAElB,oHAAoH;AACpH,MAAMK,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,MAAMC,QAAQ;IACZC,qBAAO,oBAACV;QAAKW,OAAM;OAAOT,QAAQU,KAAK;IACvCC,uBAAS,oBAACb;QAAKW,OAAM;OAAST,QAAQY,IAAI;IAC1CC,uBAAS,oBAACZ,SAAYG;AACxB;AAMA,SAASU,OAAO,EAAEC,IAAI,EAAE;IACtB,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGH;IAChC,MAAMI,OAAOZ,KAAK,CAACW,MAAM;IAEzB,qBACE,oBAACrB,yBACC,oBAACA;QAAIuB,aAAa;OAAID,OACrBH,uBAAS,oBAAClB;QAAKuB,MAAAA;OAAM,GAAGL,QAAQhB,QAAQsB,OAAO,CAAC,CAAC,CAAC,iBACnD,oBAACxB,YAAMmB;AAGb;AAEA,SAASM,OAAO,EAAEC,MAAM,EAAE;IACxB,qBACE,oBAAC3B;QAAI4B,YAAY;qBACf,oBAAC3B;QAAKW,OAAM;OAAQe,OAAOE,IAAI;AAGrC;AAEA,SAASC,M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sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import 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, Data, State } from '../types';\nimport { DataType } from '../types';\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst spinner = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...spinner} />,\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n <Box marginRight={1}>{icon}</Box>\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 OutputProps = {\n output: Data;\n};\n\nconst Output = memo(function Output({ output }: OutputProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{output.text}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Data[];\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\">\n <Text color={line.type === DataType.stderr ? 'red' : 'black'}>{line.text}</Text>\n </Box>\n ))}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { data } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={data} />\n </Box>\n );\n});\n\nconst linesRegex = /\\r\\n|\\n/g;\nconst ansiRegex = _ansiRegex();\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, data } = item;\n\n const lines = useMemo(() => {\n const lines = [];\n data.forEach((x) => {\n x.text.split(linesRegex).forEach((text) => lines.push({ type: x.type, text: text.replace(ansiRegex, '') }));\n });\n return lines;\n }, [data]);\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === DataType.stderr), [lines]);\n const output = useMemo(() => lines.filter((line) => line.text.length > 0).pop(), [lines]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && output && <Output output={output} />}\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":["React","memo","useMemo","Box","Text","_ansiRegex","figures","Spinner","DataType","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","Header","group","title","state","icon","marginRight","bold","pointer","a","b","Output","output","marginLeft","text","Lines","lines","flexDirection","map","line","index","key","type","stderr","Expanded","item","data","linesRegex","ansiRegex","Contracted","forEach","x","split","push","replace","errors","filter","length","pop","ChildProcess","expanded"],"mappings":"AAAA,OAAOA,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAASC,GAAG,EAAEC,IAAI,QAAQ,aAAa;AACvC,OAAOC,gBAAgB,mBAAmB;AAC1C,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,aAAa,YAAY;AAGhC,SAASC,QAAQ,QAAQ,WAAW;AAMpC,oHAAoH;AACpH,MAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;A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Oe,yBAAW,oBAAChB;QAASC,MAAMA;uBAAW,oBAACI;QAAWJ,MAAMA;;AACjE,GAAG"}
@@ -0,0 +1,10 @@
1
+ import { Writable } from 'readable-stream';
2
+ export default function addLines(fn) {
3
+ const stream = new Writable({
4
+ write (data, _enc, callback) {
5
+ fn(data);
6
+ callback();
7
+ }
8
+ });
9
+ return stream;
10
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addData.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nexport default function addLines(fn) {\n const stream = new Writable({\n write(data, _enc, callback) {\n fn(data);\n callback();\n },\n });\n return stream;\n}\n"],"names":["Writable","addLines","fn","stream","write","data","_enc","callback"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAE3C,eAAe,SAASC,SAASC,EAAE;IACjC,MAAMC,SAAS,IAAIH,SAAS;QAC1BI,OAAMC,IAAI,EAAEC,IAAI,EAAEC,QAAQ;YACxBL,GAAGG;YACHE;QACF;IACF;IACA,OAAOJ;AACT"}
@@ -1,6 +1,6 @@
1
1
  // @ts-ignore
2
- export var LineType = /*#__PURE__*/ function(LineType) {
3
- LineType[LineType["stdout"] = 1] = "stdout";
4
- LineType[LineType["stderr"] = 2] = "stderr";
5
- return LineType;
2
+ export var DataType = /*#__PURE__*/ function(DataType) {
3
+ DataType[DataType["stdout"] = 1] = "stdout";
4
+ DataType[DataType["stderr"] = 2] = "stderr";
5
+ return DataType;
6
6
  }({});
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: string;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n group?: string;\n expanded?: string;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["LineType"],"mappings":"AAAA,aAAa;AAQb,OAAO,IAAA,AAAKA,kCAAAA;;;WAAAA;MAGX"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: string;\n};\n\nexport enum DataType {\n stdout = 1,\n stderr = 2,\n}\nexport type Data = {\n type: DataType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n data: Data[];\n expanded?: string;\n};\n\nexport interface AppState {\n processes: ChildProcess[];\n addProcess: (process: ChildProcess) => void;\n updateProcess: (process: ChildProcess) => void;\n}\n"],"names":["DataType"],"mappings":"AAAA,aAAa;AAQb,OAAO,IAAA,AAAKA,kCAAAA;;;WAAAA;MAGX"}
@@ -83,10 +83,10 @@ import uuid from 'lil-uuid';
83
83
  import oo from 'on-one';
84
84
  import Queue from 'queue-cb';
85
85
  import createApp from './createApp.mjs';
86
- import addLines from './lib/addLines.mjs';
86
+ import addData from './lib/addData.mjs';
87
87
  import concatWritable from './lib/concatWritable.mjs';
88
88
  import formatArguments from './lib/formatArguments.mjs';
89
- import { LineType } from './types.mjs';
89
+ import { DataType } from './types.mjs';
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, [
@@ -102,7 +102,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
102
102
  command
103
103
  ].concat(formatArguments(args)).join(' '),
104
104
  state: 'running',
105
- lines: []
105
+ data: []
106
106
  }, options));
107
107
  const cp = crossSpawn(command, args, csOptions);
108
108
  const outputs = {
@@ -111,14 +111,15 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
111
111
  };
112
112
  const queue = new Queue();
113
113
  if (cp.stdout) {
114
- outputs.stdout = addLines((texts)=>{
114
+ outputs.stdout = addData((data)=>{
115
115
  const item = store.getState().processes.find((x)=>x.id === id);
116
- const lines = item.lines.concat(texts.map((text)=>({
117
- type: LineType.stdout,
118
- text
119
- })));
120
116
  store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
121
- lines
117
+ data: item.data.concat([
118
+ {
119
+ type: DataType.stdout,
120
+ text: data.toString('utf8')
121
+ }
122
+ ])
122
123
  }));
123
124
  });
124
125
  queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), [
@@ -129,14 +130,15 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
129
130
  ]));
130
131
  }
131
132
  if (cp.stderr) {
132
- outputs.stderr = addLines((texts)=>{
133
+ outputs.stderr = addData((data)=>{
133
134
  const item = store.getState().processes.find((x)=>x.id === id);
134
- const lines = item.lines.concat(texts.map((text)=>({
135
- type: LineType.stderr,
136
- text
137
- })));
138
135
  store.getState().updateProcess(_object_spread_props(_object_spread({}, item), {
139
- lines
136
+ data: item.data.concat([
137
+ {
138
+ type: DataType.stderr,
139
+ text: data.toString('utf8')
140
+ }
141
+ ])
140
142
  }));
141
143
  });
142
144
  queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), [
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport 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((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stdout, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((texts) => {\n const item = store.getState().processes.find((x) => x.id === id);\n const lines = item.lines.concat(texts.map((text) => ({ type: LineType.stderr, text })));\n store.getState().updateProcess({ ...item, lines });\n });\n 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","texts","item","processes","find","x","map","text","type","updateProcess","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;QAAUC;;IAEl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YACtD;YACAiB,MAAMU,KAAK,CAACzC,GAAG0C,IAAI,CAAC,MAAMf,GAAGE,MAAM,CAACc,IAAI,CAACf,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIF,GAAGG,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAG1B,eAAe,CAAC4C;gBAC/BpB,QAAQE,MAAM,CAACkB,MAAM,GAAGA,OAAOG,QAAQ,CAACrC,YAAY;YACtD;YACAiB,MAAMU,KAAK,CAACzC,GAAG0C,IAAI,CAAC,MAAMf,GAAGG,MAAM,CAACa,IAAI,CAACf,QAAQE,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACAC,MAAMU,KAAK,CAAC5C,MAAM+C,MAAM,CAACF,IAAI,CAAC,MAAMf,IAAI,wCAAKX;YAAWF,UAAUA,YAAY;;QAC9EiB,MAAMc,KAAK,CAAC,CAACC;YACX,MAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAIlB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACmB,MAAM,GAAG;YACtDD,IAAIjB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACkB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIlB,MAAM;gBAAEkB,IAAIjB,MAAM;gBAAE;aAAK;YAC3CgB,MAAMjC,SAASiC,OAAOjC,SAAS,MAAMkC;QACvC;IACF;AACF"}
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 addData from './lib/addData';\nimport concatWritable from './lib/concatWritable';\nimport formatArguments from './lib/formatArguments';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { DataType } 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', data: [], ...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 = addData((data) => {\n const item = store.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, data: item.data.concat([{ type: DataType.stdout, text: data.toString('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 = addData((data) => {\n const item = store.getState().processes.find((x) => x.id === id);\n store.getState().updateProcess({ ...item, data: item.data.concat([{ type: DataType.stderr, text: data.toString('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: '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","addData","concatWritable","formatArguments","DataType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","getState","addProcess","title","concat","join","state","data","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","type","text","toString","defer","bind","pipe","worker","await","err","res","output","setTimeout","release"],"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,aAAa,gBAAgB;AACpC,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;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SA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Md,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,OAAOR,QAAQ,CAACzB,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"}
@@ -1,5 +1,6 @@
1
- type ChildProcessProps = {
2
- id: string;
1
+ import type { ChildProcess as ChildProcessT } from '../types';
2
+ type ItemProps = {
3
+ item: ChildProcessT;
3
4
  };
4
- export default function ChildProcess({ id }: ChildProcessProps): any;
5
- export {};
5
+ declare const _default: import("react").NamedExoticComponent<ItemProps>;
6
+ export default _default;
@@ -3,21 +3,21 @@ export type TerminalOptions = {
3
3
  group?: string;
4
4
  expanded?: string;
5
5
  };
6
- export declare enum LineType {
6
+ export declare enum DataType {
7
7
  stdout = 1,
8
8
  stderr = 2
9
9
  }
10
- export type Line = {
11
- type: LineType;
10
+ export type Data = {
11
+ type: DataType;
12
12
  text: string;
13
13
  };
14
14
  export type State = 'running' | 'error' | 'success';
15
15
  export type ChildProcess = {
16
16
  id: string;
17
+ group?: string;
17
18
  title: string;
18
19
  state: State;
19
- lines: Line[];
20
- group?: string;
20
+ data: Data[];
21
21
  expanded?: string;
22
22
  };
23
23
  export interface AppState {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spawn-term",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(regEx);\n last = lines.pop();\n if (lines.length) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["addLines","regEx","fn","last","stream","Writable","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":";;;;+BAIA;;;eAAwBA;;;8BAJC;AAEzB,IAAMC,QAAQ;AAEC,SAASD,SAASE,EAAE;IACjC,IAAIC,OAAO;IAEX,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,IAAMC,OAAOP,OAAOI,MAAMI,QAAQ,CAAC;YACnC,IAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBE,OAAOS,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,EAAEb,GAAGU;YACrBH;QACF;IACF;IACAL,OAAOY,EAAE,CAAC,UAAU;QAClB,IAAIb,KAAKY,MAAM,EAAEb,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
@@ -1,21 +0,0 @@
1
- import { Writable } from 'readable-stream';
2
- const regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
3
- export default function addLines(fn) {
4
- let last = '';
5
- const stream = new Writable({
6
- write (chunk, _enc, callback) {
7
- const more = last + chunk.toString('utf8');
8
- const lines = more.split(regEx);
9
- last = lines.pop();
10
- if (lines.length) fn(lines);
11
- callback();
12
- }
13
- });
14
- stream.on('finish', ()=>{
15
- if (last.length) fn([
16
- last
17
- ]);
18
- last = '';
19
- });
20
- return stream;
21
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(regEx);\n last = lines.pop();\n if (lines.length) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["Writable","regEx","addLines","fn","last","stream","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAE3C,MAAMC,QAAQ;AAEd,eAAe,SAASC,SAASC,EAAE;IACjC,IAAIC,OAAO;IAEX,MAAMC,SAAS,IAAIL,SAAS;QAC1BM,OAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,MAAMC,OAAON,OAAOG,MAAMI,QAAQ,CAAC;YACnC,MAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBG,OAAOQ,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,EAAEZ,GAAGS;YACrBH;QACF;IACF;IACAJ,OAAOW,EAAE,CAAC,UAAU;QAClB,IAAIZ,KAAKW,MAAM,EAAEZ,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
File without changes