swpp-backends 2.3.1 → 2.3.3
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/DomBuilder.js +1 -1
- package/dist/index.js +1 -1
- package/dist/resources/sw-dom.js +17 -16
- package/dist/resources/sw-template.js +8 -5
- package/package.json +1 -1
package/dist/DomBuilder.js
CHANGED
|
@@ -21,7 +21,7 @@ function buildDomJs() {
|
|
|
21
21
|
}
|
|
22
22
|
let template = fs_1.default.readFileSync(path_1.default.resolve('./', module.path, 'resources/sw-dom.js'), 'utf-8');
|
|
23
23
|
if (config.onsuccess)
|
|
24
|
-
template = template.replaceAll('
|
|
24
|
+
template = template.replaceAll('const {onSuccess} = require(\'../config\')', `const onSuccess = ${config.onsuccess.toString()};`);
|
|
25
25
|
return template;
|
|
26
26
|
}
|
|
27
27
|
exports.buildDomJs = buildDomJs;
|
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.3.
|
|
13
|
+
version: '2.3.3',
|
|
14
14
|
cache: {
|
|
15
15
|
readEjectData: Utils_1.readEjectData, readUpdateJson: Variant_1.readUpdateJson,
|
|
16
16
|
readRules: Variant_1.readRules, readMergeVersionMap: Variant_1.readMergeVersionMap,
|
package/dist/resources/sw-dom.js
CHANGED
|
@@ -19,26 +19,27 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
const SESSION_KEY = 'updated'
|
|
22
|
+
// noinspection JSFileReferences
|
|
23
|
+
const {onSuccess} = require('../config')
|
|
22
24
|
if (sessionStorage.getItem(SESSION_KEY)) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
onSuccess()
|
|
26
|
+
sessionStorage.removeItem(SESSION_KEY)
|
|
25
27
|
} else postMessage2SW('update')
|
|
26
28
|
navigator.serviceWorker.addEventListener('message', event => {
|
|
27
|
-
sessionStorage.setItem(SESSION_KEY, '1')
|
|
28
29
|
const data = event.data
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
sessionStorage.setItem(SESSION_KEY, data.type)
|
|
31
|
+
const list = data.list?.filter(url => /\.(js|css)$/.test(url))
|
|
32
|
+
if (list) {
|
|
33
|
+
// noinspection JSUnresolvedReference
|
|
34
|
+
if (window.Pjax?.isSupported?.())
|
|
35
|
+
list.forEach(pjaxUpdate)
|
|
36
|
+
location.reload()
|
|
37
|
+
} else {
|
|
38
|
+
const newVersion = data.new, oldVersion = data.old
|
|
39
|
+
if (oldVersion && (newVersion.global !== oldVersion.global || newVersion.local !== oldVersion.local)) {
|
|
40
|
+
onSuccess()
|
|
41
|
+
}
|
|
42
|
+
sessionStorage.removeItem(SESSION_KEY)
|
|
42
43
|
}
|
|
43
44
|
})
|
|
44
45
|
})
|
|
@@ -28,13 +28,16 @@
|
|
|
28
28
|
readVersion().then(async oldVersion => {
|
|
29
29
|
// noinspection JSIncompatibleTypesComparison
|
|
30
30
|
if (oldVersion && oldVersion.escape !== escape) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const list = await caches.open(CACHE_NAME)
|
|
32
|
+
.then(cache => cache.keys())
|
|
33
|
+
.then(keys => keys?.map(it => it.url))
|
|
33
34
|
await caches.delete(CACHE_NAME)
|
|
34
|
-
await
|
|
35
|
+
const info = await updateJson()
|
|
36
|
+
info.type = 'escape'
|
|
37
|
+
info.list = list
|
|
35
38
|
// noinspection JSUnresolvedReference
|
|
36
|
-
const
|
|
37
|
-
|
|
39
|
+
const clientList = await clients.matchAll()
|
|
40
|
+
clientList.forEach(client => client.postMessage(info))
|
|
38
41
|
}
|
|
39
42
|
})
|
|
40
43
|
}
|