spawn-term 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/{store/Store.d.cts → Store.d.cts} +3 -1
  2. package/dist/cjs/{store/Store.d.ts → Store.d.ts} +3 -1
  3. package/dist/cjs/{store/Store.js → Store.js} +3 -0
  4. package/dist/cjs/Store.js.map +1 -0
  5. package/dist/cjs/components/App.d.cts +3 -1
  6. package/dist/cjs/components/App.d.ts +3 -1
  7. package/dist/cjs/components/App.js +2 -4
  8. package/dist/cjs/components/App.js.map +1 -1
  9. package/dist/cjs/components/ChildProcess.js +12 -14
  10. package/dist/cjs/components/ChildProcess.js.map +1 -1
  11. package/dist/cjs/createApp.d.cts +1 -1
  12. package/dist/cjs/createApp.d.ts +1 -1
  13. package/dist/cjs/createApp.js +12 -13
  14. package/dist/cjs/createApp.js.map +1 -1
  15. package/dist/esm/{store/Store.d.ts → Store.d.ts} +3 -1
  16. package/dist/esm/{store/Store.js → Store.js} +3 -0
  17. package/dist/esm/Store.js.map +1 -0
  18. package/dist/esm/components/App.d.ts +3 -1
  19. package/dist/esm/components/App.js +1 -4
  20. package/dist/esm/components/App.js.map +1 -1
  21. package/dist/esm/components/ChildProcess.js +12 -14
  22. package/dist/esm/components/ChildProcess.js.map +1 -1
  23. package/dist/esm/createApp.d.ts +1 -1
  24. package/dist/esm/createApp.js +11 -12
  25. package/dist/esm/createApp.js.map +1 -1
  26. package/package.json +1 -2
  27. package/dist/cjs/store/Context.d.cts +0 -3
  28. package/dist/cjs/store/Context.d.ts +0 -3
  29. package/dist/cjs/store/Context.js +0 -13
  30. package/dist/cjs/store/Context.js.map +0 -1
  31. package/dist/cjs/store/Store.js.map +0 -1
  32. package/dist/cjs/store/index.d.cts +0 -2
  33. package/dist/cjs/store/index.d.ts +0 -2
  34. package/dist/cjs/store/index.js +0 -26
  35. package/dist/cjs/store/index.js.map +0 -1
  36. package/dist/esm/store/Context.d.ts +0 -3
  37. package/dist/esm/store/Context.js +0 -2
  38. package/dist/esm/store/Context.js.map +0 -1
  39. package/dist/esm/store/Store.js.map +0 -1
  40. package/dist/esm/store/index.d.ts +0 -2
  41. package/dist/esm/store/index.js +0 -2
  42. package/dist/esm/store/index.js.map +0 -1
@@ -1,9 +1,11 @@
1
- import type { ChildProcess } from '../types.js';
1
+ import type { ChildProcess } from './types.ts';
2
2
  export type RenderFunction = () => void;
3
+ export type StoreData = ChildProcess[];
3
4
  export default class Store {
4
5
  processes: ChildProcess[];
5
6
  onRender: RenderFunction;
6
7
  constructor(onRender: RenderFunction);
8
+ data(): StoreData;
7
9
  addProcess(process: ChildProcess): void;
8
10
  updateProcess(process: ChildProcess): void;
9
11
  }
@@ -1,9 +1,11 @@
1
- import type { ChildProcess } from '../types.js';
1
+ import type { ChildProcess } from './types.ts';
2
2
  export type RenderFunction = () => void;
3
+ export type StoreData = ChildProcess[];
3
4
  export default class Store {
4
5
  processes: ChildProcess[];
5
6
  onRender: RenderFunction;
6
7
  constructor(onRender: RenderFunction);
8
+ data(): StoreData;
7
9
  addProcess(process: ChildProcess): void;
8
10
  updateProcess(process: ChildProcess): void;
9
11
  }
@@ -22,6 +22,9 @@ var Store = /*#__PURE__*/ function() {
22
22
  this.onRender = onRender;
23
23
  }
24
24
  var _proto = Store.prototype;
