euv-core 0.46.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Bounding geometry of the floating Mini-Program menu capsule button (`getMenuButtonBoundingClientRect`).
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct MiniAppCapsuleRect {
    /// Top offset from screen top in logical dp.
    #[get(type(copy))]
    pub(crate) top: f32,
    /// Right edge offset from screen left in logical dp.
    #[get(type(copy))]
    pub(crate) right: f32,
    /// Bottom edge offset from screen top in logical dp.
    #[get(type(copy))]
    pub(crate) bottom: f32,
    /// Left edge offset from screen left in logical dp.
    #[get(type(copy))]
    pub(crate) left: f32,
    /// Capsule width in logical dp.
    #[get(type(copy))]
    pub(crate) width: f32,
    /// Capsule height in logical dp.
    #[get(type(copy))]
    pub(crate) height: f32,
}

/// Normalized host device, window, status bar, safe-area, and capsule metrics across all Mini-Program vendors.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct MiniAppSystemInfo {
    /// Active super-app vendor runtime.
    #[get(type(copy))]
    pub(crate) vendor: MiniAppVendor,
    /// Logical viewport width in dp.
    #[get(type(copy))]
    pub(crate) window_width: u32,
    /// Logical viewport height in dp.
    #[get(type(copy))]
    pub(crate) window_height: u32,
    /// Display pixel ratio (`devicePixelRatio`).
    #[get(type(copy))]
    pub(crate) pixel_ratio: f32,
    /// OS status bar height in logical dp.
    #[get(type(copy))]
    pub(crate) status_bar_height: f32,
    /// Raw safe-area insets reported by the host super-app.
    #[get(type(copy))]
    pub(crate) safe_area: SafeAreaInsets,
    /// Floating capsule button bounding rect (`getMenuButtonBoundingClientRect`).
    #[get(type(copy))]
    pub(crate) capsule: MiniAppCapsuleRect,
    /// Active super-app light/dark theme mode.
    #[get(type(copy))]
    pub(crate) theme: ThemeMode,
    /// Active host BCP-47 language tag.
    pub(crate) language: String,
    /// Active `<canvas>` rendering mode (`Canvas2d`, `WebGl`, or `WebGl2`).
    #[get(type(copy))]
    pub(crate) canvas_mode: MiniAppCanvasMode,
}

/// Active Mini-Program canvas window record held by `MiniAppPlatform`.
#[derive(Clone, Data, Debug)]
pub struct MiniAppWindowRecord {
    /// Window configuration snapshot.
    pub(crate) config: WindowConfig,
    /// Live window metrics including capsule-cleared safe-area insets.
    #[get(type(copy))]
    pub(crate) state: WindowState,
    /// Registered host canvas identifier.
    #[get(type(copy))]
    pub(crate) canvas_id: u32,
    /// Active rendering context mode.
    #[get(type(copy))]
    pub(crate) canvas_mode: MiniAppCanvasMode,
    /// Last presented RGBA8 framebuffer snapshot.
    pub(crate) last_frame: Framebuffer,
    /// Total presented frames.
    #[get(type(copy))]
    pub(crate) present_count: u64,
}

/// Unified Rust/WASM Mini-Program host adapter abstracting WeChat, Alipay, Douyin, Baidu, QQ, Kuaishou, and HarmonyOS Atomic Service.
#[derive(Clone, Data, Debug)]
pub struct MiniAppPlatform {
    /// Normalized host system info, viewport, status bar, and capsule geometry.
    pub(crate) system_info: MiniAppSystemInfo,
    /// Resolved safe-area insets accounting for both OS notches and the floating capsule pill.
    #[get(type(copy))]
    pub(crate) resolved_safe_area: SafeAreaInsets,
    /// Monotonic window identifier allocator.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) next_id: u64,
    /// Primary Mini-Program canvas window handle, if created.
    #[get(skip)]
    pub(crate) primary_window: Option<WindowId>,
    /// Active Mini-Program canvas windows indexed by `WindowId`.
    pub(crate) windows: HashMap<WindowId, MiniAppWindowRecord>,
    /// Multi-touch contact lifecycle tracker handling `touchstart`/`touchmove`/`touchend`/`touchcancel`.
    pub(crate) touch_tracker: TouchPointerTracker,
    /// Queued normalized `WindowEvent` and `SystemEvent`s awaiting `poll_events()`.
    pub(crate) pending_events: Vec<WindowEvent>,
    /// Outbound host bridge commands drained by the thin JS/ArkTS vendor shell.
    pub(crate) outbound_commands: Vec<MiniAppHostCommand>,
    /// In-memory mirrored sandbox storage backing `PlatformStorage`.
    pub(crate) storage: HashMap<String, String>,
    /// Active page navigation stack backing `PlatformNavigation`.
    pub(crate) route_stack: Vec<String>,
    /// Cached clipboard text synchronized with host clipboard API.
    #[get(skip)]
    pub(crate) clipboard: Option<String>,
    /// Whether the host `requestAnimationFrame` pump is paused (`onHide`/`onUnload`).
    #[get(type(copy))]
    pub(crate) pump_paused: bool,
}