cdp-tunnel 3.0.0 → 3.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
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.0",
3
+ "version": "3.0.2",
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",
@@ -13,7 +13,7 @@ const CONFIG = {
13
13
  PLUGIN_MAX_MISSED_PINGS: 3,
14
14
  TAKEOVER_PORT: process.env.TAKEOVER_PORT ? parseInt(process.env.TAKEOVER_PORT) : (parseInt(process.env.PORT || '9221') + 1),
15
15
  POOL_TAKEOVER_PORT: process.env.POOL_TAKEOVER_PORT ? parseInt(process.env.POOL_TAKEOVER_PORT) : 9220,
16
- POOL_START: process.env.POOL_START ? parseInt(process.env.POOL_START) : 9222,
16
+ POOL_START: process.env.POOL_START ? parseInt(process.env.POOL_START) : 9231,
17
17
  POOL_SIZE: process.env.POOL_SIZE ? parseInt(process.env.POOL_SIZE) : 9
18
18
  };
19
19
 
@@ -187,18 +187,14 @@ class PortPoolManager {
187
187
  try { msg = JSON.parse(data.toString()); } catch { return; }
188
188
 
189
189
  if (msg.id !== undefined) {
190
- // 命令:分配新 id,记录映射,转发给 plugin
190
+ // 命令:分配新 id,记录映射(含 method 名供响应后处理),转发给 plugin
191
191
  const newId = `pool${session.portIndex}_${msg.id}`;
192
192
  session.pendingRequests.set(newId, {
193
193
  originalId: msg.id,
194
+ method: msg.method, // 记录方法名,响应时按需过滤
194
195
  clientWs: ws
195
196
  });
196
197
 
197
- // 特殊处理 createTarget:记录 targetId 归属
198
- if (msg.method === 'Target.createTarget') {
199
- msg.params = msg.params || {};
200
- }
201
-
202
198
  const forwarded = { ...msg, id: newId, __portIndex: session.portIndex };
203
199
  pluginWs.send(JSON.stringify(forwarded));
204
200
  } else {
@@ -251,6 +247,12 @@ class PortPoolManager {
251
247
  console.log(`[PORT POOL] sessionId=${msg.result.sessionId.slice(0,12)} → port ${session.port}`);
252
248
  }
253
249
 
250
+ // 如果是 getTargets 响应,按 portIndex 过滤 targetInfos
251
+ if (pending && pending.method === 'Target.getTargets' && msg.result && msg.result.targetInfos) {
252
+ msg.result.targetInfos = msg.result.targetInfos.filter(t => session.targetIds.has(t.targetId));
253
+ console.log(`[PORT POOL] getTargets filtered: ${msg.result.targetInfos.length} targets for port ${session.port}`);
254
+ }
255
+
254
256
  // 恢复原始 id,发给发起请求的 client
255
257
  const response = { ...msg, id: this._parseOriginalId(originalId) };
256
258
  if (pending && pending.clientWs && pending.clientWs.readyState === WebSocket.OPEN) {