@xbrowser/cli 1.17.0 → 1.18.1

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.
@@ -20,9 +20,9 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-CE3L6HYV.js";
24
- import "./chunk-3KUJOXUE.js";
25
- import "./chunk-TNEN6VQ2.js";
23
+ } from "./chunk-EI2XZIDF.js";
24
+ import "./chunk-LL37GYPP.js";
25
+ import "./chunk-3KZ34AUC.js";
26
26
  import "./chunk-GDKLH7ZY.js";
27
27
  import "./chunk-A6LPGFAL.js";
28
28
  import "./chunk-H2A5JUK5.js";
@@ -20,10 +20,10 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-UQUJVBXE.js";
24
- import "./chunk-W4JETHAD.js";
23
+ } from "./chunk-MMZCBUD3.js";
24
+ import "./chunk-DVKIL7H6.js";
25
25
  import "./chunk-3FWLW7FS.js";
26
- import "./chunk-TNEN6VQ2.js";
26
+ import "./chunk-3KZ34AUC.js";
27
27
  import "./chunk-GDKLH7ZY.js";
28
28
  import "./chunk-KFQGP6VL.js";
29
29
  export {
@@ -20,8 +20,8 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-3LVR44KG.js";
24
- import "./chunk-TNEN6VQ2.js";
23
+ } from "./chunk-OU335JBI.js";
24
+ import "./chunk-3KZ34AUC.js";
25
25
  import "./chunk-GDKLH7ZY.js";
26
26
  import "./chunk-KFQGP6VL.js";
27
27
  export {
@@ -14,7 +14,7 @@ import {
14
14
  scrollIntoView,
15
15
  waitForActionable,
16
16
  waitForNetworkIdle
17
- } from "./chunk-W4JETHAD.js";
17
+ } from "./chunk-DVKIL7H6.js";
18
18
  import "./chunk-3FWLW7FS.js";
19
19
  import {
20
20
  connectToCDP,
@@ -22,7 +22,7 @@ import {
22
22
  getCDPTargets,
23
23
  killChrome,
24
24
  launchChrome
25
- } from "./chunk-TNEN6VQ2.js";
25
+ } from "./chunk-3KZ34AUC.js";
26
26
  import "./chunk-GDKLH7ZY.js";
27
27
  import "./chunk-KFQGP6VL.js";
28
28
  export {
@@ -14,14 +14,14 @@ import {
14
14
  scrollIntoView,
15
15
  waitForActionable,
16
16
  waitForNetworkIdle
17
- } from "./chunk-3KUJOXUE.js";
17
+ } from "./chunk-LL37GYPP.js";
18
18
  import {
19
19
  connectToCDP,
20
20
  findChrome,
21
21
  getCDPTargets,
22
22
  killChrome,
23
23
  launchChrome
24
- } from "./chunk-TNEN6VQ2.js";
24
+ } from "./chunk-3KZ34AUC.js";
25
25
  import "./chunk-GDKLH7ZY.js";
26
26
  import "./chunk-H2A5JUK5.js";
27
27
  import "./chunk-KFQGP6VL.js";
@@ -5,7 +5,7 @@ import {
5
5
  getCDPTargets,
6
6
  killChrome,
7
7
  launchChrome
8
- } from "./chunk-AMI64BSD.js";
8
+ } from "./chunk-IWVG4XYZ.js";
9
9
  import {
10
10
  __require
11
11
  } from "./chunk-3RG5ZIWI.js";
