@xbrowser/cli 1.4.3 → 1.4.4

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,7 +20,7 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-O4HCWMU2.js";
23
+ } from "./chunk-CFPPWKVO.js";
24
24
  import "./chunk-TNEN6VQ2.js";
25
25
  import "./chunk-GDKLH7ZY.js";
26
26
  import "./chunk-KFQGP6VL.js";
@@ -20,8 +20,8 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-JLSKMNMN.js";
24
- import "./chunk-WI3XE4W3.js";
23
+ } from "./chunk-X3FKWJV4.js";
24
+ import "./chunk-IDJ5NILK.js";
25
25
  import "./chunk-TNEN6VQ2.js";
26
26
  import "./chunk-GDKLH7ZY.js";
27
27
  import "./chunk-ABXMBNQ6.js";
@@ -20,8 +20,8 @@ import {
20
20
  saveSessionDiskMeta,
21
21
  setActivePage,
22
22
  touchSession
23
- } from "./chunk-J3VNBG25.js";
24
- import "./chunk-WI3XE4W3.js";
23
+ } from "./chunk-4W54GEMV.js";
24
+ import "./chunk-IDJ5NILK.js";
25
25
  import "./chunk-TNEN6VQ2.js";
26
26
  import "./chunk-GDKLH7ZY.js";
27
27
  import "./chunk-KFQGP6VL.js";
@@ -1167,11 +1167,21 @@ var XBPageImpl = class _XBPageImpl {
1167
1167
  }
1168
1168
  async goBack(opts = {}) {
1169
1169
  await this.evaluate("() => history.back()");
1170
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1170
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1171
+ });
1172
+ try {
1173
+ this._url = await this.evaluate("location.href");
1174
+ } catch {
1175
+ }
1171
1176
  }
1172
1177
  async goForward(opts = {}) {
1173
1178
  await this.evaluate("() => history.forward()");
1174
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1179
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1180
+ });
1181
+ try {
1182
+ this._url = await this.evaluate("location.href");
1183
+ } catch {
1184
+ }
1175
1185
  }
1176
1186
  async reload(opts = {}) {
1177
1187
  this._loadState = { loadFired: false, domContentFired: false, networkIdle: false };
@@ -14,7 +14,7 @@ import {
14
14
  scrollIntoView,
15
15
  waitForActionable,
16
16
  waitForNetworkIdle
17
- } from "./chunk-WI3XE4W3.js";
17
+ } from "./chunk-IDJ5NILK.js";
18
18
  import {
19
19
  connectToCDP,
20
20
  findChrome,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  launch
3
- } from "./chunk-WI3XE4W3.js";
3
+ } from "./chunk-IDJ5NILK.js";
4
4
  import {
5
5
  errMsg
6
6
  } from "./chunk-GDKLH7ZY.js";
@@ -1172,11 +1172,21 @@ var XBPageImpl = class _XBPageImpl {
1172
1172
  }
1173
1173
  async goBack(opts = {}) {
1174
1174
  await this.evaluate("() => history.back()");
1175
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1175
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1176
+ });
1177
+ try {
1178
+ this._url = await this.evaluate("location.href");
1179
+ } catch {
1180
+ }
1176
1181
  }
1177
1182
  async goForward(opts = {}) {
1178
1183
  await this.evaluate("() => history.forward()");
1179
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1184
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1185
+ });
1186
+ try {
1187
+ this._url = await this.evaluate("location.href");
1188
+ } catch {
1189
+ }
1180
1190
  }
1181
1191
  async reload(opts = {}) {
1182
1192
  this._loadState = { loadFired: false, domContentFired: false, networkIdle: false };
@@ -1166,11 +1166,21 @@ var XBPageImpl = class _XBPageImpl {
1166
1166
  }
1167
1167
  async goBack(opts = {}) {
1168
1168
  await this.evaluate("() => history.back()");
1169
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1169
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1170
+ });
1171
+ try {
1172
+ this._url = await this.evaluate("location.href");
1173
+ } catch {
1174
+ }
1170
1175
  }
1171
1176
  async goForward(opts = {}) {
1172
1177
  await this.evaluate("() => history.forward()");
1173
- await this.waitForLoadState(opts.waitUntil ?? "load", opts.timeout);
1178
+ await this.waitForLoadState(opts.waitUntil ?? "domcontentloaded", opts.timeout ?? 5e3).catch(() => {
1179
+ });
1180
+ try {
1181
+ this._url = await this.evaluate("location.href");
1182
+ } catch {
1183
+ }
1174
1184
  }
1175
1185
  async reload(opts = {}) {
1176
1186
  this._loadState = { loadFired: false, domContentFired: false, networkIdle: false };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  launch
3
- } from "./chunk-WI3XE4W3.js";
3
+ } from "./chunk-IDJ5NILK.js";
4
4
  import {
5
5
  errMsg
6
6
  } from "./chunk-GDKLH7ZY.js";
