node-pty 0.11.0-beta9 → 1.1.0-beta1

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 (45) hide show
  1. package/README.md +5 -4
  2. package/binding.gyp +70 -29
  3. package/lib/conpty_console_list_agent.js.map +1 -1
  4. package/lib/terminal.js +10 -4
  5. package/lib/terminal.js.map +1 -1
  6. package/lib/terminal.test.js +3 -0
  7. package/lib/terminal.test.js.map +1 -1
  8. package/lib/unixTerminal.js +30 -4
  9. package/lib/unixTerminal.js.map +1 -1
  10. package/lib/unixTerminal.test.js +147 -18
  11. package/lib/unixTerminal.test.js.map +1 -1
  12. package/lib/windowsPtyAgent.js +13 -6
  13. package/lib/windowsPtyAgent.js.map +1 -1
  14. package/lib/windowsTerminal.js +21 -3
  15. package/lib/windowsTerminal.js.map +1 -1
  16. package/lib/windowsTerminal.test.js +98 -97
  17. package/lib/windowsTerminal.test.js.map +1 -1
  18. package/lib/worker/conoutSocketWorker.js +3 -0
  19. package/lib/worker/conoutSocketWorker.js.map +1 -1
  20. package/package.json +3 -4
  21. package/scripts/post-install.js +1 -0
  22. package/src/conpty_console_list_agent.ts +1 -1
  23. package/src/interfaces.ts +8 -2
  24. package/src/native.d.ts +6 -5
  25. package/src/terminal.test.ts +3 -0
  26. package/src/terminal.ts +21 -20
  27. package/src/tsconfig.json +1 -3
  28. package/src/unix/pty.cc +297 -205
  29. package/src/unix/spawn-helper.cc +23 -0
  30. package/src/unixTerminal.test.ts +117 -25
  31. package/src/unixTerminal.ts +31 -11
  32. package/src/win/conpty.cc +85 -38
  33. package/src/win/conpty_console_list.cc +3 -3
  34. package/src/win/path_util.cc +22 -3
  35. package/src/win/path_util.h +1 -0
  36. package/src/win/winpty.cc +118 -54
  37. package/src/windowsConoutConnection.ts +1 -1
  38. package/src/windowsPtyAgent.ts +16 -11
  39. package/src/windowsTerminal.test.ts +100 -99
  40. package/src/windowsTerminal.ts +23 -4
  41. package/src/worker/conoutSocketWorker.ts +4 -0
  42. package/typings/node-pty.d.ts +11 -20
  43. package/deps/winpty/.gitignore +0 -15
  44. package/deps/winpty/misc/.gitignore +0 -2
  45. package/scripts/install.js +0 -18
@@ -147,21 +147,27 @@ export class WindowsTerminal extends Terminal {
147
147
  if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
148
148
  throw new Error('resizing must be done using positive cols and rows');
149
149
  }
