feat: rename js files to ts
This commit is contained in:
parent
4cff3ebee1
commit
15b67136fe
114 changed files with 0 additions and 0 deletions
59
src/sw.ts
Normal file
59
src/sw.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* eslint-disable no-console */
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
const workboxVersion = 'v6.5.2'
|
||||
importScripts( `/workbox-${workboxVersion}/workbox-sw.js`)
|
||||
workbox.setConfig({
|
||||
modulePathPrefix: `/workbox-${workboxVersion}`,
|
||||
debug: Boolean(import.meta.env.VITE_WORKBOX_DEBUG),
|
||||
})
|
||||
|
||||
import { precacheAndRoute } from 'workbox-precaching'
|
||||
precacheAndRoute(self.__WB_MANIFEST)
|
||||
|
||||
// Cache assets
|
||||
workbox.routing.registerRoute(
|
||||
// This regexp matches all files in precache-manifest
|
||||
new RegExp('.+\\.(css|json|js|svg|woff2|png|html|txt|wav)$'),
|
||||
new workbox.strategies.StaleWhileRevalidate(),
|
||||
)
|
||||
|
||||
// Always send api reqeusts through the network
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp('api\\/v1\\/.*$'),
|
||||
new workbox.strategies.NetworkOnly(),
|
||||
)
|
||||
|
||||
// This code listens for the user's confirmation to update the app.
|
||||
self.addEventListener('message', (e) => {
|
||||
if (!e.data) {
|
||||
return
|
||||
}
|
||||
|
||||
switch (e.data) {
|
||||
case 'skipWaiting':
|
||||
self.skipWaiting()
|
||||
break
|
||||
default:
|
||||
// NOOP
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
// Notification action
|
||||
self.addEventListener('notificationclick', function (event) {
|
||||
const taskId = event.notification.data.taskId
|
||||
event.notification.close()
|
||||
|
||||
switch (event.action) {
|
||||
case 'show-task':
|
||||
clients.openWindow(`/tasks/${taskId}`)
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
workbox.core.clientsClaim()
|
||||
// The precaching code provided by Workbox.
|
||||
self.__precacheManifest = [].concat(self.__precacheManifest || [])
|
||||
workbox.precaching.precacheAndRoute(self.__precacheManifest, {})
|
||||
|
||||
Reference in a new issue