teksilo_inspector/lib.rs
1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! In-app debug inspector for Teksilo.
5//!
6//! See `docs/inspector.md` for a user-facing reference. This crate is
7//! gated by `cfg(debug_assertions)` — in release builds the
8//! [`TeksiloAppBuilderInspectorExt::install_inspector_in_debug`] entry
9//! point compiles to a no-op, so app code calling it stays ergonomic
10//! without `#[cfg]` lines.
11
12#[cfg(debug_assertions)]
13mod grip;
14#[cfg(debug_assertions)]
15mod highlight;
16#[cfg(all(debug_assertions, test))]
17mod integration_tests;
18#[cfg(debug_assertions)]
19mod keyboard;
20#[cfg(debug_assertions)]
21mod persistence;
22#[cfg(debug_assertions)]
23mod picker;
24#[cfg(debug_assertions)]
25mod resize_handle;
26#[cfg(debug_assertions)]
27mod shell;
28#[cfg(debug_assertions)]
29mod state;
30#[cfg(debug_assertions)]
31mod tabs;
32#[cfg(all(debug_assertions, test))]
33mod touch_tests;
34
35#[cfg(debug_assertions)]
36pub use state::InspectorState;
37
38use teksilo_app::TeksiloAppBuilder;
39
40/// Extension trait on [`TeksiloAppBuilder`] that wires in the debug
41/// inspector. The `install_inspector_in_debug` method is a no-op in
42/// release builds so apps can call it unconditionally.
43pub trait TeksiloAppBuilderInspectorExt {
44 /// Install the debug inspector. In debug builds, this:
45 /// - parses `--teksilo-inspector` from `std::env::args()` and
46 /// `TEKSILO_INSPECTOR=1` from the environment to seed the initial
47 /// visibility,
48 /// - registers an [`InspectorState`] in the app-state registry so
49 /// widgets can read the inspector's signals,
50 /// - registers a default `post_root` hook that wraps every
51 /// window's root with the inspector shell (currently a no-op
52 /// wrapper — slice 1).
53 ///
54 /// In release (`!cfg(debug_assertions)`), this is a no-op.
55 fn install_inspector_in_debug(self) -> Self;
56}
57
58impl TeksiloAppBuilderInspectorExt for TeksiloAppBuilder {
59 #[cfg(debug_assertions)]
60 fn install_inspector_in_debug(self) -> Self {
61 state::install(self)
62 }
63
64 #[cfg(not(debug_assertions))]
65 fn install_inspector_in_debug(self) -> Self {
66 self
67 }
68}