@orkestrel/browser 0.0.14 → 0.0.16
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 +16 -20
- package/dist/src/core/index.cjs +2624 -2374
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1588 -762
- package/dist/src/core/index.d.ts +1588 -762
- package/dist/src/core/index.js +2594 -2341
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +283 -193
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +278 -131
- package/dist/src/server/index.d.ts +278 -131
- package/dist/src/server/index.js +277 -184
- package/dist/src/server/index.js.map +1 -1
- package/package.json +18 -19
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1,69 +1,73 @@
|
|
|
1
|
-
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
-
import { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
1
|
+
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
+
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Read one captured node attribute.
|
|
7
|
-
*
|
|
8
|
-
* @param node - Captured browser node
|
|
9
|
-
* @param name - Attribute name
|
|
10
|
-
* @returns Attribute value, or undefined
|
|
11
|
-
*/
|
|
12
|
-
export declare function attributeOfBrowserNode(node: BrowserNode, name: string): string | undefined;
|
|
13
|
-
|
|
14
|
-
/** Base64 alphabet, index-ordered, used to build {@link BASE64_LOOKUP}. */
|
|
5
|
+
/** Holds the index-ordered base64 alphabet used to build {@link BASE64_LOOKUP}. */
|
|
15
6
|
export declare const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16
7
|
|
|
17
|
-
/**
|
|
8
|
+
/** Maps each base64 character to its 6-bit value, derived from {@link BASE64_CHARS}. */
|
|
18
9
|
export declare const BASE64_LOOKUP: Readonly<Record<string, number>>;
|
|
19
10
|
|
|
20
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Names the CDP runtime binding the codegen recorder script calls into,
|
|
13
|
+
* `'__orkestrelBrowserCodegen'`.
|
|
14
|
+
*/
|
|
21
15
|
export declare const BROWSER_CODEGEN_BINDING_NAME = "__orkestrelBrowserCodegen";
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
|
-
*
|
|
18
|
+
* Holds the in-page recorder script injected through `Page.addScriptToEvaluateOnNewDocument`
|
|
25
19
|
* and `Runtime.evaluate`.
|
|
26
20
|
*
|
|
27
21
|
* @remarks
|
|
28
|
-
* Attaches capturing-phase listeners for `click`, `input` (fill), and
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* install exactly once per document (`window[name]` sentinel) so
|
|
33
|
-
* injection on every new document is idempotent.
|
|
22
|
+
* Attaches capturing-phase listeners for `click`, `input` (fill), and `change` (select) on
|
|
23
|
+
* `document`, builds a stable CSS selector for the target element, and forwards each action
|
|
24
|
+
* to the CDP binding ({@link BROWSER_CODEGEN_BINDING_NAME}) as a JSON string payload. A
|
|
25
|
+
* `contenteditable` fill is captured through `input` events, the same way an input or a
|
|
26
|
+
* textarea is. Guarded to install exactly once per document (`window[name]` sentinel) so
|
|
27
|
+
* repeated injection on every new document is idempotent.
|
|
34
28
|
*/
|
|
35
29
|
export declare const BROWSER_CODEGEN_SOURCE: string;
|
|
36
30
|
|
|
37
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Sets the default timeout for browser connection, requests, and navigation, `30_000`
|
|
33
|
+
* milliseconds.
|
|
34
|
+
*/
|
|
38
35
|
export declare const BROWSER_DEFAULT_TIMEOUT_MS = 30000;
|
|
39
36
|
|
|
40
|
-
/**
|
|
37
|
+
/** Sets the default viewport height, `720` pixels. */
|
|
41
38
|
export declare const BROWSER_DEFAULT_VIEWPORT_HEIGHT = 720;
|
|
42
39
|
|
|
43
|
-
/**
|
|
40
|
+
/** Sets the default viewport width, `1280` pixels. */
|
|
44
41
|
export declare const BROWSER_DEFAULT_VIEWPORT_WIDTH = 1280;
|
|
45
42
|
|
|
46
|
-
/**
|
|
43
|
+
/** Names the isolated world used for iframe evaluation, `'__orkestrelBrowserFrame'`. */
|
|
47
44
|
export declare const BROWSER_FRAME_WORLD_NAME = "__orkestrelBrowserFrame";
|
|
48
45
|
|
|
49
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Names the tool identity embedded in HAR 1.2 documents.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* `version` is this package's own released version. A parity test in
|
|
51
|
+
* `tests/src/core/BrowserHARManager.test.ts` compares it against the manifest,
|
|
52
|
+
* so the archive stamp cannot drift away from the release that wrote it.
|
|
53
|
+
*/
|
|
50
54
|
export declare const BROWSER_HAR_CREATOR: Readonly<{
|
|
51
55
|
name: "@orkestrel/browser";
|
|
52
|
-
version: "0.0.
|
|
56
|
+
version: "0.0.16";
|
|
53
57
|
}>;
|
|
54
58
|
|
|
55
|
-
/**
|
|
59
|
+
/** Maps a canonical modifier name to its CDP Input modifier bit value. */
|
|
56
60
|
export declare const BROWSER_KEY_MODIFIERS: Readonly<Record<string, number>>;
|
|
57
61
|
|
|
58
|
-
/** CDP Input pressed-button bit
|
|
62
|
+
/** Maps each public mouse button to its CDP Input pressed-button bit value. */
|
|
59
63
|
export declare const BROWSER_MOUSE_BUTTON_MASKS: Readonly<Record<BrowserMouseButton, number>>;
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
|
-
*
|
|
63
|
-
* enforced
|
|
66
|
+
* Caps the serialized-character length for an `evaluate()`/`content()` result at `2_500_000`,
|
|
67
|
+
* enforced in-page before the result is returned to CDP.
|
|
64
68
|
*
|
|
65
69
|
* @remarks
|
|
66
|
-
* This counts UTF-16
|
|
70
|
+
* This counts UTF-16 string length (`String#length`), not transport bytes —
|
|
67
71
|
* the actual CDP frame is UTF-8 encoded (up to 3 bytes/char for common
|
|
68
72
|
* multibyte content) and carries additional JSON/CDP framing overhead on top
|
|
69
73
|
* of the raw content. A `Runtime.evaluate` result above this size, once
|
|
@@ -80,17 +84,19 @@ export declare const BROWSER_MOUSE_BUTTON_MASKS: Readonly<Record<BrowserMouseBut
|
|
|
80
84
|
export declare const BROWSER_RESULT_LIMIT = 2500000;
|
|
81
85
|
|
|
82
86
|
/**
|
|
83
|
-
* Matches the in-page result-limit sentinel error message, anchored
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
87
|
+
* Matches the in-page result-limit sentinel error message, anchored immediately after the
|
|
88
|
+
* `Error:` (optionally `Uncaught Error:`) prefix Chromium prepends to a thrown error's
|
|
89
|
+
* description, `/^(?:Uncaught )?Error: \[\[ORKESTREL_BROWSER_RESULT_LIMIT\]\](\d+)/`.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* The anchor matches the guard's own throw only at the start of the message, rather than
|
|
93
|
+
* wherever the substring happens to occur.
|
|
88
94
|
*/
|
|
89
95
|
export declare const BROWSER_RESULT_LIMIT_PATTERN: RegExp;
|
|
90
96
|
|
|
91
97
|
/**
|
|
92
|
-
*
|
|
93
|
-
* followed by the serialized length.
|
|
98
|
+
* Names the distinctive prefix for the in-page result-limit sentinel error,
|
|
99
|
+
* `'[[ORKESTREL_BROWSER_RESULT_LIMIT]]'`, immediately followed by the serialized length.
|
|
94
100
|
*
|
|
95
101
|
* @remarks
|
|
96
102
|
* Deliberately unlikely to appear in a page's own thrown error text (unlike
|
|
@@ -100,18 +106,20 @@ export declare const BROWSER_RESULT_LIMIT_PATTERN: RegExp;
|
|
|
100
106
|
*/
|
|
101
107
|
export declare const BROWSER_RESULT_LIMIT_SENTINEL_PREFIX = "[[ORKESTREL_BROWSER_RESULT_LIMIT]]";
|
|
102
108
|
|
|
103
|
-
/**
|
|
109
|
+
/** Names the attribute that tags temporary screenshot styles and masks. */
|
|
104
110
|
export declare const BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
|
|
105
111
|
|
|
106
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.
|
|
114
|
+
*/
|
|
107
115
|
export declare const BROWSER_SNAPSHOT_NODE_LIMIT = 100000;
|
|
108
116
|
|
|
109
|
-
/**
|
|
117
|
+
/** Sets the number of animation frames whose element bounds must agree before trusted input. */
|
|
110
118
|
export declare const BROWSER_STABLE_FRAME_COUNT = 2;
|
|
111
119
|
|
|
112
120
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
121
|
+
* Bounds the best-effort `Page.stopLoading` call issued after a failed `navigate()` at `1_000`
|
|
122
|
+
* milliseconds.
|
|
115
123
|
*
|
|
116
124
|
* @remarks
|
|
117
125
|
* A wedged renderer can make the underlying CDP call hang for the full
|
|
@@ -121,14 +129,40 @@ export declare const BROWSER_STABLE_FRAME_COUNT = 2;
|
|
|
121
129
|
*/
|
|
122
130
|
export declare const BROWSER_STOP_LOADING_TIMEOUT_MS = 1000;
|
|
123
131
|
|
|
124
|
-
/**
|
|
132
|
+
/** Names the attribute the semantic test-id selector uses. */
|
|
125
133
|
export declare const BROWSER_TEST_ID_ATTRIBUTE = "data-testid";
|
|
126
134
|
|
|
127
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Holds the in-page visibility predicate source, over a `style` computed style and a
|
|
137
|
+
* `rect` bounding box already in scope at the interpolation site.
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* Every compiled expression that decides whether an element is visible
|
|
141
|
+
* interpolates this one source, so what "visible" means has a single
|
|
142
|
+
* definition rather than one copy per compiler.
|
|
143
|
+
*/
|
|
144
|
+
export declare const BROWSER_VISIBILITY_SOURCE = "style.display !== 'none' && style.visibility !== 'hidden' && style.visibility !== 'collapse' && rect.width > 0 && rect.height > 0";
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sets the poll interval while waiting for a selector to appear, `100` milliseconds.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* A wait adds the same interval as slack to its own CDP call timeout, so the in-page poll
|
|
151
|
+
* expires before the call carrying it. Host-side CDP readiness probes wait it out between
|
|
152
|
+
* attempts.
|
|
153
|
+
*/
|
|
128
154
|
export declare const BROWSER_WAIT_POLL_INTERVAL_MS = 100;
|
|
129
155
|
|
|
130
156
|
/**
|
|
131
|
-
* Chromium Accessibility-domain snapshots for one page.
|
|
157
|
+
* Captures Chromium Accessibility-domain snapshots for one page.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import { BrowserAccessibility } from '@orkestrel/browser'
|
|
162
|
+
*
|
|
163
|
+
* const accessibility = new BrowserAccessibility(page)
|
|
164
|
+
* const tree = await accessibility.snapshot({ depth: 3 }) // { roots, nodes }
|
|
165
|
+
* ```
|
|
132
166
|
*/
|
|
133
167
|
export declare class BrowserAccessibility implements BrowserAccessibilityInterface {
|
|
134
168
|
#private;
|
|
@@ -136,24 +170,25 @@ export declare class BrowserAccessibility implements BrowserAccessibilityInterfa
|
|
|
136
170
|
snapshot(options?: BrowserAccessibilityOptions): Promise<BrowserAccessibilitySnapshot>;
|
|
137
171
|
}
|
|
138
172
|
|
|
139
|
-
/**
|
|
173
|
+
/** Inspects the accessibility tree. */
|
|
140
174
|
export declare interface BrowserAccessibilityInterface {
|
|
175
|
+
/** Reads the full accessibility tree, optionally pruned to the interesting nodes. */
|
|
141
176
|
snapshot(options?: BrowserAccessibilityOptions): Promise<BrowserAccessibilitySnapshot>;
|
|
142
177
|
}
|
|
143
178
|
|
|
144
|
-
/**
|
|
179
|
+
/** Describes the options for an accessibility snapshot. */
|
|
145
180
|
export declare interface BrowserAccessibilityOptions {
|
|
146
181
|
readonly root?: number;
|
|
147
182
|
readonly depth?: number;
|
|
148
183
|
}
|
|
149
184
|
|
|
150
|
-
/**
|
|
185
|
+
/** Describes a serializable accessibility-tree snapshot. */
|
|
151
186
|
export declare interface BrowserAccessibilitySnapshot {
|
|
152
187
|
readonly roots: readonly string[];
|
|
153
188
|
readonly nodes: readonly BrowserAXNode[];
|
|
154
189
|
}
|
|
155
190
|
|
|
156
|
-
/**
|
|
191
|
+
/** Describes the actionability checks performed before locator input. */
|
|
157
192
|
export declare interface BrowserActionabilityOptions {
|
|
158
193
|
readonly visible?: boolean;
|
|
159
194
|
readonly stable?: boolean;
|
|
@@ -164,24 +199,22 @@ export declare interface BrowserActionabilityOptions {
|
|
|
164
199
|
}
|
|
165
200
|
|
|
166
201
|
/**
|
|
167
|
-
*
|
|
202
|
+
* Describes the options for element interaction (click, fill, select, wait).
|
|
168
203
|
*
|
|
169
204
|
* @remarks
|
|
170
205
|
* - `timeout` — maximum time to wait for the selector in milliseconds
|
|
206
|
+
* - `strict` — require the selector to resolve to exactly one element (default `true`)
|
|
207
|
+
* - `force` — skip the actionability checks
|
|
208
|
+
* - `trial` — run the checks and stop before dispatching input
|
|
171
209
|
*/
|
|
172
210
|
export declare interface BrowserActionOptions {
|
|
173
211
|
readonly timeout?: number;
|
|
174
212
|
readonly strict?: boolean;
|
|
175
213
|
readonly force?: boolean;
|
|
176
214
|
readonly trial?: boolean;
|
|
177
|
-
readonly delay?: number;
|
|
178
|
-
readonly button?: BrowserMouseButton;
|
|
179
|
-
readonly count?: number;
|
|
180
|
-
readonly position?: BrowserPoint;
|
|
181
|
-
readonly steps?: number;
|
|
182
215
|
}
|
|
183
216
|
|
|
184
|
-
/**
|
|
217
|
+
/** Represents one decoded Chromium accessibility node. */
|
|
185
218
|
export declare interface BrowserAXNode {
|
|
186
219
|
readonly id: string;
|
|
187
220
|
readonly parent: string | undefined;
|
|
@@ -196,7 +229,7 @@ export declare interface BrowserAXNode {
|
|
|
196
229
|
readonly properties: Readonly<Record<string, unknown>>;
|
|
197
230
|
}
|
|
198
231
|
|
|
199
|
-
/**
|
|
232
|
+
/** Describes a decoded page-to-host binding call. */
|
|
200
233
|
export declare interface BrowserBindingCall {
|
|
201
234
|
readonly id: string;
|
|
202
235
|
readonly name: string;
|
|
@@ -204,17 +237,39 @@ export declare interface BrowserBindingCall {
|
|
|
204
237
|
readonly context: number;
|
|
205
238
|
}
|
|
206
239
|
|
|
207
|
-
/**
|
|
240
|
+
/** Runs a host function exposed into page JavaScript. */
|
|
208
241
|
export declare type BrowserBindingHandler = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
209
242
|
|
|
210
|
-
/**
|
|
243
|
+
/** Describes a parsed keyboard chord. */
|
|
211
244
|
export declare interface BrowserChord {
|
|
212
245
|
readonly modifiers: readonly string[];
|
|
213
246
|
readonly key: string;
|
|
214
247
|
}
|
|
215
248
|
|
|
216
249
|
/**
|
|
217
|
-
*
|
|
250
|
+
* Describes the options for a trusted mouse click.
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* - `button` — pressed mouse button (default `'left'`)
|
|
254
|
+
* - `count` — click count reported to the page (default `1`)
|
|
255
|
+
*/
|
|
256
|
+
export declare interface BrowserClickOptions extends BrowserInputOptions {
|
|
257
|
+
readonly button?: BrowserMouseButton;
|
|
258
|
+
readonly count?: number;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Controls the Chromium virtual-time budget for deterministic page timers.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { BrowserClock } from '@orkestrel/browser'
|
|
267
|
+
*
|
|
268
|
+
* const clock = new BrowserClock(page)
|
|
269
|
+
* await clock.install(Date.UTC(2026, 0, 1))
|
|
270
|
+
* await clock.advance(5_000)
|
|
271
|
+
* await clock.uninstall()
|
|
272
|
+
* ```
|
|
218
273
|
*/
|
|
219
274
|
export declare class BrowserClock implements BrowserClockInterface {
|
|
220
275
|
#private;
|
|
@@ -227,22 +282,39 @@ export declare class BrowserClock implements BrowserClockInterface {
|
|
|
227
282
|
uninstall(): Promise<void>;
|
|
228
283
|
}
|
|
229
284
|
|
|
230
|
-
/** Chromium virtual
|
|
285
|
+
/** Controls Chromium virtual time for deterministic page timers. */
|
|
231
286
|
export declare interface BrowserClockInterface {
|
|
232
287
|
readonly installed: boolean;
|
|
288
|
+
/** Takes over the page clock, optionally seeding it with an epoch time. */
|
|
233
289
|
install(time?: number): Promise<void>;
|
|
290
|
+
/** Suspends virtual time so no page timer advances. */
|
|
234
291
|
pause(): Promise<void>;
|
|
292
|
+
/** Continues virtual time after a pause. */
|
|
235
293
|
resume(): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Moves virtual time forward by the given milliseconds, firing the timers that fall due.
|
|
296
|
+
*/
|
|
236
297
|
advance(ms: number): Promise<void>;
|
|
298
|
+
/** Returns the page to the real clock, and does nothing when no clock was installed. */
|
|
237
299
|
uninstall(): Promise<void>;
|
|
238
300
|
}
|
|
239
301
|
|
|
240
302
|
/**
|
|
241
303
|
* Records page navigation and form interactions and compiles replayable scripts.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* import { BrowserCodegen } from '@orkestrel/browser'
|
|
308
|
+
*
|
|
309
|
+
* const codegen = new BrowserCodegen(client, 'session-1')
|
|
310
|
+
* await codegen.start()
|
|
311
|
+
* const actions = await codegen.stop()
|
|
312
|
+
* const script = codegen.script({ language: 'typescript' })
|
|
313
|
+
* ```
|
|
242
314
|
*/
|
|
243
315
|
export declare class BrowserCodegen implements BrowserCodegenInterface {
|
|
244
316
|
#private;
|
|
245
|
-
constructor(client: CDPClientInterface,
|
|
317
|
+
constructor(client: CDPClientInterface, session: string, options?: BrowserCodegenOptions);
|
|
246
318
|
get emitter(): EmitterInterface<BrowserCodegenEventMap>;
|
|
247
319
|
get started(): boolean;
|
|
248
320
|
start(): Promise<void>;
|
|
@@ -253,7 +325,7 @@ export declare class BrowserCodegen implements BrowserCodegenInterface {
|
|
|
253
325
|
destroy(): Promise<void>;
|
|
254
326
|
}
|
|
255
327
|
|
|
256
|
-
/**
|
|
328
|
+
/** Represents one recorded browser action captured during a codegen session. */
|
|
257
329
|
export declare type BrowserCodegenAction = {
|
|
258
330
|
readonly action: 'navigate';
|
|
259
331
|
readonly url: string;
|
|
@@ -271,7 +343,7 @@ export declare type BrowserCodegenAction = {
|
|
|
271
343
|
};
|
|
272
344
|
|
|
273
345
|
/**
|
|
274
|
-
*
|
|
346
|
+
* Maps the events a {@link BrowserCodegenInterface} emits.
|
|
275
347
|
*
|
|
276
348
|
* @remarks
|
|
277
349
|
* - `start` — recording started
|
|
@@ -303,19 +375,28 @@ export declare type BrowserCodegenEventMap = {
|
|
|
303
375
|
export declare interface BrowserCodegenInterface {
|
|
304
376
|
readonly emitter: EmitterInterface<BrowserCodegenEventMap>;
|
|
305
377
|
readonly started: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Begins recording on the page's session. A call after teardown is a silent no-op, because
|
|
380
|
+
* a torn-down recorder cannot be restarted and a fresh one is obtained through the page.
|
|
381
|
+
*/
|
|
306
382
|
start(): Promise<void>;
|
|
383
|
+
/** Stops recording and returns the captured actions. */
|
|
307
384
|
stop(): Promise<readonly BrowserCodegenAction[]>;
|
|
385
|
+
/** Returns the current normalized action list. */
|
|
308
386
|
actions(): readonly BrowserCodegenAction[];
|
|
387
|
+
/** Compiles the captured actions into a script. */
|
|
309
388
|
script(options?: BrowserCodegenScriptOptions): string;
|
|
389
|
+
/** Resets the captured action list. */
|
|
310
390
|
clear(): void;
|
|
391
|
+
/** Tears down the recorder and detaches its CDP listeners. */
|
|
311
392
|
destroy(): Promise<void>;
|
|
312
393
|
}
|
|
313
394
|
|
|
314
|
-
/**
|
|
395
|
+
/** Names the target language for a compiled codegen script. */
|
|
315
396
|
export declare type BrowserCodegenLanguage = 'javascript' | 'typescript';
|
|
316
397
|
|
|
317
398
|
/**
|
|
318
|
-
*
|
|
399
|
+
* Describes the options for creating a `BrowserCodegen` recorder.
|
|
319
400
|
*
|
|
320
401
|
* @remarks
|
|
321
402
|
* - `on` — initial event listeners wired at construction
|
|
@@ -327,7 +408,7 @@ export declare interface BrowserCodegenOptions {
|
|
|
327
408
|
}
|
|
328
409
|
|
|
329
410
|
/**
|
|
330
|
-
*
|
|
411
|
+
* Describes the options for compiling recorded actions into a script.
|
|
331
412
|
*
|
|
332
413
|
* @remarks
|
|
333
414
|
* - `language` — target output language (default `'javascript'`)
|
|
@@ -336,7 +417,7 @@ export declare interface BrowserCodegenScriptOptions {
|
|
|
336
417
|
readonly language?: BrowserCodegenLanguage;
|
|
337
418
|
}
|
|
338
419
|
|
|
339
|
-
/**
|
|
420
|
+
/** Represents one console API call. */
|
|
340
421
|
export declare interface BrowserConsoleMessage {
|
|
341
422
|
readonly level: string;
|
|
342
423
|
readonly text: string;
|
|
@@ -346,7 +427,7 @@ export declare interface BrowserConsoleMessage {
|
|
|
346
427
|
}
|
|
347
428
|
|
|
348
429
|
/**
|
|
349
|
-
*
|
|
430
|
+
* Describes the result of page content extraction.
|
|
350
431
|
*
|
|
351
432
|
* @remarks
|
|
352
433
|
* - `url` — current page URL after navigation
|
|
@@ -363,10 +444,19 @@ export declare interface BrowserContentResult {
|
|
|
363
444
|
|
|
364
445
|
/**
|
|
365
446
|
* Owns pages and shared state inside one Chromium browser context.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* import { BrowserContext } from '@orkestrel/browser'
|
|
451
|
+
*
|
|
452
|
+
* const context = new BrowserContext(client)
|
|
453
|
+
* const page = await context.create({ url: 'https://example.com' })
|
|
454
|
+
* await context.destroy()
|
|
455
|
+
* ```
|
|
366
456
|
*/
|
|
367
457
|
export declare class BrowserContext implements BrowserContextInterface {
|
|
368
458
|
#private;
|
|
369
|
-
constructor(client: CDPClientInterface, id?: string, viewport?: BrowserViewport, writer?:
|
|
459
|
+
constructor(client: CDPClientInterface, id?: string, viewport?: BrowserViewport, writer?: BrowserWriterInterface, emulation?: BrowserEmulationOptions, downloads?: BrowserDownloadOptions, options?: BrowserContextOptions);
|
|
370
460
|
get emitter(): EmitterInterface<BrowserContextEventMap>;
|
|
371
461
|
get id(): string | undefined;
|
|
372
462
|
get cookies(): BrowserCookieManagerInterface;
|
|
@@ -381,14 +471,14 @@ export declare class BrowserContext implements BrowserContextInterface {
|
|
|
381
471
|
close(): Promise<void>;
|
|
382
472
|
}
|
|
383
473
|
|
|
384
|
-
/**
|
|
474
|
+
/** Maps the browser-context lifecycle events. */
|
|
385
475
|
export declare type BrowserContextEventMap = {
|
|
386
476
|
readonly page: readonly [page: BrowserPageInterface];
|
|
387
477
|
readonly close: readonly [];
|
|
388
478
|
};
|
|
389
479
|
|
|
390
480
|
/**
|
|
391
|
-
*
|
|
481
|
+
* Represents an isolated browser session over a CDP browser context.
|
|
392
482
|
*
|
|
393
483
|
* @remarks
|
|
394
484
|
* Follows the manager accessor pattern:
|
|
@@ -408,23 +498,51 @@ export declare interface BrowserContextInterface {
|
|
|
408
498
|
readonly permissions: BrowserPermissionManagerInterface;
|
|
409
499
|
readonly storage: BrowserStorageManagerInterface;
|
|
410
500
|
readonly emulation: BrowserEmulationManagerInterface;
|
|
501
|
+
/** Returns one page by index, or the first page. */
|
|
411
502
|
page(index?: number): BrowserPageInterface | undefined;
|
|
503
|
+
/** Returns every page in creation order. */
|
|
412
504
|
pages(): readonly BrowserPageInterface[];
|
|
505
|
+
/** Opens a page in this context. */
|
|
413
506
|
create(options?: BrowserPageOptions): Promise<BrowserPageInterface>;
|
|
507
|
+
/**
|
|
508
|
+
* Synchronizes pages from the given CDP targets, which the server discovers and core never
|
|
509
|
+
* fetches. Performs a destructive diff rather than an additive merge: a page whose target
|
|
510
|
+
* id is missing from `targets` is closed and dropped, and a target that is not yet tracked
|
|
511
|
+
* is attached and added.
|
|
512
|
+
*/
|
|
414
513
|
sync(targets: readonly CDPTarget[]): Promise<void>;
|
|
514
|
+
/**
|
|
515
|
+
* Releases local pages and detaches their sessions without disposing the remote browser
|
|
516
|
+
* context.
|
|
517
|
+
*/
|
|
415
518
|
destroy(): Promise<void>;
|
|
519
|
+
/**
|
|
520
|
+
* Closes remote pages, disposes the remote browser context, and releases local resources.
|
|
521
|
+
*/
|
|
416
522
|
close(): Promise<void>;
|
|
417
523
|
}
|
|
418
524
|
|
|
419
|
-
/**
|
|
525
|
+
/**
|
|
526
|
+
* Describes the options for creating and configuring an isolated browser context.
|
|
527
|
+
*
|
|
528
|
+
* @remarks
|
|
529
|
+
* - `on` — initial event listeners wired at construction
|
|
530
|
+
* - `error` — observer error handler forwarded to the emitter
|
|
531
|
+
* - `proxy` — proxy server and bypass list for the context
|
|
532
|
+
* - `origins` — origins granted universal network access
|
|
533
|
+
* - `downloads` — download policy for the context
|
|
534
|
+
* - `emulation` — emulation overrides inherited by every page of the context
|
|
535
|
+
*/
|
|
420
536
|
export declare interface BrowserContextOptions {
|
|
537
|
+
readonly on?: EmitterHooks<BrowserContextEventMap>;
|
|
538
|
+
readonly error?: EmitterErrorHandler;
|
|
421
539
|
readonly proxy?: BrowserProxy;
|
|
422
540
|
readonly origins?: readonly string[];
|
|
423
541
|
readonly downloads?: BrowserDownloadOptions;
|
|
424
542
|
readonly emulation?: BrowserEmulationOptions;
|
|
425
543
|
}
|
|
426
544
|
|
|
427
|
-
/**
|
|
545
|
+
/** Represents one cookie returned from a browser context. */
|
|
428
546
|
export declare interface BrowserCookie {
|
|
429
547
|
readonly name: string;
|
|
430
548
|
readonly value: string;
|
|
@@ -437,14 +555,14 @@ export declare interface BrowserCookie {
|
|
|
437
555
|
readonly partition: BrowserCookiePartition | undefined;
|
|
438
556
|
}
|
|
439
557
|
|
|
440
|
-
/**
|
|
558
|
+
/** Describes optional narrowing criteria for clearing context cookies. */
|
|
441
559
|
export declare interface BrowserCookieFilter {
|
|
442
560
|
readonly name?: string;
|
|
443
561
|
readonly domain?: string;
|
|
444
562
|
readonly path?: string;
|
|
445
563
|
}
|
|
446
564
|
|
|
447
|
-
/**
|
|
565
|
+
/** Describes the input used to create or replace a browser cookie. */
|
|
448
566
|
export declare interface BrowserCookieInput {
|
|
449
567
|
readonly name: string;
|
|
450
568
|
readonly value: string;
|
|
@@ -460,31 +578,52 @@ export declare interface BrowserCookieInput {
|
|
|
460
578
|
}
|
|
461
579
|
|
|
462
580
|
/**
|
|
463
|
-
*
|
|
581
|
+
* Performs cookie operations isolated to one browser context.
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```ts
|
|
585
|
+
* import { BrowserCookieManager } from '@orkestrel/browser'
|
|
586
|
+
*
|
|
587
|
+
* const cookies = new BrowserCookieManager(client)
|
|
588
|
+
* await cookies.set([{ name: 'session', value: 'value', url: 'https://example.com/' }])
|
|
589
|
+
* const current = await cookies.cookies(['https://example.com/'])
|
|
590
|
+
* ```
|
|
464
591
|
*/
|
|
465
592
|
export declare class BrowserCookieManager implements BrowserCookieManagerInterface {
|
|
466
593
|
#private;
|
|
467
594
|
constructor(client: CDPClientInterface, context?: string);
|
|
468
|
-
|
|
595
|
+
cookies(urls?: readonly string[]): Promise<readonly BrowserCookie[]>;
|
|
469
596
|
set(cookies: readonly BrowserCookieInput[]): Promise<void>;
|
|
470
597
|
clear(filter?: BrowserCookieFilter): Promise<void>;
|
|
471
598
|
}
|
|
472
599
|
|
|
473
|
-
/**
|
|
600
|
+
/** Provides cookie operations scoped to one browser context. */
|
|
474
601
|
export declare interface BrowserCookieManagerInterface {
|
|
475
|
-
|
|
602
|
+
/** Reads the context cookies, optionally narrowed to the given URLs. */
|
|
603
|
+
cookies(urls?: readonly string[]): Promise<readonly BrowserCookie[]>;
|
|
604
|
+
/** Writes the given cookies into the context. */
|
|
476
605
|
set(cookies: readonly BrowserCookieInput[]): Promise<void>;
|
|
606
|
+
/** Deletes the context cookies matching the filter, or every cookie when given none. */
|
|
477
607
|
clear(filter?: BrowserCookieFilter): Promise<void>;
|
|
478
608
|
}
|
|
479
609
|
|
|
480
|
-
/**
|
|
610
|
+
/** Describes a cookie partition key used by CHIPS-partitioned cookies. */
|
|
481
611
|
export declare interface BrowserCookiePartition {
|
|
482
612
|
readonly site: string;
|
|
483
613
|
readonly ancestor?: boolean;
|
|
484
614
|
}
|
|
485
615
|
|
|
486
616
|
/**
|
|
487
|
-
* JavaScript precise coverage and CSS rule usage for one page target.
|
|
617
|
+
* Collects JavaScript precise coverage and CSS rule usage for one page target.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```ts
|
|
621
|
+
* import { BrowserCoverage } from '@orkestrel/browser'
|
|
622
|
+
*
|
|
623
|
+
* const coverage = new BrowserCoverage(page)
|
|
624
|
+
* await coverage.start({ javascript: true, css: true })
|
|
625
|
+
* const usage = await coverage.stop() // { scripts, styles }
|
|
626
|
+
* ```
|
|
488
627
|
*/
|
|
489
628
|
export declare class BrowserCoverage implements BrowserCoverageInterface {
|
|
490
629
|
#private;
|
|
@@ -495,86 +634,98 @@ export declare class BrowserCoverage implements BrowserCoverageInterface {
|
|
|
495
634
|
destroy(): Promise<void>;
|
|
496
635
|
}
|
|
497
636
|
|
|
498
|
-
/**
|
|
637
|
+
/** Drives the coverage capture lifecycle. */
|
|
499
638
|
export declare interface BrowserCoverageInterface {
|
|
500
639
|
readonly active: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Arms the requested domains. Throws a `BrowserError` when collection is already active or
|
|
642
|
+
* when neither domain is requested.
|
|
643
|
+
*/
|
|
501
644
|
start(options?: BrowserCoverageOptions): Promise<void>;
|
|
645
|
+
/** Reads the collected usage and disarms every domain it armed. */
|
|
502
646
|
stop(): Promise<BrowserCoverageResult>;
|
|
647
|
+
/**
|
|
648
|
+
* Stops an active collector, discarding any failure, and does nothing when no collection
|
|
649
|
+
* is running.
|
|
650
|
+
*/
|
|
503
651
|
destroy(): Promise<void>;
|
|
504
652
|
}
|
|
505
653
|
|
|
506
|
-
/**
|
|
654
|
+
/** Describes the options for a coverage capture. */
|
|
507
655
|
export declare interface BrowserCoverageOptions {
|
|
508
656
|
readonly javascript?: boolean;
|
|
509
657
|
readonly css?: boolean;
|
|
510
658
|
readonly detailed?: boolean;
|
|
511
659
|
}
|
|
512
660
|
|
|
513
|
-
/**
|
|
661
|
+
/** Describes a source range reported by JavaScript or CSS coverage. */
|
|
514
662
|
export declare interface BrowserCoverageRange {
|
|
515
663
|
readonly start: number;
|
|
516
664
|
readonly end: number;
|
|
517
665
|
readonly count: number;
|
|
518
666
|
}
|
|
519
667
|
|
|
520
|
-
/**
|
|
668
|
+
/** Describes combined JavaScript and CSS usage. */
|
|
521
669
|
export declare interface BrowserCoverageResult {
|
|
522
670
|
readonly scripts: readonly BrowserScriptCoverage[];
|
|
523
671
|
readonly styles: readonly BrowserStyleCoverage[];
|
|
524
672
|
}
|
|
525
673
|
|
|
526
|
-
/** HTTP basic-auth credentials applied to context pages. */
|
|
674
|
+
/** Describes the HTTP basic-auth credentials applied to context pages. */
|
|
527
675
|
export declare interface BrowserCredentials {
|
|
528
676
|
readonly username: string;
|
|
529
677
|
readonly password: string;
|
|
530
678
|
}
|
|
531
679
|
|
|
532
680
|
/**
|
|
533
|
-
*
|
|
681
|
+
* Groups the tracing, coverage, performance, and profiler classes beneath one page.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* import { BrowserDiagnostics } from '@orkestrel/browser'
|
|
686
|
+
*
|
|
687
|
+
* const diagnostics = new BrowserDiagnostics(page)
|
|
688
|
+
* const metrics = await diagnostics.performance.metrics()
|
|
689
|
+
* await diagnostics.destroy()
|
|
690
|
+
* ```
|
|
534
691
|
*/
|
|
535
692
|
export declare class BrowserDiagnostics implements BrowserDiagnosticsInterface {
|
|
536
693
|
#private;
|
|
537
|
-
constructor(frame: BrowserFrameInterface, writer?:
|
|
694
|
+
constructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface);
|
|
538
695
|
get tracing(): BrowserTracingInterface;
|
|
539
696
|
get coverage(): BrowserCoverageInterface;
|
|
540
697
|
get performance(): BrowserPerformanceInterface;
|
|
698
|
+
get profiler(): BrowserProfilerInterface;
|
|
541
699
|
destroy(): Promise<void>;
|
|
542
700
|
}
|
|
543
701
|
|
|
544
|
-
/**
|
|
702
|
+
/** Groups the diagnostics by capability. */
|
|
545
703
|
export declare interface BrowserDiagnosticsInterface {
|
|
546
704
|
readonly tracing: BrowserTracingInterface;
|
|
547
705
|
readonly coverage: BrowserCoverageInterface;
|
|
548
706
|
readonly performance: BrowserPerformanceInterface;
|
|
707
|
+
readonly profiler: BrowserProfilerInterface;
|
|
708
|
+
/** Tears down every diagnostics capability this page's group owns. */
|
|
549
709
|
destroy(): Promise<void>;
|
|
550
710
|
}
|
|
551
711
|
|
|
552
|
-
/**
|
|
553
|
-
* One JavaScript dialog awaiting a user decision.
|
|
554
|
-
*/
|
|
555
|
-
export declare class BrowserDialog implements BrowserDialogInterface {
|
|
556
|
-
#private;
|
|
557
|
-
constructor(frame: BrowserFrameInterface, category: BrowserDialogCategory, message: string, value: string);
|
|
558
|
-
get category(): BrowserDialogCategory;
|
|
559
|
-
get message(): string;
|
|
560
|
-
get default(): string;
|
|
561
|
-
accept(value?: string): Promise<void>;
|
|
562
|
-
dismiss(): Promise<void>;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/** JavaScript dialog category reported by Chromium. */
|
|
712
|
+
/** Names a JavaScript dialog category reported by Chromium. */
|
|
566
713
|
export declare type BrowserDialogCategory = 'alert' | 'confirm' | 'prompt' | 'beforeunload';
|
|
567
714
|
|
|
568
|
-
/**
|
|
715
|
+
/** Represents one active JavaScript dialog. */
|
|
569
716
|
export declare interface BrowserDialogInterface {
|
|
570
717
|
readonly category: BrowserDialogCategory;
|
|
571
718
|
readonly message: string;
|
|
572
719
|
readonly default: string;
|
|
720
|
+
/**
|
|
721
|
+
* Accepts the dialog, optionally supplying prompt text. Throws once the dialog is handled.
|
|
722
|
+
*/
|
|
573
723
|
accept(value?: string): Promise<void>;
|
|
724
|
+
/** Dismisses the dialog. Throws once the dialog is handled. */
|
|
574
725
|
dismiss(): Promise<void>;
|
|
575
726
|
}
|
|
576
727
|
|
|
577
|
-
/**
|
|
728
|
+
/** Represents one document captured in a CDP DOM snapshot. */
|
|
578
729
|
export declare interface BrowserDocument {
|
|
579
730
|
readonly index: number;
|
|
580
731
|
readonly frame: string;
|
|
@@ -586,32 +737,21 @@ export declare interface BrowserDocument {
|
|
|
586
737
|
readonly height: number | undefined;
|
|
587
738
|
}
|
|
588
739
|
|
|
589
|
-
/**
|
|
590
|
-
* One Chromium download and its progress lifecycle.
|
|
591
|
-
*/
|
|
592
|
-
export declare class BrowserDownload implements BrowserDownloadInterface {
|
|
593
|
-
#private;
|
|
594
|
-
constructor(client: CDPClientInterface, id: string, url: string, name: string, context?: string);
|
|
595
|
-
get emitter(): EmitterInterface<BrowserDownloadEventMap>;
|
|
596
|
-
get id(): string;
|
|
597
|
-
get url(): string;
|
|
598
|
-
get name(): string;
|
|
599
|
-
get status(): BrowserDownloadStatus;
|
|
600
|
-
get received(): number;
|
|
601
|
-
get total(): number;
|
|
602
|
-
get path(): string | undefined;
|
|
603
|
-
cancel(): Promise<void>;
|
|
604
|
-
update(progress: BrowserDownloadProgress): void;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/** Download progress events. */
|
|
740
|
+
/** Maps the download progress events. */
|
|
608
741
|
export declare type BrowserDownloadEventMap = {
|
|
609
742
|
readonly progress: readonly [received: number, total: number];
|
|
610
743
|
readonly complete: readonly [path: string | undefined];
|
|
611
744
|
readonly cancel: readonly [];
|
|
612
745
|
};
|
|
613
746
|
|
|
614
|
-
/**
|
|
747
|
+
/**
|
|
748
|
+
* Represents one context download tracked through Chromium's Browser domain.
|
|
749
|
+
*
|
|
750
|
+
* @remarks
|
|
751
|
+
* Progress arrives from the owning page, which drives the concrete
|
|
752
|
+
* `BrowserDownload`. `update` is on this contract because the class exposes
|
|
753
|
+
* exactly its interface methods.
|
|
754
|
+
*/
|
|
615
755
|
export declare interface BrowserDownloadInterface {
|
|
616
756
|
readonly emitter: EmitterInterface<BrowserDownloadEventMap>;
|
|
617
757
|
readonly id: string;
|
|
@@ -621,17 +761,22 @@ export declare interface BrowserDownloadInterface {
|
|
|
621
761
|
readonly received: number;
|
|
622
762
|
readonly total: number;
|
|
623
763
|
readonly path: string | undefined;
|
|
764
|
+
/**
|
|
765
|
+
* Sends CDP `Browser.cancelDownload` for this download, and is ignored unless the status
|
|
766
|
+
* is still pending.
|
|
767
|
+
*/
|
|
624
768
|
cancel(): Promise<void>;
|
|
769
|
+
/** Records one step of the download's progress. The owning page drives it. */
|
|
625
770
|
update(progress: BrowserDownloadProgress): void;
|
|
626
771
|
}
|
|
627
772
|
|
|
628
|
-
/**
|
|
773
|
+
/** Describes the download policy for a browser context. */
|
|
629
774
|
export declare interface BrowserDownloadOptions {
|
|
630
775
|
readonly path: string;
|
|
631
776
|
readonly named?: boolean;
|
|
632
777
|
}
|
|
633
778
|
|
|
634
|
-
/**
|
|
779
|
+
/** Describes a protocol-neutral download progress update. */
|
|
635
780
|
export declare interface BrowserDownloadProgress {
|
|
636
781
|
readonly status: BrowserDownloadStatus;
|
|
637
782
|
readonly received: number;
|
|
@@ -639,7 +784,7 @@ export declare interface BrowserDownloadProgress {
|
|
|
639
784
|
readonly path?: string;
|
|
640
785
|
}
|
|
641
786
|
|
|
642
|
-
/**
|
|
787
|
+
/** Describes a decoded `Browser.downloadWillBegin` event. */
|
|
643
788
|
export declare interface BrowserDownloadStart {
|
|
644
789
|
readonly id: string;
|
|
645
790
|
readonly url: string;
|
|
@@ -647,28 +792,54 @@ export declare interface BrowserDownloadStart {
|
|
|
647
792
|
readonly frame: string;
|
|
648
793
|
}
|
|
649
794
|
|
|
650
|
-
/**
|
|
795
|
+
/** Names a download lifecycle phase. */
|
|
651
796
|
export declare type BrowserDownloadStatus = 'pending' | 'complete' | 'cancelled';
|
|
652
797
|
|
|
653
798
|
/**
|
|
654
|
-
*
|
|
799
|
+
* Describes the options for a trusted mouse drag.
|
|
800
|
+
*
|
|
801
|
+
* @remarks
|
|
802
|
+
* - `button` — pressed mouse button (default `'left'`)
|
|
803
|
+
* - `steps` — interpolated move events between start and end (default `10`)
|
|
804
|
+
*/
|
|
805
|
+
export declare interface BrowserDragOptions extends BrowserInputOptions {
|
|
806
|
+
readonly button?: BrowserMouseButton;
|
|
807
|
+
readonly steps?: number;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Applies rendering, identity, location, and network emulation for context pages.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```ts
|
|
815
|
+
* import { BrowserEmulationManager } from '@orkestrel/browser'
|
|
816
|
+
*
|
|
817
|
+
* const emulation = new BrowserEmulationManager(() => context.pages())
|
|
818
|
+
* await emulation.apply({ locale: 'en-US', media: { scheme: 'dark' } })
|
|
819
|
+
* await emulation.clear()
|
|
820
|
+
* ```
|
|
655
821
|
*/
|
|
656
822
|
export declare class BrowserEmulationManager implements BrowserEmulationManagerInterface {
|
|
657
823
|
#private;
|
|
658
|
-
constructor(pages:
|
|
824
|
+
constructor(pages: BrowserPagesFunction, options?: BrowserEmulationOptions);
|
|
659
825
|
apply(options: BrowserEmulationOptions): Promise<void>;
|
|
660
826
|
clear(): Promise<void>;
|
|
661
827
|
attach(page: BrowserPageInterface): Promise<void>;
|
|
662
828
|
}
|
|
663
829
|
|
|
664
|
-
/**
|
|
830
|
+
/** Configures context-scoped emulation. */
|
|
665
831
|
export declare interface BrowserEmulationManagerInterface {
|
|
832
|
+
/**
|
|
833
|
+
* Clears the superseded overrides and applies the given ones to every page of the context.
|
|
834
|
+
*/
|
|
666
835
|
apply(options: BrowserEmulationOptions): Promise<void>;
|
|
836
|
+
/** Removes every override this manager applied. */
|
|
667
837
|
clear(): Promise<void>;
|
|
838
|
+
/** Applies the retained overrides to a newly created page. */
|
|
668
839
|
attach(page: BrowserPageInterface): Promise<void>;
|
|
669
840
|
}
|
|
670
841
|
|
|
671
|
-
/**
|
|
842
|
+
/** Describes network and rendering overrides inherited by context pages. */
|
|
672
843
|
export declare interface BrowserEmulationOptions {
|
|
673
844
|
readonly viewport?: BrowserViewport;
|
|
674
845
|
readonly user?: BrowserUserAgent;
|
|
@@ -682,11 +853,11 @@ export declare interface BrowserEmulationOptions {
|
|
|
682
853
|
}
|
|
683
854
|
|
|
684
855
|
/**
|
|
685
|
-
*
|
|
856
|
+
* Represents the base error for all browser automation operations, carrying the code
|
|
857
|
+
* `BROWSER_ERROR` and a `context` record.
|
|
686
858
|
*
|
|
687
859
|
* @remarks
|
|
688
|
-
*
|
|
689
|
-
* callers can branch in a `catch` without parsing message strings.
|
|
860
|
+
* A caller branches in a `catch` on the `code` rather than parsing message strings.
|
|
690
861
|
*/
|
|
691
862
|
export declare class BrowserError extends Error {
|
|
692
863
|
readonly code: string;
|
|
@@ -694,30 +865,29 @@ export declare class BrowserError extends Error {
|
|
|
694
865
|
constructor(message: string, code?: string, context?: Readonly<Record<string, unknown>>);
|
|
695
866
|
}
|
|
696
867
|
|
|
697
|
-
/**
|
|
698
|
-
* One intercepted file input selection.
|
|
699
|
-
*/
|
|
700
|
-
export declare class BrowserFileChooser implements BrowserFileChooserInterface {
|
|
701
|
-
#private;
|
|
702
|
-
constructor(frame: BrowserFrameInterface, backend: number, multiple: boolean);
|
|
703
|
-
get multiple(): boolean;
|
|
704
|
-
upload(files: readonly string[]): Promise<void>;
|
|
705
|
-
cancel(): Promise<void>;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
/** One intercepted file chooser. */
|
|
868
|
+
/** Represents one intercepted file chooser. */
|
|
709
869
|
export declare interface BrowserFileChooserInterface {
|
|
710
870
|
readonly multiple: boolean;
|
|
871
|
+
/**
|
|
872
|
+
* Sets the chosen files. Throws when a single-file chooser is given several, and once the
|
|
873
|
+
* chooser is already handled.
|
|
874
|
+
*/
|
|
711
875
|
upload(files: readonly string[]): Promise<void>;
|
|
876
|
+
/** Clears the selection. Throws once the chooser is already handled. */
|
|
712
877
|
cancel(): Promise<void>;
|
|
713
878
|
}
|
|
714
879
|
|
|
715
|
-
/** Options for filtering a locator. */
|
|
716
|
-
export declare interface BrowserFilterOptions extends BrowserLocatorFilter {
|
|
717
|
-
}
|
|
718
|
-
|
|
719
880
|
/**
|
|
720
|
-
*
|
|
881
|
+
* Represents one attached document frame, evaluated through its own CDP execution world.
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* ```ts
|
|
885
|
+
* import { BrowserFrame } from '@orkestrel/browser'
|
|
886
|
+
*
|
|
887
|
+
* const frame = new BrowserFrame(client, 'session-1', 'frame-1', 'https://example.com')
|
|
888
|
+
* await frame.fill('[name=email]', 'ada@example.com')
|
|
889
|
+
* const title = await frame.title()
|
|
890
|
+
* ```
|
|
721
891
|
*/
|
|
722
892
|
export declare class BrowserFrame implements BrowserFrameInterface {
|
|
723
893
|
#private;
|
|
@@ -739,7 +909,7 @@ export declare class BrowserFrame implements BrowserFrameInterface {
|
|
|
739
909
|
evaluate(expression: string, timeout?: number): Promise<unknown>;
|
|
740
910
|
handle(expression: string): Promise<BrowserHandleInterface>;
|
|
741
911
|
wait(selector: string, options?: BrowserWaitOptions): Promise<void>;
|
|
742
|
-
send(method: string, params?: Readonly<Record<string, unknown>>,
|
|
912
|
+
send(method: string, params?: Readonly<Record<string, unknown>>, options?: BrowserSendOptions): Promise<unknown>;
|
|
743
913
|
subscribe(method: string, handler: CDPHandler): Promise<void>;
|
|
744
914
|
unsubscribe(method: string, handler: CDPHandler): Promise<void>;
|
|
745
915
|
save(path: string, _bytes: Uint8Array): Promise<void>;
|
|
@@ -748,7 +918,7 @@ export declare class BrowserFrame implements BrowserFrameInterface {
|
|
|
748
918
|
}
|
|
749
919
|
|
|
750
920
|
/**
|
|
751
|
-
*
|
|
921
|
+
* Describes serializable frame metadata decoded from CDP `Page.getFrameTree`.
|
|
752
922
|
*
|
|
753
923
|
* @remarks
|
|
754
924
|
* - `id` — the frame's CDP frame id
|
|
@@ -764,7 +934,7 @@ export declare interface BrowserFrameInfo {
|
|
|
764
934
|
}
|
|
765
935
|
|
|
766
936
|
/**
|
|
767
|
-
*
|
|
937
|
+
* Provides the operations shared by a top-level page and an iframe document.
|
|
768
938
|
*
|
|
769
939
|
* @remarks
|
|
770
940
|
* - `id` — CDP frame id
|
|
@@ -792,31 +962,68 @@ export declare interface BrowserFrameInterface {
|
|
|
792
962
|
readonly keyboard: BrowserKeyboardInterface;
|
|
793
963
|
readonly mouse: BrowserMouseInterface;
|
|
794
964
|
readonly touch: BrowserTouchInterface;
|
|
965
|
+
/** Resolves the frame document title. */
|
|
795
966
|
title(): Promise<string>;
|
|
967
|
+
/** Extracts the URL, title, HTML, and visible text under the result-size guards. */
|
|
796
968
|
content(): Promise<BrowserContentResult>;
|
|
969
|
+
/**
|
|
970
|
+
* Distills the frame HTML to reader-facing plain text, with boilerplate and hidden regions
|
|
971
|
+
* pruned.
|
|
972
|
+
*/
|
|
797
973
|
article(): Promise<string>;
|
|
974
|
+
/**
|
|
975
|
+
* Clicks a CSS-selector match, strict by default and requiring it visible and enabled.
|
|
976
|
+
*/
|
|
798
977
|
click(selector: string, options?: BrowserActionOptions): Promise<void>;
|
|
978
|
+
/**
|
|
979
|
+
* Fills an editable input or contenteditable element, strict by default, dispatching input
|
|
980
|
+
* and change events.
|
|
981
|
+
*/
|
|
799
982
|
fill(selector: string, value: string, options?: BrowserActionOptions): Promise<void>;
|
|
983
|
+
/** Selects options on an enabled `select` element, strict by default. */
|
|
800
984
|
select(selector: string, values: readonly string[], options?: BrowserActionOptions): Promise<void>;
|
|
985
|
+
/** Evaluates an expression in the frame execution world under the result-size guard. */
|
|
801
986
|
evaluate(expression: string, timeout?: number): Promise<unknown>;
|
|
987
|
+
/**
|
|
988
|
+
* Evaluates an expression by reference and returns a disposable remote object handle.
|
|
989
|
+
*/
|
|
802
990
|
handle(expression: string): Promise<BrowserHandleInterface>;
|
|
991
|
+
/** Waits for a selector to reach the attached, detached, visible, or hidden state. */
|
|
803
992
|
wait(selector: string, options?: BrowserWaitOptions): Promise<void>;
|
|
804
|
-
|
|
993
|
+
/**
|
|
994
|
+
* Issues a raw CDP method in the frame's current target session, with a trailing
|
|
995
|
+
* `BrowserSendOptions` carrying a per-call `timeout` overriding the client-wide default.
|
|
996
|
+
*/
|
|
997
|
+
send(method: string, params?: Readonly<Record<string, unknown>>, options?: BrowserSendOptions): Promise<unknown>;
|
|
998
|
+
/** Subscribes to a CDP event in the frame's current target session. */
|
|
805
999
|
subscribe(method: string, handler: CDPHandler): Promise<void>;
|
|
1000
|
+
/** Removes a frame-session CDP event subscription. */
|
|
806
1001
|
unsubscribe(method: string, handler: CDPHandler): Promise<void>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Persists bytes through a page writer; a child frame rejects because it owns no writer.
|
|
1004
|
+
*/
|
|
807
1005
|
save(path: string, bytes: Uint8Array): Promise<void>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Throws a coded `BrowserError` when the frame can no longer accept protocol work: a frame
|
|
1008
|
+
* throws once the CDP client disconnects, and a page also throws once it closes. Every
|
|
1009
|
+
* other member here calls it first.
|
|
1010
|
+
*/
|
|
808
1011
|
assert(): void;
|
|
1012
|
+
/**
|
|
1013
|
+
* Records an externally observed URL as the frame's current `url`, which a page calls from
|
|
1014
|
+
* its own `Page.frameNavigated` handler.
|
|
1015
|
+
*/
|
|
809
1016
|
update(url: string): void;
|
|
810
1017
|
}
|
|
811
1018
|
|
|
812
|
-
/**
|
|
1019
|
+
/** Describes function coverage inside one script. */
|
|
813
1020
|
export declare interface BrowserFunctionCoverage {
|
|
814
1021
|
readonly name: string;
|
|
815
1022
|
readonly ranges: readonly BrowserCoverageRange[];
|
|
816
1023
|
readonly block: boolean;
|
|
817
1024
|
}
|
|
818
1025
|
|
|
819
|
-
/**
|
|
1026
|
+
/** Describes a geographic location override. */
|
|
820
1027
|
export declare interface BrowserGeolocation {
|
|
821
1028
|
readonly latitude: number;
|
|
822
1029
|
readonly longitude: number;
|
|
@@ -824,37 +1031,31 @@ export declare interface BrowserGeolocation {
|
|
|
824
1031
|
}
|
|
825
1032
|
|
|
826
1033
|
/**
|
|
827
|
-
*
|
|
828
|
-
*/
|
|
829
|
-
export declare class BrowserHandle implements BrowserHandleInterface {
|
|
830
|
-
#private;
|
|
831
|
-
constructor(client: CDPClientInterface, session: string, id: string);
|
|
832
|
-
get id(): string;
|
|
833
|
-
value(): Promise<unknown>;
|
|
834
|
-
call(declaration: string, args?: readonly unknown[]): Promise<unknown>;
|
|
835
|
-
property(name: string): Promise<BrowserHandleInterface | undefined>;
|
|
836
|
-
properties(): Promise<Readonly<Record<string, unknown>>>;
|
|
837
|
-
dispose(): Promise<void>;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* A remote JavaScript object retained in one frame execution context.
|
|
1034
|
+
* Represents a remote JavaScript object retained in one frame execution context.
|
|
842
1035
|
*/
|
|
843
1036
|
export declare interface BrowserHandleInterface {
|
|
844
1037
|
readonly id: string;
|
|
1038
|
+
/** Reads the object back by value. */
|
|
845
1039
|
value(): Promise<unknown>;
|
|
1040
|
+
/** Runs a function declaration with the handle as `this`, by value. */
|
|
846
1041
|
call(declaration: string, args?: readonly unknown[]): Promise<unknown>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Retains one own property as its own handle, or returns `undefined` when the property is
|
|
1044
|
+
* absent.
|
|
1045
|
+
*/
|
|
847
1046
|
property(name: string): Promise<BrowserHandleInterface | undefined>;
|
|
1047
|
+
/** Reads every own property by value. */
|
|
848
1048
|
properties(): Promise<Readonly<Record<string, unknown>>>;
|
|
1049
|
+
/** Releases the retained remote object. Idempotent. */
|
|
849
1050
|
dispose(): Promise<void>;
|
|
850
1051
|
}
|
|
851
1052
|
|
|
852
|
-
/**
|
|
1053
|
+
/** Describes the standards-shaped HAR 1.2 document produced by the network manager. */
|
|
853
1054
|
export declare interface BrowserHAR {
|
|
854
1055
|
readonly log: BrowserHARLog;
|
|
855
1056
|
}
|
|
856
1057
|
|
|
857
|
-
/**
|
|
1058
|
+
/** Describes response body metadata in an HTTP archive. */
|
|
858
1059
|
export declare interface BrowserHARContent {
|
|
859
1060
|
readonly size: number;
|
|
860
1061
|
readonly mimeType: string;
|
|
@@ -863,7 +1064,7 @@ export declare interface BrowserHARContent {
|
|
|
863
1064
|
}
|
|
864
1065
|
|
|
865
1066
|
/**
|
|
866
|
-
*
|
|
1067
|
+
* Represents one cookie in an HTTP archive.
|
|
867
1068
|
*
|
|
868
1069
|
* @remarks
|
|
869
1070
|
* HAR data preserves the official HAR 1.2 JSON field names. These compound
|
|
@@ -878,13 +1079,13 @@ export declare interface BrowserHARCookie extends BrowserHARValue {
|
|
|
878
1079
|
readonly secure?: boolean;
|
|
879
1080
|
}
|
|
880
1081
|
|
|
881
|
-
/**
|
|
1082
|
+
/** Describes the tool identity embedded in an HTTP archive. */
|
|
882
1083
|
export declare interface BrowserHARCreator {
|
|
883
1084
|
readonly name: string;
|
|
884
1085
|
readonly version: string;
|
|
885
1086
|
}
|
|
886
1087
|
|
|
887
|
-
/**
|
|
1088
|
+
/** Represents one completed HTTP exchange in a HAR recording. */
|
|
888
1089
|
export declare interface BrowserHAREntry {
|
|
889
1090
|
readonly startedDateTime: string;
|
|
890
1091
|
readonly time: number;
|
|
@@ -895,14 +1096,14 @@ export declare interface BrowserHAREntry {
|
|
|
895
1096
|
}
|
|
896
1097
|
|
|
897
1098
|
/**
|
|
898
|
-
*
|
|
1099
|
+
* Converts HAR name/value headers into a Fetch-domain header record.
|
|
899
1100
|
*
|
|
900
1101
|
* @param headers - HAR header entries
|
|
901
1102
|
* @returns Header record with later duplicate names replacing earlier values
|
|
902
1103
|
*/
|
|
903
1104
|
export declare function browserHARHeadersToRecord(headers: readonly BrowserHARValue[]): Readonly<Record<string, string>>;
|
|
904
1105
|
|
|
905
|
-
/** HAR 1.2 log object. */
|
|
1106
|
+
/** Describes the HAR 1.2 log object. */
|
|
906
1107
|
export declare interface BrowserHARLog {
|
|
907
1108
|
readonly version: '1.2';
|
|
908
1109
|
readonly creator: BrowserHARCreator;
|
|
@@ -910,11 +1111,20 @@ export declare interface BrowserHARLog {
|
|
|
910
1111
|
}
|
|
911
1112
|
|
|
912
1113
|
/**
|
|
913
|
-
*
|
|
1114
|
+
* Records and replays HTTP archives over one page network manager.
|
|
1115
|
+
*
|
|
1116
|
+
* @example
|
|
1117
|
+
* ```ts
|
|
1118
|
+
* import { BrowserHARManager } from '@orkestrel/browser'
|
|
1119
|
+
*
|
|
1120
|
+
* const har = new BrowserHARManager(page.network)
|
|
1121
|
+
* await har.start({ content: true })
|
|
1122
|
+
* const archive = await har.stop() // { log: { version: '1.2', creator, entries } }
|
|
1123
|
+
* ```
|
|
914
1124
|
*/
|
|
915
1125
|
export declare class BrowserHARManager implements BrowserHARManagerInterface {
|
|
916
1126
|
#private;
|
|
917
|
-
constructor(network: BrowserNetworkManagerInterface, writer?:
|
|
1127
|
+
constructor(network: BrowserNetworkManagerInterface, writer?: BrowserWriterInterface);
|
|
918
1128
|
get recording(): boolean;
|
|
919
1129
|
start(options?: BrowserHAROptions): Promise<void>;
|
|
920
1130
|
stop(): Promise<BrowserHAR>;
|
|
@@ -922,40 +1132,44 @@ export declare class BrowserHARManager implements BrowserHARManagerInterface {
|
|
|
922
1132
|
clear(): Promise<void>;
|
|
923
1133
|
}
|
|
924
1134
|
|
|
925
|
-
/** HAR recording and replay operations. */
|
|
1135
|
+
/** Provides HAR recording and replay operations. */
|
|
926
1136
|
export declare interface BrowserHARManagerInterface {
|
|
927
1137
|
readonly recording: boolean;
|
|
1138
|
+
/** Begins recording exchanges, optionally capturing response content. */
|
|
928
1139
|
start(options?: BrowserHAROptions): Promise<void>;
|
|
1140
|
+
/** Ends recording and returns the archive, writing it when a path was given. */
|
|
929
1141
|
stop(): Promise<BrowserHAR>;
|
|
1142
|
+
/** Serves matching requests from an archive instead of from the network. */
|
|
930
1143
|
replay(har: BrowserHAR, options?: BrowserHARReplayOptions): Promise<void>;
|
|
1144
|
+
/** Drops the recorded entries and any active replay without ending the recording. */
|
|
931
1145
|
clear(): Promise<void>;
|
|
932
1146
|
}
|
|
933
1147
|
|
|
934
|
-
/** HAR recording
|
|
1148
|
+
/** Describes the options for a HAR recording. */
|
|
935
1149
|
export declare interface BrowserHAROptions {
|
|
936
1150
|
readonly path?: string;
|
|
937
1151
|
readonly content?: boolean;
|
|
938
1152
|
}
|
|
939
1153
|
|
|
940
|
-
/**
|
|
1154
|
+
/** Holds recording state until a request finishes; a new value replaces it on each update. */
|
|
941
1155
|
export declare interface BrowserHARPending {
|
|
942
1156
|
readonly request: BrowserRequest;
|
|
943
1157
|
readonly started: number;
|
|
944
1158
|
readonly response: BrowserResponse | undefined;
|
|
945
1159
|
}
|
|
946
1160
|
|
|
947
|
-
/**
|
|
1161
|
+
/** Describes request body metadata in an HTTP archive. */
|
|
948
1162
|
export declare interface BrowserHARPost {
|
|
949
1163
|
readonly mimeType: string;
|
|
950
1164
|
readonly text: string;
|
|
951
1165
|
}
|
|
952
1166
|
|
|
953
|
-
/** HAR replay behavior. */
|
|
1167
|
+
/** Describes HAR replay behavior. */
|
|
954
1168
|
export declare interface BrowserHARReplayOptions {
|
|
955
1169
|
readonly fallback?: boolean;
|
|
956
1170
|
}
|
|
957
1171
|
|
|
958
|
-
/** HAR 1.2 request entry. */
|
|
1172
|
+
/** Describes a HAR 1.2 request entry. */
|
|
959
1173
|
export declare interface BrowserHARRequest {
|
|
960
1174
|
readonly method: string;
|
|
961
1175
|
readonly url: string;
|
|
@@ -968,7 +1182,7 @@ export declare interface BrowserHARRequest {
|
|
|
968
1182
|
readonly bodySize: number;
|
|
969
1183
|
}
|
|
970
1184
|
|
|
971
|
-
/** HAR 1.2 response entry. */
|
|
1185
|
+
/** Describes a HAR 1.2 response entry. */
|
|
972
1186
|
export declare interface BrowserHARResponse {
|
|
973
1187
|
readonly status: number;
|
|
974
1188
|
readonly statusText: string;
|
|
@@ -981,7 +1195,7 @@ export declare interface BrowserHARResponse {
|
|
|
981
1195
|
readonly bodySize: number;
|
|
982
1196
|
}
|
|
983
1197
|
|
|
984
|
-
/** HAR 1.2 phase timings in milliseconds. */
|
|
1198
|
+
/** Holds HAR 1.2 phase timings in milliseconds. */
|
|
985
1199
|
export declare interface BrowserHARTimings {
|
|
986
1200
|
readonly blocked: number;
|
|
987
1201
|
readonly dns: number;
|
|
@@ -992,21 +1206,31 @@ export declare interface BrowserHARTimings {
|
|
|
992
1206
|
readonly ssl: number;
|
|
993
1207
|
}
|
|
994
1208
|
|
|
995
|
-
/**
|
|
1209
|
+
/** Represents one name/value pair in an HTTP archive. */
|
|
996
1210
|
export declare interface BrowserHARValue {
|
|
997
1211
|
readonly name: string;
|
|
998
1212
|
readonly value: string;
|
|
999
1213
|
}
|
|
1000
1214
|
|
|
1001
1215
|
/**
|
|
1002
|
-
*
|
|
1216
|
+
* Converts a header record to Fetch-domain name/value entries.
|
|
1003
1217
|
*
|
|
1004
1218
|
* @param headers - Header record
|
|
1005
1219
|
* @returns Protocol header entries
|
|
1006
1220
|
*/
|
|
1007
1221
|
export declare function browserHeadersToProtocol(headers: Readonly<Record<string, string>>): ReadonlyArray<Readonly<Record<string, string>>>;
|
|
1008
1222
|
|
|
1009
|
-
/**
|
|
1223
|
+
/**
|
|
1224
|
+
* Describes the options shared by every trusted input operation.
|
|
1225
|
+
*
|
|
1226
|
+
* @remarks
|
|
1227
|
+
* - `delay` — milliseconds between the transitions the operation dispatches
|
|
1228
|
+
*/
|
|
1229
|
+
export declare interface BrowserInputOptions {
|
|
1230
|
+
readonly delay?: number;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/** Describes normalized CDP keyboard key data. */
|
|
1010
1234
|
export declare interface BrowserKey {
|
|
1011
1235
|
readonly key: string;
|
|
1012
1236
|
readonly code: string;
|
|
@@ -1015,28 +1239,49 @@ export declare interface BrowserKey {
|
|
|
1015
1239
|
}
|
|
1016
1240
|
|
|
1017
1241
|
/**
|
|
1018
|
-
*
|
|
1242
|
+
* Sends trusted keyboard input through Chromium's CDP Input domain.
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```ts
|
|
1246
|
+
* import { BrowserKeyboard } from '@orkestrel/browser'
|
|
1247
|
+
*
|
|
1248
|
+
* const keyboard = new BrowserKeyboard(page)
|
|
1249
|
+
* await keyboard.type('orkestrel', { delay: 10 })
|
|
1250
|
+
* await keyboard.press('Control+Enter')
|
|
1251
|
+
* ```
|
|
1019
1252
|
*/
|
|
1020
1253
|
export declare class BrowserKeyboard implements BrowserKeyboardInterface {
|
|
1021
1254
|
#private;
|
|
1022
1255
|
constructor(frame: BrowserFrameInterface);
|
|
1023
1256
|
down(value: string): Promise<void>;
|
|
1024
1257
|
up(value: string): Promise<void>;
|
|
1025
|
-
press(value: string, options?:
|
|
1026
|
-
type(value: string, options?:
|
|
1258
|
+
press(value: string, options?: BrowserInputOptions): Promise<void>;
|
|
1259
|
+
type(value: string, options?: BrowserInputOptions): Promise<void>;
|
|
1027
1260
|
insert(value: string): Promise<void>;
|
|
1028
1261
|
}
|
|
1029
1262
|
|
|
1030
|
-
/**
|
|
1263
|
+
/** Provides keyboard input operations bound to one frame target session. */
|
|
1031
1264
|
export declare interface BrowserKeyboardInterface {
|
|
1265
|
+
/**
|
|
1266
|
+
* Presses one key and holds it, retaining it in the modifier mask when it is a modifier.
|
|
1267
|
+
*/
|
|
1032
1268
|
down(key: string): Promise<void>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Releases one key, dropping it from the modifier mask even when the release frame fails.
|
|
1271
|
+
*/
|
|
1033
1272
|
up(key: string): Promise<void>;
|
|
1034
|
-
|
|
1035
|
-
|
|
1273
|
+
/**
|
|
1274
|
+
* Presses a chord: holds its modifiers, presses and releases its terminal key, then
|
|
1275
|
+
* releases the modifiers.
|
|
1276
|
+
*/
|
|
1277
|
+
press(key: string, options?: BrowserInputOptions): Promise<void>;
|
|
1278
|
+
/** Types a string as one press and release per character. */
|
|
1279
|
+
type(value: string, options?: BrowserInputOptions): Promise<void>;
|
|
1280
|
+
/** Inserts composed text in one frame, firing no per-key events. */
|
|
1036
1281
|
insert(value: string): Promise<void>;
|
|
1037
1282
|
}
|
|
1038
1283
|
|
|
1039
|
-
/**
|
|
1284
|
+
/** Describes layout data associated with one captured DOM node. */
|
|
1040
1285
|
export declare interface BrowserLayout {
|
|
1041
1286
|
readonly bounds: BrowserRect | undefined;
|
|
1042
1287
|
readonly styles: Readonly<Record<string, string>>;
|
|
@@ -1048,7 +1293,16 @@ export declare interface BrowserLayout {
|
|
|
1048
1293
|
}
|
|
1049
1294
|
|
|
1050
1295
|
/**
|
|
1051
|
-
*
|
|
1296
|
+
* Represents a reusable strict semantic locator over one frame.
|
|
1297
|
+
*
|
|
1298
|
+
* @example
|
|
1299
|
+
* ```ts
|
|
1300
|
+
* import { BrowserLocator } from '@orkestrel/browser'
|
|
1301
|
+
*
|
|
1302
|
+
* const save = new BrowserLocator(page, { selector: 'role', value: 'button', name: 'Save' })
|
|
1303
|
+
* await save.click({ count: 2 })
|
|
1304
|
+
* const label = await save.text()
|
|
1305
|
+
* ```
|
|
1052
1306
|
*/
|
|
1053
1307
|
export declare class BrowserLocator implements BrowserLocatorInterface {
|
|
1054
1308
|
#private;
|
|
@@ -1056,24 +1310,25 @@ export declare class BrowserLocator implements BrowserLocatorInterface {
|
|
|
1056
1310
|
get frame(): BrowserFrameInterface;
|
|
1057
1311
|
get query(): BrowserQuery;
|
|
1058
1312
|
locator(selector: string): BrowserLocatorInterface;
|
|
1059
|
-
filter(options:
|
|
1313
|
+
filter(options: BrowserLocatorFilter): BrowserLocatorInterface;
|
|
1060
1314
|
first(): BrowserLocatorInterface;
|
|
1061
1315
|
last(): BrowserLocatorInterface;
|
|
1062
1316
|
item(index: number): BrowserLocatorInterface;
|
|
1063
1317
|
count(): Promise<number>;
|
|
1064
1318
|
all(): Promise<readonly BrowserLocatorInterface[]>;
|
|
1065
|
-
click(options?:
|
|
1319
|
+
click(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1066
1320
|
fill(value: string, options?: BrowserActionOptions): Promise<void>;
|
|
1067
1321
|
select(values: readonly string[], options?: BrowserActionOptions): Promise<void>;
|
|
1068
|
-
check(options?:
|
|
1069
|
-
uncheck(options?:
|
|
1070
|
-
hover(options?:
|
|
1322
|
+
check(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1323
|
+
uncheck(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1324
|
+
hover(options?: BrowserPointerOptions): Promise<void>;
|
|
1071
1325
|
focus(options?: BrowserActionOptions): Promise<void>;
|
|
1072
|
-
press(key: string, options?:
|
|
1073
|
-
type(value: string, options?:
|
|
1326
|
+
press(key: string, options?: BrowserLocatorTypeOptions): Promise<void>;
|
|
1327
|
+
type(value: string, options?: BrowserLocatorTypeOptions): Promise<void>;
|
|
1074
1328
|
clear(options?: BrowserActionOptions): Promise<void>;
|
|
1075
1329
|
wait(options?: BrowserWaitOptions): Promise<void>;
|
|
1076
|
-
text(
|
|
1330
|
+
text(): Promise<string>;
|
|
1331
|
+
texts(): Promise<readonly string[]>;
|
|
1077
1332
|
html(): Promise<string>;
|
|
1078
1333
|
value(): Promise<string>;
|
|
1079
1334
|
attribute(name: string): Promise<string | undefined>;
|
|
@@ -1082,10 +1337,18 @@ export declare class BrowserLocator implements BrowserLocatorInterface {
|
|
|
1082
1337
|
editable(): Promise<boolean>;
|
|
1083
1338
|
screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult>;
|
|
1084
1339
|
upload(options: BrowserUploadOptions): Promise<void>;
|
|
1085
|
-
drag(target: BrowserLocatorInterface, options?:
|
|
1340
|
+
drag(target: BrowserLocatorInterface, options?: BrowserLocatorDragOptions): Promise<void>;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** Describes the options for a locator click, combining element resolution with mouse input. */
|
|
1344
|
+
export declare interface BrowserLocatorClickOptions extends BrowserPointerOptions, BrowserClickOptions {
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/** Describes the options for a locator drag, combining element resolution with mouse input. */
|
|
1348
|
+
export declare interface BrowserLocatorDragOptions extends BrowserPointerOptions, BrowserDragOptions {
|
|
1086
1349
|
}
|
|
1087
1350
|
|
|
1088
|
-
/**
|
|
1351
|
+
/** Describes a declarative locator filter applied after selector resolution. */
|
|
1089
1352
|
export declare interface BrowserLocatorFilter {
|
|
1090
1353
|
readonly text?: string;
|
|
1091
1354
|
readonly exact?: boolean;
|
|
@@ -1093,42 +1356,82 @@ export declare interface BrowserLocatorFilter {
|
|
|
1093
1356
|
}
|
|
1094
1357
|
|
|
1095
1358
|
/**
|
|
1096
|
-
*
|
|
1359
|
+
* Represents a reusable strict locator over one frame.
|
|
1097
1360
|
*/
|
|
1098
1361
|
export declare interface BrowserLocatorInterface {
|
|
1099
1362
|
readonly frame: BrowserFrameInterface;
|
|
1100
1363
|
readonly query: BrowserQuery;
|
|
1364
|
+
/** Narrows to a descendant matching the CSS selector. */
|
|
1101
1365
|
locator(selector: string): BrowserLocatorInterface;
|
|
1102
|
-
filter
|
|
1366
|
+
/** Narrows to the matches satisfying the filter. */
|
|
1367
|
+
filter(options: BrowserLocatorFilter): BrowserLocatorInterface;
|
|
1368
|
+
/** Narrows to the first match. */
|
|
1103
1369
|
first(): BrowserLocatorInterface;
|
|
1370
|
+
/** Narrows to the last match. */
|
|
1104
1371
|
last(): BrowserLocatorInterface;
|
|
1372
|
+
/** Narrows to the match at the given index. */
|
|
1105
1373
|
item(index: number): BrowserLocatorInterface;
|
|
1374
|
+
/** Counts the current matches. */
|
|
1106
1375
|
count(): Promise<number>;
|
|
1376
|
+
/** Resolves one indexed locator per current match. */
|
|
1107
1377
|
all(): Promise<readonly BrowserLocatorInterface[]>;
|
|
1108
|
-
|
|
1378
|
+
/** Clicks the match with trusted input after its actionability checks pass. */
|
|
1379
|
+
click(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1380
|
+
/** Replaces the match's value with the given text. */
|
|
1109
1381
|
fill(value: string, options?: BrowserActionOptions): Promise<void>;
|
|
1382
|
+
/** Selects the given option values on the match. */
|
|
1110
1383
|
select(values: readonly string[], options?: BrowserActionOptions): Promise<void>;
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1384
|
+
/** Clicks the match unless it already reports checked. */
|
|
1385
|
+
check(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1386
|
+
/** Clicks the match unless it already reports unchecked. */
|
|
1387
|
+
uncheck(options?: BrowserLocatorClickOptions): Promise<void>;
|
|
1388
|
+
/** Moves trusted pointer input over the match. */
|
|
1389
|
+
hover(options?: BrowserPointerOptions): Promise<void>;
|
|
1390
|
+
/** Gives the match keyboard focus. */
|
|
1114
1391
|
focus(options?: BrowserActionOptions): Promise<void>;
|
|
1115
|
-
|
|
1116
|
-
|
|
1392
|
+
/** Focuses the match and presses one key or chord. */
|
|
1393
|
+
press(key: string, options?: BrowserLocatorTypeOptions): Promise<void>;
|
|
1394
|
+
/** Focuses the match and types the value one key at a time. */
|
|
1395
|
+
type(value: string, options?: BrowserLocatorTypeOptions): Promise<void>;
|
|
1396
|
+
/** Empties the match's value. */
|
|
1117
1397
|
clear(options?: BrowserActionOptions): Promise<void>;
|
|
1398
|
+
/** Waits until the match reaches the requested state. Rejects on timeout. */
|
|
1118
1399
|
wait(options?: BrowserWaitOptions): Promise<void>;
|
|
1119
|
-
|
|
1400
|
+
/** Reads the first match's rendered text. */
|
|
1401
|
+
text(): Promise<string>;
|
|
1402
|
+
/** Reads the rendered text of every match. */
|
|
1403
|
+
texts(): Promise<readonly string[]>;
|
|
1404
|
+
/** Reads the first match's inner HTML. */
|
|
1120
1405
|
html(): Promise<string>;
|
|
1406
|
+
/** Reads the first match's form value. */
|
|
1121
1407
|
value(): Promise<string>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Reads one attribute of the first match, or returns `undefined` when the match carries
|
|
1410
|
+
* none.
|
|
1411
|
+
*/
|
|
1122
1412
|
attribute(name: string): Promise<string | undefined>;
|
|
1413
|
+
/** Reports whether the first match renders a non-empty box. */
|
|
1123
1414
|
visible(): Promise<boolean>;
|
|
1415
|
+
/** Reports whether the first match accepts input. */
|
|
1124
1416
|
enabled(): Promise<boolean>;
|
|
1417
|
+
/** Reports whether the first match accepts typed text. */
|
|
1125
1418
|
editable(): Promise<boolean>;
|
|
1419
|
+
/**
|
|
1420
|
+
* Captures the first match's box, persisting it through the page writer when a path is
|
|
1421
|
+
* given.
|
|
1422
|
+
*/
|
|
1126
1423
|
screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult>;
|
|
1424
|
+
/** Sets the file selection on the matched file input. */
|
|
1127
1425
|
upload(options: BrowserUploadOptions): Promise<void>;
|
|
1128
|
-
|
|
1426
|
+
/** Drags the match onto the target locator with trusted pointer input. */
|
|
1427
|
+
drag(target: BrowserLocatorInterface, options?: BrowserLocatorDragOptions): Promise<void>;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/** Describes the options for locator keyboard entry, combining element resolution with key input. */
|
|
1431
|
+
export declare interface BrowserLocatorTypeOptions extends BrowserActionOptions, BrowserInputOptions {
|
|
1129
1432
|
}
|
|
1130
1433
|
|
|
1131
|
-
/**
|
|
1434
|
+
/** Describes the paper margin lengths accepted by Chromium print-to-PDF. */
|
|
1132
1435
|
export declare interface BrowserMargin {
|
|
1133
1436
|
readonly top?: number;
|
|
1134
1437
|
readonly right?: number;
|
|
@@ -1136,23 +1439,41 @@ export declare interface BrowserMargin {
|
|
|
1136
1439
|
readonly left?: number;
|
|
1137
1440
|
}
|
|
1138
1441
|
|
|
1139
|
-
/**
|
|
1442
|
+
/**
|
|
1443
|
+
* Describes browser color and media feature overrides.
|
|
1444
|
+
*
|
|
1445
|
+
* @remarks
|
|
1446
|
+
* - `output` — emulated output medium, mirroring the CSS `media` type
|
|
1447
|
+
* - `scheme` — emulated `prefers-color-scheme` value
|
|
1448
|
+
* - `contrast` — emulated `prefers-contrast` value
|
|
1449
|
+
* - `motion` — emulated `prefers-reduced-motion` value
|
|
1450
|
+
* - `colors` — emulated `forced-colors` value, keeping the CSS feature's word
|
|
1451
|
+
*/
|
|
1140
1452
|
export declare interface BrowserMedia {
|
|
1141
|
-
readonly
|
|
1142
|
-
readonly
|
|
1453
|
+
readonly output?: 'screen' | 'print';
|
|
1454
|
+
readonly scheme?: 'light' | 'dark' | 'no-preference';
|
|
1143
1455
|
readonly contrast?: 'more' | 'less' | 'no-preference';
|
|
1144
1456
|
readonly motion?: 'reduce' | 'no-preference';
|
|
1145
1457
|
readonly colors?: 'active' | 'none';
|
|
1146
1458
|
}
|
|
1147
1459
|
|
|
1148
|
-
/**
|
|
1460
|
+
/** Represents one Performance-domain metric. */
|
|
1149
1461
|
export declare interface BrowserMetric {
|
|
1150
1462
|
readonly name: string;
|
|
1151
1463
|
readonly value: number;
|
|
1152
1464
|
}
|
|
1153
1465
|
|
|
1154
1466
|
/**
|
|
1155
|
-
*
|
|
1467
|
+
* Sends trusted mouse input through Chromium's CDP Input domain.
|
|
1468
|
+
*
|
|
1469
|
+
* @example
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* import { BrowserMouse } from '@orkestrel/browser'
|
|
1472
|
+
*
|
|
1473
|
+
* const mouse = new BrowserMouse(page)
|
|
1474
|
+
* await mouse.click({ x: 50, y: 20 }, { button: 'left', count: 2 })
|
|
1475
|
+
* await mouse.drag({ x: 10, y: 10 }, { x: 90, y: 90 }, { steps: 20 })
|
|
1476
|
+
* ```
|
|
1156
1477
|
*/
|
|
1157
1478
|
export declare class BrowserMouse implements BrowserMouseInterface {
|
|
1158
1479
|
#private;
|
|
@@ -1160,26 +1481,44 @@ export declare class BrowserMouse implements BrowserMouseInterface {
|
|
|
1160
1481
|
move(point: BrowserPoint): Promise<void>;
|
|
1161
1482
|
down(button?: BrowserMouseButton, count?: number): Promise<void>;
|
|
1162
1483
|
up(button?: BrowserMouseButton, count?: number): Promise<void>;
|
|
1163
|
-
click(point: BrowserPoint, options?:
|
|
1164
|
-
drag(start: BrowserPoint, end: BrowserPoint, options?:
|
|
1484
|
+
click(point: BrowserPoint, options?: BrowserClickOptions): Promise<void>;
|
|
1485
|
+
drag(start: BrowserPoint, end: BrowserPoint, options?: BrowserDragOptions): Promise<void>;
|
|
1165
1486
|
wheel(delta: BrowserPoint): Promise<void>;
|
|
1166
1487
|
}
|
|
1167
1488
|
|
|
1168
|
-
/**
|
|
1489
|
+
/** Names a mouse button understood by Chromium's Input domain. */
|
|
1169
1490
|
export declare type BrowserMouseButton = 'left' | 'middle' | 'right' | 'back' | 'forward';
|
|
1170
1491
|
|
|
1171
|
-
/**
|
|
1492
|
+
/** Provides mouse input operations bound to one frame target session. */
|
|
1172
1493
|
export declare interface BrowserMouseInterface {
|
|
1494
|
+
/** Moves the pointer to a point, carrying the pressed buttons. */
|
|
1173
1495
|
move(point: BrowserPoint): Promise<void>;
|
|
1496
|
+
/** Presses a button at the current point, adding it to the pressed mask. */
|
|
1174
1497
|
down(button?: BrowserMouseButton, count?: number): Promise<void>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Releases a button at the current point, dropping it from the mask even when the frame
|
|
1500
|
+
* fails.
|
|
1501
|
+
*/
|
|
1175
1502
|
up(button?: BrowserMouseButton, count?: number): Promise<void>;
|
|
1176
|
-
|
|
1177
|
-
|
|
1503
|
+
/** Moves to the given point, presses, optionally delays, and releases. */
|
|
1504
|
+
click(point: BrowserPoint, options?: BrowserClickOptions): Promise<void>;
|
|
1505
|
+
/** Presses at the start, moves in the requested steps to the end, and releases. */
|
|
1506
|
+
drag(start: BrowserPoint, end: BrowserPoint, options?: BrowserDragOptions): Promise<void>;
|
|
1507
|
+
/** Sends a wheel delta at the current point. */
|
|
1178
1508
|
wheel(delta: BrowserPoint): Promise<void>;
|
|
1179
1509
|
}
|
|
1180
1510
|
|
|
1181
1511
|
/**
|
|
1182
|
-
* URL and page-predicate waits resilient to ordinary navigation events.
|
|
1512
|
+
* Runs URL and page-predicate waits resilient to ordinary navigation events.
|
|
1513
|
+
*
|
|
1514
|
+
* @example
|
|
1515
|
+
* ```ts
|
|
1516
|
+
* import { BrowserNavigationManager } from '@orkestrel/browser'
|
|
1517
|
+
*
|
|
1518
|
+
* const navigation = new BrowserNavigationManager(page)
|
|
1519
|
+
* const url = await navigation.wait('https://example.com/checkout', { timeout: 5_000 })
|
|
1520
|
+
* await navigation.until('document.readyState === "complete"')
|
|
1521
|
+
* ```
|
|
1183
1522
|
*/
|
|
1184
1523
|
export declare class BrowserNavigationManager implements BrowserNavigationManagerInterface {
|
|
1185
1524
|
#private;
|
|
@@ -1188,14 +1527,22 @@ export declare class BrowserNavigationManager implements BrowserNavigationManage
|
|
|
1188
1527
|
until(expression: string, options?: BrowserNavigationWaitOptions): Promise<unknown>;
|
|
1189
1528
|
}
|
|
1190
1529
|
|
|
1191
|
-
/** URL and in-page predicate waits associated with one page. */
|
|
1530
|
+
/** Provides URL and in-page predicate waits associated with one page. */
|
|
1192
1531
|
export declare interface BrowserNavigationManagerInterface {
|
|
1532
|
+
/**
|
|
1533
|
+
* Resolves with the URL of the next navigation matching the `*` and `**` glob pattern.
|
|
1534
|
+
* Rejects on timeout.
|
|
1535
|
+
*/
|
|
1193
1536
|
wait(pattern: string, options?: BrowserNavigationWaitOptions): Promise<string>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Polls an expression in the page until it returns a truthy value, and resolves with that
|
|
1539
|
+
* value.
|
|
1540
|
+
*/
|
|
1194
1541
|
until(expression: string, options?: BrowserNavigationWaitOptions): Promise<unknown>;
|
|
1195
1542
|
}
|
|
1196
1543
|
|
|
1197
1544
|
/**
|
|
1198
|
-
*
|
|
1545
|
+
* Describes the options for page navigation.
|
|
1199
1546
|
*
|
|
1200
1547
|
* @remarks
|
|
1201
1548
|
* - `condition` — page load condition to wait for (default `'load'`)
|
|
@@ -1207,14 +1554,14 @@ export declare interface BrowserNavigationOptions {
|
|
|
1207
1554
|
readonly timeout?: number;
|
|
1208
1555
|
}
|
|
1209
1556
|
|
|
1210
|
-
/**
|
|
1557
|
+
/** Describes the outcome of a top-level navigation command. */
|
|
1211
1558
|
export declare interface BrowserNavigationResult {
|
|
1212
1559
|
readonly url: string;
|
|
1213
1560
|
readonly response: BrowserResponse | undefined;
|
|
1214
1561
|
readonly same: boolean;
|
|
1215
1562
|
}
|
|
1216
1563
|
|
|
1217
|
-
/**
|
|
1564
|
+
/** Represents one pending URL-pattern wait. */
|
|
1218
1565
|
export declare interface BrowserNavigationWait {
|
|
1219
1566
|
readonly pattern: string;
|
|
1220
1567
|
readonly timer: ReturnType<typeof setTimeout>;
|
|
@@ -1222,17 +1569,17 @@ export declare interface BrowserNavigationWait {
|
|
|
1222
1569
|
readonly reject: (error: unknown) => void;
|
|
1223
1570
|
}
|
|
1224
1571
|
|
|
1225
|
-
/**
|
|
1572
|
+
/** Describes the options for URL and predicate waits. */
|
|
1226
1573
|
export declare interface BrowserNavigationWaitOptions {
|
|
1227
1574
|
readonly timeout?: number;
|
|
1228
1575
|
}
|
|
1229
1576
|
|
|
1230
|
-
/**
|
|
1577
|
+
/** Holds the state retained while correlating navigation with Network events. */
|
|
1231
1578
|
export declare interface BrowserNavigationWatch {
|
|
1232
|
-
readonly responses: BrowserResponse[];
|
|
1579
|
+
readonly responses: readonly BrowserResponse[];
|
|
1233
1580
|
}
|
|
1234
1581
|
|
|
1235
|
-
/**
|
|
1582
|
+
/** Maps the network events a page's network manager emits. */
|
|
1236
1583
|
export declare type BrowserNetworkEventMap = {
|
|
1237
1584
|
readonly request: readonly [request: BrowserRequest];
|
|
1238
1585
|
readonly response: readonly [response: BrowserResponse];
|
|
@@ -1242,11 +1589,21 @@ export declare type BrowserNetworkEventMap = {
|
|
|
1242
1589
|
};
|
|
1243
1590
|
|
|
1244
1591
|
/**
|
|
1245
|
-
*
|
|
1592
|
+
* Drives the page-scoped Network and Fetch domain lifecycle.
|
|
1593
|
+
*
|
|
1594
|
+
* @example
|
|
1595
|
+
* ```ts
|
|
1596
|
+
* import { BrowserNetworkManager } from '@orkestrel/browser'
|
|
1597
|
+
*
|
|
1598
|
+
* const network = new BrowserNetworkManager(page)
|
|
1599
|
+
* await network.start()
|
|
1600
|
+
* network.emitter.on('response', (response) => log(response.status))
|
|
1601
|
+
* await network.destroy()
|
|
1602
|
+
* ```
|
|
1246
1603
|
*/
|
|
1247
1604
|
export declare class BrowserNetworkManager implements BrowserNetworkManagerInterface {
|
|
1248
1605
|
#private;
|
|
1249
|
-
constructor(frame: BrowserFrameInterface, writer?:
|
|
1606
|
+
constructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface);
|
|
1250
1607
|
get emitter(): EmitterInterface<BrowserNetworkEventMap>;
|
|
1251
1608
|
get har(): BrowserHARManagerInterface;
|
|
1252
1609
|
start(): Promise<void>;
|
|
@@ -1261,30 +1618,46 @@ export declare class BrowserNetworkManager implements BrowserNetworkManagerInter
|
|
|
1261
1618
|
destroy(): Promise<void>;
|
|
1262
1619
|
}
|
|
1263
1620
|
|
|
1264
|
-
/**
|
|
1621
|
+
/** Provides page-scoped network observation and interception. */
|
|
1265
1622
|
export declare interface BrowserNetworkManagerInterface {
|
|
1266
1623
|
readonly emitter: EmitterInterface<BrowserNetworkEventMap>;
|
|
1267
1624
|
readonly har: BrowserHARManagerInterface;
|
|
1625
|
+
/** Enables the Network domain and subscribes to its events. Idempotent. */
|
|
1268
1626
|
start(): Promise<void>;
|
|
1627
|
+
/** Reads one observed response body as bytes. */
|
|
1269
1628
|
body(id: string): Promise<Uint8Array>;
|
|
1629
|
+
/** Reads one observed response body as text. */
|
|
1270
1630
|
text(id: string): Promise<string>;
|
|
1631
|
+
/** Reads one observed response body as parsed JSON. */
|
|
1271
1632
|
json(id: string): Promise<unknown>;
|
|
1633
|
+
/** Intercepts requests matching the query and hands each one to the handler. */
|
|
1272
1634
|
route(query: BrowserRouteQuery, handler: BrowserRouteHandler): Promise<void>;
|
|
1635
|
+
/** Removes one handler's routes, or every route when given none. */
|
|
1273
1636
|
unroute(handler?: BrowserRouteHandler): Promise<void>;
|
|
1637
|
+
/** Applies extra HTTP headers to every request the page makes. */
|
|
1274
1638
|
headers(headers: Readonly<Record<string, string>>): Promise<void>;
|
|
1639
|
+
/** Emulates an offline connection, or restores connectivity. */
|
|
1275
1640
|
offline(offline: boolean): Promise<void>;
|
|
1641
|
+
/** Applies HTTP basic-auth credentials, or clears them when given none. */
|
|
1276
1642
|
credentials(credentials?: BrowserCredentials): Promise<void>;
|
|
1643
|
+
/** Removes every route, unsubscribes, and disables the domains this manager enabled. */
|
|
1277
1644
|
destroy(): Promise<void>;
|
|
1278
1645
|
}
|
|
1279
1646
|
|
|
1280
|
-
/**
|
|
1647
|
+
/**
|
|
1648
|
+
* Represents one serializable DOM node decoded from a CDP DOM snapshot.
|
|
1649
|
+
*
|
|
1650
|
+
* @remarks
|
|
1651
|
+
* `category` mirrors the DOM `nodeType` value — `1` for an element, `3` for
|
|
1652
|
+
* text, `9` for a document, and the rest of the DOM node categories.
|
|
1653
|
+
*/
|
|
1281
1654
|
export declare interface BrowserNode {
|
|
1282
1655
|
readonly document: number;
|
|
1283
1656
|
readonly frame: string;
|
|
1284
1657
|
readonly index: number;
|
|
1285
1658
|
readonly id: number | undefined;
|
|
1286
1659
|
readonly parent: number | undefined;
|
|
1287
|
-
readonly
|
|
1660
|
+
readonly category: number;
|
|
1288
1661
|
readonly name: string;
|
|
1289
1662
|
readonly value: string;
|
|
1290
1663
|
readonly attributes: Readonly<Record<string, string>>;
|
|
@@ -1301,11 +1674,11 @@ export declare interface BrowserNode {
|
|
|
1301
1674
|
readonly layout: BrowserLayout | undefined;
|
|
1302
1675
|
}
|
|
1303
1676
|
|
|
1304
|
-
/**
|
|
1677
|
+
/** Names the predicate form accepted by {@link BrowserSnapshotInterface} find, filter, and closest methods. */
|
|
1305
1678
|
export declare type BrowserNodePredicate = (node: BrowserNode) => boolean;
|
|
1306
1679
|
|
|
1307
1680
|
/**
|
|
1308
|
-
*
|
|
1681
|
+
* Describes a declarative browser-node matcher used by {@link matchesBrowserNode}.
|
|
1309
1682
|
*
|
|
1310
1683
|
* @remarks
|
|
1311
1684
|
* Every supplied field must match. `name` is case-insensitive, `text`
|
|
@@ -1322,11 +1695,31 @@ export declare interface BrowserNodeQuery {
|
|
|
1322
1695
|
}
|
|
1323
1696
|
|
|
1324
1697
|
/**
|
|
1325
|
-
*
|
|
1698
|
+
* Collects every option a trusted-input operation can carry.
|
|
1699
|
+
*
|
|
1700
|
+
* @remarks
|
|
1701
|
+
* The intersection of each option type that carries a bounded key, so one
|
|
1702
|
+
* validator answers for a locator click, a locator drag, a mouse click, a
|
|
1703
|
+
* mouse drag, and keyboard entry alike.
|
|
1704
|
+
*/
|
|
1705
|
+
export declare type BrowserOperationOptions = BrowserPointerOptions & BrowserClickOptions & BrowserDragOptions;
|
|
1706
|
+
|
|
1707
|
+
/**
|
|
1708
|
+
* Represents a top-level browser page, including its target lifecycle and child frames.
|
|
1709
|
+
*
|
|
1710
|
+
* @example
|
|
1711
|
+
* ```ts
|
|
1712
|
+
* import { BrowserPage } from '@orkestrel/browser'
|
|
1713
|
+
*
|
|
1714
|
+
* const page = new BrowserPage(client, 'target-1', 'session-1')
|
|
1715
|
+
* await page.navigate('https://example.com')
|
|
1716
|
+
* const shot = await page.screenshot({ format: 'png' })
|
|
1717
|
+
* await page.close()
|
|
1718
|
+
* ```
|
|
1326
1719
|
*/
|
|
1327
1720
|
export declare class BrowserPage extends BrowserFrame implements BrowserPageInterface {
|
|
1328
1721
|
#private;
|
|
1329
|
-
constructor(client: CDPClientInterface, targetId: string, sessionId: string, writer?:
|
|
1722
|
+
constructor(client: CDPClientInterface, targetId: string, sessionId: string, writer?: BrowserWriterInterface, url?: string, frameId?: string, contextId?: string, opener?: BrowserPageInterface, options?: BrowserPageOptions);
|
|
1330
1723
|
get emitter(): EmitterInterface<BrowserPageEventMap>;
|
|
1331
1724
|
get network(): BrowserNetworkManagerInterface;
|
|
1332
1725
|
get navigation(): BrowserNavigationManagerInterface;
|
|
@@ -1353,14 +1746,14 @@ export declare class BrowserPage extends BrowserFrame implements BrowserPageInte
|
|
|
1353
1746
|
assert(): void;
|
|
1354
1747
|
}
|
|
1355
1748
|
|
|
1356
|
-
/**
|
|
1749
|
+
/** Represents one uncaught page exception. */
|
|
1357
1750
|
export declare interface BrowserPageError {
|
|
1358
1751
|
readonly message: string;
|
|
1359
1752
|
readonly stack: readonly BrowserStackFrame[];
|
|
1360
1753
|
readonly timestamp: number;
|
|
1361
1754
|
}
|
|
1362
1755
|
|
|
1363
|
-
/**
|
|
1756
|
+
/** Maps the typed page, frame, target, and user-visible browser events. */
|
|
1364
1757
|
export declare type BrowserPageEventMap = {
|
|
1365
1758
|
readonly navigate: readonly [url: string];
|
|
1366
1759
|
readonly attach: readonly [frame: BrowserFrameInterface];
|
|
@@ -1381,7 +1774,8 @@ export declare type BrowserPageEventMap = {
|
|
|
1381
1774
|
};
|
|
1382
1775
|
|
|
1383
1776
|
/**
|
|
1384
|
-
*
|
|
1777
|
+
* Abstracts a single top-level browser page, extending `BrowserFrameInterface` with
|
|
1778
|
+
* navigation, screenshots, frame discovery, DOM snapshots, codegen, and target teardown.
|
|
1385
1779
|
*
|
|
1386
1780
|
* @remarks
|
|
1387
1781
|
* Inherits every {@link BrowserFrameInterface} document operation for the
|
|
@@ -1408,35 +1802,67 @@ export declare interface BrowserPageInterface extends BrowserFrameInterface {
|
|
|
1408
1802
|
readonly opener: BrowserPageInterface | undefined;
|
|
1409
1803
|
readonly target: string;
|
|
1410
1804
|
readonly closed: boolean;
|
|
1805
|
+
/**
|
|
1806
|
+
* Goes to a URL, waits for the requested load condition, and returns the final URL with
|
|
1807
|
+
* its response correlation.
|
|
1808
|
+
*/
|
|
1411
1809
|
navigate(url: string, options?: BrowserNavigationOptions): Promise<BrowserNavigationResult>;
|
|
1810
|
+
/** Reloads the page and returns the final URL with its response correlation. */
|
|
1412
1811
|
reload(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult>;
|
|
1812
|
+
/**
|
|
1813
|
+
* Navigates to the previous history entry, or returns the unchanged URL when none exists.
|
|
1814
|
+
*/
|
|
1413
1815
|
back(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Navigates to the next history entry, or returns the unchanged URL when none exists.
|
|
1818
|
+
*/
|
|
1414
1819
|
forward(options?: BrowserNavigationOptions): Promise<BrowserNavigationResult>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Captures PNG or JPEG bytes, optionally full-page and persisted through an injected
|
|
1822
|
+
* writer.
|
|
1823
|
+
*/
|
|
1415
1824
|
screenshot(options?: BrowserScreenshotOptions): Promise<BrowserScreenshotResult>;
|
|
1825
|
+
/** Prints the page to PDF bytes, optionally persisted through the injected writer. */
|
|
1416
1826
|
pdf(options?: BrowserPDFOptions): Promise<BrowserPDFResult>;
|
|
1827
|
+
/** Looks up a first-class frame by name or URL. */
|
|
1417
1828
|
frame(name: string): Promise<BrowserFrameInterface | undefined>;
|
|
1829
|
+
/** Decodes the flattened frame tree, main frame first. */
|
|
1418
1830
|
frames(): Promise<readonly BrowserFrameInterface[]>;
|
|
1831
|
+
/**
|
|
1832
|
+
* Captures and decodes every attached document, shadow root, template content, layout box,
|
|
1833
|
+
* and requested computed style.
|
|
1834
|
+
*/
|
|
1419
1835
|
snapshot(options?: BrowserSnapshotOptions): Promise<BrowserSnapshotInterface>;
|
|
1836
|
+
/** Starts the action recorder, or returns the running one. */
|
|
1420
1837
|
codegen(options?: BrowserCodegenOptions): Promise<BrowserCodegenInterface>;
|
|
1838
|
+
/** Releases local resources and detaches without closing the remote target. */
|
|
1421
1839
|
destroy(): Promise<void>;
|
|
1840
|
+
/** Closes the remote target and releases its resources. */
|
|
1422
1841
|
close(): Promise<void>;
|
|
1423
1842
|
}
|
|
1424
1843
|
|
|
1425
1844
|
/**
|
|
1426
|
-
*
|
|
1845
|
+
* Describes the options for creating a `BrowserPage` instance.
|
|
1427
1846
|
*
|
|
1428
1847
|
* @remarks
|
|
1848
|
+
* - `on` — initial event listeners wired at construction
|
|
1849
|
+
* - `error` — observer error handler forwarded to the emitter
|
|
1429
1850
|
* - `url` — navigate to this URL immediately after creation
|
|
1430
1851
|
* - `viewport` — override the context-level default viewport
|
|
1431
1852
|
* - `timeout` — navigation timeout for the initial URL
|
|
1432
1853
|
*/
|
|
1433
1854
|
export declare interface BrowserPageOptions {
|
|
1855
|
+
readonly on?: EmitterHooks<BrowserPageEventMap>;
|
|
1856
|
+
readonly error?: EmitterErrorHandler;
|
|
1434
1857
|
readonly url?: string;
|
|
1435
1858
|
readonly viewport?: BrowserViewport;
|
|
1436
1859
|
readonly timeout?: number;
|
|
1437
1860
|
}
|
|
1438
1861
|
|
|
1439
|
-
/**
|
|
1862
|
+
/** Returns the context's live pages at call time. */
|
|
1863
|
+
export declare type BrowserPagesFunction = () => readonly BrowserPageInterface[];
|
|
1864
|
+
|
|
1865
|
+
/** Describes the options for printing a Chromium page to PDF. */
|
|
1440
1866
|
export declare interface BrowserPDFOptions {
|
|
1441
1867
|
readonly path?: string;
|
|
1442
1868
|
readonly landscape?: boolean;
|
|
@@ -1452,14 +1878,14 @@ export declare interface BrowserPDFOptions {
|
|
|
1452
1878
|
readonly outline?: boolean;
|
|
1453
1879
|
}
|
|
1454
1880
|
|
|
1455
|
-
/**
|
|
1881
|
+
/** Describes the result of printing a page to PDF. */
|
|
1456
1882
|
export declare interface BrowserPDFResult {
|
|
1457
1883
|
readonly bytes: Uint8Array;
|
|
1458
1884
|
readonly path: string | undefined;
|
|
1459
1885
|
}
|
|
1460
1886
|
|
|
1461
1887
|
/**
|
|
1462
|
-
*
|
|
1888
|
+
* Validates and compiles Page.printToPDF parameters.
|
|
1463
1889
|
*
|
|
1464
1890
|
* @param options - Public PDF options
|
|
1465
1891
|
* @returns Protocol parameter record
|
|
@@ -1467,29 +1893,46 @@ export declare interface BrowserPDFResult {
|
|
|
1467
1893
|
export declare function browserPDFToParams(options?: BrowserPDFOptions): Readonly<Record<string, unknown>>;
|
|
1468
1894
|
|
|
1469
1895
|
/**
|
|
1470
|
-
* Performance-domain metrics
|
|
1896
|
+
* Reads Performance-domain metrics for one frame.
|
|
1897
|
+
*
|
|
1898
|
+
* @example
|
|
1899
|
+
* ```ts
|
|
1900
|
+
* import { BrowserPerformance } from '@orkestrel/browser'
|
|
1901
|
+
*
|
|
1902
|
+
* const performance = new BrowserPerformance(page)
|
|
1903
|
+
* const metrics = await performance.metrics() // readonly BrowserMetric[]
|
|
1904
|
+
* ```
|
|
1471
1905
|
*/
|
|
1472
1906
|
export declare class BrowserPerformance implements BrowserPerformanceInterface {
|
|
1473
1907
|
#private;
|
|
1474
1908
|
constructor(frame: BrowserFrameInterface);
|
|
1475
|
-
get active(): boolean;
|
|
1476
1909
|
metrics(): Promise<readonly BrowserMetric[]>;
|
|
1477
|
-
start(interval?: number): Promise<void>;
|
|
1478
|
-
stop(): Promise<BrowserProfile>;
|
|
1479
|
-
destroy(): Promise<void>;
|
|
1480
1910
|
}
|
|
1481
1911
|
|
|
1482
|
-
/**
|
|
1912
|
+
/**
|
|
1913
|
+
* Reads Performance-domain metrics.
|
|
1914
|
+
*
|
|
1915
|
+
* @remarks
|
|
1916
|
+
* Each call enables the Performance domain and disables it again, so the
|
|
1917
|
+
* reader holds no protocol state and needs no teardown. Sampled CPU profiling
|
|
1918
|
+
* is {@link BrowserProfilerInterface}, its peer under `diagnostics`.
|
|
1919
|
+
*/
|
|
1483
1920
|
export declare interface BrowserPerformanceInterface {
|
|
1484
|
-
|
|
1921
|
+
/** Enables the domain, reads every metric, and disables the domain again. */
|
|
1485
1922
|
metrics(): Promise<readonly BrowserMetric[]>;
|
|
1486
|
-
start(interval?: number): Promise<void>;
|
|
1487
|
-
stop(): Promise<BrowserProfile>;
|
|
1488
|
-
destroy(): Promise<void>;
|
|
1489
1923
|
}
|
|
1490
1924
|
|
|
1491
1925
|
/**
|
|
1492
|
-
*
|
|
1926
|
+
* Applies permission overrides isolated to one browser context.
|
|
1927
|
+
*
|
|
1928
|
+
* @example
|
|
1929
|
+
* ```ts
|
|
1930
|
+
* import { BrowserPermissionManager } from '@orkestrel/browser'
|
|
1931
|
+
*
|
|
1932
|
+
* const permissions = new BrowserPermissionManager(client)
|
|
1933
|
+
* await permissions.grant(['geolocation'], 'https://example.com')
|
|
1934
|
+
* await permissions.clear()
|
|
1935
|
+
* ```
|
|
1493
1936
|
*/
|
|
1494
1937
|
export declare class BrowserPermissionManager implements BrowserPermissionManagerInterface {
|
|
1495
1938
|
#private;
|
|
@@ -1499,20 +1942,33 @@ export declare class BrowserPermissionManager implements BrowserPermissionManage
|
|
|
1499
1942
|
clear(): Promise<void>;
|
|
1500
1943
|
}
|
|
1501
1944
|
|
|
1502
|
-
/**
|
|
1945
|
+
/** Provides permission override operations scoped to one browser context. */
|
|
1503
1946
|
export declare interface BrowserPermissionManagerInterface {
|
|
1947
|
+
/** Grants each named permission, optionally for one origin, as its own CDP frame. */
|
|
1504
1948
|
grant(permissions: readonly string[], origin?: string): Promise<void>;
|
|
1949
|
+
/** Denies each named permission, optionally for one origin, as its own CDP frame. */
|
|
1505
1950
|
deny(permissions: readonly string[], origin?: string): Promise<void>;
|
|
1951
|
+
/** Resets every permission override on the context. */
|
|
1506
1952
|
clear(): Promise<void>;
|
|
1507
1953
|
}
|
|
1508
1954
|
|
|
1509
|
-
/**
|
|
1955
|
+
/** Describes a point in viewport CSS pixels. */
|
|
1510
1956
|
export declare interface BrowserPoint {
|
|
1511
1957
|
readonly x: number;
|
|
1512
1958
|
readonly y: number;
|
|
1513
1959
|
}
|
|
1514
1960
|
|
|
1515
|
-
/**
|
|
1961
|
+
/**
|
|
1962
|
+
* Describes the options for a locator operation that aims at a point inside the element.
|
|
1963
|
+
*
|
|
1964
|
+
* @remarks
|
|
1965
|
+
* - `position` — offset from the element's top-left corner, in CSS pixels
|
|
1966
|
+
*/
|
|
1967
|
+
export declare interface BrowserPointerOptions extends BrowserActionOptions {
|
|
1968
|
+
readonly position?: BrowserPoint;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/** Describes a sampled CPU profile. */
|
|
1516
1972
|
export declare interface BrowserProfile {
|
|
1517
1973
|
readonly start: number;
|
|
1518
1974
|
readonly end: number;
|
|
@@ -1521,7 +1977,7 @@ export declare interface BrowserProfile {
|
|
|
1521
1977
|
readonly deltas: readonly number[];
|
|
1522
1978
|
}
|
|
1523
1979
|
|
|
1524
|
-
/** JavaScript call frame from a CPU profile. */
|
|
1980
|
+
/** Describes a JavaScript call frame from a CPU profile. */
|
|
1525
1981
|
export declare interface BrowserProfileFrame {
|
|
1526
1982
|
readonly function: string;
|
|
1527
1983
|
readonly script: string;
|
|
@@ -1530,7 +1986,7 @@ export declare interface BrowserProfileFrame {
|
|
|
1530
1986
|
readonly column: number;
|
|
1531
1987
|
}
|
|
1532
1988
|
|
|
1533
|
-
/**
|
|
1989
|
+
/** Represents one node in a sampled CPU profile. */
|
|
1534
1990
|
export declare interface BrowserProfileNode {
|
|
1535
1991
|
readonly id: number;
|
|
1536
1992
|
readonly frame: BrowserProfileFrame;
|
|
@@ -1538,19 +1994,56 @@ export declare interface BrowserProfileNode {
|
|
|
1538
1994
|
readonly children: readonly number[];
|
|
1539
1995
|
}
|
|
1540
1996
|
|
|
1541
|
-
/**
|
|
1997
|
+
/**
|
|
1998
|
+
* Records sampled JavaScript CPU profiles over one frame's Profiler domain.
|
|
1999
|
+
*
|
|
2000
|
+
* @example
|
|
2001
|
+
* ```ts
|
|
2002
|
+
* import { BrowserProfiler } from '@orkestrel/browser'
|
|
2003
|
+
*
|
|
2004
|
+
* const profiler = new BrowserProfiler(page)
|
|
2005
|
+
* await profiler.start(100)
|
|
2006
|
+
* const profile = await profiler.stop() // { start, end, nodes, samples, deltas }
|
|
2007
|
+
* ```
|
|
2008
|
+
*/
|
|
2009
|
+
export declare class BrowserProfiler implements BrowserProfilerInterface {
|
|
2010
|
+
#private;
|
|
2011
|
+
constructor(frame: BrowserFrameInterface);
|
|
2012
|
+
get active(): boolean;
|
|
2013
|
+
start(interval?: number): Promise<void>;
|
|
2014
|
+
stop(): Promise<BrowserProfile>;
|
|
2015
|
+
destroy(): Promise<void>;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/** Drives the sampled CPU profile lifecycle. */
|
|
2019
|
+
export declare interface BrowserProfilerInterface {
|
|
2020
|
+
readonly active: boolean;
|
|
2021
|
+
/**
|
|
2022
|
+
* Begins sampling, optionally at an explicit positive integer interval in microseconds.
|
|
2023
|
+
*/
|
|
2024
|
+
start(interval?: number): Promise<void>;
|
|
2025
|
+
/** Ends sampling and decodes the profile's nodes, samples, and time deltas. */
|
|
2026
|
+
stop(): Promise<BrowserProfile>;
|
|
2027
|
+
/**
|
|
2028
|
+
* Stops an active profiler, discarding any failure, and does nothing when no profile is
|
|
2029
|
+
* running.
|
|
2030
|
+
*/
|
|
2031
|
+
destroy(): Promise<void>;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/** Describes proxy settings used when creating an isolated browser context. */
|
|
1542
2035
|
export declare interface BrowserProxy {
|
|
1543
2036
|
readonly server: string;
|
|
1544
2037
|
readonly bypass?: readonly string[];
|
|
1545
2038
|
}
|
|
1546
2039
|
|
|
1547
|
-
/**
|
|
2040
|
+
/** Describes a decoded content quad and its actionable center. */
|
|
1548
2041
|
export declare interface BrowserQuad {
|
|
1549
2042
|
readonly points: readonly [number, number, number, number, number, number, number, number];
|
|
1550
2043
|
readonly center: BrowserPoint;
|
|
1551
2044
|
}
|
|
1552
2045
|
|
|
1553
|
-
/**
|
|
2046
|
+
/** Describes a serializable selector query, including optional ancestry and filtering. */
|
|
1554
2047
|
export declare interface BrowserQuery {
|
|
1555
2048
|
readonly selector: BrowserSelector;
|
|
1556
2049
|
readonly value: string;
|
|
@@ -1561,10 +2054,10 @@ export declare interface BrowserQuery {
|
|
|
1561
2054
|
readonly index?: number;
|
|
1562
2055
|
}
|
|
1563
2056
|
|
|
1564
|
-
/**
|
|
2057
|
+
/** Represents a rectangle in CSS pixels: x, y, width, height. */
|
|
1565
2058
|
export declare type BrowserRect = readonly [x: number, y: number, width: number, height: number];
|
|
1566
2059
|
|
|
1567
|
-
/**
|
|
2060
|
+
/** Represents one observed browser request. */
|
|
1568
2061
|
export declare interface BrowserRequest {
|
|
1569
2062
|
readonly id: string;
|
|
1570
2063
|
readonly loader: string | undefined;
|
|
@@ -1579,7 +2072,7 @@ export declare interface BrowserRequest {
|
|
|
1579
2072
|
readonly redirect: BrowserResponse | undefined;
|
|
1580
2073
|
}
|
|
1581
2074
|
|
|
1582
|
-
/**
|
|
2075
|
+
/** Represents one failed browser request. */
|
|
1583
2076
|
export declare interface BrowserRequestFailure {
|
|
1584
2077
|
readonly id: string;
|
|
1585
2078
|
readonly error: string;
|
|
@@ -1587,7 +2080,7 @@ export declare interface BrowserRequestFailure {
|
|
|
1587
2080
|
readonly blocked: string | undefined;
|
|
1588
2081
|
}
|
|
1589
2082
|
|
|
1590
|
-
/**
|
|
2083
|
+
/** Represents one observed browser response. */
|
|
1591
2084
|
export declare interface BrowserResponse {
|
|
1592
2085
|
readonly id: string;
|
|
1593
2086
|
readonly loader: string;
|
|
@@ -1608,34 +2101,21 @@ export declare interface BrowserResponse {
|
|
|
1608
2101
|
}
|
|
1609
2102
|
|
|
1610
2103
|
/**
|
|
1611
|
-
*
|
|
1612
|
-
*
|
|
2104
|
+
* Reports that an `evaluate()`/`content()` result exceeded {@link BROWSER_RESULT_LIMIT} and
|
|
2105
|
+
* was rejected in-page before it could overflow the CDP transport frame, under the code
|
|
2106
|
+
* `BROWSER_RESULT_LIMIT_ERROR`.
|
|
1613
2107
|
*/
|
|
1614
2108
|
export declare class BrowserResultLimitError extends BrowserError {
|
|
1615
2109
|
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
1616
2110
|
}
|
|
1617
2111
|
|
|
1618
|
-
/**
|
|
2112
|
+
/** Describes the options for role-based locator creation. */
|
|
1619
2113
|
export declare interface BrowserRoleOptions {
|
|
1620
2114
|
readonly name?: string;
|
|
1621
2115
|
readonly exact?: boolean;
|
|
1622
2116
|
}
|
|
1623
2117
|
|
|
1624
|
-
/**
|
|
1625
|
-
* One paused request that can be aborted, continued, or fulfilled exactly once.
|
|
1626
|
-
*/
|
|
1627
|
-
export declare class BrowserRoute implements BrowserRouteInterface {
|
|
1628
|
-
#private;
|
|
1629
|
-
constructor(frame: BrowserFrameInterface, id: string, request: BrowserRequest);
|
|
1630
|
-
get id(): string;
|
|
1631
|
-
get request(): BrowserRequest;
|
|
1632
|
-
get handled(): boolean;
|
|
1633
|
-
abort(reason?: string): Promise<void>;
|
|
1634
|
-
continue(options?: BrowserRouteContinueOptions): Promise<void>;
|
|
1635
|
-
fulfill(options: BrowserRouteFulfillOptions): Promise<void>;
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
/** Overrides supplied when continuing an intercepted request. */
|
|
2118
|
+
/** Describes the overrides supplied when continuing an intercepted request. */
|
|
1639
2119
|
export declare interface BrowserRouteContinueOptions {
|
|
1640
2120
|
readonly url?: string;
|
|
1641
2121
|
readonly method?: string;
|
|
@@ -1643,13 +2123,13 @@ export declare interface BrowserRouteContinueOptions {
|
|
|
1643
2123
|
readonly post?: string;
|
|
1644
2124
|
}
|
|
1645
2125
|
|
|
1646
|
-
/**
|
|
2126
|
+
/** Represents one installed network route. */
|
|
1647
2127
|
export declare interface BrowserRouteDefinition {
|
|
1648
2128
|
readonly query: BrowserRouteQuery;
|
|
1649
2129
|
readonly handler: BrowserRouteHandler;
|
|
1650
2130
|
}
|
|
1651
2131
|
|
|
1652
|
-
/**
|
|
2132
|
+
/** Describes the synthetic response supplied when fulfilling an intercepted request. */
|
|
1653
2133
|
export declare interface BrowserRouteFulfillOptions {
|
|
1654
2134
|
readonly status?: number;
|
|
1655
2135
|
readonly phrase?: string;
|
|
@@ -1657,42 +2137,49 @@ export declare interface BrowserRouteFulfillOptions {
|
|
|
1657
2137
|
readonly body?: string | Uint8Array;
|
|
1658
2138
|
}
|
|
1659
2139
|
|
|
1660
|
-
/**
|
|
2140
|
+
/** Runs for a matching intercepted request. */
|
|
1661
2141
|
export declare type BrowserRouteHandler = (route: BrowserRouteInterface) => void | Promise<void>;
|
|
1662
2142
|
|
|
1663
|
-
/**
|
|
2143
|
+
/** Represents one paused Fetch-domain request. */
|
|
1664
2144
|
export declare interface BrowserRouteInterface {
|
|
1665
2145
|
readonly id: string;
|
|
1666
2146
|
readonly request: BrowserRequest;
|
|
1667
2147
|
readonly handled: boolean;
|
|
2148
|
+
/** Fails the request with a Chromium error reason, `'Failed'` by default. */
|
|
1668
2149
|
abort(reason?: string): Promise<void>;
|
|
2150
|
+
/**
|
|
2151
|
+
* Lets the request proceed, optionally overriding its URL, method, headers, or post body.
|
|
2152
|
+
*/
|
|
1669
2153
|
continue(options?: BrowserRouteContinueOptions): Promise<void>;
|
|
2154
|
+
/**
|
|
2155
|
+
* Answers the request locally. Throws when the status is not an integer from 100 to 999.
|
|
2156
|
+
*/
|
|
1670
2157
|
fulfill(options: BrowserRouteFulfillOptions): Promise<void>;
|
|
1671
2158
|
}
|
|
1672
2159
|
|
|
1673
|
-
/**
|
|
2160
|
+
/** Describes route matching criteria. Omitted fields match all values. */
|
|
1674
2161
|
export declare interface BrowserRouteQuery {
|
|
1675
2162
|
readonly url?: string;
|
|
1676
2163
|
readonly method?: string;
|
|
1677
2164
|
readonly resource?: string;
|
|
1678
2165
|
}
|
|
1679
2166
|
|
|
1680
|
-
/**
|
|
2167
|
+
/** Names a cookie same-site policy understood by Chromium. */
|
|
1681
2168
|
export declare type BrowserSameSite = 'Strict' | 'Lax' | 'None';
|
|
1682
2169
|
|
|
1683
2170
|
/**
|
|
1684
|
-
*
|
|
2171
|
+
* Describes the options for taking a page screenshot.
|
|
1685
2172
|
*
|
|
1686
2173
|
* @remarks
|
|
1687
|
-
* - `path` — file path to persist the screenshot to,
|
|
2174
|
+
* - `path` — file path to persist the screenshot to, through the page's writer
|
|
1688
2175
|
* - `full` — capture the full scrollable page (default `false`)
|
|
1689
|
-
* - `
|
|
2176
|
+
* - `format` — image format (default `'png'`)
|
|
1690
2177
|
* - `quality` — JPEG quality 0–100 (ignored for PNG)
|
|
1691
2178
|
*/
|
|
1692
2179
|
export declare interface BrowserScreenshotOptions {
|
|
1693
2180
|
readonly path?: string;
|
|
1694
2181
|
readonly full?: boolean;
|
|
1695
|
-
readonly
|
|
2182
|
+
readonly format?: 'png' | 'jpeg';
|
|
1696
2183
|
readonly quality?: number;
|
|
1697
2184
|
readonly clip?: BrowserRect;
|
|
1698
2185
|
readonly transparent?: boolean;
|
|
@@ -1704,43 +2191,52 @@ export declare interface BrowserScreenshotOptions {
|
|
|
1704
2191
|
}
|
|
1705
2192
|
|
|
1706
2193
|
/**
|
|
1707
|
-
*
|
|
2194
|
+
* Describes the result of a page screenshot.
|
|
1708
2195
|
*
|
|
1709
2196
|
* @remarks
|
|
1710
2197
|
* - `bytes` — raw image bytes
|
|
1711
|
-
* - `path` — file path if persisted
|
|
2198
|
+
* - `path` — file path if persisted through the page's writer, otherwise undefined
|
|
1712
2199
|
*/
|
|
1713
2200
|
export declare interface BrowserScreenshotResult {
|
|
1714
2201
|
readonly bytes: Uint8Array;
|
|
1715
2202
|
readonly path: string | undefined;
|
|
1716
2203
|
}
|
|
1717
2204
|
|
|
1718
|
-
/**
|
|
2205
|
+
/** Names a screenshot coordinate scale. */
|
|
1719
2206
|
export declare type BrowserScreenshotScale = 'css' | 'device';
|
|
1720
2207
|
|
|
1721
2208
|
/**
|
|
1722
|
-
*
|
|
2209
|
+
* Validates and compiles basic Page.captureScreenshot parameters.
|
|
1723
2210
|
*
|
|
1724
2211
|
* @param options - Public screenshot options
|
|
1725
2212
|
* @returns Protocol parameter record
|
|
1726
2213
|
*/
|
|
1727
2214
|
export declare function browserScreenshotToParams(options?: BrowserScreenshotOptions): Readonly<Record<string, unknown>>;
|
|
1728
2215
|
|
|
1729
|
-
/** JavaScript script coverage. */
|
|
2216
|
+
/** Describes JavaScript script coverage. */
|
|
1730
2217
|
export declare interface BrowserScriptCoverage {
|
|
1731
2218
|
readonly id: string;
|
|
1732
2219
|
readonly url: string;
|
|
1733
2220
|
readonly functions: readonly BrowserFunctionCoverage[];
|
|
1734
2221
|
}
|
|
1735
2222
|
|
|
1736
|
-
/**
|
|
2223
|
+
/** Represents one installed new-document script and its optional host binding owner. */
|
|
1737
2224
|
export declare interface BrowserScriptEntry {
|
|
1738
2225
|
readonly source: string;
|
|
1739
2226
|
readonly binding: string | undefined;
|
|
1740
2227
|
}
|
|
1741
2228
|
|
|
1742
2229
|
/**
|
|
1743
|
-
*
|
|
2230
|
+
* Installs new-document scripts and promise-based host functions for one page.
|
|
2231
|
+
*
|
|
2232
|
+
* @example
|
|
2233
|
+
* ```ts
|
|
2234
|
+
* import { BrowserScriptManager } from '@orkestrel/browser'
|
|
2235
|
+
*
|
|
2236
|
+
* const scripts = new BrowserScriptManager(page)
|
|
2237
|
+
* const id = await scripts.add('window.__ready = true')
|
|
2238
|
+
* await scripts.remove(id)
|
|
2239
|
+
* ```
|
|
1744
2240
|
*/
|
|
1745
2241
|
export declare class BrowserScriptManager implements BrowserScriptManagerInterface {
|
|
1746
2242
|
#private;
|
|
@@ -1752,16 +2248,21 @@ export declare class BrowserScriptManager implements BrowserScriptManagerInterfa
|
|
|
1752
2248
|
destroy(): Promise<void>;
|
|
1753
2249
|
}
|
|
1754
2250
|
|
|
1755
|
-
/**
|
|
2251
|
+
/** Manages initialization scripts and host bindings for one page. */
|
|
1756
2252
|
export declare interface BrowserScriptManagerInterface {
|
|
2253
|
+
/** Installs a script evaluated on every new document, and returns its identifier. */
|
|
1757
2254
|
add(source: string): Promise<string>;
|
|
2255
|
+
/** Removes one installed script by identifier. */
|
|
1758
2256
|
remove(id: string): Promise<void>;
|
|
2257
|
+
/** Binds a host function to a page-global name, callable from page JavaScript. */
|
|
1759
2258
|
expose(name: string, handler: BrowserBindingHandler): Promise<void>;
|
|
2259
|
+
/** Removes one exposed binding and its installed bridge script. */
|
|
1760
2260
|
revoke(name: string): Promise<void>;
|
|
2261
|
+
/** Removes every installed script and binding this manager owns. */
|
|
1761
2262
|
destroy(): Promise<void>;
|
|
1762
2263
|
}
|
|
1763
2264
|
|
|
1764
|
-
/** TLS details supplied with a browser response. */
|
|
2265
|
+
/** Describes the TLS details supplied with a browser response. */
|
|
1765
2266
|
export declare interface BrowserSecurity {
|
|
1766
2267
|
readonly protocol: string;
|
|
1767
2268
|
readonly issuer: string;
|
|
@@ -1769,18 +2270,33 @@ export declare interface BrowserSecurity {
|
|
|
1769
2270
|
readonly to: number;
|
|
1770
2271
|
}
|
|
1771
2272
|
|
|
1772
|
-
/**
|
|
1773
|
-
|
|
2273
|
+
/**
|
|
2274
|
+
* Names a selector axis supported by {@link BrowserSelectorManagerInterface}.
|
|
2275
|
+
*
|
|
2276
|
+
* @remarks
|
|
2277
|
+
* `testId` mirrors the `data-testid` attribute {@link BROWSER_TEST_ID_ATTRIBUTE} names.
|
|
2278
|
+
*/
|
|
2279
|
+
export declare type BrowserSelector = 'css' | 'role' | 'text' | 'label' | 'placeholder' | 'testId';
|
|
1774
2280
|
|
|
1775
2281
|
/**
|
|
1776
|
-
*
|
|
2282
|
+
* Reports that a selector-based lookup or wait timed out without the element appearing, under
|
|
2283
|
+
* the code `BROWSER_SELECTOR_ERROR`.
|
|
1777
2284
|
*/
|
|
1778
2285
|
export declare class BrowserSelectorError extends BrowserError {
|
|
1779
2286
|
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
1780
2287
|
}
|
|
1781
2288
|
|
|
1782
2289
|
/**
|
|
1783
|
-
*
|
|
2290
|
+
* Creates semantic locators for one frame.
|
|
2291
|
+
*
|
|
2292
|
+
* @example
|
|
2293
|
+
* ```ts
|
|
2294
|
+
* import { BrowserSelectorManager } from '@orkestrel/browser'
|
|
2295
|
+
*
|
|
2296
|
+
* const selectors = new BrowserSelectorManager(page)
|
|
2297
|
+
* await selectors.role('button', { name: 'Save' }).click()
|
|
2298
|
+
* await selectors.testId('checkout').click()
|
|
2299
|
+
* ```
|
|
1784
2300
|
*/
|
|
1785
2301
|
export declare class BrowserSelectorManager implements BrowserSelectorManagerInterface {
|
|
1786
2302
|
#private;
|
|
@@ -1790,28 +2306,57 @@ export declare class BrowserSelectorManager implements BrowserSelectorManagerInt
|
|
|
1790
2306
|
text(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
1791
2307
|
label(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
1792
2308
|
placeholder(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
1793
|
-
|
|
2309
|
+
testId(value: string): BrowserLocatorInterface;
|
|
1794
2310
|
}
|
|
1795
2311
|
|
|
1796
2312
|
/**
|
|
1797
|
-
*
|
|
2313
|
+
* Groups the locator factories by selector semantics.
|
|
1798
2314
|
*/
|
|
1799
2315
|
export declare interface BrowserSelectorManagerInterface {
|
|
2316
|
+
/** Locates by CSS selector. */
|
|
1800
2317
|
css(value: string): BrowserLocatorInterface;
|
|
2318
|
+
/** Locates by ARIA role, optionally by accessible name and exactness. */
|
|
1801
2319
|
role(value: string, options?: BrowserRoleOptions): BrowserLocatorInterface;
|
|
2320
|
+
/** Locates by rendered text, optionally exact. */
|
|
1802
2321
|
text(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
2322
|
+
/** Locates a labelled control by its label text, optionally exact. */
|
|
1803
2323
|
label(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
2324
|
+
/** Locates an input by its placeholder text, optionally exact. */
|
|
1804
2325
|
placeholder(value: string, options?: BrowserTextOptions): BrowserLocatorInterface;
|
|
1805
|
-
test
|
|
2326
|
+
/** Locates by the test-id attribute. */
|
|
2327
|
+
testId(value: string): BrowserLocatorInterface;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* Describes the options for one raw CDP method call issued in a frame's target session.
|
|
2332
|
+
*
|
|
2333
|
+
* @remarks
|
|
2334
|
+
* The frame supplies its own session, so a caller bounds the call and nothing
|
|
2335
|
+
* else.
|
|
2336
|
+
*
|
|
2337
|
+
* - `timeout` — ms before this one request fails, overriding the client-wide default
|
|
2338
|
+
*/
|
|
2339
|
+
export declare interface BrowserSendOptions {
|
|
2340
|
+
readonly timeout?: number;
|
|
1806
2341
|
}
|
|
1807
2342
|
|
|
1808
|
-
/**
|
|
2343
|
+
/** Resolves the current CDP session for a frame id. */
|
|
1809
2344
|
export declare type BrowserSessionFunction = (frame: string) => Promise<string>;
|
|
1810
2345
|
|
|
1811
|
-
/**
|
|
2346
|
+
/** Names a structural sibling relationship relative to a browser node. */
|
|
1812
2347
|
export declare type BrowserSiblingRelation = 'preceding' | 'following';
|
|
1813
2348
|
|
|
1814
|
-
/**
|
|
2349
|
+
/**
|
|
2350
|
+
* Represents a navigable, serializable browser DOM snapshot.
|
|
2351
|
+
*
|
|
2352
|
+
* @example
|
|
2353
|
+
* ```ts
|
|
2354
|
+
* import { BrowserSnapshot } from '@orkestrel/browser'
|
|
2355
|
+
*
|
|
2356
|
+
* const snapshot = new BrowserSnapshot({ documents, styles: ['display'] })
|
|
2357
|
+
* const main = snapshot.find({ name: 'main', visible: true })
|
|
2358
|
+
* ```
|
|
2359
|
+
*/
|
|
1815
2360
|
export declare class BrowserSnapshot implements BrowserSnapshotInterface {
|
|
1816
2361
|
#private;
|
|
1817
2362
|
readonly documents: readonly BrowserDocument[];
|
|
@@ -1832,31 +2377,75 @@ export declare class BrowserSnapshot implements BrowserSnapshotInterface {
|
|
|
1832
2377
|
path(node: BrowserNode): string;
|
|
1833
2378
|
}
|
|
1834
2379
|
|
|
1835
|
-
/**
|
|
2380
|
+
/**
|
|
2381
|
+
* Describes the serializable input for a navigable browser snapshot — the form a
|
|
2382
|
+
* `BrowserSnapshot` is built from and serializes back to.
|
|
2383
|
+
*/
|
|
1836
2384
|
export declare interface BrowserSnapshotInput {
|
|
1837
2385
|
readonly documents: readonly BrowserDocument[];
|
|
1838
2386
|
readonly styles: readonly string[];
|
|
1839
2387
|
}
|
|
1840
2388
|
|
|
1841
|
-
/**
|
|
2389
|
+
/**
|
|
2390
|
+
* Represents a navigable, serializable snapshot of every document attached to a page,
|
|
2391
|
+
* extending `BrowserSnapshotInput` with walking, structural relationships, search, and path
|
|
2392
|
+
* derivation over plain `BrowserNode` values.
|
|
2393
|
+
*/
|
|
1842
2394
|
export declare interface BrowserSnapshotInterface extends BrowserSnapshotInput {
|
|
2395
|
+
/**
|
|
2396
|
+
* Traverses the whole capture, or one subtree when `root` is given and yielded first, in
|
|
2397
|
+
* `'depth'` order by default or in `'breadth'` order. Visits each node exactly once.
|
|
2398
|
+
*/
|
|
1843
2399
|
walk(options?: BrowserWalkOptions): Generator<BrowserNode, void, unknown>;
|
|
2400
|
+
/** Traverses one node's subtree in depth-first order, excluding the node itself. */
|
|
1844
2401
|
descendants(node: BrowserNode): Generator<BrowserNode, void, unknown>;
|
|
2402
|
+
/** Resolves the captured document a node belongs to. */
|
|
1845
2403
|
document(node: BrowserNode): BrowserDocument | undefined;
|
|
2404
|
+
/**
|
|
2405
|
+
* Returns the direct children of a node, entering a linked iframe's content document.
|
|
2406
|
+
*/
|
|
1846
2407
|
children(node: BrowserNode): readonly BrowserNode[];
|
|
2408
|
+
/**
|
|
2409
|
+
* Returns the structural parent of a node, crossing a document boundary to the owning
|
|
2410
|
+
* iframe.
|
|
2411
|
+
*/
|
|
1847
2412
|
parent(node: BrowserNode): BrowserNode | undefined;
|
|
2413
|
+
/**
|
|
2414
|
+
* Returns the structural siblings of a node; `'preceding'` or `'following'` narrows to one
|
|
2415
|
+
* side, and omitting the relation returns every sibling but the node itself.
|
|
2416
|
+
*/
|
|
1848
2417
|
siblings(node: BrowserNode, relation?: BrowserSiblingRelation): readonly BrowserNode[];
|
|
2418
|
+
/**
|
|
2419
|
+
* Returns the ancestors of a node, nearest first, across document and iframe boundaries.
|
|
2420
|
+
*/
|
|
1849
2421
|
ancestors(node: BrowserNode): readonly BrowserNode[];
|
|
2422
|
+
/**
|
|
2423
|
+
* Returns the nearest common ancestor of two nodes, counting each node as its own
|
|
2424
|
+
* candidate.
|
|
2425
|
+
*/
|
|
1850
2426
|
common(first: BrowserNode, second: BrowserNode): BrowserNode | undefined;
|
|
2427
|
+
/**
|
|
2428
|
+
* Returns the structural edge count between two nodes, or `undefined` when they share no
|
|
2429
|
+
* ancestor.
|
|
2430
|
+
*/
|
|
1851
2431
|
distance(first: BrowserNode, second: BrowserNode): number | undefined;
|
|
2432
|
+
/** Returns the first node matching a `BrowserNodeQuery` or a `BrowserNodePredicate`. */
|
|
1852
2433
|
find(query: BrowserNodeQuery | BrowserNodePredicate): BrowserNode | undefined;
|
|
2434
|
+
/**
|
|
2435
|
+
* Returns every matching node, bounded by an optional `limit`; a negative or fractional
|
|
2436
|
+
* limit throws a coded `BrowserError`.
|
|
2437
|
+
*/
|
|
1853
2438
|
filter(query: BrowserNodeQuery | BrowserNodePredicate, limit?: number): readonly BrowserNode[];
|
|
2439
|
+
/**
|
|
2440
|
+
* Returns the nearest match from a node through its ancestors, testing the node first.
|
|
2441
|
+
*/
|
|
1854
2442
|
closest(node: BrowserNode, query: BrowserNodeQuery | BrowserNodePredicate): BrowserNode | undefined;
|
|
2443
|
+
/** Returns a deterministic frame-qualified structural path for one node. */
|
|
1855
2444
|
path(node: BrowserNode): string;
|
|
1856
2445
|
}
|
|
1857
2446
|
|
|
1858
2447
|
/**
|
|
1859
|
-
*
|
|
2448
|
+
* Describes the options configuring capture through {@link BrowserPageInterface} `snapshot()`.
|
|
1860
2449
|
* The snapshot entity's creation input is {@link BrowserSnapshotInput}.
|
|
1861
2450
|
*
|
|
1862
2451
|
* @remarks
|
|
@@ -1872,7 +2461,7 @@ export declare interface BrowserSnapshotOptions {
|
|
|
1872
2461
|
readonly limit?: number;
|
|
1873
2462
|
}
|
|
1874
2463
|
|
|
1875
|
-
/**
|
|
2464
|
+
/** Represents one browser-side stack frame. */
|
|
1876
2465
|
export declare interface BrowserStackFrame {
|
|
1877
2466
|
readonly url: string;
|
|
1878
2467
|
readonly function: string;
|
|
@@ -1880,71 +2469,81 @@ export declare interface BrowserStackFrame {
|
|
|
1880
2469
|
readonly column: number;
|
|
1881
2470
|
}
|
|
1882
2471
|
|
|
1883
|
-
/**
|
|
2472
|
+
/** Represents one key/value pair from web storage. */
|
|
1884
2473
|
export declare interface BrowserStorageEntry {
|
|
1885
2474
|
readonly name: string;
|
|
1886
2475
|
readonly value: string;
|
|
1887
2476
|
}
|
|
1888
2477
|
|
|
1889
2478
|
/**
|
|
1890
|
-
*
|
|
2479
|
+
* Imports, exports, and clears cookie and web-storage state for one browser context.
|
|
2480
|
+
*
|
|
2481
|
+
* @example
|
|
2482
|
+
* ```ts
|
|
2483
|
+
* import { BrowserStorageManager } from '@orkestrel/browser'
|
|
2484
|
+
*
|
|
2485
|
+
* const storage = new BrowserStorageManager(context.cookies, () => context.pages())
|
|
2486
|
+
* const state = await storage.state({ origins: ['https://example.com'] })
|
|
2487
|
+
* await storage.restore(state)
|
|
2488
|
+
* ```
|
|
1891
2489
|
*/
|
|
1892
2490
|
export declare class BrowserStorageManager implements BrowserStorageManagerInterface {
|
|
1893
2491
|
#private;
|
|
1894
|
-
constructor(cookies: BrowserCookieManagerInterface, pages:
|
|
2492
|
+
constructor(cookies: BrowserCookieManagerInterface, pages: BrowserPagesFunction);
|
|
1895
2493
|
state(options?: BrowserStorageOptions): Promise<BrowserStorageState>;
|
|
1896
2494
|
restore(state: BrowserStorageState): Promise<void>;
|
|
1897
2495
|
clear(origin?: string): Promise<void>;
|
|
1898
2496
|
}
|
|
1899
2497
|
|
|
1900
|
-
/**
|
|
2498
|
+
/** Provides storage-state import, export, and clearing operations. */
|
|
1901
2499
|
export declare interface BrowserStorageManagerInterface {
|
|
2500
|
+
/** Reads the context cookies and the per-origin local and session storage. */
|
|
1902
2501
|
state(options?: BrowserStorageOptions): Promise<BrowserStorageState>;
|
|
2502
|
+
/** Writes a previously read state back into the context. */
|
|
1903
2503
|
restore(state: BrowserStorageState): Promise<void>;
|
|
2504
|
+
/** Drops the storage of one origin, or of every origin when given none. */
|
|
1904
2505
|
clear(origin?: string): Promise<void>;
|
|
1905
2506
|
}
|
|
1906
2507
|
|
|
1907
|
-
/**
|
|
2508
|
+
/** Describes the options for collecting storage state from selected origins. */
|
|
1908
2509
|
export declare interface BrowserStorageOptions {
|
|
1909
2510
|
readonly origins?: readonly string[];
|
|
1910
2511
|
}
|
|
1911
2512
|
|
|
1912
|
-
/**
|
|
2513
|
+
/** Describes an origin-scoped local and session storage snapshot. */
|
|
1913
2514
|
export declare interface BrowserStorageOrigin {
|
|
1914
2515
|
readonly origin: string;
|
|
1915
2516
|
readonly local: readonly BrowserStorageEntry[];
|
|
1916
2517
|
readonly session: readonly BrowserStorageEntry[];
|
|
1917
2518
|
}
|
|
1918
2519
|
|
|
1919
|
-
/**
|
|
2520
|
+
/** Describes a portable browser authentication and storage snapshot. */
|
|
1920
2521
|
export declare interface BrowserStorageState {
|
|
1921
2522
|
readonly cookies: readonly BrowserCookieInput[];
|
|
1922
2523
|
readonly origins: readonly BrowserStorageOrigin[];
|
|
1923
2524
|
}
|
|
1924
2525
|
|
|
1925
|
-
/**
|
|
2526
|
+
/** Represents one decoded IO stream read. */
|
|
1926
2527
|
export declare interface BrowserStreamChunk {
|
|
1927
2528
|
readonly bytes: Uint8Array;
|
|
1928
2529
|
readonly eof: boolean;
|
|
1929
2530
|
}
|
|
1930
2531
|
|
|
1931
|
-
/** CSS stylesheet coverage. */
|
|
2532
|
+
/** Describes CSS stylesheet coverage. */
|
|
1932
2533
|
export declare interface BrowserStyleCoverage {
|
|
1933
2534
|
readonly id: string;
|
|
1934
2535
|
readonly ranges: readonly BrowserCoverageRange[];
|
|
1935
2536
|
}
|
|
1936
2537
|
|
|
1937
|
-
/**
|
|
2538
|
+
/** Runs one teardown step to settlement while the first failure is retained. */
|
|
2539
|
+
export declare type BrowserTeardownFunction = () => Promise<unknown>;
|
|
2540
|
+
|
|
2541
|
+
/** Describes the options for text-like locator creation. */
|
|
1938
2542
|
export declare interface BrowserTextOptions {
|
|
1939
2543
|
readonly exact?: boolean;
|
|
1940
2544
|
}
|
|
1941
2545
|
|
|
1942
|
-
/**
|
|
1943
|
-
export declare interface BrowserTextResultOptions {
|
|
1944
|
-
readonly all?: boolean;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
/** Network timing values in milliseconds relative to request time. */
|
|
2546
|
+
/** Holds network timing values in milliseconds relative to request time. */
|
|
1948
2547
|
export declare interface BrowserTiming {
|
|
1949
2548
|
readonly request: number;
|
|
1950
2549
|
readonly proxy: BrowserTimingRange | undefined;
|
|
@@ -1955,14 +2554,22 @@ export declare interface BrowserTiming {
|
|
|
1955
2554
|
readonly receive: number | undefined;
|
|
1956
2555
|
}
|
|
1957
2556
|
|
|
1958
|
-
/**
|
|
2557
|
+
/** Describes the start/end pair for one network timing phase. */
|
|
1959
2558
|
export declare interface BrowserTimingRange {
|
|
1960
2559
|
readonly start: number;
|
|
1961
2560
|
readonly end: number;
|
|
1962
2561
|
}
|
|
1963
2562
|
|
|
1964
2563
|
/**
|
|
1965
|
-
*
|
|
2564
|
+
* Sends trusted touch input through Chromium's CDP Input domain.
|
|
2565
|
+
*
|
|
2566
|
+
* @example
|
|
2567
|
+
* ```ts
|
|
2568
|
+
* import { BrowserTouch } from '@orkestrel/browser'
|
|
2569
|
+
*
|
|
2570
|
+
* const touch = new BrowserTouch(page)
|
|
2571
|
+
* await touch.tap({ x: 120, y: 240 })
|
|
2572
|
+
* ```
|
|
1966
2573
|
*/
|
|
1967
2574
|
export declare class BrowserTouch implements BrowserTouchInterface {
|
|
1968
2575
|
#private;
|
|
@@ -1970,32 +2577,56 @@ export declare class BrowserTouch implements BrowserTouchInterface {
|
|
|
1970
2577
|
tap(point: BrowserPoint): Promise<void>;
|
|
1971
2578
|
}
|
|
1972
2579
|
|
|
1973
|
-
/**
|
|
2580
|
+
/** Provides touch input operations bound to one frame target session. */
|
|
1974
2581
|
export declare interface BrowserTouchInterface {
|
|
2582
|
+
/**
|
|
2583
|
+
* Dispatches a touch start at the point and a touch end, cancelling the touch on failure.
|
|
2584
|
+
*/
|
|
1975
2585
|
tap(point: BrowserPoint): Promise<void>;
|
|
1976
2586
|
}
|
|
1977
2587
|
|
|
1978
2588
|
/**
|
|
1979
|
-
* Chromium
|
|
2589
|
+
* Captures Chromium traces streamed through the IO domain.
|
|
2590
|
+
*
|
|
2591
|
+
* @example
|
|
2592
|
+
* ```ts
|
|
2593
|
+
* import { BrowserTracing } from '@orkestrel/browser'
|
|
2594
|
+
*
|
|
2595
|
+
* const tracing = new BrowserTracing(page)
|
|
2596
|
+
* await tracing.start({ screenshots: true })
|
|
2597
|
+
* const trace = await tracing.stop() // { bytes, path }
|
|
2598
|
+
* ```
|
|
1980
2599
|
*/
|
|
1981
2600
|
export declare class BrowserTracing implements BrowserTracingInterface {
|
|
1982
2601
|
#private;
|
|
1983
|
-
constructor(frame: BrowserFrameInterface, writer?:
|
|
2602
|
+
constructor(frame: BrowserFrameInterface, writer?: BrowserWriterInterface);
|
|
1984
2603
|
get active(): boolean;
|
|
1985
2604
|
start(options?: BrowserTracingOptions): Promise<void>;
|
|
1986
2605
|
stop(): Promise<BrowserTracingResult>;
|
|
1987
2606
|
destroy(): Promise<void>;
|
|
1988
2607
|
}
|
|
1989
2608
|
|
|
1990
|
-
/**
|
|
2609
|
+
/** Drives the trace capture lifecycle. */
|
|
1991
2610
|
export declare interface BrowserTracingInterface {
|
|
1992
2611
|
readonly active: boolean;
|
|
2612
|
+
/**
|
|
2613
|
+
* Begins tracing with the given categories. Throws a `BrowserError` when a trace is
|
|
2614
|
+
* already active.
|
|
2615
|
+
*/
|
|
1993
2616
|
start(options?: BrowserTracingOptions): Promise<void>;
|
|
2617
|
+
/**
|
|
2618
|
+
* Ends tracing, drains the IO stream, and writes it through the page writer when a path
|
|
2619
|
+
* was set.
|
|
2620
|
+
*/
|
|
1994
2621
|
stop(): Promise<BrowserTracingResult>;
|
|
2622
|
+
/**
|
|
2623
|
+
* Stops an active trace, discarding any failure, and does nothing when no trace is
|
|
2624
|
+
* running.
|
|
2625
|
+
*/
|
|
1995
2626
|
destroy(): Promise<void>;
|
|
1996
2627
|
}
|
|
1997
2628
|
|
|
1998
|
-
/** Chromium trace capture
|
|
2629
|
+
/** Describes the options for a Chromium trace capture. */
|
|
1999
2630
|
export declare interface BrowserTracingOptions {
|
|
2000
2631
|
readonly path?: string;
|
|
2001
2632
|
readonly categories?: readonly string[];
|
|
@@ -2003,25 +2634,73 @@ export declare interface BrowserTracingOptions {
|
|
|
2003
2634
|
readonly sampling?: boolean;
|
|
2004
2635
|
}
|
|
2005
2636
|
|
|
2006
|
-
/**
|
|
2637
|
+
/** Describes the result of a trace capture. */
|
|
2007
2638
|
export declare interface BrowserTracingResult {
|
|
2008
2639
|
readonly bytes: Uint8Array;
|
|
2009
2640
|
readonly path: string | undefined;
|
|
2010
2641
|
}
|
|
2011
2642
|
|
|
2012
|
-
/**
|
|
2643
|
+
/**
|
|
2644
|
+
* Runs one asynchronous transition at a time, shared by every caller that joins it.
|
|
2645
|
+
*
|
|
2646
|
+
* @remarks
|
|
2647
|
+
* An entity with a lifecycle runs the same guard around every transition: take
|
|
2648
|
+
* the promise already in flight when one exists, otherwise start the work, hold
|
|
2649
|
+
* its promise, and release the field afterwards only when it is still this
|
|
2650
|
+
* run's. Holding that guard in one place keeps the identity check — the part a
|
|
2651
|
+
* hand-written copy drops — identical at every site. The entry guards stay with
|
|
2652
|
+
* each entity, because what makes a transition unnecessary is the entity's own
|
|
2653
|
+
* state.
|
|
2654
|
+
*
|
|
2655
|
+
* @example
|
|
2656
|
+
* ```ts
|
|
2657
|
+
* import { BrowserTransition } from '@orkestrel/browser'
|
|
2658
|
+
*
|
|
2659
|
+
* const starting = new BrowserTransition()
|
|
2660
|
+
* await starting.execute(() => transport.start())
|
|
2661
|
+
* const joined = starting.pending // the in-flight promise, or undefined
|
|
2662
|
+
* ```
|
|
2663
|
+
*/
|
|
2664
|
+
export declare class BrowserTransition<T = void> implements BrowserTransitionInterface<T> {
|
|
2665
|
+
#private;
|
|
2666
|
+
get pending(): Promise<T> | undefined;
|
|
2667
|
+
execute(work: BrowserTransitionFunction<T>): Promise<T>;
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
/** Runs the work one {@link BrowserTransitionInterface} transition performs. */
|
|
2671
|
+
export declare type BrowserTransitionFunction<T> = () => Promise<T>;
|
|
2672
|
+
|
|
2673
|
+
/**
|
|
2674
|
+
* Represents one asynchronous transition shared by every caller that arrives while it runs.
|
|
2675
|
+
*
|
|
2676
|
+
* @remarks
|
|
2677
|
+
* `pending` is the promise of the transition in flight, or undefined when none
|
|
2678
|
+
* is running; an entity reads it to answer a question about its own state, such
|
|
2679
|
+
* as whether a close must wait for an in-flight connect. `execute` starts the
|
|
2680
|
+
* work when nothing is in flight, and joins the running transition otherwise.
|
|
2681
|
+
*/
|
|
2682
|
+
export declare interface BrowserTransitionInterface<T> {
|
|
2683
|
+
readonly pending: Promise<T> | undefined;
|
|
2684
|
+
/**
|
|
2685
|
+
* Starts the work when nothing is in flight, and otherwise joins the running transition
|
|
2686
|
+
* and returns its result.
|
|
2687
|
+
*/
|
|
2688
|
+
execute(work: BrowserTransitionFunction<T>): Promise<T>;
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
/** Describes the options for setting files on a file input. */
|
|
2013
2692
|
export declare interface BrowserUploadOptions extends BrowserActionOptions {
|
|
2014
2693
|
readonly files: readonly string[];
|
|
2015
2694
|
}
|
|
2016
2695
|
|
|
2017
|
-
/**
|
|
2696
|
+
/** Describes user-agent metadata accepted by Chromium emulation. */
|
|
2018
2697
|
export declare interface BrowserUserAgent {
|
|
2019
2698
|
readonly value: string;
|
|
2020
2699
|
readonly language?: string;
|
|
2021
2700
|
readonly platform?: string;
|
|
2022
2701
|
}
|
|
2023
2702
|
|
|
2024
|
-
/**
|
|
2703
|
+
/** Describes the viewport dimensions for a browser page. */
|
|
2025
2704
|
export declare interface BrowserViewport {
|
|
2026
2705
|
readonly width: number;
|
|
2027
2706
|
readonly height: number;
|
|
@@ -2032,7 +2711,7 @@ export declare interface BrowserViewport {
|
|
|
2032
2711
|
}
|
|
2033
2712
|
|
|
2034
2713
|
/**
|
|
2035
|
-
*
|
|
2714
|
+
* Describes the options for waiting on an element.
|
|
2036
2715
|
*
|
|
2037
2716
|
* @remarks
|
|
2038
2717
|
* - `timeout` — maximum time to wait in milliseconds
|
|
@@ -2043,14 +2722,14 @@ export declare interface BrowserWaitOptions extends BrowserActionOptions {
|
|
|
2043
2722
|
readonly state?: BrowserWaitState;
|
|
2044
2723
|
}
|
|
2045
2724
|
|
|
2046
|
-
/**
|
|
2725
|
+
/** Names an element state a frame or page can wait for. */
|
|
2047
2726
|
export declare type BrowserWaitState = 'attached' | 'detached' | 'visible' | 'hidden';
|
|
2048
2727
|
|
|
2049
|
-
/**
|
|
2728
|
+
/** Names the page load condition for navigation — the CDP load event awaited by `navigate()`. */
|
|
2050
2729
|
export declare type BrowserWaitUntil = 'commit' | 'load' | 'domcontentloaded';
|
|
2051
2730
|
|
|
2052
2731
|
/**
|
|
2053
|
-
*
|
|
2732
|
+
* Describes the options for walking a browser snapshot.
|
|
2054
2733
|
*
|
|
2055
2734
|
* @remarks
|
|
2056
2735
|
* - `root` — optional subtree root, included in the walk
|
|
@@ -2061,11 +2740,19 @@ export declare interface BrowserWalkOptions {
|
|
|
2061
2740
|
readonly order?: BrowserWalkOrder;
|
|
2062
2741
|
}
|
|
2063
2742
|
|
|
2064
|
-
/**
|
|
2743
|
+
/** Names the structural ordering for a browser snapshot walk. */
|
|
2065
2744
|
export declare type BrowserWalkOrder = 'depth' | 'breadth';
|
|
2066
2745
|
|
|
2067
2746
|
/**
|
|
2068
|
-
*
|
|
2747
|
+
* Represents an observable WebSocket connection reconstructed from Network-domain events.
|
|
2748
|
+
*
|
|
2749
|
+
* @example
|
|
2750
|
+
* ```ts
|
|
2751
|
+
* import { BrowserWebSocket } from '@orkestrel/browser'
|
|
2752
|
+
*
|
|
2753
|
+
* const socket = new BrowserWebSocket('request-1', 'wss://example.com/live')
|
|
2754
|
+
* socket.emitter.on('receive', (frame) => log(frame.data))
|
|
2755
|
+
* ```
|
|
2069
2756
|
*/
|
|
2070
2757
|
export declare class BrowserWebSocket implements BrowserWebSocketInterface {
|
|
2071
2758
|
#private;
|
|
@@ -2079,7 +2766,7 @@ export declare class BrowserWebSocket implements BrowserWebSocketInterface {
|
|
|
2079
2766
|
close(timestamp: number): void;
|
|
2080
2767
|
}
|
|
2081
2768
|
|
|
2082
|
-
/** WebSocket lifecycle events. */
|
|
2769
|
+
/** Maps the WebSocket lifecycle events. */
|
|
2083
2770
|
export declare type BrowserWebSocketEventMap = {
|
|
2084
2771
|
readonly receive: readonly [frame: BrowserWebSocketFrame];
|
|
2085
2772
|
readonly transmit: readonly [frame: BrowserWebSocketFrame];
|
|
@@ -2087,7 +2774,7 @@ export declare type BrowserWebSocketEventMap = {
|
|
|
2087
2774
|
readonly close: readonly [timestamp: number];
|
|
2088
2775
|
};
|
|
2089
2776
|
|
|
2090
|
-
/** WebSocket frame payload. */
|
|
2777
|
+
/** Describes a WebSocket frame payload. */
|
|
2091
2778
|
export declare interface BrowserWebSocketFrame {
|
|
2092
2779
|
readonly opcode: number;
|
|
2093
2780
|
readonly data: string;
|
|
@@ -2095,51 +2782,65 @@ export declare interface BrowserWebSocketFrame {
|
|
|
2095
2782
|
readonly timestamp: number;
|
|
2096
2783
|
}
|
|
2097
2784
|
|
|
2098
|
-
/**
|
|
2785
|
+
/**
|
|
2786
|
+
* Represents one observed WebSocket connection.
|
|
2787
|
+
*
|
|
2788
|
+
* @remarks
|
|
2789
|
+
* The connection is an observation: a page's network manager reconstructs it
|
|
2790
|
+
* from Network-domain events and drives the concrete `BrowserWebSocket`. The
|
|
2791
|
+
* drive methods are on this contract because the class exposes exactly its
|
|
2792
|
+
* interface methods.
|
|
2793
|
+
*/
|
|
2099
2794
|
export declare interface BrowserWebSocketInterface {
|
|
2100
2795
|
readonly emitter: EmitterInterface<BrowserWebSocketEventMap>;
|
|
2101
2796
|
readonly id: string;
|
|
2102
2797
|
readonly url: string;
|
|
2798
|
+
/** Reports one received frame. The page's network manager drives it. */
|
|
2103
2799
|
receive(frame: BrowserWebSocketFrame): void;
|
|
2800
|
+
/** Reports one sent frame. The page's network manager drives it. */
|
|
2104
2801
|
transmit(frame: BrowserWebSocketFrame): void;
|
|
2802
|
+
/** Reports a connection fault. The page's network manager drives it. */
|
|
2105
2803
|
fail(message: string): void;
|
|
2804
|
+
/** Reports the connection closing and destroys the emitter. The page's network manager drives it. */
|
|
2106
2805
|
close(timestamp: number): void;
|
|
2107
2806
|
}
|
|
2108
2807
|
|
|
2109
|
-
/**
|
|
2110
|
-
* Dedicated, shared, or service worker attached through a flattened target session.
|
|
2111
|
-
*/
|
|
2112
|
-
export declare class BrowserWorker implements BrowserWorkerInterface {
|
|
2113
|
-
#private;
|
|
2114
|
-
constructor(client: CDPClientInterface, session: string, id: string, url: string, category: BrowserWorkerCategory);
|
|
2115
|
-
get id(): string;
|
|
2116
|
-
get url(): string;
|
|
2117
|
-
get category(): BrowserWorkerCategory;
|
|
2118
|
-
evaluate(expression: string, timeout?: number): Promise<unknown>;
|
|
2119
|
-
send(method: string, params?: Readonly<Record<string, unknown>>): Promise<unknown>;
|
|
2120
|
-
detach(): void;
|
|
2121
|
-
close(): Promise<void>;
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
/** Worker target category. */
|
|
2808
|
+
/** Names a worker target category. */
|
|
2125
2809
|
export declare type BrowserWorkerCategory = 'worker' | 'service_worker' | 'shared_worker';
|
|
2126
2810
|
|
|
2127
|
-
/**
|
|
2811
|
+
/** Represents a script worker attached to a page target. */
|
|
2128
2812
|
export declare interface BrowserWorkerInterface {
|
|
2129
2813
|
readonly id: string;
|
|
2130
2814
|
readonly url: string;
|
|
2131
2815
|
readonly category: BrowserWorkerCategory;
|
|
2816
|
+
/** Evaluates a guarded expression in the worker and returns its value. */
|
|
2132
2817
|
evaluate(expression: string, timeout?: number): Promise<unknown>;
|
|
2818
|
+
/** Issues one CDP method call on the worker's session. */
|
|
2133
2819
|
send(method: string, params?: Readonly<Record<string, unknown>>): Promise<unknown>;
|
|
2820
|
+
/** Stops driving the worker locally without closing its target. */
|
|
2134
2821
|
detach(): void;
|
|
2822
|
+
/** Closes the worker target, tolerating a worker that already terminated. Idempotent. */
|
|
2135
2823
|
close(): Promise<void>;
|
|
2136
2824
|
}
|
|
2137
2825
|
|
|
2138
|
-
/**
|
|
2826
|
+
/**
|
|
2827
|
+
* Provides a pluggable sink for persisting captured browser bytes to a path.
|
|
2828
|
+
*
|
|
2829
|
+
* @remarks
|
|
2830
|
+
* Core never touches a filesystem directly — a page accepts an optional
|
|
2831
|
+
* writer (server supplies an `fs`-backed implementation) and calls it when a
|
|
2832
|
+
* screenshot, PDF, trace, or HAR request carries a `path`.
|
|
2833
|
+
*/
|
|
2834
|
+
export declare interface BrowserWriterInterface {
|
|
2835
|
+
/** Persists the captured bytes to the given path, creating its parent directories. */
|
|
2836
|
+
write(path: string, data: Uint8Array): Promise<void>;
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
/** Decodes UTF-8 bytes as text. */
|
|
2139
2840
|
export declare function bytesToText(value: Uint8Array): string;
|
|
2140
2841
|
|
|
2141
2842
|
/**
|
|
2142
|
-
*
|
|
2843
|
+
* Provides a lightweight Chrome DevTools Protocol client over a {@link CDPTransportInterface}.
|
|
2143
2844
|
*
|
|
2144
2845
|
* @remarks
|
|
2145
2846
|
* Sends JSON-RPC messages over the injected transport and dispatches
|
|
@@ -2147,18 +2848,28 @@ export declare function bytesToText(value: Uint8Array): string;
|
|
|
2147
2848
|
* (WebSocket, pipe, or any other duplex channel); this class owns only
|
|
2148
2849
|
* the JSON-RPC framing and id/session correlation.
|
|
2149
2850
|
*
|
|
2150
|
-
* Supports session-scoped event subscriptions:
|
|
2151
|
-
*
|
|
2152
|
-
*
|
|
2153
|
-
*
|
|
2851
|
+
* Supports session-scoped event subscriptions: a subscription registered
|
|
2852
|
+
* without a session id receives the event whatever session carries it, and a
|
|
2853
|
+
* session-scoped subscription receives only its own session's events.
|
|
2854
|
+
*
|
|
2855
|
+
* @example
|
|
2856
|
+
* ```ts
|
|
2857
|
+
* import { CDPClient } from '@orkestrel/browser'
|
|
2858
|
+
*
|
|
2859
|
+
* const client = new CDPClient({ transport })
|
|
2860
|
+
* await client.connect()
|
|
2861
|
+
* const targets = await client.send('Target.getTargets')
|
|
2862
|
+
* await client.close()
|
|
2863
|
+
* ```
|
|
2154
2864
|
*/
|
|
2155
2865
|
export declare class CDPClient implements CDPClientInterface {
|
|
2156
2866
|
#private;
|
|
2157
2867
|
constructor(options: CDPClientOptions);
|
|
2868
|
+
get emitter(): EmitterInterface<CDPClientEventMap>;
|
|
2158
2869
|
get connected(): boolean;
|
|
2159
2870
|
connect(): Promise<void>;
|
|
2160
2871
|
/**
|
|
2161
|
-
*
|
|
2872
|
+
* Closes the transport and re-establishes a fresh connection.
|
|
2162
2873
|
*
|
|
2163
2874
|
* @remarks
|
|
2164
2875
|
* Client-level subscriptions (`subscribe`/`unsubscribe` registrations)
|
|
@@ -2167,14 +2878,14 @@ export declare class CDPClient implements CDPClientInterface {
|
|
|
2167
2878
|
* transport without re-registering every handler.
|
|
2168
2879
|
*/
|
|
2169
2880
|
reconnect(): Promise<void>;
|
|
2170
|
-
send(method: string, params?: Readonly<Record<string, unknown>>,
|
|
2171
|
-
subscribe(method: string, handler: CDPHandler,
|
|
2172
|
-
unsubscribe(method: string, handler: CDPHandler,
|
|
2881
|
+
send(method: string, params?: Readonly<Record<string, unknown>>, options?: CDPSendOptions): Promise<unknown>;
|
|
2882
|
+
subscribe(method: string, handler: CDPHandler, session?: string): void;
|
|
2883
|
+
unsubscribe(method: string, handler: CDPHandler, session?: string): void;
|
|
2173
2884
|
/**
|
|
2174
|
-
*
|
|
2885
|
+
* Closes the transport and rejects all pending requests.
|
|
2175
2886
|
*
|
|
2176
2887
|
* @remarks
|
|
2177
|
-
* Subscriptions registered
|
|
2888
|
+
* Subscriptions registered through `subscribe()` are client-level
|
|
2178
2889
|
* registrations, not connection-level state — they survive `close()`
|
|
2179
2890
|
* (and a subsequent `reconnect()`/`connect()`) and keep firing once the
|
|
2180
2891
|
* transport is active again. Only pending requests are rejected here.
|
|
@@ -2186,9 +2897,27 @@ export declare class CDPClient implements CDPClientInterface {
|
|
|
2186
2897
|
}
|
|
2187
2898
|
|
|
2188
2899
|
/**
|
|
2189
|
-
*
|
|
2900
|
+
* Maps the events a {@link CDPClientInterface} emits.
|
|
2901
|
+
*
|
|
2902
|
+
* @remarks
|
|
2903
|
+
* `connect` fires once the transport started and dispatch began; `close`
|
|
2904
|
+
* fires after an explicit teardown, including one that interrupted a
|
|
2905
|
+
* pending `connect()`; `drop` fires when the transport ended without a
|
|
2906
|
+
* close request; `error` carries a transport-level fault (unknown shape —
|
|
2907
|
+
* narrow before use).
|
|
2908
|
+
*/
|
|
2909
|
+
export declare type CDPClientEventMap = {
|
|
2910
|
+
readonly connect: readonly [];
|
|
2911
|
+
readonly close: readonly [];
|
|
2912
|
+
readonly drop: readonly [];
|
|
2913
|
+
readonly error: readonly [error: unknown];
|
|
2914
|
+
};
|
|
2915
|
+
|
|
2916
|
+
/**
|
|
2917
|
+
* Provides a lightweight Chrome DevTools Protocol client over a {@link CDPTransportInterface}.
|
|
2190
2918
|
*
|
|
2191
2919
|
* @remarks
|
|
2920
|
+
* - `emitter` — subscribe to the client's own connection lifecycle
|
|
2192
2921
|
* - `connected` — true while the transport is active
|
|
2193
2922
|
* - `connect` — start the transport and begin dispatching
|
|
2194
2923
|
* - `reconnect` — close and re-establish the transport
|
|
@@ -2200,68 +2929,107 @@ export declare class CDPClient implements CDPClientInterface {
|
|
|
2200
2929
|
* - `close` — tear down the transport and reject all pending requests
|
|
2201
2930
|
*/
|
|
2202
2931
|
export declare interface CDPClientInterface {
|
|
2932
|
+
readonly emitter: EmitterInterface<CDPClientEventMap>;
|
|
2203
2933
|
readonly connected: boolean;
|
|
2934
|
+
/** Starts the transport and begins dispatching. Idempotent. */
|
|
2204
2935
|
connect(): Promise<void>;
|
|
2936
|
+
/** Closes the transport and re-establishes it. */
|
|
2205
2937
|
reconnect(): Promise<void>;
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2938
|
+
/**
|
|
2939
|
+
* Issues a CDP method call with optional params and a trailing `CDPSendOptions` carrying
|
|
2940
|
+
* the `session` to scope it to and a per-call `timeout` overriding the client-wide
|
|
2941
|
+
* default; rejects on timeout.
|
|
2942
|
+
*/
|
|
2943
|
+
send(method: string, params?: Readonly<Record<string, unknown>>, options?: CDPSendOptions): Promise<unknown>;
|
|
2944
|
+
/** Registers a handler for a CDP event, optionally session-scoped. */
|
|
2945
|
+
subscribe(method: string, handler: CDPHandler, session?: string): void;
|
|
2946
|
+
/** Removes a handler for a CDP event, optionally session-scoped. */
|
|
2947
|
+
unsubscribe(method: string, handler: CDPHandler, session?: string): void;
|
|
2948
|
+
/** Tears down the transport and rejects every pending request. */
|
|
2209
2949
|
close(): Promise<void>;
|
|
2210
2950
|
}
|
|
2211
2951
|
|
|
2212
2952
|
/**
|
|
2213
|
-
*
|
|
2953
|
+
* Describes the options for creating a `CDPClient` instance.
|
|
2214
2954
|
*
|
|
2215
2955
|
* @remarks
|
|
2216
2956
|
* - `transport` — the text pipe the client sends/receives JSON-RPC frames over
|
|
2217
2957
|
* - `timeout` — ms before a pending request or connection attempt fails (default from constants)
|
|
2958
|
+
* - `on` — initial event listeners wired at construction
|
|
2959
|
+
* - `error` — receives a throwing subscriber's error on both dispatch paths:
|
|
2960
|
+
* a CDP event subscriber's throw arrives with the CDP method that raised it,
|
|
2961
|
+
* and a lifecycle subscriber's throw arrives with the lifecycle event name
|
|
2962
|
+
* (`connect`, `close`, `drop`, `error`) as the second argument. Without it a
|
|
2963
|
+
* broken handler fails silently, because a throwing subscriber is never
|
|
2964
|
+
* allowed to reach its siblings or the dispatch loop
|
|
2218
2965
|
*/
|
|
2219
2966
|
export declare interface CDPClientOptions {
|
|
2220
2967
|
readonly transport: CDPTransportInterface;
|
|
2221
2968
|
readonly timeout?: number;
|
|
2969
|
+
readonly on?: EmitterHooks<CDPClientEventMap>;
|
|
2970
|
+
readonly error?: EmitterErrorHandler;
|
|
2222
2971
|
}
|
|
2223
2972
|
|
|
2224
2973
|
/**
|
|
2225
|
-
*
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2974
|
+
* Reports that a CDP request could not be sent or completed because the client was not in a
|
|
2975
|
+
* connectable state — not connected, closed while connecting, or the connection dropped
|
|
2976
|
+
* mid-request — under the code `BROWSER_CDP_CONNECTION_ERROR`.
|
|
2228
2977
|
*/
|
|
2229
2978
|
export declare class CDPConnectionError extends BrowserError {
|
|
2230
2979
|
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
2231
2980
|
}
|
|
2232
2981
|
|
|
2233
2982
|
/**
|
|
2234
|
-
*
|
|
2983
|
+
* Reports that a CDP request received an error response from the remote endpoint, under the
|
|
2984
|
+
* code `BROWSER_CDP_ERROR`, with the `method`, the CDP `code`, the `message`, and any `data`
|
|
2985
|
+
* in its context.
|
|
2235
2986
|
*
|
|
2236
2987
|
* @remarks
|
|
2237
|
-
*
|
|
2238
|
-
* `message`, and `data` (when present) in `context`, so callers can branch
|
|
2239
|
-
* on the protocol-level error instead of parsing the message string.
|
|
2988
|
+
* Branch on the protocol-level error in `context` instead of parsing the message string.
|
|
2240
2989
|
*/
|
|
2241
2990
|
export declare class CDPError extends BrowserError {
|
|
2242
2991
|
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
2243
2992
|
}
|
|
2244
2993
|
|
|
2245
|
-
/**
|
|
2994
|
+
/** Receives a subscribed CDP event with its params record. */
|
|
2246
2995
|
export declare type CDPHandler = (params: Readonly<Record<string, unknown>>) => void;
|
|
2247
2996
|
|
|
2248
|
-
/**
|
|
2997
|
+
/**
|
|
2998
|
+
* Describes the options for one CDP method call.
|
|
2999
|
+
*
|
|
3000
|
+
* @remarks
|
|
3001
|
+
* - `session` — scope the call to one attached CDP session
|
|
3002
|
+
* - `timeout` — ms before this one request fails, overriding the client-wide default
|
|
3003
|
+
*/
|
|
3004
|
+
export declare interface CDPSendOptions {
|
|
3005
|
+
readonly session?: string;
|
|
3006
|
+
readonly timeout?: number;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
/**
|
|
3010
|
+
* Represents one entry of the CDP `Target.getTargets` result.
|
|
3011
|
+
*
|
|
3012
|
+
* @remarks
|
|
3013
|
+
* `category` mirrors the protocol's `type` field — `'page'`, `'worker'`,
|
|
3014
|
+
* `'browser'`, and the rest of Chromium's target categories.
|
|
3015
|
+
*/
|
|
2249
3016
|
export declare interface CDPTarget {
|
|
2250
3017
|
readonly id: string;
|
|
2251
|
-
readonly
|
|
3018
|
+
readonly category: string;
|
|
2252
3019
|
readonly title: string;
|
|
2253
3020
|
readonly url: string;
|
|
2254
3021
|
}
|
|
2255
3022
|
|
|
2256
3023
|
/**
|
|
2257
|
-
*
|
|
3024
|
+
* Reports that a pending CDP request was not answered within its timeout window, under the
|
|
3025
|
+
* code `BROWSER_CDP_TIMEOUT_ERROR`.
|
|
2258
3026
|
*/
|
|
2259
3027
|
export declare class CDPTimeoutError extends BrowserError {
|
|
2260
3028
|
constructor(message: string, context?: Readonly<Record<string, unknown>>);
|
|
2261
3029
|
}
|
|
2262
3030
|
|
|
2263
3031
|
/**
|
|
2264
|
-
*
|
|
3032
|
+
* Maps the events emitted by a {@link CDPTransportInterface} — the raw text pipe a
|
|
2265
3033
|
* {@link CDPClientInterface} sends and receives JSON-RPC frames over.
|
|
2266
3034
|
*
|
|
2267
3035
|
* @remarks
|
|
@@ -2276,7 +3044,7 @@ export declare type CDPTransportEventMap = {
|
|
|
2276
3044
|
};
|
|
2277
3045
|
|
|
2278
3046
|
/**
|
|
2279
|
-
*
|
|
3047
|
+
* Represents the text pipe a `CDPClient` sends and receives JSON-RPC frames over.
|
|
2280
3048
|
*
|
|
2281
3049
|
* @remarks
|
|
2282
3050
|
* The transport owns the connection (WebSocket, pipe, or any other duplex
|
|
@@ -2287,13 +3055,19 @@ export declare type CDPTransportEventMap = {
|
|
|
2287
3055
|
*/
|
|
2288
3056
|
export declare interface CDPTransportInterface {
|
|
2289
3057
|
readonly emitter: EmitterInterface<CDPTransportEventMap>;
|
|
3058
|
+
/** Opens the underlying connection. */
|
|
2290
3059
|
start(): Promise<void>;
|
|
3060
|
+
/**
|
|
3061
|
+
* Writes one raw text frame to the connection. Throws a coded `BrowserConnectionError`
|
|
3062
|
+
* carrying the transport `url` when called before the connection opens or after it closes.
|
|
3063
|
+
*/
|
|
2291
3064
|
send(data: string): Promise<void>;
|
|
3065
|
+
/** Closes the underlying connection and releases its resources. */
|
|
2292
3066
|
close(): Promise<void>;
|
|
2293
3067
|
}
|
|
2294
3068
|
|
|
2295
3069
|
/**
|
|
2296
|
-
*
|
|
3070
|
+
* Compiles the element-side actionability pass used before trusted input.
|
|
2297
3071
|
*
|
|
2298
3072
|
* @param options - Checks required for the action
|
|
2299
3073
|
* @returns Async `Runtime.callFunctionOn` function declaration
|
|
@@ -2301,12 +3075,12 @@ export declare interface CDPTransportInterface {
|
|
|
2301
3075
|
export declare function compileActionabilityFunction(options: BrowserActionabilityOptions): string;
|
|
2302
3076
|
|
|
2303
3077
|
/**
|
|
2304
|
-
*
|
|
3078
|
+
* Compiles an attached-state locator wait.
|
|
2305
3079
|
*/
|
|
2306
3080
|
export declare function compileAttachedLocatorWaitExpression(query: BrowserQuery, strict: boolean, timeout: number): string;
|
|
2307
3081
|
|
|
2308
3082
|
/**
|
|
2309
|
-
*
|
|
3083
|
+
* Compiles an in-page wait for an attached selector.
|
|
2310
3084
|
*
|
|
2311
3085
|
* @param selector - CSS selector
|
|
2312
3086
|
* @param strict - Whether more than one match is an error
|
|
@@ -2316,7 +3090,7 @@ export declare function compileAttachedLocatorWaitExpression(query: BrowserQuery
|
|
|
2316
3090
|
export declare function compileAttachedWaitExpression(selector: string, strict: boolean, timeout: number): string;
|
|
2317
3091
|
|
|
2318
3092
|
/**
|
|
2319
|
-
*
|
|
3093
|
+
* Compiles current-document cleanup for one page-side host binding facade.
|
|
2320
3094
|
*
|
|
2321
3095
|
* @param name - Binding identifier
|
|
2322
3096
|
* @returns Runtime cleanup expression
|
|
@@ -2324,7 +3098,7 @@ export declare function compileAttachedWaitExpression(selector: string, strict:
|
|
|
2324
3098
|
export declare function compileBrowserBindingCleanup(name: string): string;
|
|
2325
3099
|
|
|
2326
3100
|
/**
|
|
2327
|
-
*
|
|
3101
|
+
* Compiles delivery of a host binding result to one execution context.
|
|
2328
3102
|
*
|
|
2329
3103
|
* @param name - Binding identifier
|
|
2330
3104
|
* @param id - Call identifier
|
|
@@ -2335,7 +3109,7 @@ export declare function compileBrowserBindingCleanup(name: string): string;
|
|
|
2335
3109
|
export declare function compileBrowserBindingResult(name: string, id: string, success: boolean, value: unknown): string;
|
|
2336
3110
|
|
|
2337
3111
|
/**
|
|
2338
|
-
*
|
|
3112
|
+
* Compiles the page-side promise facade for one Runtime binding.
|
|
2339
3113
|
*
|
|
2340
3114
|
* @param name - Binding identifier
|
|
2341
3115
|
* @returns Self-installing script source
|
|
@@ -2343,7 +3117,7 @@ export declare function compileBrowserBindingResult(name: string, id: string, su
|
|
|
2343
3117
|
export declare function compileBrowserBindingSource(name: string): string;
|
|
2344
3118
|
|
|
2345
3119
|
/**
|
|
2346
|
-
*
|
|
3120
|
+
* Compiles a strict, visibility-checked click expression.
|
|
2347
3121
|
*
|
|
2348
3122
|
* @param selector - CSS selector
|
|
2349
3123
|
* @param strict - Whether more than one match is an error
|
|
@@ -2352,7 +3126,7 @@ export declare function compileBrowserBindingSource(name: string): string;
|
|
|
2352
3126
|
export declare function compileClickExpression(selector: string, strict: boolean): string;
|
|
2353
3127
|
|
|
2354
3128
|
/**
|
|
2355
|
-
*
|
|
3129
|
+
* Compiles recorded codegen actions into a replayable JavaScript or TypeScript script.
|
|
2356
3130
|
*
|
|
2357
3131
|
* @remarks
|
|
2358
3132
|
* Emits one statement per action against a `page` object shaped like
|
|
@@ -2368,12 +3142,12 @@ export declare function compileClickExpression(selector: string, strict: boolean
|
|
|
2368
3142
|
export declare function compileCodegenScript(actions: readonly BrowserCodegenAction[], options?: BrowserCodegenScriptOptions): string;
|
|
2369
3143
|
|
|
2370
3144
|
/**
|
|
2371
|
-
*
|
|
3145
|
+
* Compiles a detached-state locator wait.
|
|
2372
3146
|
*/
|
|
2373
3147
|
export declare function compileDetachedLocatorWaitExpression(query: BrowserQuery, strict: boolean, timeout: number): string;
|
|
2374
3148
|
|
|
2375
3149
|
/**
|
|
2376
|
-
*
|
|
3150
|
+
* Compiles an in-page wait for a detached selector.
|
|
2377
3151
|
*
|
|
2378
3152
|
* @param selector - CSS selector
|
|
2379
3153
|
* @param strict - Whether more than one match is an error
|
|
@@ -2383,7 +3157,7 @@ export declare function compileDetachedLocatorWaitExpression(query: BrowserQuery
|
|
|
2383
3157
|
export declare function compileDetachedWaitExpression(selector: string, strict: boolean, timeout: number): string;
|
|
2384
3158
|
|
|
2385
3159
|
/**
|
|
2386
|
-
*
|
|
3160
|
+
* Compiles a strict, editable fill expression.
|
|
2387
3161
|
*
|
|
2388
3162
|
* @param selector - CSS selector
|
|
2389
3163
|
* @param value - Value to assign
|
|
@@ -2393,7 +3167,7 @@ export declare function compileDetachedWaitExpression(selector: string, strict:
|
|
|
2393
3167
|
export declare function compileFillExpression(selector: string, value: string, strict: boolean): string;
|
|
2394
3168
|
|
|
2395
3169
|
/**
|
|
2396
|
-
*
|
|
3170
|
+
* Compiles an auto-retrying in-page predicate wait.
|
|
2397
3171
|
*
|
|
2398
3172
|
* @param expression - Value or function expression
|
|
2399
3173
|
* @param timeout - Maximum wait in milliseconds
|
|
@@ -2402,30 +3176,54 @@ export declare function compileFillExpression(selector: string, value: string, s
|
|
|
2402
3176
|
export declare function compileFunctionWaitExpression(expression: string, timeout: number): string;
|
|
2403
3177
|
|
|
2404
3178
|
/**
|
|
2405
|
-
*
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
/**
|
|
2410
|
-
* Compile an in-page wait for a hidden selector.
|
|
2411
|
-
*
|
|
2412
|
-
* @param selector - CSS selector
|
|
2413
|
-
* @param strict - Whether more than one match is an error
|
|
2414
|
-
* @param timeout - Maximum wait in milliseconds
|
|
2415
|
-
* @returns Runtime expression resolving to whether the state was reached
|
|
2416
|
-
*/
|
|
2417
|
-
export declare function compileHiddenWaitExpression(selector: string, strict: boolean, timeout: number): string;
|
|
2418
|
-
|
|
2419
|
-
/**
|
|
2420
|
-
* Compile a deep locator query returning its first match.
|
|
3179
|
+
* Compiles a `Runtime.evaluate` expression so the in-page code stringifies its own result and
|
|
3180
|
+
* throws a recognizable sentinel error before an oversized result would overflow the CDP
|
|
3181
|
+
* transport frame.
|
|
2421
3182
|
*
|
|
2422
|
-
* @
|
|
2423
|
-
*
|
|
2424
|
-
|
|
3183
|
+
* @remarks
|
|
3184
|
+
* A result whose `JSON.stringify` length exceeds `limit` throws
|
|
3185
|
+
* `Error('BROWSER_RESULT_LIMIT: <length>')` inside the page instead of being
|
|
3186
|
+
* returned — the caller maps that sentinel to a coded
|
|
3187
|
+
* {@link BrowserResultLimitError}. A non-serializable result (`undefined`,
|
|
3188
|
+
* a function, a symbol) makes `JSON.stringify` return `undefined`, so the
|
|
3189
|
+
* length check is skipped and today's undefined-passthrough behavior is
|
|
3190
|
+
* unchanged.
|
|
3191
|
+
*
|
|
3192
|
+
* The expression is placed on its own line inside the wrapper (rather than
|
|
3193
|
+
* inline with the guard code) so a trailing `//` line comment in the
|
|
3194
|
+
* expression cannot swallow the closing guard syntax that follows it.
|
|
3195
|
+
*
|
|
3196
|
+
* @param expression - The candidate JavaScript expression to evaluate
|
|
3197
|
+
* @param limit - Maximum serialized-character length (see {@link BROWSER_RESULT_LIMIT})
|
|
3198
|
+
* @returns The wrapped, guarded expression
|
|
3199
|
+
*/
|
|
3200
|
+
export declare function compileGuardedEvaluateExpression(expression: string, limit: number): string;
|
|
3201
|
+
|
|
3202
|
+
/**
|
|
3203
|
+
* Compiles a hidden-state locator wait.
|
|
3204
|
+
*/
|
|
3205
|
+
export declare function compileHiddenLocatorWaitExpression(query: BrowserQuery, strict: boolean, timeout: number): string;
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* Compiles an in-page wait for a hidden selector.
|
|
3209
|
+
*
|
|
3210
|
+
* @param selector - CSS selector
|
|
3211
|
+
* @param strict - Whether more than one match is an error
|
|
3212
|
+
* @param timeout - Maximum wait in milliseconds
|
|
3213
|
+
* @returns Runtime expression resolving to whether the state was reached
|
|
3214
|
+
*/
|
|
3215
|
+
export declare function compileHiddenWaitExpression(selector: string, strict: boolean, timeout: number): string;
|
|
3216
|
+
|
|
3217
|
+
/**
|
|
3218
|
+
* Compiles a deep locator query returning its first match.
|
|
3219
|
+
*
|
|
3220
|
+
* @param query - Serializable locator query
|
|
3221
|
+
* @returns Runtime expression returning one element or undefined
|
|
3222
|
+
*/
|
|
2425
3223
|
export declare function compileLocatorExpression(query: BrowserQuery): string;
|
|
2426
3224
|
|
|
2427
3225
|
/**
|
|
2428
|
-
*
|
|
3226
|
+
* Compiles a deep, shadow-aware locator query returning every match.
|
|
2429
3227
|
*
|
|
2430
3228
|
* @param query - Serializable locator query
|
|
2431
3229
|
* @returns Runtime expression returning an element array
|
|
@@ -2433,7 +3231,7 @@ export declare function compileLocatorExpression(query: BrowserQuery): string;
|
|
|
2433
3231
|
export declare function compileLocatorListExpression(query: BrowserQuery): string;
|
|
2434
3232
|
|
|
2435
3233
|
/**
|
|
2436
|
-
*
|
|
3234
|
+
* Compiles cleanup for temporary screenshot styles and masks.
|
|
2437
3235
|
*
|
|
2438
3236
|
* @param token - Preparation token
|
|
2439
3237
|
* @returns Cleanup expression
|
|
@@ -2441,7 +3239,7 @@ export declare function compileLocatorListExpression(query: BrowserQuery): strin
|
|
|
2441
3239
|
export declare function compileScreenshotCleanupExpression(token: string): string;
|
|
2442
3240
|
|
|
2443
3241
|
/**
|
|
2444
|
-
*
|
|
3242
|
+
* Compiles temporary animation, caret, and mask setup for a screenshot.
|
|
2445
3243
|
*
|
|
2446
3244
|
* @param options - Screenshot controls
|
|
2447
3245
|
* @returns Setup expression or undefined when no preparation is required
|
|
@@ -2449,7 +3247,7 @@ export declare function compileScreenshotCleanupExpression(token: string): strin
|
|
|
2449
3247
|
export declare function compileScreenshotPreparationExpression(options?: BrowserScreenshotOptions): string | undefined;
|
|
2450
3248
|
|
|
2451
3249
|
/**
|
|
2452
|
-
*
|
|
3250
|
+
* Compiles a strict select expression.
|
|
2453
3251
|
*
|
|
2454
3252
|
* @param selector - CSS selector
|
|
2455
3253
|
* @param values - Option values to select
|
|
@@ -2459,21 +3257,21 @@ export declare function compileScreenshotPreparationExpression(options?: Browser
|
|
|
2459
3257
|
export declare function compileSelectExpression(selector: string, values: readonly string[], strict: boolean): string;
|
|
2460
3258
|
|
|
2461
3259
|
/**
|
|
2462
|
-
*
|
|
3260
|
+
* Compiles an expression that clears local and session storage.
|
|
2463
3261
|
*
|
|
2464
3262
|
* @returns In-page clear expression
|
|
2465
3263
|
*/
|
|
2466
3264
|
export declare function compileStorageClearExpression(): string;
|
|
2467
3265
|
|
|
2468
3266
|
/**
|
|
2469
|
-
*
|
|
3267
|
+
* Compiles an expression that serializes local and session storage.
|
|
2470
3268
|
*
|
|
2471
3269
|
* @returns In-page storage expression
|
|
2472
3270
|
*/
|
|
2473
3271
|
export declare function compileStorageReadExpression(): string;
|
|
2474
3272
|
|
|
2475
3273
|
/**
|
|
2476
|
-
*
|
|
3274
|
+
* Compiles an expression that restores one origin's web storage.
|
|
2477
3275
|
*
|
|
2478
3276
|
* @param origin - Storage values to restore
|
|
2479
3277
|
* @returns In-page restore expression
|
|
@@ -2481,12 +3279,12 @@ export declare function compileStorageReadExpression(): string;
|
|
|
2481
3279
|
export declare function compileStorageRestoreExpression(origin: BrowserStorageOrigin): string;
|
|
2482
3280
|
|
|
2483
3281
|
/**
|
|
2484
|
-
*
|
|
3282
|
+
* Compiles a visible-state locator wait.
|
|
2485
3283
|
*/
|
|
2486
3284
|
export declare function compileVisibleLocatorWaitExpression(query: BrowserQuery, strict: boolean, timeout: number): string;
|
|
2487
3285
|
|
|
2488
3286
|
/**
|
|
2489
|
-
*
|
|
3287
|
+
* Compiles an in-page wait for a visible selector.
|
|
2490
3288
|
*
|
|
2491
3289
|
* @param selector - CSS selector
|
|
2492
3290
|
* @param strict - Whether more than one match is an error
|
|
@@ -2496,15 +3294,15 @@ export declare function compileVisibleLocatorWaitExpression(query: BrowserQuery,
|
|
|
2496
3294
|
export declare function compileVisibleWaitExpression(selector: string, strict: boolean, timeout: number): string;
|
|
2497
3295
|
|
|
2498
3296
|
/**
|
|
2499
|
-
*
|
|
3297
|
+
* Computes the CDP Input pressed-button bitmask.
|
|
2500
3298
|
*
|
|
2501
|
-
* @param buttons -
|
|
3299
|
+
* @param buttons - Pressed public mouse buttons
|
|
2502
3300
|
* @returns Combined CDP pressed-button mask
|
|
2503
3301
|
*/
|
|
2504
3302
|
export declare function computeBrowserButtons(buttons: readonly BrowserMouseButton[]): number;
|
|
2505
3303
|
|
|
2506
3304
|
/**
|
|
2507
|
-
*
|
|
3305
|
+
* Computes the CDP Input modifier bitmask.
|
|
2508
3306
|
*
|
|
2509
3307
|
* @param modifiers - Canonical modifier names
|
|
2510
3308
|
* @returns Combined CDP modifier mask
|
|
@@ -2512,7 +3310,7 @@ export declare function computeBrowserButtons(buttons: readonly BrowserMouseButt
|
|
|
2512
3310
|
export declare function computeBrowserModifiers(modifiers: readonly string[]): number;
|
|
2513
3311
|
|
|
2514
3312
|
/**
|
|
2515
|
-
*
|
|
3313
|
+
* Concatenates byte chunks without Node-specific buffers.
|
|
2516
3314
|
*
|
|
2517
3315
|
* @param chunks - Byte arrays in source order
|
|
2518
3316
|
* @returns Combined bytes
|
|
@@ -2520,7 +3318,7 @@ export declare function computeBrowserModifiers(modifiers: readonly string[]): n
|
|
|
2520
3318
|
export declare function concatBytes(chunks: readonly Uint8Array[]): Uint8Array;
|
|
2521
3319
|
|
|
2522
3320
|
/**
|
|
2523
|
-
*
|
|
3321
|
+
* Converts a typed cookie input into Chromium protocol fields.
|
|
2524
3322
|
*
|
|
2525
3323
|
* @param cookie - Validated public cookie input
|
|
2526
3324
|
* @returns Protocol cookie record
|
|
@@ -2528,7 +3326,7 @@ export declare function concatBytes(chunks: readonly Uint8Array[]): Uint8Array;
|
|
|
2528
3326
|
export declare function cookieToProtocol(cookie: BrowserCookieInput): Readonly<Record<string, unknown>>;
|
|
2529
3327
|
|
|
2530
3328
|
/**
|
|
2531
|
-
*
|
|
3329
|
+
* Builds a standards-shaped HAR 1.2 entry from one observed exchange.
|
|
2532
3330
|
*
|
|
2533
3331
|
* @param pending - Request and optional response captured by the recorder
|
|
2534
3332
|
* @param duration - Whole exchange duration in milliseconds
|
|
@@ -2539,30 +3337,30 @@ export declare function cookieToProtocol(cookie: BrowserCookieInput): Readonly<R
|
|
|
2539
3337
|
export declare function createBrowserHAREntry(pending: BrowserHARPending, duration: number, body?: Uint8Array, error?: string): BrowserHAREntry;
|
|
2540
3338
|
|
|
2541
3339
|
/**
|
|
2542
|
-
*
|
|
3340
|
+
* Creates a navigable `BrowserSnapshotInterface` over decoded `BrowserSnapshotInput` data.
|
|
2543
3341
|
*
|
|
2544
3342
|
* @param input - Captured documents and computed-style names
|
|
2545
3343
|
* @returns A {@link BrowserSnapshotInterface}
|
|
2546
3344
|
*
|
|
2547
3345
|
* @example
|
|
2548
3346
|
* ```ts
|
|
2549
|
-
* import { createBrowserSnapshot,
|
|
3347
|
+
* import { createBrowserSnapshot, readBrowserSnapshot } from '@orkestrel/browser'
|
|
2550
3348
|
*
|
|
2551
|
-
* const snapshot = createBrowserSnapshot(
|
|
3349
|
+
* const snapshot = createBrowserSnapshot(readBrowserSnapshot(captured, ['display']))
|
|
2552
3350
|
* snapshot.find({ name: 'main' })
|
|
2553
3351
|
* ```
|
|
2554
3352
|
*/
|
|
2555
3353
|
export declare function createBrowserSnapshot(input: BrowserSnapshotInput): BrowserSnapshotInterface;
|
|
2556
3354
|
|
|
2557
3355
|
/**
|
|
2558
|
-
*
|
|
3356
|
+
* Creates a `CDPClientInterface` bound to the given `CDPTransportInterface`.
|
|
2559
3357
|
*
|
|
2560
3358
|
* @param options - The transport (and optional timeout) the client uses
|
|
2561
3359
|
* @returns A {@link CDPClientInterface}
|
|
2562
3360
|
*
|
|
2563
3361
|
* @example
|
|
2564
3362
|
* ```ts
|
|
2565
|
-
* import { createCDPClient } from '@
|
|
3363
|
+
* import { createCDPClient } from '@orkestrel/browser'
|
|
2566
3364
|
*
|
|
2567
3365
|
* const client = createCDPClient({ transport })
|
|
2568
3366
|
* await client.connect()
|
|
@@ -2571,7 +3369,7 @@ export declare function createBrowserSnapshot(input: BrowserSnapshotInput): Brow
|
|
|
2571
3369
|
export declare function createCDPClient(options: CDPClientOptions): CDPClientInterface;
|
|
2572
3370
|
|
|
2573
3371
|
/**
|
|
2574
|
-
*
|
|
3372
|
+
* Decodes a base64-encoded string into raw bytes.
|
|
2575
3373
|
*
|
|
2576
3374
|
* @remarks
|
|
2577
3375
|
* Pure JS implementation — no `Buffer`, no `atob` (DOM-only) — so it runs
|
|
@@ -2589,51 +3387,7 @@ export declare function createCDPClient(options: CDPClientOptions): CDPClientInt
|
|
|
2589
3387
|
export declare function decodeBase64(text: string): Uint8Array;
|
|
2590
3388
|
|
|
2591
3389
|
/**
|
|
2592
|
-
*
|
|
2593
|
-
*
|
|
2594
|
-
* @param value - Candidate string-index array
|
|
2595
|
-
* @param strings - Snapshot string table
|
|
2596
|
-
* @returns Frozen attribute record
|
|
2597
|
-
*/
|
|
2598
|
-
export declare function decodeBrowserAttributes(value: unknown, strings: readonly string[]): Readonly<Record<string, string>>;
|
|
2599
|
-
|
|
2600
|
-
/**
|
|
2601
|
-
* Decode a CDP `DOMSnapshot.captureSnapshot` result.
|
|
2602
|
-
*
|
|
2603
|
-
* @param value - Unknown CDP result
|
|
2604
|
-
* @param styles - Requested computed-style names, in protocol order
|
|
2605
|
-
* @param limit - Maximum accepted node count
|
|
2606
|
-
* @returns A typed serializable browser snapshot
|
|
2607
|
-
*/
|
|
2608
|
-
export declare function decodeBrowserSnapshot(value: unknown, styles?: readonly string[], limit?: number): BrowserSnapshotInput;
|
|
2609
|
-
|
|
2610
|
-
/**
|
|
2611
|
-
* Decode CDP snapshot sparse boolean data.
|
|
2612
|
-
*
|
|
2613
|
-
* @param value - Sparse `{ index }` record
|
|
2614
|
-
* @returns Set of node indexes whose value is true
|
|
2615
|
-
*/
|
|
2616
|
-
export declare function decodeRareBooleanData(value: unknown): ReadonlySet<number>;
|
|
2617
|
-
|
|
2618
|
-
/**
|
|
2619
|
-
* Decode CDP snapshot sparse integer data.
|
|
2620
|
-
*
|
|
2621
|
-
* @param value - Sparse `{ index, value }` record
|
|
2622
|
-
* @returns Node-index to integer map
|
|
2623
|
-
*/
|
|
2624
|
-
export declare function decodeRareIntegerData(value: unknown): ReadonlyMap<number, number>;
|
|
2625
|
-
|
|
2626
|
-
/**
|
|
2627
|
-
* Decode CDP snapshot sparse string data.
|
|
2628
|
-
*
|
|
2629
|
-
* @param value - Sparse `{ index, value }` record
|
|
2630
|
-
* @param strings - Snapshot string table
|
|
2631
|
-
* @returns Node-index to string map
|
|
2632
|
-
*/
|
|
2633
|
-
export declare function decodeRareStringData(value: unknown, strings: readonly string[]): ReadonlyMap<number, string>;
|
|
2634
|
-
|
|
2635
|
-
/**
|
|
2636
|
-
* Encode raw bytes as base64 without relying on Node or DOM globals.
|
|
3390
|
+
* Encodes raw bytes as base64 without relying on Node or DOM globals.
|
|
2637
3391
|
*
|
|
2638
3392
|
* @param bytes - Raw input bytes
|
|
2639
3393
|
* @returns Base64 text
|
|
@@ -2641,46 +3395,32 @@ export declare function decodeRareStringData(value: unknown, strings: readonly s
|
|
|
2641
3395
|
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
2642
3396
|
|
|
2643
3397
|
/**
|
|
2644
|
-
*
|
|
2645
|
-
*
|
|
2646
|
-
* would overflow the CDP transport frame.
|
|
2647
|
-
*
|
|
2648
|
-
* @remarks
|
|
2649
|
-
* A result whose `JSON.stringify` length exceeds `limit` throws
|
|
2650
|
-
* `Error('BROWSER_RESULT_LIMIT: <length>')` inside the page instead of being
|
|
2651
|
-
* returned — the caller maps that sentinel to a coded
|
|
2652
|
-
* {@link BrowserResultLimitError}. A non-serializable result (`undefined`,
|
|
2653
|
-
* a function, a symbol) makes `JSON.stringify` return `undefined`, so the
|
|
2654
|
-
* length check is skipped and today's undefined-passthrough behavior is
|
|
2655
|
-
* unchanged.
|
|
2656
|
-
*
|
|
2657
|
-
* The expression is placed on its own line inside the wrapper (rather than
|
|
2658
|
-
* inline with the guard code) so a trailing `//` line comment in the
|
|
2659
|
-
* expression cannot swallow the closing guard syntax that follows it.
|
|
3398
|
+
* Extracts a keyboard chord such as `Control+Shift+P` into its parts, throwing a
|
|
3399
|
+
* `BrowserError` on an empty chord or an unsupported modifier.
|
|
2660
3400
|
*
|
|
2661
|
-
* @param
|
|
2662
|
-
* @
|
|
2663
|
-
* @
|
|
3401
|
+
* @param value - Chord source
|
|
3402
|
+
* @returns Canonical modifiers and terminal key
|
|
3403
|
+
* @throws Thrown when the chord is empty or names an unsupported modifier.
|
|
2664
3404
|
*/
|
|
2665
|
-
export declare function
|
|
3405
|
+
export declare function extractBrowserChord(value: string): BrowserChord;
|
|
2666
3406
|
|
|
2667
3407
|
/**
|
|
2668
|
-
*
|
|
3408
|
+
* Narrows an unknown value to a `BrowserError`.
|
|
2669
3409
|
*
|
|
2670
3410
|
* @param value - Value to check
|
|
2671
|
-
* @returns True
|
|
3411
|
+
* @returns True if value is a BrowserError instance; false otherwise
|
|
2672
3412
|
*/
|
|
2673
3413
|
export declare function isBrowserError(value: unknown): value is BrowserError;
|
|
2674
3414
|
|
|
2675
3415
|
/**
|
|
2676
|
-
*
|
|
3416
|
+
* Tests whether a browser-node matcher is a declarative query rather than a predicate.
|
|
2677
3417
|
*
|
|
2678
3418
|
* @param value - Browser-node query or predicate
|
|
2679
|
-
* @returns
|
|
3419
|
+
* @returns True if the matcher is a declarative query; false otherwise
|
|
2680
3420
|
*
|
|
2681
3421
|
* @example
|
|
2682
3422
|
* ```ts
|
|
2683
|
-
* import { isBrowserNodeQuery } from '@
|
|
3423
|
+
* import { isBrowserNodeQuery } from '@orkestrel/browser'
|
|
2684
3424
|
*
|
|
2685
3425
|
* isBrowserNodeQuery({ name: 'main' }) // true
|
|
2686
3426
|
* isBrowserNodeQuery(() => true) // false
|
|
@@ -2689,55 +3429,55 @@ export declare function isBrowserError(value: unknown): value is BrowserError;
|
|
|
2689
3429
|
export declare function isBrowserNodeQuery(value: BrowserNodeQuery | BrowserNodePredicate): value is BrowserNodeQuery;
|
|
2690
3430
|
|
|
2691
3431
|
/**
|
|
2692
|
-
*
|
|
3432
|
+
* Tests whether a captured node has a non-empty rendered layout box.
|
|
2693
3433
|
*
|
|
2694
3434
|
* @param node - Captured browser node
|
|
2695
|
-
* @returns
|
|
3435
|
+
* @returns True if the snapshot reports a visible layout box; false otherwise
|
|
2696
3436
|
*/
|
|
2697
3437
|
export declare function isBrowserNodeVisible(node: BrowserNode): boolean;
|
|
2698
3438
|
|
|
2699
3439
|
/**
|
|
2700
|
-
*
|
|
3440
|
+
* Narrows an unknown value to a `BrowserResultLimitError`.
|
|
2701
3441
|
*
|
|
2702
3442
|
* @param value - Value to check
|
|
2703
|
-
* @returns True
|
|
3443
|
+
* @returns True if value is a BrowserResultLimitError instance; false otherwise
|
|
2704
3444
|
*/
|
|
2705
3445
|
export declare function isBrowserResultLimitError(value: unknown): value is BrowserResultLimitError;
|
|
2706
3446
|
|
|
2707
3447
|
/**
|
|
2708
|
-
*
|
|
3448
|
+
* Narrows an unknown value to a `BrowserSelectorError`.
|
|
2709
3449
|
*
|
|
2710
3450
|
* @param value - Value to check
|
|
2711
|
-
* @returns True
|
|
3451
|
+
* @returns True if value is a BrowserSelectorError instance; false otherwise
|
|
2712
3452
|
*/
|
|
2713
3453
|
export declare function isBrowserSelectorError(value: unknown): value is BrowserSelectorError;
|
|
2714
3454
|
|
|
2715
3455
|
/**
|
|
2716
|
-
*
|
|
3456
|
+
* Narrows an unknown value to a `CDPConnectionError`.
|
|
2717
3457
|
*
|
|
2718
3458
|
* @param value - Value to check
|
|
2719
|
-
* @returns True
|
|
3459
|
+
* @returns True if value is a CDPConnectionError instance; false otherwise
|
|
2720
3460
|
*/
|
|
2721
3461
|
export declare function isCDPConnectionError(value: unknown): value is CDPConnectionError;
|
|
2722
3462
|
|
|
2723
3463
|
/**
|
|
2724
|
-
*
|
|
3464
|
+
* Narrows an unknown value to a `CDPError`.
|
|
2725
3465
|
*
|
|
2726
3466
|
* @param value - Value to check
|
|
2727
|
-
* @returns True
|
|
3467
|
+
* @returns True if value is a CDPError instance; false otherwise
|
|
2728
3468
|
*/
|
|
2729
3469
|
export declare function isCDPError(value: unknown): value is CDPError;
|
|
2730
3470
|
|
|
2731
3471
|
/**
|
|
2732
|
-
*
|
|
3472
|
+
* Narrows an unknown value to a `CDPTimeoutError`.
|
|
2733
3473
|
*
|
|
2734
3474
|
* @param value - Value to check
|
|
2735
|
-
* @returns True
|
|
3475
|
+
* @returns True if value is a CDPTimeoutError instance; false otherwise
|
|
2736
3476
|
*/
|
|
2737
3477
|
export declare function isCDPTimeoutError(value: unknown): value is CDPTimeoutError;
|
|
2738
3478
|
|
|
2739
3479
|
/**
|
|
2740
|
-
*
|
|
3480
|
+
* Normalizes one key to CDP keyboard event data.
|
|
2741
3481
|
*
|
|
2742
3482
|
* @param value - Key value or canonical key name
|
|
2743
3483
|
* @returns Normalized key data
|
|
@@ -2745,43 +3485,43 @@ export declare function isCDPTimeoutError(value: unknown): value is CDPTimeoutEr
|
|
|
2745
3485
|
export declare function keyToBrowserInput(value: string): BrowserKey;
|
|
2746
3486
|
|
|
2747
3487
|
/**
|
|
2748
|
-
*
|
|
3488
|
+
* Matches a decoded cookie against one request URL.
|
|
2749
3489
|
*
|
|
2750
3490
|
* @param cookie - Decoded context cookie
|
|
2751
3491
|
* @param value - Candidate absolute URL
|
|
2752
|
-
* @returns
|
|
3492
|
+
* @returns True if domain, path, and secure constraints match; false otherwise
|
|
2753
3493
|
*/
|
|
2754
3494
|
export declare function matchesBrowserCookieURL(cookie: BrowserCookie, value: string): boolean;
|
|
2755
3495
|
|
|
2756
3496
|
/**
|
|
2757
|
-
*
|
|
3497
|
+
* Tests a captured node against a declarative query.
|
|
2758
3498
|
*
|
|
2759
3499
|
* @param node - Captured browser node
|
|
2760
3500
|
* @param query - Fields every candidate must satisfy
|
|
2761
|
-
* @returns
|
|
3501
|
+
* @returns True if the node matches; false otherwise
|
|
2762
3502
|
*/
|
|
2763
3503
|
export declare function matchesBrowserNode(node: BrowserNode, query: BrowserNodeQuery): boolean;
|
|
2764
3504
|
|
|
2765
3505
|
/**
|
|
2766
|
-
*
|
|
3506
|
+
* Matches a request against route criteria.
|
|
2767
3507
|
*
|
|
2768
3508
|
* @param request - Observed request
|
|
2769
3509
|
* @param query - Match criteria
|
|
2770
|
-
* @returns
|
|
3510
|
+
* @returns True if every supplied criterion matches; false otherwise
|
|
2771
3511
|
*/
|
|
2772
3512
|
export declare function matchesBrowserRoute(request: BrowserRequest, query: BrowserRouteQuery): boolean;
|
|
2773
3513
|
|
|
2774
3514
|
/**
|
|
2775
|
-
*
|
|
3515
|
+
* Matches a URL using Chromium-style `*` and `**` glob segments.
|
|
2776
3516
|
*
|
|
2777
3517
|
* @param url - Candidate URL
|
|
2778
3518
|
* @param pattern - Glob pattern
|
|
2779
|
-
* @returns
|
|
3519
|
+
* @returns True if the whole URL matches; false otherwise
|
|
2780
3520
|
*/
|
|
2781
3521
|
export declare function matchesBrowserURL(url: string, pattern: string): boolean;
|
|
2782
3522
|
|
|
2783
3523
|
/**
|
|
2784
|
-
*
|
|
3524
|
+
* Converts typed media preferences to Chromium emulated media features.
|
|
2785
3525
|
*
|
|
2786
3526
|
* @param media - Public media configuration
|
|
2787
3527
|
* @returns Protocol feature records
|
|
@@ -2789,13 +3529,12 @@ export declare function matchesBrowserURL(url: string, pattern: string): boolean
|
|
|
2789
3529
|
export declare function mediaToFeatures(media: BrowserMedia): ReadonlyArray<Readonly<Record<string, string>>>;
|
|
2790
3530
|
|
|
2791
3531
|
/**
|
|
2792
|
-
*
|
|
3532
|
+
* Normalizes recorded codegen actions, collapsing consecutive `fill` actions on the same
|
|
3533
|
+
* selector into the latest value.
|
|
2793
3534
|
*
|
|
2794
3535
|
* @remarks
|
|
2795
|
-
*
|
|
2796
|
-
*
|
|
2797
|
-
* compiled script reflects the final typed value rather than every
|
|
2798
|
-
* intermediate keystroke.
|
|
3536
|
+
* A text input fires one `input` event per keystroke, so the compiled script reflects
|
|
3537
|
+
* the final typed value rather than every intermediate keystroke.
|
|
2799
3538
|
*
|
|
2800
3539
|
* @param actions - Raw recorded actions, in capture order
|
|
2801
3540
|
* @returns Normalized actions, in the same order
|
|
@@ -2803,15 +3542,157 @@ export declare function mediaToFeatures(media: BrowserMedia): ReadonlyArray<Read
|
|
|
2803
3542
|
export declare function normalizeCodegenActions(actions: readonly BrowserCodegenAction[]): readonly BrowserCodegenAction[];
|
|
2804
3543
|
|
|
2805
3544
|
/**
|
|
2806
|
-
*
|
|
3545
|
+
* Coerces a string-valued Accessibility-domain AXValue to a string, or
|
|
3546
|
+
* `undefined` off-shape.
|
|
2807
3547
|
*
|
|
2808
|
-
* @param value -
|
|
2809
|
-
* @returns
|
|
3548
|
+
* @param value - Unknown AX value
|
|
3549
|
+
* @returns String or undefined
|
|
3550
|
+
*/
|
|
3551
|
+
export declare function parseBrowserAXString(value: unknown): string | undefined;
|
|
3552
|
+
|
|
3553
|
+
/**
|
|
3554
|
+
* Coerces one Runtime binding invocation to a `BrowserBindingCall`, or
|
|
3555
|
+
* `undefined` off-shape.
|
|
3556
|
+
*
|
|
3557
|
+
* @param value - Unknown `Runtime.bindingCalled` parameters
|
|
3558
|
+
* @returns Valid call or undefined
|
|
3559
|
+
*/
|
|
3560
|
+
export declare function parseBrowserBindingCall(value: unknown): BrowserBindingCall | undefined;
|
|
3561
|
+
|
|
3562
|
+
/**
|
|
3563
|
+
* Coerces one `Runtime.consoleAPICalled` event to a `BrowserConsoleMessage`, or
|
|
3564
|
+
* `undefined` off-shape.
|
|
3565
|
+
*
|
|
3566
|
+
* @param value - Unknown event parameters
|
|
3567
|
+
* @returns Console message or undefined
|
|
3568
|
+
*/
|
|
3569
|
+
export declare function parseBrowserConsoleMessage(value: unknown): BrowserConsoleMessage | undefined;
|
|
3570
|
+
|
|
3571
|
+
/**
|
|
3572
|
+
* Coerces an optional Chromium cookie partition key to a
|
|
3573
|
+
* `BrowserCookiePartition`, or `undefined` off-shape.
|
|
3574
|
+
*
|
|
3575
|
+
* @param value - Unknown partition value
|
|
3576
|
+
* @returns Partition key or undefined
|
|
3577
|
+
*/
|
|
3578
|
+
export declare function parseBrowserCookiePartition(value: unknown): BrowserCookiePartition | undefined;
|
|
3579
|
+
|
|
3580
|
+
/**
|
|
3581
|
+
* Coerces one `Browser.downloadProgress` event to a `BrowserDownloadProgress`,
|
|
3582
|
+
* or `undefined` off-shape.
|
|
3583
|
+
*
|
|
3584
|
+
* @param value - Unknown event parameters
|
|
3585
|
+
* @returns Download id and progress, or undefined
|
|
3586
|
+
*/
|
|
3587
|
+
export declare function parseBrowserDownloadProgress(value: unknown): readonly [id: string, progress: BrowserDownloadProgress] | undefined;
|
|
3588
|
+
|
|
3589
|
+
/**
|
|
3590
|
+
* Coerces one `Browser.downloadWillBegin` event to a `BrowserDownloadStart`, or
|
|
3591
|
+
* `undefined` off-shape.
|
|
3592
|
+
*
|
|
3593
|
+
* @param value - Unknown event parameters
|
|
3594
|
+
* @returns Download start or undefined
|
|
3595
|
+
*/
|
|
3596
|
+
export declare function parseBrowserDownloadStart(value: unknown): BrowserDownloadStart | undefined;
|
|
3597
|
+
|
|
3598
|
+
/**
|
|
3599
|
+
* Coerces one `Runtime.exceptionThrown` event to a `BrowserPageError`, or
|
|
3600
|
+
* `undefined` off-shape.
|
|
3601
|
+
*
|
|
3602
|
+
* @param value - Unknown event parameters
|
|
3603
|
+
* @returns Page error or undefined
|
|
3604
|
+
*/
|
|
3605
|
+
export declare function parseBrowserPageError(value: unknown): BrowserPageError | undefined;
|
|
3606
|
+
|
|
3607
|
+
/**
|
|
3608
|
+
* Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.
|
|
3609
|
+
*
|
|
3610
|
+
* @param value - Candidate four-number array
|
|
3611
|
+
* @returns A rectangle, or undefined
|
|
3612
|
+
*/
|
|
3613
|
+
export declare function parseBrowserRect(value: unknown): BrowserRect | undefined;
|
|
3614
|
+
|
|
3615
|
+
/**
|
|
3616
|
+
* Coerces one `Network.requestWillBeSent` or `Fetch.requestPaused` event to a
|
|
3617
|
+
* `BrowserRequest`, or `undefined` off-shape.
|
|
3618
|
+
*
|
|
3619
|
+
* @param value - Unknown event parameters
|
|
3620
|
+
* @returns Request or undefined
|
|
3621
|
+
*/
|
|
3622
|
+
export declare function parseBrowserRequest(value: unknown): BrowserRequest | undefined;
|
|
3623
|
+
|
|
3624
|
+
/**
|
|
3625
|
+
* Coerces one `Network.loadingFailed` event to a `BrowserRequestFailure`, or
|
|
3626
|
+
* `undefined` off-shape.
|
|
3627
|
+
*
|
|
3628
|
+
* @param value - Unknown event parameters
|
|
3629
|
+
* @returns Failure or undefined
|
|
3630
|
+
*/
|
|
3631
|
+
export declare function parseBrowserRequestFailure(value: unknown): BrowserRequestFailure | undefined;
|
|
3632
|
+
|
|
3633
|
+
/**
|
|
3634
|
+
* Coerces one `Network.responseReceived` event to a `BrowserResponse`, or
|
|
3635
|
+
* `undefined` off-shape.
|
|
3636
|
+
*
|
|
3637
|
+
* @param value - Unknown event parameters
|
|
3638
|
+
* @returns Response or undefined
|
|
3639
|
+
*/
|
|
3640
|
+
export declare function parseBrowserResponse(value: unknown): BrowserResponse | undefined;
|
|
3641
|
+
|
|
3642
|
+
/**
|
|
3643
|
+
* Coerces one Chromium response object plus its event identity to a
|
|
3644
|
+
* `BrowserResponse`, or `undefined` off-shape.
|
|
3645
|
+
*
|
|
3646
|
+
* @param value - Unknown response object
|
|
3647
|
+
* @param id - Request id
|
|
3648
|
+
* @param loader - Loader id
|
|
3649
|
+
* @param frame - Optional frame id
|
|
3650
|
+
* @param timestamp - Monotonic event timestamp
|
|
3651
|
+
* @returns Response or undefined
|
|
3652
|
+
*/
|
|
3653
|
+
export declare function parseBrowserResponseRecord(value: unknown, id: string, loader: string, frame: string | undefined, timestamp: number): BrowserResponse | undefined;
|
|
3654
|
+
|
|
3655
|
+
/**
|
|
3656
|
+
* Coerces Chromium TLS security details to a `BrowserSecurity`, or `undefined`
|
|
3657
|
+
* off-shape.
|
|
3658
|
+
*
|
|
3659
|
+
* @param value - Unknown security details
|
|
3660
|
+
* @returns Security metadata or undefined
|
|
3661
|
+
*/
|
|
3662
|
+
export declare function parseBrowserSecurity(value: unknown): BrowserSecurity | undefined;
|
|
3663
|
+
|
|
3664
|
+
/**
|
|
3665
|
+
* Coerces Chromium response timing to a `BrowserTiming`, or `undefined`
|
|
3666
|
+
* off-shape.
|
|
3667
|
+
*
|
|
3668
|
+
* @param value - Unknown timing object
|
|
3669
|
+
* @returns Timing or undefined
|
|
3670
|
+
*/
|
|
3671
|
+
export declare function parseBrowserTiming(value: unknown): BrowserTiming | undefined;
|
|
3672
|
+
|
|
3673
|
+
/**
|
|
3674
|
+
* Coerces one named start/end pair of Chromium network timing to a
|
|
3675
|
+
* `BrowserTimingRange`, or `undefined` off-shape.
|
|
3676
|
+
*
|
|
3677
|
+
* @param value - Unknown timing object
|
|
3678
|
+
* @param start - Start field
|
|
3679
|
+
* @param end - End field
|
|
3680
|
+
* @returns Timing range or undefined
|
|
3681
|
+
*/
|
|
3682
|
+
export declare function parseBrowserTimingRange(value: unknown, start: string, end: string): BrowserTimingRange | undefined;
|
|
3683
|
+
|
|
3684
|
+
/**
|
|
3685
|
+
* Coerces one WebSocket frame event to a `BrowserWebSocketFrame`, or
|
|
3686
|
+
* `undefined` off-shape.
|
|
3687
|
+
*
|
|
3688
|
+
* @param value - Unknown event parameters
|
|
3689
|
+
* @returns Frame or undefined
|
|
2810
3690
|
*/
|
|
2811
|
-
export declare function
|
|
3691
|
+
export declare function parseBrowserWebSocketFrame(value: unknown): BrowserWebSocketFrame | undefined;
|
|
2812
3692
|
|
|
2813
3693
|
/**
|
|
2814
|
-
*
|
|
3694
|
+
* Coerces a codegen binding payload string to a `BrowserCodegenAction`, or
|
|
3695
|
+
* `undefined` off-shape.
|
|
2815
3696
|
*
|
|
2816
3697
|
* @remarks
|
|
2817
3698
|
* The in-page recorder script calls the CDP binding with a JSON string
|
|
@@ -2824,64 +3705,74 @@ export declare function parseBrowserChord(value: string): BrowserChord;
|
|
|
2824
3705
|
export declare function parseCodegenActionPayload(payload: unknown): BrowserCodegenAction | undefined;
|
|
2825
3706
|
|
|
2826
3707
|
/**
|
|
2827
|
-
*
|
|
3708
|
+
* Coerces a `Page.frameNavigated` CDP event to a `navigate` codegen action, or `undefined`
|
|
3709
|
+
* off-shape and for every frame but the top-level one.
|
|
2828
3710
|
*
|
|
2829
|
-
* @
|
|
2830
|
-
*
|
|
3711
|
+
* @remarks
|
|
3712
|
+
* Only the top-level (main) frame's navigation is recorded — a frame
|
|
3713
|
+
* carrying a `parentId` is a sub-frame and is ignored.
|
|
3714
|
+
*
|
|
3715
|
+
* @param params - The CDP `Page.frameNavigated` event params
|
|
3716
|
+
* @returns A `navigate` action, or `undefined` when the event is not a
|
|
3717
|
+
* top-level navigation with a resolvable URL
|
|
2831
3718
|
*/
|
|
2832
|
-
export declare function
|
|
3719
|
+
export declare function parseCodegenNavigateAction(params: Readonly<Record<string, unknown>>): BrowserCodegenAction | undefined;
|
|
2833
3720
|
|
|
2834
3721
|
/**
|
|
2835
|
-
*
|
|
3722
|
+
* Coerces an unknown value to an all-number array, or `undefined` off-shape.
|
|
2836
3723
|
*
|
|
2837
|
-
* @param value -
|
|
2838
|
-
* @returns
|
|
3724
|
+
* @param value - Candidate value
|
|
3725
|
+
* @returns The number array, or undefined
|
|
2839
3726
|
*/
|
|
2840
|
-
export declare function
|
|
3727
|
+
export declare function parseNumberArray(value: unknown): readonly number[] | undefined;
|
|
2841
3728
|
|
|
2842
3729
|
/**
|
|
2843
|
-
*
|
|
3730
|
+
* Coerces one CDP snapshot string-table index to its string, or `undefined`
|
|
3731
|
+
* off-shape.
|
|
2844
3732
|
*
|
|
2845
|
-
* @param
|
|
2846
|
-
* @
|
|
3733
|
+
* @param strings - Snapshot string table
|
|
3734
|
+
* @param index - Candidate string index
|
|
3735
|
+
* @returns The resolved string, or undefined
|
|
2847
3736
|
*/
|
|
2848
|
-
export declare function
|
|
3737
|
+
export declare function parseSnapshotString(strings: readonly string[], index: unknown): string | undefined;
|
|
2849
3738
|
|
|
2850
3739
|
/**
|
|
2851
|
-
*
|
|
3740
|
+
* Decodes Accessibility-domain nodes into a flat serializable tree, throwing a `BrowserError`
|
|
3741
|
+
* off-shape.
|
|
2852
3742
|
*
|
|
2853
|
-
* @param value - Unknown
|
|
2854
|
-
* @returns Valid
|
|
3743
|
+
* @param value - Unknown full or partial AX-tree result
|
|
3744
|
+
* @returns Valid accessibility snapshot
|
|
2855
3745
|
*/
|
|
2856
|
-
export declare function
|
|
3746
|
+
export declare function readBrowserAccessibility(value: unknown): BrowserAccessibilitySnapshot;
|
|
2857
3747
|
|
|
2858
3748
|
/**
|
|
2859
|
-
*
|
|
3749
|
+
* Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.
|
|
2860
3750
|
*
|
|
2861
|
-
* @param value -
|
|
2862
|
-
* @
|
|
3751
|
+
* @param value - Candidate string-index array
|
|
3752
|
+
* @param strings - Snapshot string table
|
|
3753
|
+
* @returns Frozen attribute record
|
|
2863
3754
|
*/
|
|
2864
|
-
export declare function
|
|
3755
|
+
export declare function readBrowserAttributes(value: unknown, strings: readonly string[]): Readonly<Record<string, string>>;
|
|
2865
3756
|
|
|
2866
3757
|
/**
|
|
2867
|
-
*
|
|
3758
|
+
* Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.
|
|
2868
3759
|
*
|
|
2869
|
-
* @param value - Unknown
|
|
2870
|
-
* @
|
|
2871
|
-
* @returns Valid cookie
|
|
3760
|
+
* @param value - Unknown AX value
|
|
3761
|
+
* @returns Underlying value
|
|
2872
3762
|
*/
|
|
2873
|
-
export declare function
|
|
3763
|
+
export declare function readBrowserAXValue(value: unknown): unknown;
|
|
2874
3764
|
|
|
2875
3765
|
/**
|
|
2876
|
-
*
|
|
3766
|
+
* Decodes one Chromium cookie, throwing a `BrowserError` off-shape.
|
|
2877
3767
|
*
|
|
2878
|
-
* @param value - Unknown
|
|
2879
|
-
* @
|
|
3768
|
+
* @param value - Unknown cookie record
|
|
3769
|
+
* @param index - Source array position for diagnostics
|
|
3770
|
+
* @returns Valid cookie
|
|
2880
3771
|
*/
|
|
2881
|
-
export declare function
|
|
3772
|
+
export declare function readBrowserCookie(value: unknown, index: number): BrowserCookie;
|
|
2882
3773
|
|
|
2883
3774
|
/**
|
|
2884
|
-
*
|
|
3775
|
+
* Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.
|
|
2885
3776
|
*
|
|
2886
3777
|
* @param value - Unknown protocol result
|
|
2887
3778
|
* @returns Valid cookies
|
|
@@ -2889,7 +3780,7 @@ export declare function readBrowserCookiePartition(value: unknown): BrowserCooki
|
|
|
2889
3780
|
export declare function readBrowserCookies(value: unknown): readonly BrowserCookie[];
|
|
2890
3781
|
|
|
2891
3782
|
/**
|
|
2892
|
-
*
|
|
3783
|
+
* Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.
|
|
2893
3784
|
*
|
|
2894
3785
|
* @param value - Unknown ranges
|
|
2895
3786
|
* @param script - Script index for diagnostics
|
|
@@ -2898,23 +3789,8 @@ export declare function readBrowserCookies(value: unknown): readonly BrowserCook
|
|
|
2898
3789
|
export declare function readBrowserCoverageRanges(value: unknown, script: number): readonly BrowserCoverageRange[];
|
|
2899
3790
|
|
|
2900
3791
|
/**
|
|
2901
|
-
*
|
|
2902
|
-
*
|
|
2903
|
-
* @param value - Unknown event parameters
|
|
2904
|
-
* @returns Download id and progress, or undefined
|
|
2905
|
-
*/
|
|
2906
|
-
export declare function readBrowserDownloadProgress(value: unknown): readonly [id: string, progress: BrowserDownloadProgress] | undefined;
|
|
2907
|
-
|
|
2908
|
-
/**
|
|
2909
|
-
* Decode one `Browser.downloadWillBegin` event.
|
|
2910
|
-
*
|
|
2911
|
-
* @param value - Unknown event parameters
|
|
2912
|
-
* @returns Download start or undefined
|
|
2913
|
-
*/
|
|
2914
|
-
export declare function readBrowserDownloadStart(value: unknown): BrowserDownloadStart | undefined;
|
|
2915
|
-
|
|
2916
|
-
/**
|
|
2917
|
-
* Decode a flattened CDP `Page.getFrameTree` result.
|
|
3792
|
+
* Decodes a flattened CDP `Page.getFrameTree` result into depth-first frame metadata, skipping
|
|
3793
|
+
* every off-shape frame.
|
|
2918
3794
|
*
|
|
2919
3795
|
* @param value - Unknown CDP result
|
|
2920
3796
|
* @returns Frame metadata in depth-first, main-frame-first order
|
|
@@ -2922,7 +3798,8 @@ export declare function readBrowserDownloadStart(value: unknown): BrowserDownloa
|
|
|
2922
3798
|
export declare function readBrowserFrames(value: unknown): readonly BrowserFrameInfo[];
|
|
2923
3799
|
|
|
2924
3800
|
/**
|
|
2925
|
-
*
|
|
3801
|
+
* Decodes a Chromium Headers object into string values, skipping every entry that is neither a
|
|
3802
|
+
* string nor a finite number.
|
|
2926
3803
|
*
|
|
2927
3804
|
* @param value - Unknown headers
|
|
2928
3805
|
* @returns Frozen-compatible header record
|
|
@@ -2930,7 +3807,7 @@ export declare function readBrowserFrames(value: unknown): readonly BrowserFrame
|
|
|
2930
3807
|
export declare function readBrowserHeaders(value: unknown): Readonly<Record<string, string>>;
|
|
2931
3808
|
|
|
2932
3809
|
/**
|
|
2933
|
-
*
|
|
3810
|
+
* Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.
|
|
2934
3811
|
*
|
|
2935
3812
|
* @param value - Unknown metrics result
|
|
2936
3813
|
* @returns Valid metrics
|
|
@@ -2938,15 +3815,7 @@ export declare function readBrowserHeaders(value: unknown): Readonly<Record<stri
|
|
|
2938
3815
|
export declare function readBrowserMetrics(value: unknown): readonly BrowserMetric[];
|
|
2939
3816
|
|
|
2940
3817
|
/**
|
|
2941
|
-
*
|
|
2942
|
-
*
|
|
2943
|
-
* @param value - Unknown event parameters
|
|
2944
|
-
* @returns Page error or undefined
|
|
2945
|
-
*/
|
|
2946
|
-
export declare function readBrowserPageError(value: unknown): BrowserPageError | undefined;
|
|
2947
|
-
|
|
2948
|
-
/**
|
|
2949
|
-
* Decode one CPU profile.
|
|
3818
|
+
* Decodes one CPU profile, throwing a `BrowserError` off-shape.
|
|
2950
3819
|
*
|
|
2951
3820
|
* @param value - Unknown `Profiler.stop` result
|
|
2952
3821
|
* @returns Valid profile
|
|
@@ -2954,7 +3823,7 @@ export declare function readBrowserPageError(value: unknown): BrowserPageError |
|
|
|
2954
3823
|
export declare function readBrowserProfile(value: unknown): BrowserProfile;
|
|
2955
3824
|
|
|
2956
3825
|
/**
|
|
2957
|
-
*
|
|
3826
|
+
* Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.
|
|
2958
3827
|
*
|
|
2959
3828
|
* @param value - Unknown call frame
|
|
2960
3829
|
* @param node - Node index for diagnostics
|
|
@@ -2963,7 +3832,8 @@ export declare function readBrowserProfile(value: unknown): BrowserProfile;
|
|
|
2963
3832
|
export declare function readBrowserProfileFrame(value: unknown, node: number): BrowserProfileFrame;
|
|
2964
3833
|
|
|
2965
3834
|
/**
|
|
2966
|
-
*
|
|
3835
|
+
* Decodes the first `DOM.getContentQuads` quad and its center, throwing a `BrowserError`
|
|
3836
|
+
* off-shape.
|
|
2967
3837
|
*
|
|
2968
3838
|
* @param value - Unknown CDP result
|
|
2969
3839
|
* @returns Decoded quad
|
|
@@ -2971,15 +3841,8 @@ export declare function readBrowserProfileFrame(value: unknown, node: number): B
|
|
|
2971
3841
|
export declare function readBrowserQuad(value: unknown): BrowserQuad;
|
|
2972
3842
|
|
|
2973
3843
|
/**
|
|
2974
|
-
*
|
|
2975
|
-
*
|
|
2976
|
-
* @param value - Candidate four-number array
|
|
2977
|
-
* @returns A rectangle, or undefined
|
|
2978
|
-
*/
|
|
2979
|
-
export declare function readBrowserRect(value: unknown): BrowserRect | undefined;
|
|
2980
|
-
|
|
2981
|
-
/**
|
|
2982
|
-
* Decode a Runtime remote object's printable value.
|
|
3844
|
+
* Decodes a Runtime remote object's printable value, falling back to its unserializable form
|
|
3845
|
+
* and then its description, or `undefined` when it carries none.
|
|
2983
3846
|
*
|
|
2984
3847
|
* @param value - Unknown remote object
|
|
2985
3848
|
* @returns By-value data or a description
|
|
@@ -2987,43 +3850,7 @@ export declare function readBrowserRect(value: unknown): BrowserRect | undefined
|
|
|
2987
3850
|
export declare function readBrowserRemoteValue(value: unknown): unknown;
|
|
2988
3851
|
|
|
2989
3852
|
/**
|
|
2990
|
-
*
|
|
2991
|
-
*
|
|
2992
|
-
* @param value - Unknown event parameters
|
|
2993
|
-
* @returns Request or undefined
|
|
2994
|
-
*/
|
|
2995
|
-
export declare function readBrowserRequest(value: unknown): BrowserRequest | undefined;
|
|
2996
|
-
|
|
2997
|
-
/**
|
|
2998
|
-
* Decode one `Network.loadingFailed` event.
|
|
2999
|
-
*
|
|
3000
|
-
* @param value - Unknown event parameters
|
|
3001
|
-
* @returns Failure or undefined
|
|
3002
|
-
*/
|
|
3003
|
-
export declare function readBrowserRequestFailure(value: unknown): BrowserRequestFailure | undefined;
|
|
3004
|
-
|
|
3005
|
-
/**
|
|
3006
|
-
* Decode one `Network.responseReceived` event.
|
|
3007
|
-
*
|
|
3008
|
-
* @param value - Unknown event parameters
|
|
3009
|
-
* @returns Response or undefined
|
|
3010
|
-
*/
|
|
3011
|
-
export declare function readBrowserResponse(value: unknown): BrowserResponse | undefined;
|
|
3012
|
-
|
|
3013
|
-
/**
|
|
3014
|
-
* Decode one Chromium response object with its event identity.
|
|
3015
|
-
*
|
|
3016
|
-
* @param value - Unknown response object
|
|
3017
|
-
* @param id - Request id
|
|
3018
|
-
* @param loader - Loader id
|
|
3019
|
-
* @param frame - Optional frame id
|
|
3020
|
-
* @param timestamp - Monotonic event timestamp
|
|
3021
|
-
* @returns Response or undefined
|
|
3022
|
-
*/
|
|
3023
|
-
export declare function readBrowserResponseRecord(value: unknown, id: string, loader: string, frame: string | undefined, timestamp: number): BrowserResponse | undefined;
|
|
3024
|
-
|
|
3025
|
-
/**
|
|
3026
|
-
* Decode JavaScript precise coverage.
|
|
3853
|
+
* Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.
|
|
3027
3854
|
*
|
|
3028
3855
|
* @param value - Unknown `Profiler.takePreciseCoverage` result
|
|
3029
3856
|
* @returns Script coverage
|
|
@@ -3031,7 +3858,8 @@ export declare function readBrowserResponseRecord(value: unknown, id: string, lo
|
|
|
3031
3858
|
export declare function readBrowserScriptCoverage(value: unknown): readonly BrowserScriptCoverage[];
|
|
3032
3859
|
|
|
3033
3860
|
/**
|
|
3034
|
-
*
|
|
3861
|
+
* Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`
|
|
3862
|
+
* off-shape.
|
|
3035
3863
|
*
|
|
3036
3864
|
* @param value - Unknown protocol result
|
|
3037
3865
|
* @returns Script identifier
|
|
@@ -3039,15 +3867,19 @@ export declare function readBrowserScriptCoverage(value: unknown): readonly Brow
|
|
|
3039
3867
|
export declare function readBrowserScriptIdentifier(value: unknown): string;
|
|
3040
3868
|
|
|
3041
3869
|
/**
|
|
3042
|
-
*
|
|
3870
|
+
* Decodes a CDP `DOMSnapshot.captureSnapshot` result into a serializable
|
|
3871
|
+
* `BrowserSnapshotInput`, throwing a `BrowserError` off-shape and a `BrowserResultLimitError`
|
|
3872
|
+
* past the configured node limit.
|
|
3043
3873
|
*
|
|
3044
|
-
* @param value - Unknown
|
|
3045
|
-
* @
|
|
3874
|
+
* @param value - Unknown CDP result
|
|
3875
|
+
* @param styles - Requested computed-style names, in protocol order
|
|
3876
|
+
* @param limit - Maximum accepted node count
|
|
3877
|
+
* @returns A typed serializable browser snapshot
|
|
3046
3878
|
*/
|
|
3047
|
-
export declare function
|
|
3879
|
+
export declare function readBrowserSnapshot(value: unknown, styles?: readonly string[], limit?: number): BrowserSnapshotInput;
|
|
3048
3880
|
|
|
3049
3881
|
/**
|
|
3050
|
-
*
|
|
3882
|
+
* Decodes a Chromium runtime stack trace, skipping every off-shape call frame.
|
|
3051
3883
|
*
|
|
3052
3884
|
* @param value - Unknown stack trace or call-frame list
|
|
3053
3885
|
* @returns Valid stack frames
|
|
@@ -3055,7 +3887,7 @@ export declare function readBrowserSecurity(value: unknown): BrowserSecurity | u
|
|
|
3055
3887
|
export declare function readBrowserStack(value: unknown): readonly BrowserStackFrame[];
|
|
3056
3888
|
|
|
3057
3889
|
/**
|
|
3058
|
-
*
|
|
3890
|
+
* Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.
|
|
3059
3891
|
*
|
|
3060
3892
|
* @param value - Unknown entry list
|
|
3061
3893
|
* @param origin - Origin used for diagnostics
|
|
@@ -3065,7 +3897,7 @@ export declare function readBrowserStack(value: unknown): readonly BrowserStackF
|
|
|
3065
3897
|
export declare function readBrowserStorageEntries(value: unknown, origin: string, storage: 'local' | 'session'): readonly BrowserStorageEntry[];
|
|
3066
3898
|
|
|
3067
3899
|
/**
|
|
3068
|
-
*
|
|
3900
|
+
* Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.
|
|
3069
3901
|
*
|
|
3070
3902
|
* @param value - Unknown evaluation result
|
|
3071
3903
|
* @param origin - Origin represented by the result
|
|
@@ -3074,7 +3906,7 @@ export declare function readBrowserStorageEntries(value: unknown, origin: string
|
|
|
3074
3906
|
export declare function readBrowserStorageOrigin(value: unknown, origin: string): BrowserStorageOrigin;
|
|
3075
3907
|
|
|
3076
3908
|
/**
|
|
3077
|
-
*
|
|
3909
|
+
* Decodes one `IO.read` response, throwing a `BrowserError` off-shape.
|
|
3078
3910
|
*
|
|
3079
3911
|
* @param value - Unknown protocol result
|
|
3080
3912
|
* @returns Valid stream chunk
|
|
@@ -3082,7 +3914,7 @@ export declare function readBrowserStorageOrigin(value: unknown, origin: string)
|
|
|
3082
3914
|
export declare function readBrowserStreamChunk(value: unknown): BrowserStreamChunk;
|
|
3083
3915
|
|
|
3084
3916
|
/**
|
|
3085
|
-
*
|
|
3917
|
+
* Decodes CSS rule usage, throwing a `BrowserError` off-shape.
|
|
3086
3918
|
*
|
|
3087
3919
|
* @param value - Unknown `CSS.stopRuleUsageTracking` result
|
|
3088
3920
|
* @returns Stylesheet coverage
|
|
@@ -3090,71 +3922,44 @@ export declare function readBrowserStreamChunk(value: unknown): BrowserStreamChu
|
|
|
3090
3922
|
export declare function readBrowserStyleCoverage(value: unknown): readonly BrowserStyleCoverage[];
|
|
3091
3923
|
|
|
3092
3924
|
/**
|
|
3093
|
-
*
|
|
3094
|
-
*
|
|
3095
|
-
* @param value - Unknown timing object
|
|
3096
|
-
* @returns Timing or undefined
|
|
3097
|
-
*/
|
|
3098
|
-
export declare function readBrowserTiming(value: unknown): BrowserTiming | undefined;
|
|
3099
|
-
|
|
3100
|
-
/**
|
|
3101
|
-
* Decode one start/end pair from Chromium network timing data.
|
|
3102
|
-
*
|
|
3103
|
-
* @param value - Unknown timing object
|
|
3104
|
-
* @param start - Start field
|
|
3105
|
-
* @param end - End field
|
|
3106
|
-
* @returns Timing range or undefined
|
|
3107
|
-
*/
|
|
3108
|
-
export declare function readBrowserTimingRange(value: unknown, start: string, end: string): BrowserTimingRange | undefined;
|
|
3109
|
-
|
|
3110
|
-
/**
|
|
3111
|
-
* Decode one WebSocket frame event.
|
|
3112
|
-
*
|
|
3113
|
-
* @param value - Unknown event parameters
|
|
3114
|
-
* @returns Frame or undefined
|
|
3115
|
-
*/
|
|
3116
|
-
export declare function readBrowserWebSocketFrame(value: unknown): BrowserWebSocketFrame | undefined;
|
|
3117
|
-
|
|
3118
|
-
/**
|
|
3119
|
-
* Derive a `navigate` codegen action from a `Page.frameNavigated` CDP event.
|
|
3120
|
-
*
|
|
3121
|
-
* @remarks
|
|
3122
|
-
* Only the top-level (main) frame's navigation is recorded — a frame
|
|
3123
|
-
* carrying a `parentId` is a sub-frame and is ignored.
|
|
3925
|
+
* Decodes one CDP `Runtime.evaluate` result, throwing a `BrowserError` on a failed evaluation
|
|
3926
|
+
* and a `BrowserResultLimitError` past the guarded result size.
|
|
3124
3927
|
*
|
|
3125
|
-
* @param
|
|
3126
|
-
* @returns
|
|
3127
|
-
* top-level navigation with a resolvable URL
|
|
3928
|
+
* @param value - Unknown CDP result
|
|
3929
|
+
* @returns The returned by-value payload, or undefined
|
|
3128
3930
|
*/
|
|
3129
|
-
export declare function
|
|
3931
|
+
export declare function readEvaluationResult(value: unknown): unknown;
|
|
3130
3932
|
|
|
3131
3933
|
/**
|
|
3132
|
-
*
|
|
3934
|
+
* Decodes CDP snapshot sparse boolean data into a set of node indexes, skipping every
|
|
3935
|
+
* off-shape entry.
|
|
3133
3936
|
*
|
|
3134
|
-
* @param value -
|
|
3135
|
-
* @returns
|
|
3937
|
+
* @param value - Sparse `{ index }` record
|
|
3938
|
+
* @returns Set of node indexes whose value is true
|
|
3136
3939
|
*/
|
|
3137
|
-
export declare function
|
|
3940
|
+
export declare function readRareBooleanData(value: unknown): ReadonlySet<number>;
|
|
3138
3941
|
|
|
3139
3942
|
/**
|
|
3140
|
-
*
|
|
3943
|
+
* Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape
|
|
3944
|
+
* entry.
|
|
3141
3945
|
*
|
|
3142
|
-
* @param value -
|
|
3143
|
-
* @returns
|
|
3946
|
+
* @param value - Sparse `{ index, value }` record
|
|
3947
|
+
* @returns Node-index to integer map
|
|
3144
3948
|
*/
|
|
3145
|
-
export declare function
|
|
3949
|
+
export declare function readRareIntegerData(value: unknown): ReadonlyMap<number, number>;
|
|
3146
3950
|
|
|
3147
3951
|
/**
|
|
3148
|
-
*
|
|
3952
|
+
* Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape
|
|
3953
|
+
* entry.
|
|
3149
3954
|
*
|
|
3955
|
+
* @param value - Sparse `{ index, value }` record
|
|
3150
3956
|
* @param strings - Snapshot string table
|
|
3151
|
-
* @
|
|
3152
|
-
* @returns The resolved string, or undefined
|
|
3957
|
+
* @returns Node-index to string map
|
|
3153
3958
|
*/
|
|
3154
|
-
export declare function
|
|
3959
|
+
export declare function readRareStringData(value: unknown, strings: readonly string[]): ReadonlyMap<number, string>;
|
|
3155
3960
|
|
|
3156
3961
|
/**
|
|
3157
|
-
*
|
|
3962
|
+
* Requires an evaluated browser value to be a string.
|
|
3158
3963
|
*
|
|
3159
3964
|
* @param value - Candidate evaluated value
|
|
3160
3965
|
* @param field - Human-readable field name used in the error
|
|
@@ -3163,64 +3968,85 @@ export declare function readSnapshotString(strings: readonly string[], index: un
|
|
|
3163
3968
|
export declare function requireBrowserString(value: unknown, field: string): string;
|
|
3164
3969
|
|
|
3165
3970
|
/**
|
|
3166
|
-
*
|
|
3971
|
+
* Awaits every teardown step in order and returns the first failure.
|
|
3167
3972
|
*
|
|
3168
3973
|
* @remarks
|
|
3169
|
-
*
|
|
3170
|
-
*
|
|
3171
|
-
*
|
|
3974
|
+
* A teardown runs every step even after one of them fails, so a later release
|
|
3975
|
+
* is never skipped by an earlier fault, and the failure the caller reports is
|
|
3976
|
+
* the first one. The failure is returned rather than thrown, so the caller
|
|
3977
|
+
* keeps the cleanup that must still run after the steps and decides where the
|
|
3978
|
+
* throw belongs. A step may throw any value, `undefined` and `null` included,
|
|
3979
|
+
* so the first throw is retained by a separate flag rather than by testing the
|
|
3980
|
+
* retained value.
|
|
3981
|
+
*
|
|
3982
|
+
* @param steps - The teardown steps, in the order they must run
|
|
3983
|
+
* @returns The value the first failing step threw, or undefined when no step threw
|
|
3984
|
+
*
|
|
3985
|
+
* @example
|
|
3986
|
+
* ```ts
|
|
3987
|
+
* import { settleBrowserTeardown } from '@orkestrel/browser'
|
|
3988
|
+
*
|
|
3989
|
+
* const failure = await settleBrowserTeardown(
|
|
3990
|
+
* () => client.close(),
|
|
3991
|
+
* () => transport.close(),
|
|
3992
|
+
* )
|
|
3993
|
+
* if (failure !== undefined) throw failure
|
|
3994
|
+
* ```
|
|
3172
3995
|
*/
|
|
3173
|
-
export declare
|
|
3174
|
-
write(path: string, data: Uint8Array): Promise<void>;
|
|
3175
|
-
}
|
|
3996
|
+
export declare function settleBrowserTeardown(...steps: readonly BrowserTeardownFunction[]): Promise<unknown>;
|
|
3176
3997
|
|
|
3177
|
-
/**
|
|
3998
|
+
/** Encodes UTF-8 text as bytes. */
|
|
3178
3999
|
export declare function textToBytes(value: string): Uint8Array;
|
|
3179
4000
|
|
|
3180
4001
|
/**
|
|
3181
|
-
*
|
|
4002
|
+
* Validates Accessibility-domain snapshot bounds.
|
|
3182
4003
|
*
|
|
3183
4004
|
* @param options - Public accessibility snapshot options
|
|
3184
4005
|
*/
|
|
3185
4006
|
export declare function validateBrowserAccessibilityOptions(options?: BrowserAccessibilityOptions): void;
|
|
3186
4007
|
|
|
3187
4008
|
/**
|
|
3188
|
-
*
|
|
3189
|
-
*
|
|
3190
|
-
* @param options - Candidate action options
|
|
3191
|
-
*/
|
|
3192
|
-
export declare function validateBrowserActionOptions(options?: BrowserActionOptions): void;
|
|
3193
|
-
|
|
3194
|
-
/**
|
|
3195
|
-
* Validate isolated-context options before creating remote state.
|
|
4009
|
+
* Validates isolated-context options before creating remote state.
|
|
3196
4010
|
*
|
|
3197
4011
|
* @param options - Public context configuration
|
|
3198
4012
|
*/
|
|
3199
4013
|
export declare function validateBrowserContextOptions(options?: BrowserContextOptions): void;
|
|
3200
4014
|
|
|
3201
4015
|
/**
|
|
3202
|
-
*
|
|
4016
|
+
* Validates context emulation boundaries before partial application.
|
|
3203
4017
|
*
|
|
3204
4018
|
* @param options - Public emulation configuration
|
|
3205
4019
|
*/
|
|
3206
4020
|
export declare function validateBrowserEmulationOptions(options: BrowserEmulationOptions): void;
|
|
3207
4021
|
|
|
3208
4022
|
/**
|
|
3209
|
-
*
|
|
4023
|
+
* Validates the HAR 1.2 fields required for deterministic replay.
|
|
3210
4024
|
*
|
|
3211
4025
|
* @param value - Candidate archive
|
|
3212
4026
|
*/
|
|
3213
4027
|
export declare function validateBrowserHAR(value: unknown): asserts value is BrowserHAR;
|
|
3214
4028
|
|
|
3215
4029
|
/**
|
|
3216
|
-
*
|
|
4030
|
+
* Validates the bounded delay, count, steps, and position of one trusted-input operation.
|
|
4031
|
+
*
|
|
4032
|
+
* @remarks
|
|
4033
|
+
* The parameter is `BrowserOperationOptions`, so one validator answers for a
|
|
4034
|
+
* locator click, a locator drag, a mouse click, a mouse drag, and keyboard
|
|
4035
|
+
* entry alike.
|
|
4036
|
+
*
|
|
4037
|
+
* @param options - Candidate input options
|
|
4038
|
+
*/
|
|
4039
|
+
export declare function validateBrowserInputOptions(options?: BrowserOperationOptions): void;
|
|
4040
|
+
|
|
4041
|
+
/**
|
|
4042
|
+
* Validates viewport input coordinates.
|
|
3217
4043
|
*
|
|
3218
4044
|
* @param point - Candidate point
|
|
3219
4045
|
*/
|
|
3220
4046
|
export declare function validateBrowserPoint(point: BrowserPoint): void;
|
|
3221
4047
|
|
|
3222
4048
|
/**
|
|
3223
|
-
*
|
|
4049
|
+
* Validates a finite numeric range.
|
|
3224
4050
|
*
|
|
3225
4051
|
* @param value - Candidate number
|
|
3226
4052
|
* @param field - Diagnostic field
|
|
@@ -3231,14 +4057,14 @@ export declare function validateBrowserPoint(point: BrowserPoint): void;
|
|
|
3231
4057
|
export declare function validateBrowserRange(value: number, field: string, minimum: number, maximum: number, inclusive?: boolean): void;
|
|
3232
4058
|
|
|
3233
4059
|
/**
|
|
3234
|
-
*
|
|
4060
|
+
* Validates a public browser timeout before protocol work begins.
|
|
3235
4061
|
*
|
|
3236
4062
|
* @param timeout - Timeout in milliseconds
|
|
3237
4063
|
*/
|
|
3238
4064
|
export declare function validateBrowserTimeout(timeout: number): void;
|
|
3239
4065
|
|
|
3240
4066
|
/**
|
|
3241
|
-
*
|
|
4067
|
+
* Validates Chromium viewport metrics.
|
|
3242
4068
|
*
|
|
3243
4069
|
* @param viewport - Public viewport configuration
|
|
3244
4070
|
*/
|