feat(apps): add Gashboard with native signing and viewer access

This commit is contained in:
yaya
2026-10-06 06:42:25 +01:00
parent cedfbb2b07
commit 908e366006
100 changed files with 11072 additions and 0 deletions
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="gashboard">
<rect width="512" height="512" fill="#07090f"/>
<rect x="34" y="34" width="444" height="444" fill="#0c1120" stroke="#29ffe6" stroke-width="12"/>
<path d="M98 314h68v74H98zm92-118h68v192h-68zm92 54h68v138h-68zm92-126h68v264h-68z" fill="#ff3df0"/>
<path d="M80 256h64l34-82 62 178 58-132 44 70h90" fill="none" stroke="#29ffe6" stroke-width="18" stroke-linejoin="round" stroke-linecap="round"/>
<text x="256" y="104" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="54" font-weight="700">G</text>
</svg>

After

Width:  |  Height:  |  Size: 630 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="gashboard">
<rect width="512" height="512" fill="#07090f"/>
<circle cx="256" cy="256" r="188" fill="#0c1120" stroke="#29ffe6" stroke-width="14"/>
<path d="M126 316h62v72h-62zm84-118h62v190h-62zm84 52h62v138h-62zm84-126h62v264h-62z" fill="#ff3df0"/>
<path d="M104 258h66l32-82 60 176 58-132 44 70h54" fill="none" stroke="#29ffe6" stroke-width="18" stroke-linejoin="round" stroke-linecap="round"/>
<text x="256" y="112" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="52" font-weight="700">G</text>
</svg>

After

Width:  |  Height:  |  Size: 622 B

@@ -0,0 +1,34 @@
{
"name": "gashboard",
"short_name": "gashboard",
"description": "Solo mining dashboard for Datum miners.",
"start_url": "/",
"scope": "/",
"display": "standalone",
"orientation": "portrait-primary",
"background_color": "#07090f",
"theme_color": "#0a0e1a",
"categories": ["utilities", "finance"],
"icons": [
{
"src": "/icons/icon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any"
},
{
"src": "/icons/maskable.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "maskable"
}
],
"shortcuts": [
{
"name": "Graphs",
"short_name": "Graphs",
"url": "/graphs",
"description": "Open telemetry graphs"
}
]
}
@@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 220" role="img" aria-label="Avalon Mini 3 miner">
<rect width="420" height="220" fill="none"/>
<g filter="url(#g)">
<rect x="44" y="56" width="332" height="110" rx="16" fill="#1f2937" stroke="#ff3df0" stroke-width="4"/>
<rect x="70" y="78" width="210" height="66" rx="8" fill="#0b0f19" stroke="#29ffe6" stroke-width="3"/>
<path d="M92 96h166M92 112h166M92 128h166" stroke="#475569" stroke-width="7" stroke-linecap="round"/>
<circle cx="326" cy="111" r="34" fill="#07090f" stroke="#ffd84a" stroke-width="5"/>
<path d="M326 78v66M293 111h66M303 88l46 46M349 88l-46 46" stroke="#6cff8c" stroke-width="4"/>
<path d="M76 166h268M104 184h212" stroke="#475569" stroke-width="8" stroke-linecap="round"/>
<circle cx="62" cy="74" r="6" fill="#29ffe6"/>
<circle cx="360" cy="74" r="6" fill="#ff3df0"/>
</g>
<defs><filter id="g"><feDropShadow dx="0" dy="9" stdDeviation="9" flood-color="#000" flood-opacity=".55"/></filter></defs>
</svg>

After

Width:  |  Height:  |  Size: 1023 B

@@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Avalon Nano 3 miner">
<rect width="320" height="220" fill="none"/>
<g filter="url(#g)">
<rect x="76" y="44" width="168" height="128" rx="20" fill="#e7edf5" stroke="#29ffe6" stroke-width="4"/>
<rect x="96" y="64" width="128" height="88" rx="14" fill="#111827"/>
<circle cx="160" cy="108" r="42" fill="#07090f" stroke="#ff3df0" stroke-width="6"/>
<path d="M160 68c16 22 16 58 0 80M120 108c22-16 58-16 80 0M132 80c30 4 52 26 56 56M188 80c-4 30-26 52-56 56" stroke="#29ffe6" stroke-width="4" stroke-linecap="round"/>
<rect x="112" y="166" width="96" height="12" rx="6" fill="#475569"/>
<path d="M64 112h28M228 112h28" stroke="#ffd84a" stroke-width="8" stroke-linecap="round"/>
</g>
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".45"/></filter></defs>
</svg>

