whistle.global-magic-preview-component-local-resource 1.0.2 → 1.0.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/.console.log CHANGED
@@ -1,23 +1,24 @@
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
1
3
 
2
- From: whistle.demo-redirect@1.0.1
4
+ From: whistle.global-magic-preview-component-local-resource@1.0.3
3
5
  Node: v16.20.2
4
6
  Host: GL7TGHYG23
5
- Date: 12/24/2025, 12:01:36 PM
7
+ Date: 12/24/2025, 3:56:02 PM
6
8
  TypeError: Cannot read properties of undefined (reading 'ok')
7
- at checkResPort (/Users/bytedance/Desktop/package/lib/rulesServer.js:9:15)
9
+ at checkResPort (/Users/bytedance/Desktop/package/lib/rulesServer.js:13:15)
8
10
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
9
- at async Server.<anonymous> (/Users/bytedance/Desktop/package/lib/rulesServer.js:28:21)新的 common-component-button
10
- 新的 common-component-button
11
- 新的 common-component-button
12
- 新的 common-component-image
13
- 新的 common-component-button
14
- 新的 common-component-image
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
15
12
 
16
- From: whistle.demo-redirect@1.0.1
13
+ From: whistle.global-magic-preview-component-local-resource@1.0.3
17
14
  Node: v16.20.2
18
15
  Host: GL7TGHYG23
19
- Date: 12/24/2025, 2:10:36 PM
16
+ Date: 12/24/2025, 3:56:03 PM
20
17
  TypeError: Cannot read properties of undefined (reading 'ok')
21
18
  at checkResPort (/Users/bytedance/Desktop/package/lib/rulesServer.js:13:15)
22
19
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
23
- at async Server.<anonymous> (/Users/bytedance/Desktop/package/lib/rulesServer.js:33:21)
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
@@ -10,6 +10,9 @@ 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
+ }
13
16
  if (headRes.ok) {
14
17
  return {
15
18
  ok: headRes.ok,
@@ -17,14 +20,6 @@ const checkResPort = async (ports, index = 0, componentName) => {
17
20
  url
18
21
  }
19
22
  }
20
- if (index + 1 < ports.length) {
21
- return checkResPort(ports, index + 1, componentName)
22
- }
23
- return {
24
- ok: false,
25
- port: ports[index],
26
- url
27
- }
28
23
  }
29
24
 
30
25
  module.exports = async (server) => {
@@ -35,6 +30,7 @@ module.exports = async (server) => {
35
30
  const ports = [8080, 8082, 8084, 8086, 8088]
36
31
  const headRes = await checkResPort(ports, 0, componentName)
37
32
  if (headRes?.ok && method === "GET") {
33
+ console.log(`componentName: ${componentName}, port: ${headRes.port}, url: ${headRes.url}`)
38
34
  res.end(`https://sf16-website.neutral.ttwstatic.com${url} ${headRes.url}`);
39
35
  } else {
40
36
  res.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.global-magic-preview-component-local-resource",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "将线上JS资源转发到本地IP对应的文件",
5
5
  "main": "index.js",
6
6
  "publicConfig": {
@@ -17,7 +17,7 @@
17
17
  "author": "suyuefeng",
18
18
  "license": "ISC",
19
19
  "whistleConfig": {
20
- "name": "preview-component-local-resource",
20
+ "name": "global-magic-preview-component-local-resource",
21
21
  "ui": "ui/index.html",
22
22
  "rules": "rules.txt",
23
23
  "_rules": "_rules.txt"
package/rules.txt CHANGED
@@ -1,2 +1 @@
1
- # 写法 A (推荐): 匹配的URL whistle.你的插件名://
2
- /common-component-[^_]+/ whistle.demo-redirect://
1
+ /common-component-[^_]+/ whistle.global-magic-preview-component-local-resource://