const cacheName = "app-" + "08848207254ed19206a7e0901b6c869dca9004c8"; const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/docs.css","/web/css/prism.css","/web/documents/home-next.md","/web/documents/home.md","/web/documents/updates.md","/web/documents/what-is-go-app.md","/web/icon.png","/web/js/prism.js","https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500\u0026display=swap","https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1013306768105236"]; self.addEventListener("install", (event) => { console.log("installing app worker 08848207254ed19206a7e0901b6c869dca9004c8"); event.waitUntil( caches .open(cacheName) .then((cache) => { return cache.addAll(resourcesToCache); }) .then(() => { self.skipWaiting(); }) ); }); self.addEventListener("activate", (event) => { event.waitUntil( caches.keys().then((keyList) => { return Promise.all( keyList.map((key) => { if (key !== cacheName) { return caches.delete(key); } }) ); }) ); console.log("app worker 08848207254ed19206a7e0901b6c869dca9004c8 is activated"); }); self.addEventListener("fetch", (event) => { event.respondWith( caches.match(event.request).then((response) => { return response || fetch(event.request); }) ); }); self.addEventListener("push", (event) => { if (!event.data || !event.data.text()) { return; } const notification = JSON.parse(event.data.text()); if (!notification) { return; } const title = notification.title; delete notification.title; if (!notification.data) { notification.data = {}; } let actions = []; for (let i in notification.actions) { const action = notification.actions[i]; actions.push({ action: action.action, path: action.path, }); delete action.path; } notification.data.goapp = { path: notification.path, actions: actions, }; delete notification.path; event.waitUntil(self.registration.showNotification(title, notification)); }); self.addEventListener("notificationclick", (event) => { event.notification.close(); const notification = event.notification; let path = notification.data.goapp.path; for (let i in notification.data.goapp.actions) { const action = notification.data.goapp.actions[i]; if (action.action === event.action) { path = action.path; break; } } event.waitUntil( clients .matchAll({ type: "window", }) .then((clientList) => { for (var i = 0; i < clientList.length; i++) { let client = clientList[i]; if ("focus" in client) { client.focus(); client.postMessage({ goapp: { type: "notification", path: path, }, }); return; } } if (clients.openWindow) { return clients.openWindow(path); } }) ); });