Compare commits
	
		
			7 Commits
		
	
	
		
			kcl-46
			...
			coredump-e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 043bfe263f | |||
| 66064dca58 | |||
| cdb12f8e6f | |||
| 9f43dc5fc8 | |||
| 36dc589b32 | |||
| e7d6bccc60 | |||
| a76dcd76fc | 
							
								
								
									
										13
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										13
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -2567,7 +2567,7 @@ dependencies = [ | ||||
|  | ||||
| [[package]] | ||||
| name = "kcl-lib" | ||||
| version = "0.1.56" | ||||
| version = "0.1.57" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "approx", | ||||
| @ -6059,9 +6059,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" | ||||
|  | ||||
| [[package]] | ||||
| name = "ts-rs" | ||||
| version = "7.1.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "fc2cae1fc5d05d47aa24b64f9a4f7cba24cdc9187a2084dd97ac57bef5eccae6" | ||||
| version = "8.1.0" | ||||
| source = "git+https://github.com/Aleph-Alpha/ts-rs#badbac08e61e65b312880aa64e9ece2976f1bbef" | ||||
| dependencies = [ | ||||
|  "chrono", | ||||
|  "thiserror", | ||||
| @ -6072,11 +6071,9 @@ dependencies = [ | ||||
|  | ||||
| [[package]] | ||||
| name = "ts-rs-macros" | ||||
| version = "7.1.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "73f7f9b821696963053a89a7bd8b292dc34420aea8294d7b225274d488f3ec92" | ||||
| version = "8.1.0" | ||||
| source = "git+https://github.com/Aleph-Alpha/ts-rs#badbac08e61e65b312880aa64e9ece2976f1bbef" | ||||
| dependencies = [ | ||||
|  "Inflector", | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn 2.0.65", | ||||
|  | ||||
| @ -55,6 +55,10 @@ impl CoreDump for CoreDumper { | ||||
|         Ok(crate::coredump::WebrtcStats::default()) | ||||
|     } | ||||
|  | ||||
|     async fn get_client_state(&self) -> Result<crate::coredump::ClientState> { | ||||
|         Ok(crate::coredump::ClientState::default()) | ||||
|     } | ||||
|  | ||||
|     async fn screenshot(&self) -> Result<String> { | ||||
|         // Take a screenshot of the engine. | ||||
|         todo!() | ||||
|  | ||||
| @ -27,6 +27,8 @@ pub trait CoreDump: Clone { | ||||
|  | ||||
|     async fn get_webrtc_stats(&self) -> Result<WebrtcStats>; | ||||
|  | ||||
|     async fn get_client_state(&self) -> Result<ClientState>; | ||||
|  | ||||
|     /// Return a screenshot of the app. | ||||
|     async fn screenshot(&self) -> Result<String>; | ||||
|  | ||||
| @ -64,6 +66,7 @@ pub trait CoreDump: Clone { | ||||
|         let webrtc_stats = self.get_webrtc_stats().await?; | ||||
|         let os = self.os().await?; | ||||
|         let screenshot_url = self.upload_screenshot().await?; | ||||
|         let client_state = self.get_client_state().await?; | ||||
|  | ||||
|         let mut app_info = AppInfo { | ||||
|             version: self.version()?, | ||||
| @ -74,6 +77,7 @@ pub trait CoreDump: Clone { | ||||
|             webrtc_stats, | ||||
|             github_issue_url: None, | ||||
|             pool: self.pool()?, | ||||
|             client_state, | ||||
|         }; | ||||
|         app_info.set_github_issue_url(&screenshot_url)?; | ||||
|  | ||||
| @ -109,6 +113,9 @@ pub struct AppInfo { | ||||
|  | ||||
|     /// Engine pool the client is connected to. | ||||
|     pub pool: String, | ||||
|  | ||||
|     /// The client state (singletons and xstate) | ||||
|     pub client_state: ClientState, | ||||
| } | ||||
|  | ||||
| impl AppInfo { | ||||
| @ -197,3 +204,23 @@ pub struct WebrtcStats { | ||||
|     /// Packet jitter for this synchronizing source, measured in seconds. | ||||
|     pub jitter: f32, | ||||
| } | ||||
|  | ||||
| /// Client State Structure | ||||
| #[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] | ||||
| #[ts(export)] | ||||
| #[serde(rename_all = "snake_case")] | ||||
| pub struct ClientState { | ||||
|     pub engine_command_manager: EngineCommandManager, | ||||
| } | ||||
|  | ||||
| #[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] | ||||
| #[ts(export)] | ||||
| #[serde(rename_all = "snake_case")] | ||||
| pub struct EngineCommandManager { | ||||
|     pub engine_connection: EngineConnection, | ||||
| } | ||||
|  | ||||
| #[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] | ||||
| #[ts(export)] | ||||
| pub struct EngineConnection { | ||||
| } | ||||
| @ -33,6 +33,9 @@ extern "C" { | ||||
|  | ||||
|     #[wasm_bindgen(method, js_name = screenshot, catch)] | ||||
|     fn screenshot(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>; | ||||
|  | ||||
|     #[wasm_bindgen(method, js_name = getWebrtcStats, catch)] | ||||
|     fn get_client_state(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>; | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone)] | ||||
| @ -140,4 +143,25 @@ impl CoreDump for CoreDumper { | ||||
|  | ||||
|         Ok(s) | ||||
|     } | ||||
|  | ||||
|     async fn get_client_state(&self) -> Result<crate::coredump::ClientState> { | ||||
|         let promise = self | ||||
|             .manager | ||||
|             .get_client_state() | ||||
|             .map_err(|e| anyhow::anyhow!("Failed to get promise from get client state: {:?}", e))?; | ||||
|  | ||||
|         let value = JsFuture::from(promise) | ||||
|             .await | ||||
|             .map_err(|e| anyhow::anyhow!("Failed to get response from client state: {:?}", e))?; | ||||
|  | ||||
|         // Parse the value as a string. | ||||
|         let s = value | ||||
|             .as_string() | ||||
|             .ok_or_else(|| anyhow::anyhow!("Failed to get string from response from client stat: `{:?}`", value))?; | ||||
|  | ||||
|         let client_state: crate::coredump::ClientState = | ||||
|             serde_json::from_str(&s).map_err(|e| anyhow::anyhow!("Failed to parse client state: {:?}", e))?; | ||||
|  | ||||
|         Ok(client_state) | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	