koffi 2.16.2 → 3.0.0-alpha.10

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 (123) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/LICENSE.txt +1 -1
  3. package/README.md +8 -8
  4. package/build/koffi/darwin_arm64/koffi.node +0 -0
  5. package/build/koffi/darwin_x64/koffi.node +0 -0
  6. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  7. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  8. package/build/koffi/freebsd_x64/koffi.node +0 -0
  9. package/build/koffi/linux_arm64/koffi.node +0 -0
  10. package/build/koffi/linux_ia32/koffi.node +0 -0
  11. package/build/koffi/linux_x64/koffi.node +0 -0
  12. package/build/koffi/musl_arm64/koffi.node +0 -0
  13. package/build/koffi/musl_x64/koffi.node +0 -0
  14. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  15. package/build/koffi/openbsd_x64/koffi.node +0 -0
  16. package/build/koffi/win32_ia32/koffi.node +0 -0
  17. package/build/koffi/win32_x64/koffi.node +0 -0
  18. package/cnoke.cjs +816 -0
  19. package/doc/benchmarks.md +33 -33
  20. package/doc/callbacks.md +9 -9
  21. package/doc/contribute.md +41 -27
  22. package/doc/functions.md +6 -6
  23. package/doc/index.md +8 -8
  24. package/doc/input.md +70 -6
  25. package/doc/misc.md +14 -15
  26. package/doc/output.md +10 -10
  27. package/doc/packaging.md +7 -7
  28. package/doc/pointers.md +14 -16
  29. package/doc/start.md +4 -4
  30. package/doc/unions.md +2 -2
  31. package/doc/variables.md +5 -5
  32. package/index.cjs +1 -0
  33. package/index.d.ts +111 -104
  34. package/index.js +1 -634
  35. package/indirect.cjs +1 -0
  36. package/indirect.js +1 -533
  37. package/lib/native/base/base.cc +86 -92
  38. package/lib/native/base/base.hh +203 -159
  39. package/lib/native/base/unicode.inc +1 -1
  40. package/package.json +18 -7
  41. package/src/koffi/CMakeLists.txt +98 -35
  42. package/src/koffi/index.cjs +333 -0
  43. package/src/koffi/index.js +271 -0
  44. package/src/koffi/indirect.cjs +332 -0
  45. package/src/koffi/indirect.js +182 -0
  46. package/src/koffi/src/{abi_arm32.cc → abi/arm32.cc} +280 -276
  47. package/src/koffi/src/{abi_arm32_asm.S → abi/arm32_asm.S} +3 -6
  48. package/src/koffi/src/abi/arm64.cc +1516 -0
  49. package/src/koffi/src/{abi_arm64_asm.S → abi/arm64_asm.S} +45 -24
  50. package/src/koffi/src/{abi_arm64_asm.asm → abi/arm64_asm.asm} +33 -26
  51. package/src/koffi/src/{abi_loong64.cc → abi/loong64.cc} +1 -1
  52. package/src/koffi/src/{abi_loong64_asm.S → abi/loong64_asm.S} +2 -6
  53. package/src/koffi/src/{abi_riscv64.cc → abi/riscv64.cc} +280 -274
  54. package/src/koffi/src/{abi_riscv64_asm.S → abi/riscv64_asm.S} +2 -5
  55. package/src/koffi/src/abi/x64sysv.cc +1456 -0
  56. package/src/koffi/src/{abi_x64_sysv_asm.S → abi/x64sysv_asm.S} +31 -34
  57. package/src/koffi/src/abi/x64win.cc +1124 -0
  58. package/src/koffi/src/{abi_x64_win_asm.S → abi/x64win_asm.S} +9 -13
  59. package/src/koffi/src/{abi_x64_win_asm.asm → abi/x64win_asm.asm} +12 -15
  60. package/src/koffi/src/abi/x86.cc +1236 -0
  61. package/src/koffi/src/{abi_x86_asm.S → abi/x86_asm.S} +50 -26
  62. package/src/koffi/src/{abi_x86_asm.asm → abi/x86_asm.asm} +12 -15
  63. package/src/koffi/src/call.cc +534 -628
  64. package/src/koffi/src/call.hh +62 -83
  65. package/src/koffi/src/errno.inc +1 -1
  66. package/src/koffi/src/ffi.cc +787 -532
  67. package/src/koffi/src/ffi.hh +149 -99
  68. package/src/koffi/src/parser.cc +1 -5
  69. package/src/koffi/src/parser.hh +1 -1
  70. package/src/koffi/src/primitives.inc +39 -0
  71. package/src/koffi/{tools/write_trampolines.js → src/trampolines.cjs} +4 -4
  72. package/src/koffi/src/util.cc +745 -491
  73. package/src/koffi/src/util.hh +332 -60
  74. package/src/koffi/src/uv.cc +37 -22
  75. package/src/koffi/src/uv.def +1 -0
  76. package/src/koffi/src/uv.hh +74 -3
  77. package/src/koffi/src/win32.cc +1 -1
  78. package/src/koffi/src/win32.hh +31 -2
  79. package/vendor/node-addon-api/napi-inl.h +32 -32
  80. package/vendor/node-addon-api/napi.h +1 -0
  81. package/build/koffi/linux_armhf/koffi.node +0 -0
  82. package/build/koffi/linux_loong64/koffi.node +0 -0
  83. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  84. package/build/koffi/win32_arm64/koffi.exp +0 -0
  85. package/build/koffi/win32_arm64/koffi.lib +0 -0
  86. package/build/koffi/win32_arm64/koffi.node +0 -0
  87. package/doc/platforms.md +0 -36
  88. package/lib/native/base/crc.inc +0 -2214
  89. package/lib/native/base/crc_gen.py +0 -72
  90. package/lib/native/base/mimetypes.inc +0 -1248
  91. package/lib/native/base/mimetypes_gen.py +0 -58
  92. package/lib/native/base/tower.cc +0 -821
  93. package/lib/native/base/tower.hh +0 -81
  94. package/lib/native/base/unicode_gen.py +0 -152
  95. package/src/cnoke/LICENSE.txt +0 -22
  96. package/src/cnoke/README.md +0 -99
  97. package/src/cnoke/assets/FindCNoke.cmake +0 -127
  98. package/src/cnoke/assets/toolchains.json +0 -126
  99. package/src/cnoke/assets/win_delay_hook.c +0 -36
  100. package/src/cnoke/cnoke.js +0 -170
  101. package/src/cnoke/package.json +0 -24
  102. package/src/cnoke/src/builder.js +0 -511
  103. package/src/cnoke/src/index.js +0 -10
  104. package/src/cnoke/src/tools.js +0 -407
  105. package/src/koffi/src/abi_arm64.cc +0 -1295
  106. package/src/koffi/src/abi_x64_sysv.cc +0 -939
  107. package/src/koffi/src/abi_x64_win.cc +0 -715
  108. package/src/koffi/src/abi_x86.cc +0 -860
  109. package/src/koffi/src/init.js +0 -105
  110. package/vendor/node-api-headers/include/uv/aix.h +0 -32
  111. package/vendor/node-api-headers/include/uv/bsd.h +0 -34
  112. package/vendor/node-api-headers/include/uv/darwin.h +0 -61
  113. package/vendor/node-api-headers/include/uv/errno.h +0 -483
  114. package/vendor/node-api-headers/include/uv/linux.h +0 -34
  115. package/vendor/node-api-headers/include/uv/os390.h +0 -33
  116. package/vendor/node-api-headers/include/uv/posix.h +0 -31
  117. package/vendor/node-api-headers/include/uv/sunos.h +0 -44
  118. package/vendor/node-api-headers/include/uv/threadpool.h +0 -37
  119. package/vendor/node-api-headers/include/uv/tree.h +0 -521
  120. package/vendor/node-api-headers/include/uv/unix.h +0 -512
  121. package/vendor/node-api-headers/include/uv/version.h +0 -43
  122. package/vendor/node-api-headers/include/uv/win.h +0 -698
  123. package/vendor/node-api-headers/include/uv.h +0 -1990
package/CHANGELOG.md CHANGED
@@ -3,6 +3,46 @@
3
3
  > [!NOTE]
4
4
  > Consult the [migration guide](migration) to migrate between major Koffi versions.
5
5
 
6
+ ## Koffi 3
7
+
8
+ ### Koffi 3.0
9
+
10
+ #### Koffi 3.0.0 (WIP)
11
+
12
+ *Not yet released*
13
+
14
+ **Main changes:**
15
+
16
+ - Replace use of externals with type objects:
17
+ * Use `koffi.type()` to resolve type specifiers (strings or objects) to type objects
18
+ * Access type information directly on type objects without `koffi.introspect()`
19
+ - Replace use of externals with BigInt pointers
20
+ - Support ESM and CJS module types
21
+ - Rewrite call preparation and execution for vastly improved performance
22
+
23
+ **Other changes:**
24
+
25
+ - Add `koffi.enumeration()` to create [enum types](input#enum-types)
26
+ - Use proper types for various objects and handles:
27
+ * Use *LibraryHandle* objects for loaded libraries
28
+ * Use *CallbackHandle* objects for registered callbacks
29
+ * Use *PollHandle* for socket poll handles
30
+ - Add `Symbol.dispose` on library objects and registered callbacks
31
+ - Prefer types to interfaces in TypeScript declaration file
32
+ - Fix various bugs and small leaks (such as library handles)
33
+
34
+ **Newly deprecated functions:**
35
+
36
+ - Deprecate `koffi.resolve()` function, replace with `koffi.type()`
37
+ - Deprecate `koffi.introspect()` function, replace with `koffi.type()`
38
+
39
+ **Removed deprecated functions:**
40
+
41
+ - Remove `koffi.callback()` long replaced with `koffi.proto()`
42
+ - Remove `koffi.handle()` long replaced with `koffi.opaque()`
43
+
44
+ Consult the [migration guide](migration) for more information.
45
+
6
46
  ## Koffi 2
7
47
 
8
48
  ### Koffi 2.16
@@ -65,7 +105,7 @@
65
105
 
66
106
  *Released on 2026-04-03*
67
107
 
68
- - Fix *IsOnCentralStack()* assertion/crash when using callbacks in recent Node versions
108
+ - Fix "IsOnCentralStack()" assertion/crash when using callbacks in recent Node versions
69
109
  - Support SetUnhandledExceptionFilter on Windows x64 and x86 ([@longhun12346](https://github.com/longhun12346))
70
110
  - Fix incorrect stack alignment when relaying callbacks on 32-bit x86 platforms
71
111
 
@@ -81,7 +121,7 @@
81
121
 
82
122
  #### Koffi 2.15.1
83
123
 
84
- *Released on 2025-01-24*
124
+ *Released on 2026-01-24*
85
125
 
86
126
  - Fix possible union-related crashes
87
127
  - Support MinGW-w64 x64 builds on Windows
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
3
+ Copyright (C) 2026 Niels Martignène <niels.martignene@protonmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the “Software”), to deal in
package/README.md CHANGED
@@ -9,14 +9,14 @@ Koffi is a fast and easy-to-use C FFI module for Node.js, featuring:
9
9
 
10
10
  The following combinations of OS and architectures __are officially supported and tested__ at the moment:
11
11
 
12
- ISA / OS | Windows | Linux (glibc) | Linux (musl) | macOS | FreeBSD | OpenBSD
13
- ------------------ | ----------- | ------------- | ------------ | ----------- | ----------- | --------
14
- x86 (IA32) [^1] | ✅ Yes | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | ✅ Yes | ✅ Yes
15
- x86_64 (AMD64) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes
16
- ARM32 LE [^2] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
17
- ARM64 (AArch64) LE | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | 🟨 Probably
18
- RISC-V 64 [^3] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
19
- LoongArch64 | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
12
+ ISA / OS | Windows | Linux/glibc | Linux/musl | macOS | FreeBSD | OpenBSD
13
+ ------------------ | ----------- | ----------- | ----------- | ----------- | ----------- | --------
14
+ x86 (IA32) [^1] | ✅ Yes | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | ✅ Yes | ✅ Yes
15
+ x86_64 (AMD64) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes
16
+ ARM32 LE [^2] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
17
+ ARM64 (AArch64) LE | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | 🟨 Probably
18
+ RISC-V 64 [^3] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
19
+ LoongArch64 | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
20
20
 
21
21
  [^1]: The following call conventions are supported: cdecl, stdcall, MS fastcall, thiscall.
22
22
  [^2]: The prebuilt binary uses the hard float ABI and expects a VFP coprocessor. Build from source to use Koffi with a different ABI (softfp, soft).
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