cdp-tunnel 2.5.16 → 2.5.18

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": "2.5.16",
4
+ "version": "2.5.18",
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": "2.5.16",
3
+ "version": "2.5.18",
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",
@@ -53,7 +53,7 @@
53
53
  "LICENSE"
54
54
  ],
55
55
  "dependencies": {
56
- "cdp-tunnel": "^2.5.15",
56
+ "cdp-tunnel": "^2.5.17",
57
57
  "commander": "^12.0.0",
58
58
  "ws": "^8.16.0"
59
59
  },
@@ -210,8 +210,10 @@ async function requestVersionFromPlugin() {
210
210
  if (msg.id === requestId && msg.result) {
211
211
  clearTimeout(timeout);
212
212
  plugin.off('message', handler);
213
- cachedBrowserVersion = msg.result;
214
- resolve(cachedBrowserVersion);
213
+ if (msg.result.product || msg.result.userAgent) {
214
+ cachedBrowserVersion = msg.result;
215
+ }
216
+ resolve(cachedBrowserVersion || msg.result);
215
217
  }
216
218
  } catch (e) {}
217
219
  };
@@ -267,7 +269,7 @@ async function handleHttpRequest(req, res) {
267
269
  const userAgent = ver?.userAgent || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.86 Safari/537.36';
268
270
  const product = ver?.product || 'Chrome/131.0.6778.86';
269
271
  const payload = {
270
- Browser: product,
272
+ Browser: `${product} (cdp-tunnel/${PKG_VERSION})`,
271
273
  'Protocol-Version': ver?.protocolVersion || '1.3',
272
274
  'User-Agent': userAgent,
273
275
  'V8-Version': ver?.jsVersion || '',
@@ -624,6 +626,8 @@ function handlePluginConnection(ws, clientInfo) {
624
626
  if (!match) {
625
627
  console.log(` ↳ Run "cdp-tunnel update" or reload the extension to sync versions`);
626
628
  }
629
+ cachedBrowserVersion = null;
630
+ requestVersionFromPlugin();
627
631
  return;
628
632
  }
629
633
 
@@ -782,7 +786,16 @@ function handlePluginConnection(ws, clientInfo) {
782
786
  clientWs.send(msgStr);
783
787
  console.log(`[ATTACHED EVENT] Sent cached event to client: ${mapping.clientId}`);
784
788
  }
785
- invalidateTargetsCache();
789
+ const newTargetInfo = cachedCreated?.parsed?.params?.targetInfo
790
+ || cachedEvent?.parsed?.params?.targetInfo;
791
+ if (newTargetInfo) {
792
+ const exists = cachedTargets.some(t => t.targetId === targetId);
793
+ if (!exists) {
794
+ cachedTargets.push(newTargetInfo);
795
+ }
796
+ } else {
797
+ invalidateTargetsCache();
798
+ }
786
799
  }
787
800
  // 过滤 Target.getTargets 响应,只返回该客户端拥有的 target
788
801
  if (mapping.isGetTargets && parsed.result && parsed.result.targetInfos) {