Browse Source

Add service worker

main
GreatBearShark 2 years ago
parent
commit
26c734b296
  1. 1
      package.json
  2. 28
      src/service-worker.ts
  3. 5
      yarn.lock

1
package.json

@ -46,6 +46,7 @@
"psl": "^1.8.0",
"qs": "^6.9.4",
"reconnecting-websocket": "^4.4.0",
"register-service-worker": "^1.7.1",
"rxjs": "^6.5.5",
"terser": "^4.6.11",
"tippy.js": "^6.1.1",

28
src/service-worker.ts

@ -0,0 +1,28 @@
import { register } from 'register-service-worker';
register('/service-worker.js', {
registrationOptions: { scope: './' },
ready(registration) {
console.log('Service worker is active.');
},
registered(registration) {
console.log('Service worker has been registered.');
},
cached(registration) {
console.log('Content has been cached for offline use.');
},
updatefound(registration) {
console.log('New content is downloading.');
},
updated(registration) {
console.log('New content is available; please refresh.');
},
offline() {
console.log(
'No internet connection found. App is running in offline mode.'
);
},
error(error) {
console.error('Error during service worker registration:', error);
},
});

5
yarn.lock

@ -5999,6 +5999,11 @@ [email protected]^4.1.3:
unicode-match-property-ecmascript "^1.0.4"
unicode-match-property-value-ecmascript "^1.1.0"
[email protected]^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/register-service-worker/-/register-service-worker-1.7.1.tgz#6308347ac6c0af0f6c0b22ea5d59d25e836bc932"
integrity sha512-IdTfUZ4u8iJL8o1w8es8l6UMGPmkwHolUdT+UmM1UypC80IB4KbpuIlvwWVj8UDS7eJwkEYRcKRgfRX+oTmJsw==
[email protected]^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.1.tgz#48f0bf1a5ea205196929c0d9798b42d1ed98443c"

Loading…
Cancel
Save