koffi 3.0.0-alpha.2 → 3.0.0-alpha.4

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 (53) hide show
  1. package/build/koffi/darwin_arm64/koffi.node +0 -0
  2. package/build/koffi/darwin_x64/koffi.node +0 -0
  3. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  4. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  5. package/build/koffi/freebsd_x64/koffi.node +0 -0
  6. package/build/koffi/linux_arm64/koffi.node +0 -0
  7. package/build/koffi/linux_ia32/koffi.node +0 -0
  8. package/build/koffi/linux_x64/koffi.node +0 -0
  9. package/build/koffi/musl_arm64/koffi.node +0 -0
  10. package/build/koffi/musl_x64/koffi.node +0 -0
  11. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  12. package/build/koffi/openbsd_x64/koffi.node +0 -0
  13. package/build/koffi/win32_ia32/koffi.node +0 -0
  14. package/build/koffi/win32_x64/koffi.node +0 -0
  15. package/index.cjs +1 -0
  16. package/index.js +1 -1
  17. package/indirect.cjs +1 -0
  18. package/indirect.js +1 -1
  19. package/lib/native/base/base.cc +15 -1
  20. package/lib/native/base/base.hh +16 -6
  21. package/package.json +5 -4
  22. package/src/build.js +15 -377
  23. package/src/koffi/index.cjs +453 -0
  24. package/src/koffi/index.js +275 -263
  25. package/src/koffi/indirect.cjs +452 -0
  26. package/src/koffi/indirect.js +193 -127
  27. package/src/koffi/src/ffi.cc +0 -1
  28. package/src/koffi/src/primitives.inc +1 -1
  29. package/src/koffi/src/uv.cc +0 -2
  30. package/src/koffi/src/uv.hh +59 -1
  31. package/vendor/node-addon-api/napi-inl.h +0 -4
  32. package/doc/benchmarks.xlsx +0 -0
  33. package/lib/native/base/crc.inc +0 -2214
  34. package/lib/native/base/crc_gen.py +0 -72
  35. package/lib/native/base/mimetypes.inc +0 -1248
  36. package/lib/native/base/mimetypes_gen.py +0 -58
  37. package/lib/native/base/tower.cc +0 -821
  38. package/lib/native/base/tower.hh +0 -81
  39. package/lib/native/base/unicode_gen.py +0 -152
  40. package/vendor/node-api-headers/include/uv/aix.h +0 -32
  41. package/vendor/node-api-headers/include/uv/bsd.h +0 -34
  42. package/vendor/node-api-headers/include/uv/darwin.h +0 -61
  43. package/vendor/node-api-headers/include/uv/errno.h +0 -483
  44. package/vendor/node-api-headers/include/uv/linux.h +0 -34
  45. package/vendor/node-api-headers/include/uv/os390.h +0 -33
  46. package/vendor/node-api-headers/include/uv/posix.h +0 -31
  47. package/vendor/node-api-headers/include/uv/sunos.h +0 -44
  48. package/vendor/node-api-headers/include/uv/threadpool.h +0 -37
  49. package/vendor/node-api-headers/include/uv/tree.h +0 -521
  50. package/vendor/node-api-headers/include/uv/unix.h +0 -512
  51. package/vendor/node-api-headers/include/uv/version.h +0 -43
  52. package/vendor/node-api-headers/include/uv/win.h +0 -698
  53. package/vendor/node-api-headers/include/uv.h +0 -1990
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.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./src/koffi/index.cjs");
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("./src/koffi/index.js");
1
+ export koffi from "./src/koffi/index.js";
package/indirect.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./src/koffi/indirect.cjs");
package/indirect.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("./src/koffi/indirect.js");
1
+ export koffi from "./src/koffi/indirect.js";
@@ -2,7 +2,9 @@
2
2
  // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
3
 
4
4
  #include "base.hh"
5
- #include "crc.inc"
5
+ #if __has_include("crc.inc")
6
+ #include "crc.inc"
7
+ #endif
6
8
  #include "unicode.inc"
7
9
 
8
10
  #if __has_include("vendor/dragonbox/include/dragonbox/dragonbox.h")
@@ -10696,6 +10698,8 @@ const char *PromptPath(const char *prompt, const char *default_path, Span<const
10696
10698
  // Mime types
10697
10699
  // ------------------------------------------------------------------------
10698
10700
 
10701
+ #if __has_include("mimetypes.inc")
10702
+
10699
10703
  const char *GetMimeType(Span<const char> extension, const char *default_type)
10700
10704
  {
10701
10705
  static const HashMap<Span<const char>, const char *> mimetypes = {
@@ -10771,6 +10775,8 @@ bool CanCompressFile(const char *filename)
10771
10775
  return true;
10772
10776
  }
10773
10777
 
10778
+ #endif
10779
+
10774
10780
  // ------------------------------------------------------------------------
10775
10781
  // Unicode
10776
10782
  // ------------------------------------------------------------------------
@@ -10792,6 +10798,8 @@ bool IsValidUtf8(Span<const char> str)
10792
10798
  return i == str.len;
10793
10799
  }
10794
10800
 
10801
+ #if __has_include("unicode.inc")
10802
+
10795
10803
  static bool TestUnicodeTable(Span<const int32_t> table, int32_t uc)
10796
10804
  {
10797
10805
  K_ASSERT(table.len > 0);
@@ -10862,10 +10870,14 @@ bool IsXidContinue(int32_t uc)
10862
10870
  return false;
10863
10871
  }
10864
10872
 
10873
+ #endif
10874
+
10865
10875
  // ------------------------------------------------------------------------
10866
10876
  // CRC
10867
10877
  // ------------------------------------------------------------------------
10868
10878
 
10879
+ #if __has_include("crc.inc")
10880
+
10869
10881
  uint32_t CRC32(uint32_t state, Span<const uint8_t> buf)
10870
10882
  {
10871
10883
  state = ~state;
@@ -10990,4 +11002,6 @@ uint64_t CRC64nvme(uint64_t state, Span<const uint8_t> buf)
10990
11002
  return ~state;
10991
11003
  }
10992
11004
 
11005
+ #endif
11006
+
10993
11007
  }
