@things-factory/shell 6.1.0 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
|
|
1
|
-
import { setCacheNameDetails } from 'workbox-core'
|
1
|
+
import { setCacheNameDetails, cacheNames } from 'workbox-core'
|
2
|
+
|
2
3
|
import * as navigationPreload from 'workbox-navigation-preload'
|
3
4
|
import { registerRoute, NavigationRoute } from 'workbox-routing'
|
4
5
|
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching'
|
@@ -33,7 +34,23 @@ addEventListener('install', async event => {
|
|
33
34
|
|
34
35
|
navigationPreload.enable()
|
35
36
|
|
36
|
-
addEventListener('activate',
|
37
|
+
addEventListener('activate', event => {
|
38
|
+
const cacheNamesToKeep = [...Object.values(cacheNames), 'google-fonts']
|
39
|
+
|
40
|
+
event.waitUntil(
|
41
|
+
(async function () {
|
42
|
+
const userCacheNames = await caches.keys()
|
43
|
+
await Promise.all(
|
44
|
+
userCacheNames.map(async cacheName => {
|
45
|
+
if (!cacheNamesToKeep.includes(cacheName)) {
|
46
|
+
return await caches.delete(cacheName)
|
47
|
+
}
|
48
|
+
return await Promise.resolve()
|
49
|
+
})
|
50
|
+
)
|
51
|
+
})()
|
52
|
+
)
|
53
|
+
|
37
54
|
channel.postMessage({
|
38
55
|
type: 'show-reload-snackbar'
|
39
56
|
})
|