node-pty 0.11.0-beta8 → 1.0.0
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/README.md +6 -4
- package/binding.gyp +68 -29
- package/lib/conpty_console_list_agent.js.map +1 -1
- package/lib/terminal.js +10 -4
- package/lib/terminal.js.map +1 -1
- package/lib/terminal.test.js +3 -0
- package/lib/terminal.test.js.map +1 -1
- package/lib/unixTerminal.js +30 -4
- package/lib/unixTerminal.js.map +1 -1
- package/lib/unixTerminal.test.js +147 -18
- package/lib/unixTerminal.test.js.map +1 -1
- package/lib/windowsPtyAgent.js +8 -0
- package/lib/windowsPtyAgent.js.map +1 -1
- package/lib/windowsTerminal.js +21 -3
- package/lib/windowsTerminal.js.map +1 -1
- package/lib/windowsTerminal.test.js +4 -5
- package/lib/windowsTerminal.test.js.map +1 -1
- package/lib/worker/conoutSocketWorker.js +3 -0
- package/lib/worker/conoutSocketWorker.js.map +1 -1
- package/package.json +3 -4
- package/scripts/post-install.js +1 -0
- package/src/conpty_console_list_agent.ts +1 -1
- package/src/interfaces.ts +8 -2
- package/src/native.d.ts +3 -1
- package/src/terminal.test.ts +3 -0
- package/src/terminal.ts +21 -20
- package/src/tsconfig.json +1 -3
- package/src/unix/pty.cc +297 -205
- package/src/unix/spawn-helper.cc +23 -0
- package/src/unixTerminal.test.ts +117 -25
- package/src/unixTerminal.ts +31 -11
- package/src/win/conpty.cc +65 -22
- package/src/win/path_util.cc +1 -1
- package/src/windowsConoutConnection.ts +1 -1
- package/src/windowsPtyAgent.ts +11 -5
- package/src/windowsTerminal.test.ts +5 -6
- package/src/windowsTerminal.ts +23 -4
- package/src/worker/conoutSocketWorker.ts +4 -0
- package/typings/node-pty.d.ts +11 -20
- package/deps/winpty/.gitignore +0 -15
- package/deps/winpty/misc/.gitignore +0 -2
- package/scripts/install.js +0 -18
package/src/terminal.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { Socket } from 'net';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
|
-
import { ITerminal, IPtyForkOptions } from './interfaces';
|
|
9
|
+
import { ITerminal, IPtyForkOptions, IProcessEnv } from './interfaces';
|
|
10
10
|
import { EventEmitter2, IEvent } from './eventEmitter2';
|
|
11
11
|
import { IExitEvent } from './types';
|
|
12
12
|
|
|
@@ -22,18 +22,18 @@ const FLOW_CONTROL_PAUSE = '\x13'; // defaults to XOFF
|
|
|
22
22
|
const FLOW_CONTROL_RESUME = '\x11'; // defaults to XON
|
|
23
23
|
|
|
24
24
|
export abstract class Terminal implements ITerminal {
|
|
25
|
-
protected _socket
|
|
26
|
-
protected _pid: number;
|
|
27
|
-
protected _fd: number;
|
|
25
|
+
protected _socket!: Socket; // HACK: This is unsafe
|
|
26
|
+
protected _pid: number = 0;
|
|
27
|
+
protected _fd: number = 0;
|
|
28
28
|
protected _pty: any;
|
|
29
29
|
|
|
30
|
-
protected _file
|
|
31
|
-
protected _name
|
|
32
|
-
protected _cols: number;
|
|
33
|
-
protected _rows: number;
|
|
30
|
+
protected _file!: string; // HACK: This is unsafe
|
|
31
|
+
protected _name!: string; // HACK: This is unsafe
|
|
32
|
+
protected _cols: number = 0;
|
|
33
|
+
protected _rows: number = 0;
|
|
34
34
|
|
|
35
|
-
protected _readable: boolean;
|
|
36
|
-
protected _writable: boolean;
|
|
35
|
+
protected _readable: boolean = false;
|
|
36
|
+
protected _writable: boolean = false;
|
|
37
37
|
|
|
38
38
|
protected _internalee: EventEmitter;
|
|
39
39
|
private _flowControlPause: string;
|
|
@@ -53,6 +53,11 @@ export abstract class Terminal implements ITerminal {
|
|
|
53
53
|
// for 'close'
|
|
54
54
|
this._internalee = new EventEmitter();
|
|
55
55
|
|
|
56
|
+
// setup flow control handling
|
|
57
|
+
this.handleFlowControl = !!(opt?.handleFlowControl);
|
|
58
|
+
this._flowControlPause = opt?.flowControlPause || FLOW_CONTROL_PAUSE;
|
|
59
|
+
this._flowControlResume = opt?.flowControlResume || FLOW_CONTROL_RESUME;
|
|
60
|
+
|
|
56
61
|
if (!opt) {
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
@@ -67,11 +72,6 @@ export abstract class Terminal implements ITerminal {
|
|
|
67
72
|
this._checkType('uid', opt.uid ? opt.uid : undefined, 'number');
|
|
68
73
|
this._checkType('gid', opt.gid ? opt.gid : undefined, 'number');
|
|
69
74
|
this._checkType('encoding', opt.encoding ? opt.encoding : undefined, 'string');
|
|
70
|
-
|
|
71
|
-
// setup flow control handling
|
|
72
|
-
this.handleFlowControl = !!(opt.handleFlowControl);
|
|
73
|
-
this._flowControlPause = opt.flowControlPause || FLOW_CONTROL_PAUSE;
|
|
74
|
-
this._flowControlResume = opt.flowControlResume || FLOW_CONTROL_RESUME;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
protected abstract _write(data: string): void;
|
|
@@ -157,9 +157,9 @@ export abstract class Terminal implements ITerminal {
|
|
|
157
157
|
|
|
158
158
|
public emit(eventName: string, ...args: any[]): any {
|
|
159
159
|
if (eventName === 'close') {
|
|
160
|
-
return this._internalee.emit.apply(this._internalee, arguments);
|
|
160
|
+
return this._internalee.emit.apply(this._internalee, arguments as any);
|
|
161
161
|
}
|
|
162
|
-
return this._socket.emit.apply(this._socket, arguments);
|
|
162
|
+
return this._socket.emit.apply(this._socket, arguments as any);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
public listeners(eventName: string): Function[] {
|
|
@@ -179,12 +179,13 @@ export abstract class Terminal implements ITerminal {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
public abstract resize(cols: number, rows: number): void;
|
|
182
|
+
public abstract clear(): void;
|
|
182
183
|
public abstract destroy(): void;
|
|
183
184
|
public abstract kill(signal?: string): void;
|
|
184
185
|
|
|
185
186
|
public abstract get process(): string;
|
|
186
|
-
public abstract get master(): Socket;
|
|
187
|
-
public abstract get slave(): Socket;
|
|
187
|
+
public abstract get master(): Socket| undefined;
|
|
188
|
+
public abstract get slave(): Socket | undefined;
|
|
188
189
|
|
|
189
190
|
protected _close(): void {
|
|
190
191
|
this._socket.readable = false;
|
|
@@ -194,7 +195,7 @@ export abstract class Terminal implements ITerminal {
|
|
|
194
195
|
this._readable = false;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
protected _parseEnv(env:
|
|
198
|
+
protected _parseEnv(env: IProcessEnv): string[] {
|
|
198
199
|
const keys = Object.keys(env || {});
|
|
199
200
|
const pairs = [];
|
|
200
201
|
|