@@ -107,17 +107,14 @@ extern StreamReader *const StdIn;
107
107
  extern StreamWriter *const StdOut;
108
108
  extern StreamWriter *const StdErr;
109
109
 
110
- #if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || __riscv_xlen == 64 || defined(__loongarch64)
110
+ #if INTPTR_MAX == INT64_MAX
111
111
  typedef int64_t Size;
112
112
  #define K_SIZE_MAX INT64_MAX
113
- #elif defined(_WIN32) || defined(__APPLE__) || defined(__unix__)
114
- typedef int32_t Size;
115
- #define K_SIZE_MAX INT32_MAX
116
- #elif defined(__thumb__) || defined(__arm__) || defined(__wasm32__)
113
+ #elif INTPTR_MAX == INT32_MAX
117
114
  typedef int32_t Size;
118
115
  #define K_SIZE_MAX INT32_MAX
119
116
  #else
120
- #error Machine architecture not supported
117
+ #error This code base is not designed to support non-32-or-64-bit platforms
121
118
  #endif
122
119
 
123
120
  #if defined(_MSC_VER) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
@@ -135,6 +132,7 @@ extern StreamWriter *const StdErr;
135
132
  #error This code base is not designed to support non-64-bits long long types
136
133
  #endif
137
134
  static_assert(sizeof(double) == 8, "This code base is not designed to support single-precision double floats");
135
+ static_assert(sizeof(intptr_t) == sizeof(size_t), "This code base assumes that intptr_t and size_t are the same size");
138
136
 
139
137
  #define K_STRINGIFY_(a) #a
140
138
  #define K_STRINGIFY(a) K_STRINGIFY_(a)
@@ -5893,10 +5891,14 @@ static inline const char *PromptPath(const char *prompt, Allocator *alloc)
5893
5891
  // Mime types
5894
5892
  // ------------------------------------------------------------------------
5895
5893
 
5894
+ #if __has_include("mimetypes.inc")
5895
+
5896
5896
  const char *GetMimeType(Span<const char> extension, const char *default_type = "application/octet-stream");
5897
5897
 
5898
5898
  bool CanCompressFile(const char *filename);
5899
5899
 
5900
+ #endif
5901
+
5900
5902
  // ------------------------------------------------------------------------
5901
5903
  // Unicode
5902
5904
  // ------------------------------------------------------------------------
@@ -6012,19 +6014,27 @@ static inline Size EncodeUtf8(int32_t c, char out_buf[4])
6012
6014
 
6013
6015
  bool IsValidUtf8(Span<const char> str);
6014
6016
 
6017
+ #if __has_include("unicode.inc")
6018
+
6015
6019
  int ComputeUnicodeWidth(Span<const char> str);
6016
6020
 
6017
6021
  bool IsXidStart(int32_t uc);
6018
6022
  bool IsXidContinue(int32_t uc);
6019
6023
 
6024
+ #endif
6025
+
6020
6026
  // ------------------------------------------------------------------------
6021
6027
  // CRC
6022
6028
  // ------------------------------------------------------------------------
6023
6029
 
6030
+ #if __has_include("crc.inc")
6031
+
6024
6032
  uint32_t CRC32(uint32_t state, Span<const uint8_t> buf);
6025
6033
  uint32_t CRC32C(uint32_t state, Span<const uint8_t> buf);
6026
6034
 
6027
6035
  uint64_t CRC64xz(uint64_t state, Span<const uint8_t> buf);
6028
6036
  uint64_t CRC64nvme(uint64_t state, Span<const uint8_t> buf);
6029
6037
 
6038
+ #endif
6039
+
6030
6040
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -21,8 +21,7 @@
21
21
  "email": "niels.martignene@protonmail.com",
22
22
  "url": "https://koromix.dev/"
23
23
  },
24
- "main": "./index.js",
25
- "types": "./index.d.ts",
24
+ "module": "./index.js",
26
25
  "scripts": {
27
26
  "install": "node src/build.js -P . -D src/koffi --prebuild --release"
28
27
  },
@@ -33,5 +32,7 @@
33
32
  "node": 16,
34
33
  "napi": 8
35
34
  },
36
- "funding": "https://liberapay.com/Koromix"
35
+ "funding": "https://liberapay.com/Koromix",
36
+ "main": "./index.cjs",
37
+ "types": "./index.d.ts"
37
38
  }