shellphone.app/app/entry.worker.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

/// <reference lib="WebWorker" />
2022-06-01 21:56:37 +00:00
import handleInstall from "./service-worker/install";
import handleActivate from "./service-worker/activate";
import handlePush from "./service-worker/push";
import handleNotificationClick from "./service-worker/notification-click";
import handleFetch from "./service-worker/fetch";
2022-06-05 22:01:33 +00:00
import handleMessage from "./service-worker/message";
declare let self: ServiceWorkerGlobalScope;
2022-06-01 21:56:37 +00:00
self.addEventListener("install", (event) => {
event.waitUntil(handleInstall(event).then(() => self.skipWaiting()));
});
self.addEventListener("activate", (event) => {
event.waitUntil(handleActivate(event).then(() => self.clients.claim()));
});
self.addEventListener("push", (event) => {
2022-06-01 21:56:37 +00:00
event.waitUntil(handlePush(event));
});
self.addEventListener("notificationclick", (event) => {
2022-06-01 21:56:37 +00:00
event.waitUntil(handleNotificationClick(event));
});
2022-06-05 22:01:33 +00:00
self.addEventListener("message", (event) => {
event.waitUntil(handleMessage(event));
});
2022-06-01 21:56:37 +00:00
self.addEventListener("fetch", (event) => {
event.respondWith(handleFetch(event));
});