tauri-runtime-servocat 2.1.0

Servo-replacement runtime for Tauri: wires html-cat, css-cat, dom-cat, layout-cat, paint-cat, net-cat, boa-cat, ecma-runtime-cat, and web-api-cat into a single rendering + scripting pipeline. v2.1.0 applies the webview's tracked zoom factor visually: the softbuffer compositor samples the rasterized frame with `1/zoom` step so `set_zoom(1.5)` makes each source pixel cover a 1.5x1.5 destination block (zoom in, top-left anchored). Bitmap nearest-neighbour scaling -- crisp re-rasterized text waits on a pipeline-side layout-with-scale-factor pass. The Servo no-AI policy disqualifies upstream contribution; this is the AI-built parallel.
//! v2.1 demo: set the webview's `zoom` factor and see the softbuffer
//! compositor sample-scale the rasterized frame so the top-left
//! `1/zoom` of the source covers the whole window.
//!
//! Run with `cargo run --bin demo_tauri_zoom`.  Close the window to
//! exit.

#![allow(clippy::assigning_clones)]

use std::time::Duration;

use tauri_runtime::webview::{PendingWebview, WebviewAttributes};
use tauri_runtime::window::{PendingWindow, WindowBuilder};
use tauri_runtime::{Runtime, RuntimeInitArgs, WebviewDispatch};
use tauri_runtime_servocat::{ServocatRuntime, ServocatWindowBuilder};

const PAGE: &str = "data:text/html,<html><body><h1 style='background:red;color:white'>v2.1 zoom</h1><p>The red heading box should grow 2x after the worker thread fires set_zoom(2.0).</p></body></html>";

fn main() {
    let _ = ServocatRuntime::<()>::new(RuntimeInitArgs::default()).map(|runtime| {
        let window_attrs = ServocatWindowBuilder::new()
            .title("tauri-runtime-servocat v2.1 zoom demo")
            .inner_size(640.0, 360.0)
            .visible(true);
        let _ = PendingWindow::<(), ServocatRuntime<()>>::new(window_attrs, "main").map(
            |window_pending| {
                let _ = runtime
                    .create_window::<fn(tauri_runtime::window::RawWindow)>(window_pending, None)
                    .map(|detached_window| {
                        let _ = url::Url::parse(PAGE).ok().map(|page_url| {
                            let attrs = WebviewAttributes::new(
                                tauri_utils::config::WebviewUrl::External(page_url),
                            );
                            let _ = PendingWebview::<(), ServocatRuntime<()>>::new(attrs, "main")
                                .map(|mut pending| {
                                    pending.url = PAGE.to_owned();
                                    let _ = runtime
                                        .create_webview(detached_window.id, pending)
                                        .map(|detached_webview| {
                                            let dispatcher = detached_webview.dispatcher.clone();
                                            let _ = std::thread::spawn(move || {
                                                std::thread::sleep(Duration::from_millis(1500));
                                                println!(
                                                    "[v2.1 demo] set_zoom(2.0) -> {:?}",
                                                    dispatcher.set_zoom(2.0),
                                                );
                                            });
                                            runtime.run(|_event| {});
                                        });
                                });
                        });
                    });
            },
        );
    });
}