(
udid: &str,
http_origin: Option<&str>,
info: &Value,
process_identifier: i64,
source: &str,
)
| 174 | } |
| 175 | |
| 176 | pub fn build_target( |
| 177 | udid: &str, |
| 178 | http_origin: Option<&str>, |
| 179 | info: &Value, |
| 180 | process_identifier: i64, |
| 181 | source: &str, |
| 182 | ) -> ChromeDevToolsTarget { |
| 183 | let id = target_id(process_identifier); |
| 184 | let bundle_identifier = string_value(info, "bundleIdentifier"); |
| 185 | let app_name = string_value(info, "bundleName") |
| 186 | .or_else(|| bundle_identifier.clone()) |
| 187 | .or_else(|| Some(format!("Process {process_identifier}"))); |
| 188 | let source_label = source_label(source); |
| 189 | let title = app_name |
| 190 | .as_deref() |
| 191 | .map(|name| format!("{source_label}: {name}")) |
| 192 | .unwrap_or_else(|| format!("{source_label}: Process {process_identifier}")); |
| 193 | let url = bundle_identifier |
| 194 | .as_deref() |
| 195 | .map(|bundle_id| format!("simdeck://{bundle_id}")) |
| 196 | .unwrap_or_else(|| format!("simdeck://process/{process_identifier}")); |
| 197 | let web_socket_path = format!("/api/simulators/{udid}/devtools/targets/{id}/socket"); |
| 198 | let web_socket_debugger_url = websocket_url(http_origin.unwrap_or(""), &web_socket_path); |
| 199 | let devtools_frontend_url = format!( |
| 200 | "/chrome-devtools-ui/inspector.html?ws={}", |
| 201 | web_socket_debugger_url |
| 202 | .trim_start_matches("ws://") |
| 203 | .trim_start_matches("wss://") |
| 204 | ); |
| 205 | |
| 206 | ChromeDevToolsTarget { |
| 207 | id, |
| 208 | title, |
| 209 | target_type: "page".to_owned(), |
| 210 | url, |
| 211 | description: format!("SimDeck {source_label} inspector target"), |
| 212 | devtools_frontend_url, |
| 213 | web_socket_debugger_url, |
| 214 | source: source.to_owned(), |
| 215 | process_identifier, |
| 216 | bundle_identifier, |
| 217 | app_name, |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | pub async fn discover_external_devtools_targets( |
| 222 | udid: &str, |
no test coverage detected