hexo-swpp 2.7.0-beta.2 → 2.7.0-beta.4
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/lib/configLoader.js +3 -21
- package/lib/jsonBuilder.js +2 -2
- package/lib/swBuilder.js +3 -3
- package/package.json +1 -1
package/lib/configLoader.js
CHANGED
|
@@ -22,11 +22,13 @@ module.exports.load = hexo => {
|
|
|
22
22
|
break
|
|
23
23
|
}
|
|
24
24
|
if (!defA) {
|
|
25
|
-
list.
|
|
25
|
+
list.push(key)
|
|
26
26
|
handle(value, defValue, list)
|
|
27
27
|
list.pop()
|
|
28
28
|
}
|
|
29
29
|
break
|
|
30
|
+
case 'boolean':
|
|
31
|
+
break
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -42,11 +44,6 @@ module.exports.load = hexo => {
|
|
|
42
44
|
const defConfig = {
|
|
43
45
|
// sw 有关配置项
|
|
44
46
|
serviceWorker: {
|
|
45
|
-
/**
|
|
46
|
-
* 是否让插件自动生成 sw,为 false 该分类下所有配置项失效
|
|
47
|
-
* @type boolean
|
|
48
|
-
*/
|
|
49
|
-
enable: true,
|
|
50
47
|
/**
|
|
51
48
|
* 逃生门
|
|
52
49
|
* @type number
|
|
@@ -67,11 +64,6 @@ const defConfig = {
|
|
|
67
64
|
},
|
|
68
65
|
// 与 SW 注册有关的配置项
|
|
69
66
|
register: {
|
|
70
|
-
/**
|
|
71
|
-
* 是否让插件生成注册代码,为 false 时该分类下所有配置项失效
|
|
72
|
-
* @type boolean
|
|
73
|
-
*/
|
|
74
|
-
enable: true,
|
|
75
67
|
/**
|
|
76
68
|
* sw 注册成功时的动作
|
|
77
69
|
* @type ?VoidFunction
|
|
@@ -105,11 +97,6 @@ const defConfig = {
|
|
|
105
97
|
},
|
|
106
98
|
// 与 DOM 端有关的配置项
|
|
107
99
|
dom: {
|
|
108
|
-
/**
|
|
109
|
-
* 是否让插件生成 DOM 端 JS,为 false 是该分类下所有配置项失效
|
|
110
|
-
* @type boolean
|
|
111
|
-
*/
|
|
112
|
-
enable: true,
|
|
113
100
|
/**
|
|
114
101
|
* 版本更新完成后的动作
|
|
115
102
|
* @type VoidFunction
|
|
@@ -173,11 +160,6 @@ const defConfig = {
|
|
|
173
160
|
* @see https://kmar.top/posts/73014407/#c60b3060
|
|
174
161
|
*/
|
|
175
162
|
external: {
|
|
176
|
-
/**
|
|
177
|
-
* 是否启用外部文件的更新
|
|
178
|
-
* @type boolean
|
|
179
|
-
*/
|
|
180
|
-
enable: false,
|
|
181
163
|
/**
|
|
182
164
|
* 拉取网络文件时的超时时间
|
|
183
165
|
* @type number
|
package/lib/jsonBuilder.js
CHANGED
|
@@ -97,7 +97,7 @@ module.exports = (hexo, hexoConfig, swRules) => {
|
|
|
97
97
|
}
|
|
98
98
|
// 外链监控
|
|
99
99
|
const external = config.external
|
|
100
|
-
if (!external
|
|
100
|
+
if (!external) return
|
|
101
101
|
const indexOf = (str, ...chars) => {
|
|
102
102
|
let result = str.length
|
|
103
103
|
chars.forEach(it => {
|
|
@@ -511,7 +511,7 @@ module.exports = (hexo, hexoConfig, swRules) => {
|
|
|
511
511
|
|
|
512
512
|
function replaceDevRequest(url) {
|
|
513
513
|
const external = config.external
|
|
514
|
-
if (!external
|
|
514
|
+
if (!external || !external.replace) return url
|
|
515
515
|
for (let value of external.replace) {
|
|
516
516
|
for (let source of value.source) {
|
|
517
517
|
if (url.match(source)) {
|
package/lib/swBuilder.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = (hexo, hexoConfig, rules) => {
|
|
|
16
16
|
|
|
17
17
|
// noinspection JSUnresolvedVariable
|
|
18
18
|
hexo.extend.generator.register('buildSw', () => {
|
|
19
|
-
if (!serviceWorkerConfig
|
|
19
|
+
if (!serviceWorkerConfig) return
|
|
20
20
|
const absPath = module.path + '/sw-template.js'
|
|
21
21
|
const rootPath = nodePath.resolve('./')
|
|
22
22
|
const relativePath = nodePath.relative(rootPath, absPath)
|
|
@@ -177,14 +177,14 @@ module.exports = (hexo, hexoConfig, rules) => {
|
|
|
177
177
|
|
|
178
178
|
// 生成注册 sw 的代码
|
|
179
179
|
const registerConfig = config.register
|
|
180
|
-
if (registerConfig
|
|
180
|
+
if (registerConfig) {
|
|
181
181
|
// noinspection JSUnresolvedVariable
|
|
182
182
|
hexo.extend.injector.register('head_begin', () => registerConfig.builder(root, hexoConfig, config), "default")
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
// 插入 sw-dom.js
|
|
186
186
|
const domConfig = config.dom
|
|
187
|
-
if (domConfig
|
|
187
|
+
if (domConfig) {
|
|
188
188
|
// noinspection JSUnresolvedVariable,HtmlUnknownTarget
|
|
189
189
|
hexo.extend.injector.register('body_begin', () => `<script src="/sw-dom.js"></script>`)
|
|
190
190
|
// noinspection JSUnresolvedVariable
|