//! The compiled presentation, in the shape the web UI consumes. //! //! One [`Slide`] corresponds to one *page* of the compiled Typst document, which //! is also one navigation step: touying expands a slide containing `#pause` into //! several pages, and the UI walks pages, not logical slides. The `logical` and //! `subslide` fields are what let the presenter console group them back together. use serde::{Deserialize, Serialize}; /// A whole compiled deck. #[derive(Debug, Clone, Serialize)] pub struct Deck { /// Monotonic counter, bumped on every successful recompile. Clients use it to /// tell a genuine change from a reconnect. pub revision: u64, /// Page width in Typst points, for the overlay coordinate system. pub page_width: f64, /// Page height in Typst points. pub page_height: f64, pub slides: Vec, /// Diagnostics from the last compile. Warnings can accompany a good deck; a /// failed compile is reported separately as [`crate::compile::CompileError`]. pub warnings: Vec, } impl Deck { pub fn len(&self) -> usize { self.slides.len() } pub fn slide(&self, index: usize) -> Option<&Slide> { self.slides.get(index) } /// Every video on a page, in document order. pub fn videos_on(&self, index: usize) -> &[Video] { self.slides.get(index).map_or(&[], |s| &s.videos) } } /// One page of the compiled document. #[derive(Debug, Clone, Serialize)] pub struct Slide { /// Zero-based page index; also this slide's position in `Deck::slides`. pub index: usize, /// Rendered page. Skipped in the JSON deck sent over the websocket -- clients /// fetch it from `/slide/{index}` instead, keeping page markup out of the /// message stream. #[serde(skip)] pub svg: String, /// The enclosing level-1 heading, if any. pub section: Option, /// The slide title: this page's level-2 heading, or the one belonging to the /// logical slide this page is a subslide of. pub title: Option, /// Logical slide number, shared by every subslide of one `#slide`. pub logical: u32, /// Zero-based index of this page within its logical slide. pub subslide: u32, /// Speaker notes, already flattened to text by touying. pub notes: Option, pub videos: Vec