diff --git a/Cargo.lock b/Cargo.lock index bd7252f..f7a449d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,15 +43,12 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +dependencies = [ + "serde", +] [[package]] name = "cc" @@ -139,7 +136,7 @@ version = "2.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1bd081bbaef43600fd2c5dd4c525b8ecea7dfdacf40ebc674e87851dce6559e" dependencies = [ - "bitflags 2.6.0", + "bitflags", "ctor", "napi-derive", "napi-sys", @@ -222,9 +219,9 @@ checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -319,11 +316,10 @@ dependencies = [ [[package]] name = "steamworks" -version = "0.11.0" -source = "git+https://github.com/Noxime/steamworks-rs/?rev=fbb79635b06b4feea8261e5ca3e8ea3ef42facf9#fbb79635b06b4feea8261e5ca3e8ea3ef42facf9" +version = "0.12.1" +source = "git+https://github.com/Noxime/steamworks-rs/?rev=40a457a61f5ef714d93804e51e0c5e3d405145a3#40a457a61f5ef714d93804e51e0c5e3d405145a3" dependencies = [ - "bitflags 1.3.2", - "lazy_static", + "bitflags", "paste", "serde", "steamworks-sys", @@ -332,8 +328,8 @@ dependencies = [ [[package]] name = "steamworks-sys" -version = "0.11.0" -source = "git+https://github.com/Noxime/steamworks-rs/?rev=fbb79635b06b4feea8261e5ca3e8ea3ef42facf9#fbb79635b06b4feea8261e5ca3e8ea3ef42facf9" +version = "0.12.0" +source = "git+https://github.com/Noxime/steamworks-rs/?rev=40a457a61f5ef714d93804e51e0c5e3d405145a3#40a457a61f5ef714d93804e51e0c5e3d405145a3" [[package]] name = "steamworksjs" @@ -351,9 +347,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -362,18 +358,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index c6d4428..396540a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ napi = { version = "2.16.8", features = ["tokio_rt", "napi6", "serde-json"] } napi-derive = "2.16.9" lazy_static = "1" tokio = { version = "1", features = ["sync", "time"] } -steamworks = { git = "https://github.com/Noxime/steamworks-rs/", rev = "fbb79635b06b4feea8261e5ca3e8ea3ef42facf9", features = ["serde"] } +steamworks = { git = "https://github.com/Noxime/steamworks-rs/", rev = "40a457a61f5ef714d93804e51e0c5e3d405145a3", features = ["serde"] } serde = "1" serde_json = "1" diff --git a/client.d.ts b/client.d.ts index a2501ab..23cf73c 100644 --- a/client.d.ts +++ b/client.d.ts @@ -335,7 +335,7 @@ export declare namespace workshop { * Get all subscribed workshop items. * @returns an array of subscribed workshop item ids */ - export function getSubscribedItems(): Array + export function getSubscribedItems(includeLocallyDisabled: boolean): Array export const enum UGCQueryType { RankedByVote = 0, RankedByPublicationDate = 1, diff --git a/sdk/redistributable_bin/linux32/libsteam_api.so b/sdk/redistributable_bin/linux32/libsteam_api.so index d0e9958..2d9e8a7 100644 Binary files a/sdk/redistributable_bin/linux32/libsteam_api.so and b/sdk/redistributable_bin/linux32/libsteam_api.so differ diff --git a/sdk/redistributable_bin/linux64/libsteam_api.so b/sdk/redistributable_bin/linux64/libsteam_api.so index 99c9164..8783570 100644 Binary files a/sdk/redistributable_bin/linux64/libsteam_api.so and b/sdk/redistributable_bin/linux64/libsteam_api.so differ diff --git a/sdk/redistributable_bin/osx/libsteam_api.dylib b/sdk/redistributable_bin/osx/libsteam_api.dylib index 0bbdeeb..c493b2b 100644 Binary files a/sdk/redistributable_bin/osx/libsteam_api.dylib and b/sdk/redistributable_bin/osx/libsteam_api.dylib differ diff --git a/sdk/redistributable_bin/steam_api.dll b/sdk/redistributable_bin/steam_api.dll index 7fde3a3..2372ab1 100644 Binary files a/sdk/redistributable_bin/steam_api.dll and b/sdk/redistributable_bin/steam_api.dll differ diff --git a/sdk/redistributable_bin/steam_api.lib b/sdk/redistributable_bin/steam_api.lib index f163d0c..4efd430 100644 Binary files a/sdk/redistributable_bin/steam_api.lib and b/sdk/redistributable_bin/steam_api.lib differ diff --git a/sdk/redistributable_bin/win64/steam_api64.dll b/sdk/redistributable_bin/win64/steam_api64.dll index 9ad453c..6d11825 100644 Binary files a/sdk/redistributable_bin/win64/steam_api64.dll and b/sdk/redistributable_bin/win64/steam_api64.dll differ diff --git a/sdk/redistributable_bin/win64/steam_api64.lib b/sdk/redistributable_bin/win64/steam_api64.lib index 4a9b011..1f1c623 100644 Binary files a/sdk/redistributable_bin/win64/steam_api64.lib and b/sdk/redistributable_bin/win64/steam_api64.lib differ diff --git a/src/api/callback.rs b/src/api/callback.rs index 3978088..a58ae36 100644 --- a/src/api/callback.rs +++ b/src/api/callback.rs @@ -2,23 +2,37 @@ use napi_derive::napi; #[napi] pub mod callback { + use std::{ + collections::HashMap, + sync::{ + atomic::{AtomicU32, Ordering}, + Mutex, OnceLock, + }, + }; + use napi::{ threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode}, JsFunction, }; + static HANDLE_ID_COUNTER: AtomicU32 = AtomicU32::new(1); + static CALLBACK_REGISTRY: OnceLock>> = + OnceLock::new(); + + fn get_registry() -> &'static Mutex> { + CALLBACK_REGISTRY.get_or_init(|| Mutex::new(HashMap::new())) + } + #[napi] pub struct Handle { - handle: Option, + id: u32, } #[napi] impl Handle { #[napi] pub fn disconnect(&mut self) { - if let Some(handle) = self.handle.take() { - handle.disconnect(); - } + get_registry().lock().unwrap().remove(&self.id); } } @@ -79,9 +93,12 @@ pub mod callback { } }; - Handle { - handle: Some(handle), - } + let id = HANDLE_ID_COUNTER.fetch_add(1, Ordering::Relaxed); + let registry = get_registry(); + let mut map = registry.lock().unwrap(); + map.insert(id, handle); + + Handle { id } } fn register_callback( diff --git a/src/api/workshop.rs b/src/api/workshop.rs index 865235b..23495e9 100644 --- a/src/api/workshop.rs +++ b/src/api/workshop.rs @@ -7,7 +7,7 @@ pub mod workshop { use napi::threadsafe_function::ThreadsafeFunction; use napi::threadsafe_function::ThreadsafeFunctionCallMode; use std::path::Path; - use steamworks::{ClientManager, FileType, PublishedFileId, UpdateHandle}; + use steamworks::{FileType, PublishedFileId, UpdateHandle}; use tokio::sync::oneshot; #[napi(object)] @@ -61,11 +61,11 @@ pub mod workshop { impl UgcUpdate { pub fn submit( self, - mut update: UpdateHandle, + mut update: UpdateHandle, callback: impl FnOnce(Result<(PublishedFileId, bool), steamworks::SteamError>) + Send + 'static, - ) -> steamworks::UpdateWatchHandle { + ) -> steamworks::UpdateWatchHandle { if let Some(title) = self.title { update = update.title(title.as_str()); } @@ -394,9 +394,9 @@ pub mod workshop { /// Get all subscribed workshop items. /// @returns an array of subscribed workshop item ids #[napi] - pub fn get_subscribed_items() -> Vec { + pub fn get_subscribed_items(include_locally_disabled: bool) -> Vec { let client = crate::client::get_client(); - let result = client.ugc().subscribed_items(); + let result = client.ugc().subscribed_items(include_locally_disabled); result .iter() diff --git a/src/api/workshop_item.rs b/src/api/workshop_item.rs index 4a2dc73..318de0f 100644 --- a/src/api/workshop_item.rs +++ b/src/api/workshop_item.rs @@ -374,10 +374,10 @@ pub mod workshop { pub consumer: Option, } - fn handle_query_config( - mut query_handle: steamworks::QueryHandle, + fn handle_query_config( + mut query_handle: steamworks::QueryHandle, query_config: Option, - ) -> steamworks::QueryHandle { + ) -> steamworks::QueryHandle { // Apply statistics query parameters if provided if let Some(query_config) = query_config { if let Some(cached_response_max_age) = query_config.cached_response_max_age { diff --git a/src/lib.rs b/src/lib.rs index f637028..4b35d4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,6 @@ pub fn init(app_id: Option) -> Result<(), Error> { | SteamAPIInitError::VersionMismatch(msg) => Error::from_reason(msg), })?; - steam_client.user_stats().request_current_stats(); - client::set_client(steam_client); Ok(()) }