Skip to content

Commit aef102b

Browse files
committed
feat: display electron's chromium and node v8 version
1 parent 88f9b90 commit aef102b

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
A quick way to get the v8/Node.js/Electron version of a v8-bytecode file, typically produced by [bytenode](https://github.com/bytenode/bytenode).
44

5+
Electron uses different v8 versions for Chromium and Node.js.
6+
In this case, the bytecode file will have the hash from Chromium's v8 but it is actually built with Node.js's v8.
7+
58
## Changes of this fork
69

710
- Pure JS implementation, no rust/wasm

assets/analyzer.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ export function checkSignature(magicNumber) {
55
}
66

77
export function findVersions(hash) {
8-
const candidates = versions.filter((release) => release.hash === hash);
9-
return {
10-
v8: [...new Set(candidates.map((v) => v.v8))],
11-
node: candidates.filter((v) => v.type === "node"),
12-
electron: candidates.filter((v) => v.type === "electron"),
13-
};
8+
const result = { node: [], electron: [] };
9+
10+
for (const candidate of versions.filter((release) => release.hash === hash)) {
11+
result[candidate.type].push(candidate);
12+
13+
if (candidate.type === "electron") {
14+
const nodeCandidate = versions.find(
15+
(release) =>
16+
release.type === "node" && release.version === "v" + candidate.node
17+
);
18+
if (nodeCandidate) {
19+
candidate.v8Node = nodeCandidate.v8;
20+
}
21+
}
22+
}
23+
24+
return result;
1425
}
1526

1627
const versions = await hashVersions();

assets/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ submit.addEventListener('click', async () => {
3131
const hashStr = view[1].toString(16).padStart(8, '0');
3232

3333
output.value += `File signature is ${valid ? 'valid' : 'invalid'}!\n\n`;
34-
output.value += `V8 Version: ${versions.v8} (hash: ${hashStr})\n\n`;
34+
output.value += `Hash: ${hashStr}\n\n`;
3535

3636
if (versions.node.length) {
3737
output.value += `Possible Node Versions:\n${versions.node
38-
.map(v => `- ${v.version}`)
38+
.map(v => `- ${v.version} (v8 ${v.v8})`)
3939
.join('\n')}\n`;
4040
} else if (versions.electron.length) {
4141
output.value += `Possible Electron Versions:\n${versions.electron
42-
.map(v => `- ${v.version} (Node ${v.node})`)
42+
.map(v => `- ${v.version}
43+
- Chromium: v8 ${v.v8}
44+
- Node ${v.node}: v8 ${v.v8Node}`)
4345
.join('\n')}\n`;
4446
} else {
4547
output.value += `No Node or Electron versions found for this V8 version.\n`;

0 commit comments

Comments
 (0)