spawn-term 0.0.0 → 0.0.1
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/esm/components/App.mjs.map +1 -0
- package/dist/esm/{terminal/components → components}/ChildProcess.mjs +2 -4
- package/dist/esm/components/ChildProcess.mjs.map +1 -0
- package/dist/esm/components/Spinner.mjs +17 -0
- package/dist/esm/components/Spinner.mjs.map +1 -0
- package/dist/esm/createApp.mjs.map +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/addLines.mjs +2 -1
- package/dist/esm/lib/addLines.mjs.map +1 -1
- package/dist/esm/lib/concatWritable.mjs +2 -1
- package/dist/esm/lib/concatWritable.mjs.map +1 -1
- package/dist/esm/lib/figures.mjs.map +1 -0
- package/dist/esm/lib/uuid.mjs.map +1 -0
- package/dist/esm/types.mjs +5 -1
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/worker.mjs +12 -5
- package/dist/esm/worker.mjs.map +1 -1
- package/dist/types/{terminal/components → components}/App.d.ts +1 -1
- package/dist/types/{terminal/components → components}/ChildProcess.d.ts +2 -2
- package/dist/types/components/Spinner.d.ts +5 -0
- package/dist/types/{terminal/createApp.d.ts → createApp.d.ts} +1 -1
- package/dist/types/types.d.ts +12 -2
- package/package.json +2 -2
- package/dist/esm/terminal/components/App.mjs.map +0 -1
- package/dist/esm/terminal/components/ChildProcess.mjs.map +0 -1
- package/dist/esm/terminal/createApp.mjs.map +0 -1
- package/dist/esm/terminal/lib/RenderSpinner.mjs +0 -21
- package/dist/esm/terminal/lib/RenderSpinner.mjs.map +0 -1
- package/dist/esm/terminal/lib/figures.mjs.map +0 -1
- package/dist/esm/terminal/lib/uuid.mjs.map +0 -1
- package/dist/types/terminal/lib/RenderSpinner.d.ts +0 -9
- /package/dist/esm/{terminal/components → components}/App.mjs +0 -0
- /package/dist/esm/{terminal/createApp.mjs → createApp.mjs} +0 -0
- /package/dist/esm/{terminal/lib → lib}/figures.mjs +0 -0
- /package/dist/esm/{terminal/lib → lib}/uuid.mjs +0 -0
- /package/dist/types/{terminal/lib → lib}/figures.d.ts +0 -0
- /package/dist/types/{terminal/lib → lib}/uuid.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["// @ts-ignore\nimport { Box } from 'ink';\nimport React from 'react';\nimport type { ChildProcess as ChildProcessT } from '../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport interface AppProps {\n list: ChildProcessT[];\n}\n\nexport default function App({ list }: AppProps) {\n const running = list.filter((x) => ['running'].indexOf(x.state) >= 0);\n const done = list.filter((x) => ['error', 'success'].indexOf(x.state) >= 0);\n\n return (\n <>\n <Box flexDirection=\"column\">\n {running.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n <Box flexDirection=\"column\" borderStyle=\"single\" borderColor=\"black\" borderBottom={true} borderTop={false} borderLeft={false} borderRight={false} />\n <Box flexDirection=\"column\">\n {done.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n </>\n );\n}\n"],"names":["Box","React","ChildProcess","App","list","running","filter","x","indexOf","state","done","flexDirection","map","item","key","id","borderStyle","borderColor","borderBottom","borderTop","borderLeft","borderRight"],"mappings":"AAAA,aAAa;AACb,SAASA,GAAG,QAAQ,MAAM;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAOC,kBAAkB,oBAAoB;AAM7C,eAAe,SAASC,IAAI,EAAEC,IAAI,EAAY;IAC5C,MAAMC,UAAUD,KAAKE,MAAM,CAAC,CAACC,IAAM;YAAC;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IACnE,MAAMC,OAAON,KAAKE,MAAM,CAAC,CAACC,IAAM;YAAC;YAAS;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IAEzE,qBACE,wDACE,oBAACT;QAAIW,eAAc;OAChBN,QAAQO,GAAG,CAAC,CAACC,qBACZ,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;YAAG,GAAGF,IAAI;4BAGxC,oBAACb;QAAIW,eAAc;QAASK,aAAY;QAASC,aAAY;QAAQC,cAAc;QAAMC,WAAW;QAAOC,YAAY;QAAOC,aAAa;sBAC3I,oBAACrB;QAAIW,eAAc;OAChBD,KAAKE,GAAG,CAAC,CAACC,qBACT,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;YAAG,GAAGF,IAAI;;AAK9C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import RenderSpinner from '../lib/RenderSpinner.mjs';
|
|
5
4
|
import figures from '../lib/figures.mjs';
|
|
5
|
+
import Spinner from './Spinner.mjs';
|
|
6
6
|
// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2
|
|
7
7
|
const spinner = {
|
|
8
8
|
interval: 80,
|
|
@@ -26,9 +26,7 @@ const ICONS = {
|
|
|
26
26
|
success: /*#__PURE__*/ React.createElement(Text, {
|
|
27
27
|
color: "green"
|
|
28
28
|
}, figures.tick),
|
|
29
|
-
running: /*#__PURE__*/ React.createElement(
|
|
30
|
-
spinner: spinner
|
|
31
|
-
})
|
|
29
|
+
running: /*#__PURE__*/ React.createElement(Spinner, spinner)
|
|
32
30
|
};
|
|
33
31
|
const POINTERS = {
|
|
34
32
|
error: /*#__PURE__*/ React.createElement(Text, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["// @ts-ignore\nimport { Box, Text } from 'ink';\nimport React from 'react';\nimport figures from '../lib/figures.js';\nimport Spinner from './Spinner.js';\n\nimport type { Line, State } from '../types.js';\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\nconst POINTERS = {\n error: <Text color=\"red\">{figures.pointer}</Text>,\n default: <Text color=\"yellow\">{figures.pointer}</Text>,\n};\n\ntype ChildProcessProps = {\n title: string;\n state: State;\n lines: Line[];\n isExpanded?: boolean;\n};\n\nexport default function ChildProcess({ title, state, lines, isExpanded }: ChildProcessProps) {\n const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];\n const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;\n\n return (\n <Box flexDirection=\"column\">\n <Box>\n <Box marginRight={1}>\n <Text>{icon}</Text>\n </Box>\n <Text>{title}</Text>\n </Box>\n {output ? (\n <Box marginLeft={2}>\n <Text color=\"gray\">{`${figures.arrowRight} ${output}`}</Text>\n </Box>\n ) : undefined}\n {/* {state === 'running' && lines.length > 0 && (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text>{line}</Text>\n </Box>\n ))}\n </Box>\n )} */}\n </Box>\n );\n}\n"],"names":["Box","Text","React","figures","Spinner","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","POINTERS","pointer","default","ChildProcess","title","state","lines","isExpanded","icon","output","length","undefined","flexDirection","marginRight","marginLeft","arrowRight"],"mappings":"AAAA,aAAa;AACb,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,aAAa,oBAAoB;AACxC,OAAOC,aAAa,eAAe;AAInC,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,oBAACR;QAAKS,OAAM;OAAOP,QAAQQ,KAAK;IACvCC,uBAAS,oBAACX;QAAKS,OAAM;OAASP,QAAQU,IAAI;IAC1CC,uBAAS,oBAACV,SAAYC;AACxB;AAEA,MAAMU,WAAW;IACfN,qBAAO,oBAACR;QAAKS,OAAM;OAAOP,QAAQa,OAAO;IACzCC,uBAAS,oBAAChB;QAAKS,OAAM;OAAUP,QAAQa,OAAO;AAChD;AASA,eAAe,SAASE,aAAa,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAqB;IACzF,MAAMC,OAAOD,aAAaP,QAAQ,CAACK,MAAM,IAAIL,SAASE,OAAO,GAAGT,KAAK,CAACY,MAAM;IAC5E,MAAMI,SAASJ,UAAU,aAAaC,MAAMI,MAAM,GAAGJ,KAAK,CAACA,MAAMI,MAAM,GAAG,EAAE,GAAGC;IAE/E,qBACE,oBAAC1B;QAAI2B,eAAc;qBACjB,oBAAC3B,yBACC,oBAACA;QAAI4B,aAAa;qBAChB,oBAAC3B,YAAMsB,sBAET,oBAACtB,YAAMkB,SAERK,uBACC,oBAACxB;QAAI6B,YAAY;qBACf,oBAAC5B;QAAKS,OAAM;OAAQ,GAAGP,QAAQ2B,UAAU,CAAC,CAAC,EAAEN,QAAQ,KAErDE;AAaV"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Text } from 'ink';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
export default function Spinner({ interval, frames }) {
|
|
4
|
+
const [index, setIndex] = useState(0);
|
|
5
|
+
useEffect(()=>{
|
|
6
|
+
const timer = setInterval(()=>{
|
|
7
|
+
setIndex((index)=>index === frames.length - 1 ? 0 : index + 1);
|
|
8
|
+
}, interval);
|
|
9
|
+
return ()=>{
|
|
10
|
+
clearInterval(timer);
|
|
11
|
+
};
|
|
12
|
+
}, [
|
|
13
|
+
interval,
|
|
14
|
+
frames
|
|
15
|
+
]);
|
|
16
|
+
return /*#__PURE__*/ React.createElement(Text, null, frames[index]);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import { Text } from 'ink';\nimport React, { useState, useEffect } from 'react';\n\nexport type SpinnerProps = {\n interval: number;\n frames: string[];\n};\n\nexport default function Spinner({ interval, frames }: SpinnerProps) {\n const [index, setIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setIndex((index) => (index === frames.length - 1 ? 0 : index + 1));\n }, interval);\n return () => {\n clearInterval(timer);\n };\n }, [interval, frames]);\n\n return <Text>{frames[index]}</Text>;\n}\n"],"names":["Text","React","useState","useEffect","Spinner","interval","frames","index","setIndex","timer","setInterval","length","clearInterval"],"mappings":"AAAA,SAASA,IAAI,QAAQ,MAAM;AAC3B,OAAOC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AAOnD,eAAe,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAgB;IAChE,MAAM,CAACC,OAAOC,SAAS,GAAGN,SAAS;IAEnCC,UAAU;QACR,MAAMM,QAAQC,YAAY;YACxBF,SAAS,CAACD,QAAWA,UAAUD,OAAOK,MAAM,GAAG,IAAI,IAAIJ,QAAQ;QACjE,GAAGF;QACH,OAAO;YACLO,cAAcH;QAChB;IACF,GAAG;QAACJ;QAAUC;KAAO;IAErB,qBAAO,oBAACN,YAAMM,MAAM,CAACC,MAAM;AAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport React from 'react';\nimport App from './components/App.js';\nimport uuid from './lib/uuid.js';\nimport type { ChildProcess } from './types.js';\n\nexport default function createApp() {\n let refCount = 0;\n let list: ChildProcess[] | null = null;\n let inkApp: Instance | null = null;\n\n return {\n addItem(data: Partial<ChildProcess>) {\n if (!list) throw new Error('Expecting list');\n const item = { id: uuid(), title: '', state: 'pending', lines: [], ...data } as ChildProcess;\n list.push(item);\n return item;\n },\n rerender() {\n if (inkApp) inkApp.rerender(<App list={list} />);\n },\n retain() {\n if (++refCount > 1) return;\n if (inkApp) throw new Error('Not expecting app');\n list = [];\n inkApp = render(<App list={list} />);\n },\n release() {\n if (--refCount > 0) return;\n if (!inkApp) throw new Error('Expecting app');\n inkApp.unmount();\n inkApp = null;\n list = null;\n },\n };\n}\n"],"names":["render","React","App","uuid","createApp","refCount","list","inkApp","addItem","data","Error","item","id","title","state","lines","push","rerender","retain","release","unmount"],"mappings":"AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,UAAU,gBAAgB;AAGjC,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,OAA8B;IAClC,IAAIC,SAA0B;IAE9B,OAAO;QACLC,SAAQC,IAA2B;YACjC,IAAI,CAACH,MAAM,MAAM,IAAII,MAAM;YAC3B,MAAMC,OAAO;gBAAEC,IAAIT;gBAAQU,OAAO;gBAAIC,OAAO;gBAAWC,OAAO,EAAE;gBAAE,GAAGN,IAAI;YAAC;YAC3EH,KAAKU,IAAI,CAACL;YACV,OAAOA;QACT;QACAM;YACE,IAAIV,QAAQA,OAAOU,QAAQ,eAAC,oBAACf;gBAAII,MAAMA;;QACzC;QACAY;YACE,IAAI,EAAEb,WAAW,GAAG;YACpB,IAAIE,QAAQ,MAAM,IAAIG,MAAM;YAC5BJ,OAAO,EAAE;YACTC,SAASP,qBAAO,oBAACE;gBAAII,MAAMA;;QAC7B;QACAa;YACE,IAAI,EAAEd,WAAW,GAAG;YACpB,IAAI,CAACE,QAAQ,MAAM,IAAIG,MAAM;YAC7BH,OAAOa,OAAO;YACdb,SAAS;YACTD,OAAO;QACT;IACF;AACF"}
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index.ts"],"sourcesContent":["import worker from './worker.js';\n\nimport type { SpawnCallback, SpawnOptions, TerminalOptions } from './types.js';\n\nexport * from './types.js';\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["worker","spawnTerminal","command","args","spawnOptions","options","callback","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,cAAc;AAIjC,cAAc,aAAa;AAC3B,eAAe,SAASC,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACpK,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAON,OAAOE,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWT,OAAOE,SAASC,MAAMC,cAAcC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import eos from 'end-of-stream';
|
|
1
2
|
import { Writable } from 'readable-stream';
|
|
2
3
|
const regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
|
|
3
4
|
export default function addLines(addLine) {
|
|
@@ -11,7 +12,7 @@ export default function addLines(addLine) {
|
|
|
11
12
|
callback();
|
|
12
13
|
}
|
|
13
14
|
});
|
|
14
|
-
stream
|
|
15
|
+
eos(stream, ()=>{
|
|
15
16
|
if (last.length) addLine(last);
|
|
16
17
|
last = '';
|
|
17
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import eos from 'end-of-stream';\nimport { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(addLine) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(regEx);\n last = lines.pop();\n lines.forEach((line) => addLine(line));\n callback();\n },\n });\n eos(stream, () => {\n if (last.length) addLine(last);\n last = '';\n });\n return stream;\n}\n"],"names":["eos","Writable","regEx","addLines","addLine","last","stream","write","chunk","_enc","callback","more","toString","lines","split","pop","forEach","line","length"],"mappings":"AAAA,OAAOA,SAAS,gBAAgB;AAChC,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,MAAMC,QAAQ;AAEd,eAAe,SAASC,SAASC,OAAO;IACtC,IAAIC,OAAO;IAEX,MAAMC,SAAS,IAAIL,SAAS;QAC1BM,OAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,MAAMC,OAAON,OAAOG,MAAMI,QAAQ,CAAC;YACnC,MAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBG,OAAOQ,MAAME,GAAG;YAChBF,MAAMG,OAAO,CAAC,CAACC,OAASb,QAAQa;YAChCP;QACF;IACF;IACAV,IAAIM,QAAQ;QACV,IAAID,KAAKa,MAAM,EAAEd,QAAQC;QACzBA,OAAO;IACT;IACA,OAAOC;AACT"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import eos from 'end-of-stream';
|
|
1
2
|
import { Writable } from 'readable-stream';
|
|
2
3
|
export default function concatWritable(callback) {
|
|
3
4
|
const chunks = [];
|
|
@@ -7,6 +8,6 @@ export default function concatWritable(callback) {
|
|
|
7
8
|
next();
|
|
8
9
|
}
|
|
9
10
|
});
|
|
10
|
-
stream
|
|
11
|
+
eos(stream, ()=>callback(Buffer.concat(chunks.splice(0))));
|
|
11
12
|
return stream;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/concatWritable.ts"],"sourcesContent":["import eos from 'end-of-stream';\nimport { Writable } from 'readable-stream';\n\nexport default function concatWritable(callback) {\n const chunks = [];\n const stream = new Writable({\n write: (chunk, _encoding, next) => {\n chunks.push(chunk);\n next();\n },\n });\n eos(stream, () => callback(Buffer.concat(chunks.splice(0))));\n return stream;\n}\n"],"names":["eos","Writable","concatWritable","callback","chunks","stream","write","chunk","_encoding","next","push","Buffer","concat","splice"],"mappings":"AAAA,OAAOA,SAAS,gBAAgB;AAChC,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,eAAe,SAASC,eAAeC,QAAQ;IAC7C,MAAMC,SAAS,EAAE;IACjB,MAAMC,SAAS,IAAIJ,SAAS;QAC1BK,OAAO,CAACC,OAAOC,WAAWC;YACxBL,OAAOM,IAAI,CAACH;YACZE;QACF;IACF;IACAT,IAAIK,QAAQ,IAAMF,SAASQ,OAAOC,MAAM,CAACR,OAAOS,MAAM,CAAC;IACvD,OAAOR;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/figures.ts"],"sourcesContent":["// Fork of https://github.com/sindresorhus/figures\nimport isUnicodeSupported from 'is-unicode-supported';\n\nconst symbols = {\n arrowRight: '→',\n tick: '✔',\n info: 'ℹ',\n warning: '⚠',\n cross: '✖',\n squareSmallFilled: '◼',\n pointer: '❯',\n};\n\nconst fallbackSymbols = {\n arrowRight: '→',\n tick: '√',\n info: 'i',\n warning: '‼',\n cross: '×',\n squareSmallFilled: '■',\n pointer: '>',\n};\n\nexport default isUnicodeSupported() ? symbols : fallbackSymbols;\n"],"names":["isUnicodeSupported","symbols","arrowRight","tick","info","warning","cross","squareSmallFilled","pointer","fallbackSymbols"],"mappings":"AAAA,kDAAkD;AAClD,OAAOA,wBAAwB,uBAAuB;AAEtD,MAAMC,UAAU;IACdC,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;AAEA,MAAMC,kBAAkB;IACtBP,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;AAEA,eAAeR,uBAAuBC,UAAUQ,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/uuid.ts"],"sourcesContent":["// https://stackoverflow.com/a/8809472/3150390\nexport default function uuid() {\n let d = new Date().getTime();\n let d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n let r = Math.random() * 16;\n if (d > 0) {\n r = ((d + r) % 16) | 0;\n d = Math.floor(d / 16);\n } else {\n r = ((d2 + r) % 16) | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === 'x' ? r : (r & 0x7) | 0x8).toString(16);\n });\n}\n"],"names":["uuid","d","Date","getTime","d2","performance","now","replace","c","r","Math","random","floor","toString"],"mappings":"AAAA,8CAA8C;AAC9C,eAAe,SAASA;IACtB,IAAIC,IAAI,IAAIC,OAAOC,OAAO;IAC1B,IAAIC,KAAK,AAAC,OAAOC,gBAAgB,eAAeA,YAAYC,GAAG,IAAID,YAAYC,GAAG,KAAK,QAAS;IAChG,OAAO,uCAAuCC,OAAO,CAAC,SAAS,CAACC;QAC9D,IAAIC,IAAIC,KAAKC,MAAM,KAAK;QACxB,IAAIV,IAAI,GAAG;YACTQ,IAAI,AAAER,CAAAA,IAAIQ,CAAAA,IAAK,KAAM;YACrBR,IAAIS,KAAKE,KAAK,CAACX,IAAI;QACrB,OAAO;YACLQ,IAAI,AAAEL,CAAAA,KAAKK,CAAAA,IAAK,KAAM;YACtBL,KAAKM,KAAKE,KAAK,CAACR,KAAK;QACvB;QACA,OAAO,AAACI,CAAAA,MAAM,MAAMC,IAAI,AAACA,IAAI,MAAO,GAAE,EAAGI,QAAQ,CAAC;IACpD;AACF"}
|
package/dist/esm/types.mjs
CHANGED
package/dist/esm/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n summary?: boolean;\n};\n\nexport enum LineType {\n stdout = 1,\n stderr = 2,\n}\nexport type Line = {\n type: LineType;\n text: string;\n};\n\nexport type State = 'running' | 'error' | 'success';\nexport type ChildProcess = {\n id: string;\n title: string;\n state: State;\n lines: Line[];\n};\n"],"names":["LineType"],"mappings":"AAAA,aAAa;AAOb,OAAO,IAAA,AAAKA,kCAAAA;;;WAAAA;MAGX"}
|
package/dist/esm/worker.mjs
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import spawn, { crossSpawn } from 'cross-spawn-cb';
|
|
3
3
|
import eos from 'end-of-stream';
|
|
4
4
|
import Queue from 'queue-cb';
|
|
5
|
+
import createApp from './createApp.mjs';
|
|
5
6
|
import addLines from './lib/addLines.mjs';
|
|
6
7
|
import concatWritable from './lib/concatWritable.mjs';
|
|
7
|
-
import
|
|
8
|
+
import { LineType } from './types.mjs';
|
|
8
9
|
const terminal = createApp();
|
|
9
10
|
import throttle from 'lodash.throttle';
|
|
10
11
|
const THROTTLE = 100;
|
|
@@ -33,8 +34,11 @@ export default function spawnTerminal(command, args, spawnOptions, _options, cal
|
|
|
33
34
|
const queue = new Queue();
|
|
34
35
|
if (cp.stdout) {
|
|
35
36
|
if (stdio === 'inherit') {
|
|
36
|
-
outputs.stdout = addLines((
|
|
37
|
-
item.lines.push(
|
|
37
|
+
outputs.stdout = addLines((text)=>{
|
|
38
|
+
item.lines.push({
|
|
39
|
+
type: LineType.stdout,
|
|
40
|
+
text
|
|
41
|
+
});
|
|
38
42
|
rerender();
|
|
39
43
|
});
|
|
40
44
|
queue.defer(eos.bind(null, cp.stdout.pipe(outputs.stdout)));
|
|
@@ -47,8 +51,11 @@ export default function spawnTerminal(command, args, spawnOptions, _options, cal
|
|
|
47
51
|
}
|
|
48
52
|
if (cp.stderr) {
|
|
49
53
|
if (stdio === 'inherit') {
|
|
50
|
-
outputs.stderr = addLines((
|
|
51
|
-
item.lines.push(
|
|
54
|
+
outputs.stderr = addLines((text)=>{
|
|
55
|
+
item.lines.push({
|
|
56
|
+
type: LineType.stderr,
|
|
57
|
+
text
|
|
58
|
+
});
|
|
52
59
|
rerender();
|
|
53
60
|
});
|
|
54
61
|
cp.stderr.pipe(outputs.stderr);
|
package/dist/esm/worker.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport eos from 'end-of-stream';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.js';\nimport addLines from './lib/addLines.js';\nimport concatWritable from './lib/concatWritable.js';\n\nimport type { SpawnOptions, TerminalOptions } from './types.js';\nimport { LineType } from './types.js';\n\nconst terminal = createApp();\n\nimport throttle from 'lodash.throttle';\nconst THROTTLE = 100;\nconst rerender = throttle(() => {\n terminal.rerender();\n}, THROTTLE);\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, _options: TerminalOptions, callback) {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n terminal.retain();\n const item = terminal.addItem({ title: [command].concat(args).join(' '), state: 'running' });\n terminal.rerender();\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') {\n outputs.stdout = addLines((text) => {\n item.lines.push({ type: LineType.stdout, text });\n rerender();\n });\n queue.defer(eos.bind(null, cp.stdout.pipe(outputs.stdout)));\n } else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(eos.bind(null, cp.stdout.pipe(outputs.stdout)));\n }\n }\n if (cp.stderr) {\n if (stdio === 'inherit') {\n outputs.stderr = addLines((text) => {\n item.lines.push({ type: LineType.stderr, text });\n rerender();\n });\n cp.stderr.pipe(outputs.stderr);\n queue.defer(eos.bind(null, cp.stderr.pipe(outputs.stderr)));\n } else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(eos.bind(null, cp.stderr.pipe(outputs.stderr)));\n }\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\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 item.state = err ? 'error' : 'success';\n terminal.rerender();\n terminal.release();\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawn","crossSpawn","eos","Queue","createApp","addLines","concatWritable","LineType","terminal","throttle","THROTTLE","rerender","spawnTerminal","command","args","spawnOptions","_options","callback","encoding","stdio","csOptions","retain","item","addItem","title","concat","join","state","cp","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","text","lines","push","type","defer","bind","pipe","output","toString","worker","await","err","res","release"],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { Line, State } from '../types.js';
|
|
2
2
|
type ChildProcessProps = {
|
|
3
3
|
title: string;
|
|
4
4
|
state: State;
|
|
5
|
-
lines:
|
|
5
|
+
lines: Line[];
|
|
6
6
|
isExpanded?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export default function ChildProcess({ title, state, lines, isExpanded }: ChildProcessProps): any;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
export type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';
|
|
2
|
-
export type TerminalOptions =
|
|
2
|
+
export type TerminalOptions = {
|
|
3
|
+
summary?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare enum LineType {
|
|
6
|
+
stdout = 1,
|
|
7
|
+
stderr = 2
|
|
8
|
+
}
|
|
9
|
+
export type Line = {
|
|
10
|
+
type: LineType;
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
3
13
|
export type State = 'running' | 'error' | 'success';
|
|
4
14
|
export type ChildProcess = {
|
|
5
15
|
id: string;
|
|
6
16
|
title: string;
|
|
7
17
|
state: State;
|
|
8
|
-
lines:
|
|
18
|
+
lines: Line[];
|
|
9
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"version": "tsds version"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"cross-spawn-cb": "^2.1.
|
|
39
|
+
"cross-spawn-cb": "^2.1.10",
|
|
40
40
|
"end-of-stream": "^1.4.4",
|
|
41
41
|
"ink": "^5.1.0",
|
|
42
42
|
"is-unicode-supported": "^2.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/components/App.tsx"],"sourcesContent":["// @ts-ignore\nimport { Box } from 'ink';\nimport React from 'react';\nimport type { ChildProcess as ChildProcessT } from '../../types.js';\nimport ChildProcess from './ChildProcess.js';\n\nexport interface AppProps {\n list: ChildProcessT[];\n}\n\nexport default function App({ list }: AppProps) {\n const running = list.filter((x) => ['running'].indexOf(x.state) >= 0);\n const done = list.filter((x) => ['error', 'success'].indexOf(x.state) >= 0);\n\n return (\n <>\n <Box flexDirection=\"column\">\n {running.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n <Box flexDirection=\"column\" borderStyle=\"single\" borderColor=\"black\" borderBottom={true} borderTop={false} borderLeft={false} borderRight={false} />\n <Box flexDirection=\"column\">\n {done.map((item: ChildProcessT) => (\n <ChildProcess key={item.id} {...item} />\n ))}\n </Box>\n </>\n );\n}\n"],"names":["Box","React","ChildProcess","App","list","running","filter","x","indexOf","state","done","flexDirection","map","item","key","id","borderStyle","borderColor","borderBottom","borderTop","borderLeft","borderRight"],"mappings":"AAAA,aAAa;AACb,SAASA,GAAG,QAAQ,MAAM;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAOC,kBAAkB,oBAAoB;AAM7C,eAAe,SAASC,IAAI,EAAEC,IAAI,EAAY;IAC5C,MAAMC,UAAUD,KAAKE,MAAM,CAAC,CAACC,IAAM;YAAC;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IACnE,MAAMC,OAAON,KAAKE,MAAM,CAAC,CAACC,IAAM;YAAC;YAAS;SAAU,CAACC,OAAO,CAACD,EAAEE,KAAK,KAAK;IAEzE,qBACE,wDACE,oBAACT;QAAIW,eAAc;OAChBN,QAAQO,GAAG,CAAC,CAACC,qBACZ,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;YAAG,GAAGF,IAAI;4BAGxC,oBAACb;QAAIW,eAAc;QAASK,aAAY;QAASC,aAAY;QAAQC,cAAc;QAAMC,WAAW;QAAOC,YAAY;QAAOC,aAAa;sBAC3I,oBAACrB;QAAIW,eAAc;OAChBD,KAAKE,GAAG,CAAC,CAACC,qBACT,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;YAAG,GAAGF,IAAI;;AAK9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/components/ChildProcess.tsx"],"sourcesContent":["// @ts-ignore\nimport { Box, Text } from 'ink';\nimport React from 'react';\nimport RenderSpinner from '../lib/RenderSpinner.js';\nimport figures from '../lib/figures.js';\n\ntype State = 'running' | 'success' | 'error';\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: <RenderSpinner spinner={spinner} />,\n};\n\nconst POINTERS = {\n error: <Text color=\"red\">{figures.pointer}</Text>,\n default: <Text color=\"yellow\">{figures.pointer}</Text>,\n};\n\ntype ChildProcessProps = {\n title: string;\n state: State;\n lines: string[];\n isExpanded?: boolean;\n};\n\nexport default function ChildProcess({ title, state, lines, isExpanded }: ChildProcessProps) {\n const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];\n const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;\n\n return (\n <Box flexDirection=\"column\">\n <Box>\n <Box marginRight={1}>\n <Text>{icon}</Text>\n </Box>\n <Text>{title}</Text>\n </Box>\n {output ? (\n <Box marginLeft={2}>\n <Text color=\"gray\">{`${figures.arrowRight} ${output}`}</Text>\n </Box>\n ) : undefined}\n {/* {state === 'running' && lines.length > 0 && (\n <Box flexDirection=\"column\" marginLeft={2}>\n {lines.map((line, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>\n <Box key={index} flexDirection=\"column\" height={1}>\n <Text>{line}</Text>\n </Box>\n ))}\n </Box>\n )} */}\n </Box>\n );\n}\n"],"names":["Box","Text","React","RenderSpinner","figures","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","POINTERS","pointer","default","ChildProcess","title","state","lines","isExpanded","icon","output","length","undefined","flexDirection","marginRight","marginLeft","arrowRight"],"mappings":"AAAA,aAAa;AACb,SAASA,GAAG,EAAEC,IAAI,QAAQ,MAAM;AAChC,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,mBAAmB,0BAA0B;AACpD,OAAOC,aAAa,oBAAoB;AAIxC,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,oBAACR;QAAKS,OAAM;OAAON,QAAQO,KAAK;IACvCC,uBAAS,oBAACX;QAAKS,OAAM;OAASN,QAAQS,IAAI;IAC1CC,uBAAS,oBAACX;QAAcE,SAASA;;AACnC;AAEA,MAAMU,WAAW;IACfN,qBAAO,oBAACR;QAAKS,OAAM;OAAON,QAAQY,OAAO;IACzCC,uBAAS,oBAAChB;QAAKS,OAAM;OAAUN,QAAQY,OAAO;AAChD;AASA,eAAe,SAASE,aAAa,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAqB;IACzF,MAAMC,OAAOD,aAAaP,QAAQ,CAACK,MAAM,IAAIL,SAASE,OAAO,GAAGT,KAAK,CAACY,MAAM;IAC5E,MAAMI,SAASJ,UAAU,aAAaC,MAAMI,MAAM,GAAGJ,KAAK,CAACA,MAAMI,MAAM,GAAG,EAAE,GAAGC;IAE/E,qBACE,oBAAC1B;QAAI2B,eAAc;qBACjB,oBAAC3B,yBACC,oBAACA;QAAI4B,aAAa;qBAChB,oBAAC3B,YAAMsB,sBAET,oBAACtB,YAAMkB,SAERK,uBACC,oBAACxB;QAAI6B,YAAY;qBACf,oBAAC5B;QAAKS,OAAM;OAAQ,GAAGN,QAAQ0B,UAAU,CAAC,CAAC,EAAEN,QAAQ,KAErDE;AAaV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/createApp.tsx"],"sourcesContent":["import { type Instance, render } from 'ink';\nimport React from 'react';\nimport type { ChildProcess } from '../types.js';\nimport App from './components/App.js';\nimport uuid from './lib/uuid.js';\n\nexport default function createApp() {\n let refCount = 0;\n let list: ChildProcess[] | null = null;\n let inkApp: Instance | null = null;\n\n return {\n addItem(data: Partial<ChildProcess>) {\n if (!list) throw new Error('Expecting list');\n const item = { id: uuid(), title: '', state: 'pending', lines: [], ...data } as ChildProcess;\n list.push(item);\n return item;\n },\n rerender() {\n if (inkApp) inkApp.rerender(<App list={list} />);\n },\n retain() {\n if (++refCount > 1) return;\n if (inkApp) throw new Error('Not expecting app');\n list = [];\n inkApp = render(<App list={list} />);\n },\n release() {\n if (--refCount > 0) return;\n if (!inkApp) throw new Error('Expecting app');\n inkApp.unmount();\n inkApp = null;\n list = null;\n },\n };\n}\n"],"names":["render","React","App","uuid","createApp","refCount","list","inkApp","addItem","data","Error","item","id","title","state","lines","push","rerender","retain","release","unmount"],"mappings":"AAAA,SAAwBA,MAAM,QAAQ,MAAM;AAC5C,OAAOC,WAAW,QAAQ;AAE1B,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,UAAU,gBAAgB;AAEjC,eAAe,SAASC;IACtB,IAAIC,WAAW;IACf,IAAIC,OAA8B;IAClC,IAAIC,SAA0B;IAE9B,OAAO;QACLC,SAAQC,IAA2B;YACjC,IAAI,CAACH,MAAM,MAAM,IAAII,MAAM;YAC3B,MAAMC,OAAO;gBAAEC,IAAIT;gBAAQU,OAAO;gBAAIC,OAAO;gBAAWC,OAAO,EAAE;gBAAE,GAAGN,IAAI;YAAC;YAC3EH,KAAKU,IAAI,CAACL;YACV,OAAOA;QACT;QACAM;YACE,IAAIV,QAAQA,OAAOU,QAAQ,eAAC,oBAACf;gBAAII,MAAMA;;QACzC;QACAY;YACE,IAAI,EAAEb,WAAW,GAAG;YACpB,IAAIE,QAAQ,MAAM,IAAIG,MAAM;YAC5BJ,OAAO,EAAE;YACTC,SAASP,qBAAO,oBAACE;gBAAII,MAAMA;;QAC7B;QACAa;YACE,IAAI,EAAEd,WAAW,GAAG;YACpB,IAAI,CAACE,QAAQ,MAAM,IAAIG,MAAM;YAC7BH,OAAOa,OAAO;YACdb,SAAS;YACTD,OAAO;QACT;IACF;AACF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Fork of https://github.com/vadimdemedes/ink-spinner
|
|
2
|
-
import { Text } from 'ink';
|
|
3
|
-
import React, { useState, useEffect } from 'react';
|
|
4
|
-
const RenderSpinner = ({ spinner })=>{
|
|
5
|
-
const [frameIndex, setFrameIndex] = useState(0);
|
|
6
|
-
useEffect(()=>{
|
|
7
|
-
const timer = setInterval(()=>{
|
|
8
|
-
setFrameIndex((currentFrameIndex)=>{
|
|
9
|
-
const isLastFrame = currentFrameIndex === spinner.frames.length - 1;
|
|
10
|
-
return isLastFrame ? 0 : currentFrameIndex + 1;
|
|
11
|
-
});
|
|
12
|
-
}, spinner.interval);
|
|
13
|
-
return ()=>{
|
|
14
|
-
clearInterval(timer);
|
|
15
|
-
};
|
|
16
|
-
}, [
|
|
17
|
-
spinner
|
|
18
|
-
]);
|
|
19
|
-
return /*#__PURE__*/ React.createElement(Text, null, spinner.frames[frameIndex]);
|
|
20
|
-
};
|
|
21
|
-
export default RenderSpinner;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/lib/RenderSpinner.tsx"],"sourcesContent":["// Fork of https://github.com/vadimdemedes/ink-spinner\n\nimport { Text } from 'ink';\nimport React, { useState, useEffect } from 'react';\nimport type { FC } from 'react';\n\nexport type Spinner = {\n interval: number;\n frames: string[];\n};\n\nconst RenderSpinner: FC<{\n spinner: Spinner;\n}> = ({ spinner }) => {\n const [frameIndex, setFrameIndex] = useState(0);\n\n useEffect(() => {\n const timer = setInterval(() => {\n setFrameIndex((currentFrameIndex) => {\n const isLastFrame = currentFrameIndex === spinner.frames.length - 1;\n return isLastFrame ? 0 : currentFrameIndex + 1;\n });\n }, spinner.interval);\n\n return () => {\n clearInterval(timer);\n };\n }, [spinner]);\n\n return <Text>{spinner.frames[frameIndex]}</Text>;\n};\n\nexport default RenderSpinner;\n"],"names":["Text","React","useState","useEffect","RenderSpinner","spinner","frameIndex","setFrameIndex","timer","setInterval","currentFrameIndex","isLastFrame","frames","length","interval","clearInterval"],"mappings":"AAAA,sDAAsD;AAEtD,SAASA,IAAI,QAAQ,MAAM;AAC3B,OAAOC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AAQnD,MAAMC,gBAED,CAAC,EAAEC,OAAO,EAAE;IACf,MAAM,CAACC,YAAYC,cAAc,GAAGL,SAAS;IAE7CC,UAAU;QACR,MAAMK,QAAQC,YAAY;YACxBF,cAAc,CAACG;gBACb,MAAMC,cAAcD,sBAAsBL,QAAQO,MAAM,CAACC,MAAM,GAAG;gBAClE,OAAOF,cAAc,IAAID,oBAAoB;YAC/C;QACF,GAAGL,QAAQS,QAAQ;QAEnB,OAAO;YACLC,cAAcP;QAChB;IACF,GAAG;QAACH;KAAQ;IAEZ,qBAAO,oBAACL,YAAMK,QAAQO,MAAM,CAACN,WAAW;AAC1C;AAEA,eAAeF,cAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/lib/figures.ts"],"sourcesContent":["// Fork of https://github.com/sindresorhus/figures\nimport isUnicodeSupported from 'is-unicode-supported';\n\nconst symbols = {\n arrowRight: '→',\n tick: '✔',\n info: 'ℹ',\n warning: '⚠',\n cross: '✖',\n squareSmallFilled: '◼',\n pointer: '❯',\n};\n\nconst fallbackSymbols = {\n arrowRight: '→',\n tick: '√',\n info: 'i',\n warning: '‼',\n cross: '×',\n squareSmallFilled: '■',\n pointer: '>',\n};\n\nexport default isUnicodeSupported() ? symbols : fallbackSymbols;\n"],"names":["isUnicodeSupported","symbols","arrowRight","tick","info","warning","cross","squareSmallFilled","pointer","fallbackSymbols"],"mappings":"AAAA,kDAAkD;AAClD,OAAOA,wBAAwB,uBAAuB;AAEtD,MAAMC,UAAU;IACdC,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;AAEA,MAAMC,kBAAkB;IACtBP,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;AAEA,eAAeR,uBAAuBC,UAAUQ,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-terminal/src/terminal/lib/uuid.ts"],"sourcesContent":["// https://stackoverflow.com/a/8809472/3150390\nexport default function uuid() {\n let d = new Date().getTime();\n let d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n let r = Math.random() * 16;\n if (d > 0) {\n r = ((d + r) % 16) | 0;\n d = Math.floor(d / 16);\n } else {\n r = ((d2 + r) % 16) | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === 'x' ? r : (r & 0x7) | 0x8).toString(16);\n });\n}\n"],"names":["uuid","d","Date","getTime","d2","performance","now","replace","c","r","Math","random","floor","toString"],"mappings":"AAAA,8CAA8C;AAC9C,eAAe,SAASA;IACtB,IAAIC,IAAI,IAAIC,OAAOC,OAAO;IAC1B,IAAIC,KAAK,AAAC,OAAOC,gBAAgB,eAAeA,YAAYC,GAAG,IAAID,YAAYC,GAAG,KAAK,QAAS;IAChG,OAAO,uCAAuCC,OAAO,CAAC,SAAS,CAACC;QAC9D,IAAIC,IAAIC,KAAKC,MAAM,KAAK;QACxB,IAAIV,IAAI,GAAG;YACTQ,IAAI,AAAER,CAAAA,IAAIQ,CAAAA,IAAK,KAAM;YACrBR,IAAIS,KAAKE,KAAK,CAACX,IAAI;QACrB,OAAO;YACLQ,IAAI,AAAEL,CAAAA,KAAKK,CAAAA,IAAK,KAAM;YACtBL,KAAKM,KAAKE,KAAK,CAACR,KAAK;QACvB;QACA,OAAO,AAACI,CAAAA,MAAM,MAAMC,IAAI,AAACA,IAAI,MAAO,GAAE,EAAGI,QAAQ,CAAC;IACpD;AACF"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|