node-abi 4.28.0 → 4.29.0

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/abi_registry.json CHANGED
@@ -132,8 +132,8 @@
132
132
  "2026-10-28",
133
133
  "2027-10-20"
134
134
  ],
135
- "future": true,
136
- "abi": "144"
135
+ "future": false,
136
+ "abi": "147"
137
137
  },
138
138
  {
139
139
  "abi": "70",
package/getNextTarget.js CHANGED
@@ -1,13 +1,17 @@
1
1
  import semver from 'semver';
2
2
 
3
- export function getNextTarget (runtime, targets) {
4
- const latest = targets.filter((t) => { return t.runtime === runtime }).slice(-1)[0]
5
- const increment = runtime === 'electron' ? 'minor' : 'major'
6
- let next = semver.inc(latest.target, increment)
3
+ export function getNextTarget(runtime, targets) {
4
+ const latest = targets
5
+ .filter((t) => {
6
+ return t.runtime === runtime;
7
+ })
8
+ .slice(-1)[0];
9
+ const increment = runtime === 'electron' ? 'minor' : 'major';
10
+ let next = semver.inc(latest.target, increment);
7
11
  // Electron releases appear in the registry in their beta form, sometimes there is
8
12
  // no active beta line. During this time we need to double bump
9
13
  if (runtime === 'electron' && semver.parse(latest.target).prerelease.length) {
10
- next = semver.inc(next, 'major')
14
+ next = semver.inc(next, 'major');
11
15
  }
12
- return next
16
+ return next;
13
17
  }
package/index.js CHANGED
@@ -6,156 +6,171 @@ import semver from 'semver';
6
6
 
7
7
  import { getNextTarget } from './getNextTarget.js';
8
8
 
9
- export function getAbi (target, runtime) {
10
- if (target === String(Number(target))) return target
11
- if (target) target = target.replace(/^v/, '')
12
- if (!runtime) runtime = 'node'
9
+ export function getAbi(target, runtime) {
10
+ if (target === String(Number(target))) return target;
11
+ if (target) target = target.replace(/^v/, '');
12
+ if (!runtime) runtime = 'node';
13
13
 
14
14
  if (runtime === 'node') {
15
- if (!target) return process.versions.modules
16
- if (target === process.versions.node) return process.versions.modules
15
+ if (!target) return process.versions.modules;
16
+ if (target === process.versions.node) return process.versions.modules;
17
17
  }
18
18
 
19
- let abi
20
- let lastTarget
19
+ let abi;
20
+ let lastTarget;
21
21
 
22
22
  for (let i = 0; i < allTargets.length; i++) {
23
- const t = allTargets[i]
24
- if (t.runtime !== runtime) continue
23
+ const t = allTargets[i];
24
+ if (t.runtime !== runtime) continue;
25
25
  if (semver.lte(t.target, target) && (!lastTarget || semver.gte(t.target, lastTarget))) {
26
- abi = t.abi
27
- lastTarget = t.target
26
+ abi = t.abi;
27
+ lastTarget = t.target;
28
28
  }
29
29
  }
30
30
 
31
- if (abi && semver.lt(target, getNextTarget(runtime, allTargets))) return abi
32
- throw new Error('Could not detect abi for version ' + target + ' and runtime ' + runtime + '. Updating "node-abi" might help solve this issue if it is a new release of ' + runtime)
31
+ if (abi && semver.lt(target, getNextTarget(runtime, allTargets))) return abi;
32
+ throw new Error(
33
+ 'Could not detect abi for version ' +
34
+ target +
35
+ ' and runtime ' +
36
+ runtime +
37
+ '. Updating "node-abi" might help solve this issue if it is a new release of ' +
38
+ runtime,
39
+ );
33
40
  }
34
41
 
35
- export function getTarget (abi, runtime) {
36
- if (abi && abi !== String(Number(abi))) return abi
37
- if (!runtime) runtime = 'node'
42
+ export function getTarget(abi, runtime) {
43
+ if (abi && abi !== String(Number(abi))) return abi;
44
+ if (!runtime) runtime = 'node';
38
45
 
39
- if (runtime === 'node' && !abi) return process.versions.node
46
+ if (runtime === 'node' && !abi) return process.versions.node;
40
47
 
41
48
  const match = allTargets
42
49
  .filter(function (t) {
43
- return t.abi === abi && t.runtime === runtime
50
+ return t.abi === abi && t.runtime === runtime;
44
51
  })
45
52
  .map(function (t) {
46
- return t.target
47
- })
53
+ return t.target;
54
+ });
48
55
  if (match.length) {
49
- const betaSeparatorIndex = match[0].indexOf("-")
50
- return betaSeparatorIndex > -1
51
- ? match[0].substring(0, betaSeparatorIndex)
52
- : match[0]
56
+ const betaSeparatorIndex = match[0].indexOf('-');
57
+ return betaSeparatorIndex > -1 ? match[0].substring(0, betaSeparatorIndex) : match[0];
53
58
  }
54
59
 
55
- throw new Error('Could not detect target for abi ' + abi + ' and runtime ' + runtime)
60
+ throw new Error('Could not detect target for abi ' + abi + ' and runtime ' + runtime);
56
61
  }
57
62
 
58
- function sortByTargetFn (a, b) {
59
- const abiComp = Number(a.abi) - Number(b.abi)
60
- if (abiComp !== 0) return abiComp
61
- if (a.target < b.target) return -1
62
- if (a.target > b.target) return 1
63
- return 0
63
+ function sortByTargetFn(a, b) {
64
+ const abiComp = Number(a.abi) - Number(b.abi);
65
+ if (abiComp !== 0) return abiComp;
66
+ if (a.target < b.target) return -1;
67
+ if (a.target > b.target) return 1;
68
+ return 0;
64
69
  }
65
70
 
66
- function loadGeneratedTargets () {
67
- const registry = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), 'abi_registry.json'), 'utf8'))
71
+ function loadGeneratedTargets() {
72
+ const registry = JSON.parse(
73
+ fs.readFileSync(
74
+ path.join(path.dirname(fileURLToPath(import.meta.url)), 'abi_registry.json'),
75
+ 'utf8',
76
+ ),
77
+ );
68
78
  const targets = {
69
79
  supported: [],
70
80
  additional: [],
71
- future: []
72
- }
81
+ future: [],
82
+ };
73
83
 
74
84
  registry.forEach(function (item) {
75
85
  const target = {
76
86
  runtime: item.runtime,
77
87
  target: item.target,
78
- abi: item.abi
79
- }
88
+ abi: item.abi,
89
+ };
80
90
  if (item.lts) {
81
- const startDate = new Date(Date.parse(item.lts[0]))
82
- const endDate = new Date(Date.parse(item.lts[1]))
83
- const currentDate = new Date()
84
- target.lts = startDate < currentDate && currentDate < endDate
91
+ const startDate = new Date(Date.parse(item.lts[0]));
92
+ const endDate = new Date(Date.parse(item.lts[1]));
93
+ const currentDate = new Date();
94
+ target.lts = startDate < currentDate && currentDate < endDate;
85
95
  } else {
86
- target.lts = false
96
+ target.lts = false;
87
97
  }
88
98
 
89
99
  if (target.runtime === 'node-webkit') {
90
- targets.additional.push(target)
100
+ targets.additional.push(target);
91
101
  } else if (item.future) {
92
- targets.future.push(target)
102
+ targets.future.push(target);
93
103
  } else {
94
- targets.supported.push(target)
104
+ targets.supported.push(target);
95
105
  }
96
- })
106
+ });
97
107
 
98
- targets.supported.sort(sortByTargetFn)
99
- targets.additional.sort(sortByTargetFn)
100
- targets.future.sort(sortByTargetFn)
108
+ targets.supported.sort(sortByTargetFn);
109
+ targets.additional.sort(sortByTargetFn);
110
+ targets.future.sort(sortByTargetFn);
101
111
 
102
- return targets
112
+ return targets;
103
113
  }
104
114
 
105
- const generatedTargets = loadGeneratedTargets()
115
+ const generatedTargets = loadGeneratedTargets();
106
116
 
