Phone panels (reviewed + QA'd, matrix of 22 layouts with real taps/bounding boxes): - selected-tower action bar over the board (Upgrade/Sell/Target/close), info panel updated in place so taps are never lost, scrollable palette for 7+ towers, overlays with pinned footers (Help "Got it", Play solo, Join always visible), tappable room chip to invite, reduced-motion/contrast/forced-colors fixes, paused state, partner cursor labels, bigger level pips and owner flags - touch input rewritten around "pointerdown commits nothing": pinch never builds, 10px tap slop, palm-proof pinch, long-press pings with any tool armed, nudge arrows for precise placement, hotkey repeat guard, proportional wheel zoom - new e2e: select/sell, info-panel stability, UI states, touch precision; camera unit tests Proxy/server (reproduced against real nginx 1.26 with NPM v2.16 config): - Origin check works when the proxy drops a non-default port, TRUSTED_PROXIES for proxies on global IPv6/CGNAT addresses, service worker no longer serves nginx's 502 page, DEPLOY.md corrected (NPM default read timeout is 90 s, Advanced-tab limits, path-prefix, cookie size, per-IP cap behaviour) Content: - Orbital Uplink: 4-level endgame tower (450 + 500/800/1200 credits): piercing armour-ignoring beam, blast and lingering slow, ground+air, range 11-14; glyph, beam effect, sound, help text, unit tests - Maps: The Canyon, Archipelago, Fortress, Pinwheel (7 maps total) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
39 lines
2 KiB
JavaScript
39 lines
2 KiB
JavaScript
/* Netwall service worker: network-first so updates always win, cache as an offline fallback (solo play offline). */
|
|
const CACHE = 'netwall-v1';
|
|
const CORE = ['./', 'index.html', 'css/style.css', 'js/sim.js', 'js/audio.js', 'js/controllers.js', 'js/render.js', 'js/main.js',
|
|
'manifest.webmanifest', 'icons/icon.svg', 'icons/icon-192.png', 'assets/music/tracks.json'];
|
|
|
|
self.addEventListener('install', (e) => {
|
|
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(CORE)).then(() => self.skipWaiting()).catch(() => self.skipWaiting()));
|
|
});
|
|
self.addEventListener('activate', (e) => {
|
|
e.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim()));
|
|
});
|
|
// An error page from the proxy in front of the app (nginx answers 502/503/504 while the Node process restarts or is
|
|
// down) is a "network failure" for our purposes: serve the cached copy instead of the proxy's error page.
|
|
const GATEWAY_ERRORS = [502, 503, 504];
|
|
|
|
// The cached copy of this request; a navigation (also /?room=ABCD, which has no cache entry of its own) falls back to the
|
|
// cached app shell. `res` is the proxy's error response, still better than nothing for a file that was never cached.
|
|
function offline(req, res) {
|
|
return caches.match(req)
|
|
.then((r) => r || (req.mode === 'navigate' ? caches.match('index.html') : null))
|
|
.then((r) => r || res || Response.error());
|
|
}
|
|
|
|
self.addEventListener('fetch', (e) => {
|
|
const req = e.request;
|
|
if (req.method !== 'GET') return;
|
|
const url = new URL(req.url);
|
|
if (url.origin !== self.location.origin) return;
|
|
e.respondWith(
|
|
fetch(req)
|
|
.then((res) => {
|
|
if (GATEWAY_ERRORS.includes(res.status)) return offline(req, res);
|
|
// Only complete responses: a 206 (a range request for audio) is ok but is not the whole file.
|
|
if (res.status === 200 && res.type === 'basic') { const copy = res.clone(); caches.open(CACHE).then((c) => c.put(req, copy)).catch(() => {}); }
|
|
return res;
|
|
})
|
|
.catch(() => offline(req)),
|
|
);
|
|
});
|