forked from jsnbuchanan/crowd-funder-for-time-pwa
Update worker dependencies
This commit is contained in:
@@ -1,33 +1,63 @@
|
|||||||
const notifications = require("./safari-notifications.js");
|
/* eslint-env serviceworker */
|
||||||
|
/* global workbox */
|
||||||
|
importScripts(
|
||||||
|
"https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js",
|
||||||
|
);
|
||||||
|
|
||||||
|
self.addEventListener("install", (event) => {
|
||||||
|
importScripts(
|
||||||
|
"safari-notifications.js",
|
||||||
|
"nacl.js",
|
||||||
|
"noble-curves.js",
|
||||||
|
"noble-hashes.js",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
self.addEventListener("push", function (event) {
|
self.addEventListener("push", function (event) {
|
||||||
|
event.waitUntil(
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
let payload;
|
let payload;
|
||||||
if (event.data) {
|
if (event.data) {
|
||||||
payload = JSON.parse(event.data.text());
|
payload = JSON.parse(event.data.text());
|
||||||
}
|
}
|
||||||
|
const message = await self.getNotificationCount();
|
||||||
const title = payload ? payload.title : "Custom Title";
|
const title = payload ? payload.title : "Custom Title";
|
||||||
const options = {
|
const options = {
|
||||||
body: payload ? payload.body : "Custom body text",
|
body: message,
|
||||||
icon: payload ? payload.icon : "icon.png",
|
icon: payload ? payload.icon : "icon.png",
|
||||||
badge: payload ? payload.badge : "badge.png",
|
badge: payload ? payload.badge : "badge.png",
|
||||||
};
|
};
|
||||||
|
await self.registration.showNotification(title, options);
|
||||||
event.waitUntil(self.registration.showNotification(title, options));
|
} catch (error) {
|
||||||
|
console.error("Error in processing the push event:", error);
|
||||||
|
}
|
||||||
|
})(),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.addEventListener("message", (event) => {
|
||||||
self.addEventListener("message", function (event) {
|
if (event.data && event.data.type === "SEND_LOCAL_DATA") {
|
||||||
const data = event.data;
|
self.secret = event.data.data;
|
||||||
|
event.ports[0].postMessage({ success: true });
|
||||||
const result = notifications.getNotificationCount()
|
|
||||||
|
|
||||||
switch (data.command) {
|
|
||||||
case "account":
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
console.log("Unknown command:", data.command);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.addEventListener("activate", (event) => {
|
||||||
|
event.waitUntil(clients.claim());
|
||||||
|
console.log("Service worker activated", event);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener("fetch", (event) => {
|
||||||
|
console.log(event.request);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener("error", (event) => {
|
||||||
|
console.error("Error in Service Worker:", event.message);
|
||||||
|
console.error("File:", event.filename);
|
||||||
|
console.error("Line:", event.lineno);
|
||||||
|
console.error("Column:", event.colno);
|
||||||
|
console.error("Error Object:", event.error);
|
||||||
|
});
|
||||||
|
|
||||||
|
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
|
||||||
|
|||||||
1051
sw_scripts/nacl.js
Normal file
1051
sw_scripts/nacl.js
Normal file
File diff suppressed because it is too large
Load Diff
5248
sw_scripts/noble-curves.js
Normal file
5248
sw_scripts/noble-curves.js
Normal file
File diff suppressed because it is too large
Load Diff
3068
sw_scripts/noble-hashes.js
Normal file
3068
sw_scripts/noble-hashes.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user