@xbrowser/cli 1.24.3 → 1.25.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.
@@ -9,7 +9,7 @@ import {
9
9
  landingOffset,
10
10
  rand,
11
11
  typingDelay
12
- } from "./chunk-GYB5BOSP.js";
12
+ } from "./chunk-R3F4K2SB.js";
13
13
  import {
14
14
  connectToCDP,
15
15
  launchChrome
@@ -4852,7 +4852,7 @@ async function launch(options = {}) {
4852
4852
  const bv = await conn.send("Browser.getVersion");
4853
4853
  const m = bv.product.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
4854
4854
  if (m && !options.stealthConfig?.uaChProfile) {
4855
- const { deriveUaChProfileForBinary } = await import("./stealth-JOXGV34D.js");
4855
+ const { deriveUaChProfileForBinary } = await import("./stealth-MHJNBJY7.js");
4856
4856
  stealthOpts = { stealthConfig: { uaChProfile: deriveUaChProfileForBinary(m[0], m[1]) } };
4857
4857
  }
4858
4858
  } catch {
package/dist/cli.js CHANGED
@@ -10,13 +10,14 @@ import {
10
10
  executeCommand,
11
11
  getAllCommands,
12
12
  getCommand,
13
+ getCommandNames,
13
14
  getPluginLoader,
14
15
  getPluginStorage,
15
16
  isChainInput,
16
17
  loadHooks,
17
18
  parsePluginParams,
18
19
  readJsonFile
19
- } from "./chunk-SUHS2EWV.js";
20
+ } from "./chunk-55TCNPMB.js";
20
21
  import "./chunk-JKVUFP3G.js";
21
22
  import {
22
23
  forwardCommandLog,
@@ -80,8 +81,8 @@ import {
80
81
  findSession,
81
82
  getAllSessions,
82
83
  saveSessionDiskMeta
83
- } from "./chunk-X735U7G7.js";
84
- import "./chunk-GYB5BOSP.js";
84
+ } from "./chunk-CRRR4KUO.js";
85
+ import "./chunk-R3F4K2SB.js";
85
86
  import "./chunk-MYH6FIBZ.js";
86
87
  import {
87
88
  errMsg
@@ -2508,10 +2509,11 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
2508
2509
  }
2509
2510
  case "mouse": {
2510
2511
  const flatArgs = args.flatMap((a) => a.split(/\s+/).filter(Boolean));
2511
- const action = options.action || flatArgs.find((a) => ["move", "click", "dblclick", "down", "up"].includes(a));
2512
- const actionIdx = action ? flatArgs.indexOf(action) : -1;
2513
- const x = options.x !== void 0 ? Number(options.x) : actionIdx >= 0 && flatArgs[actionIdx + 1] ? Number(flatArgs[actionIdx + 1]) : void 0;
2514
- const y = options.y !== void 0 ? Number(options.y) : actionIdx >= 0 && flatArgs[actionIdx + 2] ? Number(flatArgs[actionIdx + 2]) : void 0;
2512
+ const argActionIdx = flatArgs.findIndex((a) => ["move", "click", "dblclick", "down", "up"].includes(a));
2513
+ const action = options.action || (argActionIdx >= 0 ? flatArgs[argActionIdx] : void 0);
2514
+ const coordArgs = options.action !== void 0 ? flatArgs : argActionIdx >= 0 ? flatArgs.slice(argActionIdx + 1) : flatArgs;
2515
+ const x = options.x !== void 0 ? Number(options.x) : coordArgs[0] !== void 0 ? Number(coordArgs[0]) : void 0;
2516
+ const y = options.y !== void 0 ? Number(options.y) : coordArgs[1] !== void 0 ? Number(coordArgs[1]) : void 0;
2515
2517
  if (!action || x === void 0 || y === void 0 || isNaN(x) || isNaN(y)) {
2516
2518
  outputError("Usage: xbrowser mouse <move|click|dblclick> <x> <y>\n xbrowser mouse --action <action> --x <x> --y <y>");
2517
2519
  }
@@ -5466,7 +5468,13 @@ function extractSessionNameFromArgv(argv) {
5466
5468
  async function handleEvalMode(argv) {
5467
5469
  const evalCommands = parseEvalFlags(argv);
5468
5470
  if (evalCommands.length === 0) return;
5469
- const chain = evalCommands.map((script) => `eval --script-b64 ${Buffer.from(script, "utf8").toString("base64url")}`).join(" ; ");
5471
+ const knownCommands = new Set(getCommandNames());
5472
+ const chainParts = evalCommands.map((value) => {
5473
+ const firstWord = value.trim().split(/\s+/)[0] || "";
5474
+ if (knownCommands.has(firstWord)) return value;
5475
+ return `eval --script-b64 ${Buffer.from(value, "utf8").toString("base64url")}`;
5476
+ });
5477
+ const chain = chainParts.join(" ; ");
5470
5478
  const cdpEndpoint = extractCdpFromArgv(argv);
5471
5479
  const sessionArgIdx = argv.indexOf("--session");
5472
5480
  const sessionName = sessionArgIdx >= 0 && argv[sessionArgIdx + 1] ? argv[sessionArgIdx + 1] : process.env.XBROWSER_SESSION || "default";
@@ -5556,6 +5564,8 @@ async function handleChainInput(input, argv) {
5556
5564
  }
5557
5565
  async function routeCommand(argvIn, stdinCommands) {
5558
5566
  let argv = argvIn;
5567
+ let chainTokenStart = -1;
5568
+ let chainTokenEnd = -1;
5559
5569
  process.exitCode = 0;
5560
5570
  try {
5561
5571
  if (stdinCommands && stdinCommands.length > 0) {
@@ -5605,6 +5615,8 @@ async function routeCommand(argvIn, stdinCommands) {
5605
5615
  const remainder = chainArg.substring(spaceIdx + 1);
5606
5616
  let remainderParts = remainder.split(/\s+/).filter(Boolean);
5607
5617
  remainderParts = remainderParts.flatMap((part) => part.split(";").filter(Boolean));
5618
+ chainTokenStart = chainArgIdx;
5619
+ chainTokenEnd = chainArgIdx + remainderParts.length;
5608
5620
  argv = [...argv.slice(0, chainArgIdx), possibleCmd, ...remainderParts, ...argv.slice(chainArgIdx + 1)];
5609
5621
  }
5610
5622
  }
@@ -5830,6 +5842,10 @@ async function routeCommand(argvIn, stdinCommands) {
5830
5842
  const globalFlagSet = /* @__PURE__ */ new Set(["--session", "--cdp", "--json", "--yaml", "--help", "-h", "--version", "--output", "-o"]);
5831
5843
  const cleanParts = [];
5832
5844
  for (let i = 0; i < argv.length; i++) {
5845
+ if (chainTokenStart >= 0 && i >= chainTokenStart && i <= chainTokenEnd) {
5846
+ cleanParts.push(argv[i]);
5847
+ continue;
5848
+ }
5833
5849
  if (globalFlagSet.has(argv[i])) continue;
5834
5850
  if (i > 0 && globalFlagSet.has(argv[i - 1]) && !argv[i].startsWith("-")) continue;
5835
5851
  if (argv[i].startsWith("--session=") || argv[i].startsWith("--cdp=")) continue;
@@ -6016,7 +6032,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
6016
6032
  const targetPage = pages[cmdTabIndex];
6017
6033
  await targetPage.bringToFront().catch(() => {
6018
6034
  });
6019
- const { setActivePage } = await import("./browser-I3EZY3FL.js");
6035
+ const { setActivePage } = await import("./browser-FIEYZRSV.js");
6020
6036
  setActivePage(session, targetPage);
6021
6037
  }
6022
6038
  }
@@ -6281,7 +6297,7 @@ async function handleRemote(args, options, mode) {
6281
6297
  }
6282
6298
  }
6283
6299
  async function startMcpServer() {
6284
- const { startMcpStdio } = await import("./server-A5R4OIGX.js");
6300
+ const { startMcpStdio } = await import("./server-HITV2PS7.js");
6285
6301
  startMcpStdio();
6286
6302
  }
6287
6303
 
@@ -6300,7 +6316,7 @@ async function main() {
6300
6316
  const command = process.argv[2];
6301
6317
  const isLongRunning = command === "preview" || command === "serve" || command === "mcp";
6302
6318
  if (!isLongRunning) {
6303
- const { ensureProcessCanExit } = await import("./browser-I3EZY3FL.js");
6319
+ const { ensureProcessCanExit } = await import("./browser-FIEYZRSV.js");
6304
6320
  await ensureProcessCanExit().catch(() => {
6305
6321
  });
6306
6322
  process.exit(process.exitCode || exitCode);