107
117
  export const supportedTargets = [
108
- {runtime: 'node', target: '5.0.0', abi: '47', lts: false},
109
- {runtime: 'node', target: '6.0.0', abi: '48', lts: false},
110
- {runtime: 'node', target: '7.0.0', abi: '51', lts: false},
111
- {runtime: 'node', target: '8.0.0', abi: '57', lts: false},
112
- {runtime: 'node', target: '9.0.0', abi: '59', lts: false},
113
- {runtime: 'node', target: '10.0.0', abi: '64', lts: new Date(2018, 10, 1) < new Date() && new Date() < new Date(2020, 4, 31)},
114
- {runtime: 'electron', target: '0.36.0', abi: '47', lts: false},
115
- {runtime: 'electron', target: '1.1.0', abi: '48', lts: false},
116
- {runtime: 'electron', target: '1.3.0', abi: '49', lts: false},
117
- {runtime: 'electron', target: '1.4.0', abi: '50', lts: false},
118
- {runtime: 'electron', target: '1.5.0', abi: '51', lts: false},
119
- {runtime: 'electron', target: '1.6.0', abi: '53', lts: false},
120
- {runtime: 'electron', target: '1.7.0', abi: '54', lts: false},
121
- {runtime: 'electron', target: '1.8.0', abi: '57', lts: false},
122
- {runtime: 'electron', target: '2.0.0', abi: '57', lts: false},
123
- {runtime: 'electron', target: '3.0.0', abi: '64', lts: false},
124
- {runtime: 'electron', target: '4.0.0', abi: '64', lts: false},
125
- {runtime: 'electron', target: '4.0.4', abi: '69', lts: false},
126
- ...generatedTargets.supported
127
- ]
118
+ { runtime: 'node', target: '5.0.0', abi: '47', lts: false },
119
+ { runtime: 'node', target: '6.0.0', abi: '48', lts: false },
120
+ { runtime: 'node', target: '7.0.0', abi: '51', lts: false },
121
+ { runtime: 'node', target: '8.0.0', abi: '57', lts: false },
122
+ { runtime: 'node', target: '9.0.0', abi: '59', lts: false },
123
+ {
124
+ runtime: 'node',
125
+ target: '10.0.0',
126
+ abi: '64',
127
+ lts: new Date(2018, 10, 1) < new Date() && new Date() < new Date(2020, 4, 31),
128
+ },
129
+ { runtime: 'electron', target: '0.36.0', abi: '47', lts: false },
130
+ { runtime: 'electron', target: '1.1.0', abi: '48', lts: false },
131
+ { runtime: 'electron', target: '1.3.0', abi: '49', lts: false },
132
+ { runtime: 'electron', target: '1.4.0', abi: '50', lts: false },
133
+ { runtime: 'electron', target: '1.5.0', abi: '51', lts: false },
134
+ { runtime: 'electron', target: '1.6.0', abi: '53', lts: false },
135
+ { runtime: 'electron', target: '1.7.0', abi: '54', lts: false },
136
+ { runtime: 'electron', target: '1.8.0', abi: '57', lts: false },
137
+ { runtime: 'electron', target: '2.0.0', abi: '57', lts: false },
138
+ { runtime: 'electron', target: '3.0.0', abi: '64', lts: false },
139
+ { runtime: 'electron', target: '4.0.0', abi: '64', lts: false },
140
+ { runtime: 'electron', target: '4.0.4', abi: '69', lts: false },
141
+ ...generatedTargets.supported,
142
+ ];
128
143
 
129
144
  export const additionalTargets = [
130
- {runtime: 'node-webkit', target: '0.13.0', abi: '47', lts: false},
131
- {runtime: 'node-webkit', target: '0.15.0', abi: '48', lts: false},
132
- {runtime: 'node-webkit', target: '0.18.3', abi: '51', lts: false},
133
- {runtime: 'node-webkit', target: '0.23.0', abi: '57', lts: false},
134
- {runtime: 'node-webkit', target: '0.26.5', abi: '59', lts: false},
135
- ...generatedTargets.additional
136
- ]
145
+ { runtime: 'node-webkit', target: '0.13.0', abi: '47', lts: false },
146
+ { runtime: 'node-webkit', target: '0.15.0', abi: '48', lts: false },
147
+ { runtime: 'node-webkit', target: '0.18.3', abi: '51', lts: false },
148
+ { runtime: 'node-webkit', target: '0.23.0', abi: '57', lts: false },
149
+ { runtime: 'node-webkit', target: '0.26.5', abi: '59', lts: false },
150
+ ...generatedTargets.additional,
151
+ ];
137
152
 
