hexo-swpp 4.0.0 → 4.0.2
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/README.md +2 -0
- package/dist/index.js +11 -5
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -54,7 +54,6 @@ function checkHexoConfig(config) {
|
|
|
54
54
|
'auto_exec': 'boolean',
|
|
55
55
|
'npm_url': 'string',
|
|
56
56
|
'sort_rules': 'object',
|
|
57
|
-
'track_link': 'boolean',
|
|
58
57
|
};
|
|
59
58
|
for (let configKey in config) {
|
|
60
59
|
const type = typeMap[configKey];
|
|
@@ -106,7 +105,7 @@ async function start(hexo) {
|
|
|
106
105
|
await initRules(hexo, pluginConfig);
|
|
107
106
|
try {
|
|
108
107
|
const compilationData = actions.compilationData;
|
|
109
|
-
const response = await compilationData
|
|
108
|
+
const response = await fetchUrl(compilationData, test);
|
|
110
109
|
if ([200, 301, 302, 307, 308].includes(response.status)) {
|
|
111
110
|
logger.info('[SWPP][LINK TEST] 资源拉取成功,状态码:' + response.status);
|
|
112
111
|
}
|
|
@@ -184,8 +183,7 @@ async function runSwpp(hexo, pluginConfig) {
|
|
|
184
183
|
function checkVersion(pluginConfig) {
|
|
185
184
|
const compilationData = actions.compilationData;
|
|
186
185
|
const root = pluginConfig['npm_url'] ?? 'https://registry.npmjs.org';
|
|
187
|
-
|
|
188
|
-
fetcher.fetch(`${root}/swpp-backends/${swpp_backends_1.swppVersion}`)
|
|
186
|
+
fetchUrl(compilationData, `${root}/swpp-backends/${swpp_backends_1.swppVersion}`)
|
|
189
187
|
.then(response => {
|
|
190
188
|
if (![200, 301, 302, 307, 308].includes(response.status))
|
|
191
189
|
return Promise.reject(response.status);
|
|
@@ -219,7 +217,6 @@ async function loadConfig(hexo, pluginConfig) {
|
|
|
219
217
|
isServiceWorker: pluginConfig.serviceWorker ?? true,
|
|
220
218
|
domJsPath: pluginConfig.gen_dom ? 'sw-dom.js' : undefined,
|
|
221
219
|
diffJsonPath: pluginConfig.gen_diff,
|
|
222
|
-
trackLink: pluginConfig.track_link
|
|
223
220
|
});
|
|
224
221
|
await actions.loadConfig({
|
|
225
222
|
compilationEnv: {
|
|
@@ -365,6 +362,15 @@ function sort(hexo, pluginConfig) {
|
|
|
365
362
|
return result;
|
|
366
363
|
};
|
|
367
364
|
}
|
|
365
|
+
function fetchUrl(compilationData, url) {
|
|
366
|
+
const fetcher = compilationData.compilationEnv.read('NETWORK_FILE_FETCHER');
|
|
367
|
+
if (fetcher.fetch) {
|
|
368
|
+
return fetcher.fetch(url);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
return fetch(url);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
368
374
|
start(hexo).catch(e => {
|
|
369
375
|
logger.error("[SWPP] 加载时遇到严重错误!");
|
|
370
376
|
logger.error(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hexo-swpp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"hexo-log": "^4.1.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"swpp-backends": "^3.
|
|
33
|
+
"swpp-backends": "^3.1.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {}
|
|
36
36
|
}
|