Restructure project to root layout

This commit is contained in:
beatz174-bit committed 2025-11-21 16:10:41 +10:00
1 parent e0e26a34ab
commit 3ffe9bbf99
51 files changed
+16 -12

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
{
"name": "StockFill",
"short_name": "StockFill",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#0d6efd",
"icons": [
{
"src": "/icons/icon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any"
}
]
}
+48
View File
@@ -0,0 +1,48 @@
const CACHE_NAME = 'stockfill-cache-v1';
const OFFLINE_URLS = ['/', '/index.html'];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
return cache.addAll(OFFLINE_URLS);
}),
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(
keys.map((key) => {
if (key !== CACHE_NAME) {
return caches.delete(key);
}
return undefined;
}),
),
),
);
});
self.addEventListener('fetch', (event) => {
const { request } = event;
if (request.method !== 'GET') return;
event.respondWith(
fetch(request)
.then((response) => {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
return response;
})
.catch(async () => {
const cached = await caches.match(request);
if (cached) return cached;
if (request.mode === 'navigate') {
const fallback = await caches.match('/index.html');
if (fallback) return fallback;
}
throw new Error('Network error');
}),
);
});