25
+ _proto.data = function data() {
26
+ return this.processes;
27
+ };
25
28
  _proto.addProcess = function addProcess(process) {
26
29
  this.processes.push(process);
27
30
  this.onRender();
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/Store.ts"],"sourcesContent":["import type { ChildProcess } from './types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","onRender","Error","processes","data","addProcess","process","push","updateProcess","map","x","id"],"mappings":";;;;;;;eAKqBA;;;;;;;;AAAN,IAAA,AAAMA,sBAAN;;aAAMA,MAIPC,QAAwB;gCAJjBD;QAKjB,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM;QAC/B,IAAI,CAACC,SAAS,GAAG,EAAE;QACnB,IAAI,CAACF,QAAQ,GAAGA;;iBAPCD;IAUnBI,OAAAA,IAEC,GAFDA,SAAAA;QACE,OAAO,IAAI,CAACD,SAAS;IACvB;IAEAE,OAAAA,UAGC,GAHDA,SAAAA,WAAWC,OAAqB;QAC9B,IAAI,CAACH,SAAS,CAACI,IAAI,CAACD;QACpB,IAAI,CAACL,QAAQ;IACf;IAEAO,OAAAA,aAGC,GAHDA,SAAAA,cAAcF,OAAqB;QACjC,IAAI,CAACH,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,SAACC;mBAAOA,EAAEC,EAAE,KAAKL,QAAQK,EAAE,GAAGL,UAAUI;;QAC5E,IAAI,CAACT,QAAQ;IACf;WAtBmBD"}
@@ -1 +1,3 @@
1
- export default function App(): import("react").JSX.Element;
1
+ export default function App({ store }: {
2
+ store: any;
3
+ }): import("react").JSX.Element;
@@ -1 +1,3 @@
1
- export default function App(): import("react").JSX.Element;
1
+ export default function App({ store }: {
2
+ store: any;
3
+ }): import("react").JSX.Element;
@@ -10,16 +10,14 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  var _jsxruntime = require("react/jsx-runtime");
12
12
  var _ink = require("ink");
13
- var _react = require("react");
14
- var _index = require("../store/index.js");
15
13
  var _ChildProcess = /*#__PURE__*/ _interop_require_default(require("./ChildProcess.js"));
16
14
  function _interop_require_default(obj) {
17
15
  return obj && obj.__esModule ? obj : {
18
16
  default: obj
19
17
  };
20
18
  }
21
- function App() {
22
- var store = (0, _react.useContext)(_index.Context);
19
+ function App(param) {
20
+ var store = param.store;
23
21
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
24
22
  flexDirection: "column",
25
23
  children: store.processes.map(function(item) {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport { useContext } from 'react';\nimport { Context, type Store } from '../store/index.js';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App() {\n const store = useContext<Store>(Context);\n\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","useContext","Context","Box","flexDirection","processes","map","item","ChildProcess","id"],"mappings":";;;;+BAMA;;;eAAwBA;;;;mBANJ;qBACO;qBACS;mEAEX;;;;;;AAEV,SAASA;IACtB,IAAMC,QAAQC,IAAAA,iBAAU,EAAQC,cAAO;IAEvC,qBACE,qBAACC,QAAG;QAACC,eAAc;kBAChBJ,MAAMK,SAAS,CAACC,GAAG,CAAC,SAACC;iCACpB,qBAACC,qBAAY;gBAAeD,MAAMA;eAAfA,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"}
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _jsxruntime = require("react/jsx-runtime");
12
- var _ansicolors = /*#__PURE__*/ _interop_require_default(require("ansi-colors"));
13
12
  var _ink = require("ink");
14
13
  var _react = require("react");
15
14
  var _ansiRegex = /*#__PURE__*/ _interop_require_default(require("../lib/ansiRegex.js"));
@@ -71,13 +70,13 @@ var SPINNER = {
71
70
  ]
72
71
  };
73
72
  var ICONS = {
74
- // @ts-ignore
75
- error: /*#__PURE__*/ (0, _jsxruntime.jsx)("ink-text", {
76
- children: _ansicolors.default.red(_figures.default.cross)
73
+ error: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
74
+ color: "red",
75
+ children: _figures.default.cross
77
76
  }),
78
- // @ts-ignore
79
- success: /*#__PURE__*/ (0, _jsxruntime.jsx)("ink-text", {
80
- children: _ansicolors.default.green(_figures.default.tick)
77
+ success: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
78
+ color: "green",
79
+ children: _figures.default.tick
81
80
  }),
82
81
  running: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Spinner.default, _object_spread({}, SPINNER))
83
82
  };
@@ -110,13 +109,12 @@ var RunningSummary = /*#__PURE__*/ (0, _react.memo)(function RunningSummary(para
110
109
  });
111
110
  });
112
111
  var renderLine = function(line, index) {
113
- return(// @ts-ignore
114
- /*#__PURE__*/ (0, _jsxruntime.jsx)("ink-text", {
115
- style: {
116
- minHeight: 1
117
- },
118
- children: line.text
119
- }, index));
112
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Box, {
113
+ minHeight: 1,
114
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ink.Text, {
115
+ children: line.text
116
+ })
117
+ }, index);
120
118
  };
121
119
  var Lines = /*#__PURE__*/ (0, _react.memo)(function Lines(param) {
122
120
  var lines = param.lines;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport { 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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { lines } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, lines } = item;\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === LineType.stderr), [lines]);\n const summary = useMemo(() => lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && <RunningSummary line={summary || BLANK_LINE} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n});\n\nexport default memo(function ChildProcess({ item }: ItemProps) {\n const { expanded } = item;\n return expanded ? <Expanded item={item} /> : <Contracted item={item} />;\n});\n"],"names":["REGEX_ANSI","ansiRegex","BLANK_LINE","type","LineType","stdout","text","SPINNER","interval","frames","ICONS","error","ink-text","c","red","figures","cross","success","green","tick","running","Spinner","Header","memo","group","title","state","icon","Box","Text","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","useMemo","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;+BAgHA;;;eAAA;;;;iEAhHc;mBACY;qBACI;gEACR;8DACF;qBAEK;8DACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,IAAMA,aAAaC,IAAAA,kBAAS;AAC5B,IAAMC,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AAeC,MAAMmB,WAAWpD;;YACxDgD,OAAOK,MAAM,GAAG,mBAAK,qBAACZ;gBAAMC,OAAOM;;;;AAG1C;IAEA,yBAAe3B,IAAAA,WAAI,EAAC,SAASmC,aAAa,KAAmB;QAAnB,AAAEV,OAAF,MAAEA;IAC1C,IAAM,AAAEW,WAAaX,KAAbW;IACR,OAAOA,yBAAW,qBAACZ;QAASC,MAAMA;uBAAW,qBAACC;QAAWD,MAAMA;;AACjE"}
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,IA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xD2C,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 { Store } from './store/index.js';
1
+ import { default as Store } from './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 { Store } from './store/index.js';
1
+ import { default as Store } from './Store.js';
2
2
  export type RetainCallback = (app: Store) => undefined;
3
3
  export type ReleaseCallback = () => undefined;
4
4
  export default function createApp(): {
@@ -12,22 +12,24 @@ 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 _Context = /*#__PURE__*/ _interop_require_default(require("./store/Context.js"));
16
- var _index = require("./store/index.js");
15
+ var _Store = /*#__PURE__*/ _interop_require_default(require("./Store.js"));
17
16
  function _interop_require_default(obj) {
18
17
  return obj && obj.__esModule ? obj : {
19
18
  default: obj
20
19
  };
21
20
  }
22
- var THROTTLE = 50;
21
+ var THROTTLE = 100;
23
22
  function createApp() {
24
23
  var refCount = 0;
25
24
  var store = null;
26
25
  var inkApp = null;
26
+ var previousData = null;
27
27
  var rerender = function() {
28
- inkApp === null || inkApp === void 0 ? void 0 : inkApp.rerender(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Context.default.Provider, {
29
- value: store,
30
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {})
28
+ if (!inkApp || !store) return;
29
+ if (store.data() === previousData) return;
30
+ previousData = store.data();
31
+ inkApp.rerender(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
32
+ store: store
31
33
  }));
32
34
  };
33
35
  var rerenderThrottled = (0, _lodashthrottle.default)(rerender, THROTTLE);
@@ -35,13 +37,10 @@ function createApp() {
35
37
  retain: function retain(fn) {
36
38
  if (++refCount > 1) return fn(store);
37
39
  if (store) throw new Error('Not expecting store');
38
- store = new _index.Store(rerenderThrottled);
39
- inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Context.default.Provider, {
40
- value: store,
41
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {})
42
- }), {
43
- patchConsole: false
44
- });
40
+ store = new _Store.default(rerenderThrottled);
41
+ inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_App.default, {
42
+ store: store
43
+ }));
45
44
  fn(store);
46
45
  },
