@xbrowser/cli 1.8.0 → 1.8.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.
package/dist/cli.js CHANGED
@@ -10253,13 +10253,29 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
10253
10253
  const sub = args[0];
10254
10254
  switch (sub) {
10255
10255
  case "close": {
10256
- const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
10257
- try {
10258
- await forwardSessionClose(name);
10259
- } catch {
10256
+ if (options.all) {
10257
+ let count = 0;
10258
+ try {
10259
+ const sessions2 = await forwardSessionList();
10260
+ for (const s of sessions2) {
10261
+ try {
10262
+ await forwardSessionClose(s.name);
10263
+ count++;
10264
+ } catch {
10265
+ }
10266
+ }
10267
+ } catch {
10268
+ }
10269
+ outputResult({ ok: true, closed: count, all: true }, mode);
10270
+ } else {
10271
+ const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
10272
+ try {
10273
+ await forwardSessionClose(name);
10274
+ } catch {
10275
+ }
10276
+ await closeSession(name);
10277
+ outputResult({ ok: true, name }, mode);
10260
10278
  }
10261
- await closeSession(name);
10262
- outputResult({ ok: true, name }, mode);
10263
10279
  break;
10264
10280
  }
10265
10281
  case "list":
@@ -11316,12 +11332,13 @@ async function handleRun(filePath, options) {
11316
11332
  async function handleViewer(_args, options, mode, _cdpEndpoint) {
11317
11333
  const name = options.name || process.env.XBROWSER_SESSION || "default";
11318
11334
  const selector = options.selector;
11335
+ const userPort = options.port ? Number(options.port) : void 0;
11319
11336
  let status = getDaemonProcessStatus();
11320
11337
  if (!status.running) {
11321
- await startDaemonProcess();
11338
+ await startDaemonProcess(userPort || 9224);
11322
11339
  status = getDaemonProcessStatus();
11323
11340
  }
11324
- const port = status.port || getDaemonConfig().basePort;
11341
+ const port = userPort || status.port || getDaemonConfig().basePort;
11325
11342
  let url = `http://localhost:${port}/preview/${name}`;
11326
11343
  if (selector) {
11327
11344
  try {
package/dist/index.js CHANGED
@@ -10576,13 +10576,29 @@ async function handleSession(args, options, mode, _cdpEndpoint) {
10576
10576
  const sub = args[0];
10577
10577
  switch (sub) {
10578
10578
  case "close": {
10579
- const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
10580
- try {
10581
- await forwardSessionClose(name);
10582
- } catch {
10579
+ if (options.all) {
10580
+ let count = 0;
10581
+ try {
10582
+ const sessions2 = await forwardSessionList();
10583
+ for (const s of sessions2) {
10584
+ try {
10585
+ await forwardSessionClose(s.name);
10586
+ count++;
10587
+ } catch {
10588
+ }
10589
+ }
10590
+ } catch {
10591
+ }
10592
+ outputResult({ ok: true, closed: count, all: true }, mode);
10593
+ } else {
10594
+ const name = options.session || options.name || process.env.XBROWSER_SESSION || "default";
10595
+ try {
10596
+ await forwardSessionClose(name);
10597
+ } catch {
10598
+ }
10599
+ await closeSession(name);
10600
+ outputResult({ ok: true, name }, mode);
10583
10601
  }
10584
- await closeSession(name);
10585
- outputResult({ ok: true, name }, mode);
10586
10602
  break;
10587
10603
  }
10588
10604
  case "list":
@@ -11639,12 +11655,13 @@ async function handleRun(filePath, options) {
11639
11655
  async function handleViewer(_args, options, mode, _cdpEndpoint) {
11640
11656
  const name = options.name || process.env.XBROWSER_SESSION || "default";
11641
11657
  const selector = options.selector;
11658
+ const userPort = options.port ? Number(options.port) : void 0;
11642
11659
  let status = getDaemonProcessStatus();
11643
11660
  if (!status.running) {
11644
- await startDaemonProcess();
11661
+ await startDaemonProcess(userPort || 9224);
11645
11662
  status = getDaemonProcessStatus();
11646
11663
  }
11647
- const port = status.port || getDaemonConfig().basePort;
11664
+ const port = userPort || status.port || getDaemonConfig().basePort;
11648
11665
  let url = `http://localhost:${port}/preview/${name}`;
11649
11666
  if (selector) {
11650
11667
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.8.0",
3
+ "version": "1.8.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": {