Update NAPI-RS to v3

This commit is contained in:
Oliver Hamlet
2025-07-27 10:00:40 +01:00
parent d6be961095
commit ac0a355117
9 changed files with 3052 additions and 254 deletions
+3 -3
View File
@@ -12,11 +12,11 @@ libloot = { path = ".." }
libloot-ffi-errors = { path = "../ffi-errors" }
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
napi = { version = "3.1.3", default-features = false, features = ["napi4"] }
napi-derive = "3.1.1"
[build-dependencies]
napi-build = "2.2.2"
napi-build = "2.2.3"
[lints]
workspace = true
+2370 -133
View File
File diff suppressed because it is too large Load Diff
+7 -10
View File
@@ -4,18 +4,15 @@
"main": "index.js",
"types": "index.d.ts",
"napi": {
"name": "libloot-nodejs",
"triples": {
"defaults": false,
"additional": [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu"
]
}
"binaryName": "libloot-nodejs",
"targets": [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu"
]
},
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "^2.18.4",
"@napi-rs/cli": "^3.0.4",
"ava": "^6.4.1"
},
"ava": {
@@ -30,7 +27,7 @@
"build:debug": "napi build --platform",
"prepublishOnly": "napi prepublish -t npm",
"test": "ava",
"universal": "napi universal",
"universalize": "napi universalize",
"version": "napi version"
},
"packageManager": "yarn@4.9.1"
+1 -1
View File
@@ -278,7 +278,7 @@ impl From<Vertex> for libloot::Vertex {
}
#[napi]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum EdgeType {
Hardcoded,
MasterFlag,
+1 -1
View File
@@ -6,7 +6,7 @@ use napi_derive::napi;
use crate::{database::Database, error::VerboseError, plugin::Plugin};
#[napi]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum GameType {
Oblivion,
Skyrim,
+5 -20
View File
@@ -12,10 +12,7 @@ mod game;
mod metadata;
mod plugin;
use napi::{
threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode},
Either,
};
use napi::threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode};
use napi_derive::napi;
pub use metadata::select_message_content;
@@ -45,7 +42,7 @@ pub const LIBLOOT_VERSION_MINOR: u32 = libloot::LIBLOOT_VERSION_MINOR;
pub const LIBLOOT_VERSION_PATCH: u32 = libloot::LIBLOOT_VERSION_PATCH;
#[napi]
#[derive(Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum LogLevel {
Trace,
Debug,
@@ -84,22 +81,10 @@ pub fn set_log_level(level: LogLevel) {
}
#[napi(ts_args_type = "callback: (logLevel: LogLevel, message: string) => void")]
pub fn set_logging_callback(callback: napi::JsFunction) -> napi::Result<()> {
let thread_safe_callback: ThreadsafeFunction<
(libloot::LogLevel, String),
ErrorStrategy::Fatal,
> = callback.create_threadsafe_function(0, |ctx| {
let (level, message): (libloot::LogLevel, String) = ctx.value;
Ok(vec![
Either::A::<LogLevel, _>(level.into()),
Either::B(message),
])
})?;
pub fn set_logging_callback(callback: ThreadsafeFunction<(LogLevel, String)>) -> napi::Result<()> {
let rust_callback = move |level: libloot::LogLevel, message: &str| {
thread_safe_callback.call(
(level, message.to_owned()),
callback.call(
Ok((LogLevel::from(level), message.to_owned())),
ThreadsafeFunctionCallMode::Blocking,
);
};
+2 -2
View File
@@ -120,7 +120,7 @@ pub fn select_message_content(
}
#[napi]
#[derive(Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum MessageType {
Say,
Warn,
@@ -384,7 +384,7 @@ impl From<PluginCleaningData> for libloot::metadata::PluginCleaningData {
}
#[napi]
#[derive(Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum TagSuggestion {
Addition,
Removal,
+616 -63
View File
File diff suppressed because it is too large Load Diff