hexo-swpp 2.3.6 → 2.4.0

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.
@@ -167,7 +167,7 @@ module.exports = (hexo, config, pluginConfig, swRules) => {
167
167
  .each((i, it) => handleLink(it))
168
168
  const relList = ['stylesheet', 'manifest', 'icon', 'shortcut icon', 'mask-icon']
169
169
  for (let value of relList) {
170
- html(`link[href][rel=${value}]`)
170
+ html(`link[href][rel='${value}']`)
171
171
  .map((i, ele) => html(ele).attr('href'))
172
172
  .each((i, it) => handleLink(it))
173
173
  }
@@ -24,8 +24,13 @@
24
24
  .then(keys => Promise.all(
25
25
  keys.map(async it => {
26
26
  const url = it.url
27
- // noinspection ES6MissingAwait,CommaExpressionJS
28
- return url !== CTRL_PATH && list.match(url) ? (cache.delete(it), url) : null
27
+ if (url !== CTRL_PATH && list.match(url)) {
28
+ // [debug delete]
29
+ // noinspection ES6MissingAwait
30
+ cache.delete(it)
31
+ return url
32
+ }
33
+ return null
29
34
  })
30
35
  )).then(list => list.filter(it => it))
31
36
  )
@@ -43,6 +48,7 @@
43
48
  if (response.status === 200) {
44
49
  const clone = response.clone()
45
50
  caches.open(CACHE_NAME).then(it => it.put(key, clone))
51
+ // [debug put]
46
52
  }
47
53
  return response
48
54
  })
@@ -55,6 +61,7 @@
55
61
  })
56
62
 
57
63
  self.addEventListener('message', event => {
64
+ // [debug message]
58
65
  if (event.data === 'update') {
59
66
  updateJson().then(info =>
60
67
  // noinspection JSUnresolvedVariable
package/lib/swBuilder.js CHANGED
@@ -120,6 +120,16 @@ module.exports = (hexo, config, pluginConfig, rules) => {
120
120
  return event.respondWith(new Response(null, {status: 208}))
121
121
  `)
122
122
  }
123
+ // noinspection JSUnresolvedVariable
124
+ if (pluginConfig.sw.debug) {
125
+ swContent = swContent.replaceAll('// [debug delete]', `
126
+ console.debug(\`delete cache: \${url}\`)
127
+ `).replaceAll('// [debug put]', `
128
+ console.debug(\`put cache: \${key}\`)
129
+ `).replaceAll('// [debug message]', `
130
+ console.debug(\`receive: \${event.data}\`)
131
+ `)
132
+ }
123
133
  return {
124
134
  path: 'sw.js',
125
135
  data: swContent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-swpp",
3
- "version": "2.3.6",
3
+ "version": "2.4.0",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "hexo-log": "^3.0.0",