Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koffi

Package Overview
Dependencies
Maintainers
1
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koffi - npm Package Compare versions

Comparing version 2.5.8 to 2.5.9

build/koffi/darwin_arm64/koffi.node

110

CHANGELOG.md

@@ -7,6 +7,16 @@ # Changelog

#### Koffi 2.5.8
#### Koffi 2.5.9
**Main changes:**
- Use bundler-friendly static require calls in Koffi
- Add packaging examples to documentation
**Other changes:**
- Add missing unload() export to TS file
- Add export for koffi.types in TS file
#### Koffi 2.5.8
- Add more search paths for native Koffi modules

@@ -17,4 +27,2 @@ - Add section [about bundling](start.md#bundling-koffi) to documentation

**Main changes:**
- Point package to new repository

@@ -24,4 +32,2 @@

**Main changes:**
- Increase limit of output parameters from 16 to 32

@@ -31,4 +37,2 @@

**Main changes:**
- Support decoding non-char null-terminated arrays

@@ -38,8 +42,3 @@

**Main changes:**
- Fix `koffi.pointer()` not accepting disposable types
**Other changes:**
- Fix potential issues when making pointers to anonymous types

@@ -49,8 +48,3 @@

**Main changes:**
- Add missing union exports in TS definition file
**Other changes:**
- Fix some parameter names in TS definition file

@@ -60,4 +54,2 @@

**Main changes:**
- Default initialize unset object/struct members

@@ -67,4 +59,2 @@

**Main changes:**
- Fix crash with some struct types in System V 64 ABI

@@ -88,8 +78,3 @@ - Always use direct passthrough for buffer arguments

**Main changes:**
- Support calling variadic function pointers
**Other changes:**
- Add documentation for function pointers

@@ -116,4 +101,2 @@

**Main fixes:**
- Support explicit library unloading with `lib.unload()`

@@ -123,4 +106,2 @@

**Main fixes:**
- Actually allow non-ambiguous [string] values for `void *` arguments

@@ -130,4 +111,2 @@

**Main fixes:**
- Fix possible crash on exit caused by unregistered callbacks

@@ -137,4 +116,2 @@

**Main changes:**
- Allow strings for input `void *`, `int8_t *` and `int16_t *` pointer arguments

@@ -145,9 +122,4 @@ - Support using `[string]` (single-element string arrays) for polymorphic input/output arguments

**Main changes:**
- Fix Windows ARM64 build to work with official Node.js version
- Compile Windows builds with Visual Studio 2022 17.5.3
**Other changes:**
- Support null in `koffi.free()` and `koffi.address()`

@@ -157,4 +129,2 @@

**Main changes:**
- Improve manual decoding of 0-terminated strings

@@ -165,4 +135,2 @@ - Add checks around array conversion hints

**Main changes:**
- Add `koffi.errno()` function to get and set current errno value

@@ -173,4 +141,2 @@ - Add `koffi.os.errno` object with valid errno codes

**Main changes:**
- Add `koffi.address()` to get the raw value of a wrapper pointer

@@ -180,4 +146,2 @@

**Main fixes:**
- Fix broken syntax in TS definition file

@@ -200,4 +164,2 @@ - Add missing exported properties in TS file

**Main changes:**
- Relicense under MIT license

@@ -207,4 +169,2 @@

**Main fixes:**
- Disable non-ready union support

@@ -216,4 +176,2 @@ - Simplify Windows stack allocation and drop NOACCESS and GUARD pages

**Main fixes:**
- Fix missing require in index.js ([@gastonFrecceroNapse](https://github.com/gastonFrecceroNapse))

@@ -224,4 +182,2 @@ - Reduce NPM package bloat (from 65 MB to 20 MB) caused by changes in 2.3.6

**Main changes:**
- Fix broken TS definition file

@@ -248,4 +204,2 @@ - Keep all prebuilt binaries and load correct one at runtime

**Main fixes:**
- Fix error when installing Koffi on Windows (2.3.2)

@@ -268,4 +222,2 @@

**Main changes:**
- Error out when trying to use ambiguous `void *` arguments (input and/or output)

@@ -296,4 +248,2 @@ - Adjust TypeScript definitions ([@insraq](https://github.com/insraq))

**Main changes:**
- Relicense Koffi under LGPL 3.0

@@ -303,8 +253,3 @@

**Main fixes:**
- Fix memory leak on Windows (in Koffi 2.2.3) when running many async calls
**Other changes:**
- Reorganize documentation pages

@@ -314,8 +259,3 @@

**Main fixes:**
- Support native code that uses [Structured Exception Handling (SEH)](https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp) on Windows (x86, x64 and ARM64)
**Other changes:**
- Try to use ebp/rbp as frame pointer in x86/x64 ASM code

@@ -339,4 +279,2 @@

**Main fixes:**
- Fix crash when [calling callback again after FFI call inside previous callback](https://github.com/Koromix/rygel/issues/15)

@@ -362,4 +300,2 @@

**Main fixes:**
- Add missing README.md file to NPM package

@@ -380,4 +316,2 @@

**Main changes:**
- Support up to 16 output parameters (instead of 8)

@@ -387,4 +321,2 @@

**Main changes:**
- Support up to 8 output parameters (instead of 4)

@@ -394,4 +326,2 @@

**Main fixes:**
- Fix potential memory allocation bugs

@@ -421,4 +351,2 @@

**Main changes:**
- Return `undefined` (instead of null) for `void` functions

@@ -454,4 +382,2 @@

**Main fixes:**
- Fix support for Yarn package manager

@@ -461,4 +387,2 @@

**Main fixes:**
- Fix broken parsing of `void *` when used for first parameter

@@ -480,4 +404,2 @@

**Main fixes:**
- Fix prebuild compatibility with Electron on Windows x64

@@ -535,4 +457,2 @@

**Main fixes:**
- Fix possible OpenBSD i386 crash with `(void)` functions

@@ -554,4 +474,2 @@

**Main fixes:**
- Support compilation in C++14 mode (graceful degradation)

@@ -562,4 +480,2 @@ - Support older toolchains on Linux (tested on Debian 9)

**Main fixes:**
- The prebuilt binary is tested when Koffi is installed, and a rebuild happens if it fails to load

@@ -587,4 +503,2 @@

**New features:**
- Windows ARM64 is now supported

@@ -594,4 +508,2 @@

**New features:**
- A prebuilt binary for macOS ARM64 (M1) is now included

@@ -598,0 +510,0 @@

@@ -112,37 +112,2 @@ # Get started

*Improved in Koffi 2.5.8*
Koffi uses native modules to work. The NPM package contains binaries for various platforms and architectures, and the appropriate module is selected at runtime.
If you use a bundler, you must make sure that the {{ "`node_modules/koffi/build/" ~ stable ~ "`" }} directory is available in your bundled script.
Here is an example that would work:
```{eval-rst}
.. parsed-literal::
koffi/
|version|/
win32_x64/
koffi.node
linux_x64/
koffi.node
...
MyBundle.js
```
When running in Electron, Koffi will also try to find the native module in `process.resourcesPath`. For an Electron app you could do something like this
```{eval-rst}
.. parsed-literal::
locales/
resources/
koffi/
|version|/
darwin_arm64/
koffi.node
darwin_x64/
koffi.node
MyApp.exe
```
You must configure your bundler and/or your packager to make this work.
Please read the [dedicated page](packaging.md) for information about bundling and packaging applications using Koffi.
{
"name": "koffi",
"version": "2.5.8",
"stable": "2.5.8",
"version": "2.5.9",
"stable": "2.5.9",
"description": "Fast and simple C FFI (foreign function interface) for Node.js",

@@ -6,0 +6,0 @@ "keywords": [

@@ -82,2 +82,4 @@ // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>

thiscall(name: string, result: TypeSpec, arguments: TypeSpec[]): KoffiFunction;
unload(): void;
}

@@ -153,2 +155,4 @@

};
export const types: Record<string, IKoffiCType>;
}

@@ -41,29 +41,58 @@ // Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>

let arch = cnoke.determine_arch();
let triplet = `${process.platform}_${arch}`;
let filenames = [
__dirname + `/../build/${pkg.version}/${process.platform}_${arch}/koffi.node`,
__dirname + `/build/koffi/${pkg.version}/${process.platform}_${arch}/koffi.node`,
__dirname + `/koffi/${pkg.version}/${process.platform}_${arch}/koffi.node`,
__dirname + `/../build/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`,
__dirname + `/build/koffi/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`,
__dirname + `/koffi/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`
];
let native = null;
if (process.resourcesPath != null) {
filenames.push(
process.resourcesPath + `/build/${pkg.version}/${process.platform}_${arch}/koffi.node`,
process.resourcesPath + `/build/koffi/${pkg.version}/${process.platform}_${arch}/koffi.node`,
process.resourcesPath + `/koffi/${pkg.version}/${process.platform}_${arch}/koffi.node`,
process.resourcesPath + `/build/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`,
process.resourcesPath + `/build/koffi/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`,
process.resourcesPath + `/koffi/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`
);
// Try an explicit list with static strings to help bundlers
try {
switch (triplet) {
case 'darwin_arm64': { native = require('../build/koffi/darwin_arm64/koffi.node'); } break;
case 'darwin_x64': { native = require('../build/koffi/darwin_x64/koffi.node'); } break;
case 'freebsd_arm46': { native = require('../build/koffi/freebsd_arm46/koffi.node'); } break;
case 'freebsd_ia32': { native = require('../build/koffi/freebsd_ia32/koffi.node'); } break;
case 'freebsd_x64': { native = require('../build/koffi/freebsd_x64/koffi.node'); } break;
case 'linux_arm32hf': { native = require('../build/koffi/linux_arm32hf/koffi.node'); } break;
case 'linux_arm64': { native = require('../build/koffi/linux_arm64/koffi.node'); } break;
case 'linux_ia32': { native = require('../build/koffi/linux_ia32/koffi.node'); } break;
case 'linux_risc64hf64': { native = require('../build/koffi/linux_risc64hf64/koffi.node'); } break;
case 'linux_x64': { native = require('../build/koffi/linux_x64/koffi.node'); } break;
case 'openbsd_ia32': { native = require('../build/koffi/openbsd_ia32/koffi.node'); } break;
case 'openbsd_x64': { native = require('../build/koffi/openbsd_x64/koffi.node'); } break;
case 'win32_arm64': { native = require('../build/koffi/win32_arm64/koffi.node'); } break;
case 'win32_ia32': { native = require('../build/koffi/win32_ia32/koffi.node'); } break;
case 'win32_x64': { native = require('../build/koffi/win32_x64/koffi.node'); } break;
}
} catch (err) {
// Go on!
}
let filename = filenames.find(filename => fs.existsSync(filename));
if (filename == null)
// And now, search everywhere we know
if (native == null) {
let names = [
`/koffi/${process.platform}_${arch}/koffi.node`,
`/node_modules/koffi/build/koffi/${process.platform}_${arch}/koffi.node`
];
for (let name of names) {
if (fs.existsSync(__dirname + name)) {
native = require(__dirname + name);
break;
}
}
if (native == null && process.resourcesPath != null) {
for (let name of names) {
if (fs.existsSync(process.resourcesPath + name)) {
native = require(process.resourcesPath + name);
break;
}
}
}
}
if (native == null)
throw new Error('Cannot find the native Koffi module; did you bundle it correctly?');
if (native.version != pkg.version)
throw new Error('Mismatched native Koffi modules');
let native = require(filename);
module.exports = {

@@ -70,0 +99,0 @@ ...native,

@@ -50,2 +50,8 @@ # Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>

file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.json PKG)
string(REGEX MATCH "\"version\": \"([^\"]+)\"" XX "${PKG}")
set(KOFFI_VERSION ${CMAKE_MATCH_1})
set_source_files_properties(src/ffi.cc PROPERTIES COMPILE_DEFINITIONS VERSION=${KOFFI_VERSION})
set(KOFFI_SRC

@@ -52,0 +58,0 @@ src/call.cc

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc