@omnicross/cli-launcher 0.1.1 → 0.1.2
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/chunk-HNYCLVZP.cjs +1023 -0
- package/dist/chunk-K7IZD73K.js +1023 -0
- package/dist/index.cjs +78 -197
- package/dist/index.js +7 -112
- package/dist/pty-adapter.cjs +9 -102
- package/dist/pty-adapter.js +6 -80
- package/dist/types.cjs +1 -18
- package/package.json +4 -2
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __esm = (fn, res) => function __init() {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
};
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// ../../node_modules/node-pty/dist/chunk-DA5uXrvU.js
|
|
23
|
+
var _module = require('module');
|
|
24
|
+
var __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __esm2, __export2, __copyProps2, __toCommonJS2, __require;
|
|
25
|
+
var init_chunk_DA5uXrvU = __esm({
|
|
26
|
+
"../../node_modules/node-pty/dist/chunk-DA5uXrvU.js"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
__defProp2 = Object.defineProperty;
|
|
29
|
+
__getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
30
|
+
__getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
31
|
+
__hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
32
|
+
__esm2 = (fn, res) => function() {
|
|
33
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
34
|
+
};
|
|
35
|
+
__export2 = (target, all) => {
|
|
36
|
+
for (var name in all) __defProp2(target, name, {
|
|
37
|
+
get: all[name],
|
|
38
|
+
enumerable: true
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
__copyProps2 = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
43
|
+
key = keys[i];
|
|
44
|
+
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
45
|
+
get: ((k) => from[k]).bind(null, key),
|
|
46
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return to;
|
|
50
|
+
};
|
|
51
|
+
__toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
52
|
+
__require = /* @__PURE__ */ _module.createRequire.call(void 0, import.meta.url);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// ../../node_modules/node-pty/dist/conout-DQRErfxK.js
|
|
57
|
+
function getWorkerPipeName(conoutPipeName) {
|
|
58
|
+
return `${conoutPipeName}-worker`;
|
|
59
|
+
}
|
|
60
|
+
var ConoutWorkerMessage, init_conout;
|
|
61
|
+
var init_conout_DQRErfxK = __esm({
|
|
62
|
+
"../../node_modules/node-pty/dist/conout-DQRErfxK.js"() {
|
|
63
|
+
"use strict";
|
|
64
|
+
init_chunk_DA5uXrvU();
|
|
65
|
+
init_conout = __esm2({ "src/shared/conout.ts": (() => {
|
|
66
|
+
ConoutWorkerMessage = /* @__PURE__ */ (function(ConoutWorkerMessage$1) {
|
|
67
|
+
ConoutWorkerMessage$1[ConoutWorkerMessage$1["READY"] = 1] = "READY";
|
|
68
|
+
return ConoutWorkerMessage$1;
|
|
69
|
+
})({});
|
|
70
|
+
}) });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/node-pty/dist/index.js
|
|
75
|
+
var dist_exports = {};
|
|
76
|
+
__export(dist_exports, {
|
|
77
|
+
createTerminal: () => createTerminal,
|
|
78
|
+
fork: () => fork,
|
|
79
|
+
native: () => native,
|
|
80
|
+
open: () => open,
|
|
81
|
+
spawn: () => spawn
|
|
82
|
+
});
|
|
83
|
+
var _path = require('path'); var path$1 = _interopRequireWildcard(_path);
|
|
84
|
+
var _url = require('url');
|
|
85
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
86
|
+
var _os = require('os'); var os = _interopRequireWildcard(_os);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var _events = require('events');
|
|
90
|
+
var _child_process = require('child_process');
|
|
91
|
+
var _net = require('net');
|
|
92
|
+
var _worker_threads = require('worker_threads');
|
|
93
|
+
var _tty = require('tty'); var tty = _interopRequireWildcard(_tty);
|
|
94
|
+
function prebuildName() {
|
|
95
|
+
const tags = [];
|
|
96
|
+
tags.push(process.versions.hasOwnProperty("electron") ? "electron" : "node");
|
|
97
|
+
tags.push("abi" + process.versions.modules);
|
|
98
|
+
if (os.platform() === "linux" && fs.existsSync("/etc/alpine-release")) tags.push("musl");
|
|
99
|
+
return tags.join(".") + ".node";
|
|
100
|
+
}
|
|
101
|
+
function argsToCommandLine(file, args) {
|
|
102
|
+
if (isCommandLine(args)) {
|
|
103
|
+
if (args.length === 0) return file;
|
|
104
|
+
return `${argsToCommandLine(file, [])} ${args}`;
|
|
105
|
+
}
|
|
106
|
+
const argv = [file];
|
|
107
|
+
Array.prototype.push.apply(argv, args);
|
|
108
|
+
let result = "";
|
|
109
|
+
for (let argIndex = 0; argIndex < argv.length; argIndex++) {
|
|
110
|
+
if (argIndex > 0) result += " ";
|
|
111
|
+
const arg = argv[argIndex];
|
|
112
|
+
const hasLopsidedEnclosingQuote = xOr(arg[0] !== '"', arg[arg.length - 1] !== '"');
|
|
113
|
+
const hasNoEnclosingQuotes = arg[0] !== '"' && arg[arg.length - 1] !== '"';
|
|
114
|
+
const quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes);
|
|
115
|
+
if (quote) result += '"';
|
|
116
|
+
let bsCount = 0;
|
|
117
|
+
for (let i = 0; i < arg.length; i++) {
|
|
118
|
+
const p = arg[i];
|
|
119
|
+
if (p === "\\") bsCount++;
|
|
120
|
+
else if (p === '"') {
|
|
121
|
+
result += repeatText("\\", bsCount * 2 + 1);
|
|
122
|
+
result += '"';
|
|
123
|
+
bsCount = 0;
|
|
124
|
+
} else {
|
|
125
|
+
result += repeatText("\\", bsCount);
|
|
126
|
+
bsCount = 0;
|
|
127
|
+
result += p;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (quote) {
|
|
131
|
+
result += repeatText("\\", bsCount * 2);
|
|
132
|
+
result += '"';
|
|
133
|
+
} else result += repeatText("\\", bsCount);
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
function isCommandLine(args) {
|
|
138
|
+
return typeof args === "string";
|
|
139
|
+
}
|
|
140
|
+
function repeatText(text, count) {
|
|
141
|
+
let result = "";
|
|
142
|
+
for (let i = 0; i < count; i++) result += text;
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
function xOr(arg1, arg2) {
|
|
146
|
+
return arg1 && !arg2 || !arg1 && arg2;
|
|
147
|
+
}
|
|
148
|
+
function assign(target, ...sources) {
|
|
149
|
+
sources.forEach((source) => Object.keys(source).forEach((key) => target[key] = source[key]));
|
|
150
|
+
return target;
|
|
151
|
+
}
|
|
152
|
+
function spawn(file, args, opt) {
|
|
153
|
+
return new terminalCtor(file, args, opt);
|
|
154
|
+
}
|
|
155
|
+
function fork(file, args, opt) {
|
|
156
|
+
return new terminalCtor(file, args, opt);
|
|
157
|
+
}
|
|
158
|
+
function createTerminal(file, args, opt) {
|
|
159
|
+
return new terminalCtor(file, args, opt);
|
|
160
|
+
}
|
|
161
|
+
function open(options) {
|
|
162
|
+
return terminalCtor.open(options);
|
|
163
|
+
}
|
|
164
|
+
var getFilename, getDirname, __dirname, init_esm_shims, pathToBuild, ptyPath, init_prebuild_file_path, EventEmitter2, init_eventEmitter2, DEFAULT_COLS, DEFAULT_ROWS, FLOW_CONTROL_PAUSE, FLOW_CONTROL_RESUME, Terminal, init_terminal, FLUSH_DATA_INTERVAL$1, ConoutConnection, init_windowsConoutConnection, conptyNative, winptyNative, FLUSH_DATA_INTERVAL, WindowsPtyAgent, init_windowsPtyAgent, init_utils, windowsTerminal_exports, DEFAULT_FILE$1, DEFAULT_NAME$1, WindowsTerminal, init_windowsTerminal, pty$1, pty, init_prebuild_loader, unixTerminal_exports, helperPath, DEFAULT_FILE, DEFAULT_NAME, DESTROY_SOCKET_TIMEOUT_MS, UnixTerminal, init_unixTerminal, terminalCtor, native;
|
|
165
|
+
var init_dist = __esm({
|
|
166
|
+
"../../node_modules/node-pty/dist/index.js"() {
|
|
167
|
+
"use strict";
|
|
168
|
+
init_chunk_DA5uXrvU();
|
|
169
|
+
init_conout_DQRErfxK();
|
|
170
|
+
init_esm_shims = __esm2({ "node_modules/.pnpm/tsdown@0.14.1_typescript@5.9.2/node_modules/tsdown/esm-shims.js": (() => {
|
|
171
|
+
getFilename = () => _url.fileURLToPath.call(void 0, import.meta.url);
|
|
172
|
+
getDirname = () => path$1.default.dirname(getFilename());
|
|
173
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
174
|
+
}) });
|
|
175
|
+
init_prebuild_file_path = __esm2({ "src/prebuild-file-path.ts": (() => {
|
|
176
|
+
init_esm_shims();
|
|
177
|
+
pathToBuild = path$1.resolve(__dirname, `../prebuilds/${os.platform()}-${os.arch()}/${prebuildName()}`);
|
|
178
|
+
ptyPath = fs.existsSync(pathToBuild) ? pathToBuild : null;
|
|
179
|
+
}) });
|
|
180
|
+
init_eventEmitter2 = __esm2({ "src/eventEmitter2.ts": (() => {
|
|
181
|
+
EventEmitter2 = (_class = class {constructor() { _class.prototype.__init2.call(this); }
|
|
182
|
+
__init2() {this._listeners = []}
|
|
183
|
+
|
|
184
|
+
get event() {
|
|
185
|
+
if (!this._event) this._event = (listener) => {
|
|
186
|
+
this._listeners.push(listener);
|
|
187
|
+
const disposable = { dispose: () => {
|
|
188
|
+
for (let i = 0; i < this._listeners.length; i++) if (this._listeners[i] === listener) {
|
|
189
|
+
this._listeners.splice(i, 1);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
} };
|
|
193
|
+
return disposable;
|
|
194
|
+
};
|
|
195
|
+
return this._event;
|
|
196
|
+
}
|
|
197
|
+
fire(data) {
|
|
198
|
+
const queue = [];
|
|
199
|
+
for (let i = 0; i < this._listeners.length; i++) queue.push(this._listeners[i]);
|
|
200
|
+
for (let i = 0; i < queue.length; i++) queue[i].call(void 0, data);
|
|
201
|
+
}
|
|
202
|
+
}, _class);
|
|
203
|
+
}) });
|
|
204
|
+
init_terminal = __esm2({ "src/terminal.ts": (() => {
|
|
205
|
+
init_eventEmitter2();
|
|
206
|
+
DEFAULT_COLS = 80;
|
|
207
|
+
DEFAULT_ROWS = 24;
|
|
208
|
+
FLOW_CONTROL_PAUSE = "";
|
|
209
|
+
FLOW_CONTROL_RESUME = "";
|
|
210
|
+
Terminal = (_class2 = class {
|
|
211
|
+
|
|
212
|
+
__init3() {this._pid = 0}
|
|
213
|
+
__init4() {this._fd = 0}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
__init5() {this._cols = 0}
|
|
218
|
+
__init6() {this._rows = 0}
|
|
219
|
+
__init7() {this._readable = false}
|
|
220
|
+
__init8() {this._writable = false}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
__init9() {this._onData = new EventEmitter2()}
|
|
226
|
+
get onData() {
|
|
227
|
+
return this._onData.event;
|
|
228
|
+
}
|
|
229
|
+
__init10() {this._onExit = new EventEmitter2()}
|
|
230
|
+
get onExit() {
|
|
231
|
+
return this._onExit.event;
|
|
232
|
+
}
|
|
233
|
+
get pid() {
|
|
234
|
+
return this._pid;
|
|
235
|
+
}
|
|
236
|
+
get cols() {
|
|
237
|
+
return this._cols;
|
|
238
|
+
}
|
|
239
|
+
get rows() {
|
|
240
|
+
return this._rows;
|
|
241
|
+
}
|
|
242
|
+
constructor(opt) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);
|
|
243
|
+
this._internalee = new (0, _events.EventEmitter)();
|
|
244
|
+
this.handleFlowControl = !!_optionalChain([opt, 'optionalAccess', _ => _.handleFlowControl]);
|
|
245
|
+
this._flowControlPause = _optionalChain([opt, 'optionalAccess', _2 => _2.flowControlPause]) || FLOW_CONTROL_PAUSE;
|
|
246
|
+
this._flowControlResume = _optionalChain([opt, 'optionalAccess', _3 => _3.flowControlResume]) || FLOW_CONTROL_RESUME;
|
|
247
|
+
if (!opt) return;
|
|
248
|
+
this._checkType("name", opt.name ? opt.name : void 0, "string");
|
|
249
|
+
this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
|
|
250
|
+
this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
|
|
251
|
+
this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
|
|
252
|
+
this._checkType("env", opt.env ? opt.env : void 0, "object");
|
|
253
|
+
this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
|
|
254
|
+
this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
|
|
255
|
+
this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
|
|
256
|
+
}
|
|
257
|
+
write(data) {
|
|
258
|
+
if (this.handleFlowControl) {
|
|
259
|
+
if (data === this._flowControlPause) {
|
|
260
|
+
this.pause();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (data === this._flowControlResume) {
|
|
264
|
+
this.resume();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
this._write(data);
|
|
269
|
+
}
|
|
270
|
+
_forwardEvents() {
|
|
271
|
+
this.on("data", (e) => this._onData.fire(e));
|
|
272
|
+
this.on("exit", (exitCode, signal) => this._onExit.fire({
|
|
273
|
+
exitCode,
|
|
274
|
+
signal
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
_checkType(name, value, type, allowArray = false) {
|
|
278
|
+
if (value === void 0) return;
|
|
279
|
+
if (allowArray) {
|
|
280
|
+
if (Array.isArray(value)) {
|
|
281
|
+
value.forEach((v, i) => {
|
|
282
|
+
if (typeof v !== type) throw new Error(`${name}[${i}] must be a ${type} (not a ${typeof v[i]})`);
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (typeof value !== type) throw new Error(`${name} must be a ${type} (not a ${typeof value})`);
|
|
288
|
+
}
|
|
289
|
+
/** See net.Socket.end */
|
|
290
|
+
end(data) {
|
|
291
|
+
this._socket.end(data);
|
|
292
|
+
}
|
|
293
|
+
/** See stream.Readable.pipe */
|
|
294
|
+
pipe(dest, options) {
|
|
295
|
+
return this._socket.pipe(dest, options);
|
|
296
|
+
}
|
|
297
|
+
/** See net.Socket.pause */
|
|
298
|
+
pause() {
|
|
299
|
+
return this._socket.pause();
|
|
300
|
+
}
|
|
301
|
+
/** See net.Socket.resume */
|
|
302
|
+
resume() {
|
|
303
|
+
return this._socket.resume();
|
|
304
|
+
}
|
|
305
|
+
/** See net.Socket.setEncoding */
|
|
306
|
+
setEncoding(encoding) {
|
|
307
|
+
if (this._socket._decoder) delete this._socket._decoder;
|
|
308
|
+
if (encoding) this._socket.setEncoding(encoding);
|
|
309
|
+
}
|
|
310
|
+
addListener(eventName, listener) {
|
|
311
|
+
this.on(eventName, listener);
|
|
312
|
+
}
|
|
313
|
+
on(eventName, listener) {
|
|
314
|
+
if (eventName === "close") {
|
|
315
|
+
this._internalee.on("close", listener);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this._socket.on(eventName, listener);
|
|
319
|
+
}
|
|
320
|
+
emit(eventName, ...args) {
|
|
321
|
+
if (eventName === "close") return this._internalee.emit.apply(this._internalee, arguments);
|
|
322
|
+
return this._socket.emit.apply(this._socket, arguments);
|
|
323
|
+
}
|
|
324
|
+
listeners(eventName) {
|
|
325
|
+
return this._socket.listeners(eventName);
|
|
326
|
+
}
|
|
327
|
+
removeListener(eventName, listener) {
|
|
328
|
+
this._socket.removeListener(eventName, listener);
|
|
329
|
+
}
|
|
330
|
+
removeAllListeners(eventName) {
|
|
331
|
+
this._socket.removeAllListeners(eventName);
|
|
332
|
+
}
|
|
333
|
+
once(eventName, listener) {
|
|
334
|
+
this._socket.once(eventName, listener);
|
|
335
|
+
}
|
|
336
|
+
_close() {
|
|
337
|
+
this._socket.readable = false;
|
|
338
|
+
this.write = () => {
|
|
339
|
+
};
|
|
340
|
+
this.end = () => {
|
|
341
|
+
};
|
|
342
|
+
this._writable = false;
|
|
343
|
+
this._readable = false;
|
|
344
|
+
}
|
|
345
|
+
_parseEnv(env) {
|
|
346
|
+
const keys = Object.keys(env || {});
|
|
347
|
+
const pairs = [];
|
|
348
|
+
for (let i = 0; i < keys.length; i++) {
|
|
349
|
+
if (keys[i] === void 0) continue;
|
|
350
|
+
pairs.push(keys[i] + "=" + env[keys[i]]);
|
|
351
|
+
}
|
|
352
|
+
return pairs;
|
|
353
|
+
}
|
|
354
|
+
}, _class2);
|
|
355
|
+
}) });
|
|
356
|
+
init_windowsConoutConnection = __esm2({ "src/windowsConoutConnection.ts": (() => {
|
|
357
|
+
init_esm_shims();
|
|
358
|
+
init_conout();
|
|
359
|
+
init_eventEmitter2();
|
|
360
|
+
FLUSH_DATA_INTERVAL$1 = 1e3;
|
|
361
|
+
ConoutConnection = (_class3 = class {
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
__init11() {this._isDisposed = false}
|
|
365
|
+
__init12() {this._onReady = new EventEmitter2()}
|
|
366
|
+
get onReady() {
|
|
367
|
+
return this._onReady.event;
|
|
368
|
+
}
|
|
369
|
+
constructor(_conoutPipeName, _useConptyDll) {;_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);
|
|
370
|
+
this._conoutPipeName = _conoutPipeName;
|
|
371
|
+
this._useConptyDll = _useConptyDll;
|
|
372
|
+
const workerData$1 = { conoutPipeName: _conoutPipeName };
|
|
373
|
+
const scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
|
|
374
|
+
this._worker = new (0, _worker_threads.Worker)(_path.join.call(void 0, scriptPath, "worker/conoutSocketWorker.js"), { workerData: workerData$1 });
|
|
375
|
+
this._worker.on("message", (message) => {
|
|
376
|
+
switch (message) {
|
|
377
|
+
case ConoutWorkerMessage.READY:
|
|
378
|
+
this._onReady.fire();
|
|
379
|
+
return;
|
|
380
|
+
default:
|
|
381
|
+
console.warn("Unexpected ConoutWorkerMessage", message);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
dispose() {
|
|
386
|
+
if (!this._useConptyDll && this._isDisposed) return;
|
|
387
|
+
this._isDisposed = true;
|
|
388
|
+
this._drainDataAndClose();
|
|
389
|
+
}
|
|
390
|
+
connectSocket(socket) {
|
|
391
|
+
socket.connect(getWorkerPipeName(this._conoutPipeName));
|
|
392
|
+
}
|
|
393
|
+
_drainDataAndClose() {
|
|
394
|
+
if (this._drainTimeout) clearTimeout(this._drainTimeout);
|
|
395
|
+
this._drainTimeout = setTimeout(() => this._destroySocket(), FLUSH_DATA_INTERVAL$1);
|
|
396
|
+
}
|
|
397
|
+
async _destroySocket() {
|
|
398
|
+
await this._worker.terminate();
|
|
399
|
+
}
|
|
400
|
+
}, _class3);
|
|
401
|
+
}) });
|
|
402
|
+
init_windowsPtyAgent = __esm2({ "src/windowsPtyAgent.ts": (() => {
|
|
403
|
+
init_esm_shims();
|
|
404
|
+
init_windowsConoutConnection();
|
|
405
|
+
;
|
|
406
|
+
;
|
|
407
|
+
FLUSH_DATA_INTERVAL = 1e3;
|
|
408
|
+
WindowsPtyAgent = (_class4 = class {
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
__init13() {this._pid = 0}
|
|
412
|
+
__init14() {this._innerPid = 0}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
get inSocket() {
|
|
420
|
+
return this._inSocket;
|
|
421
|
+
}
|
|
422
|
+
get outSocket() {
|
|
423
|
+
return this._outSocket;
|
|
424
|
+
}
|
|
425
|
+
get fd() {
|
|
426
|
+
return this._fd;
|
|
427
|
+
}
|
|
428
|
+
get innerPid() {
|
|
429
|
+
return this._innerPid;
|
|
430
|
+
}
|
|
431
|
+
get pty() {
|
|
432
|
+
return this._pty;
|
|
433
|
+
}
|
|
434
|
+
constructor(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll = false, conptyInheritCursor = false) {;_class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this);
|
|
435
|
+
this._useConpty = _useConpty;
|
|
436
|
+
this._useConptyDll = _useConptyDll;
|
|
437
|
+
if (this._useConpty === void 0 || this._useConpty === true) this._useConpty = this._getWindowsBuildNumber() >= 18309;
|
|
438
|
+
if (this._useConpty) {
|
|
439
|
+
if (!conptyNative) try {
|
|
440
|
+
conptyNative = __require("../build/Release/conpty.node");
|
|
441
|
+
} catch (outerError) {
|
|
442
|
+
try {
|
|
443
|
+
conptyNative = __require("../build/Debug/conpty.node");
|
|
444
|
+
} catch (innerError) {
|
|
445
|
+
console.error("innerError", innerError);
|
|
446
|
+
throw outerError;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
} else if (!winptyNative) try {
|
|
450
|
+
winptyNative = __require("../build/Release/pty.node");
|
|
451
|
+
} catch (outerError) {
|
|
452
|
+
try {
|
|
453
|
+
winptyNative = __require("../build/Debug/pty.node");
|
|
454
|
+
} catch (innerError) {
|
|
455
|
+
console.error("innerError", innerError);
|
|
456
|
+
throw outerError;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
this._ptyNative = this._useConpty ? conptyNative : winptyNative;
|
|
460
|
+
cwd = path$1.resolve(cwd);
|
|
461
|
+
const commandLine = argsToCommandLine(file, args);
|
|
462
|
+
let term;
|
|
463
|
+
if (this._useConpty) term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
|
|
464
|
+
else {
|
|
465
|
+
term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
|
|
466
|
+
this._pid = term.pid;
|
|
467
|
+
this._innerPid = term.innerPid;
|
|
468
|
+
}
|
|
469
|
+
this._fd = term.fd;
|
|
470
|
+
this._pty = term.pty;
|
|
471
|
+
this._outSocket = new (0, _net.Socket)();
|
|
472
|
+
this._outSocket.setEncoding("utf8");
|
|
473
|
+
this._conoutSocketWorker = new ConoutConnection(term.conout, this._useConptyDll);
|
|
474
|
+
this._conoutSocketWorker.onReady(() => {
|
|
475
|
+
this._conoutSocketWorker.connectSocket(this._outSocket);
|
|
476
|
+
});
|
|
477
|
+
this._outSocket.on("connect", () => {
|
|
478
|
+
this._outSocket.emit("ready_datapipe");
|
|
479
|
+
});
|
|
480
|
+
const inSocketFD = fs.openSync(term.conin, "w");
|
|
481
|
+
this._inSocket = new (0, _net.Socket)({
|
|
482
|
+
fd: inSocketFD,
|
|
483
|
+
readable: false,
|
|
484
|
+
writable: true
|
|
485
|
+
});
|
|
486
|
+
this._inSocket.setEncoding("utf8");
|
|
487
|
+
if (this._useConpty) {
|
|
488
|
+
const connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, (c) => this._$onProcessExit(c));
|
|
489
|
+
this._innerPid = connect.pid;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
resize(cols, rows) {
|
|
493
|
+
if (this._useConpty) {
|
|
494
|
+
if (this._exitCode !== void 0) throw new Error("Cannot resize a pty that has already exited");
|
|
495
|
+
this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
this._ptyNative.resize(this._pid, cols, rows);
|
|
499
|
+
}
|
|
500
|
+
clear() {
|
|
501
|
+
if (this._useConpty) this._ptyNative.clear(this._pty, this._useConptyDll);
|
|
502
|
+
}
|
|
503
|
+
kill() {
|
|
504
|
+
if (this._useConpty) if (!this._useConptyDll) {
|
|
505
|
+
this._inSocket.readable = false;
|
|
506
|
+
this._outSocket.readable = false;
|
|
507
|
+
this._getConsoleProcessList().then((consoleProcessList) => {
|
|
508
|
+
consoleProcessList.forEach((pid) => {
|
|
509
|
+
try {
|
|
510
|
+
process.kill(pid);
|
|
511
|
+
} catch (e) {
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
this._ptyNative.kill(this._pty, this._useConptyDll);
|
|
516
|
+
this._conoutSocketWorker.dispose();
|
|
517
|
+
} else {
|
|
518
|
+
this._inSocket.destroy();
|
|
519
|
+
this._ptyNative.kill(this._pty, this._useConptyDll);
|
|
520
|
+
this._outSocket.on("data", () => {
|
|
521
|
+
this._conoutSocketWorker.dispose();
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
const processList = this._ptyNative.getProcessList(this._pid);
|
|
526
|
+
this._ptyNative.kill(this._pid, this._innerPid);
|
|
527
|
+
processList.forEach((pid) => {
|
|
528
|
+
try {
|
|
529
|
+
process.kill(pid);
|
|
530
|
+
} catch (e) {
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
_getConsoleProcessList() {
|
|
536
|
+
return new Promise((resolve2) => {
|
|
537
|
+
const agent = _child_process.fork.call(void 0, path$1.join(__dirname, "conpty_console_list_agent"), [this._innerPid.toString()]);
|
|
538
|
+
agent.on("message", (message) => {
|
|
539
|
+
clearTimeout(timeout);
|
|
540
|
+
resolve2(message.consoleProcessList);
|
|
541
|
+
});
|
|
542
|
+
const timeout = setTimeout(() => {
|
|
543
|
+
agent.kill();
|
|
544
|
+
resolve2([this._innerPid]);
|
|
545
|
+
}, 5e3);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
get exitCode() {
|
|
549
|
+
if (this._useConpty) return this._exitCode;
|
|
550
|
+
const winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
|
|
551
|
+
return winptyExitCode === -1 ? void 0 : winptyExitCode;
|
|
552
|
+
}
|
|
553
|
+
_getWindowsBuildNumber() {
|
|
554
|
+
const osVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(os.release());
|
|
555
|
+
let buildNumber = 0;
|
|
556
|
+
if (osVersion && osVersion.length === 4) buildNumber = parseInt(osVersion[3]);
|
|
557
|
+
return buildNumber;
|
|
558
|
+
}
|
|
559
|
+
_generatePipeName() {
|
|
560
|
+
return `conpty-${Math.random() * 1e7}`;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Triggered from the native side when a contpy process exits.
|
|
564
|
+
*/
|
|
565
|
+
_$onProcessExit(exitCode) {
|
|
566
|
+
this._exitCode = exitCode;
|
|
567
|
+
if (!this._useConptyDll) {
|
|
568
|
+
this._flushDataAndCleanUp();
|
|
569
|
+
this._outSocket.on("data", () => this._flushDataAndCleanUp());
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
_flushDataAndCleanUp() {
|
|
573
|
+
if (this._useConptyDll) return;
|
|
574
|
+
if (this._closeTimeout) clearTimeout(this._closeTimeout);
|
|
575
|
+
this._closeTimeout = setTimeout(() => this._cleanUpProcess(), FLUSH_DATA_INTERVAL);
|
|
576
|
+
}
|
|
577
|
+
_cleanUpProcess() {
|
|
578
|
+
if (this._useConptyDll) return;
|
|
579
|
+
this._inSocket.readable = false;
|
|
580
|
+
this._outSocket.readable = false;
|
|
581
|
+
this._outSocket.destroy();
|
|
582
|
+
}
|
|
583
|
+
}, _class4);
|
|
584
|
+
}) });
|
|
585
|
+
init_utils = __esm2({ "src/utils.ts": (() => {
|
|
586
|
+
}) });
|
|
587
|
+
windowsTerminal_exports = {};
|
|
588
|
+
__export2(windowsTerminal_exports, { WindowsTerminal: () => WindowsTerminal });
|
|
589
|
+
init_windowsTerminal = __esm2({ "src/windowsTerminal.ts": (() => {
|
|
590
|
+
init_terminal();
|
|
591
|
+
init_windowsPtyAgent();
|
|
592
|
+
init_utils();
|
|
593
|
+
DEFAULT_FILE$1 = "cmd.exe";
|
|
594
|
+
DEFAULT_NAME$1 = "Windows Shell";
|
|
595
|
+
WindowsTerminal = class extends Terminal {
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
constructor(file, args, opt) {
|
|
600
|
+
super(opt);
|
|
601
|
+
this._checkType("args", args, "string", true);
|
|
602
|
+
args = args || [];
|
|
603
|
+
file = file || DEFAULT_FILE$1;
|
|
604
|
+
opt = opt || {};
|
|
605
|
+
opt.env = opt.env || process.env;
|
|
606
|
+
if (opt.encoding) console.warn("Setting encoding on Windows is not supported");
|
|
607
|
+
const env = assign({}, opt.env);
|
|
608
|
+
this._cols = opt.cols || DEFAULT_COLS;
|
|
609
|
+
this._rows = opt.rows || DEFAULT_ROWS;
|
|
610
|
+
const cwd = opt.cwd || process.cwd();
|
|
611
|
+
const name = opt.name || env.TERM || DEFAULT_NAME$1;
|
|
612
|
+
const parsedEnv = this._parseEnv(env);
|
|
613
|
+
this._isReady = false;
|
|
614
|
+
this._deferreds = [];
|
|
615
|
+
this._agent = new WindowsPtyAgent(file, args, parsedEnv, cwd, this._cols, this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
|
|
616
|
+
this._socket = this._agent.outSocket;
|
|
617
|
+
this._pid = this._agent.innerPid;
|
|
618
|
+
this._fd = this._agent.fd;
|
|
619
|
+
this._pty = this._agent.pty;
|
|
620
|
+
this._socket.on("ready_datapipe", () => {
|
|
621
|
+
[
|
|
622
|
+
"connect",
|
|
623
|
+
"data",
|
|
624
|
+
"end",
|
|
625
|
+
"timeout",
|
|
626
|
+
"drain"
|
|
627
|
+
].forEach((event) => {
|
|
628
|
+
this._socket.on(event, () => {
|
|
629
|
+
if (!this._isReady && event === "data") {
|
|
630
|
+
this._isReady = true;
|
|
631
|
+
this._deferreds.forEach((fn) => {
|
|
632
|
+
fn.run();
|
|
633
|
+
});
|
|
634
|
+
this._deferreds = [];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
this._socket.on("error", (err) => {
|
|
639
|
+
this._close();
|
|
640
|
+
if (err.code) {
|
|
641
|
+
if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
|
|
642
|
+
}
|
|
643
|
+
if (this.listeners("error").length < 2) throw err;
|
|
644
|
+
});
|
|
645
|
+
this._socket.on("close", () => {
|
|
646
|
+
this.emit("exit", this._agent.exitCode);
|
|
647
|
+
this._close();
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
this._file = file;
|
|
651
|
+
this._name = name;
|
|
652
|
+
this._readable = true;
|
|
653
|
+
this._writable = true;
|
|
654
|
+
this._forwardEvents();
|
|
655
|
+
}
|
|
656
|
+
_write(data) {
|
|
657
|
+
this._defer(this._doWrite, data);
|
|
658
|
+
}
|
|
659
|
+
_doWrite(data) {
|
|
660
|
+
this._agent.inSocket.write(data);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* openpty
|
|
664
|
+
*/
|
|
665
|
+
static open(options) {
|
|
666
|
+
throw new Error("open() not supported on windows, use Fork() instead.");
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* TTY
|
|
670
|
+
*/
|
|
671
|
+
resize(cols, rows) {
|
|
672
|
+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
|
|
673
|
+
this._deferNoArgs(() => {
|
|
674
|
+
this._agent.resize(cols, rows);
|
|
675
|
+
this._cols = cols;
|
|
676
|
+
this._rows = rows;
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
clear() {
|
|
680
|
+
this._deferNoArgs(() => {
|
|
681
|
+
this._agent.clear();
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
destroy() {
|
|
685
|
+
this._deferNoArgs(() => {
|
|
686
|
+
this.kill();
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
kill(signal) {
|
|
690
|
+
this._deferNoArgs(() => {
|
|
691
|
+
if (signal) throw new Error("Signals not supported on windows.");
|
|
692
|
+
this._close();
|
|
693
|
+
this._agent.kill();
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
_deferNoArgs(deferredFn) {
|
|
697
|
+
if (this._isReady) {
|
|
698
|
+
deferredFn.call(this);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
this._deferreds.push({ run: () => deferredFn.call(this) });
|
|
702
|
+
}
|
|
703
|
+
_defer(deferredFn, arg) {
|
|
704
|
+
if (this._isReady) {
|
|
705
|
+
deferredFn.call(this, arg);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
this._deferreds.push({ run: () => deferredFn.call(this, arg) });
|
|
709
|
+
}
|
|
710
|
+
get process() {
|
|
711
|
+
return this._name;
|
|
712
|
+
}
|
|
713
|
+
get master() {
|
|
714
|
+
throw new Error("master is not supported on Windows");
|
|
715
|
+
}
|
|
716
|
+
get slave() {
|
|
717
|
+
throw new Error("slave is not supported on Windows");
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
}) });
|
|
721
|
+
init_prebuild_loader = __esm2({ "src/prebuild-loader.ts": (() => {
|
|
722
|
+
init_prebuild_file_path();
|
|
723
|
+
;
|
|
724
|
+
try {
|
|
725
|
+
pty$1 = __require(ptyPath || "../build/Release/pty.node");
|
|
726
|
+
} catch (outerError) {
|
|
727
|
+
try {
|
|
728
|
+
pty$1 = ptyPath ? __require("../build/Release/pty.node") : __require("../build/Debug/pty.node");
|
|
729
|
+
} catch (innerError) {
|
|
730
|
+
console.error("innerError", innerError);
|
|
731
|
+
throw outerError;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
pty = pty$1;
|
|
735
|
+
}) });
|
|
736
|
+
unixTerminal_exports = {};
|
|
737
|
+
__export2(unixTerminal_exports, { UnixTerminal: () => UnixTerminal });
|
|
738
|
+
init_unixTerminal = __esm2({ "src/unixTerminal.ts": (() => {
|
|
739
|
+
init_esm_shims();
|
|
740
|
+
init_terminal();
|
|
741
|
+
init_utils();
|
|
742
|
+
init_prebuild_loader();
|
|
743
|
+
;
|
|
744
|
+
helperPath = "../build/Release/spawn-helper";
|
|
745
|
+
helperPath = path$1.resolve(__dirname, helperPath);
|
|
746
|
+
helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
|
|
747
|
+
helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
|
|
748
|
+
DEFAULT_FILE = "sh";
|
|
749
|
+
DEFAULT_NAME = "xterm";
|
|
750
|
+
DESTROY_SOCKET_TIMEOUT_MS = 200;
|
|
751
|
+
UnixTerminal = (_class5 = class UnixTerminal2 extends Terminal {
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
__init15() {this._boundClose = false}
|
|
759
|
+
__init16() {this._emittedClose = false}
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
get master() {
|
|
763
|
+
return this._master;
|
|
764
|
+
}
|
|
765
|
+
get slave() {
|
|
766
|
+
return this._slave;
|
|
767
|
+
}
|
|
768
|
+
constructor(file, args, opt) {
|
|
769
|
+
super(opt);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);;
|
|
770
|
+
if (typeof args === "string") throw new Error("args as a string is not supported on unix.");
|
|
771
|
+
args = args || [];
|
|
772
|
+
file = file || DEFAULT_FILE;
|
|
773
|
+
opt = opt || {};
|
|
774
|
+
opt.env = opt.env || process.env;
|
|
775
|
+
this._cols = opt.cols || DEFAULT_COLS;
|
|
776
|
+
this._rows = opt.rows || DEFAULT_ROWS;
|
|
777
|
+
const uid = _nullishCoalesce(opt.uid, () => ( -1));
|
|
778
|
+
const gid = _nullishCoalesce(opt.gid, () => ( -1));
|
|
779
|
+
const env = assign({}, opt.env);
|
|
780
|
+
if (opt.env === process.env) this._sanitizeEnv(env);
|
|
781
|
+
const cwd = opt.cwd || process.cwd();
|
|
782
|
+
env.PWD = cwd;
|
|
783
|
+
const name = opt.name || env.TERM || DEFAULT_NAME;
|
|
784
|
+
env.TERM = name;
|
|
785
|
+
const parsedEnv = this._parseEnv(env);
|
|
786
|
+
const encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
|
|
787
|
+
const onexit = (code, signal) => {
|
|
788
|
+
if (!this._emittedClose) {
|
|
789
|
+
if (this._boundClose) return;
|
|
790
|
+
this._boundClose = true;
|
|
791
|
+
let timeout = setTimeout(() => {
|
|
792
|
+
timeout = null;
|
|
793
|
+
this._socket.destroy();
|
|
794
|
+
}, DESTROY_SOCKET_TIMEOUT_MS);
|
|
795
|
+
this.once("close", () => {
|
|
796
|
+
if (timeout !== null) clearTimeout(timeout);
|
|
797
|
+
this.emit("exit", code, signal);
|
|
798
|
+
});
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
this.emit("exit", code, signal);
|
|
802
|
+
};
|
|
803
|
+
const term = pty.fork(file, args, parsedEnv, cwd, this._cols, this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
|
|
804
|
+
this._socket = new tty.ReadStream(term.fd);
|
|
805
|
+
if (encoding !== null) this._socket.setEncoding(encoding);
|
|
806
|
+
this._socket.on("error", (err) => {
|
|
807
|
+
if (err.code) {
|
|
808
|
+
if (~err.code.indexOf("EAGAIN")) return;
|
|
809
|
+
}
|
|
810
|
+
this._close();
|
|
811
|
+
if (!this._emittedClose) {
|
|
812
|
+
this._emittedClose = true;
|
|
813
|
+
this.emit("close");
|
|
814
|
+
}
|
|
815
|
+
if (err.code) {
|
|
816
|
+
if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) return;
|
|
817
|
+
}
|
|
818
|
+
if (this.listeners("error").length < 2) throw err;
|
|
819
|
+
});
|
|
820
|
+
this._pid = term.pid;
|
|
821
|
+
this._fd = term.fd;
|
|
822
|
+
this._pty = term.pty;
|
|
823
|
+
this._file = file;
|
|
824
|
+
this._name = name;
|
|
825
|
+
this._readable = true;
|
|
826
|
+
this._writable = true;
|
|
827
|
+
this._socket.on("close", () => {
|
|
828
|
+
if (this._emittedClose) return;
|
|
829
|
+
this._emittedClose = true;
|
|
830
|
+
this._close();
|
|
831
|
+
this.emit("close");
|
|
832
|
+
});
|
|
833
|
+
this._forwardEvents();
|
|
834
|
+
}
|
|
835
|
+
_write(data) {
|
|
836
|
+
this._socket.write(data);
|
|
837
|
+
}
|
|
838
|
+
get fd() {
|
|
839
|
+
return this._fd;
|
|
840
|
+
}
|
|
841
|
+
get ptsName() {
|
|
842
|
+
return this._pty;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* openpty
|
|
846
|
+
*/
|
|
847
|
+
static open(opt) {
|
|
848
|
+
const self = Object.create(UnixTerminal2.prototype);
|
|
849
|
+
opt = opt || {};
|
|
850
|
+
if (arguments.length > 1) opt = {
|
|
851
|
+
cols: arguments[1],
|
|
852
|
+
rows: arguments[2]
|
|
853
|
+
};
|
|
854
|
+
const cols = opt.cols || DEFAULT_COLS;
|
|
855
|
+
const rows = opt.rows || DEFAULT_ROWS;
|
|
856
|
+
const encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
|
|
857
|
+
const term = pty.open(cols, rows);
|
|
858
|
+
self._master = new tty.ReadStream(term.master);
|
|
859
|
+
if (encoding !== null) self._master.setEncoding(encoding);
|
|
860
|
+
self._master.resume();
|
|
861
|
+
self._slave = new tty.ReadStream(term.slave);
|
|
862
|
+
if (encoding !== null) self._slave.setEncoding(encoding);
|
|
863
|
+
self._slave.resume();
|
|
864
|
+
self._socket = self._master;
|
|
865
|
+
self._pid = -1;
|
|
866
|
+
self._fd = term.master;
|
|
867
|
+
self._pty = term.pty;
|
|
868
|
+
self._file = process.argv[0] || "node";
|
|
869
|
+
self._name = process.env.TERM || "";
|
|
870
|
+
self._readable = true;
|
|
871
|
+
self._writable = true;
|
|
872
|
+
self._socket.on("error", (err) => {
|
|
873
|
+
self._close();
|
|
874
|
+
if (self.listeners("error").length < 2) throw err;
|
|
875
|
+
});
|
|
876
|
+
self._socket.on("close", () => {
|
|
877
|
+
self._close();
|
|
878
|
+
});
|
|
879
|
+
return self;
|
|
880
|
+
}
|
|
881
|
+
destroy() {
|
|
882
|
+
this._close();
|
|
883
|
+
this._socket.once("close", () => {
|
|
884
|
+
this.kill("SIGHUP");
|
|
885
|
+
});
|
|
886
|
+
this._socket.destroy();
|
|
887
|
+
}
|
|
888
|
+
kill(signal) {
|
|
889
|
+
try {
|
|
890
|
+
process.kill(this.pid, signal || "SIGHUP");
|
|
891
|
+
} catch (e) {
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Gets the name of the process.
|
|
896
|
+
*/
|
|
897
|
+
get process() {
|
|
898
|
+
if (process.platform === "darwin") {
|
|
899
|
+
const title = pty.process(this._fd);
|
|
900
|
+
return title !== "kernel_task" ? title : this._file;
|
|
901
|
+
}
|
|
902
|
+
return pty.process(this._fd, this._pty) || this._file;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* TTY
|
|
906
|
+
*/
|
|
907
|
+
resize(cols, rows) {
|
|
908
|
+
if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) throw new Error("resizing must be done using positive cols and rows");
|
|
909
|
+
pty.resize(this._fd, cols, rows);
|
|
910
|
+
this._cols = cols;
|
|
911
|
+
this._rows = rows;
|
|
912
|
+
}
|
|
913
|
+
clear() {
|
|
914
|
+
}
|
|
915
|
+
_sanitizeEnv(env) {
|
|
916
|
+
delete env["TMUX"];
|
|
917
|
+
delete env["TMUX_PANE"];
|
|
918
|
+
delete env["STY"];
|
|
919
|
+
delete env["WINDOW"];
|
|
920
|
+
delete env["WINDOWID"];
|
|
921
|
+
delete env["TERMCAP"];
|
|
922
|
+
delete env["COLUMNS"];
|
|
923
|
+
delete env["LINES"];
|
|
924
|
+
}
|
|
925
|
+
}, _class5);
|
|
926
|
+
}) });
|
|
927
|
+
init_prebuild_file_path();
|
|
928
|
+
if (process.platform === "win32") terminalCtor = (init_windowsTerminal(), __toCommonJS2(windowsTerminal_exports)).WindowsTerminal;
|
|
929
|
+
else terminalCtor = (init_unixTerminal(), __toCommonJS2(unixTerminal_exports)).UnixTerminal;
|
|
930
|
+
native = process.platform !== "win32" ? __require(ptyPath || "../build/Release/pty.node") : null;
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
// src/pty-adapter.ts
|
|
935
|
+
var pty_adapter_exports = {};
|
|
936
|
+
__export(pty_adapter_exports, {
|
|
937
|
+
buildPtyEnv: () => buildPtyEnv,
|
|
938
|
+
createPtyAdapter: () => createPtyAdapter
|
|
939
|
+
});
|
|
940
|
+
function buildPtyEnv(overlay) {
|
|
941
|
+
return overlay ? { ...process.env, ...overlay } : { ...process.env };
|
|
942
|
+
}
|
|
943
|
+
function createPtyAdapter(input) {
|
|
944
|
+
const nodePty = (init_dist(), __toCommonJS(dist_exports));
|
|
945
|
+
const shell = _nullishCoalesce(input.shell, () => ( (process.platform === "win32" ? "powershell.exe" : "/bin/bash")));
|
|
946
|
+
const pty2 = nodePty.spawn(shell, _nullishCoalesce(input.args, () => ( [])), {
|
|
947
|
+
name: "xterm-256color",
|
|
948
|
+
cols: _nullishCoalesce(input.cols, () => ( 120)),
|
|
949
|
+
rows: _nullishCoalesce(input.rows, () => ( 30)),
|
|
950
|
+
cwd: input.cwd,
|
|
951
|
+
env: buildPtyEnv(input.env)
|
|
952
|
+
});
|
|
953
|
+
const stdoutListeners = [];
|
|
954
|
+
const stderrListeners = [];
|
|
955
|
+
const dataDisposable = pty2.onData((data) => {
|
|
956
|
+
for (const cb of stdoutListeners) cb(data);
|
|
957
|
+
});
|
|
958
|
+
let exitResolve = null;
|
|
959
|
+
const exitPromise = new Promise((resolve2) => {
|
|
960
|
+
exitResolve = resolve2;
|
|
961
|
+
});
|
|
962
|
+
const exitDisposable = pty2.onExit(({ exitCode, signal }) => {
|
|
963
|
+
_optionalChain([exitResolve, 'optionalCall', _4 => _4({ code: exitCode, signal: signal != null ? String(signal) : null })]);
|
|
964
|
+
});
|
|
965
|
+
let disposed = false;
|
|
966
|
+
return {
|
|
967
|
+
pid: pty2.pid,
|
|
968
|
+
onStdout(cb) {
|
|
969
|
+
stdoutListeners.push(cb);
|
|
970
|
+
},
|
|
971
|
+
onStderr(cb) {
|
|
972
|
+
stderrListeners.push(cb);
|
|
973
|
+
},
|
|
974
|
+
stdin: {
|
|
975
|
+
write(data) {
|
|
976
|
+
if (!disposed) pty2.write(data);
|
|
977
|
+
},
|
|
978
|
+
end() {
|
|
979
|
+
if (!disposed) pty2.write("");
|
|
980
|
+
},
|
|
981
|
+
destroy() {
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
write(data) {
|
|
985
|
+
if (!disposed) pty2.write(data);
|
|
986
|
+
},
|
|
987
|
+
resize(cols, rows) {
|
|
988
|
+
if (!disposed) pty2.resize(cols, rows);
|
|
989
|
+
},
|
|
990
|
+
wait() {
|
|
991
|
+
return exitPromise;
|
|
992
|
+
},
|
|
993
|
+
kill(signal) {
|
|
994
|
+
if (disposed) return;
|
|
995
|
+
try {
|
|
996
|
+
pty2.kill(signal);
|
|
997
|
+
} catch (e2) {
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
dispose() {
|
|
1001
|
+
if (disposed) return;
|
|
1002
|
+
disposed = true;
|
|
1003
|
+
dataDisposable.dispose();
|
|
1004
|
+
exitDisposable.dispose();
|
|
1005
|
+
try {
|
|
1006
|
+
pty2.kill();
|
|
1007
|
+
} catch (e3) {
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
var init_pty_adapter = __esm({
|
|
1013
|
+
"src/pty-adapter.ts"() {
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
exports.__toCommonJS = __toCommonJS; exports.buildPtyEnv = buildPtyEnv; exports.createPtyAdapter = createPtyAdapter; exports.pty_adapter_exports = pty_adapter_exports; exports.init_pty_adapter = init_pty_adapter;
|