Commit 1de9ef1
committed
feat(demo): subdomain gateway, readiness probe, IndexedDB cache, interstitial
Service-worker gateway extensions to the existing demo, mirroring the IPFS
service-worker-gateway pattern (https://inbrowser.link) but for Swarm:
* Subdomain detection in sw.js: <cid>.localhost, <cid>.bzz.localhost, and
<cid>.bytes.localhost (the last routes to bee's /bytes endpoint for raw
chunk retrieval, the others to /bzz for manifest-style content). The
subdomain label is passed verbatim to bee, which resolves it via the
cidv1 resolver (swarm-manifest codec 0xfa, keccak-256 multihash, base32
multibase) back to the underlying 32-byte chunk address.
* main.js register-and-reload bootstrap: subdomain origins register the SW
on first visit, then reload so the controller can intercept the next
navigation.
* Readiness probe (/__bee_ready) backed by /peers + a 20s SW-side startup
grace. Bee bypasses --warmup-time for light nodes (warmupTime=0 in
pkg/node/node.go for !FullNodeMode), so kademlia bins haven't populated
by the time the API opens. The grace gives them time before we let the
page issue retrieval requests.
* interstitial.js: polls readiness, surfaces distinct states (warming
grace, peer wait, API not ready), and reloads once truly ready so the
SW's navigation handler forwards to bee.
* IndexedDB-backed localstore mount: chunks + their leveldb index persist
across reloads so repeat visits don't re-fetch the same chunks. Other
paths stay InMemory so identity / kademlia / accounting state doesn't
leak across sessions.
* navigate-mode waitUntil(10s) keeps the SW alive after responses so bee's
background cache-write goroutines (Cache().Put scheduled async in
pkg/storer/netstore.go) have time to flush to IndexedDB before Chrome
idle-kills the worker.
* Bee error passthrough: 4xx/5xx navigation responses surface bee's actual
JSON error message in a terminal page instead of a misleading
'content not reachable' string.1 parent a2ae4cf commit 1de9ef1
3 files changed
Lines changed: 462 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
4 | | - | |
5 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
6 | 27 | | |
7 | 28 | | |
8 | 29 | | |
| |||
0 commit comments