whistle.global-magic-preview-component-local-resource 1.0.3 → 1.0.5

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/.console.log CHANGED
@@ -1,4 +1,42 @@
1
+ headRes: [object Response]
1
2
  componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_index.js
2
- componentName: common-component-image, port: 8082, url: http://127.0.0.1:8082/common-component-image_index.js
3
+ headRes: [object Response]
4
+ headRes: [object Response]
5
+ headRes: [object Response]
6
+ headRes: [object Response]
7
+ headRes: [object Response]
8
+ componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_index.js
9
+ headRes: [object Response]
10
+ headRes: [object Response]
11
+ headRes: [object Response]
12
+ headRes: [object Response]
13
+ headRes: [object Response]
14
+ componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_index.js
15
+ headRes: [object Response]
16
+ headRes: [object Response]
17
+ headRes: [object Response]
18
+ headRes: [object Response]
19
+ headRes: [object Response]
20
+ componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_index.js
21
+ headRes: [object Response]
22
+ headRes: [object Response]
23
+ headRes: [object Response]
24
+ headRes: [object Response]
3
25
  componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_index.js
26
+ headRes: [object Response]
27
+ headRes: [object Response]
28
+ headRes: [object Response]
29
+ headRes: [object Response]
4
30
  componentName: common-component-image, port: 8082, url: http://127.0.0.1:8082/common-component-image_index.js
31
+ headRes: [object Response]
32
+ headRes: undefined
33
+ headRes: [object Response]
34
+ headRes: undefined
35
+ headRes: [object Response]
36
+ headRes: undefined
37
+ headRes: undefined
38
+ headRes: undefined
39
+ headRes: undefined
40
+ headRes: undefined
41
+ headRes: undefined
42
+ headRes: undefined
@@ -10,7 +10,7 @@ const checkResPort = async (ports, index = 0, componentName) => {
10
10
  }
11
11
  }
12
12
  const headRes = await fetch(`${url}`, { method: "HEAD" }).catch(() => { });
13
- if (headRes.ok) {
13
+ if (headRes && headRes.ok) {
14
14
  return {
15
15
  ok: headRes.ok,
16
16
  port: ports[index],
@@ -20,11 +20,13 @@ const checkResPort = async (ports, index = 0, componentName) => {
20
20
  if (index + 1 < ports.length) {
21
21
  return checkResPort(ports, index + 1, componentName)
22
22
  }
23
+
23
24
  return {
24
25
  ok: false,
25
26
  port: ports[index],
26
27
  url
27
28
  }
29
+
28
30
  }
29
31
 
30
32
  module.exports = async (server) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.global-magic-preview-component-local-resource",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "将线上JS资源转发到本地IP对应的文件",
5
5
  "main": "index.js",
6
6
  "publicConfig": {
package/rules.txt CHANGED
@@ -1,2 +1 @@
1
- # 写法 A (推荐): 匹配的URL whistle.你的插件名://
2
1
  /common-component-[^_]+/ whistle.global-magic-preview-component-local-resource://