node-pty 1.1.0-beta4 → 1.1.0-beta41
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 +10 -20
- package/deps/winpty/src/agent/Agent.cc +11 -3
- package/deps/winpty/src/winpty.gyp +29 -1
- package/lib/conpty_console_list_agent.js +3 -7
- package/lib/conpty_console_list_agent.js.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/terminal.js.map +1 -1
- package/lib/terminal.test.js.map +1 -1
- package/lib/unixTerminal.js +7 -44
- package/lib/unixTerminal.js.map +1 -1
- package/lib/unixTerminal.test.js +3 -5
- package/lib/unixTerminal.test.js.map +1 -1
- package/lib/utils.js +23 -1
- package/lib/utils.js.map +1 -1
- package/lib/windowsConoutConnection.js +6 -3
- package/lib/windowsConoutConnection.js.map +1 -1
- package/lib/windowsPtyAgent.js +45 -48
- package/lib/windowsPtyAgent.js.map +1 -1
- package/lib/windowsTerminal.js +1 -1
- package/lib/windowsTerminal.js.map +1 -1
- package/lib/windowsTerminal.test.js +40 -26
- package/lib/windowsTerminal.test.js.map +1 -1
- package/lib/worker/conoutSocketWorker.js.map +1 -1
- package/package.json +7 -2
- package/prebuilds/darwin-arm64/pty.node +0 -0
- package/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/prebuilds/darwin-x64/pty.node +0 -0
- package/prebuilds/darwin-x64/spawn-helper +0 -0
- package/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/prebuilds/win32-arm64/conpty.node +0 -0
- package/prebuilds/win32-arm64/conpty.pdb +0 -0
- package/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
- package/prebuilds/win32-arm64/pty.node +0 -0
- package/prebuilds/win32-arm64/pty.pdb +0 -0
- package/prebuilds/win32-arm64/winpty-agent.exe +0 -0
- package/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
- package/prebuilds/win32-arm64/winpty.dll +0 -0
- package/prebuilds/win32-arm64/winpty.pdb +0 -0
- package/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/prebuilds/win32-x64/conpty.node +0 -0
- package/prebuilds/win32-x64/conpty.pdb +0 -0
- package/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
- package/prebuilds/win32-x64/pty.node +0 -0
- package/prebuilds/win32-x64/pty.pdb +0 -0
- package/prebuilds/win32-x64/winpty-agent.exe +0 -0
- package/prebuilds/win32-x64/winpty-agent.pdb +0 -0
- package/prebuilds/win32-x64/winpty.dll +0 -0
- package/prebuilds/win32-x64/winpty.pdb +0 -0
- package/scripts/gen-compile-commands.js +8 -0
- package/scripts/{publish.js → increment-version.js} +7 -15
- package/scripts/post-install.js +48 -10
- package/scripts/prebuild.js +34 -0
- package/src/conpty_console_list_agent.ts +2 -6
- package/src/index.ts +2 -1
- package/src/interfaces.ts +2 -1
- package/src/native.d.ts +5 -5
- package/src/terminal.test.ts +1 -1
- package/src/terminal.ts +2 -2
- package/src/unix/pty.cc +244 -284
- package/src/unixTerminal.test.ts +3 -6
- package/src/unixTerminal.ts +9 -36
- package/src/utils.ts +20 -0
- package/src/win/conpty.cc +268 -187
- package/src/win/conpty.h +41 -0
- package/src/win/conpty_console_list.cc +16 -15
- package/src/win/path_util.cc +39 -36
- package/src/win/path_util.h +5 -2
- package/src/win/winpty.cc +108 -151
- package/src/windowsConoutConnection.ts +6 -3
- package/src/windowsPtyAgent.ts +42 -43
- package/src/windowsTerminal.test.ts +46 -33
- package/src/windowsTerminal.ts +3 -3
- package/src/worker/conoutSocketWorker.ts +2 -2
- package/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
- package/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
- package/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
- package/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
- package/typings/node-pty.d.ts +9 -1
|
@@ -7,30 +7,19 @@ const fs = require('fs');
|
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const packageJson = require('../package.json');
|
|
9
9
|
|
|
10
|
-
// Setup auth
|
|
11
|
-
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
|
|
12
|
-
|
|
13
10
|
// Determine if this is a stable or beta release
|
|
14
11
|
const publishedVersions = getPublishedVersions();
|
|
15
|
-
const isStableRelease = publishedVersions.
|
|
12
|
+
const isStableRelease = !publishedVersions.includes(packageJson.version);
|
|
16
13
|
|
|
17
14
|
// Get the next version
|
|
18
|
-
|
|
19
|
-
console.log(`
|
|
15
|
+
const nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
|
|
16
|
+
console.log(`Setting version to ${nextVersion}`);
|
|
20
17
|
|
|
21
18
|
// Set the version in package.json
|
|
22
19
|
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
|
|
23
20
|
packageJson.version = nextVersion;
|
|
24
21
|
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
|
25
22
|
|
|
26
|
-
// Publish
|
|
27
|
-
const args = ['publish'];
|
|
28
|
-
if (!isStableRelease) {
|
|
29
|
-
args.push('--tag', 'beta');
|
|
30
|
-
}
|
|
31
|
-
const result = cp.spawn('npm', args, { stdio: 'inherit' });
|
|
32
|
-
result.on('exit', code => process.exit(code));
|
|
33
|
-
|
|
34
23
|
function getNextBetaVersion() {
|
|
35
24
|
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
|
|
36
25
|
console.error('The package.json version must be of the form x.y.z');
|
|
@@ -53,7 +42,10 @@ function getNextBetaVersion() {
|
|
|
53
42
|
}
|
|
54
43
|
|
|
55
44
|
function getPublishedVersions(version, tag) {
|
|
56
|
-
const
|
|
45
|
+
const isWin32 = process.platform === 'win32';
|
|
46
|
+
const versionsProcess = isWin32 ?
|
|
47
|
+
cp.spawnSync('npm.cmd', ['view', packageJson.name, 'versions', '--json'], { shell: true }) :
|
|
48
|
+
cp.spawnSync('npm', ['view', packageJson.name, 'versions', '--json']);
|
|
57
49
|
const versionsJson = JSON.parse(versionsProcess.stdout);
|
|
58
50
|
if (tag) {
|
|
59
51
|
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
|
package/scripts/post-install.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
var path = require('path');
|
|
1
|
+
//@ts-check
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const RELEASE_DIR = path.join(__dirname, '../build/Release');
|
|
8
|
+
const BUILD_FILES = [
|
|
6
9
|
path.join(RELEASE_DIR, 'conpty.node'),
|
|
7
10
|
path.join(RELEASE_DIR, 'conpty.pdb'),
|
|
8
11
|
path.join(RELEASE_DIR, 'conpty_console_list.node'),
|
|
@@ -15,14 +18,19 @@ var BUILD_FILES = [
|
|
|
15
18
|
path.join(RELEASE_DIR, 'winpty.dll'),
|
|
16
19
|
path.join(RELEASE_DIR, 'winpty.pdb')
|
|
17
20
|
];
|
|
21
|
+
const CONPTY_DIR = path.join(__dirname, '../third_party/conpty');
|
|
22
|
+
const CONPTY_SUPPORTED_ARCH = ['x64', 'arm64'];
|
|
23
|
+
|
|
24
|
+
console.log('\x1b[32m> Cleaning release folder...\x1b[0m');
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
/** @param {string} folder */
|
|
27
|
+
function cleanFolderRecursive(folder) {
|
|
20
28
|
var files = [];
|
|
21
|
-
if(
|
|
29
|
+
if (fs.existsSync(folder)) {
|
|
22
30
|
files = fs.readdirSync(folder);
|
|
23
31
|
files.forEach(function(file,index) {
|
|
24
32
|
var curPath = path.join(folder, file);
|
|
25
|
-
if(fs.lstatSync(curPath).isDirectory()) { // recurse
|
|
33
|
+
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
|
26
34
|
cleanFolderRecursive(curPath);
|
|
27
35
|
fs.rmdirSync(curPath);
|
|
28
36
|
} else if (BUILD_FILES.indexOf(curPath) < 0){ // delete file
|
|
@@ -36,7 +44,37 @@ try {
|
|
|
36
44
|
cleanFolderRecursive(RELEASE_DIR);
|
|
37
45
|
} catch(e) {
|
|
38
46
|
console.log(e);
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log(`\x1b[32m> Moving conpty.dll...\x1b[0m`);
|
|
51
|
+
if (os.platform() !== 'win32') {
|
|
52
|
+
console.log(' SKIPPED (not Windows)');
|
|
53
|
+
} else {
|
|
54
|
+
let windowsArch;
|
|
55
|
+
if (process.env.npm_config_arch) {
|
|
56
|
+
windowsArch = process.env.npm_config_arch;
|
|
57
|
+
console.log(` Using $npm_config_arch: ${windowsArch}`);
|
|
58
|
+
} else {
|
|
59
|
+
windowsArch = os.arch();
|
|
60
|
+
console.log(` Using os.arch(): ${windowsArch}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!CONPTY_SUPPORTED_ARCH.includes(windowsArch)) {
|
|
64
|
+
console.log(` SKIPPED (unsupported architecture ${windowsArch})`);
|
|
65
|
+
} else {
|
|
66
|
+
const versionFolder = fs.readdirSync(CONPTY_DIR)[0];
|
|
67
|
+
console.log(` Found version ${versionFolder}`);
|
|
68
|
+
const sourceFolder = path.join(CONPTY_DIR, versionFolder, `win10-${windowsArch}`);
|
|
69
|
+
const destFolder = path.join(RELEASE_DIR, 'conpty');
|
|
70
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
71
|
+
for (const file of ['conpty.dll', 'OpenConsole.exe']) {
|
|
72
|
+
const sourceFile = path.join(sourceFolder, file);
|
|
73
|
+
const destFile = path.join(destFolder, file);
|
|
74
|
+
console.log(` Copying ${sourceFile} -> ${destFile}`);
|
|
75
|
+
fs.copyFileSync(sourceFile, destFile);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
42
78
|
}
|
|
79
|
+
|
|
80
|
+
process.exit(0);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This script checks for the prebuilt binaries for the current platform and
|
|
8
|
+
* architecture. It exits with 0 if prebuilds are found and 1 if not.
|
|
9
|
+
*
|
|
10
|
+
* If npm_config_build_from_source is set then it removes the prebuilds for the
|
|
11
|
+
* current platform so they are not loaded at runtime.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* node scripts/prebuild.js
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const PREBUILDS_ROOT = path.join(__dirname, '..', 'prebuilds');
|
|
18
|
+
const PREBUILD_DIR = path.join(__dirname, '..', 'prebuilds', `${process.platform}-${process.arch}`);
|
|
19
|
+
|
|
20
|
+
// Do not use prebuilds when npm_config_build_from_source is set
|
|
21
|
+
if (process.env.npm_config_build_from_source === 'true') {
|
|
22
|
+
console.log('\x1b[33m> Removing prebuilds and rebuilding because npm_config_build_from_source is set\x1b[0m');
|
|
23
|
+
fs.rmSync(PREBUILDS_ROOT, { recursive: true, force: true });
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Check whether the correct prebuilt files exist
|
|
28
|
+
console.log('\x1b[32m> Checking prebuilds...\x1b[0m');
|
|
29
|
+
if (!fs.existsSync(PREBUILD_DIR)) {
|
|
30
|
+
console.log(`\x1b[33m> Rebuilding because directory ${PREBUILD_DIR} does not exist\x1b[0m`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
process.exit(0);
|
|
@@ -6,13 +6,9 @@
|
|
|
6
6
|
* single console attached to a process.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
getConsoleProcessList = require('../build/Release/conpty_console_list.node').getConsoleProcessList;
|
|
12
|
-
} catch (err) {
|
|
13
|
-
getConsoleProcessList = require('../build/Debug/conpty_console_list.node').getConsoleProcessList;
|
|
14
|
-
}
|
|
9
|
+
import { loadNativeModule } from './utils';
|
|
15
10
|
|
|
11
|
+
const getConsoleProcessList = loadNativeModule('conpty_console_list').module.getConsoleProcessList;
|
|
16
12
|
const shellPid = parseInt(process.argv[2], 10);
|
|
17
13
|
const consoleProcessList = getConsoleProcessList(shellPid);
|
|
18
14
|
process.send!({ consoleProcessList });
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { ITerminal, IPtyOpenOptions, IPtyForkOptions, IWindowsPtyForkOptions } from './interfaces';
|
|
8
8
|
import { ArgvOrCommandLine } from './types';
|
|
9
|
+
import { loadNativeModule } from './utils';
|
|
9
10
|
|
|
10
11
|
let terminalCtor: any;
|
|
11
12
|
if (process.platform === 'win32') {
|
|
@@ -48,4 +49,4 @@ export function open(options: IPtyOpenOptions): ITerminal {
|
|
|
48
49
|
* Expose the native API when not Windows, note that this is not public API and
|
|
49
50
|
* could be removed at any time.
|
|
50
51
|
*/
|
|
51
|
-
export const native = (process.platform !== 'win32' ?
|
|
52
|
+
export const native = (process.platform !== 'win32' ? loadNativeModule('pty').module : null);
|
package/src/interfaces.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface ITerminal {
|
|
|
22
22
|
* Writes data to the socket.
|
|
23
23
|
* @param data The data to write.
|
|
24
24
|
*/
|
|
25
|
-
write(data: string): void;
|
|
25
|
+
write(data: string | Buffer): void;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Resize the pty.
|
|
@@ -119,6 +119,7 @@ export interface IPtyForkOptions extends IBasePtyForkOptions {
|
|
|
119
119
|
|
|
120
120
|
export interface IWindowsPtyForkOptions extends IBasePtyForkOptions {
|
|
121
121
|
useConpty?: boolean;
|
|
122
|
+
useConptyDll?: boolean;
|
|
122
123
|
conptyInheritCursor?: boolean;
|
|
123
124
|
}
|
|
124
125
|
|
package/src/native.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
interface IConptyNative {
|
|
6
|
-
startProcess(file: string, cols: number, rows: number, debug: boolean, pipeName: string, conptyInheritCursor: boolean): IConptyProcess;
|
|
7
|
-
connect(ptyId: number, commandLine: string, cwd: string, env: string[], onExitCallback: (exitCode: number) => void): { pid: number };
|
|
8
|
-
resize(ptyId: number, cols: number, rows: number): void;
|
|
9
|
-
clear(ptyId: number): void;
|
|
10
|
-
kill(ptyId: number): void;
|
|
6
|
+
startProcess(file: string, cols: number, rows: number, debug: boolean, pipeName: string, conptyInheritCursor: boolean, useConptyDll: boolean): IConptyProcess;
|
|
7
|
+
connect(ptyId: number, commandLine: string, cwd: string, env: string[], useConptyDll: boolean, onExitCallback: (exitCode: number) => void): { pid: number };
|
|
8
|
+
resize(ptyId: number, cols: number, rows: number, useConptyDll: boolean): void;
|
|
9
|
+
clear(ptyId: number, useConptyDll: boolean): void;
|
|
10
|
+
kill(ptyId: number, useConptyDll: boolean): void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface IWinptyNative {
|
package/src/terminal.test.ts
CHANGED
|
@@ -23,7 +23,7 @@ class TestTerminal extends Terminal {
|
|
|
23
23
|
public checkType<T>(name: string, value: T, type: string, allowArray: boolean = false): void {
|
|
24
24
|
this._checkType(name, value, type, allowArray);
|
|
25
25
|
}
|
|
26
|
-
protected _write(data: string): void {
|
|
26
|
+
protected _write(data: string | Buffer): void {
|
|
27
27
|
throw new Error('Method not implemented.');
|
|
28
28
|
}
|
|
29
29
|
public resize(cols: number, rows: number): void {
|
package/src/terminal.ts
CHANGED
|
@@ -74,9 +74,9 @@ export abstract class Terminal implements ITerminal {
|
|
|
74
74
|
this._checkType('encoding', opt.encoding ? opt.encoding : undefined, 'string');
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
protected abstract _write(data: string): void;
|
|
77
|
+
protected abstract _write(data: string | Buffer): void;
|
|
78
78
|
|
|
79
|
-
public write(data: string): void {
|
|
79
|
+
public write(data: string | Buffer): void {
|
|
80
80
|
if (this.handleFlowControl) {
|
|
81
81
|
// PAUSE/RESUME messages are not forwarded to the pty
|
|
82
82
|
if (data === this._flowControlPause) {
|