Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
refactor(cdp): share CSS inventory notification payloads
ldm0cb28d957e147
diff --git a/moli-protocol/src/domains/css/native.rs b/moli-protocol/src/domains/css/native.rsindex dd5c7a1bc..9825e24b0 100644--- a/moli-protocol/src/domains/css/native.rs+++ b/moli-protocol/src/domains/css/native.rs@@ -25,14 +25,12 @@ pub(crate) fn try_start(conn: &mut CdpConnection, cmd: &Cmd<'_>) -> Option<Nativmove |reply| match reply {Ok(Reply::StyleSheetInventory(update)) => {let mut response = Response::success(json!({}));- for id in update.removed {- response.notifications.push(json!({"method": "CSS.styleSheetRemoved", "params": {"styleSheetId": id}}).into());- }- for header in update.added {- response.notifications.push(json!({"method": "CSS.styleSheetAdded", "params": {- "header": style_sheets::style_sheet_header_value(&frame_id, &header),- }}).into());- }+ response.notifications.extend(+ style_sheets::style_sheet_inventory_notifications(&frame_id, update)+ .map(|(method, params)| {+ json!({ "method": method, "params": params }).into()+ }),+ );response}Err(error) => Response::error(-32000, error.to_string()),diff --git a/moli-protocol/src/domains/css/style_sheets.rs b/moli-protocol/src/domains/css/style_sheets.rsindex 67fd114fa..0dfc0d827 100644--- a/moli-protocol/src/domains/css/style_sheets.rs+++ b/moli-protocol/src/domains/css/style_sheets.rs@@ -67,27 +67,33 @@ pub(super) fn complete_enable_command_output_plan(update: RendererStyleSheetInventoryUpdate,) -> CommandOutputPlan {let mut plan = CommandOutputPlan::success();- for style_sheet_id in update.removed {+ for (method, params) in style_sheet_inventory_notifications(frame_id, update) {plan.push_background_event(BackgroundProtocolEvent::immediate(build_event(- "CSS.styleSheetRemoved",- json!({- "styleSheetId": style_sheet_id,- }),- session_id,- )));- }- for header in update.added {- plan.push_background_event(BackgroundProtocolEvent::immediate(build_event(- "CSS.styleSheetAdded",- json!({- "header": style_sheet_header_value(frame_id, &header),- }),- session_id,+ method, params, session_id,)));}plan}+pub(super) fn style_sheet_inventory_notifications(+ frame_id: &str,+ update: RendererStyleSheetInventoryUpdate,+) -> impl Iterator<Item = (&'static str, Value)> + '_ {+ let removed = update.removed.into_iter().map(|style_sheet_id| {+ (+ "CSS.styleSheetRemoved",+ json!({ "styleSheetId": style_sheet_id }),+ )+ });+ let added = update.added.into_iter().map(move |header| {+ (+ "CSS.styleSheetAdded",+ json!({ "header": style_sheet_header_value(frame_id, &header) }),+ )+ });+ removed.chain(added)+}+pub(super) fn get_style_sheet_result(style_sheet_id: &str,frame_id: &str,