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...'), waiting: () => console.log('>>> waiting...'),
active: () => console.log('>>> active...'), active: () => console.log('>>> active...'),
error: (error) => console.error('>>> error', error), error: (error) => console.error('>>> error', error),
unsupported: () => console.log('>>> service worker unsupported'),
afterRegistration: async () => { afterRegistration: async () => {
const sw = await navigator.serviceWorker.getRegistration(); const sw = await navigator.serviceWorker.getRegistration();
console.log('>>> registrered', sw) console.log('>>> registrered', sw)

View file

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