swpp-backends 2.3.7 → 2.3.9

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.
@@ -20,8 +20,13 @@ function buildDomJs() {
20
20
  throw '功能未开启';
21
21
  }
22
22
  let template = fs_1.default.readFileSync(path_1.default.resolve('./', module.path, 'resources/sw-dom.js'), 'utf-8');
23
- if (config.onsuccess)
24
- template = template.replaceAll('const {onSuccess} = require(\'../config\')', `const onSuccess = ${config.onsuccess.toString()};`);
23
+ const key = 'const {onSuccess} = require(\'../config\')';
24
+ if (config.onsuccess) {
25
+ template = template.replaceAll(key, `const onSuccess = ${config.onsuccess.toString()};`);
26
+ }
27
+ else {
28
+ template = template.replaceAll(key, '');
29
+ }
25
30
  return template;
26
31
  }
27
32
  exports.buildDomJs = buildDomJs;
@@ -32,7 +32,7 @@ function buildServiceWorker() {
32
32
  let fetchFileReplaced;
33
33
  if (!fetchFile) {
34
34
  const { JS_CODE_GET_CDN_LIST, JS_CODE_GET_SPARE_URLS, JS_CODE_DEF_FETCH_FILE } = require('./resources/sw-fetch.js');
35
- let selected, replaced;
35
+ let selected;
36
36
  if (getRaceUrls) {
37
37
  selected = JS_CODE_GET_CDN_LIST;
38
38
  fetchFileReplaced = 'getRaceUrls(request.url)';
package/dist/SwppRules.js CHANGED
@@ -54,7 +54,7 @@ function mergeConfig(dist, that) {
54
54
  for (let key in that) {
55
55
  const distValue = dist[key];
56
56
  const thatValue = that[key];
57
- if (!thatValue)
57
+ if (thatValue === undefined || thatValue === null)
58
58
  continue;
59
59
  switch (typeof distValue) {
60
60
  case "undefined":
@@ -7,11 +7,10 @@ module.exports.JS_CODE_GET_CDN_LIST= 'const fetchFile = ' + (
7
7
  (request, banCache, urls) => {
8
8
  if (!urls) {
9
9
  urls = getRaceUrls(request.url)
10
- if (!urls) return fetchWithCors(request, banCache)
11
10
  }
12
11
  if (!urls || !Promise.any) return fetchWithCors(request, banCache)
13
12
  const res = urls.map(url => new Request(url, request))
14
- const controllers = []
13
+ const controllers = new Array(res.length)
15
14
  // noinspection JSCheckFunctionSignatures
16
15
  return Promise.any(
17
16
  res.map((it, index) => fetchWithCors(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swpp-backends",
3
- "version": "2.3.7",
3
+ "version": "2.3.9",
4
4
  "main": "dist/index.js",
5
5
  "typings": "types/index.d.ts",
6
6
  "description": "Generate a powerful ServiceWorker for your website.",