#![warn(missing_docs)]
mod internal_runtime;
mod server;
mod session;
mod ui;
use std::path::{Path, PathBuf};
pub use session::{
Edge, EdgeKind, Event, EventKind, FunctionMeta, Node, NodeKind, Session, TypeMeta, ValueSlot,
};
pub use internal_runtime::{UiDebugValue, current_session, reset_session, runtime, type_preview};
pub use server::{serve_session, serve_session_with_rerun};
pub fn write_session_json(path: impl AsRef<Path>) -> std::io::Result<()> {
let sess = current_session();
session::write_session_json(&sess, path)
}
pub fn read_session_json(path: impl AsRef<Path>) -> std::io::Result<Session> {
session::read_session_json(path)
}
pub fn write_session_snapshot_in_dir(
dir: impl AsRef<Path>,
label: impl AsRef<str>,
) -> std::io::Result<PathBuf> {
let sess = current_session();
session::write_session_snapshot_in_dir(&sess, dir, label)
}
pub fn write_session_snapshot_from_env(label: impl AsRef<str>) -> std::io::Result<Option<PathBuf>> {
let sess = current_session();
session::write_session_snapshot_from_env(&sess, label)
}
pub fn capture_session<T>(title: impl Into<String>, run: impl FnOnce() -> T) -> T {
reset_session(title);
run()
}
pub fn capture_session_to_path<T>(
title: impl Into<String>,
path: impl AsRef<Path>,
run: impl FnOnce() -> T,
) -> std::io::Result<T> {
reset_session(title);
let result = run();
write_session_json(path)?;
Ok(result)
}
pub fn capture_session_and_serve<T>(
title: impl Into<String>,
host: &str,
port: u16,
run: impl FnOnce() -> T,
) -> std::io::Result<T> {
reset_session(title);
let result = run();
serve_session(current_session(), host, port)?;
Ok(result)
}