138
153
  export const deprecatedTargets = [
139
- {runtime: 'node', target: '0.2.0', abi: '1', lts: false},
140
- {runtime: 'node', target: '0.9.1', abi: '0x000A', lts: false},
141
- {runtime: 'node', target: '0.9.9', abi: '0x000B', lts: false},
142
- {runtime: 'node', target: '0.10.4', abi: '11', lts: false},
143
- {runtime: 'node', target: '0.11.0', abi: '0x000C', lts: false},
144
- {runtime: 'node', target: '0.11.8', abi: '13', lts: false},
145
- {runtime: 'node', target: '0.11.11', abi: '14', lts: false},
146
- {runtime: 'node', target: '1.0.0', abi: '42', lts: false},
147
- {runtime: 'node', target: '1.1.0', abi: '43', lts: false},
148
- {runtime: 'node', target: '2.0.0', abi: '44', lts: false},
149
- {runtime: 'node', target: '3.0.0', abi: '45', lts: false},
150
- {runtime: 'node', target: '4.0.0', abi: '46', lts: false},
151
- {runtime: 'electron', target: '0.30.0', abi: '44', lts: false},
152
- {runtime: 'electron', target: '0.31.0', abi: '45', lts: false},
153
- {runtime: 'electron', target: '0.33.0', abi: '46', lts: false}
154
- ]
155
-
156
- export const futureTargets = generatedTargets.future
154
+ { runtime: 'node', target: '0.2.0', abi: '1', lts: false },
155
+ { runtime: 'node', target: '0.9.1', abi: '0x000A', lts: false },
156
+ { runtime: 'node', target: '0.9.9', abi: '0x000B', lts: false },
157
+ { runtime: 'node', target: '0.10.4', abi: '11', lts: false },
158
+ { runtime: 'node', target: '0.11.0', abi: '0x000C', lts: false },
159
+ { runtime: 'node', target: '0.11.8', abi: '13', lts: false },
160
+ { runtime: 'node', target: '0.11.11', abi: '14', lts: false },
161
+ { runtime: 'node', target: '1.0.0', abi: '42', lts: false },
162
+ { runtime: 'node', target: '1.1.0', abi: '43', lts: false },
163
+ { runtime: 'node', target: '2.0.0', abi: '44', lts: false },
164
+ { runtime: 'node', target: '3.0.0', abi: '45', lts: false },
165
+ { runtime: 'node', target: '4.0.0', abi: '46', lts: false },
166
+ { runtime: 'electron', target: '0.30.0', abi: '44', lts: false },
167
+ { runtime: 'electron', target: '0.31.0', abi: '45', lts: false },
168
+ { runtime: 'electron', target: '0.33.0', abi: '46', lts: false },
169
+ ];
170
+
171
+ export const futureTargets = generatedTargets.future;
157
172
 
158
173
  export const allTargets = deprecatedTargets
159
174
  .concat(supportedTargets)
160
175
  .concat(additionalTargets)
161
- .concat(futureTargets)
176
+ .concat(futureTargets);
package/package.json CHANGED
@@ -1,43 +1,61 @@
1
1
  {
2
2
  "name": "node-abi",
3
- "version": "4.28.0",
3
+ "version": "4.29.0",
4
4
  "description": "Get the Node ABI for a given target and runtime, and vice versa.",
5
- "type": "module",
6
- "exports": "./index.js",
7
- "scripts": {
8
- "test": "node --test test/index.js",
9
- "update-abi-registry": "node --unhandled-rejections=strict scripts/update-abi-registry.js"
10
- },
11
- "files": [
12
- "abi_registry.json",
13
- "index.js",
14
- "getNextTarget.js"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/electron/node-abi.git"
19
- },
20
5
  "keywords": [
21
- "node",
6
+ "abi",
22
7
  "electron",
8
+ "node",
23
9
  "node_module_version",
24
- "abi",
25
10
  "v8"
26
11
  ],
27
- "author": "Lukas Geiger",
28
- "license": "MIT",
12
+ "homepage": "https://github.com/electron/node-abi#readme",
29
13
  "bugs": {
30
14
  "url": "https://github.com/electron/node-abi/issues"
31
15
  },
32
- "homepage": "https://github.com/electron/node-abi#readme",
16
+ "license": "MIT",
17
+ "author": "Lukas Geiger",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/electron/node-abi.git"
21
+ },
22
+ "files": [
23
+ "abi_registry.json",
24
+ "index.js",
25
+ "getNextTarget.js"
26
+ ],
27
+ "type": "module",
28
+ "exports": "./index.js",
29
+ "publishConfig": {
30
+ "provenance": true
31
+ },
32
+ "scripts": {
33
+ "test": "node --test test/index.js",
34
+ "lint": "oxfmt --check . && oxlint",
35
+ "lint:fix": "oxfmt --write . && oxlint --fix",
36
+ "update-abi-registry": "node --unhandled-rejections=strict scripts/update-abi-registry.js",
37
+ "prepare": "husky"
38
+ },
33
39
  "dependencies": {
34
40
  "semver": "^7.6.3"
35
41
  },
42
+ "devDependencies": {
43
+ "husky": "^9.1.7",
44
+ "lint-staged": "^16.4.0",
45
+ "oxfmt": "^0.44.0",
46
+ "oxlint": "^1.59.0"
47
+ },
48
+ "lint-staged": {
49
+ "*.{js,mjs,cjs}": [
50
+ "oxfmt --write",
51
+ "oxlint"
52
+ ],
53
+ "*.{json,css,html}": [
54
+ "oxfmt --write"
55
+ ]
56
+ },
36
57
  "engines": {
37
58
  "node": ">=22.12.0"
38
59
  },
39
- "publishConfig": {
40
- "provenance": true
41
- },
42
60
  "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
43
61
  }