47
46
  release: function release(cb) {
@@ -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 StoreContext from './store/Context.js';\nimport { Store } from './store/index.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 50;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n const rerender = () => {\n inkApp?.rerender(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>\n );\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(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>,\n { patchConsole: false }\n );\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","rerender","StoreContext","Provider","value","App","rerenderThrottled","throttle","retain","fn","Error","Store","render","patchConsole","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";;;;+BAWA;;;eAAwBA;;;;mBAXc;qEACjB;0DACL;8DACS;qBACH;;;;;;AAKtB,IAAMC,WAAW;AAEF,SAASD;IACtB,IAAIE,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAMC,WAAW;QACfD,mBAAAA,6BAAAA,OAAQC,QAAQ,eACd,qBAACC,gBAAY,CAACC,QAAQ;YAACC,OAAOL;sBAC5B,cAAA,qBAACM,YAAG;;IAGV;IACA,IAAMC,oBAAoBC,IAAAA,uBAAQ,EAACN,UAAUJ;IAE7C,OAAO;QACLW,QAAAA,SAAAA,OAAOC,EAAkB;YACvB,IAAI,EAAEX,WAAW,GAAG,OAAOW,GAAGV;YAC9B,IAAIA,OAAO,MAAM,IAAIW,MAAM;YAE3BX,QAAQ,IAAIY,YAAK,CAACL;YAClBN,SAASY,IAAAA,WAAM,gBACb,qBAACV,gBAAY,CAACC,QAAQ;gBAACC,OAAOL;0BAC5B,cAAA,qBAACM,YAAG;gBAEN;gBAAEQ,cAAc;YAAM;YAExBJ,GAAGV;QACL;QACAe,SAAAA,SAAAA,QAAQC,EAAmB;YACzB,IAAI,EAAEjB,WAAW,GAAG,OAAOiB;YAC3B,IAAI,CAAChB,OAAO,MAAM,IAAIW,MAAM;YAE5BT;YACAD,OACGgB,aAAa,GACbC,IAAI,CAAC;uBAAMF;eACXG,KAAK,CAACH;YACTf,OAAOmB,OAAO;YACdnB,SAAS;YACTD,QAAQ;YACRqB,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 './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,9 +1,11 @@
1
- import type { ChildProcess } from '../types.js';
1
+ import type { ChildProcess } from './types.ts';
2
2
  export type RenderFunction = () => void;
3
+ export type StoreData = ChildProcess[];
3
4
  export default class Store {
4
5
  processes: ChildProcess[];
5
6
  onRender: RenderFunction;
6
7
  constructor(onRender: RenderFunction);
8
+ data(): StoreData;
7
9
  addProcess(process: ChildProcess): void;
8
10
  updateProcess(process: ChildProcess): void;
9
11
  }
@@ -1,4 +1,7 @@
1
1
  class Store {
2
+ data() {
3
+ return this.processes;
4
+ }
2
5
  addProcess(process) {
3
6
  this.processes.push(process);
4
7
  this.onRender();
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/Store.ts"],"sourcesContent":["import type { ChildProcess } from './types.ts';\n\nexport type RenderFunction = () => void;\nexport type StoreData = ChildProcess[];\n\nexport default class Store {\n processes: ChildProcess[];\n onRender: RenderFunction;\n\n constructor(onRender: RenderFunction) {\n if (!onRender) throw new Error('missing on render');\n this.processes = [];\n this.onRender = onRender;\n }\n\n data(): StoreData {\n return this.processes;\n }\n\n addProcess(process: ChildProcess): void {\n this.processes.push(process);\n this.onRender();\n }\n\n updateProcess(process: ChildProcess): void {\n this.processes = this.processes.map((x) => (x.id === process.id ? process : x));\n this.onRender();\n }\n}\n"],"names":["Store","data","processes","addProcess","process","push","onRender","updateProcess","map","x","id","Error"],"mappings":"AAKe,MAAMA;IAUnBC,OAAkB;QAChB,OAAO,IAAI,CAACC,SAAS;IACvB;IAEAC,WAAWC,OAAqB,EAAQ;QACtC,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACE,QAAQ;IACf;IAEAC,cAAcH,OAAqB,EAAQ;QACzC,IAAI,CAACF,SAAS,GAAG,IAAI,CAACA,SAAS,CAACM,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKN,QAAQM,EAAE,GAAGN,UAAUK;QAC5E,IAAI,CAACH,QAAQ;IACf;IAlBA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIK,MAAM;QAC/B,IAAI,CAACT,SAAS,GAAG,EAAE;QACnB,IAAI,CAACI,QAAQ,GAAGA;IAClB;AAeF;AAvBA,SAAqBN,mBAuBpB"}
@@ -1 +1,3 @@
1
- export default function App(): import("react").JSX.Element;
1
+ export default function App({ store }: {
2
+ store: any;
3
+ }): import("react").JSX.Element;
@@ -1,10 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box } from 'ink';
3
- import { useContext } from 'react';
4
- import { Context } from '../store/index.js';
5
3
  import ChildProcess from './ChildProcess.js';
6
- export default function App() {
7
- const store = useContext(Context);
4
+ export default function App({ store }) {
8
5
  return /*#__PURE__*/ _jsx(Box, {
9
6
  flexDirection: "column",
10
7
  children: store.processes.map((item)=>/*#__PURE__*/ _jsx(ChildProcess, {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import { Box } from 'ink';\nimport { useContext } from 'react';\nimport { Context, type Store } from '../store/index.js';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport default function App() {\n const store = useContext<Store>(Context);\n\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","useContext","Context","ChildProcess","App","store","flexDirection","processes","map","item","id"],"mappings":";AAAA,SAASA,GAAG,QAAQ,MAAM;AAC1B,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,OAAO,QAAoB,oBAAoB;AAExD,OAAOC,kBAAkB,oBAAoB;AAE7C,eAAe,SAASC;IACtB,MAAMC,QAAQJ,WAAkBC;IAEhC,qBACE,KAACF;QAAIM,eAAc;kBAChBD,MAAME,SAAS,CAACC,GAAG,CAAC,CAACC,qBACpB,KAACN;gBAA2BM,MAAMA;eAAfA,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"}
@@ -27,7 +27,6 @@ function _object_spread(target) {
27
27
  return target;
28
28
  }
29
29
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
- import c from 'ansi-colors';
31
30
  import { Box, Text } from 'ink';
32
31
  import { memo, useMemo } from 'react';
33
32
  import ansiRegex from '../lib/ansiRegex.js';
@@ -56,13 +55,13 @@ const SPINNER = {
56
55
  ]
57
56
  };
58
57
  const ICONS = {
59
- // @ts-ignore
60
- error: /*#__PURE__*/ _jsx("ink-text", {
61
- children: c.red(figures.cross)
58
+ error: /*#__PURE__*/ _jsx(Text, {
59
+ color: "red",
60
+ children: figures.cross
62
61
  }),
63
- // @ts-ignore
64
- success: /*#__PURE__*/ _jsx("ink-text", {
65
- children: c.green(figures.tick)
62
+ success: /*#__PURE__*/ _jsx(Text, {
63
+ color: "green",
64
+ children: figures.tick
66
65
  }),
67
66
  running: /*#__PURE__*/ _jsx(Spinner, _object_spread({}, SPINNER))
68
67
  };
@@ -91,13 +90,12 @@ const RunningSummary = /*#__PURE__*/ memo(function RunningSummary({ line }) {
91
90
  });
92
91
  });
93
92
  const renderLine = (line, index)=>{
94
- return(// @ts-ignore
95
- /*#__PURE__*/ _jsx("ink-text", {
96
- style: {
97
- minHeight: 1
98
- },
99
- children: line.text
100
- }, index));
93
+ return /*#__PURE__*/ _jsx(Box, {
94
+ minHeight: 1,
95
+ children: /*#__PURE__*/ _jsx(Text, {
96
+ children: line.text
97
+ })
98
+ }, index);
101
99
  };
102
100
  const Lines = /*#__PURE__*/ memo(function Lines({ lines }) {
103
101
  return /*#__PURE__*/ _jsx(Box, {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import c from 'ansi-colors';\nimport { 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 // @ts-ignore\n error: <ink-text>{c.red(figures.cross)}</ink-text>,\n // @ts-ignore\n success: <ink-text>{c.green(figures.tick)}</ink-text>,\n running: <Spinner {...SPINNER} />,\n};\n\ntype ItemProps = {\n item: ChildProcessT;\n};\n\ntype HeaderProps = {\n group?: string;\n title: string;\n state: State;\n};\n\nconst Header = memo(\n function Header({ group, title, state }: HeaderProps) {\n const icon = ICONS[state];\n\n return (\n <Box>\n {icon}\n {group && <Text bold>{`${group}${figures.pointer} `}</Text>}\n <Text>{title}</Text>\n </Box>\n );\n },\n (a, b) => a.group === b.group && a.title === b.title && a.state === b.state\n);\n\ntype RunningSummaryProps = {\n line: Line;\n};\n\nconst RunningSummary = memo(function RunningSummary({ line }: RunningSummaryProps) {\n return (\n <Box marginLeft={2}>\n <Text color=\"gray\">{line.text.replace(REGEX_ANSI, '')}</Text>\n </Box>\n );\n});\n\ntype LinesProps = {\n lines: Line[];\n};\n\nconst renderLine = (line, index) => {\n return (\n // @ts-ignore\n <ink-text key={index} style={{ minHeight: 1 }}>\n {line.text}\n {/* @ts-ignore */}\n </ink-text>\n );\n};\n\nconst Lines = memo(function Lines({ lines }: LinesProps) {\n return (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map(renderLine)}\n </Box>\n );\n});\n\nconst Expanded = memo(function Expanded({ item }: ItemProps) {\n const { lines } = item;\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n <Lines lines={lines} />\n </Box>\n );\n});\n\nconst Contracted = memo(function Contracted({ item }: ItemProps) {\n const { state, lines } = item;\n\n // remove ansi codes when displaying single lines\n const errors = useMemo(() => lines.filter((line) => line.type === LineType.stderr), [lines]);\n const summary = useMemo(() => lines.filter((line) => line.text.length > 0 && errors.indexOf(line) < 0).pop(), [lines, errors]);\n\n return (\n <Box flexDirection=\"column\">\n <Header group={item.group} title={item.title} state={item.state} />\n {state === 'running' && <RunningSummary line={summary || BLANK_LINE} />}\n {errors.length > 0 && <Lines lines={errors} />}\n </Box>\n );\n});\n\nexport default memo(function ChildProcess({ item }: ItemProps) {\n const { expanded } = item;\n return expanded ? <Expanded item={item} /> : <Contracted item={item} />;\n});\n"],"names":["c","Box","Text","memo","useMemo","ansiRegex","figures","LineType","Spinner","REGEX_ANSI","BLANK_LINE","type","stdout","text","SPINNER","interval","frames","ICONS","error","ink-text","red","cross","success","green","tick","running","Header","group","title","state","icon","bold","pointer","a","b","RunningSummary","line","marginLeft","color","replace","renderLine","index","style","minHeight","Lines","lines","flexDirection","map","Expanded","item","Contracted","errors","filter","stderr","summary","length","indexOf","pop","ChildProcess","expanded"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,OAAO,cAAc;AAC5B,SAASC,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;IACZ,aAAa;IACbC,qBAAO,KAACC;kBAAUnB,EAAEoB,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EC,OAAOqB,KAAKrB,KAAK;gBAAEC,OAAOoB,KAAKpB,KAAK;;0BAC/D,KAACe;gBAAMC,OAAOA;;;;AAGpB;AAEA,MAAMK,2BAAa/C,KAAK,SAAS+C,WAAW,EAAED,IAAI,EAAa;IAC7D,MAAM,EAAEpB,KAAK,EAAEgB,KAAK,EAAE,GAAGI;IAEzB,iDAAiD;IACjD,MAAME,SAAS/C,QAAQ,IAAMyC,MAAMO,MAAM,CAAC,CAAChB,OAASA,KAAKzB,IAAI,KAAKJ,SAAS8C,MAAM,GAAG;QAACR;KAAM;IAC3F,MAAMS,UAAUlD,QAAQ,IAAMyC,MAAMO,MAAM,CAAC,CAAChB,OAASA,KAAKvB,IAAI,CAAC0C,MAAM,GAAG,KAAKJ,OAAOK,OAAO,CAACpB,QAAQ,GAAGqB,GAAG,IAAI;QAACZ;QAAOM;KAAO;IAE7H,qBACE,MAAClD;QAAI6C,eAAc;;0BACjB,KAACpB;gBAAOC,OAAOsB,KAAKtB,KAAK;gBAAEC,OAAOqB,KAAKrB,KAAK;gBAAEC,OAAOoB,KAAKpB,KAAK;;YAC9DA,UAAU,2BAAa,KAACM;gBAAeC,MAAMkB,WAAW5C;;YACxDyC,OAAOI,MAAM,GAAG,mBAAK,KAACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAehD,KAAK,SAASuD,aAAa,EAAET,IAAI,EAAa;IAC3D,MAAM,EAAEU,QAAQ,EAAE,GAAGV;IACrB,OAAOU,yBAAW,KAACX;QAASC,MAAMA;uBAAW,KAACC;QAAWD,MAAMA;;AACjE,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,OAA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,KAAK,EAAE,GAAGI;IAEzB,iDAAiD;IACjD,MAAME,SAAS3C,QAAQ,IAAMqC,MAAMO,MAAM,CAAC,CAACd,OAASA,KAAKvB,IAAI,KAAKJ,SAAS0C,MAAM,GAAG;QAACR;KAAM;IAC3F,MAAMS,UAAU9C,QAAQ,IAAMqC,MAAMO,MAAM,CAAC,CAACd,OAASA,KAAKrB,IAAI,CAACsC,MAAM,GAAG,KAAKJ,OAAOK,OAAO,CAAClB,QAAQ,GAAGmB,GAAG,IAAI;QAACZ;QAAOM;KAAO;IAE7H,qBACE,MAAC9C;QAAIyC,eAAc;;0BACjB,KAAClB;gBAAOC,OAAOoB,KAAKpB,KAAK;gBAAEC,OAAOmB,KAAKnB,KAAK;gBAAEC,OAAOkB,KAAKlB,KAAK;;YAC9DA,UAAU,2BAAa,KAACM;gBAAeC,MAAMgB,WAAWxC;;YACxDqC,OAAOI,MAAM,GAAG,mBAAK,KAACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAe5C,KAAK,SAASmD,aAAa,EAAET,IAAI,EAAa;IAC3D,MAAM,EAAEU,QAAQ,EAAE,GAAGV;IACrB,OAAOU,yBAAW,KAACX;QAASC,MAAMA;uBAAW,KAACC;QAAWD,MAAMA;;AACjE,GAAG"}
@@ -1,4 +1,4 @@
1
- import { Store } from './store/index.js';
1
+ import { default as Store } from './Store.js';
2
2
  export type RetainCallback = (app: Store) => undefined;
3
3
  export type ReleaseCallback = () => undefined;
4
4
  export default function createApp(): {
@@ -2,17 +2,19 @@ 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 StoreContext from './store/Context.js';
6
- import { Store } from './store/index.js';
7
- const THROTTLE = 50;
5
+ import { default as Store } from './Store.js';
6
+ const THROTTLE = 100;
8
7
  export default function createApp() {
9
8
  let refCount = 0;
10
9
  let store = null;
11
10
  let inkApp = null;
11
+ let previousData = null;
12
12
  const rerender = ()=>{
13
- inkApp === null || inkApp === void 0 ? void 0 : inkApp.rerender(/*#__PURE__*/ _jsx(StoreContext.Provider, {
14
- value: store,
15
- children: /*#__PURE__*/ _jsx(App, {})
13
+ if (!inkApp || !store) return;
14
+ if (store.data() === previousData) return;
15
+ previousData = store.data();
16
+ inkApp.rerender(/*#__PURE__*/ _jsx(App, {
17
+ store: store
16
18
  }));
17
19
  };
18
20
  const rerenderThrottled = throttle(rerender, THROTTLE);
@@ -21,12 +23,9 @@ export default function createApp() {
21
23
  if (++refCount > 1) return fn(store);
22
24
  if (store) throw new Error('Not expecting store');
23
25
  store = new Store(rerenderThrottled);
24
- inkApp = render(/*#__PURE__*/ _jsx(StoreContext.Provider, {
25
- value: store,
26
- children: /*#__PURE__*/ _jsx(App, {})
27
- }), {
28
- patchConsole: false
29
- });
26
+ inkApp = render(/*#__PURE__*/ _jsx(App, {
27
+ store: store
28
+ }));
30
29
  fn(store);
31
30
  },
32
31
  release (cb) {
@@ -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 StoreContext from './store/Context.js';\nimport { Store } from './store/index.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 50;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n const rerender = () => {\n inkApp?.rerender(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>\n );\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(\n <StoreContext.Provider value={store}>\n <App />\n </StoreContext.Provider>,\n { patchConsole: false }\n );\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","StoreContext","Store","THROTTLE","createApp","refCount","store","inkApp","rerender","Provider","value","rerenderThrottled","retain","fn","Error","patchConsole","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,kBAAkB,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,mBAAmB;AAKzC,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,MAAMC,WAAW;QACfD,mBAAAA,6BAAAA,OAAQC,QAAQ,eACd,KAACP,aAAaQ,QAAQ;YAACC,OAAOJ;sBAC5B,cAAA,KAACN;;IAGP;IACA,MAAMW,oBAAoBZ,SAASS,UAAUL;IAE7C,OAAO;QACLS,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMS;YAClBJ,SAAST,qBACP,KAACG,aAAaQ,QAAQ;gBAACC,OAAOJ;0BAC5B,cAAA,KAACN;gBAEH;gBAAEe,cAAc;YAAM;YAExBF,GAAGP;QACL;QACAU,SAAQC,EAAmB;YACzB,IAAI,EAAEZ,WAAW,GAAG,OAAOY;YAC3B,IAAI,CAACX,OAAO,MAAM,IAAIQ,MAAM;YAE5BN;YACAD,OACGW,aAAa,GACbC,IAAI,CAAC,IAAMF,MACXG,KAAK,CAACH;YACTV,OAAOc,OAAO;YACdd,SAAS;YACTD,QAAQ;YACRgB,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 './Store.js';\n\nexport type RetainCallback = (app: Store) => undefined;\nexport type ReleaseCallback = () => undefined;\n\nconst THROTTLE = 100;\n\nexport default function createApp() {\n let refCount = 0;\n let store = null;\n let inkApp: Instance | null = null;\n\n let previousData: StoreData[] = null;\n const rerender = () => {\n if (!inkApp || !store) return;\n if (store.data() === previousData) return;\n previousData = store.data();\n inkApp.rerender(<App store={store} />);\n };\n const rerenderThrottled = throttle(rerender, THROTTLE);\n\n return {\n retain(fn: RetainCallback): undefined {\n if (++refCount > 1) return fn(store);\n if (store) throw new Error('Not expecting store');\n\n store = new Store(rerenderThrottled);\n inkApp = render(<App store={store} />);\n fn(store);\n },\n release(cb: ReleaseCallback): undefined {\n if (--refCount > 0) return cb();\n if (!store) throw new Error('Expecting store');\n\n rerender();\n inkApp\n .waitUntilExit()\n .then(() => cb())\n .catch(cb);\n inkApp.unmount();\n inkApp = null;\n store = null;\n process.stdout.write('\\x1b[?25h'); // show cursor\n },\n };\n}\n"],"names":["render","throttle","App","default","Store","THROTTLE","createApp","refCount","store","inkApp","previousData","rerender","data","rerenderThrottled","retain","fn","Error","release","cb","waitUntilExit","then","catch","unmount","process","stdout","write"],"mappings":";AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,SAAS,sBAAsB;AACtC,SAASC,WAAWC,KAAK,QAAwB,aAAa;AAK9D,MAAMC,WAAW;AAEjB,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,QAAQ;IACZ,IAAIC,SAA0B;IAE9B,IAAIC,eAA4B;IAChC,MAAMC,WAAW;QACf,IAAI,CAACF,UAAU,CAACD,OAAO;QACvB,IAAIA,MAAMI,IAAI,OAAOF,cAAc;QACnCA,eAAeF,MAAMI,IAAI;QACzBH,OAAOE,QAAQ,eAAC,KAACT;YAAIM,OAAOA;;IAC9B;IACA,MAAMK,oBAAoBZ,SAASU,UAAUN;IAE7C,OAAO;QACLS,QAAOC,EAAkB;YACvB,IAAI,EAAER,WAAW,GAAG,OAAOQ,GAAGP;YAC9B,IAAIA,OAAO,MAAM,IAAIQ,MAAM;YAE3BR,QAAQ,IAAIJ,MAAMS;YAClBJ,SAAST,qBAAO,KAACE;gBAAIM,OAAOA;;YAC5BO,GAAGP;QACL;QACAS,SAAQC,EAAmB;YACzB,IAAI,EAAEX,WAAW,GAAG,OAAOW;YAC3B,IAAI,CAACV,OAAO,MAAM,IAAIQ,MAAM;YAE5BL;YACAF,OACGU,aAAa,GACbC,IAAI,CAAC,IAAMF,MACXG,KAAK,CAACH;YACTT,OAAOa,OAAO;YACdb,SAAS;YACTD,QAAQ;YACRe,QAAQC,MAAM,CAACC,KAAK,CAAC,cAAc,cAAc;QACnD;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spawn-term",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -40,7 +40,6 @@
40
40
  "version": "tsds version"
41
41
  },
42
42
  "dependencies": {
43
- "ansi-colors": "^4.1.3",
44
43
  "cross-spawn-cb": "^2.2.9",
45
44
  "ink": "^6.0.0",
46
45
  "lodash.throttle": "^4.1.1",
@@ -1,3 +0,0 @@
1
- import type Store from './Store.js';
2
- declare const _default: import("react").Context<Store>;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type Store from './Store.js';
2
- declare const _default: import("react").Context<Store>;
3
- export default _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
9
- }
10
- });
11
- var _react = require("react");
12
- var _default = /*#__PURE__*/ (0, _react.createContext)(undefined);
13
- /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/store/Context.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type Store from './Store.js';\n\nexport default createContext<Store>(undefined);\n"],"names":["createContext","undefined"],"mappings":";;;;+BAGA;;;eAAA;;;qBAH8B;IAG9B,yBAAeA,IAAAA,oBAAa,EAAQC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/store/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.js';\n\nexport type RenderFunction = () => void;\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 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","addProcess","process","push","updateProcess","map","x","id"],"mappings":";;;;;;;eAIqBA;;;;;;;;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,UAGC,GAHDA,SAAAA,WAAWC,OAAqB;QAC9B,IAAI,CAACF,SAAS,CAACG,IAAI,CAACD;QACpB,IAAI,CAACJ,QAAQ;IACf;IAEAM,OAAAA,aAGC,GAHDA,SAAAA,cAAcF,OAAqB;QACjC,IAAI,CAACF,SAAS,GAAG,IAAI,CAACA,SAAS,CAACK,GAAG,CAAC,SAACC;mBAAOA,EAAEC,EAAE,KAAKL,QAAQK,EAAE,GAAGL,UAAUI;;QAC5E,IAAI,CAACR,QAAQ;IACf;WAlBmBD"}
@@ -1,2 +0,0 @@
1
- export { default as Context } from './Context.js';
2
- export { default as Store } from './Store.js';
@@ -1,2 +0,0 @@
1
- export { default as Context } from './Context.js';
2
- export { default as Store } from './Store.js';
@@ -1,26 +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 Context () {
13
- return _Context.default;
14
- },
15
- get Store () {
16
- return _Store.default;
17
- }
18
- });
19
- var _Context = /*#__PURE__*/ _interop_require_default(require("./Context.js"));
20
- var _Store = /*#__PURE__*/ _interop_require_default(require("./Store.js"));
21
- function _interop_require_default(obj) {
22
- return obj && obj.__esModule ? obj : {
23
- default: obj
24
- };
25
- }
26
- /* 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/store/index.ts"],"sourcesContent":["export { default as Context } from './Context.js';\nexport { default as Store } from './Store.js';\n"],"names":["Context","Store"],"mappings":";;;;;;;;;;;QAAoBA;eAAAA,gBAAO;;QACPC;eAAAA,cAAK;;;8DADU;4DACF"}
@@ -1,3 +0,0 @@
1
- import type Store from './Store.js';
2
- declare const _default: import("react").Context<Store>;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- import { createContext } from 'react';
2
- export default /*#__PURE__*/ createContext(undefined);
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/store/Context.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type Store from './Store.js';\n\nexport default createContext<Store>(undefined);\n"],"names":["createContext","undefined"],"mappings":"AAAA,SAASA,aAAa,QAAQ,QAAQ;AAGtC,6BAAeA,cAAqBC,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/store/Store.ts"],"sourcesContent":["import type { ChildProcess } from '../types.js';\n\nexport type RenderFunction = () => void;\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 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","addProcess","process","processes","push","onRender","updateProcess","map","x","id","Error"],"mappings":"AAIe,MAAMA;IAUnBC,WAAWC,OAAqB,EAAQ;QACtC,IAAI,CAACC,SAAS,CAACC,IAAI,CAACF;QACpB,IAAI,CAACG,QAAQ;IACf;IAEAC,cAAcJ,OAAqB,EAAQ;QACzC,IAAI,CAACC,SAAS,GAAG,IAAI,CAACA,SAAS,CAACI,GAAG,CAAC,CAACC,IAAOA,EAAEC,EAAE,KAAKP,QAAQO,EAAE,GAAGP,UAAUM;QAC5E,IAAI,CAACH,QAAQ;IACf;IAdA,YAAYA,QAAwB,CAAE;QACpC,IAAI,CAACA,UAAU,MAAM,IAAIK,MAAM;QAC/B,IAAI,CAACP,SAAS,GAAG,EAAE;QACnB,IAAI,CAACE,QAAQ,GAAGA;IAClB;AAWF;AAnBA,SAAqBL,mBAmBpB"}
@@ -1,2 +0,0 @@
1
- export { default as Context } from './Context.js';
2
- export { default as Store } from './Store.js';
@@ -1,2 +0,0 @@
1
- export { default as Context } from './Context.js';
2
- export { default as Store } from './Store.js';
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/store/index.ts"],"sourcesContent":["export { default as Context } from './Context.js';\nexport { default as Store } from './Store.js';\n"],"names":["default","Context","Store"],"mappings":"AAAA,SAASA,WAAWC,OAAO,QAAQ,eAAe;AAClD,SAASD,WAAWE,KAAK,QAAQ,aAAa"}