Skip to main content

Module assets

Module assets 

Source
Expand description

Static files embedded into the binary – stylesheets, scripts, logos and fonts – and how they are served.

Two sources: the explicit list below (static/, media/: files of the web UI) and shared/, the files the web UI shares with the desktop app. build.rs walks shared/ and writes its table into OUT_DIR; every file there is served at /static/shared/<path> (README, tests and test vectors are skipped – the same rule as in desktop/build.rs).

Cache busting: pages link every asset with ?v=<assets version>, a hash over all embedded files. A request with the current version may be cached for a year (immutable); any other request – an outdated link, a font referenced from CSS – has to be revalidated (no-cache + ETag). So a browser never shows an old stylesheet or logo after the server was updated.

Shared scripts are linked through a versioned path instead, /static/shared/v/<assets version>/js/…: ES modules import each other with relative URLs, which drop a ?v= query but stay inside the versioned directory. The same rules apply – the current version is immutable, any other version is still served, with no-cache, so an outdated page works.

Structs§

Asset
One embedded file and the URL path it is served at.

Constants§

FAVICON
URL of the favicon (the TeamCraft icon).
SHARED_PREFIX
URL prefix of the files from shared/.

Functions§

all
Every embedded asset.
find
resolve
The asset for a request path, and whether the request names the current version (?v=<version>, or the path /static/shared/v/<version>/…).
respond
The asset as a response, honouring If-None-Match and the cache rules described at the top of this module (current: see resolve).
version
Version of all embedded assets (12 hex digits), used as ?v= in links and in the versioned path of shared scripts.