node-pty 1.2.0-beta.1 → 1.2.0-beta.3

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 (36) hide show
  1. package/binding.gyp +59 -2
  2. package/deps/winpty/src/winpty.gyp +2 -0
  3. package/lib/utils.js +1 -1
  4. package/lib/utils.js.map +1 -1
  5. package/package.json +1 -1
  6. package/prebuilds/darwin-arm64/pty.node +0 -0
  7. package/prebuilds/darwin-arm64/spawn-helper +0 -0
  8. package/prebuilds/darwin-x64/pty.node +0 -0
  9. package/prebuilds/darwin-x64/spawn-helper +0 -0
  10. package/prebuilds/linux-arm64/pty.node +0 -0
  11. package/prebuilds/linux-x64/pty.node +0 -0
  12. package/prebuilds/win32-arm64/conpty.node +0 -0
  13. package/prebuilds/win32-arm64/conpty.pdb +0 -0
  14. package/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  15. package/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  16. package/prebuilds/win32-arm64/pty.node +0 -0
  17. package/prebuilds/win32-arm64/pty.pdb +0 -0
  18. package/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  19. package/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  20. package/prebuilds/win32-arm64/winpty.dll +0 -0
  21. package/prebuilds/win32-arm64/winpty.pdb +0 -0
  22. package/prebuilds/win32-x64/conpty.node +0 -0
  23. package/prebuilds/win32-x64/conpty.pdb +0 -0
  24. package/prebuilds/win32-x64/conpty_console_list.node +0 -0
  25. package/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  26. package/prebuilds/win32-x64/pty.node +0 -0
  27. package/prebuilds/win32-x64/pty.pdb +0 -0
  28. package/prebuilds/win32-x64/winpty-agent.exe +0 -0
  29. package/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  30. package/prebuilds/win32-x64/winpty.dll +0 -0
  31. package/prebuilds/win32-x64/winpty.pdb +0 -0
  32. package/scripts/linux/checksums.txt +2 -0
  33. package/scripts/linux/install-sysroot.js +157 -0
  34. package/scripts/linux/verify-glibc-requirements.sh +36 -0
  35. package/scripts/prebuild.js +8 -0
  36. package/src/utils.ts +1 -1
package/binding.gyp CHANGED
@@ -14,8 +14,9 @@
14
14
  '/guard:cf',
15
15
  '/sdl',
16
16
  '/W3',
17
- '/w34244',
18
- '/w34267',
17
+ '/we4146',
18
+ '/we4244',
19
+ '/we4267',
19
20
  '/ZH:SHA_256'
20
21
  ]
21
22
  },
@@ -80,6 +81,7 @@
80
81
  '-lutil'
81
82
  ],
82
83
  'cflags': ['-Wall', '-O2', '-D_FORTIFY_SOURCE=2'],
84
+ 'ldflags': [],
83
85
  'conditions': [
84
86
  # http://www.gnu.org/software/gnulib/manual/html_node/forkpty.html
85
87
  # One some systems (at least including Cygwin, Interix,
@@ -88,6 +90,61 @@
88
90
  'libraries!': [
89
91
  '-lutil'
90
92
  ]
93
+ }],
94
+ ['OS=="linux"', {
95
+ 'variables': {
96
+ 'sysroot%': '<!(node -p "process.env.SYSROOT_PATH || \'\'")',
97
+ 'target_arch%': '<!(node -p "process.env.npm_config_arch || process.arch")',
98
+ },
99
+ 'conditions': [
100
+ ['sysroot!=""', {
101
+ 'variables': {
102
+ 'gcc_include%': '<!(${CXX:-g++} -print-file-name=include)',
103
+ },
104
+ 'conditions': [
105
+ ['target_arch=="x64"', {
106
+ 'cflags': [
107
+ '--sysroot=<(sysroot)',
108
+ '-nostdinc',
109
+ '-isystem<(gcc_include)',
110
+ '-isystem<(sysroot)/usr/include',
111
+ '-isystem<(sysroot)/usr/include/x86_64-linux-gnu'
112
+ ],
113
+ 'cflags_cc': [
114
+ '-nostdinc++',
115
+ '-isystem<(sysroot)/../include/c++/10.5.0',
116
+ '-isystem<(sysroot)/../include/c++/10.5.0/x86_64-linux-gnu',
117
+ '-isystem<(sysroot)/../include/c++/10.5.0/backward'
118
+ ],
119
+ 'ldflags': [
120
+ '--sysroot=<(sysroot)',
121
+ '-L<(sysroot)/lib',
122
+ '-L<(sysroot)/usr/lib'
123
+ ],
124
+ }],
125
+ ['target_arch=="arm64"', {
126
+ 'cflags': [
127
+ '--sysroot=<(sysroot)',
128
+ '-nostdinc',
129
+ '-isystem<(gcc_include)',
130
+ '-isystem<(sysroot)/usr/include',
131
+ '-isystem<(sysroot)/usr/include/aarch64-linux-gnu'
132
+ ],
133
+ 'cflags_cc': [
134
+ '-nostdinc++',
135
+ '-isystem<(sysroot)/../include/c++/10.5.0',
136
+ '-isystem<(sysroot)/../include/c++/10.5.0/aarch64-linux-gnu',
137
+ '-isystem<(sysroot)/../include/c++/10.5.0/backward'
138
+ ],
139
+ 'ldflags': [
140
+ '--sysroot=<(sysroot)',
141
+ '-L<(sysroot)/lib',
142
+ '-L<(sysroot)/usr/lib'
143
+ ],
144
+ }]
145
+ ]
146
+ }]
147
+ ]
91
148
  }]
