euv-example 0.49.4

Cross-platform native showcase application demonstrating euv fine-grained reactivity, multi-mode rendering, window controls, and euv-ui components.
Documentation
use super::*;

/// Independent stacked HTML `<canvas>` presentation target locked to a single browser context family.
#[derive(Clone, Copy, Data, Debug, Eq, PartialEq)]
pub struct ShowcaseWebCanvasSlot {
    /// Unique monotonic identifier for this `<canvas>` DOM element.
    #[get(type(copy))]
    pub(crate) canvas_id: u64,
    /// Permanently locked context family (`WebGl2` or `Canvas2d`) for this `<canvas>`.
    #[get(type(copy))]
    pub(crate) context_family: ShowcaseWebCanvasContextFamily,
    /// Target presentation path served by this slot.
    #[get(type(copy))]
    pub(crate) path: ShowcaseWebPresentationPath,
    /// Whether this `<canvas>` is currently visible in the foreground stack.
    #[get(type(copy))]
    pub(crate) visible: bool,
    /// CSS stacking `z-index` (`1` active foreground, `0` hidden standby).
    #[get(type(copy))]
    pub(crate) z_index: i32,
    /// Physical canvas width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Physical canvas height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Scene revision rendered into this slot (`0` before first frame).
    #[get(type(copy))]
    pub(crate) scene_version: u64,
    /// Whether the candidate's first frame has completed and is ready for atomic handoff.
    #[get(type(copy))]
    pub(crate) ready: bool,
}

/// Stacked dual-canvas handoff controller guaranteeing independent `<canvas>` targets and honest `SubmissionProxy` telemetry.
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct ShowcaseWebDualCanvasCoordinator {
    /// Foreground visible `<canvas>` currently presenting frames.
    #[get(type(copy))]
    pub(crate) active: ShowcaseWebCanvasSlot,
    /// Optional hidden sibling `<canvas>` pre-warming a candidate backend before atomic frame-boundary swap.
    #[get(skip)]
    pub(crate) standby: Option<ShowcaseWebCanvasSlot>,
    /// Explicit CPU-mirror flag (`false` for `GpuDirect`; `true` for `GpuUpload` and `Canvas2d`).
    #[get(type(copy))]
    pub(crate) cpu_mirror_active: bool,
    /// Truthful timing source (browser rAF always reports `SubmissionProxy`).
    #[get(type(copy))]
    pub(crate) timing_source: ShowcaseWebTimingSource,
    /// Next unique `<canvas>` ID allocator.
    #[get(type(copy))]
    pub(crate) next_canvas_id: u64,
    /// Total atomic frame-boundary handoff swaps committed.
    #[get(type(copy))]
    pub(crate) completed_swaps: u64,
    /// Total aborted candidate handoffs leaving the previous canvas active.
    #[get(type(copy))]
    pub(crate) aborted_swaps: u64,
    /// Total browser rAF ticks recorded strictly as `SubmissionProxy`.
    #[get(type(copy))]
    pub(crate) raf_proxy_ticks: u64,
    /// Exact framebuffer upload bytes reported on the latest frame (`0` on `GpuDirect`).
    #[get(type(copy))]
    pub(crate) last_upload_bytes: u64,
    /// Ordered history of retired `<canvas>` IDs removed only after atomic commit.
    pub(crate) retired_canvas_ids: Vec<u64>,
}

/// Persistent zero-DOM WebAssembly canvas host runtime backing Mini-Programs, QuickApps, and WASM Wearables.
#[cfg(target_arch = "wasm32")]
#[derive(Data)]
pub struct HostCanvasRuntime {
    /// Active EUV application instance rendering into the software RGBA8 framebuffer.
    pub(crate) app: App,
    /// Shared reactive showcase state.
    pub(crate) state: ShowcaseState,
    /// Multi-touch contact tracker translating touch phases into pointer events and drag gestures.
    pub(crate) touch_tracker: TouchPointerTracker,
    /// Canonical host vendor identifier (e.g. `"wechat"`, `"alliance"`, `"vivo-watch"`).
    pub(crate) vendor: String,
    /// Active platform kind (`MiniApp`, `QuickApp`, or `Wearable`).
    #[get(type(copy))]
    pub(crate) platform_kind: PlatformKind,
    /// Current logical viewport width in dp.
    #[get(type(copy))]
    pub(crate) logical_width: u32,
    /// Current logical viewport height in dp.
    #[get(type(copy))]
    pub(crate) logical_height: u32,
    /// Active display pixel ratio.
    #[get(type(copy))]
    pub(crate) dpr: f32,
    /// Whether host lifecycle froze the frame pump (`onHide`/`onUnload`/screen-off).
    #[get(type(copy))]
    pub(crate) paused: bool,
    /// Whether wearable Always-On Display (1Hz ambient) mode is active.
    #[get(type(copy))]
    pub(crate) ambient: bool,
    /// Pending dirty flag requiring a software rasterization pass on the next host step.
    #[get(type(copy))]
    pub(crate) dirty: bool,
    /// Whether the next rendered frame must report full-viewport damage (`[0, 0, phys_w, phys_h]`).
    #[get(type(copy))]
    pub(crate) force_full_dirty: bool,
    /// Last rendered physical dirty rectangle X origin in pixels.
    #[get(type(copy))]
    pub(crate) dirty_x: u32,
    /// Last rendered physical dirty rectangle Y origin in pixels.
    #[get(type(copy))]
    pub(crate) dirty_y: u32,
    /// Last rendered physical dirty rectangle width in pixels.
    #[get(type(copy))]
    pub(crate) dirty_w: u32,
    /// Last rendered physical dirty rectangle height in pixels.
    #[get(type(copy))]
    pub(crate) dirty_h: u32,
    /// Total frames rasterized during this host session.
    #[get(type(copy))]
    pub(crate) frame_count: u64,
    /// Deterministic pixel hash of the latest rasterized frame.
    #[get(type(copy))]
    pub(crate) last_frame_hash: u64,
    /// Accumulated fractional crown detents for discrete wearable focus/directional stepping.
    #[get(type(copy))]
    pub(crate) crown_remainder: f32,
}