@@ -370,6 +370,19 @@ function buildStealthInitScript() {
370
370
  " document.fonts.add(ff);ff.load();}catch(e2){}",
371
371
  " });",
372
372
  " }catch(e){}",
373
+ // 3g. Notification.requestPermission 延迟(d62):headless 无原生横幅,
374
+ // request 瞬回 denied —— 真机 request 会 pending 在横幅上数秒到分钟。
375
+ // 延迟 2-6s 再 resolve,模拟横幅期(用户"看了下然后拒绝")。
376
+ " try{",
377
+ " if(window.Notification&&Notification.requestPermission){",
378
+ " var _nrp=Notification.requestPermission.bind(Notification);",
379
+ " Notification.requestPermission=function(cb){",
380
+ " return new Promise(function(res){",
381
+ " setTimeout(function(){_nrp().then(function(r){if(cb)try{cb(r)}catch(e){}res(r);});},2000+Math.random()*4000);",
382
+ " });",
383
+ " };",
384
+ " }",
385
+ " }catch(e){}",
373
386
  // 3. toString disguise (name-list based)
374
387
  " var _ts=Function.prototype.toString;",
375
388
  " var _hf=document.hasFocus;",
@@ -3417,7 +3430,7 @@ var XBBrowserImpl = class {
3417
3430
  this._exitHandler = null;
3418
3431
  }
3419
3432
  if (this.childProcess) {
3420
- const { killChrome: killChrome2 } = await import("./launcher-OZXJQPNG.js");
3433
+ const { killChrome: killChrome2 } = await import("./launcher-EXJHHAUL.js");
3421
3434
  await killChrome2(this.childProcess, this.tmpDir);
3422
3435
  }
3423
3436
  await this.conn.close();
@@ -3552,7 +3565,7 @@ var XBBrowserImpl = class {
3552
3565
  if (pageTargets.length === 0 && httpFallbackUrl) {
3553
3566
  console.log(`[discoverContexts] Target.getTargets returned ${targetInfos.length} targets (0 page type). Falling back to HTTP /json/list at ${httpFallbackUrl}`);
3554
3567
  try {
3555
- const { getCDPTargets: getCDPTargets2 } = await import("./launcher-OZXJQPNG.js");
3568
+ const { getCDPTargets: getCDPTargets2 } = await import("./launcher-EXJHHAUL.js");
3556
3569
  const httpPages = await getCDPTargets2(httpFallbackUrl);
3557
3570
  console.log(`[discoverContexts] HTTP /json/list returned ${httpPages.length} pages`);
3558
3571
  for (const p of httpPages) {
@@ -101,6 +101,7 @@ async function launchChrome(options = {}) {
101
101
  ];
102
102
  if (headless) {
103
103
  allArgs.push("--headless", "--hide-scrollbars", "--mute-audio");
104
+ allArgs.push("--autoplay-policy=no-user-gesture-required");
104
105
  }
105
106
  let tmpDir;
106
107
  if (userDataDir) {
@@ -160,6 +161,15 @@ async function connectToCDP(rawEndpoint) {
160
161
  }
161
162
  return resolveEndpointFromHTTP(rawEndpoint);
162
163
  }
164
+ function joinCdpHttpUrl(baseURL, path) {
165
+ try {
166
+ const u = new URL(baseURL);
167
+ u.pathname = (u.pathname.replace(/\/+$/, "") || "") + path;
168
+ return u.toString();
169
+ } catch {
170
+ return `${baseURL}${path}`;
171
+ }
172
+ }
163
173
  async function findFreePort() {
164
174
  const { createServer } = await import("net");
165
175
  return new Promise((resolve, reject) => {
@@ -193,7 +203,7 @@ async function waitForCDPReady(port, timeoutMs, child) {
193
203
  throw new Error(`Chrome CDP not ready after ${timeoutMs}ms (port ${port})`);
194
204
  }
195
205
  async function resolveEndpointFromHTTP(baseURL) {
196
- const url = `${baseURL}/json/version`;
206
+ const url = joinCdpHttpUrl(baseURL, "/json/version");
197
207
  const resp = await fetch(url, { signal: AbortSignal.timeout(3e3) });
198
208
  if (!resp.ok) {
199
209
  throw new Error(`CDP HTTP ${resp.status}: ${url}`);
@@ -205,7 +215,7 @@ async function resolveEndpointFromHTTP(baseURL) {
205
215
  return data.webSocketDebuggerUrl;
206
216
  }
207
217
  async function getCDPTargets(baseURL) {
208
- const url = `${baseURL}/json/list`;
218
+ const url = joinCdpHttpUrl(baseURL, "/json/list");
209
219
  const resp = await fetch(url, { signal: AbortSignal.timeout(5e3) });
210
220
  if (!resp.ok) {
211
221
  throw new Error(`CDP list HTTP ${resp.status}: ${url}`);
@@ -258,6 +268,7 @@ export {
258
268
  findChrome,
259
269
  launchChrome,
260
270
  connectToCDP,
271
+ joinCdpHttpUrl,
261
272
  getCDPTargets,
262
273
  killChrome
263
274
  };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  connectToCDP,
7
7
  launchChrome
8
- } from "./chunk-TNEN6VQ2.js";
8
+ } from "./chunk-3KZ34AUC.js";
9
9
  import {
10
10
  errMsg
11
11
  } from "./chunk-GDKLH7ZY.js";
@@ -381,6 +381,19 @@ function buildStealthInitScript() {
381
381
  " document.fonts.add(ff);ff.load();}catch(e2){}",
382
382
  " });",
383
383
  " }catch(e){}",
384
+ // 3g. Notification.requestPermission 延迟(d62):headless 无原生横幅,
385
+ // request 瞬回 denied —— 真机 request 会 pending 在横幅上数秒到分钟。
386
+ // 延迟 2-6s 再 resolve,模拟横幅期(用户"看了下然后拒绝")。
387
+ " try{",
388
+ " if(window.Notification&&Notification.requestPermission){",
389
+ " var _nrp=Notification.requestPermission.bind(Notification);",
390
+ " Notification.requestPermission=function(cb){",
391
+ " return new Promise(function(res){",
392
+ " setTimeout(function(){_nrp().then(function(r){if(cb)try{cb(r)}catch(e){}res(r);});},2000+Math.random()*4000);",
393
+ " });",
394
+ " };",
395
+ " }",
396
+ " }catch(e){}",
384
397
  // 3. toString disguise (name-list based)
385
398
  " var _ts=Function.prototype.toString;",
386
399
  " var _hf=document.hasFocus;",
@@ -3326,7 +3339,7 @@ var XBBrowserImpl = class {
3326
3339
  this._exitHandler = null;
3327
3340
  }
3328
3341
  if (this.childProcess) {
3329
- const { killChrome: killChrome2 } = await import("./launcher-L2JNDB2H.js");
3342
+ const { killChrome: killChrome2 } = await import("./launcher-44STYRJC.js");
3330
3343
  await killChrome2(this.childProcess, this.tmpDir);
3331
3344
  }
3332
3345
  await this.conn.close();
@@ -3461,7 +3474,7 @@ var XBBrowserImpl = class {
3461
3474
  if (pageTargets.length === 0 && httpFallbackUrl) {
3462
3475
  console.log(`[discoverContexts] Target.getTargets returned ${targetInfos.length} targets (0 page type). Falling back to HTTP /json/list at ${httpFallbackUrl}`);
3463
3476
  try {
3464
- const { getCDPTargets: getCDPTargets2 } = await import("./launcher-L2JNDB2H.js");
3477
+ const { getCDPTargets: getCDPTargets2 } = await import("./launcher-44STYRJC.js");
3465
3478
  const httpPages = await getCDPTargets2(httpFallbackUrl);
3466
3479
  console.log(`[discoverContexts] HTTP /json/list returned ${httpPages.length} pages`);
3467
3480
  for (const p of httpPages) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  launch
3
- } from "./chunk-3KUJOXUE.js";
3
+ } from "./chunk-LL37GYPP.js";
4
4
  import {
5
5
  errMsg
6
6
  } from "./chunk-GDKLH7ZY.js";
@@ -105,6 +105,7 @@ async function launchChrome(options = {}) {
105
105
  ];
106
106
  if (headless) {
107
107
  allArgs.push("--headless", "--hide-scrollbars", "--mute-audio");
108
+ allArgs.push("--autoplay-policy=no-user-gesture-required");
108
109
  }
109
110
  let tmpDir;
110
111
  if (userDataDir) {
@@ -164,6 +165,15 @@ async function connectToCDP(rawEndpoint) {
164
165
  }
165
166
  return resolveEndpointFromHTTP(rawEndpoint);
166
167
  }
168
+ function joinCdpHttpUrl(baseURL, path) {
169
+ try {
170
+ const u = new URL(baseURL);
171
+ u.pathname = (u.pathname.replace(/\/+$/, "") || "") + path;
172
+ return u.toString();
173
+ } catch {
174
+ return `${baseURL}${path}`;
175
+ }
176
+ }
167
177
  async function findFreePort() {
168
178
  const { createServer } = await import("net");
169
179
  return new Promise((resolve, reject) => {
@@ -197,7 +207,7 @@ async function waitForCDPReady(port, timeoutMs, child) {
197
207
  throw new Error(`Chrome CDP not ready after ${timeoutMs}ms (port ${port})`);
198
208
  }
199
209
  async function resolveEndpointFromHTTP(baseURL) {
200
- const url = `${baseURL}/json/version`;
210
+ const url = joinCdpHttpUrl(baseURL, "/json/version");
201
211
  const resp = await fetch(url, { signal: AbortSignal.timeout(3e3) });
202
212
  if (!resp.ok) {
203
213
  throw new Error(`CDP HTTP ${resp.status}: ${url}`);
@@ -209,7 +219,7 @@ async function resolveEndpointFromHTTP(baseURL) {
209
219
  return data.webSocketDebuggerUrl;
210
220
  }
211
221
  async function getCDPTargets(baseURL) {
212
- const url = `${baseURL}/json/list`;
222
+ const url = joinCdpHttpUrl(baseURL, "/json/list");
213
223
  const resp = await fetch(url, { signal: AbortSignal.timeout(5e3) });
214
224
  if (!resp.ok) {
215
225
  throw new Error(`CDP list HTTP ${resp.status}: ${url}`);
@@ -263,6 +273,7 @@ export {
263
273
  findChrome,
264
274
  launchChrome,
265
275
  connectToCDP,
276
+ joinCdpHttpUrl,
266
277
  getCDPTargets,
267
278
  killChrome
268
279
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  connectToCDP,
3
3
  launchChrome
4
- } from "./chunk-TNEN6VQ2.js";
4
+ } from "./chunk-3KZ34AUC.js";
5
5
  import {
6
6
  errMsg
7
7
  } from "./chunk-GDKLH7ZY.js";
@@ -380,6 +380,19 @@ function buildStealthInitScript() {
380
380
  " document.fonts.add(ff);ff.load();}catch(e2){}",
381
381
  " });",
382
382
  " }catch(e){}",
383
+ // 3g. Notification.requestPermission 延迟(d62):headless 无原生横幅,
384
+ // request 瞬回 denied —— 真机 request 会 pending 在横幅上数秒到分钟。
385
+ // 延迟 2-6s 再 resolve,模拟横幅期(用户"看了下然后拒绝")。
386
+ " try{",
387
+ " if(window.Notification&&Notification.requestPermission){",
388
+ " var _nrp=Notification.requestPermission.bind(Notification);",
389
+ " Notification.requestPermission=function(cb){",
390
+ " return new Promise(function(res){",
391
+ " setTimeout(function(){_nrp().then(function(r){if(cb)try{cb(r)}catch(e){}res(r);});},2000+Math.random()*4000);",
392
+ " });",
393
+ " };",
394
+ " }",
395
+ " }catch(e){}",
383
396
  // 3. toString disguise (name-list based)
384
397
  " var _ts=Function.prototype.toString;",
385
398
  " var _hf=document.hasFocus;",
@@ -3427,7 +3440,7 @@ var XBBrowserImpl = class {
3427
3440
  this._exitHandler = null;
3428
3441
  }
3429
3442
  if (this.childProcess) {
3430
- const { killChrome: killChrome2 } = await import("./launcher-L2JNDB2H.js");
3443
+ const { killChrome: killChrome2 } = await import("./launcher-44STYRJC.js");
3431
3444
  await killChrome2(this.childProcess, this.tmpDir);
3432
3445
  }
3433
3446
  await this.conn.close();
@@ -3562,7 +3575,7 @@ var XBBrowserImpl = class {
3562
3575
  if (pageTargets.length === 0 && httpFallbackUrl) {
3563
3576
  console.log(`[discoverContexts] Target.getTargets returned ${targetInfos.length} targets (0 page type). Falling back to HTTP /json/list at ${httpFallbackUrl}`);
3564
3577
  try {
3565
- const { getCDPTargets: getCDPTargets2 } = await import("./launcher-L2JNDB2H.js");
3578
+ const { getCDPTargets: getCDPTargets2 } = await import("./launcher-44STYRJC.js");
3566
3579
  const httpPages = await getCDPTargets2(httpFallbackUrl);
3567
3580
  console.log(`[discoverContexts] HTTP /json/list returned ${httpPages.length} pages`);
3568
3581
  for (const p of httpPages) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createRuleEngine,
3
3
  launch
4
- } from "./chunk-W4JETHAD.js";
4
+ } from "./chunk-DVKIL7H6.js";
5
5
  import {
6
6
  errMsg
7
7
  } from "./chunk-GDKLH7ZY.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  connectToCDP,
3
3
  launchChrome
4
- } from "./chunk-TNEN6VQ2.js";
4
+ } from "./chunk-3KZ34AUC.js";
5
5
  import {
6
6
  errMsg
7
7
  } from "./chunk-GDKLH7ZY.js";
@@ -383,6 +383,19 @@ function buildStealthInitScript() {
383
383
  " document.fonts.add(ff);ff.load();}catch(e2){}",
384
384
  " });",
385
385
  " }catch(e){}",
386
+ // 3g. Notification.requestPermission 延迟(d62):headless 无原生横幅,
387
+ // request 瞬回 denied —— 真机 request 会 pending 在横幅上数秒到分钟。
388
+ // 延迟 2-6s 再 resolve,模拟横幅期(用户"看了下然后拒绝")。
389
+ " try{",
390
+ " if(window.Notification&&Notification.requestPermission){",
391
+ " var _nrp=Notification.requestPermission.bind(Notification);",
392
+ " Notification.requestPermission=function(cb){",
393
+ " return new Promise(function(res){",
394
+ " setTimeout(function(){_nrp().then(function(r){if(cb)try{cb(r)}catch(e){}res(r);});},2000+Math.random()*4000);",
395
+ " });",
396
+ " };",
397
+ " }",
398
+ " }catch(e){}",
386
399
  // 3. toString disguise (name-list based)
387
400
  " var _ts=Function.prototype.toString;",
388
401
  " var _hf=document.hasFocus;",
@@ -3430,7 +3443,7 @@ var XBBrowserImpl = class {
3430
3443
  this._exitHandler = null;
3431
3444
  }
3432
3445
  if (this.childProcess) {
3433
- const { killChrome: killChrome2 } = await import("./launcher-L2JNDB2H.js");
3446
+ const { killChrome: killChrome2 } = await import("./launcher-44STYRJC.js");
3434
3447
  await killChrome2(this.childProcess, this.tmpDir);
3435
3448
  }
3436
3449
  await this.conn.close();
@@ -3565,7 +3578,7 @@ var XBBrowserImpl = class {
3565
3578
  if (pageTargets.length === 0 && httpFallbackUrl) {
3566
3579
  console.log(`[discoverContexts] Target.getTargets returned ${targetInfos.length} targets (0 page type). Falling back to HTTP /json/list at ${httpFallbackUrl}`);
3567
3580
  try {
3568
- const { getCDPTargets: getCDPTargets3 } = await import("./launcher-L2JNDB2H.js");
3581
+ const { getCDPTargets: getCDPTargets3 } = await import("./launcher-44STYRJC.js");
3569
3582
  const httpPages = await getCDPTargets3(httpFallbackUrl);
3570
3583
  console.log(`[discoverContexts] HTTP /json/list returned ${httpPages.length} pages`);
3571
3584
  for (const p of httpPages) {
package/dist/cli.js CHANGED
@@ -72,8 +72,8 @@ import {
72
72
  setActivePage,
73
73
  sleep,
74
74
  wheelDelta
75
- } from "./chunk-3LVR44KG.js";
76
- import "./chunk-TNEN6VQ2.js";
75
+ } from "./chunk-OU335JBI.js";
76
+ import "./chunk-3KZ34AUC.js";
77
77
  import {
78
78
  errMsg
79
79
  } from "./chunk-GDKLH7ZY.js";
@@ -7545,7 +7545,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7545
7545
  }
7546
7546
  let targetPageOverride = null;
7547
7547
  if (_target && extraOpts?.cdpEndpoint) {
7548
- const { findTargetPage } = await import("./browser-HY7UXUQV.js");
7548
+ const { findTargetPage } = await import("./browser-W3Z4HPJN.js");
7549
7549
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
7550
7550
  if (!targetPageOverride) {
7551
7551
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -7583,9 +7583,12 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7583
7583
  session.page.evaluate(() => true),
7584
7584
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 3e3))
7585
7585
  ]);
7586
- } catch {
7587
- await closeSessionByName(session.name);
7588
- session = void 0;
7586
+ } catch (err) {
7587
+ const msg = err instanceof Error ? err.message : String(err);
7588
+ if (/closed|detached|destroyed|not found|Session closed/i.test(msg)) {
7589
+ await closeSessionByName(session.name);
7590
+ session = void 0;
7591
+ }
7589
7592
  }
7590
7593
  }
7591
7594
  if (session && targetPageOverride && session.page) {
@@ -13720,7 +13723,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
13720
13723
  const targetPage = pages[cmdTabIndex];
13721
13724
  await targetPage.bringToFront().catch(() => {
13722
13725
  });
13723
- const { setActivePage: setActivePage2 } = await import("./browser-HY7UXUQV.js");
13726
+ const { setActivePage: setActivePage2 } = await import("./browser-W3Z4HPJN.js");
13724
13727
  setActivePage2(session, targetPage);
13725
13728
  }
13726
13729
  }
@@ -13996,7 +13999,7 @@ async function main() {
13996
13999
  const command = process.argv[2];
13997
14000
  const isLongRunning = command === "preview" || command === "serve";
13998
14001
  if (!isLongRunning) {
13999
- const { ensureProcessCanExit } = await import("./browser-HY7UXUQV.js");
14002
+ const { ensureProcessCanExit } = await import("./browser-W3Z4HPJN.js");
14000
14003
  await ensureProcessCanExit().catch(() => {
14001
14004
  });
14002
14005
  process.exit(process.exitCode || exitCode);
@@ -34,17 +34,17 @@ import {
34
34
  resolveLaunchOpts,
35
35
  saveSessionDiskMeta,
36
36
  setActivePage
37
- } from "./chunk-UQUJVBXE.js";
37
+ } from "./chunk-MMZCBUD3.js";
38
38
  import {
39
39
  createRuleEngine,
40
40
  rand,
41
41
  sleep,
42
42
  wheelDelta
43
- } from "./chunk-W4JETHAD.js";
43
+ } from "./chunk-DVKIL7H6.js";
44
44
  import {
45
45
  queryJS
46
46
  } from "./chunk-3FWLW7FS.js";
47
- import "./chunk-TNEN6VQ2.js";
47
+ import "./chunk-3KZ34AUC.js";
48
48
  import {
49
49
  errMsg
50
50
  } from "./chunk-GDKLH7ZY.js";
@@ -7063,7 +7063,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7063
7063
  }
7064
7064
  let targetPageOverride = null;
7065
7065
  if (_target && extraOpts?.cdpEndpoint) {
7066
- const { findTargetPage } = await import("./browser-ZVNDI4TR.js");
7066
+ const { findTargetPage } = await import("./browser-UPKOT3V6.js");
7067
7067
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
7068
7068
  if (!targetPageOverride) {
7069
7069
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -7101,9 +7101,12 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7101
7101
  session.page.evaluate(() => true),
7102
7102
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 3e3))
7103
7103
  ]);
7104
- } catch {
7105
- await closeSessionByName(session.name);
7106
- session = void 0;
7104
+ } catch (err) {
7105
+ const msg = err instanceof Error ? err.message : String(err);
7106
+ if (/closed|detached|destroyed|not found|Session closed/i.test(msg)) {
7107
+ await closeSessionByName(session.name);
7108
+ session = void 0;
7109
+ }
7107
7110
  }
7108
7111
  }
7109
7112
  if (session && targetPageOverride && session.page) {
@@ -8882,7 +8885,7 @@ function createRPCHandler() {
8882
8885
  if (isNewFormat) {
8883
8886
  try {
8884
8887
  const replayErrors = [];
8885
- const { SessionReplayer } = await import("./session-replayer-NV65I6OQ.js");
8888
+ const { SessionReplayer } = await import("./session-replayer-J4GXUULG.js");
8886
8889
  const replayer = new SessionReplayer({
8887
8890
  page: session.page,
8888
8891
  stepDelay: slowMo * 500,
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  resolveLaunchOpts,
19
19
  saveSessionDiskMeta,
20
20
  setActivePage
21
- } from "./chunk-CE3L6HYV.js";
21
+ } from "./chunk-EI2XZIDF.js";
22
22
  import {
23
23
  detectAntiBot,
24
24
  formatDetectionMessage
@@ -86,8 +86,8 @@ import {
86
86
  rand,
87
87
  sleep,
88
88
  wheelDelta
89
- } from "./chunk-3KUJOXUE.js";
90
- import "./chunk-TNEN6VQ2.js";
89
+ } from "./chunk-LL37GYPP.js";
90
+ import "./chunk-3KZ34AUC.js";
91
91
  import {
92
92
  errMsg
93
93
  } from "./chunk-GDKLH7ZY.js";
@@ -7896,7 +7896,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7896
7896
  }
7897
7897
  let targetPageOverride = null;
7898
7898
  if (_target && extraOpts?.cdpEndpoint) {
7899
- const { findTargetPage } = await import("./browser-GPRLH6P6.js");
7899
+ const { findTargetPage } = await import("./browser-SYE57VHU.js");
7900
7900
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
7901
7901
  if (!targetPageOverride) {
7902
7902
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -7934,9 +7934,12 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7934
7934
  session.page.evaluate(() => true),
7935
7935
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 3e3))
7936
7936
  ]);
7937
- } catch {
7938
- await closeSessionByName(session.name);
7939
- session = void 0;
7937
+ } catch (err) {
7938
+ const msg = err instanceof Error ? err.message : String(err);
7939
+ if (/closed|detached|destroyed|not found|Session closed/i.test(msg)) {
7940
+ await closeSessionByName(session.name);
7941
+ session = void 0;
7942
+ }
7940
7943
  }
7941
7944
  }
7942
7945
  if (session && targetPageOverride && session.page) {
@@ -14109,7 +14112,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
14109
14112
  const targetPage = pages[cmdTabIndex];
14110
14113
  await targetPage.bringToFront().catch(() => {
14111
14114
  });
14112
- const { setActivePage: setActivePage2 } = await import("./browser-GPRLH6P6.js");
14115
+ const { setActivePage: setActivePage2 } = await import("./browser-SYE57VHU.js");
14113
14116
  setActivePage2(session, targetPage);
14114
14117
  }
14115
14118
  }
@@ -17282,7 +17285,7 @@ var DataCollector = class {
17282
17285
  return results;
17283
17286
  }
17284
17287
  async createBrowserContext() {
17285
- const { launch } = await import("./cdp-driver-GMDP4KDN.js");
17288
+ const { launch } = await import("./cdp-driver-KT6HL33W.js");
17286
17289
  const { browser } = await launch({
17287
17290
  headless: true,
17288
17291
  args: ["--no-sandbox", "--disable-setuid-sandbox"]
@@ -4,9 +4,10 @@ import {
4
4
  connectToCDP,
5
5
  findChrome,
6
6
  getCDPTargets,
7
+ joinCdpHttpUrl,
7
8
  killChrome,
8
9
  launchChrome
9
- } from "./chunk-TNEN6VQ2.js";
10
+ } from "./chunk-3KZ34AUC.js";
10
11
  import "./chunk-GDKLH7ZY.js";
11
12
  import "./chunk-KFQGP6VL.js";
12
13
  export {
@@ -15,6 +16,7 @@ export {
15
16
  connectToCDP,
16
17
  findChrome,
17
18
  getCDPTargets,
19
+ joinCdpHttpUrl,
18
20
  killChrome,
19
21
  launchChrome
20
22
  };
@@ -4,9 +4,10 @@ import {
4
4
  connectToCDP,
5
5
  findChrome,
6
6
  getCDPTargets,
7
+ joinCdpHttpUrl,
7
8
  killChrome,
8
9
  launchChrome
9
- } from "./chunk-AMI64BSD.js";
10
+ } from "./chunk-IWVG4XYZ.js";
10
11
  import "./chunk-3RG5ZIWI.js";
11
12
  export {
12
13
  ANTI_DETECT_ARGS,
@@ -14,6 +15,7 @@ export {
14
15
  connectToCDP,
15
16
  findChrome,
16
17
  getCDPTargets,
18
+ joinCdpHttpUrl,
17
19
  killChrome,
18
20
  launchChrome
19
21
  };
@@ -34,7 +34,7 @@ var SessionReplayer = class {
34
34
  if (this.opts.page) {
35
35
  this.page = this.opts.page;
36
36
  } else if (this.opts.cdpUrl) {
37
- const { launch } = await import("./cdp-driver-FIAUJTBZ.js");
37
+ const { launch } = await import("./cdp-driver-4UAV56SQ.js");
38
38
  const { browser } = await launch({ cdpEndpoint: this.opts.cdpUrl });
39
39
  let contexts = browser.contexts();
40
40
  for (let i = 0; i < 10 && contexts.length === 0; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.17.0",
3
+ "version": "1.18.1",
4
4
  "description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
5
5
  "type": "module",
6
6
  "bin": {