cdp-tunnel 3.3.3 → 3.3.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/package.json
CHANGED
|
@@ -146,7 +146,7 @@ class PortPoolManager {
|
|
|
146
146
|
Browser: 'Chrome/131.0.6778.86 (cdp-tunnel)',
|
|
147
147
|
'Protocol-Version': '1.3',
|
|
148
148
|
'User-Agent': 'cdp-tunnel/3.0',
|
|
149
|
-
'webSocketDebuggerUrl': `ws://localhost:${session.port}/
|
|
149
|
+
'webSocketDebuggerUrl': `ws://localhost:${session.port}/client`
|
|
150
150
|
}));
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
@@ -374,14 +374,32 @@ class PortPoolManager {
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
-
// sessionId 路由(Network/Screencast/Input 等 session 事件)
|
|
377
|
+
// sessionId 路由(Network/Screencast/Input/Page 等 session 事件)
|
|
378
378
|
if (msg.sessionId) {
|
|
379
379
|
const portIndex = this.sessionToPort.get(msg.sessionId);
|
|
380
380
|
if (portIndex !== undefined) {
|
|
381
381
|
this._broadcastToPort(portIndex, msg);
|
|
382
382
|
return true;
|
|
383
383
|
}
|
|
384
|
+
// 竞态兜底:sessionId 还没注册(attachToTarget 响应未到)
|
|
385
|
+
// 但事件已经来了。广播给所有端口池 client,确保不丢。
|
|
386
|
+
// 对齐直连 Chrome——所有 session 事件都广播给所有连接。
|
|
387
|
+
for (let pi = 0; pi < this.portSessions.length; pi++) {
|
|
388
|
+
if (this.portSessions[pi]) {
|
|
389
|
+
this._broadcastToPort(pi, msg);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return true;
|
|
384
393
|
}
|
|
394
|
+
|
|
395
|
+
// 兜底:有 method 但没有 targetId 也没有 sessionId 的事件
|
|
396
|
+
// 也广播,确保不丢(如 Target.targetDestroyed 等)
|
|
397
|
+
for (let pi = 0; pi < this.portSessions.length; pi++) {
|
|
398
|
+
if (this.portSessions[pi]) {
|
|
399
|
+
this._broadcastToPort(pi, msg);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return true;
|
|
385
403
|
}
|
|
386
404
|
|
|
387
405
|
return false; // 不是端口池的消息
|