Skip to content

Commit 0cc7673

Browse files
committed
feat: add PWA manifest and service worker for Add to Home Screen support
1 parent ff36504 commit 0cc7673

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

client/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<title>Instbyte</title>
66
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-dynamic.png">
77
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-dynamic.png">
8+
<link rel="manifest" href="/manifest.json">
9+
<meta name="theme-color" id="themeColorMeta" content="#111827">
810
<meta name="viewport" content="width=device-width,initial-scale=1">
911

1012
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
@@ -89,7 +91,11 @@
8991
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
9092
<script src="/js/app.js?v=1.9.1.2"></script>
9193

92-
94+
<script>
95+
if ('serviceWorker' in navigator) {
96+
navigator.serviceWorker.register('/sw.js').catch(() => { });
97+
}
98+
</script>
9399
</body>
94100

95101
</html>

client/js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ async function applyBranding() {
116116
root.style.setProperty("--color-secondary-light", p.secondaryLight);
117117
root.style.setProperty("--color-on-secondary", p.onSecondary);
118118

119+
const themeMeta = document.getElementById('themeColorMeta');
120+
if (themeMeta) themeMeta.setAttribute('content', p.primary);
121+
119122
} catch (e) {
120123
// Branding failed — default styles remain, no crash
121124
}

client/sw.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// sw.js — Instbyte service worker
2+
// Minimal install-only service worker.
3+
// We do not cache anything — Instbyte is a real-time LAN tool and must
4+
// always fetch live data. This file exists solely to satisfy the PWA
5+
// installability requirement.
6+
7+
self.addEventListener('install', () => self.skipWaiting());
8+
self.addEventListener('activate', e => e.waitUntil(self.clients.claim()));
9+
10+
// No fetch handler — all requests go straight to the network as normal.

server/server.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,37 @@ app.get("/branding", (req, res) => {
772772
});
773773
});
774774

775+
/* PWA MANIFEST */
776+
app.get("/manifest.json", (req, res) => {
777+
const b = config.branding;
778+
const name = b.appName || "Instbyte";
779+
const color = b.primaryColor || "#111827";
780+
781+
res.json({
782+
name,
783+
short_name: name.length > 12 ? name.slice(0, 12) : name,
784+
description: "Real-time LAN sharing — no cloud, no accounts",
785+
start_url: "/",
786+
display: "standalone",
787+
background_color: "#f3f4f6",
788+
theme_color: color,
789+
icons: [
790+
{
791+
src: "/logo-dynamic.png",
792+
sizes: "192x192",
793+
type: "image/png",
794+
purpose: "any maskable"
795+
},
796+
{
797+
src: "/logo-dynamic.png",
798+
sizes: "512x512",
799+
type: "image/png",
800+
purpose: "any maskable"
801+
}
802+
]
803+
});
804+
});
805+
775806
/* HEALTH MONITOR */
776807
app.get("/health", (req, res) => {
777808
res.json({

0 commit comments

Comments
 (0)