cdp-tunnel 2.5.19 → 2.5.20

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.
@@ -263,6 +263,10 @@ var State = (function() {
263
263
  return _state.cdpCreatedTabIds.has(tabId);
264
264
  }
265
265
 
266
+ function getCDPCreatedTabIds() {
267
+ return Array.from(_state.cdpCreatedTabIds);
268
+ }
269
+
266
270
  function clearAllState() {
267
271
  clearSessionState();
268
272
  _state.attachedTabIds.clear();
@@ -506,6 +510,7 @@ var State = (function() {
506
510
  removePreExistingTab: removePreExistingTab,
507
511
  clearPreExistingTabsForClient: clearPreExistingTabsForClient,
508
512
  addCDPCreatedTab: addCDPCreatedTab,
509
- isCDPCreatedTab: isCDPCreatedTab
513
+ isCDPCreatedTab: isCDPCreatedTab,
514
+ getCDPCreatedTabIds: getCDPCreatedTabIds
510
515
  };
511
516
  })();
@@ -339,23 +339,40 @@ var WebSocketManager = (function() {
339
339
 
340
340
  function closeTabsByClientId(clientId, resolve) {
341
341
  var attachedTabs = State.getAttachedTabIds();
342
+ var cdpCreatedTabs = State.getCDPCreatedTabIds();
342
343
  var tabsToClose = [];
344
+ var tabsToCloseSet = new Set();
345
+
346
+ Logger.info('[WS] closeTabsByClientId: clientId=' + clientId + ' attachedTabs=' + JSON.stringify(attachedTabs) + ' cdpCreatedTabs=' + JSON.stringify(cdpCreatedTabs));
343
347
 
344
- Logger.info('[WS] closeTabsByClientId: clientId=' + clientId + ' attachedTabs=' + JSON.stringify(attachedTabs));
345
348
  attachedTabs.forEach(function(tabId) {
346
349
  var tabClientId = State.getClientIdByTabId(tabId);
347
350
  var isPre = State.isPreExistingTab(tabId);
348
351
  var isCDP = State.isCDPCreatedTab(tabId);
349
- Logger.info('[WS] tabId=' + tabId + ' clientId=' + tabClientId + ' isPre=' + isPre + ' isCDP=' + isCDP);
352
+ Logger.info('[WS] [attached] tabId=' + tabId + ' clientId=' + tabClientId + ' isPre=' + isPre + ' isCDP=' + isCDP);
350
353
  if (tabClientId === clientId && !isPre) {
351
- tabsToClose.push(tabId);
354
+ tabsToCloseSet.add(tabId);
352
355
  }
353
356
  });
354
357
 
358
+ cdpCreatedTabs.forEach(function(tabId) {
359
+ if (tabsToCloseSet.has(tabId)) return;
360
+
361
+ var tabClientId = State.getClientIdByTabId(tabId);
362
+ var isPre = State.isPreExistingTab(tabId);
363
+ Logger.info('[WS] [cdpCreated] tabId=' + tabId + ' clientId=' + tabClientId + ' isPre=' + isPre + ' isAttached=' + attachedTabs.includes(tabId));
364
+ if (tabClientId === clientId && !isPre && !attachedTabs.includes(tabId)) {
365
+ tabsToCloseSet.add(tabId);
366
+ Logger.info('[WS] -> Added to close list (not yet attached)');
367
+ }
368
+ });
369
+
370
+ tabsToClose = Array.from(tabsToCloseSet);
371
+
355
372
  Logger.info('[WS] closeTabsByClientId: will close ' + tabsToClose.length + ' tabs');
356
373
 
357
374
  if (tabsToClose.length === 0) {
358
- Logger.info('[WS] No attached tabs found for clientId:', clientId);
375
+ Logger.info('[WS] No tabs found for clientId:', clientId);
359
376
  resolve();
360
377
  return;
361
378
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.5.19",
4
+ "version": "2.5.20",
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.19",
3
+ "version": "2.5.20",
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",