spawn-term 1.0.7 → 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.
- package/dist/cjs/components/App.d.cts +3 -1
- package/dist/cjs/components/App.d.ts +3 -1
- package/dist/cjs/components/App.js +6 -33
- package/dist/cjs/components/App.js.map +1 -1
- package/dist/cjs/components/ChildProcess.d.cts +4 -1
- package/dist/cjs/components/ChildProcess.d.ts +4 -1
- package/dist/cjs/components/ChildProcess.js +20 -10
- package/dist/cjs/components/ChildProcess.js.map +1 -1
- package/dist/cjs/createApp.d.cts +1 -1
- package/dist/cjs/createApp.d.ts +1 -1
- package/dist/cjs/createApp.js +17 -10
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/state/Store.d.cts +11 -0
- package/dist/cjs/state/Store.d.ts +11 -0
- package/dist/cjs/state/Store.js +40 -0
- package/dist/cjs/state/Store.js.map +1 -0
- package/dist/cjs/types.d.cts +0 -7
- package/dist/cjs/types.d.ts +0 -7
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/worker.js +10 -7
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/components/App.d.ts +3 -1
- package/dist/esm/components/App.js +4 -32
- package/dist/esm/components/App.js.map +1 -1
- package/dist/esm/components/ChildProcess.d.ts +4 -1
- package/dist/esm/components/ChildProcess.js +17 -10
- package/dist/esm/components/ChildProcess.js.map +1 -1
- package/dist/esm/createApp.d.ts +1 -1
- package/dist/esm/createApp.js +17 -10
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/state/Store.d.ts +11 -0
- package/dist/esm/state/Store.js +19 -0
- package/dist/esm/state/Store.js.map +1 -0
- package/dist/esm/types.d.ts +0 -7
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/worker.js +8 -7
- package/dist/esm/worker.js.map +1 -1
- package/package.json +2 -1
- package/dist/cjs/state/ProcessContext.d.cts +0 -6
- package/dist/cjs/state/ProcessContext.d.ts +0 -6
- package/dist/cjs/state/ProcessContext.js +0 -139
- package/dist/cjs/state/ProcessContext.js.map +0 -1
- package/dist/cjs/state/ProcessStore.d.cts +0 -8
- package/dist/cjs/state/ProcessStore.d.ts +0 -8
- package/dist/cjs/state/ProcessStore.js +0 -100
- package/dist/cjs/state/ProcessStore.js.map +0 -1
- package/dist/esm/state/ProcessContext.d.ts +0 -6
- package/dist/esm/state/ProcessContext.js +0 -51
- package/dist/esm/state/ProcessContext.js.map +0 -1
- package/dist/esm/state/ProcessStore.d.ts +0 -8
- package/dist/esm/state/ProcessStore.js +0 -22
- package/dist/esm/state/ProcessStore.js.map +0 -1
|
@@ -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:
|
|
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":";;;;;;;;;;;;;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AACX;gBAAMC,OAAOM;;;;AAG1C;AAEA,6BAAe5C,KAAK,SAASmD,aAAa,EAAET,IAAI,EAAa;IAC3D,MAAM,EAAEU,QAAQ,EAAE,GAAGV;IACrB,OAAOU,yBAAW,KAACX;QAASC,MAAMA;uBAAW,KAACC;QAAWD,MAAMA;;AACjE,GAAG"}
|
package/dist/esm/createApp.d.ts
CHANGED
package/dist/esm/createApp.js
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from 'ink';
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
3
4
|
import App from './components/App.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { default as Store } from './state/Store.js';
|
|
6
|
+
const THROTTLE = 100;
|
|
6
7
|
export default function createApp() {
|
|
7
8
|
let refCount = 0;
|
|
8
9
|
let store = null;
|
|
9
10
|
let inkApp = null;
|
|
11
|
+
let previousData = null;
|
|
12
|
+
const rerender = ()=>{
|
|
13
|
+
if (!inkApp || !store) return;
|
|
14
|
+
if (store.data() === previousData) return;
|
|
15
|
+
previousData = store.data();
|
|
16
|
+
inkApp.rerender(/*#__PURE__*/ _jsx(App, {
|
|
17
|
+
store: store
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
const rerenderThrottled = throttle(rerender, THROTTLE);
|
|
10
21
|
return {
|
|
11
22
|
retain (fn) {
|
|
12
23
|
if (++refCount > 1) return fn(store);
|
|
13
24
|
if (store) throw new Error('Not expecting store');
|
|
14
|
-
store = new Store();
|
|
15
|
-
inkApp = render(/*#__PURE__*/ _jsx(
|
|
16
|
-
store: store
|
|
17
|
-
children: /*#__PURE__*/ _jsx(App, {})
|
|
25
|
+
store = new Store(rerenderThrottled);
|
|
26
|
+
inkApp = render(/*#__PURE__*/ _jsx(App, {
|
|
27
|
+
store: store
|
|
18
28
|
}));
|
|
19
29
|
fn(store);
|
|
20
30
|
},
|
|
21
31
|
release (cb) {
|
|
22
32
|
if (--refCount > 0) return cb();
|
|
23
33
|
if (!store) throw new Error('Expecting store');
|
|
24
|
-
|
|
25
|
-
store: store,
|
|
26
|
-
children: /*#__PURE__*/ _jsx(App, {})
|
|
27
|
-
}));
|
|
34
|
+
rerender();
|
|
28
35
|
inkApp.waitUntilExit().then(()=>cb()).catch(cb);
|
|
29
36
|
inkApp.unmount();
|
|
30
37
|
inkApp = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChildProcess } from '../types.js';
|
|
2
|
+
export type RenderFunction = () => void;
|
|
3
|
+
export type StoreData = ChildProcess[];
|
|
4
|
+
export default class Store {
|
|
5
|
+
processes: ChildProcess[];
|
|
6
|
+
onRender: RenderFunction;
|
|
7
|
+
constructor(onRender: RenderFunction);
|
|
8
|
+
data(): StoreData;
|
|
9
|
+
addProcess(process: ChildProcess): void;
|
|
10
|
+
updateProcess(process: ChildProcess): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Store {
|
|
2
|
+
data() {
|
|
3
|
+
return this.processes;
|
|
4
|
+
}
|
|
5
|
+
addProcess(process) {
|
|
6
|
+
this.processes.push(process);
|
|
7
|
+
this.onRender();
|
|
8
|
+
}
|
|
9
|
+
updateProcess(process) {
|
|
10
|
+
this.processes = this.processes.map((x)=>x.id === process.id ? process : x);
|
|
11
|
+
this.onRender();
|
|
12
|
+
}
|
|
13
|
+
constructor(onRender){
|
|
14
|
+
if (!onRender) throw new Error('missing on render');
|
|
15
|
+
this.processes = [];
|
|
16
|
+
this.onRender = onRender;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { Store as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/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"}
|
package/dist/esm/types.d.ts
CHANGED
package/dist/esm/types.js.map
CHANGED
|
@@ -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};\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["export type { SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from 'cross-spawn-cb';\n\nimport type { SpawnError, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n expanded?: boolean;\n};\n\nexport type TerminalCallback = (error?: SpawnError, result?: SpawnResult) => undefined;\n\nexport const LineType = {\n stdout: 1,\n stderr: 2,\n} as const;\n\nexport type Line = {\n type: (typeof LineType)[keyof typeof LineType];\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n group?: string;\n title: string;\n state: State;\n lines: Line[];\n expanded?: boolean;\n};\n"],"names":["LineType","stdout","stderr"],"mappings":"AAWA,OAAO,MAAMA,WAAW;IACtBC,QAAQ;IACRC,QAAQ;AACV,EAAW"}
|
package/dist/esm/worker.js
CHANGED
|
@@ -95,7 +95,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
|
|
|
95
95
|
if (stdio === 'inherit') {
|
|
96
96
|
terminal.retain((store)=>{
|
|
97
97
|
const id = crypto.randomUUID();
|
|
98
|
-
store.
|
|
98
|
+
store.addProcess(_object_spread({
|
|
99
99
|
id,
|
|
100
100
|
title: [
|
|
101
101
|
command
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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);
|
package/dist/esm/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\nimport formatArguments from './lib/formatArguments.js';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,iBAAiB;AACvC,OAAOC,cAAc,oBAAoB;AACzC,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AAGvD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,MAAM,EAAEC,QAA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,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.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"cross-spawn-cb": "^2.2.10",
|
|
44
44
|
"ink": "^6.0.0",
|
|
45
|
+
"lodash.throttle": "^4.1.1",
|
|
45
46
|
"on-one": "^0.1.9",
|
|
46
47
|
"queue-cb": "^1.5.4",
|
|
47
48
|
"react": "^19.1.0"
|
|
@@ -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","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AAO,CAACQ,EAAE,GAAGH,OAAOL,OAAO,GAAGO;;YAC7E;QACA;YAAS;gBACP,MAAMK,MAAM,AAAC,mBAA8B,OAAZP,OAAOJ,IAAI;YAC5C;IACF;AACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import type { ChildProcess, ChildProcessUpdate } from '../types.js';
|
|
3
|
-
export default class ProcessStore extends EventEmitter {
|
|
4
|
-
processes: ChildProcess[];
|
|
5
|
-
constructor();
|
|
6
|
-
add(process: ChildProcess): ChildProcess;
|
|
7
|
-
update(id: string, update: ChildProcessUpdate): void;
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import type { ChildProcess, ChildProcessUpdate } from '../types.js';
|
|
3
|
-
export default class ProcessStore extends EventEmitter {
|
|
4
|
-
processes: ChildProcess[];
|
|
5
|
-
constructor();
|
|
6
|
-
add(process: ChildProcess): ChildProcess;
|
|
7
|
-
update(id: string, update: ChildProcessUpdate): void;
|
|
8
|
-
}
|
|
@@ -1,100 +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 ProcessStore;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _events = require("events");
|
|
12
|
-
function _assert_this_initialized(self) {
|
|
13
|
-
if (self === void 0) {
|
|
14
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
-
}
|
|
16
|
-
return self;
|
|
17
|
-
}
|
|
18
|
-
function _call_super(_this, derived, args) {
|
|
19
|
-
derived = _get_prototype_of(derived);
|
|
20
|
-
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
21
|
-
}
|
|
22
|
-
function _class_call_check(instance, Constructor) {
|
|
23
|
-
if (!(instance instanceof Constructor)) {
|
|
24
|
-
throw new TypeError("Cannot call a class as a function");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function _get_prototype_of(o) {
|
|
28
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
29
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
30
|
-
};
|
|
31
|
-
return _get_prototype_of(o);
|
|
32
|
-
}
|
|
33
|
-
function _inherits(subClass, superClass) {
|
|
34
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
35
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
36
|
-
}
|
|
37
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
38
|
-
constructor: {
|
|
39
|
-
value: subClass,
|
|
40
|
-
writable: true,
|
|
41
|
-
configurable: true
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
45
|
-
}
|
|
46
|
-
function _possible_constructor_return(self, call) {
|
|
47
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
48
|
-
return call;
|
|
49
|
-
}
|
|
50
|
-
return _assert_this_initialized(self);
|
|
51
|
-
}
|
|
52
|
-
function _set_prototype_of(o, p) {
|
|
53
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
54
|
-
o.__proto__ = p;
|
|
55
|
-
return o;
|
|
56
|
-
};
|
|
57
|
-
return _set_prototype_of(o, p);
|
|
58
|
-
}
|
|
59
|
-
function _type_of(obj) {
|
|
60
|
-
"@swc/helpers - typeof";
|
|
61
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
62
|
-
}
|
|
63
|
-
function _is_native_reflect_construct() {
|
|
64
|
-
try {
|
|
65
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
66
|
-
} catch (_) {}
|
|
67
|
-
return (_is_native_reflect_construct = function() {
|
|
68
|
-
return !!result;
|
|
69
|
-
})();
|
|
70
|
-
}
|
|
71
|
-
var ProcessStore = /*#__PURE__*/ function(EventEmitter) {
|
|
72
|
-
"use strict";
|
|
73
|
-
_inherits(ProcessStore, EventEmitter);
|
|
74
|
-
function ProcessStore() {
|
|
75
|
-
_class_call_check(this, ProcessStore);
|
|
76
|
-
var _this;
|
|
77
|
-
_this = _call_super(this, ProcessStore), _this.processes = [];
|
|
78
|
-
if (_this.setMaxListeners) _this.setMaxListeners(Infinity);
|
|
79
|
-
return _this;
|
|
80
|
-
}
|
|
81
|
-
var _proto = ProcessStore.prototype;
|
|
82
|
-
_proto.add = function add(process) {
|
|
83
|
-
this.processes.push(process);
|
|
84
|
-
this.emit('added', process);
|
|
85
|
-
return process;
|
|
86
|
-
};
|
|
87
|
-
_proto.update = function update(id, update) {
|
|
88
|
-
var found = this.processes.find(function(x) {
|
|
89
|
-
return x.id === id;
|
|
90
|
-
});
|
|
91
|
-
if (!found) {
|
|
92
|
-
console.log("Process ".concat(id, " not found"));
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
Object.assign(found, update);
|
|
96
|
-
this.emit('changed', found);
|
|
97
|
-
};
|
|
98
|
-
return ProcessStore;
|
|
99
|
-
}(_events.EventEmitter);
|
|
100
|
-
/* 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/ProcessStore.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport type { ChildProcess, ChildProcessUpdate } from '../types.js';\n\nexport default class ProcessStore extends EventEmitter {\n processes: ChildProcess[] = [];\n\n constructor() {\n super();\n if (this.setMaxListeners) this.setMaxListeners(Infinity);\n }\n\n add(process: ChildProcess): ChildProcess {\n this.processes.push(process);\n this.emit('added', process);\n return process;\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.emit('changed', found);\n }\n}\n"],"names":["ProcessStore","processes","setMaxListeners","Infinity","add","process","push","emit","update","id","found","find","x","console","log","Object","assign","EventEmitter"],"mappings":";;;;;;;eAGqBA;;;sBAHQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,IAAA,AAAMA,6BAAN;;cAAMA;aAAAA;gCAAAA;;gBAIjB,kBAJiBA,qBACnBC,YAA4B,EAAE;QAI5B,IAAI,MAAKC,eAAe,EAAE,MAAKA,eAAe,CAACC;;;iBAL9BH;IAQnBI,OAAAA,GAIC,GAJDA,SAAAA,IAAIC,OAAqB;QACvB,IAAI,CAACJ,SAAS,CAACK,IAAI,CAACD;QACpB,IAAI,CAACE,IAAI,CAAC,SAASF;QACnB,OAAOA;IACT;IAEAG,OAAAA,MAQC,GARDA,SAAAA,OAAOC,EAAU,EAAED,MAA0B;QAC3C,IAAME,QAAQ,IAAI,CAACT,SAAS,CAACU,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,CAACD,IAAI,CAAC,WAAWG;IACvB;WAtBmBV;EAAqBiB,oBAAY"}
|
|
@@ -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"}
|