keet-streaming / index.html
ysdede's picture
fix(hf-space): harden runtime loading and cache behavior
8a16cdb
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; connect-src 'self' blob: https://huggingface.co https://*.huggingface.co https://*.hf.co https://fonts.googleapis.com https://fonts.gstatic.com; font-src 'self' https://fonts.gstatic.com; frame-src 'self'; img-src 'self' data:; object-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; worker-src 'self' blob:;" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Keet - Privacy-first real-time transcription. Your audio stays on your device." />
<meta name="theme-color" content="#6B705C" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>Keet - Real-time Transcription</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;1,400&family=Plus+Jakarta+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap"
rel="stylesheet" />
<!-- PWA Manifest -->
<link rel="manifest" href="./manifest.json" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
<script>
const isLocalDevHost = location.hostname === 'localhost' || location.hostname === '127.0.0.1';
const isHfSpace = location.hostname.endsWith('.hf.space');
if ('serviceWorker' in navigator && !isLocalDevHost) {
window.addEventListener('load', () => {
if (isHfSpace) {
navigator.serviceWorker.getRegistrations()
.then((regs) => Promise.all(regs.map((reg) => reg.unregister())))
.then(() => {
if (!('caches' in window)) return;
return caches.keys()
.then((keys) => Promise.all(keys.map((k) => caches.delete(k))));
})
.then(() => console.log('[App] SW disabled on HF Space (all caches cleared to avoid stale chunks).'))
.catch((err) => console.warn('[App] SW cleanup on HF failed:', err));
return;
}
navigator.serviceWorker.register('./sw.js')
.then((reg) => console.log('[App] SW registered:', reg.scope))
.catch((err) => console.warn('[App] SW registration failed:', err));
});
}
</script>
</body>
</html>