fix: catch undefined registrationHooks callbacks

This commit is contained in:
Ayo Ayco 2024-08-18 12:11:23 +02:00
parent dbcc8e4541
commit f5f4203c6e
2 changed files with 7 additions and 7 deletions

View file

@ -28,7 +28,6 @@ export default defineConfig({
waiting: () => console.log('>>> waiting...'),
active: () => console.log('>>> active...'),
error: (error) => console.error('>>> error', error),
unsupported: () => console.log('>>> service worker unsupported'),
afterRegistration: async () => {
const sw = await navigator.serviceWorker.getRegistration();
console.log('>>> registrered', sw)

View file

@ -1,3 +1,4 @@
// @ts-check
/**
* @license MIT <https://opensource.org/licenses/MIT>
* @author Ayo Ayco <https://ayo.ayco.io>
@ -50,12 +51,12 @@ export default function serviceWorker(options) {
} = options || {};
const {
installing: installingFn,
waiting: waitingFn,
active: activeFn,
error: errorFn,
unsupported: unsupportedFn,
afterRegistration: afterRegistrationFn,
installing: installingFn = () => {},
waiting: waitingFn = () => {},
active: activeFn = () => {},
error: errorFn = () => {},
unsupported: unsupportedFn = () => {},
afterRegistration: afterRegistrationFn = () => {},
} = registrationHooks;
/**