Skip to main content

Crate sk_runtime

Crate sk_runtime 

Source
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 with host_fn! and is therefore catch_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 a DevtoolsHost (--features no-devtools) it answers inertly instead of throwing, so disable() in an entry module is harmless.
bridge
The JS↔gpui call boundary: raw &mut App / &mut Window pointers are published for a bounded scope with an RAII guard (so a panic cannot leave a dangling pointer), tagged with a Phase. Host functions reach them only through with_commit / with_app; outside a published scope those return None and 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 wake to 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, appTray and 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 JsRuntime is 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 Error and 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.