@lydell/node-pty-win32-x64 1.2.0-beta.6 → 1.2.0-beta.7

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.
@@ -7,14 +7,12 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.argsToCommandLine = exports.WindowsPtyAgent = void 0;
9
9
  var fs = require("fs");
10
- var os = require("os");
11
10
  var path = require("path");
12
11
  var child_process_1 = require("child_process");
13
12
  var net_1 = require("net");
14
13
  var windowsConoutConnection_1 = require("./windowsConoutConnection");
15
14
  var utils_1 = require("./utils");
16
15
  var conptyNative;
17
- var winptyNative;
18
16
  /**
19
17
  * The amount of time to wait for additional data after the conpty shell process has exited before
20
18
  * shutting down the socket. The timer will be reset if a new data event comes in after the timer
@@ -22,46 +20,25 @@ var winptyNative;
22
20
  */
23
21
  var FLUSH_DATA_INTERVAL = 1000;
24
22
  /**
25
- * This agent sits between the WindowsTerminal class and provides a common interface for both conpty
26
- * and winpty.
23
+ * This agent sits between the WindowsTerminal class and provides an interface for conpty.
27
24
  */
28
25
  var WindowsPtyAgent = /** @class */ (function () {
29
- function WindowsPtyAgent(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
26
+ function WindowsPtyAgent(file, args, env, cwd, cols, rows, debug, _useConptyDll, conptyInheritCursor) {
30
27
  var _this = this;
31
28
  if (_useConptyDll === void 0) { _useConptyDll = false; }
32
29
  if (conptyInheritCursor === void 0) { conptyInheritCursor = false; }
33
- this._useConpty = _useConpty;
34
30
  this._useConptyDll = _useConptyDll;
35
- this._pid = 0;
36
31
  this._innerPid = 0;
37
- if (this._useConpty === undefined || this._useConpty === true) {
38
- this._useConpty = this._getWindowsBuildNumber() >= 18309;
32
+ if (!conptyNative) {
33
+ conptyNative = utils_1.loadNativeModule('conpty').module;
39
34
  }
40
- if (this._useConpty) {
41
- if (!conptyNative) {
42
- conptyNative = utils_1.loadNativeModule('conpty').module;
43
- }
44
- }
45
- else {
46
- if (!winptyNative) {
47
- winptyNative = utils_1.loadNativeModule('pty').module;
48
- }
49
- }
50
- this._ptyNative = this._useConpty ? conptyNative : winptyNative;
35
+ this._ptyNative = conptyNative;
51
36
  // Sanitize input variable.
52
37
  cwd = path.resolve(cwd);
53
38
  // Compose command line
54
39
  var commandLine = argsToCommandLine(file, args);
55
40
  // Open pty session.
56
- var term;
57
- if (this._useConpty) {
58
- term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
59
- }
60
- else {
61
- term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
62
- this._pid = term.pid;
63
- this._innerPid = term.innerPid;
64
- }
41
+ var term = conptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
65
42
  // Not available on windows.
66
43
  this._fd = term.fd;
67
44
  // Generated incremental number that has no real purpose besides using it
@@ -85,10 +62,8 @@ var WindowsPtyAgent = /** @class */ (function () {
85
62
  writable: true
86
63
  });
87
64
  this._inSocket.setEncoding('utf8');
88
- if (this._useConpty) {
89
- var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function (c) { return _this._$onProcessExit(c); });
90
- this._innerPid = connect.pid;
91
- }
65
+ var connect = conptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function (c) { return _this._$onProcessExit(c); });
66
+ this._innerPid = connect.pid;
92
67
  }
93
68
  Object.defineProperty(WindowsPtyAgent.prototype, "inSocket", {
94
69
  get: function () { return this._inSocket; },
@@ -116,65 +91,39 @@ var WindowsPtyAgent = /** @class */ (function () {
116
91
  configurable: true
117
92
  });
118
93
  WindowsPtyAgent.prototype.resize = function (cols, rows) {
119
- if (this._useConpty) {
120
- if (this._exitCode !== undefined) {
121
- throw new Error('Cannot resize a pty that has already exited');
122
- }
123
- this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
124
- return;
94
+ if (this._exitCode !== undefined) {
95
+ throw new Error('Cannot resize a pty that has already exited');
125
96
  }
126
- this._ptyNative.resize(this._pid, cols, rows);
97
+ this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
127
98
  };
128
99
  WindowsPtyAgent.prototype.clear = function () {
129
- if (this._useConpty) {
130
- this._ptyNative.clear(this._pty, this._useConptyDll);
131
- }
100
+ this._ptyNative.clear(this._pty, this._useConptyDll);
132
101
  };
133
102
  WindowsPtyAgent.prototype.kill = function () {
134
103
  var _this = this;
135
104
  // Tell the agent to kill the pty, this releases handles to the process
136
- if (this._useConpty) {
137
- if (!this._useConptyDll) {
138
- this._inSocket.readable = false;
139
- this._outSocket.readable = false;
140
- this._getConsoleProcessList().then(function (consoleProcessList) {
141
- consoleProcessList.forEach(function (pid) {
142
- try {
143
- process.kill(pid);
144
- }
145
- catch (e) {
146
- // Ignore if process cannot be found (kill ESRCH error)
147
- }
148
- });
149
- });
150
- this._ptyNative.kill(this._pty, this._useConptyDll);
151
- this._conoutSocketWorker.dispose();
152
- }
153
- else {
154
- // Close the input write handle to signal the end of session.
155
- this._inSocket.destroy();
156
- this._ptyNative.kill(this._pty, this._useConptyDll);
157
- this._outSocket.on('data', function () {
158
- _this._conoutSocketWorker.dispose();
105
+ if (!this._useConptyDll) {
106
+ this._inSocket.readable = false;
107
+ this._outSocket.readable = false;
108
+ this._getConsoleProcessList().then(function (consoleProcessList) {
109
+ consoleProcessList.forEach(function (pid) {
110
+ try {
111
+ process.kill(pid);
112
+ }
113
+ catch (e) {
114
+ // Ignore if process cannot be found (kill ESRCH error)
115
+ }
159
116
  });
160
- }
117
+ });
118
+ this._ptyNative.kill(this._pty, this._useConptyDll);
119
+ this._conoutSocketWorker.dispose();
161
120
  }
162
121
  else {
163
- // Because pty.kill closes the handle, it will kill most processes by itself.
164
- // Process IDs can be reused as soon as all handles to them are
165
- // dropped, so we want to immediately kill the entire console process list.
166
- // If we do not force kill all processes here, node servers in particular
167
- // seem to become detached and remain running (see
168
- // Microsoft/vscode#26807).
169
- var processList = this._ptyNative.getProcessList(this._pid);
170
- this._ptyNative.kill(this._pid, this._innerPid);
171
- processList.forEach(function (pid) {
172
- try {
173
- process.kill(pid);
174
- }
175
- catch (e) {
176
- // Ignore if process cannot be found (kill ESRCH error)
177
- }
122
+ // Close the input write handle to signal the end of session.
123
+ this._inSocket.destroy();
124
+ this._ptyNative.kill(this._pty, this._useConptyDll);
125
+ this._outSocket.on('data', function () {
126
+ _this._conoutSocketWorker.dispose();
178
127
  });
179
128
  }
180
129
  };
@@ -195,23 +144,11 @@ var WindowsPtyAgent = /** @class */ (function () {
195
144
  };
196
145
  Object.defineProperty(WindowsPtyAgent.prototype, "exitCode", {
197
146
  get: function () {
198
- if (this._useConpty) {
199
- return this._exitCode;
200
- }
201
- var winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
202
- return winptyExitCode === -1 ? undefined : winptyExitCode;
147
+ return this._exitCode;
203
148
  },
204
149
  enumerable: false,
205
150
  configurable: true
206
151
  });
207
- WindowsPtyAgent.prototype._getWindowsBuildNumber = function () {
208
- var osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
209
- var buildNumber = 0;
210
- if (osVersion && osVersion.length === 4) {
211
- buildNumber = parseInt(osVersion[3]);
212
- }
213
- return buildNumber;
214
- };
215
152
  WindowsPtyAgent.prototype._generatePipeName = function () {
216
153
  return "conpty-" + Math.random() * 10000000;
217
154
  };
@@ -48,7 +48,7 @@ var WindowsTerminal = /** @class */ (function (_super) {
48
48
  // Functions that need to run after `ready` event is emitted.
49
49
  _this._deferreds = [];
50
50
  // Create new termal.
51
- _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
51
+ _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConptyDll, opt.conptyInheritCursor);
52
52
  _this._socket = _this._agent.outSocket;
53
53
  // Not available until `ready` event emitted.
54
54
  _this._pid = _this._agent.innerPid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydell/node-pty-win32-x64",
3
- "version": "1.2.0-beta.6",
3
+ "version": "1.2.0-beta.7",
4
4
  "description": "The node-pty package, stripped down only for win32-x64.",
5
5
  "repository": {
6
6
  "type": "git",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file