Expand description
The JS host seam of Skathi: one JSC context (via redjs) on gpui’s main thread, pumped once per
frame, with a phase-gated bridge as the only way a JS host function may reach &mut Window / &mut App.
Invariants:
- One VM, one thread: VM thread == gpui main thread == Win32 UI thread.
- The context is created once and never released (teardown fastfails in this JSC prebuilt).
- Every
extern "sysv64"host function is written withhost_fn!and is thereforecatch_unwind-shielded: a Rust panic becomes a JS exception and poisons the runtime instead of aborting the process. - The uncaught-JS handler is a pure sink; errors are drained after each pump, never acted on re-entrantly.
Re-exports§
pub use bridge::with_app;pub use bridge::with_commit;pub use bridge::with_published;pub use bridge::with_published_app;pub use bridge::Phase;pub use runtime::JsError;pub use runtime::JsRuntime;pub use redjs;pub use redjs_webgpu;
Modules§
- app_
devtools appDevtools: an app switching the devtools off at runtime (disable(), or"devtools": false), back on, or opening the inspector. Without aDevtoolsHost(--features no-devtools) it answers inertly instead of throwing, sodisable()in an entry module is harmless.- bridge
- The JS↔gpui call boundary: raw
&mut App/&mut Windowpointers are published for a bounded scope with an RAII guard (so a panic cannot leave a dangling pointer), tagged with aPhase. Host functions reach them only throughwith_commit/with_app; outside a published scope those returnNoneand the caller must throw a JS error rather than touch gpui. - built
- frames
- The frame clock’s wake seam: a producer that wakes the redjs pump also calls
waketo get a frame. - host
- Building blocks for the native objects the host crates install: promises settled later from Rust, errors, JSON values as JS values, accessors on plain objects.
- runtime
- The process-lifetime JSC context: boot, eval, per-frame pump, and the uncaught-error sink.
- standins
- Inert app API objects for a host built or run without the crate behind one, so
appShell,appTrayand the rest always exist; each says once why it does nothing. - testing
- The JS runtime for tests: one per process, on one thread. JSC boots once per process, and
JsRuntimeis thread-affine, so a test that needs JS runs its body on one long-lived thread (on_js_thread). Bodies share that thread’s global object and thread-locals, so a test sets up what it reads; a panic in a body fails only that test.
Macros§
- host_fn
- Defines a panic-shielded JSC host function, in redjs’s host ABI: a panic becomes a thrown JS
Errorand poisons the runtime. - raw_
host_ fn - A bare host function in redjs’s ABI (
extern "sysv64"on Windows x64,extern "C"elsewhere); no panic shield.