spawn-term 0.0.9 → 0.1.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/assets/ink.cjs +30816 -0
- package/assets/intl-adapter.cjs +1083 -0
- package/dist/cjs/components/App.cjs +82 -0
- package/dist/cjs/components/App.cjs.map +1 -0
- package/dist/cjs/components/ChildProcess.cjs +81 -0
- package/dist/cjs/components/ChildProcess.cjs.map +1 -0
- package/dist/cjs/components/Spinner.cjs +118 -0
- package/dist/cjs/components/Spinner.cjs.map +1 -0
- package/dist/cjs/createApp.cjs +86 -0
- package/dist/cjs/createApp.cjs.map +1 -0
- package/dist/cjs/index.cjs.cjs +55 -0
- package/dist/cjs/index.cjs.cjs.map +1 -0
- package/dist/cjs/index.esm.cjs +55 -0
- package/dist/cjs/index.esm.cjs.map +1 -0
- package/dist/cjs/ink.cjs +112 -0
- package/dist/cjs/ink.cjs.map +1 -0
- package/dist/cjs/lib/addLines.cjs +32 -0
- package/dist/cjs/lib/addLines.cjs.map +1 -0
- package/dist/cjs/lib/concatWritable.cjs +25 -0
- package/dist/cjs/lib/concatWritable.cjs.map +1 -0
- package/dist/cjs/lib/figures.cjs +43 -0
- package/dist/cjs/lib/figures.cjs.map +1 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/worker.cjs +237 -0
- package/dist/cjs/worker.cjs.map +1 -0
- package/dist/esm/components/App.mjs +35 -10
- package/dist/esm/components/App.mjs.map +1 -1
- package/dist/esm/components/ChildProcess.mjs +12 -3
- package/dist/esm/components/ChildProcess.mjs.map +1 -1
- package/dist/esm/components/Spinner.mjs +1 -1
- package/dist/esm/components/Spinner.mjs.map +1 -1
- package/dist/esm/createApp.mjs +34 -6
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/index.cjs.mjs +14 -0
- package/dist/esm/index.cjs.mjs.map +1 -0
- package/dist/esm/{index.mjs → index.esm.mjs} +5 -2
- package/dist/esm/index.esm.mjs.map +1 -0
- package/dist/esm/ink.mjs +10 -0
- package/dist/esm/ink.mjs.map +1 -0
- package/dist/esm/lib/figures.mjs +13 -2
- package/dist/esm/lib/figures.mjs.map +1 -1
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/worker.mjs +85 -5
- package/dist/esm/worker.mjs.map +1 -1
- package/dist/types/components/App.d.ts +1 -1
- package/dist/types/components/ChildProcess.d.ts +1 -1
- package/dist/types/createApp.d.ts +1 -1
- package/dist/types/index.cjs.d.ts +6 -0
- package/dist/types/index.esm.d.ts +6 -0
- package/dist/types/ink.d.mts +15 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/worker.d.ts +1 -1
- package/package.json +16 -15
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/lib/uuid.mjs +0 -16
- package/dist/esm/lib/uuid.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/lib/uuid.d.ts +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
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 addLines;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _readablestream = require("readable-stream");
|
|
12
|
+
var regEx = /\r\n|[\n\v\f\r\x85\u2028\u2029]/g;
|
|
13
|
+
function addLines(addLine) {
|
|
14
|
+
var last = '';
|
|
15
|
+
var stream = new _readablestream.Writable({
|
|
16
|
+
write: function write(chunk, _enc, callback) {
|
|
17
|
+
var more = last + chunk.toString('utf8');
|
|
18
|
+
var lines = more.split(regEx);
|
|
19
|
+
last = lines.pop();
|
|
20
|
+
lines.forEach(function(line) {
|
|
21
|
+
return addLine(line);
|
|
22
|
+
});
|
|
23
|
+
callback();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
stream.on('finish', function() {
|
|
27
|
+
if (last.length) addLine(last);
|
|
28
|
+
last = '';
|
|
29
|
+
});
|
|
30
|
+
return stream;
|
|
31
|
+
}
|
|
32
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst regEx = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n\nexport default function addLines(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 stream.on('finish', () => {\n if (last.length) addLine(last);\n last = '';\n });\n return stream;\n}\n"],"names":["addLines","regEx","addLine","last","stream","Writable","write","chunk","_enc","callback","more","toString","lines","split","pop","forEach","line","on","length"],"mappings":";;;;+BAIA;;;eAAwBA;;;8BAJC;AAEzB,IAAMC,QAAQ;AAEC,SAASD,SAASE,OAAO;IACtC,IAAIC,OAAO;IAEX,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,IAAMC,OAAOP,OAAOI,MAAMI,QAAQ,CAAC;YACnC,IAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBE,OAAOS,MAAME,GAAG;YAChBF,MAAMG,OAAO,CAAC,SAACC;uBAASd,QAAQc;;YAChCP;QACF;IACF;IACAL,OAAOa,EAAE,CAAC,UAAU;QAClB,IAAId,KAAKe,MAAM,EAAEhB,QAAQC;QACzBA,OAAO;IACT;IACA,OAAOC;AACT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 concatWritable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _readablestream = require("readable-stream");
|
|
12
|
+
function concatWritable(callback) {
|
|
13
|
+
var chunks = [];
|
|
14
|
+
var stream = new _readablestream.Writable({
|
|
15
|
+
write: function(chunk, _encoding, next) {
|
|
16
|
+
chunks.push(chunk);
|
|
17
|
+
next();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
stream.on('finish', function() {
|
|
21
|
+
return callback(Buffer.concat(chunks.splice(0)));
|
|
22
|
+
});
|
|
23
|
+
return stream;
|
|
24
|
+
}
|
|
25
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/concatWritable.ts"],"sourcesContent":["import { 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 stream.on('finish', () => callback(Buffer.concat(chunks.splice(0))));\n return stream;\n}\n"],"names":["concatWritable","callback","chunks","stream","Writable","write","chunk","_encoding","next","push","on","Buffer","concat","splice"],"mappings":";;;;+BAEA;;;eAAwBA;;;8BAFC;AAEV,SAASA,eAAeC,QAAQ;IAC7C,IAAMC,SAAS,EAAE;IACjB,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAO,SAACC,OAAOC,WAAWC;YACxBN,OAAOO,IAAI,CAACH;YACZE;QACF;IACF;IACAL,OAAOO,EAAE,CAAC,UAAU;eAAMT,SAASU,OAAOC,MAAM,CAACV,OAAOW,MAAM,CAAC;;IAC/D,OAAOV;AACT"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// From: https://github.com/sindresorhus/is-unicode-supported
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function isUnicodeSupported() {
|
|
13
|
+
var env = process.env;
|
|
14
|
+
var TERM = env.TERM, TERM_PROGRAM = env.TERM_PROGRAM;
|
|
15
|
+
if (process.platform !== 'win32') {
|
|
16
|
+
return TERM !== 'linux'; // Linux console (kernel)
|
|
17
|
+
}
|
|
18
|
+
return Boolean(env.WT_SESSION) || // Windows Terminal
|
|
19
|
+
Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
|
|
20
|
+
env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
|
|
21
|
+
TERM_PROGRAM === 'Terminus-Sublime' || TERM_PROGRAM === 'vscode' || TERM === 'xterm-256color' || TERM === 'alacritty' || TERM === 'rxvt-unicode' || TERM === 'rxvt-unicode-256color' || env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
22
|
+
}
|
|
23
|
+
// From https://github.com/sindresorhus/figures
|
|
24
|
+
var symbols = {
|
|
25
|
+
arrowRight: '→',
|
|
26
|
+
tick: '✔',
|
|
27
|
+
info: 'ℹ',
|
|
28
|
+
warning: '⚠',
|
|
29
|
+
cross: '✖',
|
|
30
|
+
squareSmallFilled: '◼',
|
|
31
|
+
pointer: '❯'
|
|
32
|
+
};
|
|
33
|
+
var fallbackSymbols = {
|
|
34
|
+
arrowRight: '→',
|
|
35
|
+
tick: '√',
|
|
36
|
+
info: 'i',
|
|
37
|
+
warning: '‼',
|
|
38
|
+
cross: '×',
|
|
39
|
+
squareSmallFilled: '■',
|
|
40
|
+
pointer: '>'
|
|
41
|
+
};
|
|
42
|
+
var _default = isUnicodeSupported() ? symbols : fallbackSymbols;
|
|
43
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/figures.ts"],"sourcesContent":["// From: https://github.com/sindresorhus/is-unicode-supported\nfunction isUnicodeSupported() {\n const { env } = process;\n const { TERM, TERM_PROGRAM } = env;\n\n if (process.platform !== 'win32') {\n return TERM !== 'linux'; // Linux console (kernel)\n }\n\n return (\n Boolean(env.WT_SESSION) || // Windows Terminal\n Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)\n env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder\n TERM_PROGRAM === 'Terminus-Sublime' ||\n TERM_PROGRAM === 'vscode' ||\n TERM === 'xterm-256color' ||\n TERM === 'alacritty' ||\n TERM === 'rxvt-unicode' ||\n TERM === 'rxvt-unicode-256color' ||\n env.TERMINAL_EMULATOR === 'JetBrains-JediTerm'\n );\n}\n\n// From https://github.com/sindresorhus/figures\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","env","process","TERM","TERM_PROGRAM","platform","Boolean","WT_SESSION","TERMINUS_SUBLIME","ConEmuTask","TERMINAL_EMULATOR","symbols","arrowRight","tick","info","warning","cross","squareSmallFilled","pointer","fallbackSymbols"],"mappings":"AAAA,6DAA6D;;;;;+BA4C7D;;;eAAA;;;AA3CA,SAASA;IACP,IAAM,AAAEC,MAAQC,QAARD;IACR,IAAQE,OAAuBF,IAAvBE,MAAMC,eAAiBH,IAAjBG;IAEd,IAAIF,QAAQG,QAAQ,KAAK,SAAS;QAChC,OAAOF,SAAS,SAAS,yBAAyB;IACpD;IAEA,OACEG,QAAQL,IAAIM,UAAU,KAAK,mBAAmB;IAC9CD,QAAQL,IAAIO,gBAAgB,KAAK,qBAAqB;IACtDP,IAAIQ,UAAU,KAAK,kBAAkB,mBAAmB;IACxDL,iBAAiB,sBACjBA,iBAAiB,YACjBD,SAAS,oBACTA,SAAS,eACTA,SAAS,kBACTA,SAAS,2BACTF,IAAIS,iBAAiB,KAAK;AAE9B;AAEA,+CAA+C;AAC/C,IAAMC,UAAU;IACdC,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;AAEA,IAAMC,kBAAkB;IACtBP,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,OAAO;IACPC,mBAAmB;IACnBC,SAAS;AACX;IAEA,WAAelB,uBAAuBW,UAAUQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "LineType", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return LineType;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var LineType = /*#__PURE__*/ function(LineType) {
|
|
13
|
+
LineType[LineType["stdout"] = 1] = "stdout";
|
|
14
|
+
LineType[LineType["stderr"] = 2] = "stderr";
|
|
15
|
+
return LineType;
|
|
16
|
+
}({});
|
|
17
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/types.ts"],"sourcesContent":["// @ts-ignore\nexport type { SpawnOptions, SpawnCallback, SpawnResult } from 'cross-spawn-cb';\n\nexport type TerminalOptions = {\n group?: string;\n};\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;;;;;+BAODA;;;eAAAA;;;AAAL,IAAA,AAAKA,kCAAAA;;;WAAAA"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return spawnTerminal;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _crossspawncb = /*#__PURE__*/ _interop_require_wildcard(require("cross-spawn-cb"));
|
|
13
|
+
var _onone = /*#__PURE__*/ _interop_require_default(require("on-one"));
|
|
14
|
+
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
15
|
+
var _createApp = /*#__PURE__*/ _interop_require_default(require("./createApp.cjs"));
|
|
16
|
+
var _addLines = /*#__PURE__*/ _interop_require_default(require("./lib/addLines.cjs"));
|
|
17
|
+
var _concatWritable = /*#__PURE__*/ _interop_require_default(require("./lib/concatWritable.cjs"));
|
|
18
|
+
var _types = require("./types.cjs");
|
|
19
|
+
var _lodashthrottle = /*#__PURE__*/ _interop_require_default(require("lodash.throttle"));
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
function _interop_require_default(obj) {
|
|
34
|
+
return obj && obj.__esModule ? obj : {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
39
|
+
if (typeof WeakMap !== "function") return null;
|
|
40
|
+
var cacheBabelInterop = new WeakMap();
|
|
41
|
+
var cacheNodeInterop = new WeakMap();
|
|
42
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
43
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
44
|
+
})(nodeInterop);
|
|
45
|
+
}
|
|
46
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
47
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
51
|
+
return {
|
|
52
|
+
default: obj
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
56
|
+
if (cache && cache.has(obj)) {
|
|
57
|
+
return cache.get(obj);
|
|
58
|
+
}
|
|
59
|
+
var newObj = {
|
|
60
|
+
__proto__: null
|
|
61
|
+
};
|
|
62
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
63
|
+
for(var key in obj){
|
|
64
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
65
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
66
|
+
if (desc && (desc.get || desc.set)) {
|
|
67
|
+
Object.defineProperty(newObj, key, desc);
|
|
68
|
+
} else {
|
|
69
|
+
newObj[key] = obj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
newObj.default = obj;
|
|
74
|
+
if (cache) {
|
|
75
|
+
cache.set(obj, newObj);
|
|
76
|
+
}
|
|
77
|
+
return newObj;
|
|
78
|
+
}
|
|
79
|
+
function _object_spread(target) {
|
|
80
|
+
for(var i = 1; i < arguments.length; i++){
|
|
81
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
82
|
+
var ownKeys = Object.keys(source);
|
|
83
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
84
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
85
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
ownKeys.forEach(function(key) {
|
|
89
|
+
_define_property(target, key, source[key]);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return target;
|
|
93
|
+
}
|
|
94
|
+
function ownKeys(object, enumerableOnly) {
|
|
95
|
+
var keys = Object.keys(object);
|
|
96
|
+
if (Object.getOwnPropertySymbols) {
|
|
97
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
98
|
+
if (enumerableOnly) {
|
|
99
|
+
symbols = symbols.filter(function(sym) {
|
|
100
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
keys.push.apply(keys, symbols);
|
|
104
|
+
}
|
|
105
|
+
return keys;
|
|
106
|
+
}
|
|
107
|
+
function _object_spread_props(target, source) {
|
|
108
|
+
source = source != null ? source : {};
|
|
109
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
110
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
111
|
+
} else {
|
|
112
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
113
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return target;
|
|
117
|
+
}
|
|
118
|
+
function _object_without_properties(source, excluded) {
|
|
119
|
+
if (source == null) return {};
|
|
120
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
121
|
+
var key, i;
|
|
122
|
+
if (Object.getOwnPropertySymbols) {
|
|
123
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
124
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
125
|
+
key = sourceSymbolKeys[i];
|
|
126
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
127
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
128
|
+
target[key] = source[key];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return target;
|
|
132
|
+
}
|
|
133
|
+
function _object_without_properties_loose(source, excluded) {
|
|
134
|
+
if (source == null) return {};
|
|
135
|
+
var target = {};
|
|
136
|
+
var sourceKeys = Object.keys(source);
|
|
137
|
+
var key, i;
|
|
138
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
139
|
+
key = sourceKeys[i];
|
|
140
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
141
|
+
target[key] = source[key];
|
|
142
|
+
}
|
|
143
|
+
return target;
|
|
144
|
+
}
|
|
145
|
+
var terminal = (0, _createApp.default)();
|
|
146
|
+
var THROTTLE = 100;
|
|
147
|
+
var rerender = (0, _lodashthrottle.default)(function() {
|
|
148
|
+
terminal.rerender();
|
|
149
|
+
}, THROTTLE);
|
|
150
|
+
function spawnTerminal(command, args, spawnOptions, _options, callback) {
|
|
151
|
+
var encoding = spawnOptions.encoding, stdio = spawnOptions.stdio, csOptions = _object_without_properties(spawnOptions, [
|
|
152
|
+
"encoding",
|
|
153
|
+
"stdio"
|
|
154
|
+
]);
|
|
155
|
+
terminal.retain();
|
|
156
|
+
var item = terminal.addItem({
|
|
157
|
+
title: [
|
|
158
|
+
command
|
|
159
|
+
].concat(args).join(' '),
|
|
160
|
+
state: 'running'
|
|
161
|
+
});
|
|
162
|
+
terminal.rerender();
|
|
163
|
+
var cp = (0, _crossspawncb.crossSpawn)(command, args, csOptions);
|
|
164
|
+
var outputs = {
|
|
165
|
+
stdout: null,
|
|
166
|
+
stderr: null
|
|
167
|
+
};
|
|
168
|
+
if (cp.stdout && process.stdout.getMaxListeners) {
|
|
169
|
+
process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);
|
|
170
|
+
process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);
|
|
171
|
+
}
|
|
172
|
+
var queue = new _queuecb.default();
|
|
173
|
+
if (cp.stdout) {
|
|
174
|
+
if (stdio === 'inherit') {
|
|
175
|
+
outputs.stdout = (0, _addLines.default)(function(text) {
|
|
176
|
+
item.lines.push({
|
|
177
|
+
type: _types.LineType.stdout,
|
|
178
|
+
text: text
|
|
179
|
+
});
|
|
180
|
+
rerender();
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
outputs.stdout = (0, _concatWritable.default)(function(output) {
|
|
184
|
+
outputs.stdout.output = output.toString(encoding || 'utf8');
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
queue.defer(_onone.default.bind(null, cp.stdout.pipe(outputs.stdout), [
|
|
188
|
+
'error',
|
|
189
|
+
'end',
|
|
190
|
+
'close',
|
|
191
|
+
'finish'
|
|
192
|
+
]));
|
|
193
|
+
}
|
|
194
|
+
if (cp.stderr) {
|
|
195
|
+
if (stdio === 'inherit') {
|
|
196
|
+
outputs.stderr = (0, _addLines.default)(function(text) {
|
|
197
|
+
item.lines.push({
|
|
198
|
+
type: _types.LineType.stderr,
|
|
199
|
+
text: text
|
|
200
|
+
});
|
|
201
|
+
rerender();
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
outputs.stderr = (0, _concatWritable.default)(function(output) {
|
|
205
|
+
outputs.stderr.output = output.toString(encoding || 'utf8');
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
queue.defer(_onone.default.bind(null, cp.stderr.pipe(outputs.stderr), [
|
|
209
|
+
'error',
|
|
210
|
+
'end',
|
|
211
|
+
'close',
|
|
212
|
+
'finish'
|
|
213
|
+
]));
|
|
214
|
+
}
|
|
215
|
+
queue.defer(_crossspawncb.default.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), {
|
|
216
|
+
encoding: 'utf8'
|
|
217
|
+
})));
|
|
218
|
+
queue.await(function(err) {
|
|
219
|
+
if (cp.stdout && process.stdout.getMaxListeners) {
|
|
220
|
+
process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);
|
|
221
|
+
process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);
|
|
222
|
+
}
|
|
223
|
+
var res = err ? err : {};
|
|
224
|
+
res.stdout = outputs.stdout ? outputs.stdout.output : null;
|
|
225
|
+
res.stderr = outputs.stderr ? outputs.stderr.output : null;
|
|
226
|
+
res.output = [
|
|
227
|
+
res.stdout,
|
|
228
|
+
res.stderr,
|
|
229
|
+
null
|
|
230
|
+
];
|
|
231
|
+
item.state = err ? 'error' : 'success';
|
|
232
|
+
terminal.rerender();
|
|
233
|
+
terminal.release();
|
|
234
|
+
err ? callback(err) : callback(null, res);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["// @ts-ignore\nimport spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp';\nimport addLines from './lib/addLines';\nimport concatWritable from './lib/concatWritable';\n\nimport type { SpawnOptions, TerminalOptions } from './types';\nimport { LineType } from './types';\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 } else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n }\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\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 } else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n }\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err) => {\n 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":["spawnTerminal","terminal","createApp","THROTTLE","rerender","throttle","command","args","spawnOptions","_options","callback","encoding","stdio","csOptions","retain","item","addItem","title","concat","join","state","cp","crossSpawn","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","Queue","addLines","text","lines","push","type","LineType","concatWritable","output","toString","defer","oo","bind","pipe","spawn","worker","await","err","res","release"],"mappings":"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"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
3
29
|
import React from 'react';
|
|
30
|
+
import { Box } from '../ink.mjs';
|
|
4
31
|
import ChildProcess from './ChildProcess.mjs';
|
|
5
32
|
export default function App({ list }) {
|
|
6
33
|
const running = list.filter((x)=>[
|
|
@@ -12,10 +39,9 @@ export default function App({ list }) {
|
|
|
12
39
|
].indexOf(x.state) >= 0);
|
|
13
40
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Box, {
|
|
14
41
|
flexDirection: "column"
|
|
15
|
-
}, running.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, {
|
|
16
|
-
key: item.id
|
|
17
|
-
|
|
18
|
-
}))), /*#__PURE__*/ React.createElement(Box, {
|
|
42
|
+
}, running.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, _object_spread({
|
|
43
|
+
key: item.id
|
|
44
|
+
}, item)))), /*#__PURE__*/ React.createElement(Box, {
|
|
19
45
|
flexDirection: "column",
|
|
20
46
|
borderStyle: "single",
|
|
21
47
|
borderColor: "black",
|
|
@@ -25,8 +51,7 @@ export default function App({ list }) {
|
|
|
25
51
|
borderRight: false
|
|
26
52
|
}), /*#__PURE__*/ React.createElement(Box, {
|
|
27
53
|
flexDirection: "column"
|
|
28
|
-
}, done.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, {
|
|
29
|
-
key: item.id
|
|
30
|
-
|
|
31
|
-
}))));
|
|
54
|
+
}, done.map((item)=>/*#__PURE__*/ React.createElement(ChildProcess, _object_spread({
|
|
55
|
+
key: item.id
|
|
56
|
+
}, item)))));
|
|
32
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/App.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '../ink.mjs';\nimport type { ChildProcess as ChildProcessT } from '../types';\nimport ChildProcess from './ChildProcess';\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":["React","Box","ChildProcess","App","list","running","filter","x","indexOf","state","done","flexDirection","map","item","key","id","borderStyle","borderColor","borderBottom","borderTop","borderLeft","borderRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,GAAG,QAAQ,aAAa;AAEjC,OAAOC,kBAAkB,iBAAiB;AAM1C,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,oBAACR;QAAIU,eAAc;OAChBN,QAAQO,GAAG,CAAC,CAACC,qBACZ,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;WAAMF,wBAGpC,oBAACZ;QAAIU,eAAc;QAASK,aAAY;QAASC,aAAY;QAAQC,cAAc;QAAMC,WAAW;QAAOC,YAAY;QAAOC,aAAa;sBAC3I,oBAACpB;QAAIU,eAAc;OAChBD,KAAKE,GAAG,CAAC,CAACC,qBACT,oBAACX;YAAaY,KAAKD,KAAKE,EAAE;WAAMF;AAK1C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
1
|
import React from 'react';
|
|
2
|
+
import { Box, Text } from '../ink.mjs';
|
|
4
3
|
import figures from '../lib/figures.mjs';
|
|
5
4
|
import Spinner from './Spinner.mjs';
|
|
5
|
+
import { LineType } from '../types.mjs';
|
|
6
6
|
// From: https://github.com/sindresorhus/cli-spinners/blob/00de8fbeee16fa49502fa4f687449f70f2c8ca2c/spinners.json#L2
|
|
7
7
|
const spinner = {
|
|
8
8
|
interval: 80,
|
|
@@ -39,6 +39,7 @@ const POINTERS = {
|
|
|
39
39
|
export default function ChildProcess({ title, state, lines, isExpanded }) {
|
|
40
40
|
const icon = isExpanded ? POINTERS[state] || POINTERS.default : ICONS[state];
|
|
41
41
|
const output = state === 'running' && lines.length ? lines[lines.length - 1] : undefined;
|
|
42
|
+
const errors = state !== 'running' ? lines.filter((line)=>line.type === LineType.stderr) : [];
|
|
42
43
|
return /*#__PURE__*/ React.createElement(Box, {
|
|
43
44
|
flexDirection: "column"
|
|
44
45
|
}, /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Box, {
|
|
@@ -47,5 +48,13 @@ export default function ChildProcess({ title, state, lines, isExpanded }) {
|
|
|
47
48
|
marginLeft: 2
|
|
48
49
|
}, /*#__PURE__*/ React.createElement(Text, {
|
|
49
50
|
color: "gray"
|
|
50
|
-
}, `${figures.arrowRight} ${output}`)) : undefined
|
|
51
|
+
}, `${figures.arrowRight} ${output.text}`)) : undefined, errors.length > 0 && /*#__PURE__*/ React.createElement(Box, {
|
|
52
|
+
flexDirection: "column",
|
|
53
|
+
marginLeft: 2
|
|
54
|
+
}, lines.map((line, index)=>// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
|
|
55
|
+
/*#__PURE__*/ React.createElement(Box, {
|
|
56
|
+
key: index,
|
|
57
|
+
flexDirection: "column",
|
|
58
|
+
height: 1
|
|
59
|
+
}, /*#__PURE__*/ React.createElement(Text, null, line.text)))));
|
|
51
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/ChildProcess.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Text } from '../ink.mjs';\nimport figures from '../lib/figures';\nimport Spinner from './Spinner';\n\nimport type { Line, State } from '../types';\nimport { LineType } from '../types';\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 const errors = state !== 'running' ? lines.filter((line) => line.type === LineType.stderr) : [];\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}`}</Text>\n </Box>\n ) : undefined}\n {errors.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}</Text>\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n}\n"],"names":["React","Box","Text","figures","Spinner","LineType","spinner","interval","frames","ICONS","error","color","cross","success","tick","running","POINTERS","pointer","default","ChildProcess","title","state","lines","isExpanded","icon","output","length","undefined","errors","filter","line","type","stderr","flexDirection","marginRight","marginLeft","arrowRight","text","map","index","key","height"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,GAAG,EAAEC,IAAI,QAAQ,aAAa;AACvC,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,aAAa,YAAY;AAGhC,SAASC,QAAQ,QAAQ,WAAW;AAEpC,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;OAAOR,QAAQS,KAAK;IACvCC,uBAAS,oBAACX;QAAKS,OAAM;OAASR,QAAQW,IAAI;IAC1CC,uBAAS,oBAACX,SAAYE;AACxB;AAEA,MAAMU,WAAW;IACfN,qBAAO,oBAACR;QAAKS,OAAM;OAAOR,QAAQc,OAAO;IACzCC,uBAAS,oBAAChB;QAAKS,OAAM;OAAUR,QAAQc,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;IAC/E,MAAMC,SAASP,UAAU,YAAYC,MAAMO,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAK1B,SAAS2B,MAAM,IAAI,EAAE;IAE/F,qBACE,oBAAC/B;QAAIgC,eAAc;qBACjB,oBAAChC,yBACC,oBAACA;QAAIiC,aAAa;qBAChB,oBAAChC,YAAMsB,sBAET,oBAACtB,YAAMkB,SAERK,uBACC,oBAACxB;QAAIkC,YAAY;qBACf,oBAACjC;QAAKS,OAAM;OAAQ,GAAGR,QAAQiC,UAAU,CAAC,CAAC,EAAEX,OAAOY,IAAI,EAAE,KAE1DV,WACHC,OAAOF,MAAM,GAAG,mBACf,oBAACzB;QAAIgC,eAAc;QAASE,YAAY;OACrCb,MAAMgB,GAAG,CAAC,CAACR,MAAMS,QAChB,8DAA8D;sBAC9D,oBAACtC;YAAIuC,KAAKD;YAAON,eAAc;YAASQ,QAAQ;yBAC9C,oBAACvC,YAAM4B,KAAKO,IAAI;AAO9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/components/Spinner.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Text } from '../ink.mjs';\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":["React","useState","useEffect","Text","Spinner","interval","frames","index","setIndex","timer","setInterval","length","clearInterval"],"mappings":"AAAA,OAAOA,SAASC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AACnD,SAASC,IAAI,QAAQ,aAAa;AAOlC,eAAe,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAgB;IAChE,MAAM,CAACC,OAAOC,SAAS,GAAGP,SAAS;IAEnCC,UAAU;QACR,MAAMO,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,oBAACH,YAAMG,MAAM,CAACC,MAAM;AAC7B"}
|
package/dist/esm/createApp.mjs
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
import uuid from 'lil-uuid';
|
|
2
30
|
import React from 'react';
|
|
3
31
|
import App from './components/App.mjs';
|
|
4
|
-
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
import { render } from './ink.mjs';
|
|
5
34
|
export default function createApp() {
|
|
6
35
|
let refCount = 0;
|
|
7
36
|
let list = null;
|
|
@@ -9,13 +38,12 @@ export default function createApp() {
|
|
|
9
38
|
return {
|
|
10
39
|
addItem (data) {
|
|
11
40
|
if (!list) throw new Error('Expecting list');
|
|
12
|
-
const item = {
|
|
41
|
+
const item = _object_spread({
|
|
13
42
|
id: uuid(),
|
|
14
43
|
title: '',
|
|
15
44
|
state: 'pending',
|
|
16
|
-
lines: []
|
|
17
|
-
|
|
18
|
-
};
|
|
45
|
+
lines: []
|
|
46
|
+
}, data);
|
|
19
47
|
list.push(item);
|
|
20
48
|
return item;
|
|
21
49
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createApp.tsx"],"sourcesContent":["import uuid from 'lil-uuid';\nimport React from 'react';\nimport App from './components/App';\n// @ts-ignore\nimport { type Instance, render } from './ink.mjs';\nimport type { ChildProcess } from './types';\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":["uuid","React","App","render","createApp","refCount","list","inkApp","addItem","data","Error","item","id","title","state","lines","push","rerender","retain","release","unmount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,UAAU,WAAW;AAC5B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,mBAAmB;AACnC,aAAa;AACb,SAAwBC,MAAM,QAAQ,YAAY;AAGlD,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,IAAIZ;gBAAQa,OAAO;gBAAIC,OAAO;gBAAWC,OAAO,EAAE;eAAKN;YACtEH,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,SAASJ,qBAAO,oBAACD;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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function spawnTerminal(command, args, spawnOptions, options, callback) {
|
|
2
|
+
const worker = require('./worker.cjs');
|
|
3
|
+
if (typeof options === 'function') {
|
|
4
|
+
callback = options;
|
|
5
|
+
options = {};
|
|
6
|
+
}
|
|
7
|
+
options = options || {};
|
|
8
|
+
if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);
|
|
9
|
+
return new Promise((resolve, reject)=>worker(command, args, spawnOptions, options, (err, result)=>err ? reject(err) : resolve(result)));
|
|
10
|
+
}
|
|
11
|
+
const major = +process.versions.node.split('.')[0];
|
|
12
|
+
export * from './types.mjs';
|
|
13
|
+
export { default as figures } from './lib/figures.mjs';
|
|
14
|
+
export default major > 10 ? spawnTerminal : undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index.cjs.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, TerminalOptions } from './types';\n\nfunction spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | SpawnCallback, callback?: SpawnCallback) {\n const worker = require('./worker.cjs');\n\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\nconst major = +process.versions.node.split('.')[0];\n\nexport * from './types';\nexport { default as figures } from './lib/figures';\nexport default major > 10 ? spawnTerminal : undefined;\n"],"names":["spawnTerminal","command","args","spawnOptions","options","callback","worker","require","Promise","resolve","reject","err","result","major","process","versions","node","split","default","figures","undefined"],"mappings":"AAEA,SAASA,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAyC,EAAEC,QAAwB;IACrJ,MAAMC,SAASC,QAAQ;IAEvB,IAAI,OAAOH,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIG,QAAQ,CAACC,SAASC,SAAWJ,OAAOL,SAASC,MAAMC,cAAcC,SAAS,CAACO,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI;AAEA,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,cAAc,UAAU;AACxB,SAASC,WAAWC,OAAO,QAAQ,gBAAgB;AACnD,eAAeN,QAAQ,KAAKb,gBAAgBoB,UAAU"}
|