@opensteer/browser-core 0.7.0

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.
@@ -0,0 +1,1135 @@
1
+ declare const brandSymbol: unique symbol;
2
+ type Brand<Value, Name extends string> = Value & {
3
+ readonly [brandSymbol]: Name;
4
+ };
5
+ declare function brand<Value, Name extends string>(value: Value): Brand<Value, Name>;
6
+
7
+ type SessionRef = Brand<string, "SessionRef">;
8
+ type PageRef = Brand<string, "PageRef">;
9
+ type FrameRef = Brand<string, "FrameRef">;
10
+ type DocumentRef = Brand<string, "DocumentRef">;
11
+ type NodeRef = Brand<string, "NodeRef">;
12
+ type NetworkRequestId = Brand<string, "NetworkRequestId">;
13
+ type DownloadRef = Brand<string, "DownloadRef">;
14
+ type DialogRef = Brand<string, "DialogRef">;
15
+ type ChooserRef = Brand<string, "ChooserRef">;
16
+ type WorkerRef = Brand<string, "WorkerRef">;
17
+ type DocumentEpoch = Brand<number, "DocumentEpoch">;
18
+ interface NodeLocator {
19
+ readonly documentRef: DocumentRef;
20
+ readonly documentEpoch: DocumentEpoch;
21
+ readonly nodeRef: NodeRef;
22
+ }
23
+ declare function createSessionRef(value: string): SessionRef;
24
+ declare function createPageRef(value: string): PageRef;
25
+ declare function createFrameRef(value: string): FrameRef;
26
+ declare function createDocumentRef(value: string): DocumentRef;
27
+ declare function createNodeRef(value: string): NodeRef;
28
+ declare function createNetworkRequestId(value: string): NetworkRequestId;
29
+ declare function createDownloadRef(value: string): DownloadRef;
30
+ declare function createDialogRef(value: string): DialogRef;
31
+ declare function createChooserRef(value: string): ChooserRef;
32
+ declare function createWorkerRef(value: string): WorkerRef;
33
+ declare function isSessionRef(value: string): value is SessionRef;
34
+ declare function isPageRef(value: string): value is PageRef;
35
+ declare function isFrameRef(value: string): value is FrameRef;
36
+ declare function isDocumentRef(value: string): value is DocumentRef;
37
+ declare function isNodeRef(value: string): value is NodeRef;
38
+ declare function isNetworkRequestId(value: string): value is NetworkRequestId;
39
+ declare function isDownloadRef(value: string): value is DownloadRef;
40
+ declare function isDialogRef(value: string): value is DialogRef;
41
+ declare function isChooserRef(value: string): value is ChooserRef;
42
+ declare function isWorkerRef(value: string): value is WorkerRef;
43
+ declare function serializeRef(ref: SessionRef | PageRef | FrameRef | DocumentRef | NodeRef | NetworkRequestId | DownloadRef | DialogRef | ChooserRef | WorkerRef): string;
44
+ declare function createDocumentEpoch(value: number): DocumentEpoch;
45
+ declare function nextDocumentEpoch(epoch: DocumentEpoch): DocumentEpoch;
46
+ declare function serializeDocumentEpoch(epoch: DocumentEpoch): number;
47
+ declare function createNodeLocator(documentRef: DocumentRef, documentEpoch: DocumentEpoch, nodeRef: NodeRef): NodeLocator;
48
+
49
+ type PageLifecycleState = "opening" | "open" | "closing" | "closed" | "crashed";
50
+ interface PageInfo {
51
+ readonly pageRef: PageRef;
52
+ readonly sessionRef: SessionRef;
53
+ readonly openerPageRef?: PageRef;
54
+ readonly url: string;
55
+ readonly title: string;
56
+ readonly lifecycleState: PageLifecycleState;
57
+ }
58
+ interface FrameInfo {
59
+ readonly frameRef: FrameRef;
60
+ readonly pageRef: PageRef;
61
+ readonly parentFrameRef?: FrameRef;
62
+ readonly documentRef: DocumentRef;
63
+ readonly documentEpoch: DocumentEpoch;
64
+ readonly url: string;
65
+ readonly name?: string;
66
+ readonly isMainFrame: boolean;
67
+ }
68
+
69
+ interface Point {
70
+ readonly x: number;
71
+ readonly y: number;
72
+ }
73
+ interface Size {
74
+ readonly width: number;
75
+ readonly height: number;
76
+ }
77
+ interface Rect {
78
+ readonly x: number;
79
+ readonly y: number;
80
+ readonly width: number;
81
+ readonly height: number;
82
+ }
83
+ type Quad = readonly [Point, Point, Point, Point];
84
+ interface ScrollOffset {
85
+ readonly x: number;
86
+ readonly y: number;
87
+ }
88
+ type CoordinateSpace = "document-css" | "layout-viewport-css" | "visual-viewport-css" | "computer-display-css" | "window" | "screen" | "device-pixel";
89
+ interface LayoutViewport {
90
+ readonly origin: Point;
91
+ readonly size: Size;
92
+ }
93
+ interface VisualViewport {
94
+ readonly origin: Point;
95
+ readonly offsetWithinLayoutViewport: ScrollOffset;
96
+ readonly size: Size;
97
+ }
98
+ type DevicePixelRatio = Brand<number, "DevicePixelRatio">;
99
+ type PageScaleFactor = Brand<number, "PageScaleFactor">;
100
+ type PageZoomFactor = Brand<number, "PageZoomFactor">;
101
+ interface ViewportMetrics {
102
+ readonly layoutViewport: LayoutViewport;
103
+ readonly visualViewport: VisualViewport;
104
+ readonly scrollOffset: ScrollOffset;
105
+ readonly contentSize: Size;
106
+ readonly devicePixelRatio: DevicePixelRatio;
107
+ readonly pageScaleFactor: PageScaleFactor;
108
+ readonly pageZoomFactor: PageZoomFactor;
109
+ }
110
+ declare function createPoint(x: number, y: number): Point;
111
+ declare function createSize(width: number, height: number): Size;
112
+ declare function createRect(x: number, y: number, width: number, height: number): Rect;
113
+ declare function createScrollOffset(x: number, y: number): ScrollOffset;
114
+ declare function createQuad(points: readonly [Point, Point, Point, Point]): Quad;
115
+ declare function rectToQuad(rect: Rect): Quad;
116
+ declare function quadBounds(quad: Quad): Rect;
117
+ declare function rectContainsPoint(rect: Rect, point: Point): boolean;
118
+ declare function createDevicePixelRatio(value: number): DevicePixelRatio;
119
+ declare function createPageScaleFactor(value: number): PageScaleFactor;
120
+ declare function createPageZoomFactor(value: number): PageZoomFactor;
121
+
122
+ interface HeaderEntry {
123
+ readonly name: string;
124
+ readonly value: string;
125
+ }
126
+ type BodyPayloadEncoding = "identity" | "base64" | "gzip" | "deflate" | "brotli" | "unknown";
127
+ interface BodyPayload {
128
+ readonly bytes: Uint8Array;
129
+ readonly encoding: BodyPayloadEncoding;
130
+ readonly mimeType?: string;
131
+ readonly charset?: string;
132
+ readonly truncated: boolean;
133
+ readonly capturedByteLength: number;
134
+ readonly originalByteLength?: number;
135
+ }
136
+ type NetworkCaptureState = "pending" | "complete" | "failed" | "skipped";
137
+ type NetworkRecordKind = "http" | "websocket" | "event-stream";
138
+ type NetworkResourceType = "document" | "stylesheet" | "image" | "media" | "font" | "script" | "fetch" | "xhr" | "websocket" | "event-stream" | "manifest" | "texttrack" | "beacon" | "ping" | "preflight" | "other";
139
+ type NetworkInitiatorType = "parser" | "script" | "preload" | "redirect" | "user" | "service-worker" | "other";
140
+ interface NetworkInitiator {
141
+ readonly type: NetworkInitiatorType;
142
+ readonly url?: string;
143
+ readonly lineNumber?: number;
144
+ readonly columnNumber?: number;
145
+ readonly requestId?: NetworkRequestId;
146
+ readonly stackTrace?: readonly string[];
147
+ }
148
+ interface NetworkTiming {
149
+ readonly requestStartMs?: number;
150
+ readonly dnsStartMs?: number;
151
+ readonly dnsEndMs?: number;
152
+ readonly connectStartMs?: number;
153
+ readonly connectEndMs?: number;
154
+ readonly sslStartMs?: number;
155
+ readonly sslEndMs?: number;
156
+ readonly requestSentMs?: number;
157
+ readonly responseStartMs?: number;
158
+ readonly responseEndMs?: number;
159
+ readonly workerStartMs?: number;
160
+ readonly workerReadyMs?: number;
161
+ }
162
+ interface NetworkTransferSizes {
163
+ readonly requestHeadersBytes?: number;
164
+ readonly responseHeadersBytes?: number;
165
+ readonly encodedBodyBytes?: number;
166
+ readonly decodedBodyBytes?: number;
167
+ readonly transferSizeBytes?: number;
168
+ }
169
+ interface NetworkSourceMetadata {
170
+ readonly protocol?: string;
171
+ readonly remoteAddress?: {
172
+ readonly ip?: string;
173
+ readonly port?: number;
174
+ };
175
+ readonly fromServiceWorker?: boolean;
176
+ readonly fromDiskCache?: boolean;
177
+ readonly fromMemoryCache?: boolean;
178
+ readonly workerRef?: WorkerRef;
179
+ }
180
+ interface NetworkRecord {
181
+ readonly kind: NetworkRecordKind;
182
+ readonly requestId: NetworkRequestId;
183
+ readonly sessionRef: SessionRef;
184
+ readonly pageRef?: PageRef;
185
+ readonly frameRef?: FrameRef;
186
+ readonly documentRef?: DocumentRef;
187
+ readonly method: string;
188
+ readonly url: string;
189
+ readonly requestHeaders: readonly HeaderEntry[];
190
+ readonly responseHeaders: readonly HeaderEntry[];
191
+ readonly status?: number;
192
+ readonly statusText?: string;
193
+ readonly resourceType: NetworkResourceType;
194
+ readonly redirectFromRequestId?: NetworkRequestId;
195
+ readonly redirectToRequestId?: NetworkRequestId;
196
+ readonly navigationRequest: boolean;
197
+ readonly initiator?: NetworkInitiator;
198
+ readonly timing?: NetworkTiming;
199
+ readonly transfer?: NetworkTransferSizes;
200
+ readonly source?: NetworkSourceMetadata;
201
+ readonly captureState: NetworkCaptureState;
202
+ readonly requestBodyState: NetworkCaptureState;
203
+ readonly responseBodyState: NetworkCaptureState;
204
+ readonly requestBodySkipReason?: string;
205
+ readonly responseBodySkipReason?: string;
206
+ readonly requestBodyError?: string;
207
+ readonly responseBodyError?: string;
208
+ readonly requestBody?: BodyPayload;
209
+ readonly responseBody?: BodyPayload;
210
+ }
211
+ interface NetworkRecordFilterInput {
212
+ readonly url?: string;
213
+ readonly hostname?: string;
214
+ readonly path?: string;
215
+ readonly method?: string;
216
+ readonly status?: string;
217
+ readonly resourceType?: NetworkResourceType;
218
+ }
219
+ declare function createHeaderEntry(name: string, value: string): HeaderEntry;
220
+ declare function createBodyPayload(bytes: Uint8Array, options?: {
221
+ encoding?: BodyPayloadEncoding;
222
+ mimeType?: string;
223
+ charset?: string;
224
+ truncated?: boolean;
225
+ originalByteLength?: number;
226
+ }): BodyPayload;
227
+ declare function bodyPayloadFromUtf8(value: string, options?: {
228
+ mimeType?: string;
229
+ encoding?: BodyPayloadEncoding;
230
+ truncated?: boolean;
231
+ originalByteLength?: number;
232
+ }): BodyPayload;
233
+ declare function matchesNetworkRecordFilters(record: Pick<NetworkRecord, "url" | "method" | "status" | "resourceType">, filters: NetworkRecordFilterInput): boolean;
234
+
235
+ type ScreenshotFormat = "png" | "jpeg" | "webp";
236
+ interface ScreenshotArtifact {
237
+ readonly pageRef: PageRef;
238
+ readonly frameRef?: FrameRef;
239
+ readonly documentRef?: DocumentRef;
240
+ readonly documentEpoch?: DocumentEpoch;
241
+ readonly payload: BodyPayload;
242
+ readonly format: ScreenshotFormat;
243
+ readonly size: Size;
244
+ readonly coordinateSpace: CoordinateSpace;
245
+ readonly clip?: Rect;
246
+ }
247
+ interface HtmlSnapshot {
248
+ readonly pageRef: PageRef;
249
+ readonly frameRef: FrameRef;
250
+ readonly documentRef: DocumentRef;
251
+ readonly documentEpoch: DocumentEpoch;
252
+ readonly url: string;
253
+ readonly capturedAt: number;
254
+ readonly html: string;
255
+ }
256
+ interface DomSnapshotNode {
257
+ readonly snapshotNodeId: number;
258
+ readonly nodeRef?: NodeRef;
259
+ readonly parentSnapshotNodeId?: number;
260
+ readonly childSnapshotNodeIds: readonly number[];
261
+ readonly shadowRootType?: "open" | "closed" | "user-agent";
262
+ readonly shadowHostNodeRef?: NodeRef;
263
+ readonly contentDocumentRef?: DocumentRef;
264
+ readonly nodeType: number;
265
+ readonly nodeName: string;
266
+ readonly nodeValue: string;
267
+ readonly textContent?: string;
268
+ readonly computedStyle?: {
269
+ readonly display?: string;
270
+ readonly visibility?: string;
271
+ readonly opacity?: string;
272
+ readonly position?: string;
273
+ readonly cursor?: string;
274
+ readonly overflowX?: string;
275
+ readonly overflowY?: string;
276
+ };
277
+ readonly attributes: readonly {
278
+ readonly name: string;
279
+ readonly value: string;
280
+ }[];
281
+ readonly layout?: {
282
+ readonly rect?: Rect;
283
+ readonly quad?: Quad;
284
+ readonly paintOrder?: number;
285
+ };
286
+ }
287
+ type ShadowDomSnapshotMode = "flattened" | "preserved" | "unsupported";
288
+ interface DomSnapshot {
289
+ readonly pageRef: PageRef;
290
+ readonly frameRef: FrameRef;
291
+ readonly documentRef: DocumentRef;
292
+ readonly parentDocumentRef?: DocumentRef;
293
+ readonly documentEpoch: DocumentEpoch;
294
+ readonly url: string;
295
+ readonly capturedAt: number;
296
+ readonly rootSnapshotNodeId: number;
297
+ readonly shadowDomMode: ShadowDomSnapshotMode;
298
+ readonly geometryCoordinateSpace?: CoordinateSpace;
299
+ readonly nodes: readonly DomSnapshotNode[];
300
+ }
301
+ interface HitTestResult {
302
+ readonly inputPoint: Point;
303
+ readonly inputCoordinateSpace: CoordinateSpace;
304
+ readonly resolvedPoint: Point;
305
+ readonly resolvedCoordinateSpace: CoordinateSpace;
306
+ readonly pageRef: PageRef;
307
+ readonly frameRef: FrameRef;
308
+ readonly documentRef: DocumentRef;
309
+ readonly documentEpoch: DocumentEpoch;
310
+ readonly nodeRef?: NodeRef;
311
+ readonly targetQuad?: Quad;
312
+ readonly obscured: boolean;
313
+ readonly pointerEventsSkipped: boolean;
314
+ }
315
+ type VisualStabilityScope = "main-frame" | "visible-frames";
316
+ declare function findDomSnapshotNode(snapshot: DomSnapshot, snapshotNodeId: number): DomSnapshotNode | undefined;
317
+ declare function findDomSnapshotNodeByRef(snapshot: DomSnapshot, nodeRef: NodeRef): DomSnapshotNode | undefined;
318
+
319
+ type CookieSameSite = "strict" | "lax" | "none";
320
+ type CookiePriority = "low" | "medium" | "high";
321
+ interface CookieRecord {
322
+ readonly sessionRef: SessionRef;
323
+ readonly name: string;
324
+ readonly value: string;
325
+ readonly domain: string;
326
+ readonly path: string;
327
+ readonly secure: boolean;
328
+ readonly httpOnly: boolean;
329
+ readonly sameSite?: CookieSameSite;
330
+ readonly priority?: CookiePriority;
331
+ readonly partitionKey?: string;
332
+ readonly session: boolean;
333
+ readonly expiresAt?: number | null;
334
+ }
335
+ interface StorageEntry {
336
+ readonly key: string;
337
+ readonly value: string;
338
+ }
339
+ interface IndexedDbRecord {
340
+ readonly key: unknown;
341
+ readonly primaryKey?: unknown;
342
+ readonly value: unknown;
343
+ }
344
+ interface IndexedDbIndexSnapshot {
345
+ readonly name: string;
346
+ readonly keyPath?: string | readonly string[];
347
+ readonly multiEntry: boolean;
348
+ readonly unique: boolean;
349
+ }
350
+ interface IndexedDbObjectStoreSnapshot {
351
+ readonly name: string;
352
+ readonly keyPath?: string | readonly string[];
353
+ readonly autoIncrement: boolean;
354
+ readonly indexes: readonly IndexedDbIndexSnapshot[];
355
+ readonly records: readonly IndexedDbRecord[];
356
+ }
357
+ interface IndexedDbDatabaseSnapshot {
358
+ readonly name: string;
359
+ readonly version: number;
360
+ readonly objectStores: readonly IndexedDbObjectStoreSnapshot[];
361
+ }
362
+ interface StorageOriginSnapshot {
363
+ readonly origin: string;
364
+ readonly localStorage: readonly StorageEntry[];
365
+ readonly indexedDb?: readonly IndexedDbDatabaseSnapshot[];
366
+ }
367
+ interface SessionStorageSnapshot {
368
+ readonly pageRef: PageRef;
369
+ readonly frameRef: FrameRef;
370
+ readonly origin: string;
371
+ readonly entries: readonly StorageEntry[];
372
+ }
373
+ interface StorageSnapshot {
374
+ readonly sessionRef: SessionRef;
375
+ readonly capturedAt: number;
376
+ readonly origins: readonly StorageOriginSnapshot[];
377
+ readonly sessionStorage?: readonly SessionStorageSnapshot[];
378
+ }
379
+ declare function filterCookieRecords(cookies: readonly CookieRecord[], urls: readonly string[]): CookieRecord[];
380
+
381
+ interface BrowserCapabilities {
382
+ readonly executor: {
383
+ readonly sessionLifecycle: boolean;
384
+ readonly pageLifecycle: boolean;
385
+ readonly navigation: boolean;
386
+ readonly pointerInput: boolean;
387
+ readonly keyboardInput: boolean;
388
+ readonly touchInput: boolean;
389
+ readonly screenshots: boolean;
390
+ readonly executionControl: {
391
+ readonly pause: boolean;
392
+ readonly resume: boolean;
393
+ readonly freeze: boolean;
394
+ };
395
+ };
396
+ readonly inspector: {
397
+ readonly pageEnumeration: boolean;
398
+ readonly frameEnumeration: boolean;
399
+ readonly html: boolean;
400
+ readonly domSnapshot: boolean;
401
+ readonly visualStability: boolean;
402
+ readonly text: boolean;
403
+ readonly attributes: boolean;
404
+ readonly hitTest: boolean;
405
+ readonly viewportMetrics: boolean;
406
+ readonly network: boolean;
407
+ readonly networkBodies: boolean;
408
+ readonly cookies: boolean;
409
+ readonly localStorage: boolean;
410
+ readonly sessionStorage: boolean;
411
+ readonly indexedDb: boolean;
412
+ };
413
+ readonly transport: {
414
+ readonly sessionHttp: boolean;
415
+ };
416
+ readonly instrumentation: {
417
+ readonly initScripts: boolean;
418
+ readonly routing: boolean;
419
+ };
420
+ readonly events: {
421
+ readonly pageLifecycle: boolean;
422
+ readonly dialog: boolean;
423
+ readonly download: boolean;
424
+ readonly chooser: boolean;
425
+ readonly worker: boolean;
426
+ readonly console: boolean;
427
+ readonly pageError: boolean;
428
+ readonly websocket: boolean;
429
+ readonly eventStream: boolean;
430
+ readonly executionState: boolean;
431
+ };
432
+ }
433
+ type BrowserCapabilityPath = "executor.sessionLifecycle" | "executor.pageLifecycle" | "executor.navigation" | "executor.pointerInput" | "executor.keyboardInput" | "executor.touchInput" | "executor.screenshots" | "executor.executionControl.pause" | "executor.executionControl.resume" | "executor.executionControl.freeze" | "inspector.pageEnumeration" | "inspector.frameEnumeration" | "inspector.html" | "inspector.domSnapshot" | "inspector.visualStability" | "inspector.text" | "inspector.attributes" | "inspector.hitTest" | "inspector.viewportMetrics" | "inspector.network" | "inspector.networkBodies" | "inspector.cookies" | "inspector.localStorage" | "inspector.sessionStorage" | "inspector.indexedDb" | "transport.sessionHttp" | "instrumentation.initScripts" | "instrumentation.routing" | "events.pageLifecycle" | "events.dialog" | "events.download" | "events.chooser" | "events.worker" | "events.console" | "events.pageError" | "events.websocket" | "events.eventStream" | "events.executionState";
434
+ type PartialBrowserCapabilities = {
435
+ readonly [K in keyof BrowserCapabilities]?: BrowserCapabilities[K] extends object ? {
436
+ readonly [Inner in keyof BrowserCapabilities[K]]?: BrowserCapabilities[K][Inner] extends object ? {
437
+ readonly [Leaf in keyof BrowserCapabilities[K][Inner]]?: BrowserCapabilities[K][Inner][Leaf];
438
+ } : BrowserCapabilities[K][Inner];
439
+ } : BrowserCapabilities[K];
440
+ };
441
+ declare function noBrowserCapabilities(): BrowserCapabilities;
442
+ declare function allBrowserCapabilities(): BrowserCapabilities;
443
+ declare function mergeBrowserCapabilities(base: BrowserCapabilities, override: PartialBrowserCapabilities): BrowserCapabilities;
444
+ declare function hasCapability(capabilities: BrowserCapabilities, path: BrowserCapabilityPath): boolean;
445
+
446
+ type BrowserCoreErrorCode = "invalid-argument" | "invalid-ref" | "not-found" | "unsupported-capability" | "stale-node-ref" | "session-closed" | "page-closed" | "frame-detached" | "timeout" | "navigation-failed" | "operation-failed";
447
+ interface BrowserCoreErrorOptions {
448
+ readonly cause?: unknown;
449
+ readonly retriable?: boolean;
450
+ readonly capability?: BrowserCapabilityPath;
451
+ readonly details?: Record<string, unknown>;
452
+ }
453
+ declare class BrowserCoreError extends Error {
454
+ readonly code: BrowserCoreErrorCode;
455
+ readonly retriable: boolean;
456
+ readonly capability: BrowserCapabilityPath | undefined;
457
+ readonly details: Record<string, unknown> | undefined;
458
+ constructor(code: BrowserCoreErrorCode, message: string, options?: BrowserCoreErrorOptions);
459
+ }
460
+ declare function isBrowserCoreError(value: unknown): value is BrowserCoreError;
461
+ declare function createBrowserCoreError(code: BrowserCoreErrorCode, message: string, options?: BrowserCoreErrorOptions): BrowserCoreError;
462
+ declare function unsupportedCapabilityError(capability: BrowserCapabilityPath): BrowserCoreError;
463
+ declare function staleNodeRefError(input: {
464
+ readonly nodeRef: NodeRef;
465
+ readonly documentRef: DocumentRef;
466
+ readonly documentEpoch: DocumentEpoch;
467
+ }): BrowserCoreError;
468
+ declare function closedSessionError(sessionRef: SessionRef): BrowserCoreError;
469
+ declare function closedPageError(pageRef: PageRef): BrowserCoreError;
470
+
471
+ type ConsoleLevel = "debug" | "log" | "info" | "warn" | "error" | "trace";
472
+ interface StepEventBase {
473
+ readonly eventId: string;
474
+ readonly kind: string;
475
+ readonly timestamp: number;
476
+ readonly sessionRef: SessionRef;
477
+ readonly pageRef?: PageRef;
478
+ readonly frameRef?: FrameRef;
479
+ readonly documentRef?: DocumentRef;
480
+ readonly documentEpoch?: DocumentEpoch;
481
+ }
482
+ interface PageCreatedStepEvent extends StepEventBase {
483
+ readonly kind: "page-created";
484
+ readonly pageRef: PageRef;
485
+ }
486
+ interface PopupOpenedStepEvent extends StepEventBase {
487
+ readonly kind: "popup-opened";
488
+ readonly pageRef: PageRef;
489
+ readonly openerPageRef: PageRef;
490
+ }
491
+ interface PageClosedStepEvent extends StepEventBase {
492
+ readonly kind: "page-closed";
493
+ readonly pageRef: PageRef;
494
+ }
495
+ interface DialogOpenedStepEvent extends StepEventBase {
496
+ readonly kind: "dialog-opened";
497
+ readonly dialogRef: DialogRef;
498
+ readonly dialogType: "alert" | "beforeunload" | "confirm" | "prompt";
499
+ readonly message: string;
500
+ readonly defaultValue?: string;
501
+ }
502
+ interface DownloadStartedStepEvent extends StepEventBase {
503
+ readonly kind: "download-started";
504
+ readonly downloadRef: DownloadRef;
505
+ readonly url: string;
506
+ readonly suggestedFilename?: string;
507
+ }
508
+ interface DownloadFinishedStepEvent extends StepEventBase {
509
+ readonly kind: "download-finished";
510
+ readonly downloadRef: DownloadRef;
511
+ readonly state: "completed" | "canceled" | "failed";
512
+ readonly filePath?: string;
513
+ }
514
+ interface ChooserOpenedStepEvent extends StepEventBase {
515
+ readonly kind: "chooser-opened";
516
+ readonly chooserRef: ChooserRef;
517
+ readonly chooserType: "file" | "select";
518
+ readonly multiple: boolean;
519
+ readonly options?: readonly {
520
+ readonly index: number;
521
+ readonly label: string;
522
+ readonly value: string;
523
+ readonly selected: boolean;
524
+ }[];
525
+ }
526
+ interface WorkerCreatedStepEvent extends StepEventBase {
527
+ readonly kind: "worker-created";
528
+ readonly workerRef: WorkerRef;
529
+ readonly workerType: "dedicated" | "shared" | "service";
530
+ readonly url: string;
531
+ }
532
+ interface WorkerDestroyedStepEvent extends StepEventBase {
533
+ readonly kind: "worker-destroyed";
534
+ readonly workerRef: WorkerRef;
535
+ readonly workerType: "dedicated" | "shared" | "service";
536
+ readonly url: string;
537
+ }
538
+ interface ConsoleStepEvent extends StepEventBase {
539
+ readonly kind: "console";
540
+ readonly level: ConsoleLevel;
541
+ readonly text: string;
542
+ readonly location?: {
543
+ readonly url?: string;
544
+ readonly lineNumber?: number;
545
+ readonly columnNumber?: number;
546
+ };
547
+ }
548
+ interface PageErrorStepEvent extends StepEventBase {
549
+ readonly kind: "page-error";
550
+ readonly message: string;
551
+ readonly stack?: string;
552
+ }
553
+ interface WebSocketOpenedStepEvent extends StepEventBase {
554
+ readonly kind: "websocket-opened";
555
+ readonly socketId: string;
556
+ readonly url: string;
557
+ }
558
+ interface WebSocketFrameStepEvent extends StepEventBase {
559
+ readonly kind: "websocket-frame";
560
+ readonly socketId: string;
561
+ readonly direction: "sent" | "received";
562
+ readonly opcode?: number;
563
+ readonly payloadPreview?: string;
564
+ }
565
+ interface WebSocketClosedStepEvent extends StepEventBase {
566
+ readonly kind: "websocket-closed";
567
+ readonly socketId: string;
568
+ readonly code?: number;
569
+ readonly reason?: string;
570
+ }
571
+ interface EventStreamMessageStepEvent extends StepEventBase {
572
+ readonly kind: "event-stream-message";
573
+ readonly streamId: string;
574
+ readonly eventName?: string;
575
+ readonly dataPreview?: string;
576
+ }
577
+ interface PausedStepEvent extends StepEventBase {
578
+ readonly kind: "paused";
579
+ readonly reason?: string;
580
+ }
581
+ interface ResumedStepEvent extends StepEventBase {
582
+ readonly kind: "resumed";
583
+ readonly reason?: string;
584
+ }
585
+ interface FrozenStepEvent extends StepEventBase {
586
+ readonly kind: "frozen";
587
+ readonly reason?: string;
588
+ }
589
+ type StepEvent = PageCreatedStepEvent | PopupOpenedStepEvent | PageClosedStepEvent | DialogOpenedStepEvent | DownloadStartedStepEvent | DownloadFinishedStepEvent | ChooserOpenedStepEvent | WorkerCreatedStepEvent | WorkerDestroyedStepEvent | ConsoleStepEvent | PageErrorStepEvent | WebSocketOpenedStepEvent | WebSocketFrameStepEvent | WebSocketClosedStepEvent | EventStreamMessageStepEvent | PausedStepEvent | ResumedStepEvent | FrozenStepEvent;
590
+ interface StepResult<TData = void> {
591
+ readonly stepId: string;
592
+ readonly sessionRef: SessionRef;
593
+ readonly pageRef?: PageRef;
594
+ readonly frameRef?: FrameRef;
595
+ readonly documentRef?: DocumentRef;
596
+ readonly documentEpoch?: DocumentEpoch;
597
+ readonly startedAt: number;
598
+ readonly completedAt: number;
599
+ readonly durationMs: number;
600
+ readonly events: readonly StepEvent[];
601
+ readonly data: TData;
602
+ }
603
+
604
+ type MouseButton = "left" | "middle" | "right";
605
+ type KeyModifier = "Shift" | "Control" | "Alt" | "Meta";
606
+ interface SessionTransportRequest {
607
+ readonly method: string;
608
+ readonly url: string;
609
+ readonly headers?: readonly HeaderEntry[];
610
+ readonly body?: BodyPayload;
611
+ readonly timeoutMs?: number;
612
+ readonly followRedirects?: boolean;
613
+ }
614
+ interface SessionTransportResponse {
615
+ readonly url: string;
616
+ readonly status: number;
617
+ readonly statusText: string;
618
+ readonly headers: readonly HeaderEntry[];
619
+ readonly body?: BodyPayload;
620
+ readonly redirected: boolean;
621
+ }
622
+ interface BrowserInitScriptInput {
623
+ readonly sessionRef: SessionRef;
624
+ readonly pageRef?: PageRef;
625
+ readonly script: string;
626
+ readonly args?: readonly unknown[];
627
+ }
628
+ interface BrowserInitScriptRegistration {
629
+ readonly registrationId: string;
630
+ readonly sessionRef: SessionRef;
631
+ readonly pageRef?: PageRef;
632
+ }
633
+ interface BrowserRouteRequest {
634
+ readonly url: string;
635
+ readonly method: string;
636
+ readonly headers: readonly HeaderEntry[];
637
+ readonly resourceType: NetworkRecord["resourceType"];
638
+ readonly pageRef?: PageRef;
639
+ readonly postData?: BodyPayload;
640
+ }
641
+ interface BrowserRouteFetchResult extends SessionTransportResponse {
642
+ }
643
+ type BrowserRouteHandlerResult = {
644
+ readonly kind: "continue";
645
+ } | {
646
+ readonly kind: "fulfill";
647
+ readonly status?: number;
648
+ readonly headers?: readonly HeaderEntry[];
649
+ readonly body?: BodyPayload;
650
+ readonly contentType?: string;
651
+ } | {
652
+ readonly kind: "abort";
653
+ readonly errorCode?: string;
654
+ };
655
+ interface BrowserRouteRegistrationInput {
656
+ readonly sessionRef: SessionRef;
657
+ readonly pageRef?: PageRef;
658
+ readonly urlPattern: string;
659
+ readonly resourceTypes?: readonly NetworkRecord["resourceType"][];
660
+ readonly times?: number;
661
+ readonly handler: (input: {
662
+ readonly request: BrowserRouteRequest;
663
+ fetchOriginal(): Promise<BrowserRouteFetchResult>;
664
+ }) => Promise<BrowserRouteHandlerResult> | BrowserRouteHandlerResult;
665
+ }
666
+ interface BrowserRouteRegistration {
667
+ readonly routeId: string;
668
+ readonly sessionRef: SessionRef;
669
+ readonly pageRef?: PageRef;
670
+ readonly urlPattern: string;
671
+ }
672
+ interface GetNetworkRecordsInput extends NetworkRecordFilterInput {
673
+ readonly sessionRef: SessionRef;
674
+ readonly pageRef?: PageRef;
675
+ readonly requestIds?: readonly string[];
676
+ readonly includeBodies?: boolean;
677
+ readonly signal?: AbortSignal;
678
+ }
679
+ interface BrowserExecutor {
680
+ readonly capabilities: Readonly<BrowserCapabilities>;
681
+ createSession(): Promise<SessionRef>;
682
+ closeSession(input: {
683
+ readonly sessionRef: SessionRef;
684
+ }): Promise<void>;
685
+ createPage(input: {
686
+ readonly sessionRef: SessionRef;
687
+ readonly openerPageRef?: PageRef;
688
+ readonly url?: string;
689
+ }): Promise<StepResult<PageInfo>>;
690
+ closePage(input: {
691
+ readonly pageRef: PageRef;
692
+ }): Promise<StepResult<void>>;
693
+ activatePage(input: {
694
+ readonly pageRef: PageRef;
695
+ }): Promise<StepResult<PageInfo>>;
696
+ navigate(input: {
697
+ readonly pageRef: PageRef;
698
+ readonly url: string;
699
+ readonly referrer?: string;
700
+ readonly timeoutMs?: number;
701
+ }): Promise<StepResult<{
702
+ readonly pageInfo: PageInfo;
703
+ readonly mainFrame: FrameInfo;
704
+ }>>;
705
+ reload(input: {
706
+ readonly pageRef: PageRef;
707
+ readonly timeoutMs?: number;
708
+ }): Promise<StepResult<{
709
+ readonly pageInfo: PageInfo;
710
+ readonly mainFrame: FrameInfo;
711
+ }>>;
712
+ goBack(input: {
713
+ readonly pageRef: PageRef;
714
+ }): Promise<StepResult<boolean>>;
715
+ goForward(input: {
716
+ readonly pageRef: PageRef;
717
+ }): Promise<StepResult<boolean>>;
718
+ stopLoading(input: {
719
+ readonly pageRef: PageRef;
720
+ }): Promise<StepResult<void>>;
721
+ mouseMove(input: {
722
+ readonly pageRef: PageRef;
723
+ readonly point: Point;
724
+ readonly coordinateSpace: CoordinateSpace;
725
+ }): Promise<StepResult<void>>;
726
+ mouseClick(input: {
727
+ readonly pageRef: PageRef;
728
+ readonly point: Point;
729
+ readonly coordinateSpace: CoordinateSpace;
730
+ readonly button?: MouseButton;
731
+ readonly clickCount?: number;
732
+ readonly modifiers?: readonly KeyModifier[];
733
+ }): Promise<StepResult<HitTestResult | undefined>>;
734
+ mouseScroll(input: {
735
+ readonly pageRef: PageRef;
736
+ readonly point: Point;
737
+ readonly coordinateSpace: CoordinateSpace;
738
+ readonly delta: Point;
739
+ }): Promise<StepResult<void>>;
740
+ keyPress(input: {
741
+ readonly pageRef: PageRef;
742
+ readonly key: string;
743
+ readonly modifiers?: readonly KeyModifier[];
744
+ }): Promise<StepResult<void>>;
745
+ textInput(input: {
746
+ readonly pageRef: PageRef;
747
+ readonly text: string;
748
+ }): Promise<StepResult<void>>;
749
+ captureScreenshot(input: {
750
+ readonly pageRef: PageRef;
751
+ readonly format?: ScreenshotFormat;
752
+ readonly clip?: Rect;
753
+ readonly clipSpace?: CoordinateSpace;
754
+ readonly fullPage?: boolean;
755
+ readonly includeCursor?: boolean;
756
+ }): Promise<StepResult<ScreenshotArtifact>>;
757
+ setExecutionState(input: {
758
+ readonly pageRef: PageRef;
759
+ readonly paused?: boolean;
760
+ readonly frozen?: boolean;
761
+ }): Promise<StepResult<{
762
+ readonly paused: boolean;
763
+ readonly frozen: boolean;
764
+ }>>;
765
+ }
766
+ interface BrowserInspector {
767
+ readonly capabilities: Readonly<BrowserCapabilities>;
768
+ listPages(input: {
769
+ readonly sessionRef: SessionRef;
770
+ }): Promise<readonly PageInfo[]>;
771
+ listFrames(input: {
772
+ readonly pageRef: PageRef;
773
+ }): Promise<readonly FrameInfo[]>;
774
+ getPageInfo(input: {
775
+ readonly pageRef: PageRef;
776
+ }): Promise<PageInfo>;
777
+ getFrameInfo(input: {
778
+ readonly frameRef: FrameRef;
779
+ }): Promise<FrameInfo>;
780
+ getHtmlSnapshot(input: {
781
+ readonly frameRef?: FrameRef;
782
+ readonly documentRef?: DocumentRef;
783
+ }): Promise<HtmlSnapshot>;
784
+ getDomSnapshot(input: {
785
+ readonly frameRef?: FrameRef;
786
+ readonly documentRef?: DocumentRef;
787
+ }): Promise<DomSnapshot>;
788
+ waitForVisualStability(input: {
789
+ readonly pageRef: PageRef;
790
+ readonly timeoutMs?: number;
791
+ readonly settleMs?: number;
792
+ readonly scope?: VisualStabilityScope;
793
+ }): Promise<void>;
794
+ readText(input: NodeLocator): Promise<string | null>;
795
+ readAttributes(input: NodeLocator): Promise<readonly {
796
+ readonly name: string;
797
+ readonly value: string;
798
+ }[]>;
799
+ hitTest(input: {
800
+ readonly pageRef: PageRef;
801
+ readonly point: Point;
802
+ readonly coordinateSpace: CoordinateSpace;
803
+ readonly ignorePointerEventsNone?: boolean;
804
+ readonly includeUserAgentShadowDom?: boolean;
805
+ }): Promise<HitTestResult>;
806
+ getViewportMetrics(input: {
807
+ readonly pageRef: PageRef;
808
+ }): Promise<ViewportMetrics>;
809
+ getNetworkRecords(input: GetNetworkRecordsInput): Promise<readonly NetworkRecord[]>;
810
+ getCookies(input: {
811
+ readonly sessionRef: SessionRef;
812
+ readonly urls?: readonly string[];
813
+ }): Promise<readonly CookieRecord[]>;
814
+ setCookies(input: {
815
+ readonly sessionRef: SessionRef;
816
+ readonly cookies: readonly CookieRecord[];
817
+ }): Promise<void>;
818
+ getStorageSnapshot(input: {
819
+ readonly sessionRef: SessionRef;
820
+ readonly includeSessionStorage?: boolean;
821
+ readonly includeIndexedDb?: boolean;
822
+ }): Promise<StorageSnapshot>;
823
+ evaluatePage(input: {
824
+ readonly pageRef: PageRef;
825
+ readonly script: string;
826
+ readonly args?: readonly unknown[];
827
+ readonly timeoutMs?: number;
828
+ }): Promise<StepResult<unknown>>;
829
+ }
830
+ interface SessionTransportExecutor {
831
+ readonly capabilities: Readonly<BrowserCapabilities>;
832
+ executeRequest(input: {
833
+ readonly sessionRef: SessionRef;
834
+ readonly request: SessionTransportRequest;
835
+ readonly signal?: AbortSignal;
836
+ }): Promise<StepResult<SessionTransportResponse>>;
837
+ }
838
+ interface BrowserInstrumentation {
839
+ readonly capabilities: Readonly<BrowserCapabilities>;
840
+ addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
841
+ registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
842
+ }
843
+ interface BrowserCoreEngine extends BrowserExecutor, BrowserInspector, SessionTransportExecutor, BrowserInstrumentation {
844
+ }
845
+ interface FakeBrowserCorePageSeed {
846
+ readonly url?: string;
847
+ readonly title?: string;
848
+ readonly viewportSize?: Size;
849
+ }
850
+ interface FakeBrowserCoreEngineOptions {
851
+ readonly capabilities?: BrowserCapabilities;
852
+ readonly timestampSeedMs?: number;
853
+ readonly initialPages?: readonly FakeBrowserCorePageSeed[];
854
+ }
855
+
856
+ declare class FakeBrowserCoreEngine implements BrowserCoreEngine {
857
+ readonly capabilities: Readonly<BrowserCapabilities>;
858
+ private readonly sessions;
859
+ private readonly pages;
860
+ private readonly frames;
861
+ private readonly documents;
862
+ private readonly retiredDocuments;
863
+ private pageCounter;
864
+ private frameCounter;
865
+ private documentCounter;
866
+ private nodeCounter;
867
+ private requestCounter;
868
+ private sessionCounter;
869
+ private stepCounter;
870
+ private eventCounter;
871
+ private timestampMs;
872
+ constructor(options?: FakeBrowserCoreEngineOptions);
873
+ enqueueStepEvents(pageRef: PageRef, events: readonly StepEvent[]): void;
874
+ advanceDocumentEpoch(documentRef: DocumentRef): DocumentEpoch;
875
+ seedCookies(sessionRef: SessionRef, cookies: readonly CookieRecord[]): void;
876
+ seedTransportResponse(sessionRef: SessionRef, request: SessionTransportRequest, response: SessionTransportResponse): void;
877
+ addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
878
+ registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
879
+ createSession(): Promise<SessionRef>;
880
+ closeSession(input: {
881
+ readonly sessionRef: SessionRef;
882
+ }): Promise<void>;
883
+ createPage(input: {
884
+ readonly sessionRef: SessionRef;
885
+ readonly openerPageRef?: PageRef;
886
+ readonly url?: string;
887
+ }): Promise<StepResult<PageInfo>>;
888
+ closePage(input: {
889
+ readonly pageRef: PageRef;
890
+ }): Promise<StepResult<void>>;
891
+ activatePage(input: {
892
+ readonly pageRef: PageRef;
893
+ }): Promise<StepResult<PageInfo>>;
894
+ navigate(input: {
895
+ readonly pageRef: PageRef;
896
+ readonly url: string;
897
+ readonly referrer?: string;
898
+ readonly timeoutMs?: number;
899
+ }): Promise<StepResult<{
900
+ readonly pageInfo: PageInfo;
901
+ readonly mainFrame: FrameInfo;
902
+ }>>;
903
+ reload(input: {
904
+ readonly pageRef: PageRef;
905
+ readonly timeoutMs?: number;
906
+ }): Promise<StepResult<{
907
+ readonly pageInfo: PageInfo;
908
+ readonly mainFrame: FrameInfo;
909
+ }>>;
910
+ goBack(input: {
911
+ readonly pageRef: PageRef;
912
+ }): Promise<StepResult<boolean>>;
913
+ goForward(input: {
914
+ readonly pageRef: PageRef;
915
+ }): Promise<StepResult<boolean>>;
916
+ stopLoading(input: {
917
+ readonly pageRef: PageRef;
918
+ }): Promise<StepResult<void>>;
919
+ mouseMove(input: {
920
+ readonly pageRef: PageRef;
921
+ readonly point: Point;
922
+ readonly coordinateSpace: CoordinateSpace;
923
+ }): Promise<StepResult<void>>;
924
+ mouseClick(input: {
925
+ readonly pageRef: PageRef;
926
+ readonly point: Point;
927
+ readonly coordinateSpace: CoordinateSpace;
928
+ readonly button?: "left" | "middle" | "right";
929
+ readonly clickCount?: number;
930
+ readonly modifiers?: readonly ("Shift" | "Control" | "Alt" | "Meta")[];
931
+ }): Promise<StepResult<HitTestResult | undefined>>;
932
+ mouseScroll(input: {
933
+ readonly pageRef: PageRef;
934
+ readonly point: Point;
935
+ readonly coordinateSpace: CoordinateSpace;
936
+ readonly delta: Point;
937
+ }): Promise<StepResult<void>>;
938
+ keyPress(input: {
939
+ readonly pageRef: PageRef;
940
+ readonly key: string;
941
+ readonly modifiers?: readonly ("Shift" | "Control" | "Alt" | "Meta")[];
942
+ }): Promise<StepResult<void>>;
943
+ textInput(input: {
944
+ readonly pageRef: PageRef;
945
+ readonly text: string;
946
+ }): Promise<StepResult<void>>;
947
+ captureScreenshot(input: {
948
+ readonly pageRef: PageRef;
949
+ readonly format?: "png" | "jpeg" | "webp";
950
+ readonly clip?: Rect;
951
+ readonly clipSpace?: CoordinateSpace;
952
+ readonly fullPage?: boolean;
953
+ readonly includeCursor?: boolean;
954
+ }): Promise<StepResult<ScreenshotArtifact>>;
955
+ setExecutionState(input: {
956
+ readonly pageRef: PageRef;
957
+ readonly paused?: boolean;
958
+ readonly frozen?: boolean;
959
+ }): Promise<StepResult<{
960
+ readonly paused: boolean;
961
+ readonly frozen: boolean;
962
+ }>>;
963
+ listPages(input: {
964
+ readonly sessionRef: SessionRef;
965
+ }): Promise<readonly PageInfo[]>;
966
+ listFrames(input: {
967
+ readonly pageRef: PageRef;
968
+ }): Promise<readonly FrameInfo[]>;
969
+ getPageInfo(input: {
970
+ readonly pageRef: PageRef;
971
+ }): Promise<PageInfo>;
972
+ getFrameInfo(input: {
973
+ readonly frameRef: FrameRef;
974
+ }): Promise<FrameInfo>;
975
+ getHtmlSnapshot(input: {
976
+ readonly frameRef?: FrameRef;
977
+ readonly documentRef?: DocumentRef;
978
+ }): Promise<HtmlSnapshot>;
979
+ getDomSnapshot(input: {
980
+ readonly frameRef?: FrameRef;
981
+ readonly documentRef?: DocumentRef;
982
+ }): Promise<DomSnapshot>;
983
+ waitForVisualStability(_input: {
984
+ readonly pageRef: PageRef;
985
+ readonly timeoutMs?: number;
986
+ readonly settleMs?: number;
987
+ readonly scope?: "main-frame" | "visible-frames";
988
+ }): Promise<void>;
989
+ readText(input: NodeLocator): Promise<string | null>;
990
+ readAttributes(input: NodeLocator): Promise<readonly {
991
+ readonly name: string;
992
+ readonly value: string;
993
+ }[]>;
994
+ hitTest(input: {
995
+ readonly pageRef: PageRef;
996
+ readonly point: Point;
997
+ readonly coordinateSpace: CoordinateSpace;
998
+ readonly ignorePointerEventsNone?: boolean;
999
+ readonly includeUserAgentShadowDom?: boolean;
1000
+ }): Promise<HitTestResult>;
1001
+ getViewportMetrics(input: {
1002
+ readonly pageRef: PageRef;
1003
+ }): Promise<ViewportMetrics>;
1004
+ getNetworkRecords(input: GetNetworkRecordsInput): Promise<readonly NetworkRecord[]>;
1005
+ getCookies(input: {
1006
+ readonly sessionRef: SessionRef;
1007
+ readonly urls?: readonly string[];
1008
+ }): Promise<readonly CookieRecord[]>;
1009
+ setCookies(input: {
1010
+ readonly sessionRef: SessionRef;
1011
+ readonly cookies: readonly CookieRecord[];
1012
+ }): Promise<void>;
1013
+ getStorageSnapshot(input: {
1014
+ readonly sessionRef: SessionRef;
1015
+ readonly includeSessionStorage?: boolean;
1016
+ readonly includeIndexedDb?: boolean;
1017
+ }): Promise<StorageSnapshot>;
1018
+ evaluatePage(input: {
1019
+ readonly pageRef: PageRef;
1020
+ readonly script: string;
1021
+ readonly args?: readonly unknown[];
1022
+ readonly timeoutMs?: number;
1023
+ }): Promise<StepResult<unknown>>;
1024
+ executeRequest(input: {
1025
+ readonly sessionRef: SessionRef;
1026
+ readonly request: SessionTransportRequest;
1027
+ readonly signal?: AbortSignal;
1028
+ }): Promise<StepResult<SessionTransportResponse>>;
1029
+ private createPageInternal;
1030
+ private pageInfoFromState;
1031
+ private createDefaultStorage;
1032
+ private seedDefaultSessionStorage;
1033
+ private performNavigation;
1034
+ private createDocumentSnapshot;
1035
+ private rebuildDocumentStateForFrame;
1036
+ private rebuildDocumentState;
1037
+ private resolveDocumentInput;
1038
+ private requireLiveNode;
1039
+ private resolvePoint;
1040
+ private hitTestKey;
1041
+ private requireCapability;
1042
+ private assertEventCapability;
1043
+ private eventCapabilityForKind;
1044
+ private createEvent;
1045
+ private maybeCreateEvent;
1046
+ private createStepResult;
1047
+ private drainQueuedEvents;
1048
+ private requireSession;
1049
+ private requirePage;
1050
+ private requireFrame;
1051
+ private requireDocument;
1052
+ private getMainFrame;
1053
+ private getMainFrameInfo;
1054
+ private destroyPage;
1055
+ private retireDocument;
1056
+ private nextTimestamp;
1057
+ }
1058
+ declare function createFakeBrowserCoreEngine(options?: FakeBrowserCoreEngineOptions): FakeBrowserCoreEngine;
1059
+
1060
+ declare const DOM_SNAPSHOT_COMPUTED_STYLE_NAMES: readonly ["display", "visibility", "opacity", "position", "cursor", "overflow-x", "overflow-y"];
1061
+ interface CdpRareStringData {
1062
+ readonly index: readonly number[];
1063
+ readonly value: readonly number[];
1064
+ }
1065
+ interface CdpRareIntegerData {
1066
+ readonly index: readonly number[];
1067
+ readonly value: readonly number[];
1068
+ }
1069
+ interface CdpShadowBoundaryInfo {
1070
+ readonly shadowRootType?: "open" | "closed" | "user-agent";
1071
+ readonly shadowHostBackendNodeId?: number;
1072
+ }
1073
+ interface CdpDomTreeNode {
1074
+ readonly backendNodeId?: number;
1075
+ readonly children?: readonly CdpDomTreeNode[];
1076
+ readonly shadowRoots?: readonly CdpDomTreeNode[];
1077
+ readonly contentDocument?: CdpDomTreeNode;
1078
+ readonly shadowRootType?: string;
1079
+ }
1080
+ interface CdpDomSnapshotDocument {
1081
+ readonly frameId: number;
1082
+ readonly nodes: {
1083
+ readonly parentIndex?: readonly number[];
1084
+ readonly nodeType?: readonly number[];
1085
+ readonly shadowRootType?: CdpRareStringData;
1086
+ readonly nodeName?: readonly number[];
1087
+ readonly nodeValue?: readonly number[];
1088
+ readonly backendNodeId?: readonly number[];
1089
+ readonly attributes?: ReadonlyArray<readonly number[]>;
1090
+ readonly textValue?: CdpRareStringData;
1091
+ readonly inputValue?: CdpRareStringData;
1092
+ readonly contentDocumentIndex?: CdpRareIntegerData;
1093
+ };
1094
+ readonly layout: {
1095
+ readonly nodeIndex: readonly number[];
1096
+ readonly styles?: ReadonlyArray<readonly number[]>;
1097
+ readonly bounds: ReadonlyArray<readonly number[]>;
1098
+ readonly text: readonly number[];
1099
+ readonly paintOrders?: readonly number[];
1100
+ };
1101
+ }
1102
+ interface CapturedCdpDomSnapshot {
1103
+ readonly capturedAt: number;
1104
+ readonly rawDocument: CdpDomSnapshotDocument;
1105
+ readonly shadowBoundariesByBackendNodeId: ReadonlyMap<number, CdpShadowBoundaryInfo>;
1106
+ readonly strings: readonly string[];
1107
+ }
1108
+ interface SnapshotDocumentIdentity {
1109
+ readonly pageRef: PageRef;
1110
+ readonly frameRef: FrameRef;
1111
+ readonly documentRef: DocumentRef;
1112
+ readonly parentDocumentRef: DocumentRef | undefined;
1113
+ readonly documentEpoch: DocumentEpoch;
1114
+ readonly url: string;
1115
+ }
1116
+ declare function parseCdpStringTable(strings: readonly string[], index: number | undefined): string;
1117
+ declare function rareCdpStringValue(strings: readonly string[], data: CdpRareStringData | undefined, index: number): string | undefined;
1118
+ declare function rareCdpIntegerValue(data: CdpRareIntegerData | undefined, index: number): number | undefined;
1119
+ declare function normalizeCdpShadowRootType(value: string | undefined): "open" | "closed" | "user-agent" | undefined;
1120
+ declare function buildCdpShadowBoundaryIndex(root: CdpDomTreeNode): ReadonlyMap<number, CdpShadowBoundaryInfo>;
1121
+ declare function buildDomSnapshotFromCdpCapture(document: SnapshotDocumentIdentity, captured: CapturedCdpDomSnapshot, nodeRefResolver: (backendNodeId: number) => NodeRef, contentDocRefResolver: (contentDocumentIndex: number) => DocumentRef | undefined): DomSnapshot;
1122
+
1123
+ declare const DEFAULT_VISUAL_STABILITY_TIMEOUT_MS = 30000;
1124
+ declare const DEFAULT_VISUAL_STABILITY_SETTLE_MS = 750;
1125
+ interface CdpSessionLike {
1126
+ send(method: string, params?: object): Promise<unknown>;
1127
+ }
1128
+ interface VisualStabilityOptions {
1129
+ readonly timeoutMs?: number;
1130
+ readonly settleMs?: number;
1131
+ readonly scope?: VisualStabilityScope;
1132
+ }
1133
+ declare function waitForCdpVisualStability(cdp: CdpSessionLike, options?: VisualStabilityOptions): Promise<void>;
1134
+
1135
+ export { type BodyPayload, type BodyPayloadEncoding, type Brand, type BrowserCapabilities, type BrowserCapabilityPath, type BrowserCoreEngine, BrowserCoreError, type BrowserCoreErrorCode, type BrowserCoreErrorOptions, type BrowserExecutor, type BrowserInitScriptInput, type BrowserInitScriptRegistration, type BrowserInspector, type BrowserInstrumentation, type BrowserRouteFetchResult, type BrowserRouteHandlerResult, type BrowserRouteRegistration, type BrowserRouteRegistrationInput, type BrowserRouteRequest, type CapturedCdpDomSnapshot, type CdpDomSnapshotDocument, type CdpDomTreeNode, type CdpRareIntegerData, type CdpRareStringData, type CdpShadowBoundaryInfo, type ChooserOpenedStepEvent, type ChooserRef, type ConsoleLevel, type ConsoleStepEvent, type CookiePriority, type CookieRecord, type CookieSameSite, type CoordinateSpace, DEFAULT_VISUAL_STABILITY_SETTLE_MS, DEFAULT_VISUAL_STABILITY_TIMEOUT_MS, DOM_SNAPSHOT_COMPUTED_STYLE_NAMES, type DevicePixelRatio, type DialogOpenedStepEvent, type DialogRef, type DocumentEpoch, type DocumentRef, type DomSnapshot, type DomSnapshotNode, type DownloadFinishedStepEvent, type DownloadRef, type DownloadStartedStepEvent, type EventStreamMessageStepEvent, FakeBrowserCoreEngine, type FakeBrowserCoreEngineOptions, type FakeBrowserCorePageSeed, type FrameInfo, type FrameRef, type FrozenStepEvent, type GetNetworkRecordsInput, type HeaderEntry, type HitTestResult, type HtmlSnapshot, type IndexedDbDatabaseSnapshot, type IndexedDbIndexSnapshot, type IndexedDbObjectStoreSnapshot, type IndexedDbRecord, type KeyModifier, type LayoutViewport, type MouseButton, type NetworkCaptureState, type NetworkInitiator, type NetworkInitiatorType, type NetworkRecord, type NetworkRecordFilterInput, type NetworkRecordKind, type NetworkRequestId, type NetworkResourceType, type NetworkSourceMetadata, type NetworkTiming, type NetworkTransferSizes, type NodeLocator, type NodeRef, type PageClosedStepEvent, type PageCreatedStepEvent, type PageErrorStepEvent, type PageInfo, type PageLifecycleState, type PageRef, type PageScaleFactor, type PageZoomFactor, type PartialBrowserCapabilities, type PausedStepEvent, type Point, type PopupOpenedStepEvent, type Quad, type Rect, type ResumedStepEvent, type ScreenshotArtifact, type ScreenshotFormat, type ScrollOffset, type SessionRef, type SessionStorageSnapshot, type SessionTransportExecutor, type SessionTransportRequest, type SessionTransportResponse, type ShadowDomSnapshotMode, type Size, type StepEvent, type StepResult, type StorageEntry, type StorageOriginSnapshot, type StorageSnapshot, type ViewportMetrics, type VisualStabilityScope, type VisualViewport, type WebSocketClosedStepEvent, type WebSocketFrameStepEvent, type WebSocketOpenedStepEvent, type WorkerCreatedStepEvent, type WorkerDestroyedStepEvent, type WorkerRef, allBrowserCapabilities, bodyPayloadFromUtf8, brand, buildCdpShadowBoundaryIndex, buildDomSnapshotFromCdpCapture, closedPageError, closedSessionError, createBodyPayload, createBrowserCoreError, createChooserRef, createDevicePixelRatio, createDialogRef, createDocumentEpoch, createDocumentRef, createDownloadRef, createFakeBrowserCoreEngine, createFrameRef, createHeaderEntry, createNetworkRequestId, createNodeLocator, createNodeRef, createPageRef, createPageScaleFactor, createPageZoomFactor, createPoint, createQuad, createRect, createScrollOffset, createSessionRef, createSize, createWorkerRef, filterCookieRecords, findDomSnapshotNode, findDomSnapshotNodeByRef, hasCapability, isBrowserCoreError, isChooserRef, isDialogRef, isDocumentRef, isDownloadRef, isFrameRef, isNetworkRequestId, isNodeRef, isPageRef, isSessionRef, isWorkerRef, matchesNetworkRecordFilters, mergeBrowserCapabilities, nextDocumentEpoch, noBrowserCapabilities, normalizeCdpShadowRootType, parseCdpStringTable, quadBounds, rareCdpIntegerValue, rareCdpStringValue, rectContainsPoint, rectToQuad, serializeDocumentEpoch, serializeRef, staleNodeRefError, unsupportedCapabilityError, waitForCdpVisualStability };