cdp-tunnel 3.6.2 → 3.6.3
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
|
@@ -261,22 +261,12 @@ class PortPoolManager {
|
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
// SW 冷启动 warmup:第一个 client 连接时创建一个临时 tab 再关闭
|
|
265
|
-
if (!session.warmedUp) {
|
|
266
|
-
session.warmedUp = true;
|
|
267
|
-
const warmupId = `pool${session.portIndex}_internal_warmup`;
|
|
268
|
-
pluginWs.send(JSON.stringify({
|
|
269
|
-
id: warmupId,
|
|
270
|
-
method: 'Target.createTarget',
|
|
271
|
-
params: { url: 'about:blank' },
|
|
272
|
-
__portIndex: session.portIndex,
|
|
273
|
-
__clientId: `pool_${session.port}`
|
|
274
|
-
}));
|
|
275
|
-
// warmup 响应回来后在 handlePluginMessage 里关闭这个 tab
|
|
276
|
-
session.pendingWarmupClose = true;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
264
|
// 通知扩展有 client 连接(带端口号作为分组标识)
|
|
265
|
+
// 对齐原生 CDP:不创建任何隐式的 about:blank 页面。
|
|
266
|
+
// 原生 chrome --remote-debugging-port 在 client 连接后不创建任何 target,
|
|
267
|
+
// 只在 connectOverCDP 的 setAutoAttach 期间发现已有 target。
|
|
268
|
+
// (移除旧版 warmup 逻辑:它用 Target.createTarget 创建临时 about:blank 再关闭,
|
|
269
|
+
// 但时间窗口内 Playwright 的 setAutoAttach 会发现它,导致用户看到多余空白页。)
|
|
280
270
|
// clientId 固定为 pool_{port},让扩展为每个端口建一个独立分组
|
|
281
271
|
// __groupName 带 key 名称,让扩展用 key 名称命名 Chrome 分组(一眼看出是谁的浏览器)
|
|
282
272
|
const poolClientId = `pool_${session.port}`;
|
|
@@ -360,23 +350,8 @@ class PortPoolManager {
|
|
|
360
350
|
|
|
361
351
|
// 1. 响应消息:id 以 pool 开头(排除事件——事件有 method 字段)
|
|
362
352
|
if (msg.id && typeof msg.id === 'string' && msg.id.startsWith('pool') && !msg.method) {
|
|
363
|
-
//
|
|
353
|
+
// 内部命令响应(_ensureVisible 的 bringToFront/waitVis 等):丢弃,不路由给 client
|
|
364
354
|
if (msg.id.includes('_internal')) {
|
|
365
|
-
// warmup createTarget 响应——关掉 warmup tab
|
|
366
|
-
const m = msg.id.match(/^pool(\d+)_/);
|
|
367
|
-
if (m && msg.id.includes('_warmup') && msg.result && msg.result.targetId) {
|
|
368
|
-
const pidx = parseInt(m[1]);
|
|
369
|
-
const sess = this.portSessions[pidx];
|
|
370
|
-
const warmupTid = msg.result.targetId;
|
|
371
|
-
const closeId = `pool${pidx}_internal_warmup_close_${Date.now()}`;
|
|
372
|
-
pluginWs.send(JSON.stringify({
|
|
373
|
-
id: closeId,
|
|
374
|
-
method: 'Target.closeTarget',
|
|
375
|
-
params: { targetId: warmupTid },
|
|
376
|
-
__portIndex: pidx,
|
|
377
|
-
__clientId: `pool_${sess.port}`
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
355
|
return true;
|
|
381
356
|
}
|
|
382
357
|
const match = msg.id.match(/^pool(\d+)_(.+)$/);
|