After

Width:  |  Height:  |  Size: 925 B

@@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="BigPapa Bitaxe miner">
<rect width="320" height="220" fill="none"/>
<g filter="url(#shadow)">
<rect x="54" y="62" width="212" height="96" rx="10" fill="#16121f" stroke="#ff3df0" stroke-width="5"/>
<rect x="76" y="84" width="66" height="52" rx="6" fill="#07090f" stroke="#ffd84a" stroke-width="4"/>
<circle cx="109" cy="110" r="20" fill="#0b0f19" stroke="#29ffe6" stroke-width="5"/>
<path d="M109 88v44M87 110h44" stroke="#ff4f78" stroke-width="4"/>
<path d="M178 81h50l14 17-14 17h-50l-14-17z" fill="#ff3df0" opacity=".9"/>
<text x="203" y="104" text-anchor="middle" fill="#07090f" font-family="monospace" font-size="18" font-weight="700">BIG</text>
<rect x="166" y="124" width="76" height="13" rx="4" fill="#29ffe6" opacity=".8"/>
<path d="M74 160h172M96 177h128" stroke="#475569" stroke-width="8" stroke-linecap="round"/>
<path d="M62 56l28-24h34l-12 30zM258 56l-28-24h-34l12 30z" fill="#ffd84a" stroke="#ff3df0" stroke-width="3"/>
<circle cx="61" cy="72" r="6" fill="#6cff8c"/>
<circle cx="259" cy="72" r="6" fill="#6cff8c"/>
</g>
<text x="160" y="207" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">BIGPAPA BITAXE</text>
<defs>
<filter id="shadow">
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".6"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Bitaxe miner">
<rect width="320" height="220" fill="none"/>
<g filter="url(#g)">
<rect x="72" y="70" width="176" height="84" rx="12" fill="#152033" stroke="#6cff8c" stroke-width="4"/>
<rect x="94" y="88" width="56" height="48" rx="6" fill="#0b0f19" stroke="#29ffe6" stroke-width="3"/>
<circle cx="122" cy="112" r="18" fill="#07090f" stroke="#ff3df0" stroke-width="5"/>
<path d="M122 94v36M104 112h36" stroke="#ffd84a" stroke-width="3"/>
<rect x="166" y="90" width="54" height="18" rx="3" fill="#29ffe6" opacity=".85"/>
<rect x="166" y="118" width="38" height="10" rx="3" fill="#ff3df0" opacity=".85"/>
<path d="M86 154h148M104 170h112" stroke="#475569" stroke-width="7" stroke-linecap="round"/>
<circle cx="80" cy="80" r="5" fill="#ffd84a"/>
<circle cx="240" cy="80" r="5" fill="#ffd84a"/>
</g>
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Boomer Heater">
<rect width="320" height="220" fill="none"/>
<g filter="url(#g)">
<rect x="72" y="48" width="176" height="132" rx="14" fill="#3b2f2f" stroke="#ff4f78" stroke-width="4"/>
<rect x="92" y="70" width="136" height="84" rx="8" fill="#1f1717"/>
<path d="M116 142c-18-28 18-36 0-64M160 142c-18-28 18-36 0-64M204 142c-18-28 18-36 0-64" fill="none" stroke="#ff8a4f" stroke-width="8" stroke-linecap="round"/>
<path d="M90 180h140" stroke="#475569" stroke-width="10" stroke-linecap="round"/>
<circle cx="224" cy="58" r="9" fill="#6a7aa0"/>
<text x="160" y="205" text-anchor="middle" fill="#6a7aa0" font-family="monospace" font-size="15" font-weight="700">NO HASHES. JUST GHEI.</text>
</g>
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
</svg>

After

Width:  |  Height:  |  Size: 940 B

