browser-pilot 0.0.11 → 0.0.13

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.
@@ -1,7 +1,8 @@
1
- import { C as CDPClient } from './client-7Nqka5MV.cjs';
1
+ import { C as CDPClient } from './client-DRqxBdHv.cjs';
2
+ import { TargetInfo } from './cdp.cjs';
2
3
  import { b as ConnectOptions } from './types--wXNHUwt.cjs';
3
- import { y as Page } from './types-GWuQJs_e.cjs';
4
- export { k as ActionOptions, l as ActionResult, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, p as CustomSelectConfig, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, ae as FailureHint, F as FileInput, w as FillOptions, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, x as NetworkIdleOptions, z as PageError, H as PageSnapshot, J as SnapshotNode, K as SubmitOptions, T as TimeoutError, L as TypeOptions, U as UserAgentMetadata, M as UserAgentOptions, V as ViewportOptions, W as WaitForOptions } from './types-GWuQJs_e.cjs';
4
+ import { H as Page } from './types-BXMGFtnB.cjs';
5
+ export { k as ActionOptions, l as ActionResult, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, p as CustomSelectConfig, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, ah as FailureHint, F as FileInput, w as FillOptions, x as FormField, y as FormOption, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, z as NetworkIdleOptions, J as PageError, K as PageSnapshot, L as SnapshotNode, M as SnapshotOptions, O as SubmitOptions, T as TimeoutError, Q as TypeOptions, U as UserAgentMetadata, V as UserAgentOptions, W as ViewportOptions, X as WaitForOptions } from './types-BXMGFtnB.cjs';
5
6
 
6
7
  /**
7
8
  * Browser class - manages CDP connection and pages
@@ -31,6 +32,7 @@ declare class Browser {
31
32
  private cdp;
32
33
  private providerSession;
33
34
  private pages;
35
+ private pageCounter;
34
36
  private constructor();
35
37
  /**
36
38
  * Connect to a browser instance
@@ -54,6 +56,10 @@ declare class Browser {
54
56
  * Close a page by name
55
57
  */
56
58
  closePage(name: string): Promise<void>;
59
+ /**
60
+ * List all page targets in the connected browser.
61
+ */
62
+ listTargets(): Promise<TargetInfo[]>;
57
63
  /**
58
64
  * Get the WebSocket URL for this browser connection
59
65
  */
package/dist/browser.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { C as CDPClient } from './client-7Nqka5MV.js';
1
+ import { C as CDPClient } from './client-DRqxBdHv.js';
2
+ import { TargetInfo } from './cdp.js';
2
3
  import { b as ConnectOptions } from './types--wXNHUwt.js';
3
- import { y as Page } from './types-DtGF3yGl.js';
4
- export { k as ActionOptions, l as ActionResult, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, p as CustomSelectConfig, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, ae as FailureHint, F as FileInput, w as FillOptions, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, x as NetworkIdleOptions, z as PageError, H as PageSnapshot, J as SnapshotNode, K as SubmitOptions, T as TimeoutError, L as TypeOptions, U as UserAgentMetadata, M as UserAgentOptions, V as ViewportOptions, W as WaitForOptions } from './types-DtGF3yGl.js';
4
+ import { H as Page } from './types-CzgQjai9.js';
5
+ export { k as ActionOptions, l as ActionResult, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, p as CustomSelectConfig, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, ah as FailureHint, F as FileInput, w as FillOptions, x as FormField, y as FormOption, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, z as NetworkIdleOptions, J as PageError, K as PageSnapshot, L as SnapshotNode, M as SnapshotOptions, O as SubmitOptions, T as TimeoutError, Q as TypeOptions, U as UserAgentMetadata, V as UserAgentOptions, W as ViewportOptions, X as WaitForOptions } from './types-CzgQjai9.js';
5
6
 
6
7
  /**
7
8
  * Browser class - manages CDP connection and pages
@@ -31,6 +32,7 @@ declare class Browser {
31
32
  private cdp;
32
33
  private providerSession;
33
34
  private pages;
35
+ private pageCounter;
34
36
  private constructor();
35
37
  /**
36
38
  * Connect to a browser instance
@@ -54,6 +56,10 @@ declare class Browser {
54
56
  * Close a page by name
55
57
  */
