use super::*;
#[derive(Clone, Copy, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct FileStamp {
#[get(type(copy))]
pub(crate) modified_nanos: u128,
#[get(type(copy))]
pub(crate) size_bytes: u64,
}
#[derive(Clone, Debug, Default, Eq, Getter, PartialEq)]
pub struct WatchSnapshot {
pub(crate) entries: BTreeMap<PathBuf, FileStamp>,
}
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct FileChangeSet {
pub(crate) added: Vec<String>,
pub(crate) modified: Vec<String>,
pub(crate) removed: Vec<String>,
}
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct OtaManifest {
#[get(type(copy))]
pub(crate) version: u64,
pub(crate) slot_id: String,
pub(crate) module_url: String,
#[get(type(copy))]
pub(crate) checksum: u64,
pub(crate) signature: String,
#[get(type(copy))]
pub(crate) size_bytes: usize,
pub(crate) changed_files: Vec<String>,
}
#[derive(Clone, Debug, Eq, Getter, New, PartialEq)]
pub struct OtaBundleState {
pub(crate) manifest: OtaManifest,
pub(crate) wasm_bytes: Vec<u8>,
}
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct HmrEvent {
#[get(type(copy))]
pub(crate) revision: u64,
#[get(type(copy))]
pub(crate) kind: HmrEventKind,
pub(crate) message: String,
pub(crate) changed_files: Vec<String>,
}
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct DevServerConfig {
#[get(type(copy))]
pub(crate) target: DevTargetArg,
#[get(type(copy))]
pub(crate) render: RenderArg,
#[get(type(copy))]
pub(crate) release: bool,
pub(crate) src_dir: PathBuf,
pub(crate) out_dir: PathBuf,
pub(crate) title: Option<String>,
pub(crate) base_url: String,
pub(crate) package: Option<String>,
pub(crate) host: String,
#[get(type(copy))]
pub(crate) port: u16,
#[get(type(copy))]
pub(crate) poll_ms: u64,
#[get(type(copy))]
pub(crate) enable_ota: bool,
#[get(type(copy))]
pub(crate) once: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DevServerReport {
pub(crate) mode: String,
pub(crate) url: String,
pub(crate) hmr_url: String,
pub(crate) ota_manifest_url: String,
pub(crate) out_dir: String,
#[get(type(copy))]
pub(crate) revision: u64,
#[get(type(copy))]
pub(crate) page_count: usize,
}
#[derive(Debug)]
pub struct HmrHub {
pub(crate) revision: AtomicU64,
pub(crate) last_event: Mutex<Option<HmrEvent>>,
pub(crate) ota_state: Mutex<OtaBundleState>,
pub(crate) running: AtomicBool,
}
#[derive(Debug)]
pub struct DevServerHandle {
pub(crate) address: SocketAddr,
pub(crate) out_dir: PathBuf,
pub(crate) mode: String,
pub(crate) page_count: usize,
pub(crate) hub: Arc<HmrHub>,
pub(crate) http_thread: Option<JoinHandle<()>>,
pub(crate) watch_thread: Option<JoinHandle<()>>,
}
#[derive(Clone, Debug, Getter)]
pub(crate) struct HttpServeContext {
#[get(pub(crate))]
pub(crate) out_dir: PathBuf,
#[get(pub(crate))]
pub(crate) base_url: String,
#[get(pub(crate), type(copy))]
pub(crate) enable_ota: bool,
#[get(pub(crate))]
pub(crate) hub: Arc<HmrHub>,
}