@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="NerdQAxe miner">
<rect width="320" height="220" fill="none"/>
<g filter="url(#g)">
<rect x="58" y="54" width="204" height="112" rx="10" fill="#111827" stroke="#29ffe6" stroke-width="4"/>
<rect x="78" y="74" width="74" height="70" rx="6" fill="#2a102b" stroke="#ff3df0" stroke-width="3"/>
<circle cx="115" cy="109" r="28" fill="#07090f" stroke="#29ffe6" stroke-width="5"/>
<path d="M115 82v54M88 109h54M96 90l38 38M134 90l-38 38" stroke="#6cff8c" stroke-width="3"/>
<rect x="170" y="76" width="70" height="28" rx="4" fill="#05070c" stroke="#ffd84a" stroke-width="3"/>
<path d="M180 92h50" stroke="#ffd84a" stroke-width="4"/>
<path d="M72 166h176M88 184h144" stroke="#475569" stroke-width="8" stroke-linecap="round"/>
<circle cx="81" cy="58" r="8" fill="#ff3df0"/>
<circle cx="239" cy="58" r="8" fill="#29ffe6"/>
</g>
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#0a0d17"/>
<path d="M46 54h164v128H46z" fill="#151b2b" stroke="#29ffe6" stroke-width="4"/>
<circle cx="99" cy="105" r="26" fill="#e8edff"/>
<circle cx="157" cy="105" r="26" fill="#e8edff"/>
<path d="M77 159c25 20 77 20 102 0" fill="none" stroke="#ff3df0" stroke-width="8"/>
<path d="M65 62l126 126M191 62L65 188" stroke="#1f2a4a" stroke-width="5"/>
<text x="128" y="222" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">ANON FOUND HASHES</text>
</svg>

After

Width:  |  Height:  |  Size: 610 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#07090f"/>
<rect x="54" y="42" width="148" height="148" fill="#131a2e" stroke="#29ffe6" stroke-width="5"/>
<path d="M76 76l104 104M180 76L76 180" stroke="#ff4f78" stroke-width="15"/>
<text x="128" y="118" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">BLOCK</text>
<text x="128" y="142" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">DENIED</text>
<text x="128" y="224" text-anchor="middle" fill="#b6c3e0" font-family="monospace" font-size="13">TRY ANOTHER 2 BILLION TIMES</text>
</svg>

After

Width:  |  Height:  |  Size: 691 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#07090f"/>
<g>
<animateTransform attributeName="transform" type="translate" values="0 0;0 -10;0 0" dur=".8s" repeatCount="indefinite"/>
<rect x="74" y="52" width="108" height="108" fill="#131a2e" stroke="#29ffe6" stroke-width="5"/>
<text x="128" y="113" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="24" font-weight="700">?</text>
</g>
<path d="M82 185c24 13 68 13 92 0" fill="none" stroke="#ff3df0" stroke-width="8"/>
<text x="128" y="224" text-anchor="middle" fill="#b6c3e0" font-family="monospace" font-size="14">THIS ONE IS OURS</text>
</svg>

After

Width:  |  Height:  |  Size: 694 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#0a0d17"/>
<rect x="65" y="48" width="126" height="145" rx="8" fill="#1b1f2b" stroke="#ff4f78" stroke-width="5"/>
<path d="M89 74h78M89 98h78M89 122h78M89 146h78" stroke="#6a7aa0" stroke-width="7"/>
<path d="M83 181h90" stroke="#ffd84a" stroke-width="8"/>
<text x="128" y="222" text-anchor="middle" fill="#ff4f78" font-family="monospace" font-size="18" font-weight="700">0 H/s AND PROUD</text>
</svg>

After

Width:  |  Height:  |  Size: 511 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#07090f"/>
<path d="M83 72l28-30h50l24 35-12 75-45 36-45-36z" fill="#d9d3c7" stroke="#29ffe6" stroke-width="5"/>
<path d="M86 76h87l-16-30h-45z" fill="#ff3df0"/>
<path d="M93 108h28M143 108h28" stroke="#07090f" stroke-width="7"/>
<path d="M101 145c23 13 49 13 72 0" fill="none" stroke="#07090f" stroke-width="7"/>
<text x="128" y="220" text-anchor="middle" fill="#6cff8c" font-family="monospace" font-size="18" font-weight="700">HASHING. UNBOTHERED.</text>
</svg>

