browser-pilot 0.0.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.
- package/LICENSE +21 -0
- package/README.md +539 -0
- package/dist/actions.cjs +277 -0
- package/dist/actions.d.cts +33 -0
- package/dist/actions.d.ts +33 -0
- package/dist/actions.mjs +8 -0
- package/dist/browser.cjs +2765 -0
- package/dist/browser.d.cts +71 -0
- package/dist/browser.d.ts +71 -0
- package/dist/browser.mjs +19 -0
- package/dist/cdp.cjs +279 -0
- package/dist/cdp.d.cts +230 -0
- package/dist/cdp.d.ts +230 -0
- package/dist/cdp.mjs +10 -0
- package/dist/chunk-BCOZUKWS.mjs +251 -0
- package/dist/chunk-FI55U7JS.mjs +2108 -0
- package/dist/chunk-R3PS4PCM.mjs +207 -0
- package/dist/chunk-YEHK2XY3.mjs +250 -0
- package/dist/chunk-ZIQA4JOT.mjs +226 -0
- package/dist/cli.cjs +3587 -0
- package/dist/cli.d.cts +23 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.mjs +827 -0
- package/dist/client-7Nqka5MV.d.cts +53 -0
- package/dist/client-7Nqka5MV.d.ts +53 -0
- package/dist/index.cjs +3074 -0
- package/dist/index.d.cts +157 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.mjs +64 -0
- package/dist/providers.cjs +238 -0
- package/dist/providers.d.cts +86 -0
- package/dist/providers.d.ts +86 -0
- package/dist/providers.mjs +16 -0
- package/dist/types-Cs89wle0.d.cts +925 -0
- package/dist/types-DL_-3BZk.d.ts +925 -0
- package/dist/types-D_uDqh0Z.d.cts +56 -0
- package/dist/types-D_uDqh0Z.d.ts +56 -0
- package/package.json +91 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { C as CDPClient } from './client-7Nqka5MV.cjs';
|
|
2
|
+
import { C as ConnectOptions } from './types-D_uDqh0Z.cjs';
|
|
3
|
+
import { P as Page } from './types-Cs89wle0.cjs';
|
|
4
|
+
export { d as ActionOptions, e as ActionResult, C as ConsoleHandler, f as ConsoleMessage, g as ConsoleMessageType, h as CustomSelectConfig, D as Dialog, i as DialogHandler, j as DialogType, k as Download, E as ElementInfo, l as ElementNotFoundError, m as EmulationState, n as ErrorHandler, F as FileInput, o as FillOptions, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, p as NetworkIdleOptions, q as PageError, r as PageSnapshot, s as SnapshotNode, t as SubmitOptions, T as TimeoutError, u as TypeOptions, U as UserAgentMetadata, v as UserAgentOptions, V as ViewportOptions, W as WaitForOptions } from './types-Cs89wle0.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Browser class - manages CDP connection and pages
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface BrowserOptions extends ConnectOptions {
|
|
11
|
+
/** Enable debug logging */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare class Browser {
|
|
15
|
+
private cdp;
|
|
16
|
+
private providerSession;
|
|
17
|
+
private pages;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Connect to a browser instance
|
|
21
|
+
*/
|
|
22
|
+
static connect(options: BrowserOptions): Promise<Browser>;
|
|
23
|
+
/**
|
|
24
|
+
* Get or create a page by name
|
|
25
|
+
* If no name is provided, returns the first available page or creates a new one
|
|
26
|
+
*/
|
|
27
|
+
page(name?: string): Promise<Page>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new page (tab)
|
|
30
|
+
*/
|
|
31
|
+
newPage(url?: string): Promise<Page>;
|
|
32
|
+
/**
|
|
33
|
+
* Close a page by name
|
|
34
|
+
*/
|
|
35
|
+
closePage(name: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the WebSocket URL for this browser connection
|
|
38
|
+
*/
|
|
39
|
+
get wsUrl(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get the provider session ID (for resumption)
|
|
42
|
+
*/
|
|
43
|
+
get sessionId(): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get provider metadata
|
|
46
|
+
*/
|
|
47
|
+
get metadata(): Record<string, unknown> | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Check if connected
|
|
50
|
+
*/
|
|
51
|
+
get isConnected(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Disconnect from the browser (keeps provider session alive for reconnection)
|
|
54
|
+
*/
|
|
55
|
+
disconnect(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Close the browser session completely
|
|
58
|
+
*/
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the underlying CDP client (for advanced usage)
|
|
62
|
+
*/
|
|
63
|
+
get cdpClient(): CDPClient;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Connect to a browser instance
|
|
67
|
+
* Convenience function for Browser.connect()
|
|
68
|
+
*/
|
|
69
|
+
declare function connect(options: BrowserOptions): Promise<Browser>;
|
|
70
|
+
|
|
71
|
+
export { Browser, type BrowserOptions, Page, connect };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { C as CDPClient } from './client-7Nqka5MV.js';
|
|
2
|
+
import { C as ConnectOptions } from './types-D_uDqh0Z.js';
|
|
3
|
+
import { P as Page } from './types-DL_-3BZk.js';
|
|
4
|
+
export { d as ActionOptions, e as ActionResult, C as ConsoleHandler, f as ConsoleMessage, g as ConsoleMessageType, h as CustomSelectConfig, D as Dialog, i as DialogHandler, j as DialogType, k as Download, E as ElementInfo, l as ElementNotFoundError, m as EmulationState, n as ErrorHandler, F as FileInput, o as FillOptions, G as GeolocationOptions, I as InteractiveElement, N as NavigationError, p as NetworkIdleOptions, q as PageError, r as PageSnapshot, s as SnapshotNode, t as SubmitOptions, T as TimeoutError, u as TypeOptions, U as UserAgentMetadata, v as UserAgentOptions, V as ViewportOptions, W as WaitForOptions } from './types-DL_-3BZk.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Browser class - manages CDP connection and pages
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface BrowserOptions extends ConnectOptions {
|
|
11
|
+
/** Enable debug logging */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare class Browser {
|
|
15
|
+
private cdp;
|
|
16
|
+
private providerSession;
|
|
17
|
+
private pages;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Connect to a browser instance
|
|
21
|
+
*/
|
|
22
|
+
static connect(options: BrowserOptions): Promise<Browser>;
|
|
23
|
+
/**
|
|
24
|
+
* Get or create a page by name
|
|
25
|
+
* If no name is provided, returns the first available page or creates a new one
|
|
26
|
+
*/
|
|
27
|
+
page(name?: string): Promise<Page>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new page (tab)
|
|
30
|
+
*/
|
|
31
|
+
newPage(url?: string): Promise<Page>;
|
|
32
|
+
/**
|
|
33
|
+
* Close a page by name
|
|
34
|
+
*/
|
|
35
|
+
closePage(name: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the WebSocket URL for this browser connection
|
|
38
|
+
*/
|
|
39
|
+
get wsUrl(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get the provider session ID (for resumption)
|
|
42
|
+
*/
|
|
43
|
+
get sessionId(): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get provider metadata
|
|
46
|
+
*/
|
|
47
|
+
get metadata(): Record<string, unknown> | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Check if connected
|
|
50
|
+
*/
|
|
51
|
+
get isConnected(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Disconnect from the browser (keeps provider session alive for reconnection)
|
|
54
|
+
*/
|
|
55
|
+
disconnect(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Close the browser session completely
|
|
58
|
+
*/
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the underlying CDP client (for advanced usage)
|
|
62
|
+
*/
|
|
63
|
+
get cdpClient(): CDPClient;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Connect to a browser instance
|
|
67
|
+
* Convenience function for Browser.connect()
|
|
68
|
+
*/
|
|
69
|
+
declare function connect(options: BrowserOptions): Promise<Browser>;
|
|
70
|
+
|
|
71
|
+
export { Browser, type BrowserOptions, Page, connect };
|
package/dist/browser.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Browser,
|
|
3
|
+
ElementNotFoundError,
|
|
4
|
+
NavigationError,
|
|
5
|
+
Page,
|
|
6
|
+
TimeoutError,
|
|
7
|
+
connect
|
|
8
|
+
} from "./chunk-FI55U7JS.mjs";
|
|
9
|
+
import "./chunk-BCOZUKWS.mjs";
|
|
10
|
+
import "./chunk-R3PS4PCM.mjs";
|
|
11
|
+
import "./chunk-YEHK2XY3.mjs";
|
|
12
|
+
export {
|
|
13
|
+
Browser,
|
|
14
|
+
ElementNotFoundError,
|
|
15
|
+
NavigationError,
|
|
16
|
+
Page,
|
|
17
|
+
TimeoutError,
|
|
18
|
+
connect
|
|
19
|
+
};
|
package/dist/cdp.cjs
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/cdp/index.ts
|
|
21
|
+
var cdp_exports = {};
|
|
22
|
+
__export(cdp_exports, {
|
|
23
|
+
CDPError: () => CDPError,
|
|
24
|
+
createCDPClient: () => createCDPClient,
|
|
25
|
+
createTransport: () => createTransport
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(cdp_exports);
|
|
28
|
+
|
|
29
|
+
// src/cdp/protocol.ts
|
|
30
|
+
var CDPError = class extends Error {
|
|
31
|
+
code;
|
|
32
|
+
data;
|
|
33
|
+
constructor(error) {
|
|
34
|
+
super(error.message);
|
|
35
|
+
this.name = "CDPError";
|
|
36
|
+
this.code = error.code;
|
|
37
|
+
this.data = error.data;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/cdp/transport.ts
|
|
42
|
+
function createTransport(wsUrl, options = {}) {
|
|
43
|
+
const { timeout = 3e4 } = options;
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const timeoutId = setTimeout(() => {
|
|
46
|
+
reject(new Error(`WebSocket connection timeout after ${timeout}ms`));
|
|
47
|
+
}, timeout);
|
|
48
|
+
const ws = new WebSocket(wsUrl);
|
|
49
|
+
const messageHandlers = [];
|
|
50
|
+
const closeHandlers = [];
|
|
51
|
+
const errorHandlers = [];
|
|
52
|
+
ws.addEventListener("open", () => {
|
|
53
|
+
clearTimeout(timeoutId);
|
|
54
|
+
const transport = {
|
|
55
|
+
send(message) {
|
|
56
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
57
|
+
ws.send(message);
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Cannot send message, WebSocket is ${getReadyStateString(ws.readyState)}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async close() {
|
|
65
|
+
return new Promise((resolveClose) => {
|
|
66
|
+
if (ws.readyState === WebSocket.CLOSED) {
|
|
67
|
+
resolveClose();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const onClose = () => {
|
|
71
|
+
ws.removeEventListener("close", onClose);
|
|
72
|
+
resolveClose();
|
|
73
|
+
};
|
|
74
|
+
ws.addEventListener("close", onClose);
|
|
75
|
+
ws.close();
|
|
76
|
+
setTimeout(resolveClose, 5e3);
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
onMessage(handler) {
|
|
80
|
+
messageHandlers.push(handler);
|
|
81
|
+
},
|
|
82
|
+
onClose(handler) {
|
|
83
|
+
closeHandlers.push(handler);
|
|
84
|
+
},
|
|
85
|
+
onError(handler) {
|
|
86
|
+
errorHandlers.push(handler);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
resolve(transport);
|
|
90
|
+
});
|
|
91
|
+
ws.addEventListener("message", (event) => {
|
|
92
|
+
const data = typeof event.data === "string" ? event.data : String(event.data);
|
|
93
|
+
for (const handler of messageHandlers) {
|
|
94
|
+
handler(data);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
ws.addEventListener("close", () => {
|
|
98
|
+
for (const handler of closeHandlers) {
|
|
99
|
+
handler();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
ws.addEventListener("error", (_event) => {
|
|
103
|
+
clearTimeout(timeoutId);
|
|
104
|
+
const error = new Error("WebSocket connection error");
|
|
105
|
+
for (const handler of errorHandlers) {
|
|
106
|
+
handler(error);
|
|
107
|
+
}
|
|
108
|
+
reject(error);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function getReadyStateString(state) {
|
|
113
|
+
switch (state) {
|
|
114
|
+
case WebSocket.CONNECTING:
|
|
115
|
+
return "CONNECTING";
|
|
116
|
+
case WebSocket.OPEN:
|
|
117
|
+
return "OPEN";
|
|
118
|
+
case WebSocket.CLOSING:
|
|
119
|
+
return "CLOSING";
|
|
120
|
+
case WebSocket.CLOSED:
|
|
121
|
+
return "CLOSED";
|
|
122
|
+
default:
|
|
123
|
+
return "UNKNOWN";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/cdp/client.ts
|
|
128
|
+
async function createCDPClient(wsUrl, options = {}) {
|
|
129
|
+
const { debug = false, timeout = 3e4 } = options;
|
|
130
|
+
const transport = await createTransport(wsUrl, { timeout });
|
|
131
|
+
let messageId = 0;
|
|
132
|
+
let currentSessionId;
|
|
133
|
+
let connected = true;
|
|
134
|
+
const pending = /* @__PURE__ */ new Map();
|
|
135
|
+
const eventHandlers = /* @__PURE__ */ new Map();
|
|
136
|
+
const anyEventHandlers = /* @__PURE__ */ new Set();
|
|
137
|
+
transport.onMessage((raw) => {
|
|
138
|
+
let msg;
|
|
139
|
+
try {
|
|
140
|
+
msg = JSON.parse(raw);
|
|
141
|
+
} catch {
|
|
142
|
+
if (debug) console.error("[CDP] Failed to parse message:", raw);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (debug) {
|
|
146
|
+
console.log("[CDP] <--", JSON.stringify(msg, null, 2).slice(0, 500));
|
|
147
|
+
}
|
|
148
|
+
if ("id" in msg && typeof msg.id === "number") {
|
|
149
|
+
const response = msg;
|
|
150
|
+
const request = pending.get(response.id);
|
|
151
|
+
if (request) {
|
|
152
|
+
pending.delete(response.id);
|
|
153
|
+
clearTimeout(request.timer);
|
|
154
|
+
if (response.error) {
|
|
155
|
+
request.reject(new CDPError(response.error));
|
|
156
|
+
} else {
|
|
157
|
+
request.resolve(response.result);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if ("method" in msg) {
|
|
163
|
+
const event = msg;
|
|
164
|
+
const params = event.params ?? {};
|
|
165
|
+
for (const handler of anyEventHandlers) {
|
|
166
|
+
try {
|
|
167
|
+
handler(event.method, params);
|
|
168
|
+
} catch (e) {
|
|
169
|
+
if (debug) console.error("[CDP] Error in any-event handler:", e);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const handlers = eventHandlers.get(event.method);
|
|
173
|
+
if (handlers) {
|
|
174
|
+
for (const handler of handlers) {
|
|
175
|
+
try {
|
|
176
|
+
handler(params);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
if (debug) console.error(`[CDP] Error in handler for ${event.method}:`, e);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
transport.onClose(() => {
|
|
185
|
+
connected = false;
|
|
186
|
+
for (const [id, request] of pending) {
|
|
187
|
+
clearTimeout(request.timer);
|
|
188
|
+
request.reject(new Error("WebSocket connection closed"));
|
|
189
|
+
pending.delete(id);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
transport.onError((error) => {
|
|
193
|
+
if (debug) console.error("[CDP] Transport error:", error);
|
|
194
|
+
});
|
|
195
|
+
const client = {
|
|
196
|
+
async send(method, params, sessionId) {
|
|
197
|
+
if (!connected) {
|
|
198
|
+
throw new Error("CDP client is not connected");
|
|
199
|
+
}
|
|
200
|
+
const id = ++messageId;
|
|
201
|
+
const effectiveSessionId = sessionId ?? currentSessionId;
|
|
202
|
+
const request = { id, method };
|
|
203
|
+
if (params !== void 0) {
|
|
204
|
+
request.params = params;
|
|
205
|
+
}
|
|
206
|
+
if (effectiveSessionId !== void 0) {
|
|
207
|
+
request.sessionId = effectiveSessionId;
|
|
208
|
+
}
|
|
209
|
+
const message = JSON.stringify(request);
|
|
210
|
+
if (debug) {
|
|
211
|
+
console.log("[CDP] -->", message.slice(0, 500));
|
|
212
|
+
}
|
|
213
|
+
return new Promise((resolve, reject) => {
|
|
214
|
+
const timer = setTimeout(() => {
|
|
215
|
+
pending.delete(id);
|
|
216
|
+
reject(new Error(`CDP command ${method} timed out after ${timeout}ms`));
|
|
217
|
+
}, timeout);
|
|
218
|
+
pending.set(id, {
|
|
219
|
+
resolve,
|
|
220
|
+
reject,
|
|
221
|
+
method,
|
|
222
|
+
timer
|
|
223
|
+
});
|
|
224
|
+
try {
|
|
225
|
+
transport.send(message);
|
|
226
|
+
} catch (e) {
|
|
227
|
+
pending.delete(id);
|
|
228
|
+
clearTimeout(timer);
|
|
229
|
+
reject(e);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
on(event, handler) {
|
|
234
|
+
let handlers = eventHandlers.get(event);
|
|
235
|
+
if (!handlers) {
|
|
236
|
+
handlers = /* @__PURE__ */ new Set();
|
|
237
|
+
eventHandlers.set(event, handlers);
|
|
238
|
+
}
|
|
239
|
+
handlers.add(handler);
|
|
240
|
+
},
|
|
241
|
+
off(event, handler) {
|
|
242
|
+
const handlers = eventHandlers.get(event);
|
|
243
|
+
if (handlers) {
|
|
244
|
+
handlers.delete(handler);
|
|
245
|
+
if (handlers.size === 0) {
|
|
246
|
+
eventHandlers.delete(event);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
onAny(handler) {
|
|
251
|
+
anyEventHandlers.add(handler);
|
|
252
|
+
},
|
|
253
|
+
async close() {
|
|
254
|
+
connected = false;
|
|
255
|
+
await transport.close();
|
|
256
|
+
},
|
|
257
|
+
async attachToTarget(targetId) {
|
|
258
|
+
const result = await this.send("Target.attachToTarget", {
|
|
259
|
+
targetId,
|
|
260
|
+
flatten: true
|
|
261
|
+
});
|
|
262
|
+
currentSessionId = result.sessionId;
|
|
263
|
+
return result.sessionId;
|
|
264
|
+
},
|
|
265
|
+
get sessionId() {
|
|
266
|
+
return currentSessionId;
|
|
267
|
+
},
|
|
268
|
+
get isConnected() {
|
|
269
|
+
return connected;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
return client;
|
|
273
|
+
}
|
|
274
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
275
|
+
0 && (module.exports = {
|
|
276
|
+
CDPError,
|
|
277
|
+
createCDPClient,
|
|
278
|
+
createTransport
|
|
279
|
+
});
|
package/dist/cdp.d.cts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
export { C as CDPClient, a as CDPClientOptions, T as Transport, d as TransportOptions, c as createCDPClient, b as createTransport } from './client-7Nqka5MV.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CDP Protocol type definitions
|
|
5
|
+
* Minimal subset of Chrome DevTools Protocol types needed for browser automation
|
|
6
|
+
*/
|
|
7
|
+
interface CDPRequest {
|
|
8
|
+
id: number;
|
|
9
|
+
method: string;
|
|
10
|
+
params?: Record<string, unknown>;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
}
|
|
13
|
+
interface CDPResponse {
|
|
14
|
+
id: number;
|
|
15
|
+
result?: unknown;
|
|
16
|
+
error?: CDPErrorData;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CDPEvent {
|
|
20
|
+
method: string;
|
|
21
|
+
params?: Record<string, unknown>;
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
}
|
|
24
|
+
interface CDPErrorData {
|
|
25
|
+
code: number;
|
|
26
|
+
message: string;
|
|
27
|
+
data?: string;
|
|
28
|
+
}
|
|
29
|
+
type CDPMessage = CDPResponse | CDPEvent;
|
|
30
|
+
declare class CDPError extends Error {
|
|
31
|
+
code: number;
|
|
32
|
+
data?: string;
|
|
33
|
+
constructor(error: CDPErrorData);
|
|
34
|
+
}
|
|
35
|
+
interface TargetInfo {
|
|
36
|
+
targetId: string;
|
|
37
|
+
type: string;
|
|
38
|
+
title: string;
|
|
39
|
+
url: string;
|
|
40
|
+
attached: boolean;
|
|
41
|
+
canAccessOpener: boolean;
|
|
42
|
+
browserContextId?: string;
|
|
43
|
+
}
|
|
44
|
+
interface DOMNode {
|
|
45
|
+
nodeId: number;
|
|
46
|
+
backendNodeId: number;
|
|
47
|
+
nodeType: number;
|
|
48
|
+
nodeName: string;
|
|
49
|
+
localName: string;
|
|
50
|
+
nodeValue: string;
|
|
51
|
+
childNodeCount?: number;
|
|
52
|
+
children?: DOMNode[];
|
|
53
|
+
attributes?: string[];
|
|
54
|
+
documentURL?: string;
|
|
55
|
+
baseURL?: string;
|
|
56
|
+
publicId?: string;
|
|
57
|
+
systemId?: string;
|
|
58
|
+
internalSubset?: string;
|
|
59
|
+
xmlVersion?: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
value?: string;
|
|
62
|
+
pseudoType?: string;
|
|
63
|
+
shadowRootType?: string;
|
|
64
|
+
frameId?: string;
|
|
65
|
+
contentDocument?: DOMNode;
|
|
66
|
+
shadowRoots?: DOMNode[];
|
|
67
|
+
templateContent?: DOMNode;
|
|
68
|
+
pseudoElements?: DOMNode[];
|
|
69
|
+
importedDocument?: DOMNode;
|
|
70
|
+
distributedNodes?: BackendNode[];
|
|
71
|
+
isSVG?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface BackendNode {
|
|
74
|
+
nodeType: number;
|
|
75
|
+
nodeName: string;
|
|
76
|
+
backendNodeId: number;
|
|
77
|
+
}
|
|
78
|
+
interface AXNode {
|
|
79
|
+
nodeId: string;
|
|
80
|
+
ignored: boolean;
|
|
81
|
+
ignoredReasons?: AXProperty[];
|
|
82
|
+
role?: AXValue;
|
|
83
|
+
chromeRole?: AXValue;
|
|
84
|
+
name?: AXValue;
|
|
85
|
+
description?: AXValue;
|
|
86
|
+
value?: AXValue;
|
|
87
|
+
properties?: AXProperty[];
|
|
88
|
+
parentId?: string;
|
|
89
|
+
childIds?: string[];
|
|
90
|
+
backendDOMNodeId?: number;
|
|
91
|
+
frameId?: string;
|
|
92
|
+
}
|
|
93
|
+
interface AXValue {
|
|
94
|
+
type: string;
|
|
95
|
+
value?: unknown;
|
|
96
|
+
relatedNodes?: AXRelatedNode[];
|
|
97
|
+
sources?: AXValueSource[];
|
|
98
|
+
}
|
|
99
|
+
interface AXRelatedNode {
|
|
100
|
+
backendDOMNodeId: number;
|
|
101
|
+
idref?: string;
|
|
102
|
+
text?: string;
|
|
103
|
+
}
|
|
104
|
+
interface AXValueSource {
|
|
105
|
+
type: string;
|
|
106
|
+
value?: AXValue;
|
|
107
|
+
attribute?: string;
|
|
108
|
+
attributeValue?: AXValue;
|
|
109
|
+
superseded?: boolean;
|
|
110
|
+
nativeSource?: string;
|
|
111
|
+
nativeSourceValue?: AXValue;
|
|
112
|
+
invalid?: boolean;
|
|
113
|
+
invalidReason?: string;
|
|
114
|
+
}
|
|
115
|
+
interface AXProperty {
|
|
116
|
+
name: string;
|
|
117
|
+
value: AXValue;
|
|
118
|
+
}
|
|
119
|
+
interface RemoteObject {
|
|
120
|
+
type: string;
|
|
121
|
+
subtype?: string;
|
|
122
|
+
className?: string;
|
|
123
|
+
value?: unknown;
|
|
124
|
+
unserializableValue?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
objectId?: string;
|
|
127
|
+
preview?: ObjectPreview;
|
|
128
|
+
customPreview?: CustomPreview;
|
|
129
|
+
}
|
|
130
|
+
interface ObjectPreview {
|
|
131
|
+
type: string;
|
|
132
|
+
subtype?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
overflow: boolean;
|
|
135
|
+
properties: PropertyPreview[];
|
|
136
|
+
entries?: EntryPreview[];
|
|
137
|
+
}
|
|
138
|
+
interface PropertyPreview {
|
|
139
|
+
name: string;
|
|
140
|
+
type: string;
|
|
141
|
+
value?: string;
|
|
142
|
+
valuePreview?: ObjectPreview;
|
|
143
|
+
subtype?: string;
|
|
144
|
+
}
|
|
145
|
+
interface EntryPreview {
|
|
146
|
+
key?: ObjectPreview;
|
|
147
|
+
value: ObjectPreview;
|
|
148
|
+
}
|
|
149
|
+
interface CustomPreview {
|
|
150
|
+
header: string;
|
|
151
|
+
bodyGetterId?: string;
|
|
152
|
+
}
|
|
153
|
+
interface ExceptionDetails {
|
|
154
|
+
exceptionId: number;
|
|
155
|
+
text: string;
|
|
156
|
+
lineNumber: number;
|
|
157
|
+
columnNumber: number;
|
|
158
|
+
scriptId?: string;
|
|
159
|
+
url?: string;
|
|
160
|
+
stackTrace?: StackTrace;
|
|
161
|
+
exception?: RemoteObject;
|
|
162
|
+
executionContextId?: number;
|
|
163
|
+
}
|
|
164
|
+
interface StackTrace {
|
|
165
|
+
description?: string;
|
|
166
|
+
callFrames: CallFrame[];
|
|
167
|
+
parent?: StackTrace;
|
|
168
|
+
parentId?: StackTraceId;
|
|
169
|
+
}
|
|
170
|
+
interface CallFrame {
|
|
171
|
+
functionName: string;
|
|
172
|
+
scriptId: string;
|
|
173
|
+
url: string;
|
|
174
|
+
lineNumber: number;
|
|
175
|
+
columnNumber: number;
|
|
176
|
+
}
|
|
177
|
+
interface StackTraceId {
|
|
178
|
+
id: string;
|
|
179
|
+
debuggerId?: string;
|
|
180
|
+
}
|
|
181
|
+
type MouseButton = 'none' | 'left' | 'middle' | 'right' | 'back' | 'forward';
|
|
182
|
+
type MouseEventType = 'mousePressed' | 'mouseReleased' | 'mouseMoved' | 'mouseWheel';
|
|
183
|
+
type KeyEventType = 'keyDown' | 'keyUp' | 'rawKeyDown' | 'char';
|
|
184
|
+
interface FrameTree {
|
|
185
|
+
frame: FrameInfo;
|
|
186
|
+
childFrames?: FrameTree[];
|
|
187
|
+
}
|
|
188
|
+
interface FrameInfo {
|
|
189
|
+
id: string;
|
|
190
|
+
parentId?: string;
|
|
191
|
+
loaderId: string;
|
|
192
|
+
name?: string;
|
|
193
|
+
url: string;
|
|
194
|
+
urlFragment?: string;
|
|
195
|
+
domainAndRegistry: string;
|
|
196
|
+
securityOrigin: string;
|
|
197
|
+
mimeType: string;
|
|
198
|
+
unreachableUrl?: string;
|
|
199
|
+
adFrameStatus?: AdFrameStatus;
|
|
200
|
+
secureContextType: string;
|
|
201
|
+
crossOriginIsolatedContextType: string;
|
|
202
|
+
gatedAPIFeatures: string[];
|
|
203
|
+
}
|
|
204
|
+
interface AdFrameStatus {
|
|
205
|
+
adFrameType: string;
|
|
206
|
+
explanations?: string[];
|
|
207
|
+
}
|
|
208
|
+
interface Viewport {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
width: number;
|
|
212
|
+
height: number;
|
|
213
|
+
scale: number;
|
|
214
|
+
}
|
|
215
|
+
interface BoxModel {
|
|
216
|
+
content: number[];
|
|
217
|
+
padding: number[];
|
|
218
|
+
border: number[];
|
|
219
|
+
margin: number[];
|
|
220
|
+
width: number;
|
|
221
|
+
height: number;
|
|
222
|
+
shapeOutside?: ShapeOutsideInfo;
|
|
223
|
+
}
|
|
224
|
+
interface ShapeOutsideInfo {
|
|
225
|
+
bounds: number[];
|
|
226
|
+
shape: unknown[];
|
|
227
|
+
marginShape: unknown[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { type AXNode, type AXProperty, type AXRelatedNode, type AXValue, type AXValueSource, type AdFrameStatus, type BackendNode, type BoxModel, CDPError, type CDPErrorData, type CDPEvent, type CDPMessage, type CDPRequest, type CDPResponse, type CallFrame, type CustomPreview, type DOMNode, type EntryPreview, type ExceptionDetails, type FrameInfo, type FrameTree, type KeyEventType, type MouseButton, type MouseEventType, type ObjectPreview, type PropertyPreview, type RemoteObject, type ShapeOutsideInfo, type StackTrace, type StackTraceId, type TargetInfo, type Viewport };
|