webui

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package webui holds the browser client that is shared by both transports — the SSE server (engine/server) and the WASM host (cmd/notebook). It is the "one thing" behind "one file, two transports": the CSS, the control/cell builder, the dependency-graph view, and the event renderer live here once, so the two clients cannot drift into showing different notebooks.

It is pure data (Go string constants) with no imports, so importing it creates no dependency cycle and does not pull net/http into anything. Each client supplies only its transport glue: how META arrives, how an edit is sent, and how events are delivered.

The client is deliberately ignorant of Go types. It reads cell metadata (labels, directives, dependency edges, source) to build controls, a graph, and cell displays; it renders {cell, state, mime, data, epoch, err} events; it reports edits as {leaf, value}. Renderers run in Go, in-process — the client only paints their MIME-tagged output.

Index

Constants

View Source
const CSS = `` /* 12309-byte string literal not displayed */

CSS is the shared stylesheet: palette, controls + custom slider, cell state rail, the read-only source disclosure, and the dependency graph. Both clients embed it verbatim. It contains literal % (none currently) — callers that Sprintf their page must escape as needed; the server uses string.Replace and the wasm host uses indexed verbs, so this string is inserted, not formatted.

View Source
const JS = `` /* 32989-byte string literal not displayed */

JS is the shared render engine. It defines a global NB object with the whole client behavior; a transport then calls NB.init(META, {onEdit}) once and NB.render(ev) per event. Everything the two clients had in common — controls with the degradation ladder, the dependency graph, the five-state rail, the read-only source disclosure, the epoch-monotonic guard, error/blocked display — lives here exactly once.

The page must contain #controls, #cells, and #graph elements before init.

Variables

This section is empty.

Functions

func Page

func Page(opts PageOpts) string

Page assembles the complete notebook HTML for a transport. It owns the shell — <head> with the shared CSS, the graph/controls/cells body, the shared client JS — so no transport hand-rolls the page. A transport supplies only its glue (how META arrives, how edits are sent, how events are delivered). This is the presentation that used to live as a const inside engine/server; moving it here lets that package go back to being a transport that serves what it's handed.

Types

type PageOpts

type PageOpts struct {
	Title     string
	Subtitle  string
	Status    bool
	HeadExtra string
	BodyPre   string // extra markup injected before the shared body (e.g. wasm status line)
	Glue      string // transport <script> body, appended after the shared JS

	// GraphShowcase controls where the dependency graph sits. The graph is the
	// project's thesis, so the landing-page demos lead with it (open, at the top)
	// — that is what "watch the wave move through the graph" is selling. But when
	// you are USING a notebook the results are the point, so the interactive
	// server and a plain `build` put the graph in a collapsed disclosure AFTER the
	// cells: a tool you open to debug, not the first thing in your way. True =
	// open, at top (showcase); false = collapsed, at end (default).
	GraphShowcase bool
}

PageOpts parameterize the shared HTML shell for a transport. Title is the <title> and the <h1>; Subtitle is optional muted text after the <h1> (the wasm host uses "· running in your browser, no server"). Status, when true, adds a <div id="status"> line (the wasm bootstrap writes into it). Glue is the transport-specific <script> body appended after the shared client JS — it calls NB.init(...) and wires events. Head is optional extra <head> markup (e.g. the wasm host's <script src="wasm_exec.js">, placed before the client).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL