cdp-tunnel 3.0.4 → 3.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "3.0.4",
4
+ "version": "3.0.5",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Bridge Chrome's debugger API to WebSocket — control your existing browser with Playwright/Puppeteer via CDP",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",
@@ -68,13 +68,15 @@ class PortPoolManager {
68
68
  this._handleHttp(req, res, session);
69
69
  });
70
70
 
71
+ // 每个 create 端口用独立的 wss(不复用主 proxy 的 wss)
71
72
  const wss = new WebSocket.Server({ noServer: true });
73
+ this.createWss[portIndex] = wss;
72
74
 
73
75
  server.on('upgrade', (req, socket, head) => {
74
76
  const url = new URL(req.url, `http://localhost:${port}`);
75
77
  const path = url.pathname;
76
78
 
77
- // 只允许 client 连接(plugin 连的是 9221)
79
+ // 只允许 client 连接(plugin 连的是主 proxy 的 9221)
78
80
  if (path !== '/client' && !path.startsWith('/client/') &&
79
81
  !path.startsWith('/devtools/browser/') && !path.startsWith('/devtools/page/')) {
80
82
  socket.destroy();
@@ -256,7 +258,6 @@ class PortPoolManager {
256
258
  // 如果是 attachToTarget 响应,记录 sessionId → portIndex
257
259
  if (msg.result && msg.result.sessionId) {
258
260
  this.sessionToPort.set(msg.result.sessionId, portIndex);
259
- console.log(`[PORT POOL] sessionId=${msg.result.sessionId.slice(0,12)} → port ${session.port}`);
260
261
  }
261
262
 
262
263
  // 如果是 getTargets 响应,按 portIndex 过滤 targetInfos
@@ -276,9 +277,9 @@ class PortPoolManager {
276
277
  return true;
277
278
  }
278
279
 
279
- // 2. 事件消息(无 id):按 targetId 路由
280
+ // 2. 事件消息(无 id):按 targetId 或 sessionId 路由
280
281
  if (msg.method && msg.params) {
281
- // 从事件参数里提取 targetId
282
+ // 诊断:打印所有未匹配到的事件
282
283
  let targetId = null;
283
284
  if (msg.params.targetId) targetId = msg.params.targetId;
284
285
  else if (msg.params.targetInfo && msg.params.targetInfo.targetId) targetId = msg.params.targetInfo.targetId;
@@ -294,7 +295,7 @@ class PortPoolManager {
294
295
  }
295
296
  }
296
297
 
297
- // sessionId 路由(attachedToTarget 后的 session 事件)
298
+ // sessionId 路由(Network/Screencast/Input session 事件)
298
299
  if (msg.sessionId) {
299
300
  const portIndex = this.sessionToPort.get(msg.sessionId);
300
301
  if (portIndex !== undefined) {