Expand description
crepuscularity-lite — embed a V8 guest + Capacitor-shaped Rust bridge inside a GPUI (or other) host.
Development can run TypeScript / TSX guest entries through the built-in Oxc transpiler. Production
bundling, chunking, and code splitting are still the embedder’s or CLI toolchain’s job; use the
cl build esbuild path for bundled output, or multiple sources with
config::CrepusLiteConfig::guest_prelude / separate worker scripts (see docs/THREADING.md).
§How this relates to GPUI and Rust
- Rust plugins are normal Rust: types implementing
NativePlugin. They are registered on aBridgeand reached from JS viaCrepus.invoke(...). - GPUI is not “hooked” automatically. V8 does not register GPUI
actions!, keymaps, or subscriptions for you. You callV8Host::eval(or run scripts) from your GPUI event closures—the same places you would call any other Rust code. - Window / UI-thread work from plugins is deferred (e.g.
HostDeferred::SetWindowTitle). After guest code runs, callintegration::apply_window_deferredwith a live GPUIWindowso those operations hit the real window. - Hot reload:
guest_watch::spawn_guest_file_watcherwatches guest file paths; the callback must beSendand should only signal the UI thread (seedocs/THREADING.mdand the package binary). - Bridge in V8: each
V8Hostinstalls an embedder slot on the isolate’s context (CrepusBridgeSlotinv8_host.rs);Crepus.invokereads the bridge from the current context (no process-globalACTIVE_BRIDGE). - Optional TOML caps:
config::CrepusLiteConfig::build_bridgerespects[capabilities](seeexamples/*/crepus-lite.example.toml).
For a full demo, run the package binary (see src/main.rs).
Re-exports§
pub use bench_eval::eval_guest_from_config_file;pub use bench_plugin::BenchPlugin;pub use bridge::Bridge;pub use bridge::BridgeError;pub use bridge::Capability;pub use bridge::NativePlugin;pub use download_plugin::DownloadPlugin;pub use guest_compiler::prepare_guest_source;pub use host::HostEventRecord;pub use host::HostNode;pub use host::HostRoute;pub use host::HostSnapshot;pub use host::HostState;pub use host::HostStyle;pub use host_queue::DeferredWindowDecorations;pub use host_queue::HostCommandQueue;pub use host_queue::HostDeferred;pub use plugins::AppPlugin;pub use plugins::ClipboardPlugin;pub use plugins::CorePlugin;pub use plugins::FsPlugin;pub use plugins::HostPlugin;pub use plugins::WindowPlugin;pub use v8_host::V8Host;pub use v8_thread::V8ThreadHandle;pub use v8_thread::V8ThreadRequest;pub use v8_thread::V8ThreadRuntime;pub use worker::WorkerHandle;pub use worker::WorkerRuntime;
Modules§
- bench_
eval - Headless guest evaluation for benchmark tooling (no GPUI).
- bench_
plugin - Native benchmark plugin — Rust and GPUI-simulated suites.
- bridge
- Capacitor-shaped native bridge: plugins live in Rust; JS calls
Crepus.invoke(plugin, method, payloadJson). - clipboard
- Shared clipboard backend used by the Rust plugin and the host UI.
- config
- Optional
crepus-lite.tomlproject file (guest entry path, flags, capabilities). - download_
plugin - Native download manager used by the Motrix example.
- guest_
compiler - Guest-source preparation before V8 evaluation.
- guest_
watch - Debounced filesystem watch for a guest script path. The callback runs on the debouncer thread
(see
notify-debouncer-mini); schedule GPUI / UI-thread work yourself (for example viagpui::AsyncApp::foreground_executor). - host
- Host-side state for the GPUI-backed guest runtime.
- host_
queue - Deferred work that must run on the GPUI thread with a live window (e.g. native title APIs).
- integration
- Glue between the bridge / V8 host and GPUI on the UI thread.
- plugins
- Built-in plugins registered on
Bridge. - v8_host
- Embedded JavaScript via the official
v8crate (the Rust bindings project is often called rusty_v8). Seedocs/THREADING.mdfor thread constraints. - v8_
thread - Dedicated OS thread that owns a
V8Hostso GPUI never blocks oneval. - worker
- Optional compute worker: a second V8 isolate on a dedicated thread with a restricted bridge
(
Bridge::compute_only_bridge) — core + app only, no FS/window until those plugins are audited for concurrentinvoke.