150
- this._defer(() => {
150
+ this._deferNoArgs(() => {
151
151
  this._agent.resize(cols, rows);
152
152
  this._cols = cols;
153
153
  this._rows = rows;
154
154
  });
155
155
  }
156
156
 
157
+ public clear(): void {
158
+ this._deferNoArgs(() => {
159
+ this._agent.clear();
160
+ });
161
+ }
162
+
157
163
  public destroy(): void {
158
- this._defer(() => {
164
+ this._deferNoArgs(() => {
159
165
  this.kill();
160
166
  });
161
167
  }
162
168
 
163
169
  public kill(signal?: string): void {
164
- this._defer(() => {
170
+ this._deferNoArgs(() => {
165
171
  if (signal) {
166
172
  throw new Error('Signals not supported on windows.');
167
173
  }
@@ -170,7 +176,20 @@ export class WindowsTerminal extends Terminal {
170
176
  });
171
177
  }
172
178
 
173
- private _defer<A extends any>(deferredFn: (arg?: A) => void, arg?: A): void {
179
+ private _deferNoArgs<A>(deferredFn: () => void): void {
180
+ // If the terminal is ready, execute.
181
+ if (this._isReady) {
182
+ deferredFn.call(this);
183
+ return;
184
+ }
185
+
186
+ // Queue until terminal is ready.
187
+ this._deferreds.push({
188
+ run: () => deferredFn.call(this)
189
+ });
190
+ }
191
+
192
+ private _defer<A>(deferredFn: (arg: A) => void, arg: A): void {
174
193
  // If the terminal is ready, execute.
175
194
  if (this._isReady) {
176
195
  deferredFn.call(this, arg);
@@ -14,5 +14,9 @@ conoutSocket.connect(conoutPipeName, () => {
14
14
  conoutSocket.pipe(workerSocket);
15
15
  });
16
16
  server.listen(getWorkerPipeName(conoutPipeName));
17
+
18
+ if (!parentPort) {
19
+ throw new Error('worker_threads parentPort is null');
20
+ }
17
21
  parentPort.postMessage(ConoutWorkerMessage.READY);
18
22
  });
@@ -78,8 +78,8 @@ declare module 'node-pty' {
78
78
 
79
79
  export interface IPtyForkOptions extends IBasePtyForkOptions {
80
80
  /**
81
- * Security warning: use this option with great caution, as opened file descriptors
82
- * with higher privileges might leak to the child program.
81
+ * Security warning: use this option with great caution,
82
+ * as opened file descriptors with higher privileges might leak to the child program.
83
83
  */
84
84
  uid?: number;
85
85
  gid?: number;
@@ -146,30 +146,21 @@ declare module 'node-pty' {
146
146
  */
147
147
  readonly onExit: IEvent<{ exitCode: number, signal?: number }>;
148
148
 
149
- /**
150
- * Adds a listener to the data event, fired when data is returned from the pty.
151
- * @param event The name of the event.
152
- * @param listener The callback function.
153
- * @deprecated Use IPty.onData
154
- */
155
- on(event: 'data', listener: (data: string) => void): void;
156
-
157
- /**
158
- * Adds a listener to the exit event, fired when the pty exits.
159
- * @param event The name of the event.
160
- * @param listener The callback function, exitCode is the exit code of the process and signal is
161
- * the signal that triggered the exit. signal is not supported on Windows.
162
- * @deprecated Use IPty.onExit
163
- */
164
- on(event: 'exit', listener: (exitCode: number, signal?: number) => void): void;
165
-
166
149
  /**
167
150
  * Resizes the dimensions of the pty.
168
- * @param columns THe number of columns to use.
151
+ * @param columns The number of columns to use.
169
152
  * @param rows The number of rows to use.
170
153
  */
171
154
  resize(columns: number, rows: number): void;
172
155
 
156
+ /**
157
+ * Clears the pty's internal representation of its buffer. This is a no-op
158
+ * unless on Windows/ConPTY. This is useful if the buffer is cleared on the
159
+ * frontend in order to synchronize state with the backend to avoid ConPTY
160
+ * possibly reprinting the screen.
161
+ */
162
+ clear(): void;
163
+
173
164
  /**
174
165
  * Writes data to the pty.
175
166
  * @param data The data to write.
@@ -1,15 +0,0 @@
1
- *.sln
2
- *.suo
3
- *.vcxproj
4
- *.vcxproj.filters
5
- *.pyc
6
- winpty.sdf
7
- winpty.opensdf
8
- /config.mk
9
- /build
10
- /build-gyp
11
- /build-libpty
12
- /ship/packages
13
- /src/Default
14
- /src/Release
15
- /src/gen
@@ -1,2 +0,0 @@
1
- *.exe
2
- UnixEcho
@@ -1,18 +0,0 @@
1
- 'use strict'
2
-
3
- const os = require('os');
4
- const path = require('path');
5
- const spawn = require('child_process').spawn;
6
-
7
- const gypArgs = ['rebuild'];
8
- if (process.env.NODE_PTY_DEBUG) {
9
- gypArgs.push('--debug');
10
- }
11
- const gypProcess = spawn(os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', gypArgs, {
12
- cwd: path.join(__dirname, '..'),
13
- stdio: 'inherit'
14
- });
15
-
16
- gypProcess.on('exit', function (code) {
17
- process.exit(code);
18
- });