MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / inspector_available_sources

Function inspector_available_sources

packages/server/src/api/routes.rs:4693–4752  ·  view source on GitHub ↗
(info: &Value)

Source from the content-addressed store, hash-verified

4691}
4692
4693fn inspector_available_sources(info: &Value) -> Vec<String> {
4694 let mut sources = Vec::new();
4695 let snapshot_source = info.get("source").and_then(Value::as_str).unwrap_or("");
4696 let react_native_available = info
4697 .get("reactNative")
4698 .and_then(|value| value.get("available"))
4699 .and_then(Value::as_bool)
4700 .unwrap_or(snapshot_source == SOURCE_REACT_NATIVE);
4701 if react_native_available {
4702 sources.push(SOURCE_REACT_NATIVE.to_owned());
4703 }
4704 let flutter_available = info
4705 .get("flutter")
4706 .and_then(|value| value.get("available"))
4707 .and_then(Value::as_bool)
4708 .unwrap_or(false);
4709 if flutter_available {
4710 sources.push(SOURCE_FLUTTER.to_owned());
4711 }
4712 match snapshot_source {
4713 SOURCE_NATIVE_SCRIPT => push_unique_source(&mut sources, SOURCE_NATIVE_SCRIPT),
4714 SOURCE_SWIFTUI => push_unique_source(&mut sources, SOURCE_SWIFTUI),
4715 _ => {}
4716 }
4717 let app_hierarchy = info.get("appHierarchy");
4718 let app_hierarchy_available = app_hierarchy
4719 .and_then(|value| value.get("available"))
4720 .and_then(Value::as_bool)
4721 .unwrap_or(false);
4722 let app_hierarchy_source = app_hierarchy
4723 .and_then(|value| value.get("source"))
4724 .and_then(Value::as_str)
4725 .unwrap_or("");
4726 if app_hierarchy_available {
4727 match app_hierarchy_source {
4728 SOURCE_NATIVE_SCRIPT => push_unique_source(&mut sources, SOURCE_NATIVE_SCRIPT),
4729 SOURCE_REACT_NATIVE => push_unique_source(&mut sources, SOURCE_REACT_NATIVE),
4730 SOURCE_FLUTTER => push_unique_source(&mut sources, SOURCE_FLUTTER),
4731 SOURCE_SWIFTUI => push_unique_source(&mut sources, SOURCE_SWIFTUI),
4732 _ => {}
4733 }
4734 }
4735 let uikit_available = info
4736 .get("uikit")
4737 .and_then(|value| value.get("available"))
4738 .and_then(Value::as_bool)
4739 .unwrap_or_else(|| {
4740 !(react_native_available
4741 || flutter_available
4742 || snapshot_source == SOURCE_NATIVE_SCRIPT
4743 || app_hierarchy_source == SOURCE_REACT_NATIVE
4744 || app_hierarchy_source == SOURCE_FLUTTER
4745 || snapshot_source == SOURCE_REACT_NATIVE
4746 || snapshot_source == SOURCE_FLUTTER)
4747 });
4748 if uikit_available {
4749 sources.push(SOURCE_UIKIT.to_owned());
4750 }

Calls 2

push_unique_sourceFunction · 0.70
getMethod · 0.65