five-on-it / apps/client/src/renderer/level-cache
apps/client/src/renderer/level-cache
The levels a page fetches by their hash (?levels=hash on its connection, LEVELS_BY_HASH in @foi/protocol) and keeps in the browser: a welcome that names its level (ref, its SHA-256 and length) instead of carrying it is answered from this store when the level was played before, else from the game server that sent it (/levels/<hash>.json beside its socket), its bytes checked against the hash before they are kept or parsed.
The store is the Cache API where the page has it, else IndexedDB, else none (a page in a context that has neither downloads the level every time); every access is guarded, so a store that fails (a private window, cleared site data) only costs a download.