Skip to content

Commit a304cc4

Browse files
committed
1 parent e8adda8 commit a304cc4

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Diff for: lib/app/SWUpdateEvent.js

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export default class SWUpdateEvent {
77
})
88
}
99

10+
/**
11+
* Check if the new service worker exists or not.
12+
*/
13+
update () {
14+
return this.registration.update()
15+
}
16+
1017
/**
1118
* Activate new service worker to work 'location.reload()' with new data.
1219
*/

Diff for: lib/app/clientEntry.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@ router.onReady(() => {
4242
console.log('[vuepress:sw] Service worker is active.')
4343
app.$refs.layout.$emit('sw-ready')
4444
},
45-
cached () {
45+
cached (registration) {
4646
console.log('[vuepress:sw] Content has been cached for offline use.')
47-
app.$refs.layout.$emit('sw-cached')
47+
app.$refs.layout.$emit('sw-cached', new SWUpdateEvent(registration))
4848
},
49-
updated () {
49+
updated (registration) {
5050
console.log('[vuepress:sw] Content updated.')
51-
52-
navigator.serviceWorker.getRegistration().then(registration => {
53-
app.$refs.layout.$emit('sw-updated', new SWUpdateEvent(registration))
54-
})
51+
app.$refs.layout.$emit('sw-updated', new SWUpdateEvent(registration))
5552
},
5653
offline () {
5754
console.log('[vuepress:sw] No internet connection found. App is running in offline mode.')

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"portfinder": "^1.0.13",
7676
"postcss-loader": "^2.1.5",
7777
"prismjs": "^1.13.0",
78-
"register-service-worker": "^1.2.0",
78+
"register-service-worker": "^1.3.0",
7979
"semver": "^5.5.0",
8080
"stylus": "^0.54.5",
8181
"stylus-loader": "^3.0.2",

Diff for: yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -7022,7 +7022,7 @@ regexpu-core@^4.1.3, regexpu-core@^4.1.4:
70227022
unicode-match-property-ecmascript "^1.0.3"
70237023
unicode-match-property-value-ecmascript "^1.0.1"
70247024

7025-
register-service-worker@^1.2.0:
7025+
register-service-worker@^1.3.0:
70267026
version "1.3.0"
70277027
resolved "https://registry.yarnpkg.com/register-service-worker/-/register-service-worker-1.3.0.tgz#02a0b7c40413b3c5ed1d801d764deb3aab1c3397"
70287028

0 commit comments

Comments
 (0)