@xbrowser/cli 1.2.0 → 1.2.2

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/index.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  killAllDaemonProcesses,
26
26
  startDaemonProcess,
27
27
  stopDaemonProcess
28
- } from "./chunk-XYXCS7JW.js";
28
+ } from "./chunk-JPSFUFPG.js";
29
29
  import {
30
30
  CaptchaDetector,
31
31
  HumanInteractionManager,
@@ -989,10 +989,10 @@ var setCookieCommand = registerCommand({
989
989
  description: "Set a cookie",
990
990
  scope: "page",
991
991
  parameters: z8.object({
992
- name: z8.string(),
993
- value: z8.string(),
994
- domain: z8.string().optional(),
995
- path: z8.string().optional(),
992
+ name: z8.coerce.string(),
993
+ value: z8.coerce.string(),
994
+ domain: z8.coerce.string().optional(),
995
+ path: z8.coerce.string().optional(),
996
996
  expires: z8.number().optional(),
997
997
  httpOnly: z8.boolean().optional(),
998
998
  secure: z8.boolean().optional(),
@@ -2398,44 +2398,45 @@ var scrapeCommand = registerCommand({
2398
2398
  switch (p.format) {
2399
2399
  case "markdown": {
2400
2400
  const tablesMd = await page.evaluate(() => {
2401
- const tableSelectors = [
2402
- "table",
2403
- '[role="table"]',
2404
- '[role="grid"]',
2405
- '[class*="el-table"]',
2406
- // Element UI
2407
- '[class*="ant-table"]',
2408
- // Ant Design
2409
- '[class*="MuiTable"]',
2410
- // Material UI
2411
- '[class*="table"]'
2412
- // Generic table-like
2413
- ].join(",");
2414
- const tables = document.querySelectorAll(tableSelectors);
2415
- if (tables.length === 0) return "";
2401
+ document.querySelectorAll(
2402
+ '.el-table__fixed, .el-table__fixed-right, [class*="fixed-left"], [class*="fixed-right"], .ant-table-fixed-left, .ant-table-fixed-right'
2403
+ ).forEach((el) => el.remove());
2404
+ document.querySelectorAll("table").forEach((t) => {
2405
+ if (t.closest(".el-table__fixed, .el-table__fixed-right")) t.remove();
2406
+ });
2407
+ const tables = document.querySelectorAll("table");
2408
+ if (tables.length === 0) {
2409
+ const altTables = document.querySelectorAll(
2410
+ '[role="table"], [role="grid"], .el-table__body, .ant-table-tbody'
2411
+ );
2412
+ if (altTables.length === 0) return "";
2413
+ return Array.from(altTables).map((table) => {
2414
+ return extractRowsFromContainer(table);
2415
+ }).filter((md) => md).join("\n\n");
2416
+ }
2416
2417
  return Array.from(tables).map((table) => {
2417
- const rows = table.querySelectorAll('tr, [role="row"], [class*="row"]');
2418
+ return extractRowsFromContainer(table);
2419
+ }).filter((md) => md).join("\n\n");
2420
+ function extractRowsFromContainer(container) {
2421
+ const rows = container.querySelectorAll(':scope > tr, :scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, [role="row"]');
2418
2422
  if (rows.length === 0) return "";
2419
2423
  const mdRows = Array.from(rows).map((row) => {
2420
- const cells = row.querySelectorAll('th, td, [role="columnheader"], [role="cell"], [class*="cell"], [class*="col"]');
2424
+ const cells = row.querySelectorAll(':scope > th, :scope > td, :scope > [role="columnheader"], :scope > [role="cell"]');
2425
+ if (cells.length === 0) return "";
2421
2426
  return "| " + Array.from(cells).map((c) => {
2422
2427
  const cellText = c.innerText?.trim().replace(/\n/g, " ") || "";
2423
2428
  return cellText.replace(/\|/g, "\\|") || "";
2424
2429
  }).join(" | ") + " |";
2425
- }).join("\n");
2430
+ }).filter((r) => r);
2431
+ if (mdRows.length === 0) return "";
2426
2432
  const headerRow = rows[0];
2427
- const headerCells = headerRow.querySelectorAll('th, [role="columnheader"], [class*="header"]');
2428
- const hasHeader = headerCells.length > 0;
2429
- if (hasHeader && mdRows) {
2430
- const headerCount = headerCells.length;
2431
- const sep = "| " + Array(headerCount).fill("---").join(" | ") + " |";
2432
- return mdRows.split("\n").map((line, i) => {
2433
- if (i === 0) return line + "\n" + sep;
2434
- return line;
2435
- }).join("\n");
2433
+ const headerCells = headerRow.querySelectorAll(':scope > th, :scope > [role="columnheader"]');
2434
+ if (headerCells.length > 0) {
2435
+ const sep = "| " + Array(headerCells.length).fill("---").join(" | ") + " |";
2436
+ return mdRows[0] + "\n" + sep + "\n" + mdRows.slice(1).join("\n");
2436
2437
  }
2437
- return mdRows;
2438
- }).join("\n\n");
2438
+ return mdRows.join("\n");
2439
+ }
2439
2440
  });
2440
2441
  content = htmlToMarkdown(html, { onlyMainContent: p.onlyMainContent });
2441
2442
  if (tablesMd) {
@@ -7367,7 +7368,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7367
7368
  params = result.data;
7368
7369
  }
7369
7370
  if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
7370
- const { forwardExec } = await import("./daemon-client-ZHO6NG36.js");
7371
+ const { forwardExec } = await import("./daemon-client-XXKMJZZ7.js");
7371
7372
  const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
7372
7373
  if (result) return result;
7373
7374
  }
@@ -10611,6 +10612,18 @@ async function handlePlugin(args, options, mode) {
10611
10612
  await (await getPluginLoader()).reloadPlugin(result.name);
10612
10613
  } catch {
10613
10614
  }
10615
+ try {
10616
+ const { daemonPing } = await import("./daemon-client-XXKMJZZ7.js");
10617
+ if (await daemonPing()) {
10618
+ await fetch("http://localhost:9224/rpc", {
10619
+ method: "POST",
10620
+ headers: { "Content-Type": "application/json" },
10621
+ body: JSON.stringify({ method: "plugins:reload", params: {} }),
10622
+ signal: AbortSignal.timeout(5e3)
10623
+ });
10624
+ }
10625
+ } catch {
10626
+ }
10614
10627
  outputResult(
10615
10628
  { ok: true, name: result.name, source: result.source, path: result.path },
10616
10629
  mode
@@ -10766,7 +10779,8 @@ async function handleRecord(args, options, mode) {
10766
10779
  }
10767
10780
  case "stop": {
10768
10781
  const sessionName = options.session || "default";
10769
- const result = await forwardRecordStop(sessionName);
10782
+ const output = options.output || options.o;
10783
+ const result = await forwardRecordStop(sessionName, output);
10770
10784
  if (!result.ok) {
10771
10785
  outputError(String(result.error || "Failed to stop recording"));
10772
10786
  return;
@@ -10775,6 +10789,7 @@ async function handleRecord(args, options, mode) {
10775
10789
  ok: true,
10776
10790
  message: "Recording stopped.",
10777
10791
  sessionName,
10792
+ output: result.output || (output || SessionRecorder.getRecordingsDir(sessionName) + "/recording.json"),
10778
10793
  actions: result.actions,
10779
10794
  network: result.network,
10780
10795
  durationMs: result.durationMs,
@@ -12888,7 +12903,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
12888
12903
  }
12889
12904
  const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
12890
12905
  if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
12891
- const { forwardExec } = await import("./daemon-client-ZHO6NG36.js");
12906
+ const { forwardExec } = await import("./daemon-client-XXKMJZZ7.js");
12892
12907
  const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
12893
12908
  const result = await forwardExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
12894
12909
  const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
@@ -0,0 +1,9 @@
1
+ import {
2
+ getPluginLoader,
3
+ resetPluginLoader
4
+ } from "./chunk-PHBK3TRN.js";
5
+ import "./chunk-KFQGP6VL.js";
6
+ export {
7
+ getPluginLoader,
8
+ resetPluginLoader
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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": {