swpp-backends 2.0.5 → 2.0.7
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/UpdateJsonBuilder.js +0 -5
- package/dist/index.js +1 -1
- package/dist/resources/sw-template.js +20 -15
- package/package.json +1 -1
|
@@ -272,11 +272,6 @@ function zipJson(json) {
|
|
|
272
272
|
* + **执行该函数前必须调用过 [calcEjectValues]**
|
|
273
273
|
*/
|
|
274
274
|
function getShorthand(url, offset = 0) {
|
|
275
|
-
if (url.endsWith('/')) {
|
|
276
|
-
const startIndex = url.indexOf('//') + 2;
|
|
277
|
-
if (url.indexOf('/', startIndex) === url.length - 1)
|
|
278
|
-
return '/';
|
|
279
|
-
}
|
|
280
275
|
const map = (0, Variant_1.readMergeVersionMap)();
|
|
281
276
|
let collide = new Set();
|
|
282
277
|
for (let mapKey in map) {
|
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.
|
|
13
|
+
version: '2.0.7',
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
oldVersion.escape
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
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)
|
|
@@ -194,8 +197,9 @@
|
|
|
194
197
|
if (this.force) return true
|
|
195
198
|
else if (this.refresh) return findCache(url).clean
|
|
196
199
|
else {
|
|
200
|
+
const obj = new URL(url)
|
|
197
201
|
for (let it of list) {
|
|
198
|
-
if (it.match(
|
|
202
|
+
if (it.match(obj)) return true
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
return false
|
|
@@ -230,13 +234,14 @@
|
|
|
230
234
|
case 'html':
|
|
231
235
|
return url => url.match(/(\/|\.html)$/)
|
|
232
236
|
case 'end':
|
|
233
|
-
return url => forEachValues(value => url.endsWith(value))
|
|
237
|
+
return url => forEachValues(value => url.href.endsWith(value))
|
|
234
238
|
case 'begin':
|
|
235
|
-
return url => forEachValues(value => url.startsWith(value))
|
|
239
|
+
return url => forEachValues(value => url.pathname.startsWith(value))
|
|
236
240
|
case 'str':
|
|
237
|
-
return url => forEachValues(value => url.includes(value))
|
|
241
|
+
return url => forEachValues(value => url.href.includes(value))
|
|
238
242
|
case 'reg':
|
|
239
|
-
|
|
243
|
+
// noinspection JSCheckFunctionSignatures
|
|
244
|
+
return url => forEachValues(value => url.href.match(new RegExp(value, 'i')))
|
|
240
245
|
default: throw `未知表达式:${JSON.stringify(json)}`
|
|
241
246
|
}
|
|
242
247
|
}
|