Read: documents
The read package: the document reader, site home, directory, author pages and opening a site by URL.

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.

    Provide the id helpers, API client and block renderer that Discuss, Activity and Profile reuse.

Files

File

Role

Documented in

src/read/client.ts

GET {server}/api/{Key} client, SeedError, 15 s timeout

API client and superjson decoder

src/read/superjson.ts

Decoder for the {json, meta} wire envelope

API client and superjson decoder

src/read/ids.ts

Refs, hm URLs, in-app hrefs, link targets, media URLs

Ids, refs and link targets

src/read/load.ts

Document pages, caches, embeds, queries

Loading pages, caches and embeds

src/read/load.ts (rows, directory, authors)

itemOf, treeOrder, loadDirectory, loadAuthor

Rows, directory and author pages

src/read/markdown.ts

Blocks to rows, annotations to Markdown

Blocks to rows and inline Markdown

src/read/open-site.ts

Validation of a typed address

Open a site by URL

src/read/sources.ts

The four sources and the refresh epoch

Sources and the refresh epoch

read.contract

Shapes and components

Screens and components

app.contract pkg:read blocks

State, resources, actions, view switch

Root contract wiring

src/read/__tests__/

56 Bun tests in 7 files, 9 captured API fixtures

each page above, and Bun unit tests

read.test.contract, open-site.test.contract

12 and 4 Contract tests

Screens and components, Open a site by URL

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.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Comments