spawn-term 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/components/App.js +3 -29
  2. package/dist/cjs/components/App.js.map +1 -1
  3. package/dist/cjs/components/ChildProcess.d.cts +4 -1
  4. package/dist/cjs/components/ChildProcess.d.ts +4 -1
  5. package/dist/cjs/components/ChildProcess.js +20 -10
  6. package/dist/cjs/components/ChildProcess.js.map +1 -1
  7. package/dist/cjs/createApp.d.cts +1 -1
  8. package/dist/cjs/createApp.d.ts +1 -1
  9. package/dist/cjs/createApp.js +2 -2
  10. package/dist/cjs/createApp.js.map +1 -1
  11. package/dist/cjs/state/{ProcessStore.d.cts → Store.d.cts} +4 -4
  12. package/dist/cjs/state/{ProcessStore.d.ts → Store.d.ts} +4 -4
  13. package/dist/cjs/state/{ProcessStore.js → Store.js} +10 -15
  14. package/dist/cjs/state/Store.js.map +1 -0
  15. package/dist/cjs/types.d.cts +0 -7
  16. package/dist/cjs/types.d.ts +0 -7
  17. package/dist/cjs/types.js.map +1 -1
  18. package/dist/cjs/worker.js +10 -7
  19. package/dist/cjs/worker.js.map +1 -1
  20. package/dist/esm/components/App.js +3 -29
  21. package/dist/esm/components/App.js.map +1 -1
  22. package/dist/esm/components/ChildProcess.d.ts +4 -1
  23. package/dist/esm/components/ChildProcess.js +17 -10
  24. package/dist/esm/components/ChildProcess.js.map +1 -1
  25. package/dist/esm/createApp.d.ts +1 -1
  26. package/dist/esm/createApp.js +1 -1
  27. package/dist/esm/createApp.js.map +1 -1
  28. package/dist/esm/state/{ProcessStore.d.ts → Store.d.ts} +4 -4
  29. package/dist/esm/state/{ProcessStore.js → Store.js} +5 -10
  30. package/dist/esm/state/Store.js.map +1 -0
  31. package/dist/esm/types.d.ts +0 -7
  32. package/dist/esm/types.js.map +1 -1
  33. package/dist/esm/worker.js +8 -7
  34. package/dist/esm/worker.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/cjs/state/ProcessContext.d.cts +0 -6
  37. package/dist/cjs/state/ProcessContext.d.ts +0 -6
  38. package/dist/cjs/state/ProcessContext.js +0 -139
  39. package/dist/cjs/state/ProcessContext.js.map +0 -1
  40. package/dist/cjs/state/ProcessStore.js.map +0 -1
  41. package/dist/esm/state/ProcessContext.d.ts +0 -6
  42. package/dist/esm/state/ProcessContext.js +0 -51
  43. package/dist/esm/state/ProcessContext.js.map +0 -1
  44. package/dist/esm/state/ProcessStore.js.map +0 -1
@@ -11,45 +11,19 @@ Object.defineProperty(exports, "default", {
11
11
  var _jsxruntime = require("react/jsx-runtime");
12
12
  var _ink = require("ink");
13
13
  var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.js"));
14
- function _define_property(obj, key, value) {
15
- if (key in obj) {
16
- Object.defineProperty(obj, key, {
17
- value: value,
18
- enumerable: true,
19
- configurable: true,
20
- writable: true
21
- });
22
- } else {
23
- obj[key] = value;
24
- }
25
- return obj;
26
- }
27
14
  function _interop_require_default(obj) {
28
15
  return obj && obj.__esModule ? obj : {
29
16
  default: obj
30
17
  };
31
18
  }
32
- function _object_spread(target) {
33
- for(var i = 1; i < arguments.length; i++){
34
- var source = arguments[i] != null ? arguments[i] : {};
35
- var ownKeys = Object.keys(source);
36
- if (typeof Object.getOwnPropertySymbols === "function") {
37
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
38
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
39
- }));
40
- }
41
- ownKeys.forEach(function(key) {
42
- _define_property(target, key, source[key]);
43
- });
44
- }
45
- return target;
46
- }
47
19
  function App(param) {
48
20
  var store = param.store;
49
21
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
50
22
  flexDirection: "column",
51
23
  children: store.processes.map(function(item) {
52
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default, _object_spread({}, item), item.id);
24
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChildProcess.default, {
25
+ item: item
26
+ }, item.id);
53
27
  })
54
28
  });
55
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n );\n}\n"],"names":["App","store","Box","flexDirection","processes","map","item","ChildProcess","id"],"mappings":";;;;+BAIA;;;eAAwBA;;;;mBAJJ;mEAEK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,SAASA,IAAI,KAAS;QAAT,AAAEC,QAAF,MAAEA;IAC5B,qBACE,qBAACC,QAAG;QAACC,eAAc;kBAChBF,MAAMG,SAAS,CAACC,GAAG,CAAC,SAACC;iCACpB,qBAACC,qBAAY,qBAAmBD,OAAbA,KAAKE,EAAE;;;AAIlC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["App","store","Box","flexDirection","processes","map","item","ChildProcess","id"],"mappings":";;;;+BAIA;;;eAAwBA;;;;mBAJJ;mEAEK;;;;;;AAEV,SAASA,IAAI,KAAS;QAAT,AAAEC,QAAF,MAAEA;IAC5B,qBACE,qBAACC,QAAG;QAACC,eAAc;kBAChBF,MAAMG,SAAS,CAACC,GAAG,CAAC,SAACC;iCACpB,qBAACC,qBAAY;gBAAeD,MAAMA;eAAfA,KAAKE,EAAE;;;AAIlC"}
@@ -1,3 +1,6 @@
1
1
  import type { ChildProcess as ChildProcessT } from '../types.js';
2
- declare const _default: import("react").NamedExoticComponent<ChildProcessT>;
2
+ type ItemProps = {
3
+ item: ChildProcessT;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<ItemProps>;
3
6
  export default _default;
@@ -1,3 +1,6 @@
1
1
  import type { ChildProcess as ChildProcessT } from '../types.js';
2
- declare const _default: import("react").NamedExoticComponent<ChildProcessT>;
2
+ type ItemProps = {
3
+ item: ChildProcessT;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<ItemProps>;
3
6
  export default _default;
@@ -124,7 +124,9 @@ var Lines = /*#__PURE__*/ (0, _react.memo)(function Lines(param) {
124
124
  children: lines.map(renderLine)
125
125
  });
126
126
  });
127
- var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(item) {
127
+ var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(param) {
128
+ var item = param.item;
129
+ var lines = item.lines;
128
130
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ink.Box, {
129
131
  flexDirection: "column",
130
132
  children: [
@@ -134,26 +136,28 @@ var Expanded = /*#__PURE__*/ (0, _react.memo)(function Expanded(item) {
134
136
  state: item.state
135
137
  }),
136
138
  /*#__PURE__*/ (0, _jsxruntime.jsx)(Lines, {
137
- lines: item.lines
139
+ lines: lines
138
140
  })
139
141
  ]
140
142
  });
141
143
  });
142
- var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(item) {
144
+ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(param) {
145
+ var item = param.item;
146
+ var state = item.state, lines = item.lines;
143
147
  // remove ansi codes when displaying single lines
144
148
  var errors = (0, _react.useMemo)(function() {
145
- return item.lines.filter(function(line) {
149
+ return lines.filter(function(line) {
146
150
  return line.type === _types.LineType.stderr;
147
151
  });
148
152
  }, [
149
- item.lines
153
+ lines
150
154
  ]);
151
155
  var summary = (0, _react.useMemo)(function() {
152
- return item.lines.filter(function(line) {
156
+ return lines.filter(function(line) {
153
157
  return line.text.length > 0 && errors.indexOf(line) < 0;
154
158
  }).pop();
155
159
  }, [
156
- item.lines,
160
+ lines,
157
161
  errors
158
162
  ]);
159
163
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ink.Box, {
@@ -164,7 +168,7 @@ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(item) {
164
168
  title: item.title,
165
169
  state: item.state
166
170
  }),
167
- item.state === 'running' && /*#__PURE__*/ (0, _jsxruntime.jsx)(RunningSummary, {
171
+ state === 'running' && /*#__PURE__*/ (0, _jsxruntime.jsx)(RunningSummary, {
168
172
  line: summary || BLANK_LINE
169
173
  }),
170
174
  errors.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(Lines, {
@@ -173,7 +177,13 @@ var Contracted = /*#__PURE__*/ (0, _react.memo)(function Contracted(item) {
173
177
  ]
174
178
  });
175
179
  });
176
- var _default = /*#__PURE__*/ (0, _react.memo)(function ChildProcess(item) {
177
- return item.expanded ? /*#__PURE__*/ (0, _jsxruntime.jsx)(Expanded, _object_spread({}, item)) : /*#__PURE__*/ (0, _jsxruntime.jsx)(Contracted, _object_spread({}, item));
180
+ var _default = /*#__PURE__*/ (0, _react.memo)(function ChildProcess(param) {
181
+ var item = param.item;
182
+ var expanded = item.expanded;
183
+ return expanded ? /*#__PURE__*/ (0, _jsxruntime.jsx)(Expanded, {
184
+ item: item
185
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(Contracted, {
186
+ item: item
187
+ });
178
188
  });
179
189
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded(item: ChildProcessT) {\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={item.lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted(item: ChildProcessT) {\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => item.lines.filter((line) => line.type === LineType.stderr), [item.lines]);\n const summary = useMemo(() => item.lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [item.lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {item.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: ChildProcessT) {\n return item.expanded ? <Expanded {...item} /> : <Contracted {...item} />;\n});\n"],"names":["REGEX_ANSI","ansiRegex","BLANK_LINE","type","LineType","stdout","text","SPINNER","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","Header","memo","group","title","state","icon","Box","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BAmGA;;;eAAA;;;;mBAnG0B;qBACI;gEACR;8DACF;qBAEK;8DACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,IAAMA,aAAaC,IAAAA,kBAAS;AAC5B,IAAMC,aAAa;IAAEC,MAAMC,eAAQ,CAACC,MAAM;IAAEC,MAAM;AAAG;AAErD,oHAAoH;AACpH,IAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,IAAMC,QAAQ;IACZC,qBAAO,qBAACC,SAAI;QAACC,OAAM;kBAAOC,gBAAO,CAACC,KAAK;;IACvCC,uBAAS,qBAACJ,SAAI;QAACC,OAAM;kBAASC,gBAAO,CAACG,IAAI;;IAC1CC,uBAAS,qBAACC,gBAAO,qBAAKZ;AACxB;AAQA,IAAMa,uBAASC,IAAAA,WAAI,EACjB,SAASD,O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AAK;;;;AAG9B;AAEA,IAAMK,2BAAavB,IAAAA,WAAI,EAAC,SAASuB,WAAWD,IAAmB;IAC7D,iDAAiD;IACjD,IAAME,SAASC,IAAAA,cAAO,EAAC;eAAMH,KAAKJ,KAAK,CAACQ,MAAM,CAAC,SAACf;mBAASA,KAAK7B,IAAI,KAAKC,eAAQ,CAAC4C,MAAM;;OAAG;QAACL,KAAKJ,KAAK;KAAC;IACrG,IAAMU,UAAUH,IAAAA,cAAO,EAAC;eAAMH,KAAKJ,KAAK,CAACQ,MAAM,CAAC,SAACf;mBAASA,KAAK1B,IAAI,CAAC4C,MAAM,GAAG,KAAKL,OAAOM,OAAO,CAACnB,QAAQ;WAAGoB,GAAG;OAAI;QAACT,KAAKJ,KAAK;QAAEM;KAAO;IAEvI,qBACE,sBAACnB,QAAG;QAACc,eAAc;;0BACjB,qBAACpB;gBAAOE,OAAOqB,KAAKrB,KAAK;gBAAEC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;;YAC9DmB,KAAKnB,KAAK,KAAK,2BAAa,qBAACO;gBAAeC,MAAMiB,WAAW/C;;YAC7D2C,OAAOK,MAAM,GAAG,mBAAK,qBAACZ;gBAAMC,OAAOM;;;;AAG1C;IAEA,yBAAexB,IAAAA,WAAI,EAAC,SAASgC,aAAaV,IAAmB;IAC3D,OAAOA,KAAKW,QAAQ,iBAAG,qBAACZ,6BAAaC,uBAAW,qBAACC,+BAAeD;AAClE"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { lines } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, lines } = item;\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === LineType.stderr), [lines]);\n const summary = useMemo(() => lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && <RunningSummary line={summary || BLANK_LINE} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n});\n\nexport default memo(function ChildProcess({ item }: ItemProps) {\n const { expanded } = item;\n return expanded ? <Expanded item={item} /> : <Contracted item={item} />;\n});\n"],"names":["REGEX_ANSI","ansiRegex","BLANK_LINE","type","LineType","stdout","text","SPINNER","interval","frames","ICONS","error","Text","color","figures","cross","success","tick","running","Spinner","Header","memo","group","title","state","icon","Box","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BA2GA;;;eAAA;;;;mBA3G0B;qBACI;gEACR;8DACF;qBAEK;8DACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,IAAMA,aAAaC,IAAAA,kBAAS;AAC5B,IAAMC,aAAa;IAAEC,MAAMC,eAAQ,CAACC,MAAM;IAAEC,MAAM;AAAG;AAErD,oHAAoH;AACpH,IAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,IAAMC,QAAQ;IACZC,qBAAO,qBAACC,SAAI;QAACC,OAAM;kBAAOC,gBAAO,CAACC,KAAK;;IACvCC,uBAAS,qBAACJ,SAAI;QAACC,OAAM;kBAASC,gBAAO,CAACG,IAAI;;IAC1CC,uBAAS,qBAACC,gBAAO,qBAAKZ;AACxB;AAYA,IAAMa,uBAASC,IAAAA,WAAI,EACjB,SAASD,OAAO,KAAoC;QAAlCE,QAAF,MAAEA,OAAOC,QAAT,MAASA,OAAOC,QAAhB,MAAgBA;IAC9B,IAAMC,OAAOf,KAAK,CAACc,MAAM;IAEzB,qBACE,sBAACE,QAAG;;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MAAEA;IAC5C,IAAQnB,QAAiBmB,KAAjBnB,OAAOe,QAAUI,KAAVJ;IAEf,iDAAiD;IACjD,IAAMM,SAASC,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAACf;mBAASA,KAAK7B,IAAI,KAAKC,eAAQ,CAAC4C,MAAM;;OAAG;QAACT;KAAM;IAC3F,IAAMU,UAAUH,IAAAA,cAAO,EAAC;eAAMP,MAAMQ,MAAM,CAAC,SAACf;mBAASA,KAAK1B,IAAI,CAAC4C,MAAM,GAAG,KAAKL,OAAOM,OAAO,CAACnB,QAAQ;WAAGoB,GAAG;OAAI;QAACb;QAAOM;KAAO;IAE7H,qBACE,sBAACnB,QAAG;QAACc,eAAc;;0BACjB,qBAACpB;gBAAOE,OAAOqB,KAAKrB,KAAK;gBAAEC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;;YAC9DA,UAAU,2BAAa,qBAACO;gBAAeC,MAAMiB,WAAW/C;;YACxD2C,OAAOK,MAAM,GAAG,mBAAK,qBAACZ;gBAAMC,OAAOM;;;;AAG1C;IAEA,yBAAexB,IAAAA,WAAI,EAAC,SAASgC,aAAa,KAAmB;QAAnB,AAAEV,OAAF,MAAEA;IAC1C,IAAM,AAAEW,WAAaX,KAAbW;IACR,OAAOA,yBAAW,qBAACZ;QAASC,MAAMA;uBAAW,qBAACC;QAAWD,MAAMA;;AACjE"}
@@ -1,4 +1,4 @@
1
- import { default as Store } from './state/ProcessStore.js';
1
+ import { default as Store } from './state/Store.js';
2
2
  export type RetainCallback = (app: Store) => undefined;
3
3
  export type ReleaseCallback = () => undefined;
4
4
  export default function createApp(): {
@@ -1,4 +1,4 @@
1
- import { default as Store } from './state/ProcessStore.js';
1
+ import { default as Store } from './state/Store.js';
2
2
  export type RetainCallback = (app: Store) => undefined;
3
3
  export type ReleaseCallback = () => undefined;
4
4
  export default function createApp(): {
@@ -12,7 +12,7 @@ var _jsxruntime = require("react/jsx-runtime");
12
12
  var _ink = require("ink");
13
13
  var _lodashthrottle = /*#__PURE__*/ _interop_require_default(require("lodash.throttle"));
14
14
  var _App = /*#__PURE__*/ _interop_require_default(require("./components/App.js"));
15
- var _ProcessStore = /*#__PURE__*/ _interop_require_default(require("./state/ProcessStore.js"));
15
+ var _Store = /*#__PURE__*/ _interop_require_default(require("./state/Store.js"));
16
16
  function _interop_require_default(obj) {
17
17
  return obj && obj.__esModule ? obj : {
18
18
  default: obj
@@ -37,7 +37,7 @@ function createApp() {
37
37
  retain: function retain(fn) {
38
38
  if (++refCount > 1) return fn(store);
39
39
  if (store) throw new Error('Not expecting store');
40
- store = new _ProcessStore.default(rerenderThrottled);
40
+ store = new _Store.default(rerenderThrottled);
41
41
  inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
42
42
  store: store
43
43
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.js';\nimport { default as Store, type StoreData } from './state/ProcessStore.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","THROTTLE","refCount","store","inkApp","previousData","rerender","data","App","rerenderThrottled","throttle","retain","fn","Error","Store","render","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";;;;+BAUA;;;eAAwBA;;;;mBAVc;qEACjB;0DACL;mEACiC;;;;;;AAKjD,IAAMC,WAAW;AAEF,SAASD;IACtB,IAAIE,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,IAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,qBAACE,YAAG;YAACL,OAAOA;;IAC9B;IACA,IAAMM,oBAAoBC,IAAAA,uBAAQ,EAACJ,UAAUL;IAE7C,OAAO;QACLU,QAAAA,SAAAA,OAAOC,EAAkB;YACvB,IAAI,EAAEV,WAAW,GAAG,OAAOU,GAAGT;YAC9B,IAAIA,OAAO,MAAM,IAAIU,MAAM;YAE3BV,QAAQ,IAAIW,qBAAK,CAACL;YAClBL,SAASW,IAAAA,WAAM,gBAAC,qBAACP,YAAG;gBAACL,OAAOA;;YAC5BS,GAAGT;QACL;QACAa,SAAAA,SAAAA,QAAQC,EAAmB;YACzB,IAAI,EAAEf,WAAW,GAAG,OAAOe;YAC3B,IAAI,CAACd,OAAO,MAAM,IAAIU,MAAM;YAE5BP;YACAF,OACGc,aAAa,GACbC,IAAI,CAAC;uBAAMF;eACXG,KAAK,CAACH;YACTb,OAAOiB,OAAO;YACdjB,SAAS;YACTD,QAAQ;YACRmB,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.js';\nimport { default as Store, type StoreData } from './state/Store.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["createApp","THROTTLE","refCount","store","inkApp","previousData","rerender","data","App","rerenderThrottled","throttle","retain","fn","Error","Store","render","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";;;;+BAUA;;;eAAwBA;;;;mBAVc;qEACjB;0DACL;4DACiC;;;;;;AAKjD,IAAMC,WAAW;AAEF,SAASD;IACtB,IAAIE,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,IAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,qBAACE,YAAG;YAACL,OAAOA;;IAC9B;IACA,IAAMM,oBAAoBC,IAAAA,uBAAQ,EAACJ,UAAUL;IAE7C,OAAO;QACLU,QAAAA,SAAAA,OAAOC,EAAkB;YACvB,IAAI,EAAEV,WAAW,GAAG,OAAOU,GAAGT;YAC9B,IAAIA,OAAO,MAAM,IAAIU,MAAM;YAE3BV,QAAQ,IAAIW,cAAK,CAACL;YAClBL,SAASW,IAAAA,WAAM,gBAAC,qBAACP,YAAG;gBAACL,OAAOA;;YAC5BS,GAAGT;QACL;QACAa,SAAAA,SAAAA,QAAQC,EAAmB;YACzB,IAAI,EAAEf,WAAW,GAAG,OAAOe;YAC3B,IAAI,CAACd,OAAO,MAAM,IAAIU,MAAM;YAE5BP;YACAF,OACGc,aAAa,GACbC,IAAI,CAAC;uBAAMF;eACXG,KAAK,CAACH;YACTb,OAAOiB,OAAO;YACdjB,SAAS;YACTD,QAAQ;YACRmB,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
@@ -1,11 +1,11 @@
1
- import type { ChildProcess, ChildProcessUpdate } from '../types.js';
1
+ import type { ChildProcess } from '../types.js';
2
2
  export type RenderFunction = () => void;
3
3
  export type StoreData = ChildProcess[];
4
- export default class ProcessStore {
4
+ export default class Store {
5
5
  processes: ChildProcess[];
6
6
  onRender: RenderFunction;
7
7
  constructor(onRender: RenderFunction);
8
8
  data(): StoreData;
9
- add(process: ChildProcess): void;
10
- update(id: string, update: ChildProcessUpdate): void;
9
+ addProcess(process: ChildProcess): void;
10
+ updateProcess(process: ChildProcess): void;
11
11
  }
@@ -1,11 +1,11 @@
1
- import type { ChildProcess, ChildProcessUpdate } from '../types.js';
1
+ import type { ChildProcess } from '../types.js';
2
2
  export type RenderFunction = () => void;
3
3
  export type StoreData = ChildProcess[];
4
- export default class ProcessStore {
4
+ export default class Store {
5
5
  processes: ChildProcess[];
6
6
  onRender: RenderFunction;
7
7
  constructor(onRender: RenderFunction);
8
8
  data(): StoreData;
9
- add(process: ChildProcess): void;
10
- update(id: string, update: ChildProcessUpdate): void;
9
+ addProcess(process: ChildProcess): void;
10
+ updateProcess(process: ChildProcess): void;
11
11
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return ProcessStore;
8
+ return Store;
9
9
  }
10
10
  });
11
11
  function _class_call_check(instance, Constructor) {
@@ -13,33 +13,28 @@ function _class_call_check(instance, Constructor) {
13
13
  throw new TypeError("Cannot call a class as a function");
14
14
  }
15
15
  }
16
- var ProcessStore = /*#__PURE__*/ function() {
16
+ var Store = /*#__PURE__*/ function() {
17
17
  "use strict";
18
- function ProcessStore(onRender) {
19
- _class_call_check(this, ProcessStore);
18
+ function Store(onRender) {
19
+ _class_call_check(this, Store);
20
20
  if (!onRender) throw new Error('missing on render');
21
21
  this.processes = [];
22
22
  this.onRender = onRender;
23
23
  }
24
- var _proto = ProcessStore.prototype;
24
+ var _proto = Store.prototype;
25
25
  _proto.data = function data() {
26
26
  return this.processes;
27
27
  };
28
- _proto.add = function add(process) {
28
+ _proto.addProcess = function addProcess(process) {
29
29
  this.processes.push(process);
30
30
  this.onRender();
31
31
  };
32
- _proto.update = function update(id, update) {
33
- var found = this.processes.find(function(x) {
34
- return x.id === id;
32
+ _proto.updateProcess = function updateProcess(process) {
33
+ this.processes = this.processes.map(function(x) {
34
+ return x.id === process.id ? process : x;
35
35
  });
36
- if (!found) {
37
- console.log("Process ".concat(id, " not found"));
38
- return;
39
- }
40
- Object.assign(found, update);
41
36
  this.onRender();
42
37
  };
43
- return ProcessStore;
38
+ return Store;
44
39
  }();
45
40
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.js';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","onRender","Error","processes","data","addProcess","process","push","updateProcess","map","x","id"],"mappings":";;;;;;;eAKqBA;;;;;;;;AAAN,IAAA,AAAMA,sBAAN;;aAAMA,MAIPC,QAAwB;gCAJjBD;QAKjB,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM;QAC/B,IAAI,CAACC,SAAS,GAAG,EAAE;QACnB,IAAI,CAACF,QAAQ,GAAGA;;iBAPCD;IAUnBI,OAAAA,IAEC,GAFDA,SAAAA;QACE,OAAO,IAAI,CAACD,SAAS;IACvB;IAEAE,OAAAA,UAGC,GAHDA,SAAAA,WAAWC,OAAqB;QAC9B,IAAI,CAACH,SAAS,CAACI,IAAI,CAACD;QACpB,IAAI,CAACL,QAAQ;IACf;IAEAO,OAAAA,aAGC,GAHDA,SAAAA,cAAcF,OAAqB;QACjC,IAAI,CAACH,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,SAACC;mBAAOA,EAAEC,EAAE,KAAKL,QAAQK,EAAE,GAAGL,UAAUI;;QAC5E,IAAI,CAACT,QAAQ;IACf;WAtBmBD"}
@@ -22,10 +22,3 @@ export type ChildProcess = {
22
22
  lines: Line[];
23
23
  expanded?: boolean;
24
24
  };
25
- export type ChildProcessUpdate = {
26
- group?: string;
27
- title?: string;
28
- state?: State;
29
- lines?: Line[];
30
- expanded?: boolean;
31
- };
@@ -22,10 +22,3 @@ export type ChildProcess = {
22
22
  lines: Line[];
23
23
  expanded?: boolean;
24
24
  };
25
- export type ChildProcessUpdate = {
26
- group?: string;
27
- title?: string;
28
- state?: State;
29
- lines?: Line[];
30
- expanded?: boolean;
31
- };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\nexport type ChildProcessUpdate = {\n group?: string;\n title?: string;\n state?: State;\n lines?: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":";;;;+BAWaA;;;eAAAA;;;AAAN,IAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":";;;;+BAWaA;;;eAAAA;;;AAAN,IAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV"}
@@ -151,7 +151,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
151
151
  if (stdio === 'inherit') {
152
152
  terminal.retain(function(store) {
153
153
  var id = _crypto.default.randomUUID();
154
- store.add(_object_spread({
154
+ store.addProcess(_object_spread({
155
155
  id: id,
156
156
  title: [
157
157
  command
@@ -170,14 +170,14 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
170
170
  var item = store.processes.find(function(x) {
171
171
  return x.id === id;
172
172
  });
173
- store.update(id, {
173
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
174
174
  lines: item.lines.concat(lines.map(function(text) {
175
175
  return {
176
176
  type: _types.LineType.stdout,
177
177
  text: text
178
178
  };
179
179
  }))
180
- });
180
+ }));
181
181
  });
182
182
  queue.defer(_onone.default.bind(null, cp.stdout.pipe(outputs.stdout), [
183
183
  'error',
@@ -191,14 +191,14 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
191
191
  var item = store.processes.find(function(x) {
192
192
  return x.id === id;
193
193
  });
194
- store.update(id, {
194
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
195
195
  lines: item.lines.concat(lines.map(function(text) {
196
196
  return {
197
197
  type: _types.LineType.stderr,
198
198
  text: text
199
199
  };
200
200
  }))
201
- });
201
+ }));
202
202
  });
203
203
  queue.defer(_onone.default.bind(null, cp.stderr.pipe(outputs.stderr), [
204
204
  'error',
@@ -219,9 +219,12 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
219
219
  res.stderr,
220
220
  null
221
221
  ];
222
- store.update(id, {
223
- state: err ? 'error' : 'success'
222
+ var item = store.processes.find(function(x) {
223
+ return x.id === id;
224
224
  });
225
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
226
+ state: err ? 'error' : 'success'
227
+ }));
225
228
  // ensure rendering completes
226
229
  terminal.release(function() {
227
230
  err ? callback(err) : callback(null, res);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.add({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.update(id, { lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.update(id, { lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n store.update(id, { state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawnTerminal","terminal","createApp","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","crypto","randomUUID","add","title","concat","formatArguments","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addLines","item","processes","find","x","update","map","text","type","LineType","defer","oo","bind","pipe","spawn","worker","await","err","res","output","release","concatWritable","toString"],"mappings":";;;;+BAeA;;;eAAwBA;;;oEAf4B;6DACjC;4DACJ;8DACG;gEAEI;+DACD;qEACM;sEACC;qBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,kBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,IAAQ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C,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,GAAGwB,IAAAA,uBAAc,EAAC,SAACF;gBAC/BxB,QAAQE,MAAM,CAACsB,MAAM,GAAGA,OAAOG,QAAQ,CAAC5C,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"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawnTerminal","terminal","createApp","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","crypto","randomUUID","addProcess","title","concat","formatArguments","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addLines","item","processes","find","x","updateProcess","map","text","type","LineType","defer","oo","bind","pipe","spawn","worker","await","err","res","output","release","concatWritable","toString"],"mappings":";;;;+BAeA;;;eAAwBA;;;oEAf4B;6DACjC;4DACJ;8DACG;gEAEI;+DACD;qEACM;sEACC;qBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,kBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,IAAQC,WAAkCH,aAAlCG,UAAUC,QAAwBJ,aAAxBI,OAAUC,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,SAACC;YACf,IAAMC,KAAKC,eAAM,CAACC,UAAU;YA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iB,IAAI,CAAClB,QAAQC,MAAM,GAAG;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QAC/F;QACA,IAAIH,GAAGI,MAAM,EAAE;YACbF,QAAQE,MAAM,GAAGwB,IAAAA,uBAAc,EAAC,SAACF;gBAC/BxB,QAAQE,MAAM,CAACsB,MAAM,GAAGA,OAAOG,QAAQ,CAAC5C,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"}
@@ -1,37 +1,11 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _object_spread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _define_property(target, key, source[key]);
25
- });
26
- }
27
- return target;
28
- }
29
1
  import { jsx as _jsx } from "react/jsx-runtime";
30
2
  import { Box } from 'ink';
31
3
  import ChildProcess from './ChildProcess.js';
32
4
  export default function App({ store }) {
33
5
  return /*#__PURE__*/ _jsx(Box, {
34
6
  flexDirection: "column",
35
- children: store.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, _object_spread({}, item), item.id))
7
+ children: store.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, {
8
+ item: item
9
+ }, item.id))
36
10
  });
37
11
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ChildProcess","App","store","flexDirection","processes","map","item","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAG,QAAQ,MAAM;AAE1B,OAAOC,kBAAkB,oBAAoB;AAE7C,eAAe,SAASC,IAAI,EAAEC,KAAK,EAAE;IACnC,qBACE,KAACH;QAAII,eAAc;kBAChBD,MAAME,SAAS,CAACC,GAAG,CAAC,CAACC,qBACpB,KAACN,iCAA+BM,OAAbA,KAAKC,EAAE;;AAIlC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App({ store }) {\n return (\n <Box flexDirection=\"column\">\n {store.processes.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} item={item} />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ChildProcess","App","store","flexDirection","processes","map","item","id"],"mappings":";AAAA,SAASA,GAAG,QAAQ,MAAM;AAE1B,OAAOC,kBAAkB,oBAAoB;AAE7C,eAAe,SAASC,IAAI,EAAEC,KAAK,EAAE;IACnC,qBACE,KAACH;QAAII,eAAc;kBAChBD,MAAME,SAAS,CAACC,GAAG,CAAC,CAACC,qBACpB,KAACN;gBAA2BM,MAAMA;eAAfA,KAAKC,EAAE;;AAIlC"}
@@ -1,3 +1,6 @@
1
1
  import type { ChildProcess as ChildProcessT } from '../types.js';
2
- declare const _default: import("react").NamedExoticComponent<ChildProcessT>;
2
+ type ItemProps = {
3
+ item: ChildProcessT;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<ItemProps>;
3
6
  export default _default;
@@ -104,7 +104,8 @@ const Lines = /*#__PURE__*/ memo(function Lines({ lines }) {
104
104
  children: lines.map(renderLine)
105
105
  });
106
106
  });
107
- const Expanded = /*#__PURE__*/ memo(function Expanded(item) {
107
+ const Expanded = /*#__PURE__*/ memo(function Expanded({ item }) {
108
+ const { lines } = item;
108
109
  return /*#__PURE__*/ _jsxs(Box, {
109
110
  flexDirection: "column",
110
111
  children: [
@@ -114,18 +115,19 @@ const Expanded = /*#__PURE__*/ memo(function Expanded(item) {
114
115
  state: item.state
115
116
  }),
116
117
  /*#__PURE__*/ _jsx(Lines, {
117
- lines: item.lines
118
+ lines: lines
118
119
  })
119
120
  ]
120
121
  });
121
122
  });
122
- const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
123
+ const Contracted = /*#__PURE__*/ memo(function Contracted({ item }) {
124
+ const { state, lines } = item;
123
125
  // remove ansi codes when displaying single lines
124
- const errors = useMemo(()=>item.lines.filter((line)=>line.type === LineType.stderr), [
125
- item.lines
126
+ const errors = useMemo(()=>lines.filter((line)=>line.type === LineType.stderr), [
127
+ lines
126
128
  ]);
127
- const summary = useMemo(()=>item.lines.filter((line)=>line.text.length > 0 && errors.indexOf(line) < 0).pop(), [
128
- item.lines,
129
+ const summary = useMemo(()=>lines.filter((line)=>line.text.length > 0 && errors.indexOf(line) < 0).pop(), [
130
+ lines,
129
131
  errors
130
132
  ]);
131
133
  return /*#__PURE__*/ _jsxs(Box, {
@@ -136,7 +138,7 @@ const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
136
138
  title: item.title,
137
139
  state: item.state
138
140
  }),
139
- item.state === 'running' && /*#__PURE__*/ _jsx(RunningSummary, {
141
+ state === 'running' && /*#__PURE__*/ _jsx(RunningSummary, {
140
142
  line: summary || BLANK_LINE
141
143
  }),
142
144
  errors.length > 0 && /*#__PURE__*/ _jsx(Lines, {
@@ -145,6 +147,11 @@ const Contracted = /*#__PURE__*/ memo(function Contracted(item) {
145
147
  ]
146
148
  });
147
149
  });
148
- export default /*#__PURE__*/ memo(function ChildProcess(item) {
149
- return item.expanded ? /*#__PURE__*/ _jsx(Expanded, _object_spread({}, item)) : /*#__PURE__*/ _jsx(Contracted, _object_spread({}, item));
150
+ export default /*#__PURE__*/ memo(function ChildProcess({ item }) {
151
+ const { expanded } = item;
152
+ return expanded ? /*#__PURE__*/ _jsx(Expanded, {
153
+ item: item
154
+ }) : /*#__PURE__*/ _jsx(Contracted, {
155
+ item: item
156
+ });
150
157
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded(item: ChildProcessT) {\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={item.lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted(item: ChildProcessT) {\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => item.lines.filter((line) => line.type === LineType.stderr), [item.lines]);\n const summary = useMemo(() => item.lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [item.lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {item.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: ChildProcessT) {\n return item.expanded ? <Expanded {...item} /> : <Contracted {...item} />;\n});\n"],"names":["Box","Text","memo","useMemo","ansiRegex","figures","LineType","Spinner","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","color","cross","success","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AACtC,OAAOC,eAAe,sBAAsB;AAC5C,OAAOC,aAAa,oBAAoB;AAExC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,aAAa,eAAe;AAEnC,MAAMC,aAAaJ;AACnB,MAAMK,aAAa;IAAEC,MAAMJ,SAASK,MAAM;IAAEC,MAAM;AAAG;AAErD,oHAAoH;AACpH,MAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,MAAMC,QAAQ;IACZC,qBAAO,KAAChB;QAAKiB,OAAM;kBAAOb,QAAQc,KAAK;;IACvCC,uBAAS,KAACnB;QAAKiB,OAAM;kBAASb,QAAQgB,IAAI;;IAC1CC,uBAAS,KAACf,4BAAYM;AACxB;AAQA,MAAMU,uBAASrB,KACb,SAASqB,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAe;IAClD,MAAMC,OAAOX,KAAK,CAACU,MAAM;IAEzB,qBACE,MAAC1B;;YACE2B;YACAH,uBAAS,KAACvB;gBAAK2B,IAAI;0BAAE,GAAGJ,QAAQnB,Q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IAAI,CAACsC,MAAM,GAAG,KAAKJ,OAAOK,OAAO,CAAClB,QAAQ,GAAGmB,GAAG,IAAI;QAACR,KAAKJ,KAAK;QAAEM;KAAO;IAEvI,qBACE,MAAC9C;QAAIyC,eAAc;;0BACjB,KAAClB;gBAAOC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;gBAAEC,OAAOkB,KAAKlB,KAAK;;YAC9DkB,KAAKlB,KAAK,KAAK,2BAAa,KAACM;gBAAeC,MAAMgB,WAAWxC;;YAC7DqC,OAAOI,MAAM,GAAG,mBAAK,KAACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAe5C,KAAK,SAASmD,aAAaT,IAAmB;IAC3D,OAAOA,KAAKU,QAAQ,iBAAG,KAACX,6BAAaC,uBAAW,KAACC,+BAAeD;AAClE,GAAG"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { memo, useMemo } from 'react';\nimport ansiRegex from '../lib/ansiRegex.js';\nimport figures from '../lib/figures.js';\nimport type { ChildProcess as ChildProcessT, Line, State } from '../types.js';\nimport { LineType } from '../types.js';\nimport Spinner from './Spinner.js';\n\nconst REGEX_ANSI = ansiRegex();\nconst BLANK_LINE = { type: LineType.stdout, text: '' };\n\n// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2\nconst SPINNER = {\n interval: 80,\n frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],\n};\n\nconst ICONS = {\n error: <Text color=\"red\">{figures.cross}</Text>,\n success: <Text color=\"green\">{figures.tick}</Text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n <Box key={index} minHeight={1}>\n <Text>{line.text}</Text>\n </Box>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { lines } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, lines } = item;\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === LineType.stderr), [lines]);\n const summary = useMemo(() => lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && <RunningSummary line={summary || BLANK_LINE} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n});\n\nexport default memo(function ChildProcess({ item }: ItemProps) {\n const { expanded } = item;\n return expanded ? <Expanded item={item} /> : <Contracted item={item} />;\n});\n"],"names":["Box","Text","memo","useMemo","ansiRegex","figures","LineType","Spinner","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","color","cross","success","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","replace","renderLine","index","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,SAASC,IAAI,EAAEC,OAAO,QAAQ,QAAQ;AACtC,OAAOC,eAAe,sBAAsB;AAC5C,OAAOC,aAAa,oBAAoB;AAExC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,aAAa,eAAe;AAEnC,MAAMC,aAAaJ;AACnB,MAAMK,aAAa;IAAEC,MAAMJ,SAASK,MAAM;IAAEC,MAAM;AAAG;AAErD,oHAAoH;AACpH,MAAMC,UAAU;IACdC,UAAU;IACVC,QAAQ;QAAC;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;QAAK;KAAI;AAC5D;AAEA,MAAMC,QAAQ;IACZC,qBAAO,KAAChB;QAAKiB,OAAM;kBAAOb,QAAQc,KAAK;;IACvCC,uBAAS,KAACnB;QAAKiB,OAAM;kBAASb,QAAQgB,IAAI;;IAC1CC,uBAAS,KAACf,4BAAYM;AACxB;AAYA,MAAMU,uBAASrB,KACb,SAASqB,OAAO,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAe;IAClD,MAAMC,OAAOX,KAAK,CAACU,MAAM;IAEzB,qBACE,MAAC1B;;YACE2B;YACAH,uBAAS,KAACvB;gBAAK2B,IAAI;0BAAE,GAAGJ,QAAQnB,QAAQwB,OAAO,CAAC,CAAC,CAAC;;0BACnD,KAAC5B;0BAAMwB;;;;AAGb,GACA,CAACK,GAAGC,IAAMD,EAAEN,KAAK,KAAKO,EAAEP,KAAK,IAAIM,EAAEL,KAAK,KAAKM,EAAEN,KAAK,IAAIK,EAAEJ,KAAK,KAAKK,EAAEL,KAAK;AAO7E,MAAMM,+BAAiB9B,KAAK,SAAS8B,eAAe,EAAEC,IAAI,EAAu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K;gBAAEC,OAAOkB,KAAKlB,KAAK;;YAC9DA,UAAU,2BAAa,KAACM;gBAAeC,MAAMgB,WAAWxC;;YACxDqC,OAAOI,MAAM,GAAG,mBAAK,KAACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAe5C,KAAK,SAASmD,aAAa,EAAET,IAAI,EAAa;IAC3D,MAAM,EAAEU,QAAQ,EAAE,GAAGV;IACrB,OAAOU,yBAAW,KAACX;QAASC,MAAMA;uBAAW,KAACC;QAAWD,MAAMA;;AACjE,GAAG"}
@@ -1,4 +1,4 @@
1
- import { default as Store } from './state/ProcessStore.js';
1
+ import { default as Store } from './state/Store.js';
2
2
  export type RetainCallback = (app: Store) => undefined;
3
3
  export type ReleaseCallback = () => undefined;
4
4
  export default function createApp(): {
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render } from 'ink';
3
3
  import throttle from 'lodash.throttle';
4
4
  import App from './components/App.js';
5
- import { default as Store } from './state/ProcessStore.js';
5
+ import { default as Store } from './state/Store.js';
6
6
  const THROTTLE = 100;
7
7
  export default function createApp() {
8
8
  let refCount = 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.js';\nimport { default as Store, type StoreData } from './state/ProcessStore.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["render","throttle","App","default","Store","THROTTLE","createApp","refCount","store","inkApp","previousData","rerender","data","rerenderThrottled","retain","fn","Error","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,SAASC,WAAWC,KAAK,QAAwB,0BAA0B;AAK3E,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,MAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,KAACT;YAAIM,OAAOA;;IAC9B;IACA,MAAMK,oBAAoBZ,SAASU,UAAUN;IAE7C,OAAO;QACLS,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMS;YAClBJ,SAAST,qBAAO,KAACE;gBAAIM,OAAOA;;YAC5BO,GAAGP;QACL;QACAS,SAAQC,EAAmB;YACzB,IAAI,EAAEX,WAAW,GAAG,OAAOW;YAC3B,IAAI,CAACV,OAAO,MAAM,IAAIQ,MAAM;YAE5BL;YACAF,OACGU,aAAa,GACbC,IAAI,CAAC,IAAMF,MACXG,KAAK,CAACH;YACTT,OAAOa,OAAO;YACdb,SAAS;YACTD,QAAQ;YACRe,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport throttle from 'lodash.throttle';\nimport App from './components/App.js';\nimport { default as Store, type StoreData } from './state/Store.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["render","throttle","App","default","Store","THROTTLE","createApp","refCount","store","inkApp","previousData","rerender","data","rerenderThrottled","retain","fn","Error","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,SAASC,WAAWC,KAAK,QAAwB,mBAAmB;AAKpE,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,MAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,KAACT;YAAIM,OAAOA;;IAC9B;IACA,MAAMK,oBAAoBZ,SAASU,UAAUN;IAE7C,OAAO;QACLS,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMS;YAClBJ,SAAST,qBAAO,KAACE;gBAAIM,OAAOA;;YAC5BO,GAAGP;QACL;QACAS,SAAQC,EAAmB;YACzB,IAAI,EAAEX,WAAW,GAAG,OAAOW;YAC3B,IAAI,CAACV,OAAO,MAAM,IAAIQ,MAAM;YAE5BL;YACAF,OACGU,aAAa,GACbC,IAAI,CAAC,IAAMF,MACXG,KAAK,CAACH;YACTT,OAAOa,OAAO;YACdb,SAAS;YACTD,QAAQ;YACRe,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
@@ -1,11 +1,11 @@
1
- import type { ChildProcess, ChildProcessUpdate } from '../types.js';
1
+ import type { ChildProcess } from '../types.js';
2
2
  export type RenderFunction = () => void;
3
3
  export type StoreData = ChildProcess[];
4
- export default class ProcessStore {
4
+ export default class Store {
5
5
  processes: ChildProcess[];
6
6
  onRender: RenderFunction;
7
7
  constructor(onRender: RenderFunction);
8
8
  data(): StoreData;
9
- add(process: ChildProcess): void;
10
- update(id: string, update: ChildProcessUpdate): void;
9
+ addProcess(process: ChildProcess): void;
10
+ updateProcess(process: ChildProcess): void;
11
11
  }
@@ -1,18 +1,13 @@
1
- class ProcessStore {
1
+ class Store {
2
2
  data() {
3
3
  return this.processes;
4
4
  }
5
- add(process) {
5
+ addProcess(process) {
6
6
  this.processes.push(process);
7
7
  this.onRender();
8
8
  }
9
- update(id, update) {
10
- const found = this.processes.find((x)=>x.id === id);
11
- if (!found) {
12
- console.log(`Process ${id} not found`);
13
- return;
14
- }
15
- Object.assign(found, update);
9
+ updateProcess(process) {
10
+ this.processes = this.processes.map((x)=>x.id === process.id ? process : x);
16
11
  this.onRender();
17
12
  }
18
13
  constructor(onRender){
@@ -21,4 +16,4 @@ class ProcessStore {
21
16
  this.onRender = onRender;
22
17
  }
23
18
  }
24
- export { ProcessStore as default };
19
+ export { Store as default };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.js';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","data","processes","addProcess","process","push","onRender","updateProcess","map","x","id","Error"],"mappings":"AAKe,MAAMA;IAUnBC,OAAkB;QAChB,OAAO,IAAI,CAACC,SAAS;IACvB;IAEAC,WAAWC,OAAqB,EAAQ;QACtC,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACE,QAAQ;IACf;IAEAC,cAAcH,OAAqB,EAAQ;QACzC,IAAI,CAACF,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKN,QAAQM,EAAE,GAAGN,UAAUK;QAC5E,IAAI,CAACH,QAAQ;IACf;IAlBA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIK,MAAM;QAC/B,IAAI,CAACT,SAAS,GAAG,EAAE;QACnB,IAAI,CAACI,QAAQ,GAAGA;IAClB;AAeF;AAvBA,SAAqBN,mBAuBpB"}
@@ -22,10 +22,3 @@ export type ChildProcess = {
22
22
  lines: Line[];
23
23
  expanded?: boolean;
24
24
  };
25
- export type ChildProcessUpdate = {
26
- group?: string;
27
- title?: string;
28
- state?: State;
29
- lines?: Line[];
30
- expanded?: boolean;
31
- };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\nexport type ChildProcessUpdate = {\n group?: string;\n title?: string;\n state?: State;\n lines?: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":"AAWA,OAAO,MAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV,EAAW"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":"AAWA,OAAO,MAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV,EAAW"}
@@ -95,7 +95,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
95
95
  if (stdio === 'inherit') {
96
96
  terminal.retain((store)=>{
97
97
  const id = crypto.randomUUID();
98
- store.add(_object_spread({
98
+ store.addProcess(_object_spread({
99
99
  id,
100
100
  title: [
101
101
  command
@@ -112,12 +112,12 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
112
112
  if (cp.stdout) {
113
113
  outputs.stdout = addLines((lines)=>{
114
114
  const item = store.processes.find((x)=>x.id === id);
115
- store.update(id, {
115
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
116
116
  lines: item.lines.concat(lines.map((text)=>({
117
117
  type: LineType.stdout,
118
118
  text
119
119
  })))
120
- });
120
+ }));
121
121
  });
122
122
  queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), [
123
123
  'error',
@@ -129,12 +129,12 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
129
129
  if (cp.stderr) {
130
130
  outputs.stderr = addLines((lines)=>{
131
131
  const item = store.processes.find((x)=>x.id === id);
132
- store.update(id, {
132
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
133
133
  lines: item.lines.concat(lines.map((text)=>({
134
134
  type: LineType.stderr,
135
135
  text
136
136
  })))
137
- });
137
+ }));
138
138
  });
139
139
  queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), [
140
140
  'error',
@@ -155,9 +155,10 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
155
155
  res.stderr,
156
156
  null
157
157
  ];
158
- store.update(id, {
158
+ const item = store.processes.find((x)=>x.id === id);
159
+ store.updateProcess(_object_spread_props(_object_spread({}, item), {
159
160
  state: err ? 'error' : 'success'
160
- });
161
+ }));
161
162
  // ensure rendering completes
162
163
  terminal.release(()=>{
163
164
  err ? callback(err) : callback(null, res);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.add({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.update(id, { lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.update(id, { lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n store.update(id, { state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","add","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","update","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eA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I0B,GAAGE,MAAM,EAAE;YACbD,QAAQC,MAAM,GAAGzB,eAAe,CAAC2C;gBAC/BnB,QAAQC,MAAM,CAACkB,MAAM,GAAGA,OAAOE,QAAQ,CAACnC,YAAY;YACtD;YACAiB,MAAMS,KAAK,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,OAAOE,QAAQ,CAACnC,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
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,iBAAiB;AACvC,OAAOC,cAAc,oBAAoB;AACzC,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AAGvD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC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C,YAAY;YACtD;YACAiB,MAAMS,KAAK,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,OAAOE,QAAQ,CAACnC,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": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -1,6 +0,0 @@
1
- export declare function ProcessProvider({ children, store }: {
2
- children: any;
3
- store: any;
4
- }): import("react").JSX.Element;
5
- export declare function useProcesses(): any;
6
- export declare function useProcessDispatch(): any;
@@ -1,6 +0,0 @@
1
- export declare function ProcessProvider({ children, store }: {
2
- children: any;
3
- store: any;
4
- }): import("react").JSX.Element;
5
- export declare function useProcesses(): any;
6
- export declare function useProcessDispatch(): any;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ProcessProvider () {
13
- return ProcessProvider;
14
- },
15
- get useProcessDispatch () {
16
- return useProcessDispatch;
17
- },
18
- get useProcesses () {
19
- return useProcesses;
20
- }
21
- });
22
- var _jsxruntime = require("react/jsx-runtime");
23
- var _react = require("react");
24
- function _array_like_to_array(arr, len) {
25
- if (len == null || len > arr.length) len = arr.length;
26
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27
- return arr2;
28
- }
29
- function _array_with_holes(arr) {
30
- if (Array.isArray(arr)) return arr;
31
- }
32
- function _array_without_holes(arr) {
33
- if (Array.isArray(arr)) return _array_like_to_array(arr);
34
- }
35
- function _iterable_to_array(iter) {
36
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
37
- }
38
- function _iterable_to_array_limit(arr, i) {
39
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40
- if (_i == null) return;
41
- var _arr = [];
42
- var _n = true;
43
- var _d = false;
44
- var _s, _e;
45
- try {
46
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
47
- _arr.push(_s.value);
48
- if (i && _arr.length === i) break;
49
- }
50
- } catch (err) {
51
- _d = true;
52
- _e = err;
53
- } finally{
54
- try {
55
- if (!_n && _i["return"] != null) _i["return"]();
56
- } finally{
57
- if (_d) throw _e;
58
- }
59
- }
60
- return _arr;
61
- }
62
- function _non_iterable_rest() {
63
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
64
- }
65
- function _non_iterable_spread() {
66
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
- }
68
- function _sliced_to_array(arr, i) {
69
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
70
- }
71
- function _to_consumable_array(arr) {
72
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
73
- }
74
- function _unsupported_iterable_to_array(o, minLen) {
75
- if (!o) return;
76
- if (typeof o === "string") return _array_like_to_array(o, minLen);
77
- var n = Object.prototype.toString.call(o).slice(8, -1);
78
- if (n === "Object" && o.constructor) n = o.constructor.name;
79
- if (n === "Map" || n === "Set") return Array.from(n);
80
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
81
- }
82
- var ProcessContext = /*#__PURE__*/ (0, _react.createContext)(null);
83
- var ProcessDispatchContext = /*#__PURE__*/ (0, _react.createContext)(null);
84
- function ProcessProvider(param) {
85
- var children = param.children, store = param.store;
86
- var _useReducer = _sliced_to_array((0, _react.useReducer)(ProcessReducer, []), 2), Process = _useReducer[0], dispatch = _useReducer[1];
87
- store.on('added', function(process) {
88
- return dispatch({
89
- type: 'added',
90
- process: process
91
- });
92
- });
93
- store.on('changed', function(process) {
94
- return dispatch({
95
- type: 'changed',
96
- process: process
97
- });
98
- });
99
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(ProcessContext, {
100
- value: Process,
101
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ProcessDispatchContext, {
102
- value: dispatch,
103
- children: children
104
- })
105
- });
106
- }
107
- function useProcesses() {
108
- return (0, _react.useContext)(ProcessContext);
109
- }
110
- function useProcessDispatch() {
111
- return (0, _react.useContext)(ProcessDispatchContext);
112
- }
113
- function ProcessReducer(processes, action) {
114
- switch(action.type){
115
- case 'added':
116
- {
117
- if (processes.find(function(x) {
118
- return x.id === action.process.id;
119
- })) {
120
- console.log("".concat(action.process.id, " process added a second time"));
121
- return processes;
122
- }
123
- return _to_consumable_array(processes).concat([
124
- action.process
125
- ]);
126
- }
127
- case 'changed':
128
- {
129
- return processes.map(function(x) {
130
- return x.id === action.process.id ? action.process : x;
131
- });
132
- }
133
- default:
134
- {
135
- throw Error("Unknown action: ".concat(action.type));
136
- }
137
- }
138
- }
139
- /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/ProcessContext.tsx"],"sourcesContent":["import { createContext, useContext, useReducer } from 'react';\n\nconst ProcessContext = createContext(null);\nconst ProcessDispatchContext = createContext(null);\n\nexport function ProcessProvider({ children, store }) {\n const [Process, dispatch] = useReducer(ProcessReducer, []);\n\n store.on('added', (process) => dispatch({ type: 'added', process }));\n store.on('changed', (process) => dispatch({ type: 'changed', process }));\n\n return (\n <ProcessContext value={Process}>\n <ProcessDispatchContext value={dispatch}>{children}</ProcessDispatchContext>\n </ProcessContext>\n );\n}\n\nexport function useProcesses() {\n return useContext(ProcessContext);\n}\n\nexport function useProcessDispatch() {\n return useContext(ProcessDispatchContext);\n}\n\nfunction ProcessReducer(processes, action) {\n switch (action.type) {\n case 'added': {\n if (processes.find((x) => x.id === action.process.id)) {\n console.log(`${action.process.id} process added a second time`);\n return processes;\n }\n return [...processes, action.process];\n }\n case 'changed': {\n return processes.map((x) => (x.id === action.process.id ? action.process : x));\n }\n default: {\n throw Error(`Unknown action: ${action.type}`);\n }\n }\n}\n"],"names":["ProcessProvider","useProcessDispatch","useProcesses","ProcessContext","createContext","ProcessDispatchContext","children","store","useReducer","ProcessReducer","Process","dispatch","on","process","type","value","useContext","processes","action","find","x","id","console","log","map","Error"],"mappings":";;;;;;;;;;;QAKgBA;eAAAA;;QAiBAC;eAAAA;;QAJAC;eAAAA;;;;qBAlBsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,IAAMC,+BAAiBC,IAAAA,oBAAa,EAAC;AACrC,IAAMC,uCAAyBD,IAAAA,oBAAa,EAAC;AAEtC,SAASJ,gBAAgB,KAAmB;QAAjBM,WAAF,MAAEA,UAAUC,QAAZ,MAAYA;IAC1C,IAA4BC,+BAAAA,IAAAA,iBAAU,EAACC,gBAAgB,EAAE,OAAlDC,UAAqBF,gBAAZG,WAAYH;IAE5BD,MAAMK,EAAE,CAAC,SAAS,SAACC;eAAYF,SAAS;YAAEG,MAAM;YAASD,SAAAA;QAAQ;;IACjEN,MAAMK,EAAE,CAAC,WAAW,SAACC;eAAYF,SAAS;YAAEG,MAAM;YAAWD,SAAAA;QAAQ;;IAErE,qBACE,qBAACV;QAAeY,OAAOL;kBACrB,cAAA,qBAACL;YAAuBU,OAAOJ;sBAAWL;;;AAGhD;AAEO,SAASJ;IACd,OAAOc,IAAAA,iBAAU,EAACb;AACpB;AAEO,SAASF;IACd,OAAOe,IAAAA,iBAAU,EAACX;AACpB;AAEA,SAASI,eAAeQ,SAAS,EAAEC,MAAM;IACvC,OAAQA,OAAOJ,IAAI;QACjB,KAAK;YAAS;gBACZ,IAAIG,UAAUE,IAAI,CAAC,SAACC;2BAAMA,EAAEC,EAAE,KAAKH,OAAOL,OAAO,CAACQ,EAAE;oBAAG;oBACrDC,QAAQC,GAAG,CAAC,AAAC,GAAoB,OAAlBL,OAAOL,OAAO,CAACQ,EAAE,EAAC;oBACjC,OAAOJ;gBACT;gBACA,OAAO,AAAC,qBAAGA,kBAAJ;oBAAeC,OAAOL,OAAO;iBAAC;YACvC;QACA,KAAK;YAAW;gBACd,OAAOI,UAAUO,GAAG,CAAC,SAACJ;2BAAOA,EAAEC,EAAE,KAAKH,OAAOL,OAAO,CAACQ,EAAE,GAAGH,OAAOL,OAAO,GAAGO;;YAC7E;QACA;YAAS;gBACP,MAAMK,MAAM,AAAC,mBAA8B,OAAZP,OAAOJ,IAAI;YAC5C;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/ProcessStore.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessUpdate } from '../types.js';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class ProcessStore {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n add(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n update(id: string, update: ChildProcessUpdate): void {\n const found = this.processes.find((x) => x.id === id);\n if (!found) {\n console.log(`Process ${id} not found`);\n return;\n }\n Object.assign(found, update);\n this.onRender();\n }\n}\n"],"names":["ProcessStore","onRender","Error","processes","data","add","process","push","update","id","found","find","x","console","log","Object","assign"],"mappings":";;;;;;;eAKqBA;;;;;;;;AAAN,IAAA,AAAMA,6BAAN;;aAAMA,aAIPC,QAAwB;gCAJjBD;QAKjB,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM;QAC/B,IAAI,CAACC,SAAS,GAAG,EAAE;QACnB,IAAI,CAACF,QAAQ,GAAGA;;iBAPCD;IAUnBI,OAAAA,IAEC,GAFDA,SAAAA;QACE,OAAO,IAAI,CAACD,SAAS;IACvB;IAEAE,OAAAA,GAGC,GAHDA,SAAAA,IAAIC,OAAqB;QACvB,IAAI,CAACH,SAAS,CAACI,IAAI,CAACD;QACpB,IAAI,CAACL,QAAQ;IACf;IAEAO,OAAAA,MAQC,GARDA,SAAAA,OAAOC,EAAU,EAAED,MAA0B;QAC3C,IAAME,QAAQ,IAAI,CAACP,SAAS,CAACQ,IAAI,CAAC,SAACC;mBAAMA,EAAEH,EAAE,KAAKA;;QAClD,IAAI,CAACC,OAAO;YACVG,QAAQC,GAAG,CAAC,AAAC,WAAa,OAAHL,IAAG;YAC1B;QACF;QACAM,OAAOC,MAAM,CAACN,OAAOF;QACrB,IAAI,CAACP,QAAQ;IACf;WA3BmBD"}
@@ -1,6 +0,0 @@
1
- export declare function ProcessProvider({ children, store }: {
2
- children: any;
3
- store: any;
4
- }): import("react").JSX.Element;
5
- export declare function useProcesses(): any;
6
- export declare function useProcessDispatch(): any;
@@ -1,51 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, useReducer } from 'react';
3
- const ProcessContext = /*#__PURE__*/ createContext(null);
4
- const ProcessDispatchContext = /*#__PURE__*/ createContext(null);
5
- export function ProcessProvider({ children, store }) {
6
- const [Process, dispatch] = useReducer(ProcessReducer, []);
7
- store.on('added', (process)=>dispatch({
8
- type: 'added',
9
- process
10
- }));
11
- store.on('changed', (process)=>dispatch({
12
- type: 'changed',
13
- process
14
- }));
15
- return /*#__PURE__*/ _jsx(ProcessContext, {
16
- value: Process,
17
- children: /*#__PURE__*/ _jsx(ProcessDispatchContext, {
18
- value: dispatch,
19
- children: children
20
- })
21
- });
22
- }
23
- export function useProcesses() {
24
- return useContext(ProcessContext);
25
- }
26
- export function useProcessDispatch() {
27
- return useContext(ProcessDispatchContext);
28
- }
29
- function ProcessReducer(processes, action) {
30
- switch(action.type){
31
- case 'added':
32
- {
33
- if (processes.find((x)=>x.id === action.process.id)) {
34
- console.log(`${action.process.id} process added a second time`);
35
- return processes;
36
- }
37
- return [
38
- ...processes,
39
- action.process
40
- ];
41
- }
42
- case 'changed':
43
- {
44
- return processes.map((x)=>x.id === action.process.id ? action.process : x);
45
- }
46
- default:
47
- {
48
- throw Error(`Unknown action: ${action.type}`);
49
- }
50
- }
51
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/ProcessContext.tsx"],"sourcesContent":["import { createContext, useContext, useReducer } from 'react';\n\nconst ProcessContext = createContext(null);\nconst ProcessDispatchContext = createContext(null);\n\nexport function ProcessProvider({ children, store }) {\n const [Process, dispatch] = useReducer(ProcessReducer, []);\n\n store.on('added', (process) => dispatch({ type: 'added', process }));\n store.on('changed', (process) => dispatch({ type: 'changed', process }));\n\n return (\n <ProcessContext value={Process}>\n <ProcessDispatchContext value={dispatch}>{children}</ProcessDispatchContext>\n </ProcessContext>\n );\n}\n\nexport function useProcesses() {\n return useContext(ProcessContext);\n}\n\nexport function useProcessDispatch() {\n return useContext(ProcessDispatchContext);\n}\n\nfunction ProcessReducer(processes, action) {\n switch (action.type) {\n case 'added': {\n if (processes.find((x) => x.id === action.process.id)) {\n console.log(`${action.process.id} process added a second time`);\n return processes;\n }\n return [...processes, action.process];\n }\n case 'changed': {\n return processes.map((x) => (x.id === action.process.id ? action.process : x));\n }\n default: {\n throw Error(`Unknown action: ${action.type}`);\n }\n }\n}\n"],"names":["createContext","useContext","useReducer","ProcessContext","ProcessDispatchContext","ProcessProvider","children","store","Process","dispatch","ProcessReducer","on","process","type","value","useProcesses","useProcessDispatch","processes","action","find","x","id","console","log","map","Error"],"mappings":";AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAQ,QAAQ;AAE9D,MAAMC,+BAAiBH,cAAc;AACrC,MAAMI,uCAAyBJ,cAAc;AAE7C,OAAO,SAASK,gBAAgB,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IACjD,MAAM,CAACC,SAASC,SAAS,GAAGP,WAAWQ,gBAAgB,EAAE;IAEzDH,MAAMI,EAAE,CAAC,SAAS,CAACC,UAAYH,SAAS;YAAEI,MAAM;YAASD;QAAQ;IACjEL,MAAMI,EAAE,CAAC,WAAW,CAACC,UAAYH,SAAS;YAAEI,MAAM;YAAWD;QAAQ;IAErE,qBACE,KAACT;QAAeW,OAAON;kBACrB,cAAA,KAACJ;YAAuBU,OAAOL;sBAAWH;;;AAGhD;AAEA,OAAO,SAASS;IACd,OAAOd,WAAWE;AACpB;AAEA,OAAO,SAASa;IACd,OAAOf,WAAWG;AACpB;AAEA,SAASM,eAAeO,SAAS,EAAEC,MAAM;IACvC,OAAQA,OAAOL,IAAI;QACjB,KAAK;YAAS;gBACZ,IAAII,UAAUE,IAAI,CAAC,CAACC,IAAMA,EAAEC,EAAE,KAAKH,OAAON,OAAO,CAACS,EAAE,GAAG;oBACrDC,QAAQC,GAAG,CAAC,GAAGL,OAAON,OAAO,CAACS,EAAE,CAAC,4BAA4B,CAAC;oBAC9D,OAAOJ;gBACT;gBACA,OAAO;uBAAIA;oBAAWC,OAAON,OAAO;iBAAC;YACvC;QACA,KAAK;YAAW;gBACd,OAAOK,UAAUO,GAAG,CAAC,CAACJ,IAAOA,EAAEC,EAAE,KAAKH,OAAON,OAAO,CAACS,EAAE,GAAGH,OAAON,OAAO,GAAGQ;YAC7E;QACA;YAAS;gBACP,MAAMK,MAAM,CAAC,gBAAgB,EAAEP,OAAOL,IAAI,EAAE;YAC9C;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/state/ProcessStore.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessUpdate } from '../types.js';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class ProcessStore {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n add(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n update(id: string, update: ChildProcessUpdate): void {\n const found = this.processes.find((x) => x.id === id);\n if (!found) {\n console.log(`Process ${id} not found`);\n return;\n }\n Object.assign(found, update);\n this.onRender();\n }\n}\n"],"names":["ProcessStore","data","processes","add","process","push","onRender","update","id","found","find","x","console","log","Object","assign","Error"],"mappings":"AAKe,MAAMA;IAUnBC,OAAkB;QAChB,OAAO,IAAI,CAACC,SAAS;IACvB;IAEAC,IAAIC,OAAqB,EAAQ;QAC/B,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACE,QAAQ;IACf;IAEAC,OAAOC,EAAU,EAAED,MAA0B,EAAQ;QACnD,MAAME,QAAQ,IAAI,CAACP,SAAS,CAACQ,IAAI,CAAC,CAACC,IAAMA,EAAEH,EAAE,KAAKA;QAClD,IAAI,CAACC,OAAO;YACVG,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEL,GAAG,UAAU,CAAC;YACrC;QACF;QACAM,OAAOC,MAAM,CAACN,OAAOF;QACrB,IAAI,CAACD,QAAQ;IACf;IAvBA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIU,MAAM;QAC/B,IAAI,CAACd,SAAS,GAAG,EAAE;QACnB,IAAI,CAACI,QAAQ,GAAGA;IAClB;AAoBF;AA5BA,SAAqBN,0BA4BpB"}