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.
- package/README.md +5 -4
- package/binding.gyp +70 -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 +13 -6
- 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 +98 -97
- 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 +6 -5
- 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 +85 -38
- package/src/win/conpty_console_list.cc +3 -3
- package/src/win/path_util.cc +22 -3
- package/src/win/path_util.h +1 -0
- package/src/win/winpty.cc +118 -54
- package/src/windowsConoutConnection.ts +1 -1
- package/src/windowsPtyAgent.ts +16 -11
- package/src/windowsTerminal.test.ts +100 -99
- 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/windowsTerminal.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
164
|
+
this._deferNoArgs(() => {
|
|
159
165
|
this.kill();
|
|
160
166
|
});
|
|
161
167
|
}
|
|
162
168
|
|
|
163
169
|
public kill(signal?: string): void {
|
|
164
|
-
this.
|
|
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
|
|
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
|
});
|
package/typings/node-pty.d.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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.
|
package/deps/winpty/.gitignore
DELETED
package/scripts/install.js
DELETED
|
@@ -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
|
-
});
|