koffi 2.8.9 → 2.8.11

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 (50) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/koffi/darwin_arm64/koffi.node +0 -0
  3. package/build/koffi/darwin_x64/koffi.node +0 -0
  4. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  5. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  6. package/build/koffi/freebsd_x64/koffi.node +0 -0
  7. package/build/koffi/linux_arm64/koffi.node +0 -0
  8. package/build/koffi/linux_armhf/koffi.node +0 -0
  9. package/build/koffi/linux_ia32/koffi.node +0 -0
  10. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  11. package/build/koffi/linux_x64/koffi.node +0 -0
  12. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  13. package/build/koffi/openbsd_x64/koffi.node +0 -0
  14. package/build/koffi/win32_arm64/koffi.exp +0 -0
  15. package/build/koffi/win32_arm64/koffi.lib +0 -0
  16. package/build/koffi/win32_arm64/koffi.node +0 -0
  17. package/build/koffi/win32_ia32/koffi.exp +0 -0
  18. package/build/koffi/win32_ia32/koffi.lib +0 -0
  19. package/build/koffi/win32_ia32/koffi.node +0 -0
  20. package/build/koffi/win32_x64/koffi.exp +0 -0
  21. package/build/koffi/win32_x64/koffi.lib +0 -0
  22. package/build/koffi/win32_x64/koffi.node +0 -0
  23. package/index.js +28 -48
  24. package/indirect.js +24 -44
  25. package/package.json +5 -3
  26. package/src/cnoke/assets/FindCNoke.cmake +16 -3
  27. package/src/cnoke/src/builder.js +109 -102
  28. package/src/cnoke/src/tools.js +5 -23
  29. package/src/koffi/CMakeLists.txt +2 -12
  30. package/vendor/node-api-headers/CHANGELOG.md +79 -0
  31. package/vendor/node-api-headers/CODE_OF_CONDUCT.md +4 -0
  32. package/vendor/node-api-headers/CONTRIBUTING.md +32 -0
  33. package/vendor/node-api-headers/CREATING_A_RELEASE.md +58 -0
  34. package/vendor/node-api-headers/LICENSE +21 -0
  35. package/vendor/node-api-headers/README.md +106 -0
  36. package/vendor/node-api-headers/def/js_native_api.def +120 -0
  37. package/vendor/node-api-headers/def/node_api.def +151 -0
  38. package/vendor/node-api-headers/include/js_native_api.h +569 -0
  39. package/vendor/node-api-headers/include/js_native_api_types.h +168 -0
  40. package/vendor/node-api-headers/include/node_api.h +260 -0
  41. package/vendor/node-api-headers/include/node_api_types.h +52 -0
  42. package/vendor/node-api-headers/index.js +17 -0
  43. package/vendor/node-api-headers/package.json +59 -0
  44. package/vendor/node-api-headers/scripts/clang-utils.js +50 -0
  45. package/vendor/node-api-headers/scripts/update-headers.js +189 -0
  46. package/vendor/node-api-headers/scripts/write-symbols.js +154 -0
  47. package/vendor/node-api-headers/scripts/write-win32-def.js +52 -0
  48. package/vendor/node-api-headers/symbols.js +241 -0
  49. package/build/koffi/linux_arm32hf/koffi.node +0 -0
  50. package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  ### Koffi 2.8
6
6
 
7
+ #### Koffi 2.8.10 (2024-06-17)
8
+
9
+ - Work around MSVC compiler bug introduced in Visual Studio 17.10
10
+
7
11
  #### Koffi 2.8.9 (2024-05-17)
8
12
 
9
13
  - Fix ABI issue regarding bool return values on x86_64 (and possibly other platforms)
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/index.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod) => function __require() {
4
4
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
5
  };
6
6
 
7
- // build/dist/src/cnoke/src/tools.js
7
+ // ../../bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "build/dist/src/cnoke/src/tools.js"(exports2, module2) {
9
+ "../../bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
10
10
  "use strict";
11
11
  var crypto = require("crypto");
12
12
  var fs2 = require("fs");
