node-pty 1.1.0-beta3 → 1.1.0-beta31

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.
Files changed (40) hide show
  1. package/README.md +6 -5
  2. package/binding.gyp +4 -15
  3. package/deps/winpty/src/agent/Agent.cc +11 -3
  4. package/lib/unixTerminal.js +4 -27
  5. package/lib/unixTerminal.js.map +1 -1
  6. package/lib/unixTerminal.test.js +3 -5
  7. package/lib/unixTerminal.test.js.map +1 -1
  8. package/lib/windowsConoutConnection.js +6 -3
  9. package/lib/windowsConoutConnection.js.map +1 -1
  10. package/lib/windowsPtyAgent.js +42 -22
  11. package/lib/windowsPtyAgent.js.map +1 -1
  12. package/lib/windowsTerminal.js +1 -1
  13. package/lib/windowsTerminal.js.map +1 -1
  14. package/lib/windowsTerminal.test.js +38 -26
  15. package/lib/windowsTerminal.test.js.map +1 -1
  16. package/lib/worker/conoutSocketWorker.js.map +1 -1
  17. package/package.json +4 -2
  18. package/scripts/{publish.js → increment-version.js} +7 -15
  19. package/scripts/post-install.js +51 -10
  20. package/src/interfaces.ts +1 -0
  21. package/src/native.d.ts +5 -5
  22. package/src/unix/pty.cc +241 -284
  23. package/src/unixTerminal.test.ts +3 -6
  24. package/src/unixTerminal.ts +4 -18
  25. package/src/win/conpty.cc +266 -185
  26. package/src/win/conpty.h +41 -0
  27. package/src/win/conpty_console_list.cc +16 -15
  28. package/src/win/path_util.cc +39 -36
  29. package/src/win/path_util.h +5 -2
  30. package/src/win/winpty.cc +108 -151
  31. package/src/windowsConoutConnection.ts +6 -3
  32. package/src/windowsPtyAgent.ts +39 -21
  33. package/src/windowsTerminal.test.ts +43 -32
  34. package/src/windowsTerminal.ts +1 -1
  35. package/src/worker/conoutSocketWorker.ts +2 -2
  36. package/third_party/conpty/1.22.250204002/win10-arm64/OpenConsole.exe +0 -0
  37. package/third_party/conpty/1.22.250204002/win10-arm64/conpty.dll +0 -0
  38. package/third_party/conpty/1.22.250204002/win10-x64/OpenConsole.exe +0 -0
  39. package/third_party/conpty/1.22.250204002/win10-x64/conpty.dll +0 -0
  40. package/typings/node-pty.d.ts +8 -0
@@ -272,10 +272,9 @@ if (process.platform !== 'win32') {
272
272
  ptyProcess.on('data', function (data) {
273
273
  if (ptyProcess.process === 'Python') {
274
274
  console.log('title', ptyProcess.process);
275
+ console.log('ready', ptyProcess.pid);
275
276
  }
276
277
  });
277
- setTimeout(() => null, 500);
278
- console.log('ready', ptyProcess.pid);
279
278
  `;
280
279
  const p = cp.spawn('node', ['-e', data]);
281
280
  let sub = '';
@@ -283,12 +282,10 @@ if (process.platform !== 'win32') {
283
282
  p.stdout.on('data', (data) => {
284
283
  if (!data.toString().indexOf('title')) {
285
284
  sub = data.toString().split(' ')[1].slice(0, -1);
286
- setTimeout(() => {
287
- process.kill(parseInt(pid), 'SIGINT');
288
- p.kill('SIGINT');
289
- }, 200);
290
285
  } else if (!data.toString().indexOf('ready')) {
291
286
  pid = data.toString().split(' ')[1].slice(0, -1);
287
+ process.kill(parseInt(pid), 'SIGINT');
288
+ p.kill('SIGINT');
292
289
  }
293
290
  });
294
291
  p.on('exit', () => {
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import * as net from 'net';
7
7
  import * as path from 'path';
8
+ import * as tty from 'tty';
8
9
  import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
9
10
  import { IProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
10
11
  import { ArgvOrCommandLine } from './types';
@@ -113,7 +114,7 @@ export class UnixTerminal extends Terminal {
113
114
  // fork
114
115
  const term = pty.fork(file, args, parsedEnv, cwd, this._cols, this._rows, uid, gid, (encoding === 'utf8'), helperPath, onexit);
115
116
 
116
- this._socket = new PipeSocket(term.fd);
117
+ this._socket = new tty.ReadStream(term.fd);
117
118
  if (encoding !== null) {
118
119
  this._socket.setEncoding(encoding);
119
120
  }
@@ -203,13 +204,13 @@ export class UnixTerminal extends Terminal {
203
204
  // open
204
205
  const term: IUnixOpenProcess = pty.open(cols, rows);
205
206
 
206
- self._master = new PipeSocket(<number>term.master);
207
+ self._master = new tty.ReadStream(term.master);
207
208
  if (encoding !== null) {
208
209
  self._master.setEncoding(encoding);
209
210
  }
210
211
  self._master.resume();
211
212
 
212
- self._slave = new PipeSocket(term.slave);
213
+ self._slave = new tty.ReadStream(term.slave);
213
214
  if (encoding !== null) {
214
215
  self._slave.setEncoding(encoding);
215
216
  }
@@ -304,18 +305,3 @@ export class UnixTerminal extends Terminal {
304
305
  delete env['LINES'];
305
306
  }
306
307
  }
307
-
308
- /**
309
- * Wraps net.Socket to force the handle type "PIPE" by temporarily overwriting
310
- * tty_wrap.guessHandleType.
311
- * See: https://github.com/chjj/pty.js/issues/103
312
- */
313
- class PipeSocket extends net.Socket {
314
- constructor(fd: number) {
315
- const pipeWrap = (<any>process).binding('pipe_wrap'); // tslint:disable-line
316
- // @types/node has fd as string? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18275
317
- const handle = new pipeWrap.Pipe(pipeWrap.constants.SOCKET);
318
- handle.open(fd);
319
- super(<any>{ handle });
320
- }
321
- }