swpp-backends 2.0.6 → 2.0.8

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/dist/index.js CHANGED
@@ -10,7 +10,7 @@ const VersionAnalyzer_1 = require("./VersionAnalyzer");
10
10
  const DomBuilder_1 = require("./DomBuilder");
11
11
  // noinspection JSUnusedGlobalSymbols
12
12
  exports.default = {
13
- version: '2.0.6',
13
+ version: '2.0.8',
14
14
  cache: {
15
15
  readEjectData: Utils_1.readEjectData, readUpdateJson: Variant_1.readUpdateJson,
16
16
  readRules: Variant_1.readRules, readMergeVersionMap: Variant_1.readMergeVersionMap,
@@ -18,15 +18,18 @@
18
18
  self.addEventListener('install', () => {
19
19
  self.skipWaiting()
20
20
  const escape = '@$$[escape]'
21
- dbVersion.read().then(oldVersion => {
22
- if (oldVersion && oldVersion.escape !== escape) {
23
- oldVersion.escape = escape
24
- // noinspection JSUnresolvedVariable
25
- caches.delete(CACHE_NAME)
26
- .then(() => clients.matchAll())
27
- .then(list => list.forEach(client => client.postMessage({type: 'escape'})))
28
- }
29
- })
21
+ if (escape) {
22
+ dbVersion.read().then(oldVersion => {
23
+ if (oldVersion && oldVersion.escape !== escape) {
24
+ oldVersion.escape = escape
25
+ dbVersion.write(oldVersion)
26
+ // noinspection JSUnresolvedVariable
27
+ caches.delete(CACHE_NAME)
28
+ .then(() => clients.matchAll())
29
+ .then(list => list.forEach(client => client.postMessage({type: 'escape'})))
30
+ }
31
+ })
32
+ }
30
33
  })
31
34
 
32
35
  // sw 激活后立即对所有页面生效,而非等待刷新
@@ -136,7 +139,7 @@
136
139
  /** 解析字符串 */
137
140
  const parseJson = json => dbVersion.read().then(oldVersion => {
138
141
  const {info, global} = json
139
- const newVersion = {global, local: info[0].version, escape: oldVersion?.escape}
142
+ const newVersion = {global, local: info[0].version, escape: oldVersion?.escape ?? 0}
140
143
  //新用户不进行更新操作
141
144
  if (!oldVersion) {
142
145
  dbVersion.write(newVersion)
@@ -192,11 +195,12 @@
192
195
  */
193
196
  this.match = url => {
194
197
  if (this.force) return true
195
- else if (this.refresh) return findCache(url).clean
198
+ // noinspection JSValidateTypes
199
+ url = new URL(url)
200
+ if (this.refresh) return findCache(url).clean
196
201
  else {
197
- const obj = new URL(url)
198
202
  for (let it of list) {
199
- if (it.match(obj)) return true
203
+ if (it.match(url)) return true
200
204
  }
201
205
  }
202
206
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swpp-backends",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "main": "dist/index.js",
5
5
  "typings": "types/index.d.ts",
6
6
  "description": "Generate a powerful ServiceWorker for your website.",