Skip to main content

crepuscularity_lite/
lib.rs

1//! **crepuscularity-lite** — embed a V8 guest + Capacitor-shaped Rust bridge inside a GPUI (or other) host.
2//!
3//! Development can run TypeScript / TSX guest entries through the built-in Oxc transpiler. Production
4//! bundling, chunking, and code splitting are still the embedder’s or CLI toolchain’s job; use the
5//! `cl build` esbuild path for bundled output, or multiple sources with
6//! [`config::CrepusLiteConfig::guest_prelude`] / separate worker scripts (see `docs/THREADING.md`).
7//!
8//! ## How this relates to GPUI and Rust
9//!
10//! - **Rust plugins** are normal Rust: types implementing [`NativePlugin`]. They are registered on a [`Bridge`] and reached from JS via `Crepus.invoke(...)`.
11//! - **GPUI is not “hooked” automatically.** V8 does not register GPUI `actions!`, keymaps, or subscriptions for you. You call [`V8Host::eval`](v8_host::V8Host) (or run scripts) from *your* GPUI event closures—the same places you would call any other Rust code.
12//! - **Window / UI-thread work** from plugins is deferred (e.g. `HostDeferred::SetWindowTitle`). After guest code runs, call [`integration::apply_window_deferred`] with a live GPUI `Window` so those operations hit the real window.
13//! - **Hot reload:** [`guest_watch::spawn_guest_file_watcher`] watches guest file paths; the callback must be `Send` and should only signal the UI thread (see `docs/THREADING.md` and the package binary).
14//! - **Bridge in V8:** each [`V8Host`] installs an embedder slot on the isolate’s context (`CrepusBridgeSlot` in `v8_host.rs`); **`Crepus.invoke`** reads the bridge from the current context (no process-global `ACTIVE_BRIDGE`).
15//! - **Optional TOML caps:** [`config::CrepusLiteConfig::build_bridge`] respects `[capabilities]` (see `examples/*/crepus-lite.example.toml`).
16//!
17//! For a full demo, run the package binary (see `src/main.rs`).
18
19pub mod bench_eval;
20pub mod bench_plugin;
21pub mod bridge;
22pub mod clipboard;
23pub mod download_plugin;
24mod fs_paths;
25pub mod guest_compiler;
26pub mod host;
27pub mod host_queue;
28pub mod integration;
29pub mod plugins;
30pub mod v8_host;
31
32pub mod config;
33pub mod guest_watch;
34pub mod v8_thread;
35pub mod worker;
36
37pub use bench_eval::{
38    bench_matrix_shared_for_configs, eval_guest_from_config_file, BenchMatrixShared,
39};
40pub use bench_plugin::BenchPlugin;
41pub use bridge::{Bridge, BridgeError, Capability, NativePlugin};
42pub use download_plugin::DownloadPlugin;
43pub use guest_compiler::prepare_guest_source;
44pub use host::{HostEventRecord, HostNode, HostRoute, HostSnapshot, HostState, HostStyle};
45pub use host_queue::{DeferredWindowDecorations, HostCommandQueue, HostDeferred};
46pub use plugins::{AppPlugin, ClipboardPlugin, CorePlugin, FsPlugin, HostPlugin, WindowPlugin};
47pub use v8_host::V8Host;
48pub use v8_thread::{V8ThreadHandle, V8ThreadRequest, V8ThreadRuntime};
49pub use worker::{WorkerHandle, WorkerRuntime};