After

Width:  |  Height:  |  Size: 576 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#07090f"/>
<rect x="34" y="47" width="188" height="139" fill="#101624" stroke="#2c3a66" stroke-width="4"/>
<path d="M52 164h154M52 127h154M52 90h154" stroke="#1f2a4a" stroke-width="3"/>
<path d="M55 156l32-2 22-47 31 42 18-9 17-60 31 3" fill="none" stroke="#29ffe6" stroke-width="7"/>
<circle cx="175" cy="80" r="9" fill="#ff4f78"/>
<text x="128" y="222" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">CHART CRIME</text>
</svg>

After

Width:  |  Height:  |  Size: 586 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#07090f"/>
<circle cx="128" cy="112" r="68" fill="#101624" stroke="#29ffe6" stroke-width="5"/>
<g transform-origin="128 112">
<animateTransform attributeName="transform" type="rotate" from="0 128 112" to="360 128 112" dur=".45s" repeatCount="indefinite"/>
<path d="M128 112c38-44 75-21 45 11-16 17-38 7-45-11zM128 112c-38 44-75 21-45-11 16-17 38-7 45 11zM128 112c44 38 21 75-11 45-17-16-7-38 11-45zM128 112c-44-38-21-75 11-45 17 16 7 38-11 45z" fill="#ff3df0"/>
</g>
<circle cx="128" cy="112" r="13" fill="#ffd84a"/>
<text x="128" y="221" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="18" font-weight="700">FAN PANIC</text>
</svg>

After

Width:  |  Height:  |  Size: 776 B

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#080a10"/>
<circle cx="128" cy="93" r="58" fill="#8ea0c4" stroke="#2c3a66" stroke-width="5"/>
<circle cx="105" cy="86" r="9" fill="#0a0d17"/>
<circle cx="151" cy="86" r="9" fill="#0a0d17"/>
<path d="M103 123h50" stroke="#0a0d17" stroke-width="7"/>
<rect x="45" y="160" width="166" height="42" fill="#131a2e" stroke="#ff4f78" stroke-width="4"/>
<text x="128" y="187" text-anchor="middle" fill="#ff4f78" font-family="monospace" font-size="17" font-weight="700">I TRUST BANKS</text>
<text x="128" y="225" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="14">NORMAL HEATER USER</text>
</svg>

After

Width:  |  Height:  |  Size: 726 B

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#080a10"/>
<g>
<animateTransform attributeName="transform" type="scale" values="1;1.06;1" dur=".7s" repeatCount="indefinite" additive="sum"/>
<path d="M128 35c38 43 59 75 59 111 0 37-26 68-59 68s-59-31-59-68c0-36 21-68 59-111z" fill="#ff4f78" stroke="#ffd84a" stroke-width="5"/>
</g>
<path d="M106 144h44M105 166h46" stroke="#0a0d17" stroke-width="7"/>
<text x="128" y="232" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="15" font-weight="700">PROOF OF WARMTH</text>
</svg>

After

Width:  |  Height:  |  Size: 616 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#0c1120"/>
<rect x="45" y="56" width="166" height="82" fill="#151b2b" stroke="#ff4f78" stroke-width="5"/>
<rect x="64" y="118" width="128" height="62" fill="#101624" stroke="#29ffe6" stroke-width="4"/>
<path d="M79 151h98" stroke="#ffd84a" stroke-width="7" stroke-dasharray="10 8"/>
<text x="128" y="103" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="26" font-weight="700">BRRR</text>
<text x="128" y="218" text-anchor="middle" fill="#ff3df0" font-family="monospace" font-size="17" font-weight="700">FIAT PATCH NOTES</text>
</svg>

After

Width:  |  Height:  |  Size: 668 B

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#080a10"/>
<path d="M128 31l53 82H75z" fill="#131a2e" stroke="#ff3df0" stroke-width="5"/>
<circle cx="128" cy="134" r="52" fill="#151b2b" stroke="#29ffe6" stroke-width="5"/>
<circle cx="108" cy="126" r="7" fill="#ffd84a"/>
<circle cx="148" cy="126" r="7" fill="#ffd84a"/>
<path d="M102 157h52" stroke="#ff4f78" stroke-width="6"/>
<text x="128" y="220" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="16" font-weight="700">THE ODDS SAID LOL</text>
</svg>

