refactor(protocol): share client window wire projection

Command output and the BiDi adapter duplicate client-window JSON projection. Export the existing protocol projection for the adapter to reuse, keeping ownership, enum conversion and all wire keys and values without adding a dependency cycle.
This commit is contained in:
ldm0
2026-11-09 18:56:32 +08:00
committed by Donough Liu
parent ebd5dbd2f9
commit 1018d9ef45
3 changed files with 5 additions and 12 deletions
+1 -11
View File
@@ -370,17 +370,7 @@ fn bidi_realm_string_field<'a>(realm: &'a Value, field: &str) -> &'a str {
realm.get(field).and_then(Value::as_str).unwrap_or("")
}
fn bidi_client_window_info(window: moli_protocol::automation::DevToolsClientWindowInfo) -> Value {
json!({
"clientWindow": window.client_window.into_string(),
"active": window.active,
"state": window.state.as_bidi_value(),
"width": window.width,
"height": window.height,
"x": window.x,
"y": window.y,
})
}
use moli_protocol::client_window_info_json as bidi_client_window_info;
fn bidi_user_contexts_from_browser_contexts(
browser_context_ids: Vec<DevToolsBrowserContextId>,
+1 -1
View File
@@ -1968,7 +1968,7 @@ fn service_worker_log_entry_json(entry: RuntimeConsoleEvent) -> Value {
payload
}
fn client_window_info_json(window: crate::automation::DevToolsClientWindowInfo) -> Value {
pub fn client_window_info_json(window: crate::automation::DevToolsClientWindowInfo) -> Value {
json!({
"clientWindow": window.client_window.into_string(),
"active": window.active,
+3
View File
@@ -12,6 +12,9 @@ pub mod domains;
pub mod frame_index;
#[cfg(feature = "test-support")]
pub mod test_support;
pub use domains::command_output::client_window_info_json;
#[cfg(test)]
pub mod testing;
pub mod version;