spawn-term 3.2.7 → 3.3.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/cjs/createSessionWrapper.js +43 -33
- package/dist/cjs/createSessionWrapper.js.map +1 -1
- package/dist/cjs/lib/loadInk.js +69 -0
- package/dist/cjs/lib/loadInk.js.map +1 -0
- package/dist/cjs/src/lib/loadInk.d.ts +2 -0
- package/dist/esm/createSessionWrapper.js +39 -27
- package/dist/esm/createSessionWrapper.js.map +1 -1
- package/dist/esm/lib/loadInk.js +41 -0
- package/dist/esm/lib/loadInk.js.map +1 -0
- package/dist/esm/src/lib/loadInk.d.ts +2 -0
- package/package.json +7 -6
|
@@ -52,46 +52,56 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
52
52
|
function createSession(options) {
|
|
53
53
|
var realSession = null;
|
|
54
54
|
var loadError = null;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
var loading = null;
|
|
56
|
+
function getSession() {
|
|
57
|
+
if (realSession) return Promise.resolve(realSession);
|
|
58
|
+
if (loadError) return Promise.reject(loadError);
|
|
59
|
+
if (loading) return loading;
|
|
60
|
+
loading = Promise.resolve().then(function() {
|
|
61
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./lib/loadInk.js"));
|
|
62
|
+
}).then(function(mod) {
|
|
63
|
+
return new Promise(function(resolve, reject) {
|
|
64
|
+
mod.loadInk(function(err) {
|
|
65
|
+
if (err) {
|
|
66
|
+
loadError = err;
|
|
67
|
+
loading = null;
|
|
68
|
+
return reject(err);
|
|
69
|
+
}
|
|
70
|
+
Promise.resolve().then(function() {
|
|
71
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./session.js"));
|
|
72
|
+
}).then(function(sessionMod) {
|
|
73
|
+
realSession = sessionMod.createSession(options);
|
|
74
|
+
resolve(realSession);
|
|
75
|
+
}).catch(function(err) {
|
|
76
|
+
loadError = err;
|
|
77
|
+
loading = null;
|
|
78
|
+
reject(err);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}).catch(function(err) {
|
|
83
|
+
loadError = err;
|
|
84
|
+
loading = null;
|
|
85
|
+
throw err;
|
|
86
|
+
});
|
|
87
|
+
return loading;
|
|
88
|
+
}
|
|
89
|
+
// Start loading immediately in background
|
|
90
|
+
getSession().catch(function() {});
|
|
63
91
|
return {
|
|
64
92
|
spawn: function spawn(command, args, spawnOptions, processOptions, callback) {
|
|
65
|
-
|
|
66
|
-
callback
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
realSession.spawn(command, args, spawnOptions, processOptions, callback);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Still loading, wait for it
|
|
74
|
-
Promise.resolve().then(function() {
|
|
75
|
-
return /*#__PURE__*/ _interop_require_wildcard(require("./session.js"));
|
|
76
|
-
}).then(function(mod) {
|
|
77
|
-
if (!realSession) realSession = mod.createSession(options);
|
|
78
|
-
realSession.spawn(command, args, spawnOptions, processOptions, callback);
|
|
79
|
-
}).catch(callback);
|
|
93
|
+
getSession().then(function(session) {
|
|
94
|
+
session.spawn(command, args, spawnOptions, processOptions, callback);
|
|
95
|
+
}).catch(function(err) {
|
|
96
|
+
callback(err);
|
|
97
|
+
});
|
|
80
98
|
},
|
|
81
99
|
close: function close() {
|
|
82
100
|
if (realSession) realSession.close();
|
|
83
101
|
},
|
|
84
102
|
waitAndClose: function waitAndClose(callback) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// Still loading, wait for it
|
|
90
|
-
Promise.resolve().then(function() {
|
|
91
|
-
return /*#__PURE__*/ _interop_require_wildcard(require("./session.js"));
|
|
92
|
-
}).then(function(mod) {
|
|
93
|
-
if (!realSession) realSession = mod.createSession(options);
|
|
94
|
-
realSession.waitAndClose(callback);
|
|
103
|
+
getSession().then(function(session) {
|
|
104
|
+
session.waitAndClose(callback);
|
|
95
105
|
}).catch(function() {
|
|
96
106
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
97
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createSessionWrapper.ts"],"sourcesContent":["import type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nexport function createSession(options?: SessionOptions): Session {\n let realSession: Session | null = null;\n let loadError:
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createSessionWrapper.ts"],"sourcesContent":["import type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nexport function createSession(options?: SessionOptions): Session {\n let realSession: Session | null = null;\n let loadError: Error | null = null;\n let loading: Promise<Session> | null = null;\n\n function getSession(): Promise<Session> {\n if (realSession) return Promise.resolve(realSession);\n if (loadError) return Promise.reject(loadError);\n if (loading) return loading;\n\n loading = import('./lib/loadInk.ts')\n .then((mod) => {\n return new Promise<Session>((resolve, reject) => {\n mod.loadInk((err) => {\n if (err) {\n loadError = err;\n loading = null;\n return reject(err);\n }\n import('./session.ts')\n .then((sessionMod) => {\n realSession = sessionMod.createSession(options);\n resolve(realSession);\n })\n .catch((err) => {\n loadError = err;\n loading = null;\n reject(err);\n });\n });\n });\n })\n .catch((err) => {\n loadError = err;\n loading = null;\n throw err;\n });\n\n return loading;\n }\n\n // Start loading immediately in background\n getSession().catch(() => {});\n\n return {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, processOptions: ProcessOptions, callback: TerminalCallback): void {\n getSession()\n .then((session) => {\n session.spawn(command, args, spawnOptions, processOptions, callback);\n })\n .catch((err) => {\n callback(err as SpawnError);\n });\n },\n close(): void {\n if (realSession) realSession.close();\n },\n waitAndClose(callback?: () => void): void {\n getSession()\n .then((session) => {\n session.waitAndClose(callback);\n })\n .catch(() => {\n callback?.();\n });\n },\n };\n}\n"],"names":["createSession","options","realSession","loadError","loading","getSession","Promise","resolve","reject","then","mod","loadInk","err","sessionMod","catch","spawn","command","args","spawnOptions","processOptions","callback","session","close","waitAndClose"],"mappings":";;;;+BAQgBA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAT,SAASA,cAAcC,OAAwB;IACpD,IAAIC,cAA8B;IAClC,IAAIC,YAA0B;IAC9B,IAAIC,UAAmC;IAEvC,SAASC;QACP,IAAIH,aAAa,OAAOI,QAAQC,OAAO,CAACL;QACxC,IAAIC,WAAW,OAAOG,QAAQE,MAAM,CAACL;QACrC,IAAIC,SAAS,OAAOA;QAEpBA,UAAU;2DAAA,QAAO;WACdK,IAAI,CAAC,SAACC;YACL,OAAO,IAAIJ,QAAiB,SAACC,SAASC;gBACpCE,IAAIC,OAAO,CAAC,SAACC;oBACX,IAAIA,KAAK;wBACPT,YAAYS;wBACZR,UAAU;wBACV,OAAOI,OAAOI;oBAChB;oBACA;uEAAA,QAAO;uBACJH,IAAI,CAAC,SAACI;wBACLX,cAAcW,WAAWb,aAAa,CAACC;wBACvCM,QAAQL;oBACV,GACCY,KAAK,CAAC,SAACF;wBACNT,YAAYS;wBACZR,UAAU;wBACVI,OAAOI;oBACT;gBACJ;YACF;QACF,GACCE,KAAK,CAAC,SAACF;YACNT,YAAYS;YACZR,UAAU;YACV,MAAMQ;QACR;QAEF,OAAOR;IACT;IAEA,0CAA0C;IAC1CC,aAAaS,KAAK,CAAC,YAAO;IAE1B,OAAO;QACLC,OAAAA,SAAAA,MAAMC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,cAA8B,EAAEC,QAA0B;YAC3Hf,aACGI,IAAI,CAAC,SAACY;gBACLA,QAAQN,KAAK,CAACC,SAASC,MAAMC,cAAcC,gBAAgBC;YAC7D,GACCN,KAAK,CAAC,SAACF;gBACNQ,SAASR;YACX;QACJ;QACAU,OAAAA,SAAAA;YACE,IAAIpB,aAAaA,YAAYoB,KAAK;QACpC;QACAC,cAAAA,SAAAA,aAAaH,QAAqB;YAChCf,aACGI,IAAI,CAAC,SAACY;gBACLA,QAAQE,YAAY,CAACH;YACvB,GACCN,KAAK,CAAC;gBACLM,qBAAAA,+BAAAA;YACF;QACJ;IACF;AACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 isInkInstalled () {
|
|
13
|
+
return isInkInstalled;
|
|
14
|
+
},
|
|
15
|
+
get loadInk () {
|
|
16
|
+
return loadInk;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _installmodulelinked = /*#__PURE__*/ _interop_require_default(require("install-module-linked"));
|
|
20
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
21
|
+
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
22
|
+
function _interop_require_default(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// Get the node_modules directory relative to this file
|
|
28
|
+
var _dirname = _path.default.dirname(typeof __dirname !== 'undefined' ? __dirname : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
|
|
29
|
+
var nodeModules = _path.default.join(_dirname, '..', '..', '..', 'node_modules');
|
|
30
|
+
var installed = false;
|
|
31
|
+
var installing = null;
|
|
32
|
+
function installDependency(name) {
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
// install-module-linked will:
|
|
35
|
+
// 1. Check if module exists locally or in ~/.iml cache
|
|
36
|
+
// 2. If not, install to ~/.iml
|
|
37
|
+
// 3. Create symlink in nodeModules pointing to ~/.iml/package
|
|
38
|
+
(0, _installmodulelinked.default)(name, nodeModules, {}, function(err) {
|
|
39
|
+
if (err) return reject(err);
|
|
40
|
+
resolve();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function installInk() {
|
|
45
|
+
if (installed) return Promise.resolve();
|
|
46
|
+
if (installing) return installing;
|
|
47
|
+
// Install both ink and react - both are needed by session.tsx
|
|
48
|
+
installing = Promise.all([
|
|
49
|
+
installDependency('ink'),
|
|
50
|
+
installDependency('react')
|
|
51
|
+
]).then(function() {
|
|
52
|
+
installed = true;
|
|
53
|
+
}).catch(function(err) {
|
|
54
|
+
installing = null;
|
|
55
|
+
throw err;
|
|
56
|
+
});
|
|
57
|
+
return installing;
|
|
58
|
+
}
|
|
59
|
+
function loadInk(callback) {
|
|
60
|
+
installInk().then(function() {
|
|
61
|
+
return callback(null);
|
|
62
|
+
}).catch(function(err) {
|
|
63
|
+
return callback(err);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function isInkInstalled() {
|
|
67
|
+
return installed;
|
|
68
|
+
}
|
|
69
|
+
/* 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/loadInk.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install both ink and react - both are needed by session.tsx\n installing = Promise.all([installDependency('ink'), installDependency('react')])\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["isInkInstalled","loadInk","_dirname","path","dirname","__dirname","url","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","installModule","err","installInk","all","then","catch","callback"],"mappings":";;;;;;;;;;;QA+CgBA;eAAAA;;QANAC;eAAAA;;;0EAzCU;2DACT;0DACD;;;;;;AAEhB,uDAAuD;AACvD,IAAMC,WAAWC,aAAI,CAACC,OAAO,CAAC,OAAOC,cAAc,cAAcA,YAAYC,YAAG,CAACC,aAAa,CAAC;AAC/F,IAAMC,cAAcL,aAAI,CAACM,IAAI,CAACP,UAAU,MAAM,MAAM,MAAM;AAE1D,IAAIQ,YAAY;AAChB,IAAIC,aAAmC;AAEvC,SAASC,kBAAkBC,IAAY;IACrC,OAAO,IAAIC,QAAQ,SAACC,SAASC;QAC3B,8BAA8B;QAC9B,uDAAuD;QACvD,+BAA+B;QAC/B,8DAA8D;QAC9DC,IAAAA,4BAAa,EAACJ,MAAML,aAAa,CAAC,GAAG,SAACU;YACpC,IAAIA,KAAK,OAAOF,OAAOE;YACvBH;QACF;IACF;AACF;AAEA,SAASI;IACP,IAAIT,WAAW,OAAOI,QAAQC,OAAO;IACrC,IAAIJ,YAAY,OAAOA;IAEvB,8DAA8D;IAC9DA,aAAaG,QAAQM,GAAG,CAAC;QAACR,kBAAkB;QAAQA,kBAAkB;KAAS,EAC5ES,IAAI,CAAC;QACJX,YAAY;IACd,GACCY,KAAK,CAAC,SAACJ;QACNP,aAAa;QACb,MAAMO;IACR;IAEF,OAAOP;AACT;AAEO,SAASV,QAAQsB,QAAqC;IAC3DJ,aACGE,IAAI,CAAC;eAAME,SAAS;OACpBD,KAAK,CAAC,SAACJ;eAAQK,SAASL;;AAC7B;AAEO,SAASlB;IACd,OAAOU;AACT"}
|
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
export function createSession(options) {
|
|
2
2
|
let realSession = null;
|
|
3
3
|
let loadError = null;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
realSession
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let loading = null;
|
|
5
|
+
function getSession() {
|
|
6
|
+
if (realSession) return Promise.resolve(realSession);
|
|
7
|
+
if (loadError) return Promise.reject(loadError);
|
|
8
|
+
if (loading) return loading;
|
|
9
|
+
loading = import('./lib/loadInk.js').then((mod)=>{
|
|
10
|
+
return new Promise((resolve, reject)=>{
|
|
11
|
+
mod.loadInk((err)=>{
|
|
12
|
+
if (err) {
|
|
13
|
+
loadError = err;
|
|
14
|
+
loading = null;
|
|
15
|
+
return reject(err);
|
|
16
|
+
}
|
|
17
|
+
import('./session.js').then((sessionMod)=>{
|
|
18
|
+
realSession = sessionMod.createSession(options);
|
|
19
|
+
resolve(realSession);
|
|
20
|
+
}).catch((err)=>{
|
|
21
|
+
loadError = err;
|
|
22
|
+
loading = null;
|
|
23
|
+
reject(err);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}).catch((err)=>{
|
|
28
|
+
loadError = err;
|
|
29
|
+
loading = null;
|
|
30
|
+
throw err;
|
|
31
|
+
});
|
|
32
|
+
return loading;
|
|
33
|
+
}
|
|
34
|
+
// Start loading immediately in background
|
|
35
|
+
getSession().catch(()=>{});
|
|
10
36
|
return {
|
|
11
37
|
spawn (command, args, spawnOptions, processOptions, callback) {
|
|
12
|
-
|
|
13
|
-
callback
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
realSession.spawn(command, args, spawnOptions, processOptions, callback);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
// Still loading, wait for it
|
|
21
|
-
import('./session.js').then((mod)=>{
|
|
22
|
-
if (!realSession) realSession = mod.createSession(options);
|
|
23
|
-
realSession.spawn(command, args, spawnOptions, processOptions, callback);
|
|
24
|
-
}).catch(callback);
|
|
38
|
+
getSession().then((session)=>{
|
|
39
|
+
session.spawn(command, args, spawnOptions, processOptions, callback);
|
|
40
|
+
}).catch((err)=>{
|
|
41
|
+
callback(err);
|
|
42
|
+
});
|
|
25
43
|
},
|
|
26
44
|
close () {
|
|
27
45
|
if (realSession) realSession.close();
|
|
28
46
|
},
|
|
29
47
|
waitAndClose (callback) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Still loading, wait for it
|
|
35
|
-
import('./session.js').then((mod)=>{
|
|
36
|
-
if (!realSession) realSession = mod.createSession(options);
|
|
37
|
-
realSession.waitAndClose(callback);
|
|
48
|
+
getSession().then((session)=>{
|
|
49
|
+
session.waitAndClose(callback);
|
|
38
50
|
}).catch(()=>{
|
|
39
51
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
40
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createSessionWrapper.ts"],"sourcesContent":["import type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nexport function createSession(options?: SessionOptions): Session {\n let realSession: Session | null = null;\n let loadError:
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/createSessionWrapper.ts"],"sourcesContent":["import type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nexport function createSession(options?: SessionOptions): Session {\n let realSession: Session | null = null;\n let loadError: Error | null = null;\n let loading: Promise<Session> | null = null;\n\n function getSession(): Promise<Session> {\n if (realSession) return Promise.resolve(realSession);\n if (loadError) return Promise.reject(loadError);\n if (loading) return loading;\n\n loading = import('./lib/loadInk.ts')\n .then((mod) => {\n return new Promise<Session>((resolve, reject) => {\n mod.loadInk((err) => {\n if (err) {\n loadError = err;\n loading = null;\n return reject(err);\n }\n import('./session.ts')\n .then((sessionMod) => {\n realSession = sessionMod.createSession(options);\n resolve(realSession);\n })\n .catch((err) => {\n loadError = err;\n loading = null;\n reject(err);\n });\n });\n });\n })\n .catch((err) => {\n loadError = err;\n loading = null;\n throw err;\n });\n\n return loading;\n }\n\n // Start loading immediately in background\n getSession().catch(() => {});\n\n return {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, processOptions: ProcessOptions, callback: TerminalCallback): void {\n getSession()\n .then((session) => {\n session.spawn(command, args, spawnOptions, processOptions, callback);\n })\n .catch((err) => {\n callback(err as SpawnError);\n });\n },\n close(): void {\n if (realSession) realSession.close();\n },\n waitAndClose(callback?: () => void): void {\n getSession()\n .then((session) => {\n session.waitAndClose(callback);\n })\n .catch(() => {\n callback?.();\n });\n },\n };\n}\n"],"names":["createSession","options","realSession","loadError","loading","getSession","Promise","resolve","reject","then","mod","loadInk","err","sessionMod","catch","spawn","command","args","spawnOptions","processOptions","callback","session","close","waitAndClose"],"mappings":"AAQA,OAAO,SAASA,cAAcC,OAAwB;IACpD,IAAIC,cAA8B;IAClC,IAAIC,YAA0B;IAC9B,IAAIC,UAAmC;IAEvC,SAASC;QACP,IAAIH,aAAa,OAAOI,QAAQC,OAAO,CAACL;QACxC,IAAIC,WAAW,OAAOG,QAAQE,MAAM,CAACL;QACrC,IAAIC,SAAS,OAAOA;QAEpBA,UAAU,MAAM,CAAC,oBACdK,IAAI,CAAC,CAACC;YACL,OAAO,IAAIJ,QAAiB,CAACC,SAASC;gBACpCE,IAAIC,OAAO,CAAC,CAACC;oBACX,IAAIA,KAAK;wBACPT,YAAYS;wBACZR,UAAU;wBACV,OAAOI,OAAOI;oBAChB;oBACA,MAAM,CAAC,gBACJH,IAAI,CAAC,CAACI;wBACLX,cAAcW,WAAWb,aAAa,CAACC;wBACvCM,QAAQL;oBACV,GACCY,KAAK,CAAC,CAACF;wBACNT,YAAYS;wBACZR,UAAU;wBACVI,OAAOI;oBACT;gBACJ;YACF;QACF,GACCE,KAAK,CAAC,CAACF;YACNT,YAAYS;YACZR,UAAU;YACV,MAAMQ;QACR;QAEF,OAAOR;IACT;IAEA,0CAA0C;IAC1CC,aAAaS,KAAK,CAAC,KAAO;IAE1B,OAAO;QACLC,OAAMC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,cAA8B,EAAEC,QAA0B;YAC3Hf,aACGI,IAAI,CAAC,CAACY;gBACLA,QAAQN,KAAK,CAACC,SAASC,MAAMC,cAAcC,gBAAgBC;YAC7D,GACCN,KAAK,CAAC,CAACF;gBACNQ,SAASR;YACX;QACJ;QACAU;YACE,IAAIpB,aAAaA,YAAYoB,KAAK;QACpC;QACAC,cAAaH,QAAqB;YAChCf,aACGI,IAAI,CAAC,CAACY;gBACLA,QAAQE,YAAY,CAACH;YACvB,GACCN,KAAK,CAAC;gBACLM,qBAAAA,+BAAAA;YACF;QACJ;IACF;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import installModule from 'install-module-linked';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import url from 'url';
|
|
4
|
+
// Get the node_modules directory relative to this file
|
|
5
|
+
const _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));
|
|
6
|
+
const nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');
|
|
7
|
+
let installed = false;
|
|
8
|
+
let installing = null;
|
|
9
|
+
function installDependency(name) {
|
|
10
|
+
return new Promise((resolve, reject)=>{
|
|
11
|
+
// install-module-linked will:
|
|
12
|
+
// 1. Check if module exists locally or in ~/.iml cache
|
|
13
|
+
// 2. If not, install to ~/.iml
|
|
14
|
+
// 3. Create symlink in nodeModules pointing to ~/.iml/package
|
|
15
|
+
installModule(name, nodeModules, {}, (err)=>{
|
|
16
|
+
if (err) return reject(err);
|
|
17
|
+
resolve();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function installInk() {
|
|
22
|
+
if (installed) return Promise.resolve();
|
|
23
|
+
if (installing) return installing;
|
|
24
|
+
// Install both ink and react - both are needed by session.tsx
|
|
25
|
+
installing = Promise.all([
|
|
26
|
+
installDependency('ink'),
|
|
27
|
+
installDependency('react')
|
|
28
|
+
]).then(()=>{
|
|
29
|
+
installed = true;
|
|
30
|
+
}).catch((err)=>{
|
|
31
|
+
installing = null;
|
|
32
|
+
throw err;
|
|
33
|
+
});
|
|
34
|
+
return installing;
|
|
35
|
+
}
|
|
36
|
+
export function loadInk(callback) {
|
|
37
|
+
installInk().then(()=>callback(null)).catch((err)=>callback(err));
|
|
38
|
+
}
|
|
39
|
+
export function isInkInstalled() {
|
|
40
|
+
return installed;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/loadInk.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install both ink and react - both are needed by session.tsx\n installing = Promise.all([installDependency('ink'), installDependency('react')])\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["installModule","path","url","_dirname","dirname","__dirname","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","err","installInk","all","then","catch","loadInk","callback","isInkInstalled"],"mappings":"AAAA,OAAOA,mBAAmB,wBAAwB;AAClD,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,uDAAuD;AACvD,MAAMC,WAAWF,KAAKG,OAAO,CAAC,OAAOC,cAAc,cAAcA,YAAYH,IAAII,aAAa,CAAC,YAAYJ,GAAG;AAC9G,MAAMK,cAAcN,KAAKO,IAAI,CAACL,UAAU,MAAM,MAAM,MAAM;AAE1D,IAAIM,YAAY;AAChB,IAAIC,aAAmC;AAEvC,SAASC,kBAAkBC,IAAY;IACrC,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,8BAA8B;QAC9B,uDAAuD;QACvD,+BAA+B;QAC/B,8DAA8D;QAC9Df,cAAcY,MAAML,aAAa,CAAC,GAAG,CAACS;YACpC,IAAIA,KAAK,OAAOD,OAAOC;YACvBF;QACF;IACF;AACF;AAEA,SAASG;IACP,IAAIR,WAAW,OAAOI,QAAQC,OAAO;IACrC,IAAIJ,YAAY,OAAOA;IAEvB,8DAA8D;IAC9DA,aAAaG,QAAQK,GAAG,CAAC;QAACP,kBAAkB;QAAQA,kBAAkB;KAAS,EAC5EQ,IAAI,CAAC;QACJV,YAAY;IACd,GACCW,KAAK,CAAC,CAACJ;QACNN,aAAa;QACb,MAAMM;IACR;IAEF,OAAON;AACT;AAEA,OAAO,SAASW,QAAQC,QAAqC;IAC3DL,aACGE,IAAI,CAAC,IAAMG,SAAS,OACpBF,KAAK,CAAC,CAACJ,MAAQM,SAASN;AAC7B;AAEA,OAAO,SAASO;IACd,OAAOd;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spawn-term",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Formats spawn with for terminal grouping",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"spawn",
|
|
@@ -44,19 +44,20 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/headless": "^5.5.0",
|
|
46
46
|
"cross-spawn-cb": "^2.4.10",
|
|
47
|
-
"
|
|
47
|
+
"install-module-linked": "^1.3.10",
|
|
48
48
|
"on-one": "^1.0.8",
|
|
49
|
-
"queue-cb": "^1.6.1"
|
|
50
|
-
"react": "^19.2.1"
|
|
49
|
+
"queue-cb": "^1.6.1"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@types/mocha": "^10.0.10",
|
|
54
|
-
"@types/node": "^24.10.
|
|
53
|
+
"@types/node": "^24.10.2",
|
|
55
54
|
"@types/react": "^19.2.7",
|
|
56
55
|
"cr": "^0.1.0",
|
|
56
|
+
"ink": "^6.5.1",
|
|
57
57
|
"is-version": "^1.0.7",
|
|
58
|
-
"node-version-use": "^1.9.
|
|
58
|
+
"node-version-use": "^1.9.9",
|
|
59
59
|
"pinkie-promise": "^2.0.1",
|
|
60
|
+
"react": "^19.2.1",
|
|
60
61
|
"ts-dev-stack": "^1.21.2",
|
|
61
62
|
"tsds-config": "^0.2.0"
|
|
62
63
|
},
|