browser-pilot 0.0.13 → 0.0.15
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/README.md +82 -617
- package/dist/actions.cjs +1438 -17
- package/dist/actions.d.cts +21 -3
- package/dist/actions.d.ts +21 -3
- package/dist/actions.mjs +1 -1
- package/dist/browser-MEWT75IB.mjs +11 -0
- package/dist/browser.cjs +1583 -22
- package/dist/browser.d.cts +12 -3
- package/dist/browser.d.ts +12 -3
- package/dist/browser.mjs +3 -3
- package/dist/cdp.cjs +36 -3
- package/dist/cdp.d.cts +1 -1
- package/dist/cdp.d.ts +1 -1
- package/dist/cdp.mjs +3 -1
- package/dist/{chunk-A2ZRAEO3.mjs → chunk-7YVCOL2W.mjs} +1428 -17
- package/dist/chunk-BVZALQT4.mjs +303 -0
- package/dist/chunk-DTVRFXKI.mjs +35 -0
- package/dist/{chunk-HP6R3W32.mjs → chunk-LCNFBXB5.mjs} +33 -6
- package/dist/chunk-LUGLEMVR.mjs +11 -0
- package/dist/chunk-USYSHCI3.mjs +8640 -0
- package/dist/chunk-WPNW23CE.mjs +466 -0
- package/dist/{chunk-VDAMDOS6.mjs → chunk-ZAXQ5OTV.mjs} +151 -7
- package/dist/cli.mjs +3225 -8434
- package/dist/{client-DRqxBdHv.d.ts → client-B5QBRgIy.d.cts} +10 -6
- package/dist/{client-DRqxBdHv.d.cts → client-B5QBRgIy.d.ts} +10 -6
- package/dist/client-JWWZWO6L.mjs +12 -0
- package/dist/index.cjs +1629 -24
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/page-XPS6IC6V.mjs +7 -0
- package/dist/transport-WHEBAZUP.mjs +83 -0
- package/dist/{types-CzgQjai9.d.ts → types-C9ySEdOX.d.cts} +78 -4
- package/dist/{types-BXMGFtnB.d.cts → types-Cvvf0oGu.d.ts} +78 -4
- package/package.json +2 -2
package/dist/browser.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-B5QBRgIy.cjs';
|
|
2
2
|
import { TargetInfo } from './cdp.cjs';
|
|
3
3
|
import { b as ConnectOptions } from './types--wXNHUwt.cjs';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { J as Page } from './types-C9ySEdOX.cjs';
|
|
5
|
+
export { l as ActionOptions, m as ActionResult, n as ConsoleHandler, o as ConsoleMessage, p as ConsoleMessageType, q as CustomSelectConfig, D as Dialog, r as DialogHandler, s as DialogType, t as Download, E as ElementInfo, u as ElementNotFoundError, v as EmulationState, w as ErrorHandler, ai as FailureHint, F as FileInput, x as FillOptions, y as FormField, z as FormOption, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, H as NetworkIdleOptions, K as PageError, L as PageSnapshot, M as SnapshotNode, O as SnapshotOptions, Q as SubmitOptions, T as TimeoutError, U as TypeOptions, V as UserAgentMetadata, W as UserAgentOptions, X as ViewportOptions, Y as WaitForOptions } from './types-C9ySEdOX.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Browser class - manages CDP connection and pages
|
|
@@ -34,6 +34,15 @@ declare class Browser {
|
|
|
34
34
|
private pages;
|
|
35
35
|
private pageCounter;
|
|
36
36
|
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Create a Browser from an existing CDPClient (used by daemon fast-path).
|
|
39
|
+
* The caller is responsible for the CDP connection lifecycle.
|
|
40
|
+
*/
|
|
41
|
+
static fromCDP(cdp: CDPClient, sessionInfo: {
|
|
42
|
+
wsUrl: string;
|
|
43
|
+
provider?: string;
|
|
44
|
+
sessionId?: string;
|
|
45
|
+
}): Browser;
|
|
37
46
|
/**
|
|
38
47
|
* Connect to a browser instance
|
|
39
48
|
*/
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-B5QBRgIy.js';
|
|
2
2
|
import { TargetInfo } from './cdp.js';
|
|
3
3
|
import { b as ConnectOptions } from './types--wXNHUwt.js';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { J as Page } from './types-Cvvf0oGu.js';
|
|
5
|
+
export { l as ActionOptions, m as ActionResult, n as ConsoleHandler, o as ConsoleMessage, p as ConsoleMessageType, q as CustomSelectConfig, D as Dialog, r as DialogHandler, s as DialogType, t as Download, E as ElementInfo, u as ElementNotFoundError, v as EmulationState, w as ErrorHandler, ai as FailureHint, F as FileInput, x as FillOptions, y as FormField, z as FormOption, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, H as NetworkIdleOptions, K as PageError, L as PageSnapshot, M as SnapshotNode, O as SnapshotOptions, Q as SubmitOptions, T as TimeoutError, U as TypeOptions, V as UserAgentMetadata, W as UserAgentOptions, X as ViewportOptions, Y as WaitForOptions } from './types-Cvvf0oGu.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Browser class - manages CDP connection and pages
|
|
@@ -34,6 +34,15 @@ declare class Browser {
|
|
|
34
34
|
private pages;
|
|
35
35
|
private pageCounter;
|
|
36
36
|
private constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Create a Browser from an existing CDPClient (used by daemon fast-path).
|
|
39
|
+
* The caller is responsible for the CDP connection lifecycle.
|
|
40
|
+
*/
|
|
41
|
+
static fromCDP(cdp: CDPClient, sessionInfo: {
|
|
42
|
+
wsUrl: string;
|
|
43
|
+
provider?: string;
|
|
44
|
+
sessionId?: string;
|
|
45
|
+
}): Browser;
|
|
37
46
|
/**
|
|
38
47
|
* Connect to a browser instance
|
|
39
48
|
*/
|
package/dist/browser.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
Browser,
|
|
3
3
|
Page,
|
|
4
4
|
connect
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ZAXQ5OTV.mjs";
|
|
6
|
+
import "./chunk-BVZALQT4.mjs";
|
|
7
7
|
import "./chunk-BRAFQUMG.mjs";
|
|
8
8
|
import {
|
|
9
9
|
ElementNotFoundError,
|
|
10
10
|
NavigationError,
|
|
11
11
|
TimeoutError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7YVCOL2W.mjs";
|
|
13
13
|
import "./chunk-JXAUPHZM.mjs";
|
|
14
14
|
export {
|
|
15
15
|
Browser,
|
package/dist/cdp.cjs
CHANGED
|
@@ -22,10 +22,16 @@ var cdp_exports = {};
|
|
|
22
22
|
__export(cdp_exports, {
|
|
23
23
|
CDPError: () => CDPError,
|
|
24
24
|
createCDPClient: () => createCDPClient,
|
|
25
|
+
createCDPClientFromTransport: () => createCDPClientFromTransport,
|
|
25
26
|
createTransport: () => createTransport
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(cdp_exports);
|
|
28
29
|
|
|
30
|
+
// src/utils/json.ts
|
|
31
|
+
function isRecord(value) {
|
|
32
|
+
return typeof value === "object" && value !== null;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
// src/cdp/protocol.ts
|
|
30
36
|
var CDPError = class extends Error {
|
|
31
37
|
code;
|
|
@@ -140,9 +146,16 @@ function getReadyStateString(state) {
|
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
// src/cdp/client.ts
|
|
149
|
+
function createCDPClientFromTransport(transport, options = {}) {
|
|
150
|
+
return buildCDPClient(transport, options);
|
|
151
|
+
}
|
|
143
152
|
async function createCDPClient(wsUrl, options = {}) {
|
|
144
|
-
const {
|
|
153
|
+
const { timeout = 3e4 } = options;
|
|
145
154
|
const transport = await createTransport(wsUrl, { timeout });
|
|
155
|
+
return buildCDPClient(transport, options);
|
|
156
|
+
}
|
|
157
|
+
function buildCDPClient(transport, options = {}) {
|
|
158
|
+
const { debug = false, timeout = 3e4 } = options;
|
|
146
159
|
let messageId = 0;
|
|
147
160
|
let currentSessionId;
|
|
148
161
|
let connected = true;
|
|
@@ -152,7 +165,19 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
152
165
|
transport.onMessage((raw) => {
|
|
153
166
|
let msg;
|
|
154
167
|
try {
|
|
155
|
-
|
|
168
|
+
const parsed = JSON.parse(raw);
|
|
169
|
+
if (!isRecord(parsed)) {
|
|
170
|
+
if (debug) console.error("[CDP] Ignoring non-object message:", raw);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if ("id" in parsed && typeof parsed["id"] === "number") {
|
|
174
|
+
msg = parsed;
|
|
175
|
+
} else if ("method" in parsed && typeof parsed["method"] === "string") {
|
|
176
|
+
msg = parsed;
|
|
177
|
+
} else {
|
|
178
|
+
if (debug) console.error("[CDP] Ignoring invalid message shape:", raw);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
156
181
|
} catch {
|
|
157
182
|
if (debug) console.error("[CDP] Failed to parse message:", raw);
|
|
158
183
|
return;
|
|
@@ -167,7 +192,8 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
167
192
|
pending.delete(response.id);
|
|
168
193
|
clearTimeout(request.timer);
|
|
169
194
|
if (response.error) {
|
|
170
|
-
|
|
195
|
+
const error = typeof response.error === "string" ? { code: -32e3, message: response.error } : response.error;
|
|
196
|
+
request.reject(new CDPError(error));
|
|
171
197
|
} else {
|
|
172
198
|
request.resolve(response.result);
|
|
173
199
|
}
|
|
@@ -265,6 +291,9 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
265
291
|
onAny(handler) {
|
|
266
292
|
anyEventHandlers.add(handler);
|
|
267
293
|
},
|
|
294
|
+
offAny(handler) {
|
|
295
|
+
anyEventHandlers.delete(handler);
|
|
296
|
+
},
|
|
268
297
|
async close() {
|
|
269
298
|
connected = false;
|
|
270
299
|
await transport.close();
|
|
@@ -280,6 +309,9 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
280
309
|
get sessionId() {
|
|
281
310
|
return currentSessionId;
|
|
282
311
|
},
|
|
312
|
+
setSessionId(sessionId) {
|
|
313
|
+
currentSessionId = sessionId;
|
|
314
|
+
},
|
|
283
315
|
get isConnected() {
|
|
284
316
|
return connected;
|
|
285
317
|
}
|
|
@@ -290,5 +322,6 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
290
322
|
0 && (module.exports = {
|
|
291
323
|
CDPError,
|
|
292
324
|
createCDPClient,
|
|
325
|
+
createCDPClientFromTransport,
|
|
293
326
|
createTransport
|
|
294
327
|
});
|
package/dist/cdp.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CDPClient, a as CDPClientOptions, T as Transport,
|
|
1
|
+
export { C as CDPClient, a as CDPClientOptions, T as Transport, e as TransportOptions, c as createCDPClient, b as createCDPClientFromTransport, d as createTransport } from './client-B5QBRgIy.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,
|
|
1
|
+
export { C as CDPClient, a as CDPClientOptions, T as Transport, e as TransportOptions, c as createCDPClient, b as createCDPClientFromTransport, d as createTransport } from './client-B5QBRgIy.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* CDP Protocol type definitions
|
package/dist/cdp.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCDPClient,
|
|
3
|
+
createCDPClientFromTransport,
|
|
3
4
|
createTransport
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BVZALQT4.mjs";
|
|
5
6
|
import {
|
|
6
7
|
CDPError
|
|
7
8
|
} from "./chunk-JXAUPHZM.mjs";
|
|
8
9
|
export {
|
|
9
10
|
CDPError,
|
|
10
11
|
createCDPClient,
|
|
12
|
+
createCDPClientFromTransport,
|
|
11
13
|
createTransport
|
|
12
14
|
};
|