- Re-architect VoiceSession into full-bleed studio cockpit with overlay slide-over companion drawer - Eliminate width squishing defect on LiveInsightPanel and add native dark/light theme support - Integrate authentic Google Gemini 3.8 Flash TTS with Fenrir persona and fallback audio pipeline - Implement comprehensive Playwright E2E visual regression suite across Desktop, iPad, and iPhone (21 tests, 45 snapshots) - Migrate core application to Svelte 5 runes (, , ) with reactive stores - Maintain .NET 8 Azure Functions serverless endpoints and clean build hygiene
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
/// <reference lib="webworker" />
|
|
declare const self: ServiceWorkerGlobalScope;
|
|
|
|
import { clientsClaim } from 'workbox-core';
|
|
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
|
|
import { registerRoute } from 'workbox-routing';
|
|
import { StaleWhileRevalidate, CacheFirst, NetworkFirst } from 'workbox-strategies';
|
|
import { ExpirationPlugin } from 'workbox-expiration';
|
|
import { CacheableResponsePlugin } from 'workbox-cacheable-response';
|
|
|
|
// Precache all assets generated by Vite build
|
|
precacheAndRoute(self.__WB_MANIFEST);
|
|
|
|
cleanupOutdatedCaches();
|
|
|
|
// Cache Google Fonts stylesheets
|
|
registerRoute(
|
|
({ url }) => url.origin === 'https://fonts.googleapis.com',
|
|
new StaleWhileRevalidate({
|
|
cacheName: 'google-fonts-stylesheets',
|
|
})
|
|
);
|
|
|
|
// Cache Google Fonts webfont files with 1-year expiration
|
|
registerRoute(
|
|
({ url }) => url.origin === 'https://fonts.gstatic.com',
|
|
new CacheFirst({
|
|
cacheName: 'google-fonts-webfonts',
|
|
plugins: [
|
|
new CacheableResponsePlugin({
|
|
statuses: [0, 200],
|
|
}),
|
|
new ExpirationPlugin({
|
|
maxAgeSeconds: 60 * 60 * 24 * 365,
|
|
maxEntries: 30,
|
|
}),
|
|
],
|
|
})
|
|
);
|
|
|
|
// Cache static images and icons
|
|
registerRoute(
|
|
({ request }) => request.destination === 'image',
|
|
new CacheFirst({
|
|
cacheName: 'images-cache',
|
|
plugins: [
|
|
new CacheableResponsePlugin({
|
|
statuses: [0, 200],
|
|
}),
|
|
new ExpirationPlugin({
|
|
maxEntries: 60,
|
|
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
|
|
}),
|
|
],
|
|
})
|
|
);
|
|
|
|
// Force immediate activation of new SW
|
|
self.addEventListener('install', () => {
|
|
console.log('[SW] Installing Cognitive Clarity PWA Service Worker...');
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', () => {
|
|
console.log('[SW] Activating Cognitive Clarity PWA Service Worker...');
|
|
clientsClaim();
|
|
});
|
|
|
|
// Handle explicit SKIP_WAITING message from client UI
|
|
self.addEventListener('message', (event) => {
|
|
if (event.data?.type === 'SKIP_WAITING') {
|
|
self.skipWaiting();
|
|
}
|
|
});
|