package/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  resolveLaunchOpts,
26
26
  saveSessionDiskMeta,
27
27
  setActivePage
28
- } from "./chunk-O4HCWMU2.js";
28
+ } from "./chunk-CFPPWKVO.js";
29
29
  import "./chunk-TNEN6VQ2.js";
30
30
  import {
31
31
  forwardCommandLog,
@@ -376,7 +376,8 @@ var backCommand = registerCommand({
376
376
  result: z.object({ url: z.string() }),
377
377
  handler: async (_p, ctx) => {
378
378
  await ctx.page.goBack();
379
- return ok({ url: ctx.page.url() });
379
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
380
+ return ok({ url });
380
381
  }
381
382
  });
382
383
  var forwardCommand = registerCommand({
@@ -386,7 +387,8 @@ var forwardCommand = registerCommand({
386
387
  result: z.object({ url: z.string() }),
387
388
  handler: async (_p, ctx) => {
388
389
  await ctx.page.goForward();
389
- return ok({ url: ctx.page.url() });
390
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
391
+ return ok({ url });
390
392
  }
391
393
  });
392
394
  var refreshCommand = registerCommand({
@@ -7075,7 +7077,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7075
7077
  }
7076
7078
  let targetPageOverride = null;
7077
7079
  if (_target && extraOpts?.cdpEndpoint) {
7078
- const { findTargetPage } = await import("./browser-B5W577GO.js");
7080
+ const { findTargetPage } = await import("./browser-DS24BWJW.js");
7079
7081
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
7080
7082
  if (!targetPageOverride) {
7081
7083
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -10026,6 +10028,12 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
10026
10028
  };
10027
10029
  break;
10028
10030
  }
10031
+ case "waitForTimeout":
10032
+ cmdName = "waitForTimeout";
10033
+ params = {
10034
+ timeout: args[0] ? Number(args[0]) : options.timeout ? Number(options.timeout) : 1e3
10035
+ };
10036
+ break;
10029
10037
  default:
10030
10038
  cmdName = command;
10031
10039
  params = { ...options };
@@ -12444,7 +12452,7 @@ async function routeCommand(argvIn, stdinCommands) {
12444
12452
  const mode = options.json ? "json" : options.yaml ? "yaml" : "text";
12445
12453
  const sessionName = options.session || process.env.XBROWSER_SESSION || "default";
12446
12454
  const cdpEndpoint = options.cdp || process.env.XBROWSER_CDP;
12447
- if (options.version || options.v) {
12455
+ if (options.version) {
12448
12456
  console.log(`xbrowser v${version}`);
12449
12457
  return;
12450
12458
  }
@@ -13041,7 +13049,7 @@ async function main() {
13041
13049
  const command = process.argv[2];
13042
13050
  const isLongRunning = command === "preview" || command === "serve";
13043
13051
  if (!isLongRunning) {
13044
- const { ensureProcessCanExit } = await import("./browser-B5W577GO.js");
13052
+ const { ensureProcessCanExit } = await import("./browser-DS24BWJW.js");
13045
13053
  await ensureProcessCanExit().catch(() => {
13046
13054
  });
13047
13055
  process.exit(exitCode);
@@ -21,8 +21,8 @@ import {
21
21
  resolveLaunchOpts,
22
22
  saveSessionDiskMeta,
23
23
  setActivePage
24
- } from "./chunk-J3VNBG25.js";
25
- import "./chunk-WI3XE4W3.js";
24
+ } from "./chunk-4W54GEMV.js";
25
+ import "./chunk-IDJ5NILK.js";
26
26
  import "./chunk-TNEN6VQ2.js";
27
27
  import {
28
28
  getPluginLoader
@@ -337,7 +337,8 @@ var backCommand = registerCommand({
337
337
  result: z.object({ url: z.string() }),
338
338
  handler: async (_p, ctx) => {
339
339
  await ctx.page.goBack();
340
- return ok({ url: ctx.page.url() });
340
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
341
+ return ok({ url });
341
342
  }
342
343
  });
343
344
  var forwardCommand = registerCommand({
@@ -347,7 +348,8 @@ var forwardCommand = registerCommand({
347
348
  result: z.object({ url: z.string() }),
348
349
  handler: async (_p, ctx) => {
349
350
  await ctx.page.goForward();
350
- return ok({ url: ctx.page.url() });
351
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
352
+ return ok({ url });
351
353
  }
352
354
  });
353
355
  var refreshCommand = registerCommand({
@@ -6606,7 +6608,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
6606
6608
  }
6607
6609
  let targetPageOverride = null;
6608
6610
  if (_target && extraOpts?.cdpEndpoint) {
6609
- const { findTargetPage } = await import("./browser-VWKGCFA5.js");
6611
+ const { findTargetPage } = await import("./browser-YKJO3BOQ.js");
6610
6612
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
6611
6613
  if (!targetPageOverride) {
6612
6614
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -8322,7 +8324,7 @@ function createRPCHandler() {
8322
8324
  const isNewFormat = Array.isArray(parsed.actions);
8323
8325
  if (isNewFormat) {
8324
8326
  try {
8325
- const { SessionReplayer } = await import("./session-replayer-X3S47AA3.js");
8327
+ const { SessionReplayer } = await import("./session-replayer-F4ORJMCL.js");
8326
8328
  const replayer = new SessionReplayer({
8327
8329
  page: session.page,
8328
8330
  stepDelay: slowMo * 500,
package/dist/index.js CHANGED
@@ -81,8 +81,8 @@ import {
81
81
  resolveLaunchOpts,
82
82
  saveSessionDiskMeta,
83
83
  setActivePage
84
- } from "./chunk-JLSKMNMN.js";
85
- import "./chunk-WI3XE4W3.js";
84
+ } from "./chunk-X3FKWJV4.js";
85
+ import "./chunk-IDJ5NILK.js";
86
86
  import "./chunk-TNEN6VQ2.js";
87
87
  import {
88
88
  errMsg
@@ -416,7 +416,8 @@ var backCommand = registerCommand({
416
416
  result: z.object({ url: z.string() }),
417
417
  handler: async (_p, ctx) => {
418
418
  await ctx.page.goBack();
419
- return ok({ url: ctx.page.url() });
419
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
420
+ return ok({ url });
420
421
  }
421
422
  });
422
423
  var forwardCommand = registerCommand({
@@ -426,7 +427,8 @@ var forwardCommand = registerCommand({
426
427
  result: z.object({ url: z.string() }),
427
428
  handler: async (_p, ctx) => {
428
429
  await ctx.page.goForward();
429
- return ok({ url: ctx.page.url() });
430
+ const url = await ctx.page.evaluate("location.href").catch(() => ctx.page.url());
431
+ return ok({ url });
430
432
  }
431
433
  });
432
434
  var refreshCommand = registerCommand({
@@ -7395,7 +7397,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
7395
7397
  }
7396
7398
  let targetPageOverride = null;
7397
7399
  if (_target && extraOpts?.cdpEndpoint) {
7398
- const { findTargetPage } = await import("./browser-MPMDAGZY.js");
7400
+ const { findTargetPage } = await import("./browser-KBUORWR3.js");
7399
7401
  targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
7400
7402
  if (!targetPageOverride) {
7401
7403
  return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
@@ -10366,6 +10368,12 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
10366
10368
  };
10367
10369
  break;
10368
10370
  }
10371
+ case "waitForTimeout":
10372
+ cmdName = "waitForTimeout";
10373
+ params = {
10374
+ timeout: args[0] ? Number(args[0]) : options.timeout ? Number(options.timeout) : 1e3
10375
+ };
10376
+ break;
10369
10377
  default:
10370
10378
  cmdName = command;
10371
10379
  params = { ...options };
@@ -12784,7 +12792,7 @@ async function routeCommand(argvIn, stdinCommands) {
12784
12792
  const mode = options.json ? "json" : options.yaml ? "yaml" : "text";
12785
12793
  const sessionName = options.session || process.env.XBROWSER_SESSION || "default";
12786
12794
  const cdpEndpoint = options.cdp || process.env.XBROWSER_CDP;
12787
- if (options.version || options.v) {
12795
+ if (options.version) {
12788
12796
  console.log(`xbrowser v${version}`);
12789
12797
  return;
12790
12798
  }
@@ -16168,7 +16176,7 @@ var DataCollector = class {
16168
16176
  return results;
16169
16177
  }
16170
16178
  async createBrowserContext() {
16171
- const { launch } = await import("./cdp-driver-RCRYKHVQ.js");
16179
+ const { launch } = await import("./cdp-driver-VRXHK6P6.js");
16172
16180
  const { browser } = await launch({
16173
16181
  headless: true,
16174
16182
  args: ["--no-sandbox", "--disable-setuid-sandbox"]
@@ -31,7 +31,7 @@ var SessionReplayer = class {
31
31
  if (this.opts.page) {
32
32
  this.page = this.opts.page;
33
33
  } else if (this.opts.cdpUrl) {
34
- const { launch } = await import("./cdp-driver-RCRYKHVQ.js");
34
+ const { launch } = await import("./cdp-driver-VRXHK6P6.js");
35
35
  const { browser } = await launch({ cdpEndpoint: this.opts.cdpUrl });
36
36
  let contexts = browser.contexts();
37
37
  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.4.3",
3
+ "version": "1.4.4",
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": {