mirror of
https://git.tuxpa.in/a/code-server.git
synced 2025-01-06 16:58:44 +00:00
25 lines
536 B
TypeScript
25 lines
536 B
TypeScript
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
|
|
||
|
self.addEventListener("install", () => {
|
||
|
console.log("[Service Worker] install")
|
||
|
})
|
||
|
|
||
|
self.addEventListener("activate", (event: any) => {
|
||
|
event.waitUntil((self as any).clients.claim())
|
||
|
})
|
||
|
|
||
|
self.addEventListener("fetch", (event: any) => {
|
||
|
if (!navigator.onLine) {
|
||
|
event.respondWith(
|
||
|
new Promise((resolve) => {
|
||
|
resolve(
|
||
|
new Response("OFFLINE", {
|
||
|
status: 200,
|
||
|
statusText: "OK",
|
||
|
}),
|
||
|
)
|
||
|
}),
|
||
|
)
|
||
|
}
|
||
|
})
|