browser-pilot 0.0.12 → 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.
- package/README.md +13 -7
- package/dist/actions.cjs +63 -10
- package/dist/actions.d.cts +3 -3
- package/dist/actions.d.ts +3 -3
- package/dist/actions.mjs +1 -1
- package/dist/browser.cjs +629 -57
- package/dist/browser.d.cts +9 -3
- package/dist/browser.d.ts +9 -3
- package/dist/browser.mjs +3 -3
- package/dist/cdp.cjs +1 -1
- package/dist/cdp.d.cts +1 -1
- package/dist/cdp.d.ts +1 -1
- package/dist/cdp.mjs +1 -1
- package/dist/{chunk-NLIARNEE.mjs → chunk-A2ZRAEO3.mjs} +63 -10
- package/dist/{chunk-4MBSALQL.mjs → chunk-HP6R3W32.mjs} +1 -1
- package/dist/{chunk-RUWAXHDX.mjs → chunk-VDAMDOS6.mjs} +606 -57
- package/dist/cli.mjs +1145 -127
- package/dist/{client-7Nqka5MV.d.ts → client-DRqxBdHv.d.cts} +1 -1
- package/dist/{client-7Nqka5MV.d.cts → client-DRqxBdHv.d.ts} +1 -1
- package/dist/index.cjs +668 -66
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/{types-j23Iqo2L.d.ts → types-BXMGFtnB.d.cts} +46 -5
- package/dist/{types-BOPu0OQZ.d.cts → types-CzgQjai9.d.ts} +46 -5
- package/package.json +1 -1
package/dist/browser.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
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 {
|
|
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,
|
|
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-
|
|
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 {
|
|
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,
|
|
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,14 @@ import {
|
|
|
2
2
|
Browser,
|
|
3
3
|
Page,
|
|
4
4
|
connect
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
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-
|
|
12
|
+
} from "./chunk-A2ZRAEO3.mjs";
|
|
13
13
|
import "./chunk-JXAUPHZM.mjs";
|
|
14
14
|
export {
|
|
15
15
|
Browser,
|
package/dist/cdp.cjs
CHANGED
|
@@ -213,7 +213,7 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
213
213
|
throw new Error("CDP client is not connected");
|
|
214
214
|
}
|
|
215
215
|
const id = ++messageId;
|
|
216
|
-
const effectiveSessionId = sessionId ?? currentSessionId;
|
|
216
|
+
const effectiveSessionId = sessionId === null ? void 0 : sessionId ?? currentSessionId;
|
|
217
217
|
const request = { id, method };
|
|
218
218
|
if (params !== void 0) {
|
|
219
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-
|
|
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-
|
|
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
|
@@ -926,6 +926,9 @@ var BatchExecutor = class {
|
|
|
926
926
|
const snapshot = await this.page.snapshot();
|
|
927
927
|
return { value: snapshot };
|
|
928
928
|
}
|
|
929
|
+
case "forms": {
|
|
930
|
+
return { value: await this.page.forms() };
|
|
931
|
+
}
|
|
929
932
|
case "screenshot": {
|
|
930
933
|
const data = await this.page.screenshot({
|
|
931
934
|
format: step.format,
|
|
@@ -945,6 +948,21 @@ var BatchExecutor = class {
|
|
|
945
948
|
const text = await this.page.text(selector);
|
|
946
949
|
return { text, selectorUsed: selector };
|
|
947
950
|
}
|
|
951
|
+
case "newTab": {
|
|
952
|
+
const { targetId } = await this.page.cdpClient.send(
|
|
953
|
+
"Target.createTarget",
|
|
954
|
+
{
|
|
955
|
+
url: step.url ?? "about:blank"
|
|
956
|
+
},
|
|
957
|
+
null
|
|
958
|
+
);
|
|
959
|
+
return { value: { targetId } };
|
|
960
|
+
}
|
|
961
|
+
case "closeTab": {
|
|
962
|
+
const targetId = step.targetId ?? this.page.targetId;
|
|
963
|
+
await this.page.cdpClient.send("Target.closeTarget", { targetId }, null);
|
|
964
|
+
return { value: { targetId, closedCurrent: targetId === this.page.targetId } };
|
|
965
|
+
}
|
|
948
966
|
case "switchFrame": {
|
|
949
967
|
if (!step.selector) throw new Error("switchFrame requires selector");
|
|
950
968
|
await this.page.switchToFrame(step.selector, { timeout, optional });
|
|
@@ -1059,10 +1077,15 @@ var BatchExecutor = class {
|
|
|
1059
1077
|
snap: "snapshot",
|
|
1060
1078
|
accessibility: "snapshot",
|
|
1061
1079
|
a11y: "snapshot",
|
|
1080
|
+
formslist: "forms",
|
|
1062
1081
|
image: "screenshot",
|
|
1063
1082
|
pic: "screenshot",
|
|
1064
1083
|
frame: "switchFrame",
|
|
1065
1084
|
iframe: "switchFrame",
|
|
1085
|
+
newtab: "newTab",
|
|
1086
|
+
opentab: "newTab",
|
|
1087
|
+
createtab: "newTab",
|
|
1088
|
+
closetab: "closeTab",
|
|
1066
1089
|
assert_visible: "assertVisible",
|
|
1067
1090
|
assert_exists: "assertExists",
|
|
1068
1091
|
assert_text: "assertText",
|
|
@@ -1076,7 +1099,7 @@ var BatchExecutor = class {
|
|
|
1076
1099
|
};
|
|
1077
1100
|
const suggestion = aliases[action.toLowerCase()];
|
|
1078
1101
|
const hint = suggestion ? ` Did you mean "${suggestion}"?` : "";
|
|
1079
|
-
const valid = "goto, click, fill, type, select, check, uncheck, submit, press, shortcut, focus, hover, scroll, wait, snapshot, screenshot, evaluate, text, switchFrame, switchToMain, assertVisible, assertExists, assertText, assertUrl, assertValue";
|
|
1102
|
+
const valid = "goto, click, fill, type, select, check, uncheck, submit, press, shortcut, focus, hover, scroll, wait, snapshot, forms, screenshot, evaluate, text, newTab, closeTab, switchFrame, switchToMain, assertVisible, assertExists, assertText, assertUrl, assertValue";
|
|
1080
1103
|
throw new Error(`Unknown action "${action}".${hint}
|
|
1081
1104
|
|
|
1082
1105
|
Valid actions: ${valid}`);
|
|
@@ -1147,6 +1170,11 @@ var ACTION_ALIASES = {
|
|
|
1147
1170
|
pic: "screenshot",
|
|
1148
1171
|
frame: "switchFrame",
|
|
1149
1172
|
iframe: "switchFrame",
|
|
1173
|
+
formslist: "forms",
|
|
1174
|
+
newtab: "newTab",
|
|
1175
|
+
opentab: "newTab",
|
|
1176
|
+
createtab: "newTab",
|
|
1177
|
+
closetab: "closeTab",
|
|
1150
1178
|
assert_visible: "assertVisible",
|
|
1151
1179
|
assert_exists: "assertExists",
|
|
1152
1180
|
assert_text: "assertText",
|
|
@@ -1183,7 +1211,8 @@ var PROPERTY_ALIASES = {
|
|
|
1183
1211
|
button: "key",
|
|
1184
1212
|
address: "url",
|
|
1185
1213
|
page: "url",
|
|
1186
|
-
path: "url"
|
|
1214
|
+
path: "url",
|
|
1215
|
+
tabId: "targetId"
|
|
1187
1216
|
};
|
|
1188
1217
|
var ACTION_RULES = {
|
|
1189
1218
|
goto: {
|
|
@@ -1284,6 +1313,10 @@ var ACTION_RULES = {
|
|
|
1284
1313
|
fullPage: { type: "boolean" }
|
|
1285
1314
|
}
|
|
1286
1315
|
},
|
|
1316
|
+
forms: {
|
|
1317
|
+
required: {},
|
|
1318
|
+
optional: {}
|
|
1319
|
+
},
|
|
1287
1320
|
evaluate: {
|
|
1288
1321
|
required: { value: { type: "string" } },
|
|
1289
1322
|
optional: {}
|
|
@@ -1298,6 +1331,18 @@ var ACTION_RULES = {
|
|
|
1298
1331
|
required: { selector: { type: "string|string[]" } },
|
|
1299
1332
|
optional: {}
|
|
1300
1333
|
},
|
|
1334
|
+
newTab: {
|
|
1335
|
+
required: {},
|
|
1336
|
+
optional: {
|
|
1337
|
+
url: { type: "string" }
|
|
1338
|
+
}
|
|
1339
|
+
},
|
|
1340
|
+
closeTab: {
|
|
1341
|
+
required: {},
|
|
1342
|
+
optional: {
|
|
1343
|
+
targetId: { type: "string" }
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
1301
1346
|
switchToMain: {
|
|
1302
1347
|
required: {},
|
|
1303
1348
|
optional: {}
|
|
@@ -1340,6 +1385,7 @@ var KNOWN_STEP_FIELDS = /* @__PURE__ */ new Set([
|
|
|
1340
1385
|
"selector",
|
|
1341
1386
|
"url",
|
|
1342
1387
|
"value",
|
|
1388
|
+
"targetId",
|
|
1343
1389
|
"key",
|
|
1344
1390
|
"combo",
|
|
1345
1391
|
"modifiers",
|
|
@@ -1494,15 +1540,22 @@ function validateSteps(steps) {
|
|
|
1494
1540
|
const rule = ACTION_RULES[action];
|
|
1495
1541
|
for (const key of Object.keys(obj)) {
|
|
1496
1542
|
if (key === "action") continue;
|
|
1497
|
-
if (
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1543
|
+
if (KNOWN_STEP_FIELDS.has(key)) continue;
|
|
1544
|
+
const canonical = PROPERTY_ALIASES[key];
|
|
1545
|
+
if (canonical) {
|
|
1546
|
+
if (!(canonical in obj)) {
|
|
1547
|
+
obj[canonical] = obj[key];
|
|
1548
|
+
}
|
|
1549
|
+
delete obj[key];
|
|
1550
|
+
continue;
|
|
1505
1551
|
}
|
|
1552
|
+
const suggestion = suggestProperty(key);
|
|
1553
|
+
errors.push({
|
|
1554
|
+
stepIndex: i,
|
|
1555
|
+
field: key,
|
|
1556
|
+
message: suggestion ? `unknown property "${key}". Did you mean "${suggestion}"?` : `unknown property "${key}".`,
|
|
1557
|
+
suggestion: suggestion ? `Did you mean "${suggestion}"?` : void 0
|
|
1558
|
+
});
|
|
1506
1559
|
}
|
|
1507
1560
|
for (const [field, fieldRule] of Object.entries(rule.required)) {
|
|
1508
1561
|
if (!(field in obj) || obj[field] === void 0) {
|
|
@@ -177,7 +177,7 @@ async function createCDPClient(wsUrl, options = {}) {
|
|
|
177
177
|
throw new Error("CDP client is not connected");
|
|
178
178
|
}
|
|
179
179
|
const id = ++messageId;
|
|
180
|
-
const effectiveSessionId = sessionId ?? currentSessionId;
|
|
180
|
+
const effectiveSessionId = sessionId === null ? void 0 : sessionId ?? currentSessionId;
|
|
181
181
|
const request = { id, method };
|
|
182
182
|
if (params !== void 0) {
|
|
183
183
|
request.params = params;
|