Skip to main content

ashlar_app/
lib.rs

1//! ashlar runtime: the [`App`] builder, the frame scheduler, crash guard, logging, telemetry and
2//! agent control.
3//!
4//! An app declares its document type and [`Format`](ashlar_store::Format), its commands
5//! (`fn(&mut Session<D>, &Value)`) and a view; [`App::run`] opens the window and gives it undo and
6//! redo (one step per top-level command), save / open / autosave and crash recovery, menus, a
7//! keymap editor and command palette, a crash guard and log files, the agent control port, and
8//! telemetry when enabled. [`App::cli`] / [`cli_main`] serve the same commands as a CLI and MCP
9//! server; [`App::headless`] and [`Driver`] run them in tests.
10//!
11//! | Module | |
12//! |---|---|
13//! | [`session`] | `Session<D>`: the state commands run on; the host glue (one undo step per command, failed commands change nothing) |
14//! | [`runtime`] | `Runtime<D>`: one frame (control, jobs, keys, menus, view, dialogs, autosave), repaint policy, `Cx` for views |
15//! | [`driver`] | `Driver`: a headless, virtual-clock event loop for tests and benches |
16//! | [`crash`] | panic hook, crash logs, last panic, launch guard (from `ashlar-log`) |
17//! | [`logging`] | stderr + rotating file + in-memory ring (`app.logs`), directive filters (from `ashlar-log`) |
18//! | [`stats`] | frame-time p50/p95/max (`app.stats`) |
19//! | [`frame_log`] | `ASHLAR_FRAME_LOG=FILE`: one JSON line per frame, size-bounded |
20//! | [`perf_warn`] | debug-build stall and same-frame warnings, `ASHLAR_FRAME_BUDGET_MS` |
21//! | [`caret`] | the text caret's blink, run on the wake scheduler; solid after a while without input |
22//! | [`wake`] | frame requests with a reason, frames and requests per reason (`app.stats` → `wakes`; from `ashlar-ui`) |
23//! | [`telemetry`] | ashlar-telemetry hook points (feature `telemetry`) |
24#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
25
26mod app;
27mod builtins;
28pub mod caret;
29mod clock;
30mod control;
31pub mod driver;
32pub mod frame_log;
33#[cfg(all(feature = "headless", not(target_arch = "wasm32")))]
34mod headless_run;
35#[cfg(all(feature = "native-menu", any(target_os = "macos", target_os = "windows")))]
36mod native_menu;
37#[cfg(not(target_arch = "wasm32"))]
38mod offscreen;
39mod open;
40pub mod perf_warn;
41pub mod record;
42mod renderer;
43pub mod runtime;
44pub mod session;
45pub mod stats;
46pub mod telemetry;
47pub mod window_state;
48
49/// Logging and crash safety live in the headless `ashlar-log` crate (a CLI can use them without
50/// the window); re-exported here unchanged.
51pub use ashlar_log::{crash, logging};
52/// The frame scheduler lives in `ashlar-ui` (it needs only egui, so hosts without the runtime use
53/// it too); re-exported here unchanged.
54pub use ashlar_ui::wake;
55
56pub use app::{App, Error, Headless, SetupFn, ViewFn, ViewportFn, cli_main};
57pub use ashlar_native::single_instance::Forwarded;
58pub use driver::Driver;
59pub use renderer::Renderer;
60pub use runtime::{Cx, FilePicker, Pick, Runtime};
61pub use session::{Document, Effect, Origin, Session};
62pub use stats::{FrameStats, LaunchTimes, StatsSummary};
63
64/// Methods the windowed runtime answers on the control port besides the standard ones.
65pub fn control_methods() -> Vec<String> {
66    use ashlar_control::UiHandler;
67    control::UiQueue::default().methods()
68}