public/sw.js: network-falling-back-to-cache for RainViewer radar tile requests specifically (nothing else — the app itself is served by the same local server that's already the offline resource in the van, so there's no app-shell to precache). Registered from layout.erb, a no-op where it can't register (insecure context) rather than an error. Verified: registers and controls the page, tiles get cached on a normal fetch, cache.match() correctly retrieves them by the same request. CDP's network-blocking simulation doesn't interact cleanly with Service Worker fetch interception (a known tooling quirk, not specific to this), so the actual offline fallback path is the standard try/catch pattern, verified by code review rather than a simulated-offline screenshot.
46 lines
2.0 KiB
ERB
46 lines
2.0 KiB
ERB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>MapTool</title>
|
|
<link rel="stylesheet" href="/vendor/maplibre-gl/maplibre-gl.css">
|
|
<link rel="stylesheet" href="/css/style.css?v=<%= ASSET_VERSION %>">
|
|
</head>
|
|
<body>
|
|
<%= yield %>
|
|
<script>
|
|
// Caches radar tile images (see public/sw.js) so the last-seen frames
|
|
// stay visible once the network is actually gone. Silently a no-op
|
|
// where it can't register — insecure-context LAN access without a
|
|
// reverse proxy in front, for instance — same as radar caching simply
|
|
// not working there; nothing else on the page depends on this.
|
|
if ("serviceWorker" in navigator) {
|
|
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
|
}
|
|
</script>
|
|
<script src="/vendor/pmtiles/pmtiles.js"></script>
|
|
<script src="/vendor/protomaps-themes-base/protomaps-themes-base.js"></script>
|
|
<%# Vendored libs above don't change between deploys, so they're left
|
|
unversioned; app.js's own modules do, and map.js statically imports
|
|
them by bare path — an import map remaps those paths to a versioned
|
|
URL so editing e.g. gpx.js also busts its cache, without having to
|
|
touch every file's import statements. Must come before the module
|
|
script below: the importmap has to be parsed first. %>
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"/js/gnss.js": "/js/gnss.js?v=<%= ASSET_VERSION %>",
|
|
"/js/gpx.js": "/js/gpx.js?v=<%= ASSET_VERSION %>",
|
|
"/js/icons.js": "/js/icons.js?v=<%= ASSET_VERSION %>",
|
|
"/js/livetrack.js": "/js/livetrack.js?v=<%= ASSET_VERSION %>",
|
|
"/js/panels.js": "/js/panels.js?v=<%= ASSET_VERSION %>",
|
|
"/js/radar.js": "/js/radar.js?v=<%= ASSET_VERSION %>",
|
|
"/js/track_profile.js": "/js/track_profile.js?v=<%= ASSET_VERSION %>"
|
|
}
|
|
}
|
|
</script>
|
|
<script type="module" src="/js/map.js?v=<%= ASSET_VERSION %>"></script>
|
|
</body>
|
|
</html>
|