From 2a7c0002750f960ace872d16b6735cade736714c Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 20 Mar 2024 22:43:50 +0800 Subject: [PATCH] Release independent packages - napi@3.0.0-alpha.0 - napi-derive@3.0.0-alpha.0 --- crates/backend/Cargo.toml | 2 +- crates/macro/Cargo.toml | 4 ++-- crates/napi/Cargo.toml | 3 +-- crates/napi/README.md | 4 ++-- .../src/bindgen_runtime/js_values/function.rs | 2 ++ crates/napi/src/js_values/global.rs | 21 +++++-------------- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/crates/backend/Cargo.toml b/crates/backend/Cargo.toml index 6368d3cf..a1eb6300 100644 --- a/crates/backend/Cargo.toml +++ b/crates/backend/Cargo.toml @@ -7,7 +7,7 @@ name = "napi-derive-backend" readme = "README.md" repository = "https://github.com/napi-rs/napi-rs" rust-version = "1.65" -version = "1.0.62" +version = "2.0.0-alpha.0" [package.metadata.workspaces] independent = true diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index cf721be7..62ef6bad 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -8,7 +8,7 @@ name = "napi-derive" readme = "README.md" repository = "https://github.com/napi-rs/napi-rs" rust-version = "1.65" -version = "2.16.0" +version = "3.0.0-alpha.0" [package.metadata.workspaces] independent = true @@ -23,7 +23,7 @@ type-def = ["napi-derive-backend/type-def"] [dependencies] convert_case = "0.6" -napi-derive-backend = { version = "1.0.62", path = "../backend" } +napi-derive-backend = { version = "2.0.0-alpha.0", path = "../backend" } proc-macro2 = "1" quote = "1" syn = { version = "2", features = ["fold", "full", "extra-traits"] } diff --git a/crates/napi/Cargo.toml b/crates/napi/Cargo.toml index a9754eb6..d0ac5440 100644 --- a/crates/napi/Cargo.toml +++ b/crates/napi/Cargo.toml @@ -8,7 +8,7 @@ name = "napi" readme = "README.md" repository = "https://github.com/napi-rs/napi-rs" rust-version = "1.65" -version = "2.16.0" +version = "3.0.0-alpha.0" [lib] doctest = false @@ -78,7 +78,6 @@ optional = true version = "0.4" [target.'cfg(target_family = "wasm")'.dependencies] -napi-derive = { path = "../macro", version = "2.10.1", default-features = false } tokio = { version = "1", optional = true, features = ["rt", "sync"] } [target.'cfg(not(target_family = "wasm"))'.dependencies] diff --git a/crates/napi/README.md b/crates/napi/README.md index f3490fd1..f82e5608 100644 --- a/crates/napi/README.md +++ b/crates/napi/README.md @@ -115,8 +115,8 @@ name = "awesome" crate-type = ["cdylib"] [dependencies] -napi = "2" -napi-derive = "2" +napi = "3" +napi-derive = "3" [build-dependencies] napi-build = "1" diff --git a/crates/napi/src/bindgen_runtime/js_values/function.rs b/crates/napi/src/bindgen_runtime/js_values/function.rs index eab1b2e4..498d8c19 100644 --- a/crates/napi/src/bindgen_runtime/js_values/function.rs +++ b/crates/napi/src/bindgen_runtime/js_values/function.rs @@ -242,6 +242,7 @@ impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> Function<'scope, } } +#[cfg(feature = "napi4")] pub struct ThreadsafeFunctionBuilder< Args: JsValuesTupleIntoVec, Return, @@ -254,6 +255,7 @@ pub struct ThreadsafeFunctionBuilder< _return: std::marker::PhantomData, } +#[cfg(feature = "napi4")] impl< Args: JsValuesTupleIntoVec, Return: FromNapiValue, diff --git a/crates/napi/src/js_values/global.rs b/crates/napi/src/js_values/global.rs index 61e37661..b626f5b0 100644 --- a/crates/napi/src/js_values/global.rs +++ b/crates/napi/src/js_values/global.rs @@ -1,8 +1,5 @@ use super::*; -use crate::{ - bindgen_runtime::{FromNapiValue, Function}, - threadsafe_function::UnknownReturnValue, -}; +use crate::bindgen_runtime::{FromNapiValue, Function, Unknown}; pub struct JsGlobal(pub(crate) Value); @@ -28,12 +25,8 @@ impl JSON { } impl JsGlobal { - pub fn set_interval( - &self, - handler: Function<(), UnknownReturnValue>, - interval: f64, - ) -> Result { - let func: Function<(Function<(), UnknownReturnValue>, f64), JsTimeout> = + pub fn set_interval(&self, handler: Function<(), Unknown>, interval: f64) -> Result { + let func: Function<(Function<(), Unknown>, f64), JsTimeout> = self.get_named_property_unchecked("setInterval")?; func.call((handler, interval)) } @@ -44,12 +37,8 @@ impl JsGlobal { func.call(timer) } - pub fn set_timeout( - &self, - handler: Function<(), UnknownReturnValue>, - interval: f64, - ) -> Result { - let func: Function<(Function<(), UnknownReturnValue>, f64), JsTimeout> = + pub fn set_timeout(&self, handler: Function<(), Unknown>, interval: f64) -> Result { + let func: Function<(Function<(), Unknown>, f64), JsTimeout> = self.get_named_property_unchecked("setTimeout")?; func.call((handler, interval)) }