whistle.global-magic-preview-component-local-resource 1.0.4 → 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,24 +1,42 @@
1
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
2
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
3
-
4
- From: whistle.global-magic-preview-component-local-resource@1.0.3
5
- Node: v16.20.2
6
- Host: GL7TGHYG23
7
- Date: 12/24/2025, 3:56:02 PM
8
- TypeError: Cannot read properties of undefined (reading 'ok')
9
- at checkResPort (/Users/bytedance/Desktop/package/lib/rulesServer.js:13:15)
10
- at processTicksAndRejections (node:internal/process/task_queues:96:5)
11
- at async Server.<anonymous> (/Users/bytedance/Desktop/package/lib/rulesServer.js:36:21)componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
12
-
13
- From: whistle.global-magic-preview-component-local-resource@1.0.3
14
- Node: v16.20.2
15
- Host: GL7TGHYG23
16
- Date: 12/24/2025, 3:56:03 PM
17
- TypeError: Cannot read properties of undefined (reading 'ok')
18
- at checkResPort (/Users/bytedance/Desktop/package/lib/rulesServer.js:13:15)
19
- at processTicksAndRejections (node:internal/process/task_queues:96:5)
20
- at async Server.<anonymous> (/Users/bytedance/Desktop/package/lib/rulesServer.js:36:21)componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
21
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
22
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
23
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
24
- componentName: common-component-button, port: 8080, url: http://100.84.145.19:8080/common-component-button_index.js
1
+ headRes: [object Response]
2
+ componentName: common-component-button, port: 8080, url: http://127.0.0.1:8080/common-component-button_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]
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]
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,16 +10,23 @@ const checkResPort = async (ports, index = 0, componentName) => {
10
10
  }
11
11
  }
12
12
  const headRes = await fetch(`${url}`, { method: "HEAD" }).catch(() => { });
13
- if (!headRes && index + 1 < ports.length) {
14
- return checkResPort(ports, index + 1, componentName)
15
- }
16
- if (headRes.ok) {
13
+ if (headRes && headRes.ok) {
17
14
  return {
18
15
  ok: headRes.ok,
19
16
  port: ports[index],
20
17
  url
21
18
  }
22
19
  }
20
+ if (index + 1 < ports.length) {
21
+ return checkResPort(ports, index + 1, componentName)
22
+ }
23
+
24
+ return {
25
+ ok: false,
26
+ port: ports[index],
27
+ url
28
+ }
29
+
23
30
  }
24
31
 
25
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.4",
3
+ "version": "1.0.5",
4
4
  "description": "将线上JS资源转发到本地IP对应的文件",
5
5
  "main": "index.js",
6
6
  "publicConfig": {