hexo-swpp 1.3.5 → 1.4.1
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.
- package/README.md +1 -1
- package/index.js +4 -2
- package/package.json +1 -1
- package/sw-dom.js +2 -2
- package/sw-template.js +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -38,13 +38,15 @@ if (pluginConfig?.enable) {
|
|
|
38
38
|
const absPath = module.path + '/sw-template.js'
|
|
39
39
|
const rootPath = nodePath.resolve('./')
|
|
40
40
|
const relativePath = nodePath.relative(rootPath, absPath)
|
|
41
|
-
const template = fs.readFileSync(relativePath, 'utf8')
|
|
42
41
|
const cache = fs.readFileSync('sw-cache.js', 'utf8')
|
|
43
42
|
.replaceAll('module.exports.cacheList', 'const cacheList')
|
|
44
43
|
.replaceAll('module.exports.replaceList', 'const replaceList')
|
|
44
|
+
const swContent = fs.readFileSync(relativePath, 'utf8')
|
|
45
|
+
.replaceAll('const { cacheList, replaceList } = require(\'../sw-cache\')', cache)
|
|
46
|
+
.replaceAll("'@$$[escape]'", (pluginConfig.escape ?? 0).toString())
|
|
45
47
|
return {
|
|
46
48
|
path: 'sw.js',
|
|
47
|
-
data:
|
|
49
|
+
data: swContent
|
|
48
50
|
}
|
|
49
51
|
})
|
|
50
52
|
|
package/package.json
CHANGED
package/sw-dom.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
if (sessionStorage.getItem('updated')) {
|
|
36
36
|
// ${onSuccess}
|
|
37
37
|
sessionStorage.removeItem('updated')
|
|
38
|
-
} else
|
|
38
|
+
} else postMessage2SW('update')
|
|
39
39
|
navigator.serviceWorker.addEventListener('message', event => {
|
|
40
40
|
const data = event.data
|
|
41
41
|
switch (data.type) {
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
break
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
|
-
})
|
|
68
|
+
})()
|
package/sw-template.js
CHANGED
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
dbVersion.write(JSON.stringify(newVersion))
|
|
172
172
|
return resolve(newVersion)
|
|
173
173
|
}
|
|
174
|
-
const refresh = parseChange(list, elementList, oldVersion.local)
|
|
174
|
+
const refresh = oldVersion.local < '@$$[escape]' ? true : parseChange(list, elementList, oldVersion.local)
|
|
175
175
|
dbVersion.write(JSON.stringify(newVersion))
|
|
176
176
|
//如果需要清理全站
|
|
177
177
|
if (refresh) {
|