beck_rt/
lib.rs

1//! The Beck runtime — the effectful host a compiled program runs on.
2//!
3//! [`docs/05-tier-lowering.md`](../../../../docs/05-tier-lowering.md) §5.2 calls this "the 'Roc
4//! platform' of Beck — an effectful Rust host owning I/O, scheduling and memory, executing the
5//! pure program". Concretely: the log engine, the sequencer, the structural differ, the patch
6//! protocol, the websocket, and the SSR path.
7//!
8//! Phase 0 built all of this against one hand-written application. The interesting property of
9//! Phase 1 is what is *missing* here: no `Todo`, no `Command`, no view. Those arrive as compiled
10//! `Core` through [`program::Runtime`].
11
12pub mod app;
13pub mod awareness;
14pub mod dash;
15pub mod http;
16pub mod identity;
17pub mod log;
18pub mod oidc;
19pub mod outbound;
20pub mod patch;
21pub mod pgwire;
22pub mod presence;
23pub mod quota;
24pub mod session;
25pub mod signals;
26pub mod telemetry;
27pub mod testing;
28
29pub use app::{replay_from_genesis, replay_to, App, AppConfig};
30pub use beck_core::diff::{self, diff, Op, Path};
31pub use beck_host::Runtime;
32/// The compiled program and the wire it speaks on, from [`beck_host`] — the half of this platform
33/// that is program-shaped rather than machine-shaped, and that a browser tab therefore also runs
34/// ([`docs/17-playground.md`](../../../../docs/17-playground.md) §17.2). Re-exported at the paths
35/// they have always had: `beck_rt::program::Runtime` is `beck_host::program::Runtime`.
36pub use beck_host::{program, protocol};
37pub use dash::{Dashboard, ResourceRow};
38pub use log::{
39    Durability, Envelope, Instant, LogStore, MemoryLog, PgLog, RedbLog, Seq, Snapshot, SqliteLog,
40};
41pub use patch::{Codec, PatchFrame};
42pub use telemetry::{telemetry, timed, Telemetry};
43pub use testing::{run as run_tests, Case, Options as TestOptions, Outcome, Report as TestReport};
44
45/// The patch interpreter and the socket, shared by both rendering modes (§5.1).
46///
47/// "Hand-written JavaScript never appears in the source — it's compiler residue: the patch
48/// interpreter plus the compiled view. You stopped writing it the moment the page became a
49/// function." These three files are that residue, and they hold no application logic.
50pub const PATCH_CLIENT: &str = include_str!("../client/beck-patch.js");
51
52/// Mode A: apply the patches the server sends, post commands back up the socket.
53pub const THIN_CLIENT: &str = include_str!("../client/beck-thin.js");
54
55/// Mode B: load the kernel, hold the state, render locally ([`beck_core::render`]).
56pub const MODE_B_CLIENT: &str = include_str!("../client/beck-mode-b.js");
57
58/// The devtools panel: the signal graph, the patch traffic and the pending commands.
59///
60/// Loaded only when it is asked for (`?devtools`, or the switch it leaves in `localStorage`), which
61/// is what keeps it out of the residue every page pays for. It reads the same three things the
62/// runtime already publishes and computes nothing of its own — a panel that derived a second
63/// account of the client's state could be the only wrong one on the screen.
64pub const DEVTOOLS_CLIENT: &str = include_str!("../client/beck-devtools.js");
65
66/// Mode B's service worker: the shell, cached, so a cold start with no network is a page.
67///
68/// Served with the program's wire id substituted for `%WIRE%`, which is what keys the cache to the
69/// program and what deletes the previous one on a deploy.
70pub const SERVICE_WORKER: &str = include_str!("../client/beck-sw.js");