diff --git a/Cargo.lock b/Cargo.lock index 09fe9e5c347..1bd9a943811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1361,7 +1361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -1537,9 +1537,9 @@ dependencies = [ [[package]] name = "convert_case" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb402b8d4c85569410425650ce3eddc7d698ed96d39a73f941b08fb63082f1e7" +checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f" dependencies = [ "unicode-segmentation", ] @@ -1775,14 +1775,20 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +checksum = "ec09e802f5081de6157da9a75701d6c713d8dc3ba52571fd4bd25f412644e8a6" dependencies = [ - "quote", - "syn", + "ctor-proc-macro", + "dtor", ] +[[package]] +name = "ctor-proc-macro" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2931af7e13dc045d8e9d26afccc6fa115d64e115c9c84b1166288b46f6782c2" + [[package]] name = "ctr" version = "0.9.2" @@ -2125,6 +2131,21 @@ dependencies = [ "dtoa", ] +[[package]] +name = "dtor" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cbdf2ad6846025e8e25df05171abfb30e3ababa12ee0a0e44b9bbe570633a8" +dependencies = [ + "dtor-proc-macro", +] + +[[package]] +name = "dtor-proc-macro" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7454e41ff9012c00d53cf7f475c5e3afa3b91b7c90568495495e8d9bf47a1055" + [[package]] name = "dunce" version = "1.0.5" @@ -4852,7 +4873,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -5305,13 +5326,18 @@ dependencies = [ ] [[package]] -name = "napi-derive-backend-ohos" -version = "1.0.4" +name = "napi-build-ohos" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd974d6316c670078fa15276c6134e5b45142b393db350b24682ae613733cdac" +checksum = "959f833e4ea8bec8f92b23b705b5558d42d8e63672c77b9b281b7228c5df6e88" + +[[package]] +name = "napi-derive-backend-ohos" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b27250baa967a15214e57384dd6228c59afbccb15ab8f97207c9758917544bf5" dependencies = [ "convert_case", - "once_cell", "proc-macro2", "quote", "semver", @@ -5320,11 +5346,12 @@ dependencies = [ [[package]] name = "napi-derive-ohos" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a8b89bbc39f81c472e76813dcd837f311aae7850a24a01d0bf5858221b1fd2" +checksum = "c844efa85d53b5adc3b326520f3a108c3a737b7534ee10d406f81884e7e71b3c" dependencies = [ "convert_case", + "ctor", "napi-derive-backend-ohos", "proc-macro2", "quote", @@ -5333,20 +5360,23 @@ dependencies = [ [[package]] name = "napi-ohos" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32036ede4ef064610304337831e9d49dac23e7edc4e9efd076c8259eab6d19a9" +checksum = "44cd7f1a2b5b17e763d8fcc33f3a9f426c0303a1fcb9b89d7c553308c3a1db97" dependencies = [ "bitflags 2.9.1", "ctor", + "napi-build-ohos", "napi-sys-ohos", + "nohash-hasher", + "rustc-hash 2.1.1", ] [[package]] name = "napi-sys-ohos" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e18642400316f886a6f153b2fbc48f5652d0e117803057005f89f0e48217d64" +checksum = "ff0b7e156bf62a778295ba4f130cde6c2fe07936ebf9448fab6ca0f7c7040682" dependencies = [ "libloading", ] @@ -9940,7 +9970,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 5b9cc4a7419..748983e0a65 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -93,8 +93,8 @@ euclid = { workspace = true } hilog = "0.2.2" # force inprocess until we add multi-process support for ohos ipc-channel = { workspace = true, features = ["force-inprocess"] } -napi-derive-ohos = "1.0.4" -napi-ohos = "1.0.4" +napi-derive-ohos = "1.1.0" +napi-ohos = "1.1.0" ohos-ime = "0.4.0" ohos-ime-sys = "0.2.2" ohos-deviceinfo = "0.1.0" diff --git a/ports/servoshell/egl/ohos.rs b/ports/servoshell/egl/ohos.rs index 8c6925396b3..baf19c7ea13 100644 --- a/ports/servoshell/egl/ohos.rs +++ b/ports/servoshell/egl/ohos.rs @@ -15,10 +15,10 @@ use std::time::Duration; use keyboard_types::{Key, NamedKey}; use log::{LevelFilter, debug, error, info, trace, warn}; -use napi_derive_ohos::{module_exports, napi}; -use napi_ohos::bindgen_prelude::Function; +use napi_derive_ohos::napi; +use napi_ohos::bindgen_prelude::{Function, JsObjectValue, Object}; use napi_ohos::threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode}; -use napi_ohos::{Env, JsObject, JsString, NapiRaw}; +use napi_ohos::{Env, JsString, JsValue}; use ohos_ime::{ AttachOptions, CreateImeProxyError, CreateTextEditorProxyError, Ime, ImeProxy, RawTextEditorProxy, @@ -124,12 +124,13 @@ const PROMPT_QUEUE_SIZE: usize = 4; // Todo: Need to check if OnceLock is suitable, or if the TS function can be destroyed, e.g. // if the activity gets suspended. static SET_URL_BAR_CB: OnceLock< - ThreadsafeFunction, + ThreadsafeFunction, +> = OnceLock::new(); +static TERMINATE_CALLBACK: OnceLock< + ThreadsafeFunction<(), (), (), napi_ohos::Status, false, false, 1>, > = OnceLock::new(); -static TERMINATE_CALLBACK: OnceLock> = - OnceLock::new(); static PROMPT_TOAST: OnceLock< - ThreadsafeFunction, + ThreadsafeFunction, > = OnceLock::new(); /// Storing webview related items @@ -594,9 +595,9 @@ pub fn set_log_filter(filter: Option<&str>) { (*LOGGER).set_filter(filter); } -fn register_xcomponent_callbacks(env: &Env, xcomponent: &JsObject) -> napi_ohos::Result<()> { +fn register_xcomponent_callbacks(env: &Env, xcomponent: &Object) -> napi_ohos::Result<()> { info!("napi_get_named_property call successfull"); - let raw = unsafe { xcomponent.raw() }; + let raw = xcomponent.raw(); let raw_env = env.raw(); let mut nativeXComponent: *mut OH_NativeXComponent = core::ptr::null_mut(); unsafe { @@ -634,7 +635,7 @@ fn register_xcomponent_callbacks(env: &Env, xcomponent: &JsObject) -> napi_ohos: } #[allow(unused)] -fn debug_jsobject(obj: &JsObject, obj_name: &str) -> napi_ohos::Result<()> { +fn debug_jsobject(obj: &Object, obj_name: &str) -> napi_ohos::Result<()> { let names = obj.get_property_names()?; error!("Getting property names of object {obj_name}"); let len = names.get_array_length()?; @@ -647,11 +648,11 @@ fn debug_jsobject(obj: &JsObject, obj_name: &str) -> napi_ohos::Result<()> { Ok(()) } -#[module_exports] -fn init(exports: JsObject, env: Env) -> napi_ohos::Result<()> { +#[napi(module_exports)] +fn init(exports: Object, env: Env) -> napi_ohos::Result<()> { initialize_logging_once(); info!("simpleservo init function called"); - if let Ok(xcomponent) = exports.get_named_property::("__NATIVE_XCOMPONENT_OBJ__") { + if let Ok(xcomponent) = exports.get_named_property::("__NATIVE_XCOMPONENT_OBJ__") { register_xcomponent_callbacks(&env, &xcomponent)?; }