@embedder/embedder 2.0.29 → 2.0.31

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.
@@ -1,1234 +0,0 @@
1
- #!/usr/bin/env node
2
- import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CSHRO93D.js";
3
- import require$$0$1 from "events";
4
- import fs__default from "fs";
5
- import path__default from "path";
6
- import require$$3$1 from "net";
7
- import require$$3 from "child_process";
8
- import require$$0$2 from "worker_threads";
9
- import require$$1 from "tty";
10
- function _mergeNamespaces(n, m) {
11
- for (var i = 0; i < m.length; i++) {
12
- const e = m[i];
13
- if (typeof e !== "string" && !Array.isArray(e)) {
14
- for (const k in e) {
15
- if (k !== "default" && !(k in n)) {
16
- const d = Object.getOwnPropertyDescriptor(e, k);
17
- if (d) {
18
- Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: () => e[k] });
19
- }
20
- }
21
- }
22
- }
23
- }
24
- return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
25
- }
26
- var nodePty = {};
27
- var windowsTerminal = {};
28
- var terminal = {};
29
- var eventEmitter2 = {};
30
- var hasRequiredEventEmitter2;
31
- function requireEventEmitter2() {
32
- if (hasRequiredEventEmitter2) return eventEmitter2;
33
- hasRequiredEventEmitter2 = 1;
34
- Object.defineProperty(eventEmitter2, "__esModule", { value: true });
35
- var EventEmitter2 = (
36
- /** @class */
37
- (function() {
38
- function EventEmitter22() {
39
- this._listeners = [];
40
- }
41
- Object.defineProperty(EventEmitter22.prototype, "event", {
42
- get: function() {
43
- var _this = this;
44
- if (!this._event) {
45
- this._event = function(listener) {
46
- _this._listeners.push(listener);
47
- var disposable = {
48
- dispose: function() {
49
- for (var i = 0; i < _this._listeners.length; i++) {
50
- if (_this._listeners[i] === listener) {
51
- _this._listeners.splice(i, 1);
52
- return;
53
- }
54
- }
55
- }
56
- };
57
- return disposable;
58
- };
59
- }
60
- return this._event;
61
- },
62
- enumerable: true,
63
- configurable: true
64
- });
65
- EventEmitter22.prototype.fire = function(data) {
66
- var queue = [];
67
- for (var i = 0; i < this._listeners.length; i++) {
68
- queue.push(this._listeners[i]);
69
- }
70
- for (var i = 0; i < queue.length; i++) {
71
- queue[i].call(void 0, data);
72
- }
73
- };
74
- return EventEmitter22;
75
- })()
76
- );
77
- eventEmitter2.EventEmitter2 = EventEmitter2;
78
- return eventEmitter2;
79
- }
80
- var hasRequiredTerminal;
81
- function requireTerminal() {
82
- if (hasRequiredTerminal) return terminal;
83
- hasRequiredTerminal = 1;
84
- Object.defineProperty(terminal, "__esModule", { value: true });
85
- var events_1 = require$$0$1;
86
- var eventEmitter2_1 = requireEventEmitter2();
87
- terminal.DEFAULT_COLS = 80;
88
- terminal.DEFAULT_ROWS = 24;
89
- var FLOW_CONTROL_PAUSE = "";
90
- var FLOW_CONTROL_RESUME = "";
91
- var Terminal = (
92
- /** @class */
93
- (function() {
94
- function Terminal2(opt) {
95
- this._pid = 0;
96
- this._fd = 0;
97
- this._cols = 0;
98
- this._rows = 0;
99
- this._readable = false;
100
- this._writable = false;
101
- this._onData = new eventEmitter2_1.EventEmitter2();
102
- this._onExit = new eventEmitter2_1.EventEmitter2();
103
- this._internalee = new events_1.EventEmitter();
104
- this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
105
- this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
106
- this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
107
- if (!opt) {
108
- return;
109
- }
110
- this._checkType("name", opt.name ? opt.name : void 0, "string");
111
- this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
112
- this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
113
- this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
114
- this._checkType("env", opt.env ? opt.env : void 0, "object");
115
- this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
116
- this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
117
- this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
118
- }
119
- Object.defineProperty(Terminal2.prototype, "onData", {
120
- get: function() {
121
- return this._onData.event;
122
- },
123
- enumerable: true,
124
- configurable: true
125
- });
126
- Object.defineProperty(Terminal2.prototype, "onExit", {
127
- get: function() {
128
- return this._onExit.event;
129
- },
130
- enumerable: true,
131
- configurable: true
132
- });
133
- Object.defineProperty(Terminal2.prototype, "pid", {
134
- get: function() {
135
- return this._pid;
136
- },
137
- enumerable: true,
138
- configurable: true
139
- });
140
- Object.defineProperty(Terminal2.prototype, "cols", {
141
- get: function() {
142
- return this._cols;
143
- },
144
- enumerable: true,
145
- configurable: true
146
- });
147
- Object.defineProperty(Terminal2.prototype, "rows", {
148
- get: function() {
149
- return this._rows;
150
- },
151
- enumerable: true,
152
- configurable: true
153
- });
154
- Terminal2.prototype.write = function(data) {
155
- if (this.handleFlowControl) {
156
- if (data === this._flowControlPause) {
157
- this.pause();
158
- return;
159
- }
160
- if (data === this._flowControlResume) {
161
- this.resume();
162
- return;
163
- }
164
- }
165
- this._write(data);
166
- };
167
- Terminal2.prototype._forwardEvents = function() {
168
- var _this = this;
169
- this.on("data", function(e) {
170
- return _this._onData.fire(e);
171
- });
172
- this.on("exit", function(exitCode, signal) {
173
- return _this._onExit.fire({ exitCode, signal });
174
- });
175
- };
176
- Terminal2.prototype._checkType = function(name2, value, type, allowArray) {
177
- if (allowArray === void 0) {
178
- allowArray = false;
179
- }
180
- if (value === void 0) {
181
- return;
182
- }
183
- if (allowArray) {
184
- if (Array.isArray(value)) {
185
- value.forEach(function(v, i) {
186
- if (typeof v !== type) {
187
- throw new Error(name2 + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
188
- }
189
- });
190
- return;
191
- }
192
- }
193
- if (typeof value !== type) {
194
- throw new Error(name2 + " must be a " + type + " (not a " + typeof value + ")");
195
- }
196
- };
197
- Terminal2.prototype.end = function(data) {
198
- this._socket.end(data);
199
- };
200
- Terminal2.prototype.pipe = function(dest, options) {
201
- return this._socket.pipe(dest, options);
202
- };
203
- Terminal2.prototype.pause = function() {
204
- return this._socket.pause();
205
- };
206
- Terminal2.prototype.resume = function() {
207
- return this._socket.resume();
208
- };
209
- Terminal2.prototype.setEncoding = function(encoding) {
210
- if (this._socket._decoder) {
211
- delete this._socket._decoder;
212
- }
213
- if (encoding) {
214
- this._socket.setEncoding(encoding);
215
- }
216
- };
217
- Terminal2.prototype.addListener = function(eventName, listener) {
218
- this.on(eventName, listener);
219
- };
220
- Terminal2.prototype.on = function(eventName, listener) {
221
- if (eventName === "close") {
222
- this._internalee.on("close", listener);
223
- return;
224
- }
225
- this._socket.on(eventName, listener);
226
- };
227
- Terminal2.prototype.emit = function(eventName) {
228
- if (eventName === "close") {
229
- return this._internalee.emit.apply(this._internalee, arguments);
230
- }
231
- return this._socket.emit.apply(this._socket, arguments);
232
- };
233
- Terminal2.prototype.listeners = function(eventName) {
234
- return this._socket.listeners(eventName);
235
- };
236
- Terminal2.prototype.removeListener = function(eventName, listener) {
237
- this._socket.removeListener(eventName, listener);
238
- };
239
- Terminal2.prototype.removeAllListeners = function(eventName) {
240
- this._socket.removeAllListeners(eventName);
241
- };
242
- Terminal2.prototype.once = function(eventName, listener) {
243
- this._socket.once(eventName, listener);
244
- };
245
- Terminal2.prototype._close = function() {
246
- this._socket.readable = false;
247
- this.write = function() {
248
- };
249
- this.end = function() {
250
- };
251
- this._writable = false;
252
- this._readable = false;
253
- };
254
- Terminal2.prototype._parseEnv = function(env) {
255
- var keys = Object.keys(env || {});
256
- var pairs = [];
257
- for (var i = 0; i < keys.length; i++) {
258
- if (keys[i] === void 0) {
259
- continue;
260
- }
261
- pairs.push(keys[i] + "=" + env[keys[i]]);
262
- }
263
- return pairs;
264
- };
265
- return Terminal2;
266
- })()
267
- );
268
- terminal.Terminal = Terminal;
269
- return terminal;
270
- }
271
- var windowsPtyAgent = {};
272
- var windowsConoutConnection = {};
273
- var conout = {};
274
- var hasRequiredConout;
275
- function requireConout() {
276
- if (hasRequiredConout) return conout;
277
- hasRequiredConout = 1;
278
- Object.defineProperty(conout, "__esModule", { value: true });
279
- function getWorkerPipeName(conoutPipeName) {
280
- return conoutPipeName + "-worker";
281
- }
282
- conout.getWorkerPipeName = getWorkerPipeName;
283
- return conout;
284
- }
285
- var hasRequiredWindowsConoutConnection;
286
- function requireWindowsConoutConnection() {
287
- if (hasRequiredWindowsConoutConnection) return windowsConoutConnection;
288
- hasRequiredWindowsConoutConnection = 1;
289
- var __awaiter = windowsConoutConnection && windowsConoutConnection.__awaiter || function(thisArg, _arguments, P, generator) {
290
- function adopt(value) {
291
- return value instanceof P ? value : new P(function(resolve) {
292
- resolve(value);
293
- });
294
- }
295
- return new (P || (P = Promise))(function(resolve, reject) {
296
- function fulfilled(value) {
297
- try {
298
- step(generator.next(value));
299
- } catch (e) {
300
- reject(e);
301
- }
302
- }
303
- function rejected(value) {
304
- try {
305
- step(generator["throw"](value));
306
- } catch (e) {
307
- reject(e);
308
- }
309
- }
310
- function step(result) {
311
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
312
- }
313
- step((generator = generator.apply(thisArg, _arguments || [])).next());
314
- });
315
- };
316
- var __generator = windowsConoutConnection && windowsConoutConnection.__generator || function(thisArg, body) {
317
- var _ = { label: 0, sent: function() {
318
- if (t[0] & 1) throw t[1];
319
- return t[1];
320
- }, trys: [], ops: [] }, f, y, t, g;
321
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
322
- return this;
323
- }), g;
324
- function verb(n) {
325
- return function(v) {
326
- return step([n, v]);
327
- };
328
- }
329
- function step(op) {
330
- if (f) throw new TypeError("Generator is already executing.");
331
- while (_) try {
332
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
333
- if (y = 0, t) op = [op[0] & 2, t.value];
334
- switch (op[0]) {
335
- case 0:
336
- case 1:
337
- t = op;
338
- break;
339
- case 4:
340
- _.label++;
341
- return { value: op[1], done: false };
342
- case 5:
343
- _.label++;
344
- y = op[1];
345
- op = [0];
346
- continue;
347
- case 7:
348
- op = _.ops.pop();
349
- _.trys.pop();
350
- continue;
351
- default:
352
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
353
- _ = 0;
354
- continue;
355
- }
356
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
357
- _.label = op[1];
358
- break;
359
- }
360
- if (op[0] === 6 && _.label < t[1]) {
361
- _.label = t[1];
362
- t = op;
363
- break;
364
- }
365
- if (t && _.label < t[2]) {
366
- _.label = t[2];
367
- _.ops.push(op);
368
- break;
369
- }
370
- if (t[2]) _.ops.pop();
371
- _.trys.pop();
372
- continue;
373
- }
374
- op = body.call(thisArg, _);
375
- } catch (e) {
376
- op = [6, e];
377
- y = 0;
378
- } finally {
379
- f = t = 0;
380
- }
381
- if (op[0] & 5) throw op[1];
382
- return { value: op[0] ? op[1] : void 0, done: true };
383
- }
384
- };
385
- Object.defineProperty(windowsConoutConnection, "__esModule", { value: true });
386
- var worker_threads_1 = require$$0$2;
387
- var conout_1 = requireConout();
388
- var path_1 = path__default;
389
- var eventEmitter2_1 = requireEventEmitter2();
390
- var FLUSH_DATA_INTERVAL = 1e3;
391
- var ConoutConnection = (
392
- /** @class */
393
- (function() {
394
- function ConoutConnection2(_conoutPipeName) {
395
- var _this = this;
396
- this._conoutPipeName = _conoutPipeName;
397
- this._isDisposed = false;
398
- this._onReady = new eventEmitter2_1.EventEmitter2();
399
- var workerData = { conoutPipeName: _conoutPipeName };
400
- var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
401
- this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
402
- this._worker.on("message", function(message) {
403
- switch (message) {
404
- case 1:
405
- _this._onReady.fire();
406
- return;
407
- default:
408
- console.warn("Unexpected ConoutWorkerMessage", message);
409
- }
410
- });
411
- }
412
- Object.defineProperty(ConoutConnection2.prototype, "onReady", {
413
- get: function() {
414
- return this._onReady.event;
415
- },
416
- enumerable: true,
417
- configurable: true
418
- });
419
- ConoutConnection2.prototype.dispose = function() {
420
- if (this._isDisposed) {
421
- return;
422
- }
423
- this._isDisposed = true;
424
- this._drainDataAndClose();
425
- };
426
- ConoutConnection2.prototype.connectSocket = function(socket) {
427
- socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
428
- };
429
- ConoutConnection2.prototype._drainDataAndClose = function() {
430
- var _this = this;
431
- if (this._drainTimeout) {
432
- clearTimeout(this._drainTimeout);
433
- }
434
- this._drainTimeout = setTimeout(function() {
435
- return _this._destroySocket();
436
- }, FLUSH_DATA_INTERVAL);
437
- };
438
- ConoutConnection2.prototype._destroySocket = function() {
439
- return __awaiter(this, void 0, void 0, function() {
440
- return __generator(this, function(_a) {
441
- switch (_a.label) {
442
- case 0:
443
- return [4, this._worker.terminate()];
444
- case 1:
445
- _a.sent();
446
- return [
447
- 2
448
- /*return*/
449
- ];
450
- }
451
- });
452
- });
453
- };
454
- return ConoutConnection2;
455
- })()
456
- );
457
- windowsConoutConnection.ConoutConnection = ConoutConnection;
458
- return windowsConoutConnection;
459
- }
460
- function commonjsRequire(path) {
461
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
462
- }
463
- var requireBinary = {};
464
- const name = "@lydell/node-pty";
465
- const description = "node-pty with prebuilt binaries";
466
- const author = "Simon Lydell";
467
- const version = "1.1.0";
468
- const license = "MIT";
469
- const main = "./index.js";
470
- const types = "./node-pty.d.ts";
471
- const repository = { "type": "git", "url": "git://github.com/lydell/node-pty.git" };
472
- const keywords = ["pty", "tty", "terminal", "pseudoterminal", "forkpty", "openpty", "prebuild", "prebuilt"];
473
- const optionalDependencies = { "@lydell/node-pty-darwin-x64": "1.1.0", "@lydell/node-pty-darwin-arm64": "1.1.0", "@lydell/node-pty-linux-x64": "1.1.0", "@lydell/node-pty-linux-arm64": "1.1.0", "@lydell/node-pty-win32-x64": "1.1.0", "@lydell/node-pty-win32-arm64": "1.1.0" };
474
- const require$$0 = {
475
- name,
476
- description,
477
- author,
478
- version,
479
- license,
480
- main,
481
- types,
482
- repository,
483
- keywords,
484
- optionalDependencies
485
- };
486
- var hasRequiredRequireBinary;
487
- function requireRequireBinary() {
488
- if (hasRequiredRequireBinary) return requireBinary;
489
- hasRequiredRequireBinary = 1;
490
- Object.defineProperty(requireBinary, "__esModule", { value: true });
491
- var PACKAGE_NAME = "@lydell/node-pty-" + process.platform + "-" + process.arch;
492
- var help = '\nThis can happen if you use the "--omit=optional" (or "--no-optional") npm flag.\nThe "optionalDependencies" package.json feature is used to install the correct\nbinary executable for your current platform. Remove that flag to use @lydell/node-pty.\n\nThis can also happen if the "node_modules" folder was copied between two operating systems\nthat need different binaries - including "virtual" operating systems like Docker and WSL.\nIf so, try installing with npm rather than copying "node_modules".\n'.trim();
493
- function requireBinary$1(file) {
494
- try {
495
- return commonjsRequire(PACKAGE_NAME + "/" + file);
496
- } catch (error) {
497
- if (error && error.code === "MODULE_NOT_FOUND") {
498
- var optionalDependencies2 = getOptionalDependencies();
499
- throw new Error(
500
- optionalDependencies2 === void 0 ? "The @lydell/node-pty package could not find the binary package: " + PACKAGE_NAME + "/" + file + "\n\n" + help + "\n\nYour platform (" + process.platform + "-" + process.arch + ") might not be supported." : PACKAGE_NAME in optionalDependencies2 ? "The @lydell/node-pty package supports your platform (" + process.platform + "-" + process.arch + "), but it could not find the binary package for it: " + PACKAGE_NAME + "/" + file + "\n\n" + help : "The @lydell/node-pty package currently does not support your platform: " + process.platform + "-" + process.arch,
501
- // @ts-ignore: The TypeScript setup does not seem to support cause.
502
- { cause: error }
503
- );
504
- } else {
505
- throw error;
506
- }
507
- }
508
- }
509
- requireBinary.requireBinary = requireBinary$1;
510
- function getOptionalDependencies() {
511
- try {
512
- return require$$0.optionalDependencies;
513
- } catch (_error) {
514
- return void 0;
515
- }
516
- }
517
- return requireBinary;
518
- }
519
- var hasRequiredWindowsPtyAgent;
520
- function requireWindowsPtyAgent() {
521
- if (hasRequiredWindowsPtyAgent) return windowsPtyAgent;
522
- hasRequiredWindowsPtyAgent = 1;
523
- Object.defineProperty(windowsPtyAgent, "__esModule", { value: true });
524
- var fs = fs__default;
525
- var path = path__default;
526
- var net_1 = require$$3$1;
527
- var child_process_1 = require$$3;
528
- var windowsConoutConnection_1 = requireWindowsConoutConnection();
529
- var requireBinary_1 = requireRequireBinary();
530
- var conptyNative;
531
- var FLUSH_DATA_INTERVAL = 1e3;
532
- var WindowsPtyAgent = (
533
- /** @class */
534
- (function() {
535
- function WindowsPtyAgent2(file, args, env, cwd, cols, rows, debug, conptyInheritCursor) {
536
- var _this = this;
537
- if (conptyInheritCursor === void 0) {
538
- conptyInheritCursor = false;
539
- }
540
- this._pid = 0;
541
- this._innerPid = 0;
542
- if (!conptyNative) {
543
- conptyNative = requireBinary_1.requireBinary("conpty.node");
544
- }
545
- this._ptyNative = conptyNative;
546
- cwd = path.resolve(cwd);
547
- var commandLine = argsToCommandLine(file, args);
548
- var term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor);
549
- this._fd = term.fd;
550
- this._pty = term.pty;
551
- this._outSocket = new net_1.Socket();
552
- this._outSocket.setEncoding("utf8");
553
- this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout);
554
- this._conoutSocketWorker.onReady(function() {
555
- _this._conoutSocketWorker.connectSocket(_this._outSocket);
556
- });
557
- this._outSocket.on("connect", function() {
558
- _this._outSocket.emit("ready_datapipe");
559
- });
560
- var inSocketFD = fs.openSync(term.conin, "w");
561
- this._inSocket = new net_1.Socket({
562
- fd: inSocketFD,
563
- readable: false,
564
- writable: true
565
- });
566
- this._inSocket.setEncoding("utf8");
567
- var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, function(c) {
568
- return _this._$onProcessExit(c);
569
- });
570
- this._innerPid = connect.pid;
571
- }
572
- Object.defineProperty(WindowsPtyAgent2.prototype, "inSocket", {
573
- get: function() {
574
- return this._inSocket;
575
- },
576
- enumerable: true,
577
- configurable: true
578
- });
579
- Object.defineProperty(WindowsPtyAgent2.prototype, "outSocket", {
580
- get: function() {
581
- return this._outSocket;
582
- },
583
- enumerable: true,
584
- configurable: true
585
- });
586
- Object.defineProperty(WindowsPtyAgent2.prototype, "fd", {
587
- get: function() {
588
- return this._fd;
589
- },
590
- enumerable: true,
591
- configurable: true
592
- });
593
- Object.defineProperty(WindowsPtyAgent2.prototype, "innerPid", {
594
- get: function() {
595
- return this._innerPid;
596
- },
597
- enumerable: true,
598
- configurable: true
599
- });
600
- Object.defineProperty(WindowsPtyAgent2.prototype, "pty", {
601
- get: function() {
602
- return this._pty;
603
- },
604
- enumerable: true,
605
- configurable: true
606
- });
607
- WindowsPtyAgent2.prototype.resize = function(cols, rows) {
608
- if (this._exitCode !== void 0) {
609
- throw new Error("Cannot resize a pty that has already exited");
610
- }
611
- this._ptyNative.resize(this._pty, cols, rows);
612
- };
613
- WindowsPtyAgent2.prototype.clear = function() {
614
- this._ptyNative.clear(this._pty);
615
- };
616
- WindowsPtyAgent2.prototype.kill = function() {
617
- var _this = this;
618
- this._inSocket.readable = false;
619
- this._outSocket.readable = false;
620
- this._getConsoleProcessList().then(function(consoleProcessList) {
621
- consoleProcessList.forEach(function(pid) {
622
- try {
623
- process.kill(pid);
624
- } catch (e) {
625
- }
626
- });
627
- _this._ptyNative.kill(_this._pty);
628
- });
629
- this._conoutSocketWorker.dispose();
630
- };
631
- WindowsPtyAgent2.prototype._getConsoleProcessList = function() {
632
- var _this = this;
633
- return new Promise(function(resolve) {
634
- var agent = child_process_1.fork(path.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
635
- agent.on("message", function(message) {
636
- clearTimeout(timeout);
637
- resolve(message.consoleProcessList);
638
- });
639
- var timeout = setTimeout(function() {
640
- agent.kill();
641
- resolve([_this._innerPid]);
642
- }, 5e3);
643
- });
644
- };
645
- Object.defineProperty(WindowsPtyAgent2.prototype, "exitCode", {
646
- get: function() {
647
- return this._exitCode;
648
- },
649
- enumerable: true,
650
- configurable: true
651
- });
652
- WindowsPtyAgent2.prototype._generatePipeName = function() {
653
- return "conpty-" + Math.random() * 1e7;
654
- };
655
- WindowsPtyAgent2.prototype._$onProcessExit = function(exitCode) {
656
- var _this = this;
657
- this._exitCode = exitCode;
658
- this._flushDataAndCleanUp();
659
- this._outSocket.on("data", function() {
660
- return _this._flushDataAndCleanUp();
661
- });
662
- };
663
- WindowsPtyAgent2.prototype._flushDataAndCleanUp = function() {
664
- var _this = this;
665
- if (this._closeTimeout) {
666
- clearTimeout(this._closeTimeout);
667
- }
668
- this._closeTimeout = setTimeout(function() {
669
- return _this._cleanUpProcess();
670
- }, FLUSH_DATA_INTERVAL);
671
- };
672
- WindowsPtyAgent2.prototype._cleanUpProcess = function() {
673
- this._inSocket.readable = false;
674
- this._outSocket.readable = false;
675
- this._outSocket.destroy();
676
- };
677
- return WindowsPtyAgent2;
678
- })()
679
- );
680
- windowsPtyAgent.WindowsPtyAgent = WindowsPtyAgent;
681
- function argsToCommandLine(file, args) {
682
- if (isCommandLine(args)) {
683
- if (args.length === 0) {
684
- return file;
685
- }
686
- return argsToCommandLine(file, []) + " " + args;
687
- }
688
- var argv = [file];
689
- Array.prototype.push.apply(argv, args);
690
- var result = "";
691
- for (var argIndex = 0; argIndex < argv.length; argIndex++) {
692
- if (argIndex > 0) {
693
- result += " ";
694
- }
695
- var arg = argv[argIndex];
696
- var hasLopsidedEnclosingQuote = xOr(arg[0] !== '"', arg[arg.length - 1] !== '"');
697
- var hasNoEnclosingQuotes = arg[0] !== '"' && arg[arg.length - 1] !== '"';
698
- var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && (arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
699
- if (quote) {
700
- result += '"';
701
- }
702
- var bsCount = 0;
703
- for (var i = 0; i < arg.length; i++) {
704
- var p = arg[i];
705
- if (p === "\\") {
706
- bsCount++;
707
- } else if (p === '"') {
708
- result += repeatText("\\", bsCount * 2 + 1);
709
- result += '"';
710
- bsCount = 0;
711
- } else {
712
- result += repeatText("\\", bsCount);
713
- bsCount = 0;
714
- result += p;
715
- }
716
- }
717
- if (quote) {
718
- result += repeatText("\\", bsCount * 2);
719
- result += '"';
720
- } else {
721
- result += repeatText("\\", bsCount);
722
- }
723
- }
724
- return result;
725
- }
726
- windowsPtyAgent.argsToCommandLine = argsToCommandLine;
727
- function isCommandLine(args) {
728
- return typeof args === "string";
729
- }
730
- function repeatText(text, count) {
731
- var result = "";
732
- for (var i = 0; i < count; i++) {
733
- result += text;
734
- }
735
- return result;
736
- }
737
- function xOr(arg1, arg2) {
738
- return arg1 && !arg2 || !arg1 && arg2;
739
- }
740
- return windowsPtyAgent;
741
- }
742
- var utils = {};
743
- var hasRequiredUtils;
744
- function requireUtils() {
745
- if (hasRequiredUtils) return utils;
746
- hasRequiredUtils = 1;
747
- Object.defineProperty(utils, "__esModule", { value: true });
748
- function assign(target) {
749
- var sources = [];
750
- for (var _i = 1; _i < arguments.length; _i++) {
751
- sources[_i - 1] = arguments[_i];
752
- }
753
- sources.forEach(function(source) {
754
- return Object.keys(source).forEach(function(key) {
755
- return target[key] = source[key];
756
- });
757
- });
758
- return target;
759
- }
760
- utils.assign = assign;
761
- return utils;
762
- }
763
- var hasRequiredWindowsTerminal;
764
- function requireWindowsTerminal() {
765
- if (hasRequiredWindowsTerminal) return windowsTerminal;
766
- hasRequiredWindowsTerminal = 1;
767
- var __extends = windowsTerminal && windowsTerminal.__extends || /* @__PURE__ */ (function() {
768
- var extendStatics = function(d, b) {
769
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
770
- d2.__proto__ = b2;
771
- } || function(d2, b2) {
772
- for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
773
- };
774
- return extendStatics(d, b);
775
- };
776
- return function(d, b) {
777
- extendStatics(d, b);
778
- function __() {
779
- this.constructor = d;
780
- }
781
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
782
- };
783
- })();
784
- Object.defineProperty(windowsTerminal, "__esModule", { value: true });
785
- var terminal_1 = requireTerminal();
786
- var windowsPtyAgent_1 = requireWindowsPtyAgent();
787
- var utils_1 = requireUtils();
788
- var DEFAULT_FILE = "cmd.exe";
789
- var DEFAULT_NAME = "Windows Shell";
790
- var WindowsTerminal = (
791
- /** @class */
792
- (function(_super) {
793
- __extends(WindowsTerminal2, _super);
794
- function WindowsTerminal2(file, args, opt) {
795
- var _this = _super.call(this, opt) || this;
796
- _this._checkType("args", args, "string", true);
797
- args = args || [];
798
- file = file || DEFAULT_FILE;
799
- opt = opt || {};
800
- opt.env = opt.env || process.env;
801
- if (opt.encoding) {
802
- console.warn("Setting encoding on Windows is not supported");
803
- }
804
- var env = utils_1.assign({}, opt.env);
805
- _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
806
- _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
807
- var cwd = opt.cwd || process.cwd();
808
- var name2 = opt.name || env.TERM || DEFAULT_NAME;
809
- var parsedEnv = _this._parseEnv(env);
810
- _this._isReady = false;
811
- _this._deferreds = [];
812
- _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.conptyInheritCursor);
813
- _this._socket = _this._agent.outSocket;
814
- _this._pid = _this._agent.innerPid;
815
- _this._fd = _this._agent.fd;
816
- _this._pty = _this._agent.pty;
817
- _this._socket.on("ready_datapipe", function() {
818
- ["connect", "data", "end", "timeout", "drain"].forEach(function(event) {
819
- _this._socket.on(event, function() {
820
- if (!_this._isReady && event === "data") {
821
- _this._isReady = true;
822
- _this._deferreds.forEach(function(fn) {
823
- fn.run();
824
- });
825
- _this._deferreds = [];
826
- }
827
- });
828
- });
829
- _this._socket.on("error", function(err) {
830
- _this._close();
831
- if (err.code) {
832
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO"))
833
- return;
834
- }
835
- if (_this.listeners("error").length < 2) {
836
- throw err;
837
- }
838
- });
839
- _this._socket.on("close", function() {
840
- _this.emit("exit", _this._agent.exitCode);
841
- _this._close();
842
- });
843
- });
844
- _this._file = file;
845
- _this._name = name2;
846
- _this._readable = true;
847
- _this._writable = true;
848
- _this._forwardEvents();
849
- return _this;
850
- }
851
- WindowsTerminal2.prototype._write = function(data) {
852
- this._defer(this._doWrite, data);
853
- };
854
- WindowsTerminal2.prototype._doWrite = function(data) {
855
- this._agent.inSocket.write(data);
856
- };
857
- WindowsTerminal2.open = function(options) {
858
- throw new Error("open() not supported on windows, use Fork() instead.");
859
- };
860
- WindowsTerminal2.prototype.resize = function(cols, rows) {
861
- var _this = this;
862
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
863
- throw new Error("resizing must be done using positive cols and rows");
864
- }
865
- this._deferNoArgs(function() {
866
- _this._agent.resize(cols, rows);
867
- _this._cols = cols;
868
- _this._rows = rows;
869
- });
870
- };
871
- WindowsTerminal2.prototype.clear = function() {
872
- var _this = this;
873
- this._deferNoArgs(function() {
874
- _this._agent.clear();
875
- });
876
- };
877
- WindowsTerminal2.prototype.destroy = function() {
878
- var _this = this;
879
- this._deferNoArgs(function() {
880
- _this.kill();
881
- });
882
- };
883
- WindowsTerminal2.prototype.kill = function(signal) {
884
- var _this = this;
885
- this._deferNoArgs(function() {
886
- if (signal) {
887
- throw new Error("Signals not supported on windows.");
888
- }
889
- _this._close();
890
- _this._agent.kill();
891
- });
892
- };
893
- WindowsTerminal2.prototype._deferNoArgs = function(deferredFn) {
894
- var _this = this;
895
- if (this._isReady) {
896
- deferredFn.call(this);
897
- return;
898
- }
899
- this._deferreds.push({
900
- run: function() {
901
- return deferredFn.call(_this);
902
- }
903
- });
904
- };
905
- WindowsTerminal2.prototype._defer = function(deferredFn, arg) {
906
- var _this = this;
907
- if (this._isReady) {
908
- deferredFn.call(this, arg);
909
- return;
910
- }
911
- this._deferreds.push({
912
- run: function() {
913
- return deferredFn.call(_this, arg);
914
- }
915
- });
916
- };
917
- Object.defineProperty(WindowsTerminal2.prototype, "process", {
918
- get: function() {
919
- return this._name;
920
- },
921
- enumerable: true,
922
- configurable: true
923
- });
924
- Object.defineProperty(WindowsTerminal2.prototype, "master", {
925
- get: function() {
926
- throw new Error("master is not supported on Windows");
927
- },
928
- enumerable: true,
929
- configurable: true
930
- });
931
- Object.defineProperty(WindowsTerminal2.prototype, "slave", {
932
- get: function() {
933
- throw new Error("slave is not supported on Windows");
934
- },
935
- enumerable: true,
936
- configurable: true
937
- });
938
- return WindowsTerminal2;
939
- })(terminal_1.Terminal)
940
- );
941
- windowsTerminal.WindowsTerminal = WindowsTerminal;
942
- return windowsTerminal;
943
- }
944
- var unixTerminal = {};
945
- var hasRequiredUnixTerminal;
946
- function requireUnixTerminal() {
947
- if (hasRequiredUnixTerminal) return unixTerminal;
948
- hasRequiredUnixTerminal = 1;
949
- var __extends = unixTerminal && unixTerminal.__extends || /* @__PURE__ */ (function() {
950
- var extendStatics = function(d, b) {
951
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
952
- d2.__proto__ = b2;
953
- } || function(d2, b2) {
954
- for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
955
- };
956
- return extendStatics(d, b);
957
- };
958
- return function(d, b) {
959
- extendStatics(d, b);
960
- function __() {
961
- this.constructor = d;
962
- }
963
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
964
- };
965
- })();
966
- Object.defineProperty(unixTerminal, "__esModule", { value: true });
967
- var tty = require$$1;
968
- var terminal_1 = requireTerminal();
969
- var utils_1 = requireUtils();
970
- var requireBinary_1 = requireRequireBinary();
971
- var pty = requireBinary_1.requireBinary("pty.node");
972
- var helperPath = "@lydell/node-pty-" + process.platform + "-" + process.arch + "/spawn-helper";
973
- helperPath = process.platform === "darwin" ? require.resolve(helperPath) : "spawn-helper-unused";
974
- helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
975
- helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
976
- var DEFAULT_FILE = "sh";
977
- var DEFAULT_NAME = "xterm";
978
- var DESTROY_SOCKET_TIMEOUT_MS = 200;
979
- var UnixTerminal = (
980
- /** @class */
981
- (function(_super) {
982
- __extends(UnixTerminal2, _super);
983
- function UnixTerminal2(file, args, opt) {
984
- var _a, _b;
985
- var _this = _super.call(this, opt) || this;
986
- _this._boundClose = false;
987
- _this._emittedClose = false;
988
- if (typeof args === "string") {
989
- throw new Error("args as a string is not supported on unix.");
990
- }
991
- args = args || [];
992
- file = file || DEFAULT_FILE;
993
- opt = opt || {};
994
- opt.env = opt.env || process.env;
995
- _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
996
- _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
997
- var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
998
- var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
999
- var env = utils_1.assign({}, opt.env);
1000
- if (opt.env === process.env) {
1001
- _this._sanitizeEnv(env);
1002
- }
1003
- var cwd = opt.cwd || process.cwd();
1004
- env.PWD = cwd;
1005
- var name2 = opt.name || env.TERM || DEFAULT_NAME;
1006
- env.TERM = name2;
1007
- var parsedEnv = _this._parseEnv(env);
1008
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1009
- var onexit = function(code, signal) {
1010
- if (!_this._emittedClose) {
1011
- if (_this._boundClose) {
1012
- return;
1013
- }
1014
- _this._boundClose = true;
1015
- var timeout_1 = setTimeout(function() {
1016
- timeout_1 = null;
1017
- _this._socket.destroy();
1018
- }, DESTROY_SOCKET_TIMEOUT_MS);
1019
- _this.once("close", function() {
1020
- if (timeout_1 !== null) {
1021
- clearTimeout(timeout_1);
1022
- }
1023
- _this.emit("exit", code, signal);
1024
- });
1025
- return;
1026
- }
1027
- _this.emit("exit", code, signal);
1028
- };
1029
- var term = pty.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
1030
- _this._socket = new tty.ReadStream(term.fd);
1031
- if (encoding !== null) {
1032
- _this._socket.setEncoding(encoding);
1033
- }
1034
- _this._socket.on("error", function(err) {
1035
- if (err.code) {
1036
- if (~err.code.indexOf("EAGAIN")) {
1037
- return;
1038
- }
1039
- }
1040
- _this._close();
1041
- if (!_this._emittedClose) {
1042
- _this._emittedClose = true;
1043
- _this.emit("close");
1044
- }
1045
- if (err.code) {
1046
- if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) {
1047
- return;
1048
- }
1049
- }
1050
- if (_this.listeners("error").length < 2) {
1051
- throw err;
1052
- }
1053
- });
1054
- _this._pid = term.pid;
1055
- _this._fd = term.fd;
1056
- _this._pty = term.pty;
1057
- _this._file = file;
1058
- _this._name = name2;
1059
- _this._readable = true;
1060
- _this._writable = true;
1061
- _this._socket.on("close", function() {
1062
- if (_this._emittedClose) {
1063
- return;
1064
- }
1065
- _this._emittedClose = true;
1066
- _this._close();
1067
- _this.emit("close");
1068
- });
1069
- _this._forwardEvents();
1070
- return _this;
1071
- }
1072
- Object.defineProperty(UnixTerminal2.prototype, "master", {
1073
- get: function() {
1074
- return this._master;
1075
- },
1076
- enumerable: true,
1077
- configurable: true
1078
- });
1079
- Object.defineProperty(UnixTerminal2.prototype, "slave", {
1080
- get: function() {
1081
- return this._slave;
1082
- },
1083
- enumerable: true,
1084
- configurable: true
1085
- });
1086
- UnixTerminal2.prototype._write = function(data) {
1087
- this._socket.write(data);
1088
- };
1089
- Object.defineProperty(UnixTerminal2.prototype, "fd", {
1090
- /* Accessors */
1091
- get: function() {
1092
- return this._fd;
1093
- },
1094
- enumerable: true,
1095
- configurable: true
1096
- });
1097
- Object.defineProperty(UnixTerminal2.prototype, "ptsName", {
1098
- get: function() {
1099
- return this._pty;
1100
- },
1101
- enumerable: true,
1102
- configurable: true
1103
- });
1104
- UnixTerminal2.open = function(opt) {
1105
- var self = Object.create(UnixTerminal2.prototype);
1106
- opt = opt || {};
1107
- if (arguments.length > 1) {
1108
- opt = {
1109
- cols: arguments[1],
1110
- rows: arguments[2]
1111
- };
1112
- }
1113
- var cols = opt.cols || terminal_1.DEFAULT_COLS;
1114
- var rows = opt.rows || terminal_1.DEFAULT_ROWS;
1115
- var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1116
- var term = pty.open(cols, rows);
1117
- self._master = new tty.ReadStream(term.master);
1118
- if (encoding !== null) {
1119
- self._master.setEncoding(encoding);
1120
- }
1121
- self._master.resume();
1122
- self._slave = new tty.ReadStream(term.slave);
1123
- if (encoding !== null) {
1124
- self._slave.setEncoding(encoding);
1125
- }
1126
- self._slave.resume();
1127
- self._socket = self._master;
1128
- self._pid = -1;
1129
- self._fd = term.master;
1130
- self._pty = term.pty;
1131
- self._file = process.argv[0] || "node";
1132
- self._name = process.env.TERM || "";
1133
- self._readable = true;
1134
- self._writable = true;
1135
- self._socket.on("error", function(err) {
1136
- self._close();
1137
- if (self.listeners("error").length < 2) {
1138
- throw err;
1139
- }
1140
- });
1141
- self._socket.on("close", function() {
1142
- self._close();
1143
- });
1144
- return self;
1145
- };
1146
- UnixTerminal2.prototype.destroy = function() {
1147
- var _this = this;
1148
- this._close();
1149
- this._socket.once("close", function() {
1150
- _this.kill("SIGHUP");
1151
- });
1152
- this._socket.destroy();
1153
- };
1154
- UnixTerminal2.prototype.kill = function(signal) {
1155
- try {
1156
- process.kill(this.pid, signal || "SIGHUP");
1157
- } catch (e) {
1158
- }
1159
- };
1160
- Object.defineProperty(UnixTerminal2.prototype, "process", {
1161
- /**
1162
- * Gets the name of the process.
1163
- */
1164
- get: function() {
1165
- if (process.platform === "darwin") {
1166
- var title = pty.process(this._fd);
1167
- return title !== "kernel_task" ? title : this._file;
1168
- }
1169
- return pty.process(this._fd, this._pty) || this._file;
1170
- },
1171
- enumerable: true,
1172
- configurable: true
1173
- });
1174
- UnixTerminal2.prototype.resize = function(cols, rows) {
1175
- if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
1176
- throw new Error("resizing must be done using positive cols and rows");
1177
- }
1178
- pty.resize(this._fd, cols, rows);
1179
- this._cols = cols;
1180
- this._rows = rows;
1181
- };
1182
- UnixTerminal2.prototype.clear = function() {
1183
- };
1184
- UnixTerminal2.prototype._sanitizeEnv = function(env) {
1185
- delete env["TMUX"];
1186
- delete env["TMUX_PANE"];
1187
- delete env["STY"];
1188
- delete env["WINDOW"];
1189
- delete env["WINDOWID"];
1190
- delete env["TERMCAP"];
1191
- delete env["COLUMNS"];
1192
- delete env["LINES"];
1193
- };
1194
- return UnixTerminal2;
1195
- })(terminal_1.Terminal)
1196
- );
1197
- unixTerminal.UnixTerminal = UnixTerminal;
1198
- return unixTerminal;
1199
- }
1200
- var hasRequiredNodePty;
1201
- function requireNodePty() {
1202
- if (hasRequiredNodePty) return nodePty;
1203
- hasRequiredNodePty = 1;
1204
- Object.defineProperty(nodePty, "__esModule", { value: true });
1205
- var terminalCtor;
1206
- if (process.platform === "win32") {
1207
- terminalCtor = requireWindowsTerminal().WindowsTerminal;
1208
- } else {
1209
- terminalCtor = requireUnixTerminal().UnixTerminal;
1210
- }
1211
- function spawn(file, args, opt) {
1212
- return new terminalCtor(file, args, opt);
1213
- }
1214
- nodePty.spawn = spawn;
1215
- function fork(file, args, opt) {
1216
- return new terminalCtor(file, args, opt);
1217
- }
1218
- nodePty.fork = fork;
1219
- function createTerminal(file, args, opt) {
1220
- return new terminalCtor(file, args, opt);
1221
- }
1222
- nodePty.createTerminal = createTerminal;
1223
- function open(options) {
1224
- return terminalCtor.open(options);
1225
- }
1226
- nodePty.open = open;
1227
- return nodePty;
1228
- }
1229
- var nodePtyExports = requireNodePty();
1230
- const index = /* @__PURE__ */ getDefaultExportFromCjs(nodePtyExports);
1231
- const index$1 = /* @__PURE__ */ _mergeNamespaces({ __proto__: null, default: index }, [nodePtyExports]);
1232
- export {
1233
- index$1 as i
1234
- };