After

Width:  |  Height:  |  Size: 591 B

@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="#0c1120"/>
<rect x="48" y="54" width="160" height="72" fill="#151b2b" stroke="#ff4f78" stroke-width="5"/>
<g>
<animateTransform attributeName="transform" type="translate" values="0 -22;0 28;0 -22" dur="1s" repeatCount="indefinite"/>
<rect x="76" y="126" width="104" height="42" fill="#6cff8c" stroke="#0a0d17" stroke-width="4"/>
<text x="128" y="153" text-anchor="middle" fill="#0a0d17" font-family="monospace" font-size="19" font-weight="700">FIAT</text>
</g>
<text x="128" y="101" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="24" font-weight="700">BRRR</text>
<text x="128" y="222" text-anchor="middle" fill="#ff3df0" font-family="monospace" font-size="15" font-weight="700">INFINITE PATCH</text>
</svg>

After

Width:  |  Height:  |  Size: 856 B

+95
View File
@@ -0,0 +1,95 @@
const CACHE_VERSION = "gashboard-pwa-v4";
const APP_SHELL = ["/", "/manifest.webmanifest", "/icons/icon.svg", "/icons/maskable.svg"];
const MINER_ASSETS = [
"/miners/nerdqaxe.svg",
"/miners/bitaxe.svg",
"/miners/bigpapa-bitaxe.svg",
"/miners/avalon-nano-3.svg",
"/miners/avalon-mini-3.svg",
"/miners/boomer-heater.svg",
];
const STICKER_ASSETS = [
"/stickers/anon-miner.svg",
"/stickers/block-denied.svg",
"/stickers/block-hopium.svg",
"/stickers/boomer-unit.svg",
"/stickers/chad-hash.svg",
"/stickers/chart-crime.svg",
"/stickers/fan-panic.svg",
"/stickers/fiat-npc.svg",
"/stickers/heat-death.svg",
"/stickers/money-printer.svg",
"/stickers/odds-wizard.svg",
"/stickers/printer-loop.svg",
];
self.addEventListener("install", (event) => {
event.waitUntil(caches.open(CACHE_VERSION).then((cache) => cache.addAll([...APP_SHELL, ...MINER_ASSETS, ...STICKER_ASSETS])));
self.skipWaiting();
});
self.addEventListener("activate", (event) => {
event.waitUntil(
caches
.keys()
.then((keys) => Promise.all(keys.filter((key) => key !== CACHE_VERSION).map((key) => caches.delete(key))))
.then(() => self.clients.claim()),
);
});
self.addEventListener("fetch", (event) => {
const req = event.request;
if (req.method !== "GET") return;
const url = new URL(req.url);
if (url.origin !== self.location.origin) return;
if (url.pathname === "/nostr-provider.js" || url.pathname === "/nostr-signer") return;
if (url.pathname.startsWith("/api/") || url.pathname === "/healthz") return;
if (req.mode === "navigate") {
event.respondWith(networkFirst(req, "/"));
return;
}
if (
url.pathname.startsWith("/assets/")
|| url.pathname.startsWith("/icons/")
|| url.pathname.startsWith("/miners/")
|| url.pathname.startsWith("/stickers/")
) {
event.respondWith(cacheFirst(req));
return;
}
event.respondWith(networkFirst(req));
});
self.addEventListener("message", (event) => {
if (event.data?.type === "SKIP_WAITING") self.skipWaiting();
});
async function cacheFirst(req) {
const cache = await caches.open(CACHE_VERSION);
const cached = await cache.match(req);
if (cached) return cached;
const res = await fetch(req);
if (res.ok) cache.put(req, res.clone());
return res;
}
async function networkFirst(req, fallbackPath) {
const cache = await caches.open(CACHE_VERSION);
try {
const res = await fetch(req);
if (res.ok) cache.put(req, res.clone());
return res;
} catch {
const cached = await cache.match(req);
if (cached) return cached;
if (fallbackPath) {
const fallback = await cache.match(fallbackPath);
if (fallback) return fallback;
}
throw new Error("offline");
}
}