92
149
  ]
93
150
  }
@@ -50,6 +50,7 @@
50
50
  'ExceptionHandling': '1', # /EHsc
51
51
  'AdditionalOptions': [
52
52
  '/guard:cf',
53
+ '/w34146',
53
54
  '/w34244',
54
55
  '/w34267',
55
56
  '/ZH:SHA_256'
@@ -152,6 +153,7 @@
152
153
  'ExceptionHandling': '1', # /EHsc
153
154
  'AdditionalOptions': [
154
155
  '/guard:cf',
156
+ '/w34146',
155
157
  '/w34244',
156
158
  '/w34267',
157
159
  '/ZH:SHA_256'
package/lib/utils.js CHANGED
@@ -24,7 +24,7 @@ function loadNativeModule(name) {
24
24
  var d = dirs_1[_i];
25
25
  for (var _a = 0, relative_1 = relative; _a < relative_1.length; _a++) {
26
26
  var r = relative_1[_a];
27
- var dir = r + "/" + d + "/";
27
+ var dir = r + "/" + d;
28
28
  try {
29
29
  return { dir: dir, module: require(dir + "/" + name + ".node") };
30
30
  }
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,SAAgB,MAAM,CAAC,MAAW;IAA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;AAC3G,CAAC;AAjBD,4CAiBC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Microsoft Corporation"
6
6
  },
7
- "version": "1.2.0-beta.1",
7
+ "version": "1.2.0-beta.3",
8
8
  "license": "MIT",
9
9
  "main": "./lib/index.js",
10
10
  "types": "./typings/node-pty.d.ts",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ 3122af49c493c5c767c2b0772a41119cbdc9803125a705683445b4066dc88b82 x86_64-linux-gnu-glibc-2.28-gcc-10.5.0.tar.gz
2
+ 3baac81a39b69e0929e4700f4f78f022adefc515010054ec393565657c4fff32 aarch64-linux-gnu-glibc-2.28-gcc-10.5.0.tar.gz
@@ -0,0 +1,157 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ const { execSync } = require('child_process');
7
+ const { tmpdir } = require('os');
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { createHash } = require('crypto');
11
+
12
+ const REPO_ROOT = path.join(__dirname, '..', '..');
13
+
14
+ const ghApiHeaders = {
15
+ Accept: 'application/vnd.github.v3+json',
16
+ 'User-Agent': 'node-pty Build',
17
+ };
18
+
19
+ if (process.env.GITHUB_TOKEN) {
20
+ ghApiHeaders.Authorization = 'Basic ' + Buffer.from(process.env.GITHUB_TOKEN).toString('base64');
21
+ }
22
+
23
+ const ghDownloadHeaders = {
24
+ ...ghApiHeaders,
25
+ Accept: 'application/octet-stream',
26
+ };
27
+
28
+ function getSysrootChecksum(expectedName) {
29
+ const checksumPath = path.join(REPO_ROOT, 'scripts', 'linux', 'checksums.txt');
30
+ const checksums = fs.readFileSync(checksumPath, 'utf8');
31
+ for (const line of checksums.split('\n')) {
32
+ const [checksum, name] = line.split(/\s+/);
33
+ if (name === expectedName) {
34
+ return checksum;
35
+ }
36
+ }
37
+ return undefined;
38
+ }
39
+
40
+ async function fetchUrl(options, retries = 10, retryDelay = 1000) {
41
+ try {
42
+ const controller = new AbortController();
43
+ const timeout = setTimeout(() => controller.abort(), 30 * 1000);
44
+ const version = '20250407-330404';
45
+ try {
46
+ const response = await fetch(`https://api.github.com/repos/Microsoft/vscode-linux-build-agent/releases/tags/v${version}`, {
47
+ headers: ghApiHeaders,
48
+ signal: controller.signal
49
+ });
50
+ if (response.ok && (response.status >= 200 && response.status < 300)) {
51
+ console.log(`Fetch completed: Status ${response.status}.`);
52
+ const contents = Buffer.from(await response.arrayBuffer());
53
+ const asset = JSON.parse(contents.toString()).assets.find((a) => a.name === options.assetName);
54
+ if (!asset) {
55
+ throw new Error(`Could not find asset in release of Microsoft/vscode-linux-build-agent @ ${version}`);
56
+ }
57
+ console.log(`Found asset ${options.assetName} @ ${asset.url}.`);
58
+ const assetResponse = await fetch(asset.url, {
59
+ headers: ghDownloadHeaders
60
+ });
61
+ if (assetResponse.ok && (assetResponse.status >= 200 && assetResponse.status < 300)) {
62
+ const assetContents = Buffer.from(await assetResponse.arrayBuffer());
63
+ console.log(`Fetched response body buffer: ${assetContents.byteLength} bytes`);
64
+ if (options.checksumSha256) {
65
+ const actualSHA256Checksum = createHash('sha256').update(assetContents).digest('hex');
66
+ if (actualSHA256Checksum !== options.checksumSha256) {
67
+ throw new Error(`Checksum mismatch for ${asset.url} (expected ${options.checksumSha256}, actual ${actualSHA256Checksum})`);
68
+ }
69
+ }
70
+ console.log(`Verified SHA256 checksums match for ${asset.url}`);
71
+ const tarCommand = `tar -xz -C ${options.dest}`;
72
+ execSync(tarCommand, { input: assetContents });
73
+ console.log(`Fetch complete!`);
74
+ return;
75
+ }
76
+ throw new Error(`Request ${asset.url} failed with status code: ${assetResponse.status}`);
77
+ }
78
+ throw new Error(`Request https://api.github.com failed with status code: ${response.status}`);
79
+ } finally {
80
+ clearTimeout(timeout);
81
+ }
82
+ } catch (e) {
83
+ if (retries > 0) {
84
+ console.log(`Fetching failed: ${e}`);
85
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
86
+ return fetchUrl(options, retries - 1, retryDelay);
87
+ }
88
+ throw e;
89
+ }
90
+ }
91
+
92
+ async function getSysroot(arch) {
93
+ let expectedName;
94
+ let triple;
95
+ const prefix = '-glibc-2.28-gcc-10.5.0';
96
+
97
+ switch (arch) {
98
+ case 'x64':
99
+ expectedName = `x86_64-linux-gnu${prefix}.tar.gz`;
100
+ triple = 'x86_64-linux-gnu';
101
+ break;
102
+ case 'arm64':
103
+ expectedName = `aarch64-linux-gnu${prefix}.tar.gz`;
104
+ triple = 'aarch64-linux-gnu';
105
+ break;
106
+ default:
107
+ throw new Error(`Unsupported architecture: ${arch}`);
108
+ }
109
+
110
+ console.log(`Fetching ${expectedName} for ${triple}`);
111
+ const checksumSha256 = getSysrootChecksum(expectedName);
112
+ if (!checksumSha256) {
113
+ throw new Error(`Could not find checksum for ${expectedName}`);
114
+ }
115
+
116
+ const sysroot = path.join(tmpdir(), `vscode-${arch}-sysroot`);
117
+ const stamp = path.join(sysroot, '.stamp');
118
+ const result = `${sysroot}/${triple}/${triple}/sysroot`;
119
+
120
+ if (fs.existsSync(stamp) && fs.readFileSync(stamp).toString() === expectedName) {
121
+ console.log(`Sysroot already installed: ${result}`);
122
+ return result;
123
+ }
124
+
125
+ console.log(`Installing ${arch} root image: ${sysroot}`);
126
+ fs.rmSync(sysroot, { recursive: true, force: true });
127
+ fs.mkdirSync(sysroot, { recursive: true });
128
+
129
+ await fetchUrl({
130
+ checksumSha256,
131
+ assetName: expectedName,
132
+ dest: sysroot
133
+ });
134
+
135
+ fs.writeFileSync(stamp, expectedName);
136
+ console.log(`Sysroot installed: ${result}`);
137
+ return result;
138
+ }
139
+
140
+ async function main() {
141
+ const arch = process.argv[2] || process.env.ARCH || 'x64';
142
+ console.log(`Installing sysroot for architecture: ${arch}`);
143
+
144
+ try {
145
+ const sysrootPath = await getSysroot(arch);
146
+ console.log(`SYSROOT_PATH=${sysrootPath}`);
147
+ } catch (error) {
148
+ console.error('Error installing sysroot:', error);
149
+ process.exit(1);
150
+ }
151
+ }
152
+
153
+ if (require.main === module) {
154
+ main();
155
+ }
156
+
157
+ module.exports = { getSysroot };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ # Get all files with .node extension from given folder
6
+ files=$(find $SEARCH_PATH -name "*.node")
7
+
8
+ echo "Verifying requirements for files: $files"
9
+
10
+ for file in $files; do
11
+ glibc_version="$EXPECTED_GLIBC_VERSION"
12
+ glibcxx_version="$EXPECTED_GLIBCXX_VERSION"
13
+ while IFS= read -r line; do
14
+ if [[ $line == *"GLIBC_"* ]]; then
15
+ version=$(echo "$line" | awk '{if ($5 ~ /^[0-9a-fA-F]+$/) print $6; else print $5}' | tr -d '()')
16
+ version=${version#*_}
17
+ if [[ $(printf "%s\n%s" "$version" "$glibc_version" | sort -V | tail -n1) == "$version" ]]; then
18
+ glibc_version=$version
19
+ fi
20
+ elif [[ $line == *"GLIBCXX_"* ]]; then
21
+ version=$(echo "$line" | awk '{if ($5 ~ /^[0-9a-fA-F]+$/) print $6; else print $5}' | tr -d '()')
22
+ version=${version#*_}
23
+ if [[ $(printf "%s\n%s" "$version" "$glibcxx_version" | sort -V | tail -n1) == "$version" ]]; then
24
+ glibcxx_version=$version
25
+ fi
26
+ fi
27
+ done < <("$SYSROOT_PATH/../bin/objdump" -T "$file")
28
+
29
+ if [[ "$glibc_version" != "$EXPECTED_GLIBC_VERSION" ]]; then
30
+ echo "Error: File $file has dependency on GLIBC > $EXPECTED_GLIBC_VERSION, found $glibc_version"
31
+ exit 1
32
+ fi
33
+ if [[ "$glibcxx_version" != "$EXPECTED_GLIBCXX_VERSION" ]]; then
34
+ echo "Error: File $file has dependency on GLIBCXX > $EXPECTED_GLIBCXX_VERSION, found $glibcxx_version"
35
+ fi
36
+ done
@@ -31,4 +31,12 @@ if (!fs.existsSync(PREBUILD_DIR)) {
31
31
  process.exit(1);
32
32
  }
33
33
 
34
+ // Ensure spawn-helper has execute permission (may be stripped by npm pack)
35
+ if (process.platform === 'darwin') {
36
+ const spawnHelper = path.join(PREBUILD_DIR, 'spawn-helper');
37
+ if (fs.existsSync(spawnHelper)) {
38
+ fs.chmodSync(spawnHelper, 0o755);
39
+ }
40
+ }
41
+
34
42
  process.exit(0);
package/src/utils.ts CHANGED
@@ -17,7 +17,7 @@ export function loadNativeModule(name: string): {dir: string, module: any} {
17
17
  let lastError: unknown;
18
18
  for (const d of dirs) {
19
19
  for (const r of relative) {
20
- const dir = `${r}/${d}/`;
20
+ const dir = `${r}/${d}`;
21
21
  try {
22
22
  return { dir, module: require(`${dir}/${name}.node`) };
23
23
  } catch (e) {