koffi 2.14.0 → 2.15.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +1 -1
  3. package/build/koffi/darwin_arm64/koffi.node +0 -0
  4. package/build/koffi/darwin_x64/koffi.node +0 -0
  5. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  6. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  7. package/build/koffi/freebsd_x64/koffi.node +0 -0
  8. package/build/koffi/linux_arm64/koffi.node +0 -0
  9. package/build/koffi/linux_armhf/koffi.node +0 -0
  10. package/build/koffi/linux_ia32/koffi.node +0 -0
  11. package/build/koffi/linux_loong64/koffi.node +0 -0
  12. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  13. package/build/koffi/linux_x64/koffi.node +0 -0
  14. package/build/koffi/musl_arm64/koffi.node +0 -0
  15. package/build/koffi/musl_x64/koffi.node +0 -0
  16. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  17. package/build/koffi/openbsd_x64/koffi.node +0 -0
  18. package/build/koffi/win32_arm64/koffi.node +0 -0
  19. package/build/koffi/win32_ia32/koffi.node +0 -0
  20. package/build/koffi/win32_x64/koffi.node +0 -0
  21. package/doc/assets.ini +2 -1
  22. package/doc/build.sh +9 -0
  23. package/doc/pages/404.md +17 -0
  24. package/doc/pages/index.md +43 -4
  25. package/doc/pages/misc.md +16 -11
  26. package/doc/pages/platforms.md +8 -19
  27. package/doc/pages.ini +4 -7
  28. package/doc/static/highlight.js +2 -14
  29. package/doc/static/koffi.css +3 -15
  30. package/doc/static/perf_windows.png +0 -0
  31. package/doc/static/print.css +2 -14
  32. package/index.d.ts +29 -24
  33. package/index.js +10 -9
  34. package/indirect.js +10 -9
  35. package/{src/core → lib/native}/base/base.cc +1753 -1089
  36. package/{src/core → lib/native}/base/base.hh +868 -572
  37. package/{src/core → lib/native}/base/crc.inc +3 -21
  38. package/lib/native/base/crc_gen.py +72 -0
  39. package/{src/core → lib/native}/base/mimetypes.inc +2 -20
  40. package/{src/core → lib/native}/base/mimetypes_gen.py +2 -21
  41. package/lib/native/base/tower.cc +821 -0
  42. package/lib/native/base/tower.hh +81 -0
  43. package/{src/core → lib/native}/base/unicode.inc +3 -21
  44. package/{src/core → lib/native}/base/unicode_gen.py +5 -42
  45. package/package.json +3 -2
  46. package/src/cnoke/assets/FindCNoke.cmake +8 -20
  47. package/src/cnoke/assets/win_delay_hook.c +2 -20
  48. package/src/cnoke/cnoke.js +2 -21
  49. package/src/cnoke/src/builder.js +3 -22
  50. package/src/cnoke/src/index.js +2 -20
  51. package/src/cnoke/src/tools.js +2 -20
  52. package/src/koffi/CMakeLists.txt +19 -22
  53. package/src/koffi/cmake/raylib.cmake +5 -22
  54. package/src/koffi/cmake/sqlite3.cmake +2 -20
  55. package/src/koffi/src/abi_arm32.cc +31 -49
  56. package/src/koffi/src/abi_arm32_asm.S +2 -20
  57. package/src/koffi/src/abi_arm64.cc +36 -54
  58. package/src/koffi/src/abi_arm64_asm.S +2 -20
  59. package/src/koffi/src/abi_arm64_asm.asm +2 -20
  60. package/src/koffi/src/abi_loong64.cc +2 -20
  61. package/src/koffi/src/abi_loong64_asm.S +2 -20
  62. package/src/koffi/src/abi_riscv64.cc +34 -52
  63. package/src/koffi/src/abi_riscv64_asm.S +2 -20
  64. package/src/koffi/src/abi_x64_sysv.cc +36 -54
  65. package/src/koffi/src/abi_x64_sysv_asm.S +2 -20
  66. package/src/koffi/src/abi_x64_win.cc +32 -50
  67. package/src/koffi/src/abi_x64_win_asm.asm +2 -20
  68. package/src/koffi/src/abi_x86.cc +33 -51
  69. package/src/koffi/src/abi_x86_asm.S +2 -20
  70. package/src/koffi/src/abi_x86_asm.asm +2 -20
  71. package/src/koffi/src/call.cc +107 -281
  72. package/src/koffi/src/call.hh +9 -27
  73. package/src/koffi/src/errno.inc +2 -20
  74. package/src/koffi/src/ffi.cc +121 -121
  75. package/src/koffi/src/ffi.hh +23 -38
  76. package/src/koffi/src/init.js +2 -20
  77. package/src/koffi/src/parser.cc +15 -29
  78. package/src/koffi/src/parser.hh +4 -22
  79. package/src/koffi/src/trampolines/armasm.inc +0 -21
  80. package/src/koffi/src/trampolines/gnu.inc +0 -21
  81. package/src/koffi/src/trampolines/masm32.inc +0 -21
  82. package/src/koffi/src/trampolines/masm64.inc +0 -21
  83. package/src/koffi/src/trampolines/prototypes.inc +1 -22
  84. package/src/koffi/src/util.cc +87 -102
  85. package/src/koffi/src/util.hh +11 -29
  86. package/src/koffi/src/uv.cc +193 -0
  87. package/src/koffi/src/uv.def +10 -0
  88. package/src/koffi/src/uv.hh +40 -0
  89. package/src/koffi/src/win32.cc +7 -25
  90. package/src/koffi/src/win32.hh +4 -22
  91. package/vendor/node-api-headers/include/uv/aix.h +32 -0
  92. package/vendor/node-api-headers/include/uv/bsd.h +34 -0
  93. package/vendor/node-api-headers/include/uv/darwin.h +61 -0
  94. package/vendor/node-api-headers/include/uv/errno.h +483 -0
  95. package/vendor/node-api-headers/include/uv/linux.h +34 -0
  96. package/vendor/node-api-headers/include/uv/os390.h +33 -0
  97. package/vendor/node-api-headers/include/uv/posix.h +31 -0
  98. package/vendor/node-api-headers/include/uv/sunos.h +44 -0
  99. package/vendor/node-api-headers/include/uv/threadpool.h +37 -0
  100. package/vendor/node-api-headers/include/uv/tree.h +521 -0
  101. package/vendor/node-api-headers/include/uv/unix.h +512 -0
  102. package/vendor/node-api-headers/include/uv/version.h +43 -0
  103. package/vendor/node-api-headers/include/uv/win.h +698 -0
  104. package/vendor/node-api-headers/include/uv.h +1990 -0
  105. package/src/core/base/crc_gen.py +0 -109
