/// Parts of a page that render on their own (ADR 0066): a page calls /// `later skeleton render` where a slow part goes, and the handler the /// application installs decides how parts render. `inline` renders them /// in place; `streamed` renders each in an actor of its own and streams it /// in as it finishes (`parts`). /// /// `e` is the effects a part may perform. A part receives their handlers /// (its row is row evidence, ADR 0066) instead of capturing the page's, so /// it can run in an actor, under handlers installed there. import parts.{type Settings} import std/html.{type Html} import std/http.{type Response} import std/process.{type proc} import std/random.{type random} import std/time.{type clock} pub effect async { /// `skeleton` now, and `render`'s result once it is ready. fn later :: skeleton: Html render: send fn() -> Html / -> Html } /// Every part rendered in place, with the handlers around the page: /// for fragments, requests without a body, and tests. pub fn inline :: action: fn() -> a / | e> -> a / { handle { action () } with { later _ render -> render () } } /// Every part rendered by an actor of its own, and the page streamed /// (`parts.respond`). `within` runs a part in its actor under the /// application's handlers; it is written as a lambda that calls the part: /// `fn render { within_app fn { render () } }`. `settings.nonce` is the /// request's: the streamed page's policy and swap script carry it. pub fn streamed :: settings: Settings action: fn() -> Response / | e2> within: send fn(fn() -> Html / ) -> Html / -> Response / { let held = parts.new () let resp = handle { action () } with { later skeleton render -> parts.start held skeleton fn { within render } } parts.respond held settings resp }