Sessions 5-7a: 955 tests, deployment ready

This commit is contained in:
Kev
2026-06-08 18:35:13 -04:00
parent 06b82624a2
commit 1fa04dc776
371 changed files with 49366 additions and 955 deletions
+52
View File
@@ -0,0 +1,52 @@
/// <reference lib="webworker" />
/// <reference types="@serwist/next/typings" />
import { defaultCache } from '@serwist/next/worker';
import { Serwist } from 'serwist';
declare const self: ServiceWorkerGlobalScope & {
__SW_MANIFEST: (string | { url: string; revision: string | null })[];
};
const serwist = new Serwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
});
serwist.addEventListeners();
// Web Push handler — fires when the push service delivers a notification.
// Pushes are emitted server-side by src/services/distribution/webPush.js.
self.addEventListener('push', (event) => {
if (!event.data) return;
let payload: { title?: string; body?: string; icon?: string; url?: string };
try {
payload = event.data.json();
} catch {
payload = { title: 'VYNDR', body: event.data.text() };
}
const { title = 'VYNDR', body = '', icon = '/icons/icon-192.png', url = '/' } = payload;
event.waitUntil(
self.registration.showNotification(title, {
body,
icon,
badge: '/icons/icon-192.png',
data: { url },
})
);
});
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const url = (event.notification.data as { url?: string } | undefined)?.url ?? '/';
event.waitUntil(
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
const existing = clients.find((c) => c.url.endsWith(url));
if (existing) return existing.focus();
return self.clients.openWindow(url);
})
);
});