@orkestrel/browser 0.0.15 → 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 CHANGED
@@ -1,16 +1,13 @@
1
1
  # @orkestrel/browser
2
2
 
3
- A typed [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/)
4
- browser automation library for the `@orkestrel` line. The environment-agnostic
5
- core (`src/core` — `CDPClient` speaking the CDP wire protocol over an injected
6
- `CDPTransportInterface`, plus `BrowserContext`, `BrowserPage`, and
7
- `BrowserFrame`, semantic locators, trusted input, network/HAR controls,
8
- diagnostics, structured DOM snapshots, content distillation that selects a
9
- document's article rather than its whole body text, and `BrowserCodegen`)
10
- never touches `node:*` or the DOM; the Node runtime (`src/server`)
11
- adapts it with a `WebSocketCDPTransport`, browser process launch/discovery
12
- (`node:child_process` + `fetch`), a filesystem browser writer, and the
13
- `Browser` façade that ties launch → context → page together. Part of the
3
+ > A lightweight Chrome DevTools Protocol automation layer for Chromium-family
4
+ > browsers: an environment-agnostic core that drives pages, frames, locators, and
5
+ > DOM snapshots over an injected transport, and a Node runtime that finds,
6
+ > launches, and connects to the browser itself.
7
+
8
+ Connect to a running browser or launch one with the `createBrowser` function, open a page in its
9
+ default context, and drive that page through locators, trusted input, network control, and DOM
10
+ snapshots. Inject your own `CDPTransportInterface` where the runtime is not Node. Part of the
14
11
  `@orkestrel` line.
15
12
 
16
13
  ## Install
@@ -47,24 +44,23 @@ Drive the same protocol from any environment by injecting your own transport
47
44
  over the environment-agnostic core:
48
45
 
49
46
  ```ts
50
- import { CDPClient } from '@orkestrel/browser'
51
- import type { CDPTransportInterface } from '@orkestrel/browser'
47
+ import { createCDPClient } from '@orkestrel/browser'
52
48
 
53
- const transport: CDPTransportInterface = /* your injected transport */
54
- const client = new CDPClient({ transport })
49
+ const client = createCDPClient({ transport }) // transport: CDPTransportInterface
55
50
  await client.connect()
56
51
  const result = await client.send('Page.navigate', { url: 'https://example.com' })
52
+ await client.close()
57
53
  ```
58
54
 
59
55
  ## Guide
60
56
 
61
- For the full surface — the CDP dispatch core, the `BrowserContext` /
62
- `BrowserPage` / `BrowserCodegen` entities, the server transports, and usage
57
+ For the full surface — the CDP dispatch core, the `BrowserContext`,
58
+ `BrowserPage`, and `BrowserCodegen` classes, the server transports, and usage
63
59
  patterns — see [`guides/browser.md`](guides/browser.md).
64
60
 
65
61
  ## Package
66
62
 
67
- Published with two entry points per the `exports` field in `package.json`:
63
+ Published with the entry points the `exports` field in `package.json` names:
68
64
  the environment-agnostic core (`.`) — `CDPClient`, `BrowserContext`,
69
65
  `BrowserPage`, `BrowserFrame`, DOM snapshot traversal helpers,
70
66
  `BrowserCodegen`, `createCDPClient`, `CDPTransportInterface` —
@@ -72,14 +72,17 @@ var BASE64_LOOKUP = Object.freeze({
72
72
  "+": 62,
73
73
  "/": 63
74
74
  });
75
- /** Sets the default timeout in milliseconds for browser connection, requests, and navigation. */
75
+ /**
76
+ * Sets the default timeout for browser connection, requests, and navigation, `30_000`
77
+ * milliseconds.
78
+ */
76
79
  var BROWSER_DEFAULT_TIMEOUT_MS = 3e4;
77
80
  /**
78
- * Caps the serialized-character length for an `evaluate()`/`content()` result,
79
- * enforced IN-PAGE before the result is returned to CDP.
81
+ * Caps the serialized-character length for an `evaluate()`/`content()` result at `2_500_000`,
82
+ * enforced in-page before the result is returned to CDP.
80
83
  *
81
84
  * @remarks
82
- * This counts UTF-16 STRING LENGTH (`String#length`), not transport BYTES —
85
+ * This counts UTF-16 string length (`String#length`), not transport bytes —
83
86
  * the actual CDP frame is UTF-8 encoded (up to 3 bytes/char for common
84
87
  * multibyte content) and carries additional JSON/CDP framing overhead on top
85
88
  * of the raw content. A `Runtime.evaluate` result above this size, once
@@ -95,8 +98,8 @@ var BROWSER_DEFAULT_TIMEOUT_MS = 3e4;
95
98
  */
96
99
  var BROWSER_RESULT_LIMIT = 25e5;
97
100
  /**
98
- * Names the distinctive prefix for the in-page result-limit sentinel error, immediately
99
- * followed by the serialized length.
101
+ * Names the distinctive prefix for the in-page result-limit sentinel error,
102
+ * `'[[ORKESTREL_BROWSER_RESULT_LIMIT]]'`, immediately followed by the serialized length.
100
103
  *
101
104
  * @remarks
102
105
  * Deliberately unlikely to appear in a page's own thrown error text (unlike
@@ -106,18 +109,29 @@ var BROWSER_RESULT_LIMIT = 25e5;
106
109
  */
107
110
  var BROWSER_RESULT_LIMIT_SENTINEL_PREFIX = "[[ORKESTREL_BROWSER_RESULT_LIMIT]]";
108
111
  /**
109
- * Matches the in-page result-limit sentinel error message, anchored
110
- * immediately after the `Error: ` (optionally `Uncaught Error: `) prefix that
111
- * Chromium prepends to a thrown error's description — so the guard's own
112
- * throw is recognized only at the message START, not wherever the substring
113
- * happens to occur.
112
+ * Matches the in-page result-limit sentinel error message, anchored immediately after the
113
+ * `Error:` (optionally `Uncaught Error:`) prefix Chromium prepends to a thrown error's
114
+ * description, `/^(?:Uncaught )?Error: \[\[ORKESTREL_BROWSER_RESULT_LIMIT\]\](\d+)/`.
115
+ *
116
+ * @remarks
117
+ * The anchor matches the guard's own throw only at the start of the message, rather than
118
+ * wherever the substring happens to occur.
114
119
  */
115
120
  var BROWSER_RESULT_LIMIT_PATTERN = new RegExp(`^(?:Uncaught )?Error: \\[\\[ORKESTREL_BROWSER_RESULT_LIMIT\\]\\](\\d+)`);
116
- /** Sets the poll interval in milliseconds while waiting for a selector to appear. */
121
+ /**
122
+ * Sets the poll interval while waiting for a selector to appear, `100` milliseconds.
123
+ *
124
+ * @remarks
125
+ * A wait adds the same interval as slack to its own CDP call timeout, so the in-page poll
126
+ * expires before the call carrying it. Host-side CDP readiness probes wait it out between
127
+ * attempts.
128
+ */
117
129
  var BROWSER_WAIT_POLL_INTERVAL_MS = 100;
118
- /** Sets the default maximum node count accepted from a decoded CDP DOM snapshot. */
130
+ /**
131
+ * Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.
132
+ */
119
133
  var BROWSER_SNAPSHOT_NODE_LIMIT = 1e5;
120
- /** Names the isolated world used for iframe evaluation. */
134
+ /** Names the isolated world used for iframe evaluation, `'__orkestrelBrowserFrame'`. */
121
135
  var BROWSER_FRAME_WORLD_NAME = "__orkestrelBrowserFrame";
122
136
  /** Names the attribute the semantic test-id selector uses. */
123
137
  var BROWSER_TEST_ID_ATTRIBUTE = "data-testid";
@@ -158,13 +172,13 @@ var BROWSER_MOUSE_BUTTON_MASKS = Object.freeze({
158
172
  */
159
173
  var BROWSER_HAR_CREATOR = Object.freeze({
160
174
  name: "@orkestrel/browser",
161
- version: "0.0.15"
175
+ version: "0.0.16"
162
176
  });
163
177
  /** Names the attribute that tags temporary screenshot styles and masks. */
164
178
  var BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
165
179
  /**
166
- * Bounds (in milliseconds) the best-effort `Page.stopLoading` call issued
167
- * after a failed `navigate()`.
180
+ * Bounds the best-effort `Page.stopLoading` call issued after a failed `navigate()` at `1_000`
181
+ * milliseconds.
168
182
  *
169
183
  * @remarks
170
184
  * A wedged renderer can make the underlying CDP call hang for the full
@@ -173,23 +187,26 @@ var BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
173
187
  * it. Best-effort only — never masks the original navigate error.
174
188
  */
175
189
  var BROWSER_STOP_LOADING_TIMEOUT_MS = 1e3;
176
- /** Sets the default viewport width in pixels. */
190
+ /** Sets the default viewport width, `1280` pixels. */
177
191
  var BROWSER_DEFAULT_VIEWPORT_WIDTH = 1280;
178
- /** Sets the default viewport height in pixels. */
192
+ /** Sets the default viewport height, `720` pixels. */
179
193
  var BROWSER_DEFAULT_VIEWPORT_HEIGHT = 720;
180
- /** Names the CDP runtime binding the codegen recorder script calls into. */
194
+ /**
195
+ * Names the CDP runtime binding the codegen recorder script calls into,
196
+ * `'__orkestrelBrowserCodegen'`.
197
+ */
181
198
  var BROWSER_CODEGEN_BINDING_NAME = "__orkestrelBrowserCodegen";
182
199
  /**
183
200
  * Holds the in-page recorder script injected through `Page.addScriptToEvaluateOnNewDocument`
184
201
  * and `Runtime.evaluate`.
185
202
  *
186
203
  * @remarks
187
- * Attaches capturing-phase listeners for `click`, `input` (fill), and
188
- * `change` (select) on `document`, builds a stable CSS selector for the
189
- * target element, and forwards each action to the CDP binding
190
- * ({@link BROWSER_CODEGEN_BINDING_NAME}) as a JSON string payload. Guarded to
191
- * install exactly once per document (`window[name]` sentinel) so repeated
192
- * injection on every new document is idempotent.
204
+ * Attaches capturing-phase listeners for `click`, `input` (fill), and `change` (select) on
205
+ * `document`, builds a stable CSS selector for the target element, and forwards each action
206
+ * to the CDP binding ({@link BROWSER_CODEGEN_BINDING_NAME}) as a JSON string payload. A
207
+ * `contenteditable` fill is captured through `input` events, the same way an input or a
208
+ * textarea is. Guarded to install exactly once per document (`window[name]` sentinel) so
209
+ * repeated injection on every new document is idempotent.
193
210
  */
194
211
  var BROWSER_CODEGEN_SOURCE = `(() => {
195
212
  const bindingName = ${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME)}
@@ -282,11 +299,11 @@ var BROWSER_CODEGEN_SOURCE = `(() => {
282
299
  //#endregion
283
300
  //#region src/core/errors.ts
284
301
  /**
285
- * Represents the base error for all browser automation operations.
302
+ * Represents the base error for all browser automation operations, carrying the code
303
+ * `BROWSER_ERROR` and a `context` record.
286
304
  *
287
305
  * @remarks
288
- * Carries a machine-readable `code` and optional `context` so
289
- * callers can branch in a `catch` without parsing message strings.
306
+ * A caller branches in a `catch` on the `code` rather than parsing message strings.
290
307
  */
291
308
  var BrowserError = class extends Error {
292
309
  code;
@@ -299,7 +316,8 @@ var BrowserError = class extends Error {
299
316
  }
300
317
  };
301
318
  /**
302
- * Reports that a selector-based lookup or wait timed out without the element appearing.
319
+ * Reports that a selector-based lookup or wait timed out without the element appearing, under
320
+ * the code `BROWSER_SELECTOR_ERROR`.
303
321
  */
304
322
  var BrowserSelectorError = class extends BrowserError {
305
323
  constructor(message, context) {
@@ -308,12 +326,12 @@ var BrowserSelectorError = class extends BrowserError {
308
326
  }
309
327
  };
310
328
  /**
311
- * Reports that a CDP request received an error response from the remote endpoint.
329
+ * Reports that a CDP request received an error response from the remote endpoint, under the
330
+ * code `BROWSER_CDP_ERROR`, with the `method`, the CDP `code`, the `message`, and any `data`
331
+ * in its context.
312
332
  *
313
333
  * @remarks
314
- * Carries the originating `method` plus the CDP error's own `code`,
315
- * `message`, and `data` (when present) in `context`, so callers can branch
316
- * on the protocol-level error instead of parsing the message string.
334
+ * Branch on the protocol-level error in `context` instead of parsing the message string.
317
335
  */
318
336
  var CDPError = class extends BrowserError {
319
337
  constructor(message, context) {
@@ -322,9 +340,9 @@ var CDPError = class extends BrowserError {
322
340
  }
323
341
  };
324
342
  /**
325
- * Reports that a CDP request could not be sent or completed because the client was not in
326
- * a connectable state (not connected, closed while connecting, or the
327
- * connection dropped mid-request).
343
+ * Reports that a CDP request could not be sent or completed because the client was not in a
344
+ * connectable state — not connected, closed while connecting, or the connection dropped
345
+ * mid-request — under the code `BROWSER_CDP_CONNECTION_ERROR`.
328
346
  */
329
347
  var CDPConnectionError = class extends BrowserError {
330
348
  constructor(message, context) {
@@ -333,7 +351,8 @@ var CDPConnectionError = class extends BrowserError {
333
351
  }
334
352
  };
335
353
  /**
336
- * Reports that a pending CDP request was not answered within its timeout window.
354
+ * Reports that a pending CDP request was not answered within its timeout window, under the
355
+ * code `BROWSER_CDP_TIMEOUT_ERROR`.
337
356
  */
338
357
  var CDPTimeoutError = class extends BrowserError {
339
358
  constructor(message, context) {
@@ -342,8 +361,9 @@ var CDPTimeoutError = class extends BrowserError {
342
361
  }
343
362
  };
344
363
  /**
345
- * Reports that an `evaluate()`/`content()` result exceeded {@link BROWSER_RESULT_LIMIT}
346
- * and was rejected in-page before it could overflow the CDP transport frame.
364
+ * Reports that an `evaluate()`/`content()` result exceeded {@link BROWSER_RESULT_LIMIT} and
365
+ * was rejected in-page before it could overflow the CDP transport frame, under the code
366
+ * `BROWSER_RESULT_LIMIT_ERROR`.
347
367
  */
348
368
  var BrowserResultLimitError = class extends BrowserError {
349
369
  constructor(message, context) {
@@ -352,7 +372,7 @@ var BrowserResultLimitError = class extends BrowserError {
352
372
  }
353
373
  };
354
374
  /**
355
- * Narrows an unknown value to BrowserError.
375
+ * Narrows an unknown value to a `BrowserError`.
356
376
  *
357
377
  * @param value - Value to check
358
378
  * @returns True if value is a BrowserError instance; false otherwise
@@ -361,7 +381,7 @@ function isBrowserError(value) {
361
381
  return (0, _orkestrel_contract.isInstance)(value, BrowserError);
362
382
  }
363
383
  /**
364
- * Narrows an unknown value to BrowserSelectorError.
384
+ * Narrows an unknown value to a `BrowserSelectorError`.
365
385
  *
366
386
  * @param value - Value to check
367
387
  * @returns True if value is a BrowserSelectorError instance; false otherwise
@@ -370,7 +390,7 @@ function isBrowserSelectorError(value) {
370
390
  return (0, _orkestrel_contract.isInstance)(value, BrowserSelectorError);
371
391
  }
372
392
  /**
373
- * Narrows an unknown value to CDPError.
393
+ * Narrows an unknown value to a `CDPError`.
374
394
  *
375
395
  * @param value - Value to check
376
396
  * @returns True if value is a CDPError instance; false otherwise
@@ -379,7 +399,7 @@ function isCDPError(value) {
379
399
  return (0, _orkestrel_contract.isInstance)(value, CDPError);
380
400
  }
381
401
  /**
382
- * Narrows an unknown value to CDPConnectionError.
402
+ * Narrows an unknown value to a `CDPConnectionError`.
383
403
  *
384
404
  * @param value - Value to check
385
405
  * @returns True if value is a CDPConnectionError instance; false otherwise
@@ -388,7 +408,7 @@ function isCDPConnectionError(value) {
388
408
  return (0, _orkestrel_contract.isInstance)(value, CDPConnectionError);
389
409
  }
390
410
  /**
391
- * Narrows an unknown value to CDPTimeoutError.
411
+ * Narrows an unknown value to a `CDPTimeoutError`.
392
412
  *
393
413
  * @param value - Value to check
394
414
  * @returns True if value is a CDPTimeoutError instance; false otherwise
@@ -397,7 +417,7 @@ function isCDPTimeoutError(value) {
397
417
  return (0, _orkestrel_contract.isInstance)(value, CDPTimeoutError);
398
418
  }
399
419
  /**
400
- * Narrows an unknown value to BrowserResultLimitError.
420
+ * Narrows an unknown value to a `BrowserResultLimitError`.
401
421
  *
402
422
  * @param value - Value to check
403
423
  * @returns True if value is a BrowserResultLimitError instance; false otherwise
@@ -729,8 +749,8 @@ function parseCodegenActionPayload(payload) {
729
749
  }
730
750
  }
731
751
  /**
732
- * Coerces a `Page.frameNavigated` CDP event to a `navigate` codegen action, or
733
- * `undefined` off-shape.
752
+ * Coerces a `Page.frameNavigated` CDP event to a `navigate` codegen action, or `undefined`
753
+ * off-shape and for every frame but the top-level one.
734
754
  *
735
755
  * @remarks
736
756
  * Only the top-level (main) frame's navigation is recorded — a frame
@@ -773,8 +793,7 @@ function parseSnapshotString(strings, index) {
773
793
  return strings[index];
774
794
  }
775
795
  /**
776
- * Coerces a CDP snapshot rectangle to a `BrowserRect`, or `undefined`
777
- * off-shape.
796
+ * Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.
778
797
  *
779
798
  * @param value - Candidate four-number array
780
799
  * @returns A rectangle, or undefined
@@ -871,7 +890,8 @@ function browserHeadersToProtocol(headers) {
871
890
  }));
872
891
  }
873
892
  /**
874
- * Decodes a Chromium Headers object into string values.
893
+ * Decodes a Chromium Headers object into string values, skipping every entry that is neither a
894
+ * string nor a finite number.
875
895
  *
876
896
  * @param value - Unknown headers
877
897
  * @returns Frozen-compatible header record
@@ -1056,7 +1076,8 @@ function matchesBrowserURL(url, pattern) {
1056
1076
  return new RegExp(`^${source}$`).test(url);
1057
1077
  }
1058
1078
  /**
1059
- * Decodes the `Page.addScriptToEvaluateOnNewDocument` result.
1079
+ * Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`
1080
+ * off-shape.
1060
1081
  *
1061
1082
  * @param value - Unknown protocol result
1062
1083
  * @returns Script identifier
@@ -1074,7 +1095,7 @@ function validateBrowserPoint(point) {
1074
1095
  if (!(0, _orkestrel_contract.isFiniteNumber)(point.x) || !(0, _orkestrel_contract.isFiniteNumber)(point.y)) throw new BrowserError("Browser input coordinates must be finite", void 0, { point });
1075
1096
  }
1076
1097
  /**
1077
- * Validates the bounded keys of one trusted-input operation.
1098
+ * Validates the bounded delay, count, steps, and position of one trusted-input operation.
1078
1099
  *
1079
1100
  * @remarks
1080
1101
  * The parameter is `BrowserOperationOptions`, so one validator answers for a
@@ -1240,7 +1261,8 @@ function validateBrowserRange(value, field, minimum, maximum, inclusive = true)
1240
1261
  });
1241
1262
  }
1242
1263
  /**
1243
- * Decodes Accessibility-domain nodes into a flat serializable tree.
1264
+ * Decodes Accessibility-domain nodes into a flat serializable tree, throwing a `BrowserError`
1265
+ * off-shape.
1244
1266
  *
1245
1267
  * @param value - Unknown full or partial AX-tree result
1246
1268
  * @returns Valid accessibility snapshot
@@ -1276,7 +1298,7 @@ function readBrowserAccessibility(value) {
1276
1298
  };
1277
1299
  }
1278
1300
  /**
1279
- * Decodes an Accessibility-domain AXValue.
1301
+ * Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.
1280
1302
  *
1281
1303
  * @param value - Unknown AX value
1282
1304
  * @returns Underlying value
@@ -1301,7 +1323,7 @@ function concatBytes(chunks) {
1301
1323
  return result;
1302
1324
  }
1303
1325
  /**
1304
- * Decodes one `IO.read` response.
1326
+ * Decodes one `IO.read` response, throwing a `BrowserError` off-shape.
1305
1327
  *
1306
1328
  * @param value - Unknown protocol result
1307
1329
  * @returns Valid stream chunk
@@ -1314,7 +1336,7 @@ function readBrowserStreamChunk(value) {
1314
1336
  };
1315
1337
  }
1316
1338
  /**
1317
- * Decodes JavaScript precise coverage.
1339
+ * Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.
1318
1340
  *
1319
1341
  * @param value - Unknown `Profiler.takePreciseCoverage` result
1320
1342
  * @returns Script coverage
@@ -1342,7 +1364,7 @@ function readBrowserScriptCoverage(value) {
1342
1364
  });
1343
1365
  }
1344
1366
  /**
1345
- * Decodes CSS rule usage.
1367
+ * Decodes CSS rule usage, throwing a `BrowserError` off-shape.
1346
1368
  *
1347
1369
  * @param value - Unknown `CSS.stopRuleUsageTracking` result
1348
1370
  * @returns Stylesheet coverage
@@ -1366,7 +1388,7 @@ function readBrowserStyleCoverage(value) {
1366
1388
  }));
1367
1389
  }
1368
1390
  /**
1369
- * Decodes coverage ranges.
1391
+ * Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.
1370
1392
  *
1371
1393
  * @param value - Unknown ranges
1372
1394
  * @param script - Script index for diagnostics
@@ -1387,7 +1409,7 @@ function readBrowserCoverageRanges(value, script) {
1387
1409
  });
1388
1410
  }
1389
1411
  /**
1390
- * Decodes Performance-domain metrics.
1412
+ * Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.
1391
1413
  *
1392
1414
  * @param value - Unknown metrics result
1393
1415
  * @returns Valid metrics
@@ -1403,7 +1425,7 @@ function readBrowserMetrics(value) {
1403
1425
  });
1404
1426
  }
1405
1427
  /**
1406
- * Decodes one CPU profile.
1428
+ * Decodes one CPU profile, throwing a `BrowserError` off-shape.
1407
1429
  *
1408
1430
  * @param value - Unknown `Profiler.stop` result
1409
1431
  * @returns Valid profile
@@ -1436,7 +1458,7 @@ function readBrowserProfile(value) {
1436
1458
  };
1437
1459
  }
1438
1460
  /**
1439
- * Decodes a CPU profile call frame.
1461
+ * Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.
1440
1462
  *
1441
1463
  * @param value - Unknown call frame
1442
1464
  * @param node - Node index for diagnostics
@@ -1488,7 +1510,7 @@ function cookieToProtocol(cookie) {
1488
1510
  return result;
1489
1511
  }
1490
1512
  /**
1491
- * Decodes cookies returned by `Storage.getCookies`.
1513
+ * Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.
1492
1514
  *
1493
1515
  * @param value - Unknown protocol result
1494
1516
  * @returns Valid cookies
@@ -1498,7 +1520,7 @@ function readBrowserCookies(value) {
1498
1520
  return value["cookies"].map((candidate, index) => readBrowserCookie(candidate, index));
1499
1521
  }
1500
1522
  /**
1501
- * Decodes one Chromium cookie.
1523
+ * Decodes one Chromium cookie, throwing a `BrowserError` off-shape.
1502
1524
  *
1503
1525
  * @param value - Unknown cookie record
1504
1526
  * @param index - Source array position for diagnostics
@@ -1542,7 +1564,7 @@ function matchesBrowserCookieURL(cookie, value) {
1542
1564
  return domainMatches && pathMatches && secureMatches;
1543
1565
  }
1544
1566
  /**
1545
- * Decodes one in-page web-storage snapshot.
1567
+ * Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.
1546
1568
  *
1547
1569
  * @param value - Unknown evaluation result
1548
1570
  * @param origin - Origin represented by the result
@@ -1557,7 +1579,7 @@ function readBrowserStorageOrigin(value, origin) {
1557
1579
  };
1558
1580
  }
1559
1581
  /**
1560
- * Decodes a list of web-storage entries.
1582
+ * Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.
1561
1583
  *
1562
1584
  * @param value - Unknown entry list
1563
1585
  * @param origin - Origin used for diagnostics
@@ -1608,7 +1630,7 @@ function mediaToFeatures(media) {
1608
1630
  return features;
1609
1631
  }
1610
1632
  /**
1611
- * Decodes a Chromium runtime stack trace.
1633
+ * Decodes a Chromium runtime stack trace, skipping every off-shape call frame.
1612
1634
  *
1613
1635
  * @param value - Unknown stack trace or call-frame list
1614
1636
  * @returns Valid stack frames
@@ -1629,7 +1651,8 @@ function readBrowserStack(value) {
1629
1651
  return stack;
1630
1652
  }
1631
1653
  /**
1632
- * Decodes a Runtime remote object's printable value.
1654
+ * Decodes a Runtime remote object's printable value, falling back to its unserializable form
1655
+ * and then its description, or `undefined` when it carries none.
1633
1656
  *
1634
1657
  * @param value - Unknown remote object
1635
1658
  * @returns By-value data or a description
@@ -1641,7 +1664,8 @@ function readBrowserRemoteValue(value) {
1641
1664
  if ((0, _orkestrel_contract.isString)(value["description"])) return value["description"];
1642
1665
  }
1643
1666
  /**
1644
- * Decodes one CDP `Runtime.evaluate` result.
1667
+ * Decodes one CDP `Runtime.evaluate` result, throwing a `BrowserError` on a failed evaluation
1668
+ * and a `BrowserResultLimitError` past the guarded result size.
1645
1669
  *
1646
1670
  * @param value - Unknown CDP result
1647
1671
  * @returns The returned by-value payload, or undefined
@@ -1677,13 +1701,12 @@ function requireBrowserString(value, field) {
1677
1701
  throw new BrowserError(`${field} failed: no string value returned`);
1678
1702
  }
1679
1703
  /**
1680
- * Normalizes a raw list of recorded codegen actions.
1704
+ * Normalizes recorded codegen actions, collapsing consecutive `fill` actions on the same
1705
+ * selector into the latest value.
1681
1706
  *
1682
1707
  * @remarks
1683
- * Collapses consecutive `fill` actions on the same selector into the latest
1684
- * value (a text input fires one `input` event per keystroke) so the
1685
- * compiled script reflects the final typed value rather than every
1686
- * intermediate keystroke.
1708
+ * A text input fires one `input` event per keystroke, so the compiled script reflects
1709
+ * the final typed value rather than every intermediate keystroke.
1687
1710
  *
1688
1711
  * @param actions - Raw recorded actions, in capture order
1689
1712
  * @returns Normalized actions, in the same order
@@ -1701,7 +1724,8 @@ function normalizeCodegenActions(actions) {
1701
1724
  return result;
1702
1725
  }
1703
1726
  /**
1704
- * Decodes a flattened CDP `Page.getFrameTree` result.
1727
+ * Decodes a flattened CDP `Page.getFrameTree` result into depth-first frame metadata, skipping
1728
+ * every off-shape frame.
1705
1729
  *
1706
1730
  * @param value - Unknown CDP result
1707
1731
  * @returns Frame metadata in depth-first, main-frame-first order
@@ -1730,7 +1754,8 @@ function readBrowserFrames(value) {
1730
1754
  return frames;
1731
1755
  }
1732
1756
  /**
1733
- * Decodes the first `DOM.getContentQuads` quad and its center.
1757
+ * Decodes the first `DOM.getContentQuads` quad and its center, throwing a `BrowserError`
1758
+ * off-shape.
1734
1759
  *
1735
1760
  * @param value - Unknown CDP result
1736
1761
  * @returns Decoded quad
@@ -1766,7 +1791,8 @@ function readBrowserQuad(value) {
1766
1791
  };
1767
1792
  }
1768
1793
  /**
1769
- * Extracts a keyboard chord such as `Control+Shift+P` into its parts.
1794
+ * Extracts a keyboard chord such as `Control+Shift+P` into its parts, throwing a
1795
+ * `BrowserError` on an empty chord or an unsupported modifier.
1770
1796
  *
1771
1797
  * @param value - Chord source
1772
1798
  * @returns Canonical modifiers and terminal key
@@ -1804,7 +1830,7 @@ function computeBrowserModifiers(modifiers) {
1804
1830
  /**
1805
1831
  * Computes the CDP Input pressed-button bitmask.
1806
1832
  *
1807
- * @param buttons - Currently pressed public mouse buttons
1833
+ * @param buttons - Pressed public mouse buttons
1808
1834
  * @returns Combined CDP pressed-button mask
1809
1835
  */
1810
1836
  function computeBrowserButtons(buttons) {
@@ -1944,7 +1970,8 @@ function keyToBrowserInput(value) {
1944
1970
  };
1945
1971
  }
1946
1972
  /**
1947
- * Decodes CDP snapshot sparse string data.
1973
+ * Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape
1974
+ * entry.
1948
1975
  *
1949
1976
  * @param value - Sparse `{ index, value }` record
1950
1977
  * @param strings - Snapshot string table
@@ -1964,7 +1991,8 @@ function readRareStringData(value, strings) {
1964
1991
  return decoded;
1965
1992
  }
1966
1993
  /**
1967
- * Decodes CDP snapshot sparse boolean data.
1994
+ * Decodes CDP snapshot sparse boolean data into a set of node indexes, skipping every
1995
+ * off-shape entry.
1968
1996
  *
1969
1997
  * @param value - Sparse `{ index }` record
1970
1998
  * @returns Set of node indexes whose value is true
@@ -1974,7 +2002,8 @@ function readRareBooleanData(value) {
1974
2002
  return new Set(parseNumberArray(value["index"]) ?? []);
1975
2003
  }
1976
2004
  /**
1977
- * Decodes CDP snapshot sparse integer data.
2005
+ * Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape
2006
+ * entry.
1978
2007
  *
1979
2008
  * @param value - Sparse `{ index, value }` record
1980
2009
  * @returns Node-index to integer map
@@ -1993,7 +2022,7 @@ function readRareIntegerData(value) {
1993
2022
  return decoded;
1994
2023
  }
1995
2024
  /**
1996
- * Decodes flattened CDP node attributes.
2025
+ * Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.
1997
2026
  *
1998
2027
  * @param value - Candidate string-index array
1999
2028
  * @param strings - Snapshot string table
@@ -2011,7 +2040,9 @@ function readBrowserAttributes(value, strings) {
2011
2040
  return Object.freeze(attributes);
2012
2041
  }
2013
2042
  /**
2014
- * Decodes a CDP `DOMSnapshot.captureSnapshot` result.
2043
+ * Decodes a CDP `DOMSnapshot.captureSnapshot` result into a serializable
2044
+ * `BrowserSnapshotInput`, throwing a `BrowserError` off-shape and a `BrowserResultLimitError`
2045
+ * past the configured node limit.
2015
2046
  *
2016
2047
  * @param value - Unknown CDP result
2017
2048
  * @param styles - Requested computed-style names, in protocol order
@@ -2140,7 +2171,7 @@ function readBrowserSnapshot(value, styles = [], limit = BROWSER_SNAPSHOT_NODE_L
2140
2171
  };
2141
2172
  }
2142
2173
  /**
2143
- * Tests whether a browser-node matcher is a declarative query.
2174
+ * Tests whether a browser-node matcher is a declarative query rather than a predicate.
2144
2175
  *
2145
2176
  * @param value - Browser-node query or predicate
2146
2177
  * @returns True if the matcher is a declarative query; false otherwise
@@ -2412,9 +2443,9 @@ function compileStorageClearExpression() {
2412
2443
  })()`;
2413
2444
  }
2414
2445
  /**
2415
- * Compiles a `Runtime.evaluate` expression so the IN-PAGE code stringifies
2416
- * its own result and throws a recognizable error before an oversized result
2417
- * would overflow the CDP transport frame.
2446
+ * Compiles a `Runtime.evaluate` expression so the in-page code stringifies its own result and
2447
+ * throws a recognizable sentinel error before an oversized result would overflow the CDP
2448
+ * transport frame.
2418
2449
  *
2419
2450
  * @remarks
2420
2451
  * A result whose `JSON.stringify` length exceeds `limit` throws
@@ -2439,7 +2470,7 @@ ${expression}
2439
2470
  ); const s = JSON.stringify(r); if (typeof s === 'string' && s.length > ${limit}) throw new Error(${JSON.stringify(BROWSER_RESULT_LIMIT_SENTINEL_PREFIX)} + s.length); return r })()`;
2440
2471
  }
2441
2472
  /**
2442
- * Compiles recorded codegen actions into a replayable script.
2473
+ * Compiles recorded codegen actions into a replayable JavaScript or TypeScript script.
2443
2474
  *
2444
2475
  * @remarks
2445
2476
  * Emits one statement per action against a `page` object shaped like
@@ -4071,7 +4102,7 @@ var BrowserTracing = class {
4071
4102
  //#endregion
4072
4103
  //#region src/core/BrowserDiagnostics.ts
4073
4104
  /**
4074
- * Groups the diagnostic subentities beneath one page.
4105
+ * Groups the tracing, coverage, performance, and profiler classes beneath one page.
4075
4106
  *
4076
4107
  * @example
4077
4108
  * ```ts
@@ -7372,7 +7403,7 @@ var BrowserContext = class {
7372
7403
  //#endregion
7373
7404
  //#region src/core/factories.ts
7374
7405
  /**
7375
- * Creates a CDP client bound to the given transport.
7406
+ * Creates a `CDPClientInterface` bound to the given `CDPTransportInterface`.
7376
7407
  *
7377
7408
  * @param options - The transport (and optional timeout) the client uses
7378
7409
  * @returns A {@link CDPClientInterface}
@@ -7389,7 +7420,7 @@ function createCDPClient(options) {
7389
7420
  return new CDPClient(options);
7390
7421
  }
7391
7422
  /**
7392
- * Creates a navigable browser snapshot from decoded serializable data.
7423
+ * Creates a navigable `BrowserSnapshotInterface` over decoded `BrowserSnapshotInput` data.
7393
7424
  *
7394
7425
  * @param input - Captured documents and computed-style names
7395
7426
  * @returns A {@link BrowserSnapshotInterface}