@@ -14,19 +14,6 @@ var require_tools = __commonJS({
14
14
  var path = require("path");
15
15
  var zlib = require("zlib");
16
16
  async function download_http(url, dest) {
17
- if (Array.isArray(url)) {
18
- let urls = url;
19
- for (let url2 of urls) {
20
- try {
21
- await download_http(url2, dest);
22
- return;
23
- } catch (err) {
24
- if (err.code != 404)
25
- throw err;
26
- }
27
- }
28
- throw new Error("All URLs returned error 404");
29
- }
30
17
  console.log(">> Downloading " + url);
31
18
  let [tmp_name, file] = open_temporary_stream(dest);
32
19
  try {
@@ -196,31 +183,29 @@ var require_tools = __commonJS({
196
183
  if (arch2 == "riscv32" || arch2 == "riscv64") {
197
184
  let buf = read_file_header(process.execPath, 512);
198
185
  let header = decode_elf_header(buf);
199
- let float_abi = (header.e_flags & 6) >> 1;
186
+ let float_abi = header.e_flags & 6;
200
187
  switch (float_abi) {
201
188
  case 0:
202
189
  {
203
- arch2 += "sf";
204
190
  }
205
191
  break;
206
- case 1:
192
+ case 2:
207
193
  {
208
- arch2 += "hf32";
194
+ arch2 += "f";
209
195
  }
210
196
  break;
211
- case 2:
197
+ case 4:
212
198
  {
213
- arch2 += "hf64";
199
+ arch2 += "d";
214
200
  }
215
201
  break;
216
- case 3:
202
+ case 6:
217
203
  {
218
- arch2 += "hf128";
204
+ arch2 += "q";
219
205
  }
220
206
  break;
221
207
  }
222
208
  } else if (arch2 == "arm") {
223
- arch2 = "arm32";
224
209
  let buf = read_file_header(process.execPath, 512);
225
210
  let header = decode_elf_header(buf);
226
211
  if (header.e_flags & 1024) {
@@ -373,13 +358,13 @@ var require_tools = __commonJS({
373
358
  }
374
359
  });
375
360
 
376
- // build/dist/src/koffi/package.json
361
+ // ../../bin/Koffi/package/src/koffi/package.json
377
362
  var require_package = __commonJS({
378
- "build/dist/src/koffi/package.json"(exports2, module2) {
363
+ "../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
379
364
  module2.exports = {
380
365
  name: "koffi",
381
- version: "2.8.9",
382
- stable: "2.8.9",
366
+ version: "2.8.10",
367
+ stable: "2.8.10",
383
368
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
369
  keywords: [
385
370
  "foreign",
@@ -403,25 +388,19 @@ var require_package = __commonJS({
403
388
  main: "./index.js",
404
389
  types: "./index.d.ts",
405
390
  scripts: {
406
- test: "node tools/qemu.js test",
407
- prepack: `echo 'Use "npm run prepare" instead' && false`,
408
- prepublishOnly: `echo 'Use "npm run release" instead' && false`,
409
- release: "node tools/qemu.js publish"
391
+ test: "node tools/koffi.js test",
392
+ prepack: `echo 'Use "npm run package" instead' && false`,
393
+ prepublishOnly: `echo 'Use "npm run package" instead' && false`,
394
+ package: "node tools/koffi.js build"
410
395
  },
411
396
  license: "MIT",
412
397
  devDependencies: {
413
- chalk: "^4.1.2",
414
- esbuild: "^0.19.2",
415
- "ffi-napi": "^4.0.3",
416
- minimatch: "^5.0.1",
417
- "node-ssh": "^12.0.3",
418
- raylib: "^0.14.0",
419
- "ref-napi": "^3.0.3",
420
- "ref-struct-di": "^1.1.1",
421
- tar: "^6.1.11"
398
+ esbuild: "^0.19.2"
422
399
  },
423
400
  cnoke: {
424
- output: "build/koffi/{{ platform }}_{{ arch }}",
401
+ api: "../../vendor/node-api-headers",
402
+ output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
403
+ node: 16,
425
404
  napi: 8,
426
405
  require: "./index.js"
427
406
  }
@@ -429,7 +408,7 @@ var require_package = __commonJS({
429
408
  }
430
409
  });
431
410
 
432
- // build/dist/src/koffi/index.js
411
+ // ../../bin/Koffi/package/src/koffi/index.js
433
412
  var util = require("util");
434
413
  var fs = require("fs");
435
414
  var { get_napi_version, determine_arch } = require_tools();
@@ -473,9 +452,9 @@ try {
473
452
  native = require("./build/koffi/freebsd_x64/koffi.node");
474
453
  }
475
454
  break;
476
- case "linux_arm32hf":
455
+ case "linux_armhf":
477
456
  {
478
- native = require("./build/koffi/linux_arm32hf/koffi.node");
457
+ native = require("./build/koffi/linux_armhf/koffi.node");
479
458
  }
480
459
  break;
481
460
  case "linux_arm64":
@@ -488,9 +467,9 @@ try {
488
467
  native = require("./build/koffi/linux_ia32/koffi.node");
489
468
  }
490
469
  break;
491
- case "linux_riscv64hf64":
470
+ case "linux_riscv64d":
492
471
  {
493
- native = require("./build/koffi/linux_riscv64hf64/koffi.node");
472
+ native = require("./build/koffi/linux_riscv64d/koffi.node");
494
473
  }
495
474
  break;
496
475
  case "linux_x64":
@@ -533,7 +512,8 @@ if (native == null) {
533
512
  let names = [
534
513
  `/build/koffi/${process.platform}_${arch}/koffi.node`,
535
514
  `/koffi/${process.platform}_${arch}/koffi.node`,
536
- `/node_modules/koffi/build/koffi/${process.platform}_${arch}/koffi.node`
515
+ `/node_modules/koffi/build/koffi/${process.platform}_${arch}/koffi.node`,
516
+ `/../../bin/Koffi/${process.platform}_${arch}/koffi.node`
537
517
  ];
538
518
  for (let root of roots) {
539
519
  for (let name of names) {
package/indirect.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod) => function __require() {
4
4
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
5
  };
6
6
 
7
- // build/dist/src/cnoke/src/tools.js
7
+ // ../../bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "build/dist/src/cnoke/src/tools.js"(exports2, module2) {
9
+ "../../bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
10
10
  "use strict";
11
11
  var crypto = require("crypto");
12
12
  var fs2 = require("fs");
@@ -14,19 +14,6 @@ var require_tools = __commonJS({
14
14
  var path = require("path");
15
15
  var zlib = require("zlib");
16
16
  async function download_http(url, dest) {
17
- if (Array.isArray(url)) {
18
- let urls = url;
19
- for (let url2 of urls) {
20
- try {
21
- await download_http(url2, dest);
22
- return;
23
- } catch (err) {
24
- if (err.code != 404)
25
- throw err;
26
- }
27
- }
28
- throw new Error("All URLs returned error 404");
29
- }
30
17
  console.log(">> Downloading " + url);
31
18
  let [tmp_name, file] = open_temporary_stream(dest);
32
19
  try {
@@ -196,31 +183,29 @@ var require_tools = __commonJS({
196
183
  if (arch2 == "riscv32" || arch2 == "riscv64") {
197
184
  let buf = read_file_header(process.execPath, 512);
198
185
  let header = decode_elf_header(buf);
199
- let float_abi = (header.e_flags & 6) >> 1;
186
+ let float_abi = header.e_flags & 6;
200
187
  switch (float_abi) {
201
188
  case 0:
202
189
  {
203
- arch2 += "sf";
204
190
  }
205
191
  break;
206
- case 1:
192
+ case 2:
207
193
  {
208
- arch2 += "hf32";
194
+ arch2 += "f";
209
195
  }
210
196
  break;
211
- case 2:
197
+ case 4:
212
198
  {
213
- arch2 += "hf64";
199
+ arch2 += "d";
214
200
  }
215
201
  break;
216
- case 3:
202
+ case 6:
217
203
  {
218
- arch2 += "hf128";
204
+ arch2 += "q";
219
205
  }
220
206
  break;
221
207
  }
222
208
  } else if (arch2 == "arm") {
223
- arch2 = "arm32";
224
209
  let buf = read_file_header(process.execPath, 512);
225
210
  let header = decode_elf_header(buf);
226
211
  if (header.e_flags & 1024) {
@@ -373,13 +358,13 @@ var require_tools = __commonJS({
373
358
  }
374
359
  });
375
360
 
376
- // build/dist/src/koffi/package.json
361
+ // ../../bin/Koffi/package/src/koffi/package.json
377
362
  var require_package = __commonJS({
378
- "build/dist/src/koffi/package.json"(exports2, module2) {
363
+ "../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
379
364
  module2.exports = {
380
365
  name: "koffi",
381
- version: "2.8.9",
382
- stable: "2.8.9",
366
+ version: "2.8.10",
367
+ stable: "2.8.10",
383
368
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
369
  keywords: [
385
370
  "foreign",
@@ -403,25 +388,19 @@ var require_package = __commonJS({
403
388
  main: "./index.js",
404
389
  types: "./index.d.ts",
405
390
  scripts: {
406
- test: "node tools/qemu.js test",
407
- prepack: `echo 'Use "npm run prepare" instead' && false`,
408
- prepublishOnly: `echo 'Use "npm run release" instead' && false`,
409
- release: "node tools/qemu.js publish"
391
+ test: "node tools/koffi.js test",
392
+ prepack: `echo 'Use "npm run package" instead' && false`,
393
+ prepublishOnly: `echo 'Use "npm run package" instead' && false`,
394
+ package: "node tools/koffi.js build"
410
395
  },
411
396
  license: "MIT",
412
397
  devDependencies: {
413
- chalk: "^4.1.2",
414
- esbuild: "^0.19.2",
415
- "ffi-napi": "^4.0.3",
416
- minimatch: "^5.0.1",
417
- "node-ssh": "^12.0.3",
418
- raylib: "^0.14.0",
419
- "ref-napi": "^3.0.3",
420
- "ref-struct-di": "^1.1.1",
421
- tar: "^6.1.11"
398
+ esbuild: "^0.19.2"
422
399
  },
423
400
  cnoke: {
424
- output: "build/koffi/{{ platform }}_{{ arch }}",
401
+ api: "../../vendor/node-api-headers",
402
+ output: "../../bin/Koffi/{{ platform }}_{{ arch }}",
403
+ node: 16,
425
404
  napi: 8,
426
405
  require: "./index.js"
427
406
  }
@@ -429,7 +408,7 @@ var require_package = __commonJS({
429
408
  }
430
409
  });
431
410
 
432
- // build/dist/src/koffi/indirect.js
411
+ // ../../bin/Koffi/package/src/koffi/indirect.js
433
412
  var util = require("util");
434
413
  var fs = require("fs");
435
414
  var { get_napi_version, determine_arch } = require_tools();
@@ -453,7 +432,8 @@ var native = null;
453
432
  let names = [
454
433
  `/build/koffi/${process.platform}_${arch}/koffi.node`,
455
434
  `/koffi/${process.platform}_${arch}/koffi.node`,
456
- `/node_modules/koffi/build/koffi/${process.platform}_${arch}/koffi.node`
435
+ `/node_modules/koffi/build/koffi/${process.platform}_${arch}/koffi.node`,
436
+ `/../../bin/Koffi/${process.platform}_${arch}/koffi.node`
457
437
  ];
458
438
  for (let root of roots) {
459
439
  for (let name of names) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.8.9",
4
- "stable": "2.8.9",
3
+ "version": "2.8.11",
4
+ "stable": "2.8.11",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -29,8 +29,10 @@
29
29
  },
30
30
  "license": "MIT",
31
31
  "cnoke": {
32
+ "api": "../../vendor/node-api-headers",
32
33
  "output": "build/koffi/{{ platform }}_{{ arch }}",
34
+ "node": 16,
33
35
  "napi": 8,
34
36
  "require": "./index.js"
35
37
  }
36
- }
38
+ }
@@ -26,9 +26,17 @@ else()
26
26
  set(USE_UNITY_BUILDS OFF CACHE BOOL "Use single-TU builds (aka. Unity builds)")
27
27
  endif()
28
28
 
29
+ if(NODE_JS_LINK_DEF)
30
+ add_custom_command(OUTPUT ${NODE_JS_LINK_LIB}
31
+ COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS}
32
+ /def:${NODE_JS_LINK_DEF} /out:${NODE_JS_LINK_LIB}
33
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
34
+ MAIN_DEPENDENCY ${NODE_JS_LINK_DEF})
35
+ add_custom_target(node.lib DEPENDS ${NODE_JS_LINK_LIB})
36
+ endif()
37
+
29
38
  function(add_node_addon)
30
39
  cmake_parse_arguments(ARG "" "NAME" "SOURCES" ${ARGN})
31
-
32
40
  add_library(${ARG_NAME} SHARED ${ARG_SOURCES} ${NODE_JS_SOURCES})
33
41
  target_link_node(${ARG_NAME})
34
42
  set_target_properties(${ARG_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
@@ -36,9 +44,14 @@ endfunction()
36
44
 
37
45
  function(target_link_node TARGET)
38
46
  target_include_directories(${TARGET} PRIVATE ${NODE_JS_INCLUDE_DIRS})
39
- target_link_libraries(${TARGET} PRIVATE ${NODE_JS_LIBRARIES})
47
+ if(NODE_JS_LINK_LIB)
48
+ if(TARGET node.lib)
49
+ add_dependencies(${TARGET} node.lib)
50
+ endif()
51
+ target_link_libraries(${TARGET} PRIVATE ${NODE_JS_LINK_LIB})
52
+ endif()
40
53
  target_compile_options(${TARGET} PRIVATE ${NODE_JS_COMPILE_FLAGS})
41
- if (NODE_JS_LINK_FLAGS)
54
+ if(NODE_JS_LINK_FLAGS)
42
55
  target_link_options(${TARGET} PRIVATE ${NODE_JS_LINK_FLAGS})
43
56
  endif()
44
57
  endfunction()