Improve mobile layouts, co-op display sync and add offline service worker
- Board rotates 90 degrees on portrait stages (bigger cells), counter-rotated glyphs/labels; layout breakpoints fixed for landscape phones, narrow portrait phones and 320px devices (verified across a 14-size matrix) - Remote controller applies tower changes with the delayed display snapshot so towers and credits update together; compact info panel; touch confirm bar - Audio loads tracks via assets/music/tracks.json (no 404 probing) - Network-first service worker for installable, offline-capable solo play Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
107ef60ec6
commit
7fe6aba87d
3 changed files with 64 additions and 8 deletions
25
public/sw.js
Normal file
25
public/sw.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* 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()));
|
||||
});
|
||||
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 (res.ok && res.type === 'basic') { const copy = res.clone(); caches.open(CACHE).then((c) => c.put(req, copy)).catch(() => {}); }
|
||||
return res;
|
||||
})
|
||||
.catch(() => caches.match(req).then((r) => r || caches.match('index.html'))),
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue