The read package (pkg:read) is the Read tab of Seed Exact. It fetches documents from a Seed site over the Seed site read API, turns their block trees into flat rows of Markdown, and renders them with the components in read.contract. It is read-only: nothing here signs or writes.
Responsibility
Show the configured server's home document at /, any document at /d/:ref, a space's directory at /dir/:uid, an author at /a/:uid, and the open-site sheet at /open-site (see Navigation and routes).
Accept a whole URL as the doc route parameter, so deep links and typed site addresses open in the reader.
Keep every document on the navigation stack answered from a module cache, so going Back never shows a spinner.
Files
File | Role | Documented in |
|---|---|---|
| ||
Decoder for the | ||
Refs, hm URLs, in-app hrefs, link targets, media URLs | ||
Document pages, caches, embeds, queries | ||
|
| |
Blocks to rows, annotations to Markdown | ||
Validation of a typed address | ||
The four sources and the refresh epoch | ||
Shapes and components | ||
| State, resources, actions, view switch | |
| 56 Bun tests in 7 files, 9 captured API fixtures | each page above, and Bun unit tests |
| 12 and 4 Contract tests |
Data flow
flowchart TD
NAV["nav stack: read and doc entries"] --> REFS["derive readRefs"]
REFS --> RES["resource docs = readDocs(server, readRefs, readEpoch)"]
RES --> SRC["sources.readDocs in sources.ts"]
SRC --> EPOCH["epochSeen: new epoch drops caches"]
SRC --> LOAD["loadDocs then loadDoc per ref"]
LOAD --> CACHE{"docCache hit?"}
CACHE -- yes --> PAGE["DocPage"]
CACHE -- no --> BUILD["buildPage"]
BUILD --> API["api: GET server/api/Resource, Query, QueryBlock, Account, ResourceMetadata"]
API --> DEC["decodeEnvelope"]
DEC --> ROWS["blocksToRows and inlineMarkdown"]
ROWS --> PAGE
PAGE --> SCREEN["DocScreen picks the page whose ref matches"]The directory and author screens follow the same path through readDirectory and readAuthors, asked on readContextServer (the server of the visible reader) instead of the configured server.
Design rules the package follows
Sources never read a clock. Relative dates come from the root's minute tick, see State, refresh and stale-reply patterns.
A failed load is returned as a page with error set and is never cached, so Retry asks again.
Every screen receives active. Only the visible screen carries plain testIds, so covered screens on the stack never collide with the top one (read.contract L4-L7).
A typed web address is read from its own server, never silently from the default one.
In this section
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime