@vscodium/native-keymap 3.3.7-258421 → 3.3.7-258423
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/checksum.txt +22 -0
- package/install.js +274 -0
- package/package.json +5 -5
package/checksum.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
fefb5f22b365fb31a684b88d52a006ece40cb9187112f8311373e60a8acee683 native-keymap-3.3.7-258423-darwin-arm64.tar.gz
|
|
2
|
+
ff8ba051903e8ebbcf87dc370d3566ba7b048c51b051c545a6c4151aba7bd2ef native-keymap-3.3.7-258423-darwin-x64.tar.gz
|
|
3
|
+
9956527fe4c14fe4a2d1ff0e67503d6585918372dd81aaafab4fd7a6c4d7354b native-keymap-3.3.7-258423-linux-arm64.tar.gz
|
|
4
|
+
edb962b5111848917a8b00b1aa8d3a69e2a74cb1a49b2d5639d0531e0a71fa89 native-keymap-3.3.7-258423-linux-armhf.tar.gz
|
|
5
|
+
f7f21c5e48f5bf0a8e9dd87e1fac7fde2b45b9578b6ed8305a52430de568843c native-keymap-3.3.7-258423-linux-loong64.tar.gz
|
|
6
|
+
f93f2e8c11250f58167b699e37289fff90d5122f8f1232e23403e83a533245ae native-keymap-3.3.7-258423-linux-ppc64le.tar.gz
|
|
7
|
+
8e186aefe8155868c5c34fe664892b09d16a996bef02541a47a0c60f4b08f566 native-keymap-3.3.7-258423-linux-riscv64.tar.gz
|
|
8
|
+
f9f22a0e64fb2e317cab7ed36ffd17a88b53e64372f88a1e752fbfe8d5407637 native-keymap-3.3.7-258423-linux-s390x.tar.gz
|
|
9
|
+
d9fba94176ca7b5d25e282e457548abc24050891618f159bc37fa11bbe454e03 native-keymap-3.3.7-258423-linux-x64.tar.gz
|
|
10
|
+
bb245def8e5eff5ef069b72d766c3cd3cfcc4d7a7721e53b21a3ddd990b2f7d2 *native-keymap-3.3.7-258423-win32-arm64.tar.gz
|
|
11
|
+
6c0632c10bda1b6af0f810de14e007596eb53069f4a605477a6caf4dd2b00dae *native-keymap-3.3.7-258423-win32-x64.tar.gz
|
|
12
|
+
fefb5f22b365fb31a684b88d52a006ece40cb9187112f8311373e60a8acee683 native-keymap-3.3.7-258423-darwin-arm64.tar.gz
|
|
13
|
+
ff8ba051903e8ebbcf87dc370d3566ba7b048c51b051c545a6c4151aba7bd2ef native-keymap-3.3.7-258423-darwin-x64.tar.gz
|
|
14
|
+
9956527fe4c14fe4a2d1ff0e67503d6585918372dd81aaafab4fd7a6c4d7354b native-keymap-3.3.7-258423-linux-arm64.tar.gz
|
|
15
|
+
edb962b5111848917a8b00b1aa8d3a69e2a74cb1a49b2d5639d0531e0a71fa89 native-keymap-3.3.7-258423-linux-armhf.tar.gz
|
|
16
|
+
f7f21c5e48f5bf0a8e9dd87e1fac7fde2b45b9578b6ed8305a52430de568843c native-keymap-3.3.7-258423-linux-loong64.tar.gz
|
|
17
|
+
f93f2e8c11250f58167b699e37289fff90d5122f8f1232e23403e83a533245ae native-keymap-3.3.7-258423-linux-ppc64le.tar.gz
|
|
18
|
+
8e186aefe8155868c5c34fe664892b09d16a996bef02541a47a0c60f4b08f566 native-keymap-3.3.7-258423-linux-riscv64.tar.gz
|
|
19
|
+
f9f22a0e64fb2e317cab7ed36ffd17a88b53e64372f88a1e752fbfe8d5407637 native-keymap-3.3.7-258423-linux-s390x.tar.gz
|
|
20
|
+
d9fba94176ca7b5d25e282e457548abc24050891618f159bc37fa11bbe454e03 native-keymap-3.3.7-258423-linux-x64.tar.gz
|
|
21
|
+
bb245def8e5eff5ef069b72d766c3cd3cfcc4d7a7721e53b21a3ddd990b2f7d2 *native-keymap-3.3.7-258423-win32-arm64.tar.gz
|
|
22
|
+
6c0632c10bda1b6af0f810de14e007596eb53069f4a605477a6caf4dd2b00dae *native-keymap-3.3.7-258423-win32-x64.tar.gz
|
package/install.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const crypto = require('node:crypto');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const fsp = fs.promises;
|
|
7
|
+
const http = require('node:http');
|
|
8
|
+
const https = require('node:https');
|
|
9
|
+
const os = require('node:os');
|
|
10
|
+
const path = require('node:path');
|
|
11
|
+
const { pipeline } = require('node:stream');
|
|
12
|
+
const { promisify } = require('node:util');
|
|
13
|
+
const tar = require('tar');
|
|
14
|
+
const { spawnSync } = require('node:child_process');
|
|
15
|
+
|
|
16
|
+
const pipelineAsync = promisify(pipeline);
|
|
17
|
+
const PACKAGE_ROOT = path.resolve(__dirname);
|
|
18
|
+
const PACKAGE_JSON = require(path.join(PACKAGE_ROOT, 'package.json'));
|
|
19
|
+
const PACKAGE_VERSION = PACKAGE_JSON.version;
|
|
20
|
+
const RELEASE_TAG = PACKAGE_VERSION.startsWith('v') ? PACKAGE_VERSION : `v${PACKAGE_VERSION}`;
|
|
21
|
+
const DEFAULT_BASE_URL = 'https://github.com/VSCodium/native-keymap/releases/download';
|
|
22
|
+
const LOCAL_CHECKSUM_PATH = path.join(PACKAGE_ROOT, 'checksum.txt');
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
const intent = computeDownloadIntent();
|
|
26
|
+
if (!intent.shouldDownload) {
|
|
27
|
+
runNodeGypRebuild(intent.reason);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const destination = await downloadPrebuilt(intent.platform, intent.arch);
|
|
33
|
+
console.log(`[native-keymap] Installed prebuilt binary to ${destination}`);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.warn(`[native-keymap] Unable to download prebuilt binary (${error.message}). Falling back to source build.`);
|
|
36
|
+
runNodeGypRebuild();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function computeDownloadIntent() {
|
|
41
|
+
if (shouldForceSourceBuild()) {
|
|
42
|
+
return { shouldDownload: false, reason: 'download explicitly disabled' };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const platform = resolvePlatform();
|
|
46
|
+
if (!platform) {
|
|
47
|
+
return { shouldDownload: false, reason: `unsupported platform (${process.platform})` };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const arch = resolveArch();
|
|
51
|
+
if (!arch) {
|
|
52
|
+
return { shouldDownload: false, reason: `unsupported architecture (${process.arch})` };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { shouldDownload: true, platform, arch };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function shouldForceSourceBuild() {
|
|
59
|
+
if (isFalse(process.env.npm_config_build_from_source_native_keymap)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return isTrue(process.env.NATIVE_KEYMAP_SKIP_PREBUILT) ||
|
|
64
|
+
isTrue(process.env.npm_config_build_from_source) ||
|
|
65
|
+
isTrue(process.env.BUILD_FROM_SOURCE) ||
|
|
66
|
+
isTrue(process.env.npm_config_build_from_source_native_keymap);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isFalse(value) {
|
|
70
|
+
if (!value) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const normalized = String(value).toLowerCase();
|
|
74
|
+
return normalized === '0' || normalized === 'false' || normalized === 'no';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isTrue(value) {
|
|
78
|
+
if (!value) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const normalized = String(value).toLowerCase();
|
|
82
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function resolvePlatform() {
|
|
86
|
+
const rawPlatform = (process.env.npm_config_platform || process.platform || '').toLowerCase();
|
|
87
|
+
switch (rawPlatform) {
|
|
88
|
+
case 'linux':
|
|
89
|
+
return 'linux';
|
|
90
|
+
case 'darwin':
|
|
91
|
+
return 'darwin';
|
|
92
|
+
case 'win32':
|
|
93
|
+
return 'win32';
|
|
94
|
+
default:
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function resolveArch() {
|
|
100
|
+
const rawArch = (process.env.npm_config_target_arch || process.env.npm_config_arch || process.arch || '').toLowerCase();
|
|
101
|
+
switch (rawArch) {
|
|
102
|
+
case 'x64':
|
|
103
|
+
return 'x64';
|
|
104
|
+
case 'arm64':
|
|
105
|
+
case 'aarch64':
|
|
106
|
+
return 'arm64';
|
|
107
|
+
case 'arm':
|
|
108
|
+
case 'armhf':
|
|
109
|
+
case 'armv7l':
|
|
110
|
+
return 'armhf';
|
|
111
|
+
case 'riscv64':
|
|
112
|
+
return 'riscv64';
|
|
113
|
+
case 'loong64':
|
|
114
|
+
case 'loongarch64':
|
|
115
|
+
return 'loong64';
|
|
116
|
+
case 'ppc64':
|
|
117
|
+
case 'ppc64le':
|
|
118
|
+
return 'ppc64le';
|
|
119
|
+
case 's390x':
|
|
120
|
+
return 's390x';
|
|
121
|
+
default:
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function downloadPrebuilt(platform, arch) {
|
|
127
|
+
const assetName = `native-keymap-${PACKAGE_VERSION}-${platform}-${arch}.tar.gz`;
|
|
128
|
+
const baseUrl = process.env.NATIVE_KEYMAP_PREBUILT_BASE_URL || DEFAULT_BASE_URL;
|
|
129
|
+
const downloadUrl = `${baseUrl}/${RELEASE_TAG}/${assetName}`;
|
|
130
|
+
console.log(`[native-keymap] Downloading ${assetName} (${platform}/${arch})`);
|
|
131
|
+
|
|
132
|
+
const tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'native-keymap-'));
|
|
133
|
+
const archivePath = path.join(tmpDir, assetName);
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
await downloadFile(downloadUrl, archivePath);
|
|
137
|
+
const checksumRaw = await loadChecksumManifest();
|
|
138
|
+
const expectedHash = parseChecksum(checksumRaw, assetName);
|
|
139
|
+
await verifySha256(archivePath, expectedHash);
|
|
140
|
+
await tar.x({ file: archivePath, cwd: tmpDir });
|
|
141
|
+
const binaryPath = path.join(tmpDir, 'keymapping.node');
|
|
142
|
+
await fsp.access(binaryPath, fs.constants.R_OK);
|
|
143
|
+
|
|
144
|
+
const outputDir = path.join(PACKAGE_ROOT, 'build', 'Release');
|
|
145
|
+
await fsp.mkdir(outputDir, { recursive: true });
|
|
146
|
+
const destination = path.join(outputDir, 'keymapping.node');
|
|
147
|
+
await fsp.copyFile(binaryPath, destination);
|
|
148
|
+
return destination;
|
|
149
|
+
} finally {
|
|
150
|
+
await cleanup(tmpDir);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function downloadFile(url, destination) {
|
|
155
|
+
const response = await httpGet(url);
|
|
156
|
+
await pipelineAsync(response, fs.createWriteStream(destination));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function loadChecksumManifest() {
|
|
160
|
+
try {
|
|
161
|
+
const content = await fsp.readFile(LOCAL_CHECKSUM_PATH, 'utf8');
|
|
162
|
+
return content;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (error.code && error.code !== 'ENOENT') {
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function httpGet(url, redirects = 0) {
|
|
171
|
+
const parsedUrl = new URL(url);
|
|
172
|
+
const client = parsedUrl.protocol === 'http:' ? http : https;
|
|
173
|
+
const requestOptions = {
|
|
174
|
+
protocol: parsedUrl.protocol,
|
|
175
|
+
hostname: parsedUrl.hostname,
|
|
176
|
+
port: parsedUrl.port,
|
|
177
|
+
path: `${parsedUrl.pathname}${parsedUrl.search}`,
|
|
178
|
+
headers: {
|
|
179
|
+
'User-Agent': 'native-keymap-install-script',
|
|
180
|
+
'Accept': '*/*'
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const request = client.get(requestOptions, (response) => {
|
|
186
|
+
const status = response.statusCode || 0;
|
|
187
|
+
if (status >= 300 && status < 400 && response.headers.location) {
|
|
188
|
+
response.resume();
|
|
189
|
+
if (redirects > 5) {
|
|
190
|
+
reject(new Error(`Too many redirects trying to reach ${url}`));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const redirectUrl = new URL(response.headers.location, parsedUrl).toString();
|
|
194
|
+
resolve(httpGet(redirectUrl, redirects + 1));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (status !== 200) {
|
|
198
|
+
response.resume();
|
|
199
|
+
reject(new Error(`Request to ${url} failed with status ${status}`));
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
resolve(response);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
request.on('error', reject);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function parseChecksum(raw, assetName) {
|
|
210
|
+
const entries = raw
|
|
211
|
+
.split(/\r?\n/)
|
|
212
|
+
.map((line) => line.trim())
|
|
213
|
+
.filter(Boolean);
|
|
214
|
+
|
|
215
|
+
if (entries.length === 0) {
|
|
216
|
+
throw new Error('Checksum file is empty');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const entry of entries) {
|
|
220
|
+
const [hash, ...rest] = entry.split(/\s+/);
|
|
221
|
+
if (!hash) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const target = rest.join(' ');
|
|
225
|
+
if (target === assetName) {
|
|
226
|
+
return hash.toLowerCase();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
throw new Error(`Unable to find checksum entry for ${assetName}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function verifySha256(filePath, expectedHash) {
|
|
234
|
+
const hash = crypto.createHash('sha256');
|
|
235
|
+
await new Promise((resolve, reject) => {
|
|
236
|
+
const stream = fs.createReadStream(filePath);
|
|
237
|
+
stream.on('data', (chunk) => hash.update(chunk));
|
|
238
|
+
stream.on('error', reject);
|
|
239
|
+
stream.on('end', resolve);
|
|
240
|
+
});
|
|
241
|
+
const digest = hash.digest('hex');
|
|
242
|
+
if (digest !== expectedHash) {
|
|
243
|
+
throw new Error(`Checksum mismatch (expected ${expectedHash}, got ${digest})`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function cleanup(dirPath) {
|
|
248
|
+
if (!dirPath) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
await fsp.rm(dirPath, { recursive: true, force: true });
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.warn(`[native-keymap] Unable to cleanup temporary files: ${error.message}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function runNodeGypRebuild(reason) {
|
|
259
|
+
if (reason) {
|
|
260
|
+
console.log(`[native-keymap] Skipping prebuilt download: ${reason}`);
|
|
261
|
+
}
|
|
262
|
+
const nodeGypScript = process.env.npm_config_node_gyp;
|
|
263
|
+
const exec = nodeGypScript ? process.execPath : (process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp');
|
|
264
|
+
const args = nodeGypScript ? [nodeGypScript, 'rebuild'] : ['rebuild'];
|
|
265
|
+
const result = spawnSync(exec, args, { stdio: 'inherit' });
|
|
266
|
+
if (result.status !== 0) {
|
|
267
|
+
throw new Error('node-gyp rebuild failed');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
main().catch((error) => {
|
|
272
|
+
console.error(`[native-keymap] Installation failed: ${error.stack || error.message}`);
|
|
273
|
+
process.exit(1);
|
|
274
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscodium/native-keymap",
|
|
3
|
-
"version": "3.3.7-
|
|
3
|
+
"version": "3.3.7-258423",
|
|
4
4
|
"description": "Get OS key mapping",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"install": "
|
|
8
|
+
"install": "node install.js",
|
|
9
9
|
"release": "release-it --no-increment",
|
|
10
10
|
"test": "node test/test.js"
|
|
11
11
|
},
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "Microsoft Corporation",
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"prebuild-install": "^7.1.3"
|
|
20
|
-
},
|
|
21
18
|
"devDependencies": {
|
|
22
19
|
"release-it": "^19.1.0"
|
|
23
20
|
},
|
|
@@ -25,5 +22,8 @@
|
|
|
25
22
|
"branches": [
|
|
26
23
|
"main"
|
|
27
24
|
]
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"tar": "^7.5.2"
|
|
28
28
|
}
|
|
29
29
|
}
|