56
58
  closePage(name: string): Promise<void>;
59
+ /**
60
+ * List all page targets in the connected browser.
61
+ */
62
+ listTargets(): Promise<TargetInfo[]>;
57
63
  /**
58
64
  * Get the WebSocket URL for this browser connection
59
65
  */
package/dist/browser.mjs CHANGED
@@ -2,14 +2,15 @@ import {
2
2
  Browser,
3
3
  Page,
4
4
  connect
5
- } from "./chunk-JHAF52FA.mjs";
6
- import "./chunk-BCOZUKWS.mjs";
5
+ } from "./chunk-VDAMDOS6.mjs";
6
+ import "./chunk-HP6R3W32.mjs";
7
7
  import "./chunk-BRAFQUMG.mjs";
8
8
  import {
9
9
  ElementNotFoundError,
10
10
  NavigationError,
11
11
  TimeoutError
12
- } from "./chunk-FAUNIZR7.mjs";
12
+ } from "./chunk-A2ZRAEO3.mjs";
13
+ import "./chunk-JXAUPHZM.mjs";
13
14
  export {
14
15
  Browser,
15
16
  ElementNotFoundError,
package/dist/cdp.cjs CHANGED
@@ -67,13 +67,28 @@ function createTransport(wsUrl, options = {}) {
67
67
  resolveClose();
68
68
  return;
69
69
  }
70
- const onClose = () => {
70
+ let settled = false;
71
+ let fallbackTimer;
72
+ const finish = () => {
73
+ if (settled) return;
74
+ settled = true;
75
+ if (fallbackTimer) clearTimeout(fallbackTimer);
71
76
  ws.removeEventListener("close", onClose);
72
77
  resolveClose();
73
78
  };
79
+ const onClose = () => {
80
+ finish();
81
+ };
74
82
  ws.addEventListener("close", onClose);
75
- ws.close();
76
- setTimeout(resolveClose, 5e3);
83
+ try {
84
+ if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING) {
85
+ ws.close();
86
+ }
87
+ } catch {
88
+ finish();
89
+ return;
90
+ }
91
+ fallbackTimer = setTimeout(finish, 200);
77
92
  });
78
93
  },
79
94
  onMessage(handler) {
@@ -198,7 +213,7 @@ async function createCDPClient(wsUrl, options = {}) {
198
213
  throw new Error("CDP client is not connected");
199
214
  }
200
215
  const id = ++messageId;
201
- const effectiveSessionId = sessionId ?? currentSessionId;
216
+ const effectiveSessionId = sessionId === null ? void 0 : sessionId ?? currentSessionId;
202
217
  const request = { id, method };
203
218
  if (params !== void 0) {
204
219
  request.params = params;
package/dist/cdp.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as CDPClient, a as CDPClientOptions, T as Transport, d as TransportOptions, c as createCDPClient, b as createTransport } from './client-7Nqka5MV.cjs';
1
+ export { C as CDPClient, a as CDPClientOptions, T as Transport, d as TransportOptions, c as createCDPClient, b as createTransport } from './client-DRqxBdHv.cjs';
2
2
 
3
3
  /**
4
4
  * CDP Protocol type definitions
package/dist/cdp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as CDPClient, a as CDPClientOptions, T as Transport, d as TransportOptions, c as createCDPClient, b as createTransport } from './client-7Nqka5MV.js';
1
+ export { C as CDPClient, a as CDPClientOptions, T as Transport, d as TransportOptions, c as createCDPClient, b as createTransport } from './client-DRqxBdHv.js';
2
2
 
3
3
  /**
4
4
  * CDP Protocol type definitions
package/dist/cdp.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import {
2
- CDPError,
3
2
  createCDPClient,
4
3
  createTransport
5
- } from "./chunk-BCOZUKWS.mjs";
4
+ } from "./chunk-HP6R3W32.mjs";
5
+ import {
6
+ CDPError
7
+ } from "./chunk-JXAUPHZM.mjs";
6
8
  export {
7
9
  CDPError,
8
10
  createCDPClient,