How this site runs
lit-ui-router.dev is a Cloudflare Worker with static assets. The docs are plain files; a worker answers only the paths that need a routing decision — the sample apps, through ui-router-server, and the release pages, from two workers behind it: one keeps the release ledger, the other builds release diffs. Server-Side Routing follows a single request through the docs worker.
- Readers load
lit-ui-router.dev: the docs, the sample apps, the release pages and the/ghredirects the README badges link to. - Static assets answer every path outside
run_worker_firstin the site'swrangler.jsonc, with404.htmlfor misses; the worker never sees those requests. The sample-app mounts, the 404 exhibits,/releasesand/ghgo to the docs worker instead. Moved docs pages redirect from a_redirectsfile the build writes fromcatalog/redirects.ts. - The docs worker (
worker/index.ts) answers the sample-app mounts withui-router-serververdicts: a redirect, a 404, or the app's shell, fetched back from static assets like its 404 pages and any path it doesn't route. It also renders the release pages and/ghredirects from ledger rows it reads over RPC, and the release diff pages from diffs it fetches over RPC. It has no database or bucket of its own. - The diffs worker (
release-diffs) builds each pair of releases' npm diff once and serves it from R2; the docs worker calls it through theRELEASE_DIFFSservice binding. The release-diffs worker below draws what is behind it. - The ledger worker keeps the release ledger; the docs worker reads it through the
LEDGERservice binding. The release ledger below draws what is behind it.
The release ledger
The ledger worker (release-ledger) records what the git tag, npm and GitHub say about each release. Claims come in, a queue consumer checks them against the sources and writes the outcome, and other workers read the result.
- GitHub runs
publish-npm.yml, which sends a claim with an Actions OIDC token after each npm publish. Its tags and releases are one of the sources the ledger observes. - npm is the other source: versions and dist-tags.
- The ledger worker verifies each claim at
POST /claims, enqueues it and answers 202 without touching D1. A daily sweep, run by a Cron Trigger, lists the repository's release tags and enqueues a claim for each, so the ledger heals without an Actions run. The queue consumer observes each claim's release on GitHub and npm and is the only thing that writes D1. - Queues hold claims until the consumer takes them, one at a time, with a dead-letter queue for claims that run out of retries.
- D1 stores the release ledger. Other workers read it over RPC through
LedgerReader; the docs worker does, as the site diagram shows.
The ledger worker's bindings, queue settings and schedule are in its wrangler.jsonc.
The release-diffs worker
A third worker keeps the patch npm diff prints between two published versions of a package, built once per version pair.
- The release-diffs worker (
worker/index.ts) answers three RPC methods:indexlists a pair's files,filesstreams the patch sections one file preset shows, andpatchstreams the whole patch. Each reads the pair's entry from R2 first. It has no route and noworkers.devor Preview URL, so the docs worker's service binding is the only way in. - A
ReleaseDiffDurable Object, one per pair, builds a missing entry. - npm serves the packument and both tarballs a build diffs.
- R2 holds one entry per pair under
<layout>/<pkg>/<from>...<to>/: the patch, each preset's sections, andindex.json, written last, so an entry with an index is complete. The object is its only writer; the worker only reads it.
The worker's bucket and Durable Object bindings are in its cloudflare.config.ts; a Preview writes its own bucket.
Building one diff
The worker addresses a pair's object by name, <pkg>@<from>...<to>, and its first call creates it. The object keeps nothing in storage: calls that arrive while a build runs share that build, and each build reads index.json again first, in case another just finished. A build fetches the packument and both tarballs, unpacks and diffs them in memory, then writes the patch and each preset's sections before index.json. A build that fails before the index lands leaves the pair without one, so the next miss builds it again. An idle object is evicted, with nothing to clean up.