package/CHANGELOG.md CHANGED
@@ -5,8 +5,34 @@
5
5
 
6
6
  ## Koffi 2
7
7
 
8
+ ### Koffi 2.15
9
+
10
+ #### Koffi 2.15.0
11
+
12
+ *Released on 2025-12-21*
13
+
14
+ - Fix parsing error with some parameter types that could lead to weird crashes (regression introduced in Koffi 2.14)
15
+ - Fix rare data race in Koffi memory allocation/release
16
+ - Increase default and maximum length of async call queue
17
+ - Decrease default stack and heap size used for async calls
18
+ - Add API to poll sockets with Node libuv event loop ([@mkicherer](https://github.com/mkicherer))
19
+ - Fix erroneous UTF-32 range checks when decoding UTF-32 buffers ([@VastBlast](https://github.com/VastBlast))
20
+ - Fix possible overflow when encoding malformed UTF-16 to UTF-32
21
+ - Throw error when using negative offset in encode and decode functions ([@VastBlast](https://github.com/VastBlast))
22
+ - Use proper Unicode replacement char in UTF-32 routines
23
+
24
+ > [!NOTE]
25
+ > The socket polling/libuv integration API is not yet documented and might change in subsequent releases. You've been warned!
26
+
8
27
  ### Koffi 2.14
9
28
 
29
+ #### Koffi 2.14.1
30
+
31
+ *Released on 2025-09-13*
32
+
33
+ - Recompile Linux (musl) ARM64 prebuild with Alpine 3.20 (instead of Alpine edge)
34
+ - Clean up redundant code paths for handling string arguments
35
+
10
36
  #### Koffi 2.14.0
11
37
 
12
38
  *Released on 2025-08-17*
@@ -980,7 +1006,6 @@ This entry documents changes since version 1.1.0.
980
1006
 
981
1007
  The following features and improvements are planned, not necessarily in that order:
982
1008
 
983
- - Port Koffi to Loong64 ISA and ABI
984
1009
  - Port Koffi to PowerPC (POWER9+) ISA and ABI
985
1010
  - Optimize passing of structs and arrays (with auto-generated JS)
986
1011
  - Automate Windows/AArch64 (qemu) and macOS/AArch64 (how? ... thanks Apple) tests
package/README.md CHANGED
@@ -4,7 +4,7 @@ Koffi is a fast and easy-to-use C FFI module for Node.js, featuring:
4
4
 
5
5
  * Low-overhead and fast performance (see [benchmarks](https://koffi.dev/benchmarks))
6
6
  * Support for primitive and aggregate data types (structs and fixed-size arrays), both by reference (pointer) and by value
7
- * Javascript functions can be used as C callbacks (since 1.2.0)
7
+ * Javascript functions can be used as C callbacks
8
8
  * Well-tested code base for popular OS/architecture combinations
9
9
 
10
10
  The following combinations of OS and architectures __are officially supported and tested__ at the moment:
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/doc/assets.ini CHANGED
@@ -1,4 +1,5 @@
1
1
  EsbuildPath = ../../vendor/esbuild/native/node_modules/@esbuild
2
+ EsbuildRoot = ../..
2
3
 
3
4
  [favicon.png]
4
5
  Type = Copy
@@ -11,7 +12,7 @@ Ignore = favicon.png *.js *.css
11
12
 
12
13
  [static/site.min.js]
13
14
  Type = Bundle
14
- Source = ../../src/web/flat/static.js
15
+ Source = ../../lib/web/flat/static.js
15
16
 
16
17
  [static/highlight.min.js]
17
18
  Type = Bundle
package/doc/build.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash -e
2
+
3
+ cd "$(dirname $0)"
4
+
5
+ ../../bootstrap.sh
6
+ ../../felix -pFast hodler
7
+
8
+ mkdir -p ../../bin/Web/koffi.dev
9
+ ../../bin/Fast/hodler . -O ../../bin/Web/koffi.dev --gzip
@@ -0,0 +1,17 @@
1
+ *The page you requested does not exist...*
2
+
3
+ <div class="error">Error 404</div>
4
+
5
+ <style>
6
+ main {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ justify-content: center;
11
+ }
12
+ .error {
13
+ margin: 0.8em;
14
+ font-size: 4em;
15
+ font-weight: bold;
16
+ }
17
+ </style>
@@ -1,16 +1,51 @@
1
- # Koffi
1
+ # Overview
2
2
 
3
3
  Koffi is a **fast and easy-to-use C FFI module for Node.js**, featuring:
4
4
 
5
5
  * Low-overhead and fast performance (see [benchmarks](benchmarks))
6
6
  * Support for primitive and aggregate data types (structs and fixed-size arrays), both by reference (pointer) and by value
7
- * Javascript functions can be used as C callbacks (since 1.2.0)
8
- * Well-tested code base for [popular OS/architecture combinations](platforms)
7
+ * Javascript functions can be used as C callbacks
8
+ * Well-tested code base for popular OS/architecture combinations
9
9
 
10
- Koffi requires a recent [Node.js](https://nodejs.org/) version with N-API version 8 support, see [this page](platforms) for more information.
10
+ If you like this project, consider supporting me:
11
+
12
+ <p style="display: flex; gap: 2em; justify-content: center;">
13
+ <a href="https://buymeacoffee.com/koromix" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174" style="border-radius: 12px;"></a>
14
+ </p>
15
+
16
+ Koffi requires [Node.js](https://nodejs.org/) version 16 or later. Use [NVM](https://github.com/nvm-sh/nvm) to install more recent Node versions on older Linux distributions.
17
+
18
+ The following combinations of OS and architectures __are officially supported and tested__ at the moment:
19
+
20
+ ISA / OS | Windows | Linux (glibc) | Linux (musl) | macOS | FreeBSD | OpenBSD
21
+ ------------------ | ------- | ------------- | ------------ | ----- | ------- | -------
22
+ x86 (IA32) [^2] | ✅ | ✅ | 🟨 | ⬜️ | ✅ | ✅
23
+ x86_64 (AMD64) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅
24
+ ARM32 LE [^3] | ⬜️ | ✅ | 🟨 | ⬜️ | 🟨 | 🟨
25
+ ARM64 (AArch64) LE | ✅ | ✅ | ✅ | ✅ | ✅ | 🟨
26
+ RISC-V 64 [^4] | ⬜️ | ✅ | 🟨 | ⬜️ | 🟨 | 🟨
27
+ LoongArch64 | ⬜️ | ✅ | 🟨 | ⬜️ | 🟨 | 🟨
28
+
29
+ <div class="legend">✅ Yes | 🟨 Probably | ⬜️ Not applicable</div>
30
+
31
+ [^2]: The following call conventions are supported for forward calls: cdecl, stdcall, MS fastcall, thiscall. Only cdecl and stdcall can be used for C to JS callbacks.
32
+ [^3]: 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).
33
+ [^4]: The prebuilt binary uses the LP64D (double-precision float) ABI. The LP64 ABI is supported in theory if you build Koffi from source (untested), the LP64F ABI is not supported.
34
+
35
+ For all fully supported platforms (green check marks), a prebuilt binary is included in the NPM package which means you can install Koffi without a C++ compiler.
36
+
37
+ # Source code
11
38
 
12
39
  The source code is available here: https://github.com/Koromix/rygel/ (in the *src/koffi* subdirectory).
13
40
 
41
+ > [!NOTE]
42
+ > Most of my projects live in a single repository (or monorepo), which have two killer features for me:
43
+ >
44
+ > - Cross-project refactoring
45
+ > - Simplified dependency management
46
+ >
47
+ > You can find a more detailed rationale here: https://danluu.com/monorepo/
48
+
14
49
  New releases are frequent, look at the [changelog](changelog) for more information.
15
50
 
16
51
  # License
@@ -18,3 +53,7 @@ New releases are frequent, look at the [changelog](changelog) for more informati
18
53
  This program is free software: you can redistribute it and/or modify it under the terms of the **MIT License**.
19
54
 
20
55
  Find more information here: https://choosealicense.com/licenses/mit/
56
+
57
+ <style>
58
+ table td:not(:first-child) { text-align: center; }
59
+ </style>
package/doc/pages/misc.md CHANGED
@@ -112,21 +112,26 @@ let config = koffi.config();
112
112
  console.log(config);
113
113
  ```
114
114
 
115
- The same is true for asynchronous calls. When an asynchronous call is made, Koffi will allocate new blocks unless there is an unused (resident) set of blocks still available. Once the asynchronous call is finished, these blocks are freed if there are more than `resident_async_pools` sets of blocks left around.
115
+ The same is true for asynchronous calls. When an asynchronous call is made, Koffi will allocate new blocks unless there is an unused (resident) set of blocks still available. Once the asynchronous call is finished, these blocks are freed if there are more than `resident_async_pools` sets of blocks left around. By default, the preallocated stack and heap blocks are much smaller than for synchronous calls (see [default settings](#default-settings)).
116
116
 
117
- There cannot be more than `max_async_calls` running at the same time.
117
+ > [!CAUTION]
118
+ > The **memory usage can blow up easily** if you increase the size of async memory blocks and many async calls are running or queued at the same time !
119
+ >
120
+ > For example, with 4096 running/queued async calls, a stack size of 256 kiB and a heap size of 512 kiB, the memory usage will reach approximately _4096 * (256 + 512) kiB ≈ 3 GiB_ just for Koffi, even though most of it will be freed once the number of queued calls goes down.
121
+
122
+ Async calls run on worker threads, the number of which depends on the number of cores in your machine. Additional async calls are queued, up to `max_async_calls` can run and be queued at the same time. If you try to make an async call once the queue if full, an exception will be thrown.
118
123
 
119
124
  ## Default settings
120
125
 
121
- Setting | Default | Description
122
- -------------------- | ------- | -----------------------------------------------
123
- sync_stack_size | 1 MiB | Stack size for synchronous calls
124
- sync_heap_size | 2 MiB | Heap size for synchronous calls
125
- async_stack_size | 256 kiB | Stack size for asynchronous calls
126
- async_heap_size | 512 kiB | Heap size for asynchronous calls
127
- resident_async_pools | 2 | Number of resident pools for asynchronous calls
128
- max_async_calls | 64 | Maximum number of ongoing asynchronous calls
129
- max_type_size | 64 MiB | Maximum size of Koffi types (for arrays and structs)
126
+ Setting | Default | Maximum | Description
127
+ -------------------- | ------- | ------- | ----------------------------------------------------
128
+ sync_stack_size | 1 MiB | 16 MiB | Stack size for synchronous calls
129
+ sync_heap_size | 2 MiB | 16 MiB | Heap size for synchronous calls
130
+ async_stack_size | 128 kiB | 16 MiB | Stack size for asynchronous calls
131
+ async_heap_size | 128 kiB | 16 MiB | Heap size for asynchronous calls
132
+ resident_async_pools | 4 | 16 | Number of resident pools for asynchronous calls
133
+ max_async_calls | 256 | 4096 | Maximum number of queued asynchronous calls
134
+ max_type_size | 64 MiB | 512 MiB | Maximum size of Koffi types (for arrays and structs)
130
135
 
131
136
  # Usage statistics
132
137
 
@@ -14,25 +14,14 @@ Use [NVM](https://github.com/nvm-sh/nvm) to install more recent Node versions on
14
14
 
15
15
  The following combinations of OS and architectures __are officially supported and tested__ at the moment:
16
16
 
17
- ISA / OS | Windows | Linux (glibc) | Linux (musl)
18
- ------------------ | ------- | ------------- | ------------
19
- x86 (IA32) [^1] | ✅ | ✅ | 🟨
20
- x86_64 (AMD64) | ✅ | ✅ | ✅
21
- ARM32 LE [^2] | ⬜️ | ✅ | 🟨
22
- ARM64 (AArch64) LE | ✅ | ✅ | ✅
23
- RISC-V 64 [^3] | ⬜️ | ✅ | 🟨
24
- LoongArch64 | ⬜️ | ✅ | 🟨
25
-
26
- <div class="legend">✅ Yes | 🟨 Probably | ⬜️ Not applicable</div>
27
-
28
- ISA / OS | macOS | FreeBSD | OpenBSD
29
- ------------------ | ----- | ----------- | --------
30
- x86 (IA32) [^1] | ⬜️ | ✅ | ✅
31
- x86_64 (AMD64) | ✅ | ✅ | ✅
32
- ARM32 LE [^2] | ⬜️ | 🟨 | 🟨
33
- ARM64 (AArch64) LE | ✅ | ✅ | 🟨
34
- RISC-V 64 [^3] | ⬜️ | 🟨 | 🟨
35
- LoongArch64 | ⬜️ | 🟨 | 🟨
17
+ ISA / OS | Windows | Linux (glibc) | Linux (musl) | macOS | FreeBSD | OpenBSD
18
+ ------------------ | ----------- | ------------- | ------------ | ----------- | ----------- | --------
19
+ x86 (IA32) [^1] | ✅ Yes | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | ✅ Yes | ✅ Yes
20
+ x86_64 (AMD64) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes
21
+ ARM32 LE [^2] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
22
+ ARM64 (AArch64) LE | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | 🟨 Probably
23
+ RISC-V 64 [^3] | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
24
+ LoongArch64 | ⬜️ *N/A* | ✅ Yes | 🟨 Probably | ⬜️ *N/A* | 🟨 Probably | 🟨 Probably
36
25
 
37
26
  <div class="legend">✅ Yes | 🟨 Probably | ⬜️ Not applicable</div>
38
27
 
package/doc/pages.ini CHANGED
@@ -2,13 +2,6 @@
2
2
  Title = Koffi
3
3
  Menu = Overview
4
4
  Description = Koffi presentation and features
5
- ToC = Off
6
- Template = templates/page.html
7
-
8
- [pages/platforms.md]
9
- Title = Requirements | Koffi
10
- Menu = Documentation / Requirements
11
- Description = Supported systemd and architectures
12
5
  Template = templates/page.html
13
6
 
14
7
  [pages/start.md]
@@ -87,3 +80,7 @@ Title = Changelog | Koffi
87
80
  Menu = Changelog
88
81
  Description = List of Koffi versions
89
82
  Template = templates/page.html
83
+
84
+ [pages/404.md]
85
+ Title = Page not found
86
+ Template = templates/page.html
@@ -1,17 +1,5 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
3
- // This program is free software: you can redistribute it and/or modify
4
- // it under the terms of the GNU General Public License as published by
5
- // the Free Software Foundation, either version 3 of the License, or
6
- // (at your option) any later version.
7
- //
8
- // This program is distributed in the hope that it will be useful,
9
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- // GNU General Public License for more details.
12
- //
13
- // You should have received a copy of the GNU General Public License
14
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
15
3
 
16
4
  import * as hljs from '../../../vendor/highlight.js/highlight.js';
17
5
 
@@ -1,19 +1,7 @@
1
- /* Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
1
+ /* SPDX-License-Identifier: MIT */
2
+ /* SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com> */
2
3
 
3
- This program is free software: you can redistribute it and/or modify
4
- it under the terms of the GNU General Public License as published by
5
- the Free Software Foundation, either version 3 of the License, or
6
- (at your option) any later version.
7
-
8
- This program is distributed in the hope that it will be useful,
9
- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- GNU General Public License for more details.
12
-
13
- You should have received a copy of the GNU General Public License
14
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
15
-
16
- @import url('../../../src/web/flat/flat.css');
4
+ @import url('../../../lib/web/flat/flat.css');
17
5
  @import url('../../../vendor/highlight.js/styles/base16/tomorrow.css');
18
6
 
19
7
  html {
Binary file
@@ -1,17 +1,5 @@
1
- /* Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
-
3
- This program is free software: you can redistribute it and/or modify
4
- it under the terms of the GNU General Public License as published by
5
- the Free Software Foundation, either version 3 of the License, or
6
- (at your option) any later version.
7
-
8
- This program is distributed in the hope that it will be useful,
9
- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- GNU General Public License for more details.
12
-
13
- You should have received a copy of the GNU General Public License
14
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
1
+ /* SPDX-License-Identifier: MIT */
2
+ /* SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com> */
15
3
 
16
4
  @media print {
17
5
  .schema { width: 90%; }
package/index.d.ts CHANGED
@@ -1,23 +1,5 @@
1
- // Copyright (C) 2025 Niels Martignène <niels.martignene@protonmail.com>
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- // this software and associated documentation files (the “Software”), to deal in
5
- // the Software without restriction, including without limitation the rights to use,
6
- // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- // Software, and to permit persons to whom the Software is furnished to do so,
8
- // subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
14
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
- // OTHER DEALINGS IN THE SOFTWARE.
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
21
3
 
22
4
  type LoadOptions = {
23
5
  lazy?: boolean,
@@ -277,7 +259,30 @@ type PrimitiveTypes =
277
259
  | 'wchar_t';
278
260
  export const types: Record<PrimitiveTypes, IKoffiCType>;
279
261
 
280
- // Internal stuff, don't use!
281
- export const node: {
282
- env: { __brand: 'IKoffiNodeEnv' }
283
- };
262
+ export interface IKoffiPollOptions {
263
+ readable?: boolean;
264
+ writable?: boolean;
265
+ disconnect?: boolean;
266
+ }
267
+
268
+ export interface IKoffiPollEvents {
269
+ readable: boolean;
270
+ writable: boolean;
271
+ disconnect: boolean;
272
+ }
273
+
274
+ export namespace node {
275
+ export const env: { __brand: 'IKoffiNodeEnv' };
276
+
277
+ export class PollHandle {
278
+ start(opts: IKoffiPollOptions, callback: (ev: IKoffiPollEvents) => void): void;
279
+ start(callback: (ev: IKoffiPollEvents) => void): void;
280
+ stop(): void;
281
+ close(): void;
282
+ unref(): void;
283
+ ref(): void;
284
+ }
285
+
286
+ export function poll(fd: number, opts: IKoffiPollOptions, callback: (ev: IKoffiPollEvents) => void): PollHandle;
287
+ export function poll(fd: number, callback: (ev: IKoffiPollEvents) => void): PollHandle;
288
+ }
package/index.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod3) => function __require() {
4
4
  return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
5
5
  };
6
6
 
7
- // ../../../bin/Koffi/package/src/cnoke/src/tools.js
7
+ // bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "../../../bin/Koffi/package/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");
@@ -397,12 +397,12 @@ var require_tools = __commonJS({
397
397
  }
398
398
  });
399
399
 
400
- // ../../../bin/Koffi/package/src/koffi/package.json
400
+ // bin/Koffi/package/src/koffi/package.json
401
401
  var require_package = __commonJS({
402
- "../../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
402
+ "bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
403
403
  module2.exports = {
404
404
  name: "koffi",
405
- version: "2.14.0",
405
+ version: "2.15.0",
406
406
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
407
407
  keywords: [
408
408
  "foreign",
@@ -438,14 +438,15 @@ var require_package = __commonJS({
438
438
  node: 16,
439
439
  napi: 8,
440
440
  require: "./index.js"
441
- }
441
+ },
442
+ funding: "https://buymeacoffee.com/koromix"
442
443
  };
443
444
  }
444
445
  });
445
446
 
446
- // ../../../bin/Koffi/package/src/koffi/src/init.js
447
+ // bin/Koffi/package/src/koffi/src/init.js
447
448
  var require_init = __commonJS({
448
- "../../../bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
449
+ "bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
449
450
  var fs = require("fs");
450
451
  var path = require("path");
451
452
  var util = require("util");
@@ -528,7 +529,7 @@ var require_init = __commonJS({
528
529
  }
529
530
  });
530
531
 
531
- // ../../../bin/Koffi/package/src/koffi/index.js
532
+ // bin/Koffi/package/src/koffi/index.js
532
533
  var { detect: detect2, init: init2 } = require_init();
533
534
  var triplet2 = detect2();
534
535
  var native2 = null;
package/indirect.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod3) => function __require() {
4
4
  return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
5
5
  };
6
6
 
7
- // ../../../bin/Koffi/package/src/cnoke/src/tools.js
7
+ // bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "../../../bin/Koffi/package/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");
@@ -397,12 +397,12 @@ var require_tools = __commonJS({
397
397
  }
398
398
  });
399
399
 
400
- // ../../../bin/Koffi/package/src/koffi/package.json
400
+ // bin/Koffi/package/src/koffi/package.json
401
401
  var require_package = __commonJS({
402
- "../../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
402
+ "bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
403
403
  module2.exports = {
404
404
  name: "koffi",
405
- version: "2.14.0",
405
+ version: "2.15.0",
406
406
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
407
407
  keywords: [
408
408
  "foreign",
@@ -438,14 +438,15 @@ var require_package = __commonJS({
438
438
  node: 16,
439
439
  napi: 8,
440
440
  require: "./index.js"
441
- }
441
+ },
442
+ funding: "https://buymeacoffee.com/koromix"
442
443
  };
443
444
  }
444
445
  });
445
446
 
446
- // ../../../bin/Koffi/package/src/koffi/src/init.js
447
+ // bin/Koffi/package/src/koffi/src/init.js
447
448
  var require_init = __commonJS({
448
- "../../../bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
449
+ "bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
449
450
  var fs = require("fs");
450
451
  var path = require("path");
451
452
  var util = require("util");
@@ -528,7 +529,7 @@ var require_init = __commonJS({
528
529
  }
529
530
  });
530
531
 
531
- // ../../../bin/Koffi/package/src/koffi/indirect.js
532
+ // bin/Koffi/package/src/koffi/indirect.js
532
533
  var { detect: detect2, init: init2 } = require_init();
533
534
  var triplet2 = detect2();
534
535
  var mod2 = init2(triplet2, null);