koffi 2.3.5 → 2.3.6-beta.1
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/CHANGELOG.md +7 -0
- package/package.json +4 -4
- package/src/cnoke/cnoke.js +40 -834
- package/src/cnoke/package.json +1 -0
- package/src/cnoke/src/builder.js +447 -0
- package/src/cnoke/src/index.js +20 -0
- package/src/cnoke/src/tools.js +401 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.pdb +0 -0
- package/src/koffi/src/ffi.cc +2 -2
- package/src/koffi/src/index.d.ts +3 -3
- package/src/koffi/src/index.js +23 -4
- package/src/koffi/build/2.3.5/koffi_darwin_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_darwin_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_freebsd_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_freebsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_freebsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_linux_arm32hf.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_linux_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_linux_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_linux_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_openbsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_openbsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_win32_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_win32_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.5/koffi_win32_x64.tar.gz +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
// This program is free software: you can redistribute it and/or modify
|
|
2
|
+
// it under the terms of the GNU Lesser General Public License as published by
|
|
3
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
4
|
+
// (at your option) any later version.
|
|
5
|
+
//
|
|
6
|
+
// This program is distributed in the hope that it will be useful,
|
|
7
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9
|
+
// GNU Lesser General Public License for more details.
|
|
10
|
+
//
|
|
11
|
+
// You should have received a copy of the GNU Lesser General Public License
|
|
12
|
+
// along with this program. If not, see https://www.gnu.org/licenses/.
|
|
13
|
+
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
const crypto = require('crypto');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const http = require('https');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const zlib = require('zlib');
|
|
21
|
+
|
|
22
|
+
async function download_http(url, dest) {
|
|
23
|
+
if (Array.isArray(url)) {
|
|
24
|
+
let urls = url;
|
|
25
|
+
|
|
26
|
+
for (let url of urls) {
|
|
27
|
+
try {
|
|
28
|
+
await download_http(url, dest);
|
|
29
|
+
return;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err.code != 404)
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error('All URLs returned error 404');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log('>> Downloading ' + url);
|
|
40
|
+
|
|
41
|
+
let [tmp_name, file] = open_temporary_stream(dest);
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await new Promise((resolve, reject) => {
|
|
45
|
+
let request = http.get(url, response => {
|
|
46
|
+
if (response.statusCode != 200) {
|
|
47
|
+
let err = new Error(`Download failed: ${response.statusMessage} [${response.statusCode}]`);
|
|
48
|
+
err.code = response.statusCode;
|
|
49
|
+
|
|
50
|
+
reject(err);
|
|
51
|
+
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
response.pipe(file);
|
|
56
|
+
|
|
57
|
+
file.on('finish', () => file.close(() => {
|
|
58
|
+
try {
|
|
59
|
+
fs.renameSync(file.path, dest);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
if (err.code != 'EBUSY')
|
|
62
|
+
reject(err);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
resolve();
|
|
66
|
+
}));
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
request.on('error', reject);
|
|
70
|
+
file.on('error', reject);
|
|
71
|
+
});
|
|
72
|
+
} catch (err) {
|
|
73
|
+
file.close();
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
fs.unlinkSync(tmp_name);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
if (err.code != 'ENOENT')
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function open_temporary_stream(prefix) {
|
|
87
|
+
let buf = Buffer.allocUnsafe(4);
|
|
88
|
+
|
|
89
|
+
for (;;) {
|
|
90
|
+
try {
|
|
91
|
+
crypto.randomFillSync(buf);
|
|
92
|
+
|
|
93
|
+
let suffix = buf.toString('hex').padStart(8, '0');
|
|
94
|
+
let filename = `${prefix}.${suffix}`;
|
|
95
|
+
|
|
96
|
+
let file = fs.createWriteStream(filename, { flags: 'wx', mode: 0o644 });
|
|
97
|
+
return [filename, file];
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (err.code != 'EEXIST')
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function extract_targz(filename, dest_dir, strip = 0) {
|
|
106
|
+
let reader = fs.createReadStream(filename).pipe(zlib.createGunzip());
|
|
107
|
+
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
let header = null;
|
|
110
|
+
let extended = {};
|
|
111
|
+
|
|
112
|
+
reader.on('readable', () => {
|
|
113
|
+
try {
|
|
114
|
+
for (;;) {
|
|
115
|
+
if (header == null) {
|
|
116
|
+
let buf = reader.read(512);
|
|
117
|
+
if (buf == null)
|
|
118
|
+
break;
|
|
119
|
+
|
|
120
|
+
// Two zeroed 512-byte blocks end the stream
|
|
121
|
+
if (!buf[0])
|
|
122
|
+
continue;
|
|
123
|
+
|
|
124
|
+
header = {
|
|
125
|
+
filename: buf.toString('utf-8', 0, 100).replace(/\0/g, ''),
|
|
126
|
+
mode: parseInt(buf.toString('ascii', 100, 109), 8),
|
|
127
|
+
size: parseInt(buf.toString('ascii', 124, 137), 8),
|
|
128
|
+
type: String.fromCharCode(buf[156])
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// UStar filename prefix
|
|
132
|
+
/*if (buf.toString('ascii', 257, 263) == 'ustar\0') {
|
|
133
|
+
let prefix = buf.toString('utf-8', 345, 500).replace(/\0/g, '');
|
|
134
|
+
console.log(prefix);
|
|
135
|
+
header.filename = prefix ? (prefix + '/' + header.filename) : header.filename;
|
|
136
|
+
}*/
|
|
137
|
+
|
|
138
|
+
Object.assign(header, extended);
|
|
139
|
+
extended = {};
|
|
140
|
+
|
|
141
|
+
// Safety checks
|
|
142
|
+
header.filename = header.filename.replace(/\\/g, '/');
|
|
143
|
+
if (!header.filename.length)
|
|
144
|
+
throw new Error(`Insecure empty filename inside TAR archive`);
|
|
145
|
+
if (path_is_absolute(header.filename[0]))
|
|
146
|
+
throw new Error(`Insecure filename starting with / inside TAR archive`);
|
|
147
|
+
if (path_has_dotdot(header.filename))
|
|
148
|
+
throw new Error(`Insecure filename containing '..' inside TAR archive`);
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < strip; i++)
|
|
151
|
+
header.filename = header.filename.substr(header.filename.indexOf('/') + 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let aligned = Math.floor((header.size + 511) / 512) * 512;
|
|
155
|
+
let data = header.size ? reader.read(aligned) : null;
|
|
156
|
+
if (data == null) {
|
|
157
|
+
if (header.size)
|
|
158
|
+
break;
|
|
159
|
+
data = Buffer.alloc(0);
|
|
160
|
+
}
|
|
161
|
+
data = data.subarray(0, header.size);
|
|
162
|
+
|
|
163
|
+
if (header.type == '0' || header.type == '7') {
|
|
164
|
+
let filename = dest_dir + '/' + header.filename;
|
|
165
|
+
let dirname = path.dirname(filename);
|
|
166
|
+
|
|
167
|
+
fs.mkdirSync(dirname, { recursive: true, mode: 0o755 });
|
|
168
|
+
fs.writeFileSync(filename, data, { mode: header.mode });
|
|
169
|
+
} else if (header.type == '5') {
|
|
170
|
+
let filename = dest_dir + '/' + header.filename;
|
|
171
|
+
fs.mkdirSync(filename, { recursive: true, mode: header.mode });
|
|
172
|
+
} else if (header.type == 'L') { // GNU tar
|
|
173
|
+
extended.filename = data.toString('utf-8').replace(/\0/g, '');
|
|
174
|
+
} else if (header.type == 'x') { // PAX entry
|
|
175
|
+
let str = data.toString('utf-8');
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
while (str.length) {
|
|
179
|
+
let matches = str.match(/^([0-9]+) ([a-zA-Z0-9\._]+)=(.*)\n/);
|
|
180
|
+
|
|
181
|
+
let skip = parseInt(matches[1], 10);
|
|
182
|
+
let key = matches[2];
|
|
183
|
+
let value = matches[3];
|
|
184
|
+
|
|
185
|
+
switch (key) {
|
|
186
|
+
case 'path': { extended.filename = value; } break;
|
|
187
|
+
case 'size': { extended.size = parseInt(value, 10); } break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
str = str.substr(skip).trimStart();
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
throw new Error('Malformed PAX entry');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
header = null;
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
reject(err);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
reader.on('error', reject);
|
|
205
|
+
reader.on('end', resolve);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function path_is_absolute(path) {
|
|
210
|
+
if (process.platform == 'win32' && path.match(/^[a-zA-Z]:/))
|
|
211
|
+
path = path.substr(2);
|
|
212
|
+
return is_path_separator(path[0]);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function path_has_dotdot(path) {
|
|
216
|
+
let start = 0;
|
|
217
|
+
|
|
218
|
+
for (;;) {
|
|
219
|
+
let offset = path.indexOf('..', start);
|
|
220
|
+
if (offset < 0)
|
|
221
|
+
break;
|
|
222
|
+
start = offset + 2;
|
|
223
|
+
|
|
224
|
+
if (offset && !is_path_separator(path[offset - 1]))
|
|
225
|
+
continue;
|
|
226
|
+
if (offset + 2 < path.length && !is_path_separator(path[offset + 2]))
|
|
227
|
+
continue;
|
|
228
|
+
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function is_path_separator(c) {
|
|
236
|
+
if (c == '/')
|
|
237
|
+
return true;
|
|
238
|
+
if (process.platform == 'win32' && c == '\\')
|
|
239
|
+
return true;
|
|
240
|
+
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function determine_arch() {
|
|
245
|
+
let arch = process.arch;
|
|
246
|
+
|
|
247
|
+
if (arch == 'riscv32' || arch == 'riscv64') {
|
|
248
|
+
let buf = read_file_header(process.execPath, 512);
|
|
249
|
+
let header = decode_elf_header(buf);
|
|
250
|
+
let float_abi = (header.e_flags & 0x6) >> 1;
|
|
251
|
+
|
|
252
|
+
switch (float_abi) {
|
|
253
|
+
case 0: { arch += 'sf'; } break;
|
|
254
|
+
case 1: { arch += 'hf32'; } break;
|
|
255
|
+
case 2: { arch += 'hf64'; } break;
|
|
256
|
+
case 3: { arch += 'hf128'; } break;
|
|
257
|
+
}
|
|
258
|
+
} else if (arch == 'arm') {
|
|
259
|
+
arch = 'arm32';
|
|
260
|
+
|
|
261
|
+
let buf = read_file_header(process.execPath, 512);
|
|
262
|
+
let header = decode_elf_header(buf);
|
|
263
|
+
|
|
264
|
+
if (header.e_flags & 0x400) {
|
|
265
|
+
arch += 'hf';
|
|
266
|
+
} else if (header.e_flags & 0x200) {
|
|
267
|
+
arch += 'sf';
|
|
268
|
+
} else {
|
|
269
|
+
throw new Error('Unknown ARM floating-point ABI');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return arch;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function read_file_header(filename, read) {
|
|
277
|
+
let fd = null;
|
|
278
|
+
|
|
279
|
+
try {
|
|
280
|
+
let fd = fs.openSync(filename);
|
|
281
|
+
|
|
282
|
+
let buf = Buffer.allocUnsafe(read);
|
|
283
|
+
let len = fs.readSync(fd, buf);
|
|
284
|
+
|
|
285
|
+
return buf.subarray(0, len);
|
|
286
|
+
} finally {
|
|
287
|
+
if (fd != null)
|
|
288
|
+
fs.closeSync(fd);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function decode_elf_header(buf) {
|
|
293
|
+
let header = {};
|
|
294
|
+
|
|
295
|
+
if (buf.length < 16)
|
|
296
|
+
throw new Error('Truncated header');
|
|
297
|
+
if (buf[0] != 0x7F || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
298
|
+
throw new Error('Invalid magic number');
|
|
299
|
+
if (buf[6] != 1)
|
|
300
|
+
throw new Error('Invalid ELF version');
|
|
301
|
+
if (buf[5] != 1)
|
|
302
|
+
throw new Error('Big-endian architectures are not supported');
|
|
303
|
+
|
|
304
|
+
let machine = buf.readUInt16LE(18);
|
|
305
|
+
|
|
306
|
+
switch (machine) {
|
|
307
|
+
case 3: { header.e_machine = 'ia32'; } break;
|
|
308
|
+
case 40: { header.e_machine = 'arm'; } break;
|
|
309
|
+
case 62: { header.e_machine = 'amd64'; } break;
|
|
310
|
+
case 183: { header.e_machine = 'arm64'; } break;
|
|
311
|
+
case 243: {
|
|
312
|
+
switch (buf[4]) {
|
|
313
|
+
case 1: { header.e_machine = 'riscv32'; } break;
|
|
314
|
+
case 2: { header.e_machine = 'riscv64'; } break;
|
|
315
|
+
}
|
|
316
|
+
} break;
|
|
317
|
+
default: throw new Error('Unknown ELF machine type');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
switch (buf[4]) {
|
|
321
|
+
case 1: { // 32 bit
|
|
322
|
+
buf = buf.subarray(0, 68);
|
|
323
|
+
if (buf.length < 68)
|
|
324
|
+
throw new Error('Truncated ELF header');
|
|
325
|
+
|
|
326
|
+
header.ei_class = 32;
|
|
327
|
+
header.e_flags = buf.readUInt32LE(36);
|
|
328
|
+
} break;
|
|
329
|
+
case 2: { // 64 bit
|
|
330
|
+
buf = buf.subarray(0, 120);
|
|
331
|
+
if (buf.length < 120)
|
|
332
|
+
throw new Error('Truncated ELF header');
|
|
333
|
+
|
|
334
|
+
header.ei_class = 64;
|
|
335
|
+
header.e_flags = buf.readUInt32LE(48);
|
|
336
|
+
} break;
|
|
337
|
+
default: throw new Error('Invalid ELF class');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return header;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function unlink_recursive(path) {
|
|
344
|
+
try {
|
|
345
|
+
if (fs.rmSync != null) {
|
|
346
|
+
fs.rmSync(path, { recursive: true, maxRetries: process.platform == 'win32' ? 3 : 0 });
|
|
347
|
+
} else {
|
|
348
|
+
fs.rmdirSync(path, { recursive: true, maxRetries: process.platform == 'win32' ? 3 : 0 });
|
|
349
|
+
}
|
|
350
|
+
} catch (err) {
|
|
351
|
+
if (err.code !== 'ENOENT')
|
|
352
|
+
throw err;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function get_napi_version(napi, major) {
|
|
357
|
+
if (napi > 8)
|
|
358
|
+
return null;
|
|
359
|
+
|
|
360
|
+
// https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
361
|
+
const support = {
|
|
362
|
+
6: ['6.14.2', '6.14.2', '6.14.2'],
|
|
363
|
+
8: ['8.6.0', '8.10.0', '8.11.2'],
|
|
364
|
+
9: ['9.0.0', '9.3.0', '9.11.0'],
|
|
365
|
+
10: ['10.0.0', '10.0.0', '10.0.0', '10.16.0', '10.17.0', '10.20.0', '10.23.0'],
|
|
366
|
+
11: ['11.0.0', '11.0.0', '11.0.0', '11.8.0'],
|
|
367
|
+
12: ['12.0.0', '12.0.0', '12.0.0', '12.0.0', '12.11.0', '12.17.0', '12.19.0', '12.22.0'],
|
|
368
|
+
13: ['13.0.0', '13.0.0', '13.0.0', '13.0.0', '13.0.0'],
|
|
369
|
+
14: ['14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.12.0', '14.17.0'],
|
|
370
|
+
15: ['15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.12.0']
|
|
371
|
+
};
|
|
372
|
+
const max = Math.max(...Object.keys(support).map(k => parseInt(k, 10)));
|
|
373
|
+
|
|
374
|
+
if (major > max)
|
|
375
|
+
return major + '.0.0';
|
|
376
|
+
if (support[major] == null)
|
|
377
|
+
return null;
|
|
378
|
+
|
|
379
|
+
let required = support[major][napi - 1] || null;
|
|
380
|
+
return required;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Ignores prerelease suffixes
|
|
384
|
+
function cmp_version(ver1, ver2) {
|
|
385
|
+
ver1 = String(ver1).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
386
|
+
ver2 = String(ver2).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
387
|
+
|
|
388
|
+
let cmp = Math.min(Math.max(ver1 - ver2, -1), 1);
|
|
389
|
+
return cmp;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
module.exports = {
|
|
393
|
+
download_http,
|
|
394
|
+
extract_targz,
|
|
395
|
+
path_is_absolute,
|
|
396
|
+
path_has_dotdot,
|
|
397
|
+
determine_arch,
|
|
398
|
+
unlink_recursive,
|
|
399
|
+
get_napi_version,
|
|
400
|
+
cmp_version
|
|
401
|
+
};
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -2021,8 +2021,8 @@ static void SetExports(Napi::Env env, Func func)
|
|
|
2021
2021
|
|
|
2022
2022
|
func("struct", Napi::Function::New(env, CreatePaddedStructType));
|
|
2023
2023
|
func("pack", Napi::Function::New(env, CreatePackedStructType));
|
|
2024
|
-
func("union", Napi::Function::New(env, CreateUnionType));
|
|
2025
|
-
func("Union", Napi::Function::New(env, InstantiateUnion));
|
|
2024
|
+
// func("union", Napi::Function::New(env, CreateUnionType));
|
|
2025
|
+
// func("Union", Napi::Function::New(env, InstantiateUnion));
|
|
2026
2026
|
func("opaque", Napi::Function::New(env, CreateOpaqueType));
|
|
2027
2027
|
func("pointer", Napi::Function::New(env, CreatePointerType));
|
|
2028
2028
|
func("array", Napi::Function::New(env, CreateArrayType));
|
package/src/koffi/src/index.d.ts
CHANGED
|
@@ -78,10 +78,10 @@ declare module 'koffi' {
|
|
|
78
78
|
export function pack(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
79
79
|
export function pack(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
80
80
|
|
|
81
|
-
export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
82
|
-
export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
81
|
+
// export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
82
|
+
// export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
|
|
83
83
|
|
|
84
|
-
export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null);
|
|
84
|
+
export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null): IKoffiCType;
|
|
85
85
|
|
|
86
86
|
export function opaque(name: string): IKoffiCType;
|
|
87
87
|
export function opaque(): IKoffiCType;
|
package/src/koffi/src/index.js
CHANGED
|
@@ -13,12 +13,31 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const package = require('../package.json');
|
|
17
|
+
const cnoke = require('../../cnoke');
|
|
19
18
|
const util = require('util');
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
if (process.versions.napi == null || process.versions.napi < 8) {
|
|
21
|
+
let major = parseInt(process.versions.node, 10);
|
|
22
|
+
let required = cnoke.get_napi_version(8, major);
|
|
23
|
+
|
|
24
|
+
if (required != null) {
|
|
25
|
+
throw new Error(`Project ${pkg.name} requires Node >= ${required} in the Node ${major}.x branch (N-API >= 8)`);
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error(`Project ${pkg.name} does not support the Node ${major}.x branch (N-API < 8)`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let arch = cnoke.determine_arch();
|
|
32
|
+
let filename = __dirname + `/../build/${package.version}/koffi_${process.platform}_${arch}/koffi.node`;
|
|
33
|
+
|
|
34
|
+
// Development build
|
|
35
|
+
if (!fs.existsSync(filename)) {
|
|
36
|
+
let alternative = __dirname + '/../build/koffi.node';
|
|
37
|
+
if (fs.existsSync(alternative))
|
|
38
|
+
filename = alternative;
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
let native = require(filename);
|
|
23
42
|
|
|
24
43
|
module.exports = {
|
|
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
|