Add PWA support for install-to-home-screen
Adds manifest.json, service worker with static asset caching, resized cat icons, and meta tags for iOS/Android installability. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BIN
raggr-frontend/public/apple-touch-icon.png
Normal file
BIN
raggr-frontend/public/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
14
raggr-frontend/public/manifest.json
Normal file
14
raggr-frontend/public/manifest.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Ask Simba",
|
||||
"short_name": "Simba",
|
||||
"description": "Chat with Simba - your AI cat companion",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#FAF8F2",
|
||||
"theme_color": "#2A4D38",
|
||||
"icons": [
|
||||
{ "src": "/pwa-icon-192.png", "sizes": "192x192", "type": "image/png" },
|
||||
{ "src": "/pwa-icon-512.png", "sizes": "512x512", "type": "image/png" },
|
||||
{ "src": "/pwa-icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
||||
]
|
||||
}
|
||||
BIN
raggr-frontend/public/pwa-icon-192.png
Normal file
BIN
raggr-frontend/public/pwa-icon-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
raggr-frontend/public/pwa-icon-512.png
Normal file
BIN
raggr-frontend/public/pwa-icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
46
raggr-frontend/public/sw.js
Normal file
46
raggr-frontend/public/sw.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const CACHE = 'simba-v1';
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (e) => {
|
||||
e.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (e) => {
|
||||
const { request } = e;
|
||||
const url = new URL(request.url);
|
||||
|
||||
// Network-only for API calls
|
||||
if (url.pathname.startsWith('/api/')) return;
|
||||
|
||||
// Cache-first for fingerprinted static assets
|
||||
if (url.pathname.startsWith('/static/')) {
|
||||
e.respondWith(
|
||||
caches.match(request).then(
|
||||
(cached) =>
|
||||
cached ||
|
||||
fetch(request).then((res) => {
|
||||
const clone = res.clone();
|
||||
caches.open(CACHE).then((c) => c.put(request, clone));
|
||||
return res;
|
||||
})
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Network-first for navigation (offline fallback to cache)
|
||||
if (request.mode === 'navigate') {
|
||||
e.respondWith(
|
||||
fetch(request).catch(() => caches.match(request))
|
||||
);
|
||||
return;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user