koffi-cream 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 (3) hide show
  1. package/README.md +10 -10
  2. package/index.d.ts +29 -24
  3. package/package.json +14 -14
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # koffi-cream
2
- A lighter packaging of Niels Martignène's excellent [Koffi](https://koffi.dev).
2
+ A lighter repackaging of Niels Martignène's excellent [Koffi](https://koffi.dev).
3
3
 
4
4
  Just `npm install koffi-cream` instead of `koffi` and use it like the real thing:
5
5
 
@@ -12,7 +12,10 @@ const some_func = lib.func('int some_func(int a, int b)')
12
12
  ```
13
13
 
14
14
  > [!IMPORTANT]
15
- > **This package is neither a fork nor a patch. It *is* the original Koffi**, only packaged differently to avoid downloading a megalithic[^1] package bloated with files unnecessary to the average user[^2].
15
+ > **koffi-cream is neither a fork nor a patch. It *is* the original Koffi**, only packaged differently to avoid downloading a megalithic[^1] package bloated with files unnecessary to the average user[^2].
16
+
17
+ [^1]: As of 2.14.0, Koffi weights 16.9 MB compressed and 86 MB uncompressed.
18
+ [^2]: Koffi's package includes 18 native binaries (of which 17 are not compatible with your platform), the build tools and the full source code.
16
19
 
17
20
 
18
21
  ## The why and the how
@@ -24,17 +27,14 @@ This way, when you install `koffi-cream`, your package manager will only downloa
24
27
  - `koffi-cream` (this package): 5.1 kB compressed / 19.8 kB uncompressed
25
28
  - `@septh/koffi-win32-x64`: 536.2 kB compressed / 2.4 MB uncompressed
26
29
 
27
- **That's 97.2% off compared to the original Koffi package!**
30
+ **That's 74.2% off compared to the original Koffi package!**
28
31
 
29
32
  > [!NOTE]
30
- > The `os` and `cpu` are standard properties, supported by all package managers. But the `libc` property, used to distinguish Linux distros between gnu and musl, is newer and only supported by `npm 10.4.0` and later, `pnpm 7.1.0` and later, and `yarn 3.2.0` and later.
31
-
32
- [^1]: As of 2.14.0, Koffi weights 16.9 MB compressed and 86 MB uncompressed.
33
- [^2]: Koffi's package includes 18 natives binaries (of which 17 are not compatible with your platform), the build tools and the full source code.
33
+ > The `libc` property, used to distinguish Linux distros between gnu and musl, is only supported by `npm 10.4.0` and later, `pnpm 7.1.0` and later, and `yarn 3.2.0` and later.
34
34
 
35
35
 
36
36
  ## Available packages
37
- `koffi-cream` only offers a subset of Koffi's 18 native builds:
37
+ `koffi-cream` purposely only offers a subset of Koffi's 18 native builds:
38
38
 
39
39
  | Koffi binary | koffi-cream package |
40
40
  |---------------|--------------------------------------------------------------------------------------------|
@@ -57,13 +57,13 @@ This way, when you install `koffi-cream`, your package manager will only downloa
57
57
  | win32-ia32 | ❌ |
58
58
  | win32-x64 | [@septh/koffi-win32-x64](https://www.npmjs.com/package/@septh/koffi-win32-x64) |
59
59
 
60
- I do not plan to add the missing builds. If you need one of these, you'll have to stick with Koffi.
60
+ I do not plan to add the other builds. If you need one of these, you'll have to stick with Koffi.
61
61
 
62
62
 
63
63
  ## Version numbering
64
64
  To make things easy on the user, `koffi-cream`'s version number will always be aligned with Koffi's.
65
65
 
66
- Hence, there is no `koffi-cream` 1.x or 2.0; the first version published is 2.11.0 which ships with Koffi's 2.11.0 binaries.
66
+ Hence, there is no `koffi-cream` 1.x or 2.0; the first version published is 2.11.0 which ships with Koffi 2.11.0 binaries.
67
67
 
68
68
 
69
69
  ## Related
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi-cream",
3
- "version": "2.14.0",
3
+ "version": "2.15.0",
4
4
  "description": "A lighter packaging for Koffi, the fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "author": {
6
6
  "name": "Stephan 'Septh' Schreiber",
@@ -41,18 +41,18 @@
41
41
  "main": "index.js",
42
42
  "types": "index.d.ts",
43
43
  "optionalDependencies": {
44
- "@septh/koffi-darwin-arm64": "2.14.0",
45
- "@septh/koffi-darwin-x64": "2.14.0",
46
- "@septh/koffi-freebsd-arm64": "2.14.0",
47
- "@septh/koffi-freebsd-x64": "2.14.0",
48
- "@septh/koffi-linux-arm64-glibc": "2.14.0",
49
- "@septh/koffi-linux-loong64": "2.14.0",
50
- "@septh/koffi-linux-riscv64": "2.14.0",
51
- "@septh/koffi-linux-x64-glibc": "2.14.0",
52
- "@septh/koffi-linux-arm64-musl": "2.14.0",
53
- "@septh/koffi-linux-x64-musl": "2.14.0",
54
- "@septh/koffi-openbsd-x64": "2.14.0",
55
- "@septh/koffi-win32-arm64": "2.14.0",
56
- "@septh/koffi-win32-x64": "2.14.0"
44
+ "@septh/koffi-darwin-arm64": "2.15.0",
45
+ "@septh/koffi-darwin-x64": "2.15.0",
46
+ "@septh/koffi-freebsd-arm64": "2.15.0",
47
+ "@septh/koffi-freebsd-x64": "2.15.0",
48
+ "@septh/koffi-linux-arm64-glibc": "2.15.0",
49
+ "@septh/koffi-linux-loong64": "2.15.0",
50
+ "@septh/koffi-linux-riscv64": "2.15.0",
51
+ "@septh/koffi-linux-x64-glibc": "2.15.0",
52
+ "@septh/koffi-linux-arm64-musl": "2.15.0",
53
+ "@septh/koffi-linux-x64-musl": "2.15.0",
54
+ "@septh/koffi-openbsd-x64": "2.15.0",
55
+ "@septh/koffi-win32-arm64": "2.15.0",
56
+ "@septh/koffi-win32-x64": "2.15.0"
57
57
  }
58
58
  }