MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / discover_external_devtools_targets

Function discover_external_devtools_targets

packages/server/src/devtools.rs:221–308  ·  view source on GitHub ↗
(
    udid: &str,
    http_origin: Option<&str>,
    access_token: Option<&str>,
    simulator_name: Option<&str>,
    simulator_device_type_name: Option<&str>,
)

Source from the content-addressed store, hash-verified

219}
220
221pub async fn discover_external_devtools_targets(
222 udid: &str,
223 http_origin: Option<&str>,
224 access_token: Option<&str>,
225 simulator_name: Option<&str>,
226 simulator_device_type_name: Option<&str>,
227) -> (Vec<ChromeDevToolsTarget>, Vec<String>) {
228 let mut warnings = Vec::new();
229 let mut targets = Vec::new();
230 let mut seen_ids = BTreeSet::new();
231 let ports = candidate_devtools_ports().await;
232 let results = join_all(
233 ports
234 .into_iter()
235 .map(|port| async move { (port, fetch_devtools_target_list(port).await) }),
236 )
237 .await;
238 for (port, result) in results {
239 let list = match result {
240 Ok(value) => value,
241 Err(error) => {
242 debug!("DevTools discovery skipped {DEVTOOLS_HOST}:{port}: {error}");
243 continue;
244 }
245 };
246
247 let Some(entries) = list.as_array() else {
248 warnings.push(format!(
249 "DevTools endpoint on {DEVTOOLS_HOST}:{port} did not return a target list."
250 ));
251 continue;
252 };
253
254 let all_metro_entries = entries
255 .iter()
256 .filter(|entry| is_react_native_metro_target(entry))
257 .collect::<Vec<_>>();
258 let preferred_metro_entries = all_metro_entries
259 .iter()
260 .copied()
261 .filter(|entry| is_preferred_react_native_metro_target(entry))
262 .collect::<Vec<_>>();
263 let metro_entries = if preferred_metro_entries.is_empty() {
264 all_metro_entries
265 } else {
266 preferred_metro_entries
267 };
268 let mut matched_metro_count = 0;
269 for entry in &metro_entries {
270 if !metro_target_matches_simulator(entry, simulator_name, simulator_device_type_name) {
271 continue;
272 }
273 let target = build_metro_target(udid, http_origin, access_token, port, entry);
274 if seen_ids.insert(target.id.clone()) {
275 targets.push(target);
276 }
277 matched_metro_count += 1;
278 }

Callers 1

chrome_devtools_targetsFunction · 0.85

Calls 11

candidate_devtools_portsFunction · 0.85
build_metro_targetFunction · 0.85
is_emptyMethod · 0.80
insertMethod · 0.80
string_valueFunction · 0.70
cloneMethod · 0.65

Tested by

no test coverage detected