@orkestrel/browser 0.0.15 → 0.0.17

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.
@@ -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.17"
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
@@ -575,8 +595,8 @@ function parseBrowserWebSocketFrame(value) {
575
595
  */
576
596
  function parseBrowserBindingCall(value) {
577
597
  if (!(0, _orkestrel_contract.isRecord)(value) || !(0, _orkestrel_contract.isString)(value["name"]) || !(0, _orkestrel_contract.isString)(value["payload"]) || !(0, _orkestrel_contract.isInteger)(value["executionContextId"])) return;
578
- const payload = (0, _orkestrel_contract.parseJSON)(value["payload"]);
579
- if (!(0, _orkestrel_contract.isRecord)(payload) || !(0, _orkestrel_contract.isString)(payload["id"]) || !(0, _orkestrel_contract.isString)(payload["name"]) || !(0, _orkestrel_contract.isArray)(payload["args"]) || payload["name"] !== value["name"]) return;
598
+ const payload = (0, _orkestrel_contract.parseJSONAs)(value["payload"], _orkestrel_contract.isRecord);
599
+ if (payload === void 0 || !(0, _orkestrel_contract.isString)(payload["id"]) || !(0, _orkestrel_contract.isString)(payload["name"]) || !(0, _orkestrel_contract.isArray)(payload["args"]) || payload["name"] !== value["name"]) return;
580
600
  return {
581
601
  id: payload["id"],
582
602
  name: payload["name"],
@@ -702,8 +722,8 @@ function parseBrowserDownloadProgress(value) {
702
722
  */
703
723
  function parseCodegenActionPayload(payload) {
704
724
  if (!(0, _orkestrel_contract.isString)(payload)) return void 0;
705
- const parsed = (0, _orkestrel_contract.parseJSON)(payload);
706
- if (!(0, _orkestrel_contract.isRecord)(parsed)) return void 0;
725
+ const parsed = (0, _orkestrel_contract.parseJSONAs)(payload, _orkestrel_contract.isRecord);
726
+ if (parsed === void 0) return void 0;
707
727
  const action = (0, _orkestrel_contract.parseEnum)(parsed["action"], [
708
728
  "click",
709
729
  "fill",
@@ -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
@@ -757,8 +777,7 @@ function parseCodegenNavigateAction(params) {
757
777
  * @returns The number array, or undefined
758
778
  */
759
779
  function parseNumberArray(value) {
760
- if (!(0, _orkestrel_contract.isArray)(value) || !value.every(_orkestrel_contract.isFiniteNumber)) return;
761
- return value;
780
+ return (0, _orkestrel_contract.parseArray)(value, _orkestrel_contract.isFiniteNumber);
762
781
  }
763
782
  /**
764
783
  * Coerces one CDP snapshot string-table index to its string, or `undefined`
@@ -773,8 +792,7 @@ function parseSnapshotString(strings, index) {
773
792
  return strings[index];
774
793
  }
775
794
  /**
776
- * Coerces a CDP snapshot rectangle to a `BrowserRect`, or `undefined`
777
- * off-shape.
795
+ * Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.
778
796
  *
779
797
  * @param value - Candidate four-number array
780
798
  * @returns A rectangle, or undefined
@@ -871,7 +889,8 @@ function browserHeadersToProtocol(headers) {
871
889
  }));
872
890
  }
873
891
  /**
874
- * Decodes a Chromium Headers object into string values.
892
+ * Decodes a Chromium Headers object into string values, skipping every entry that is neither a
893
+ * string nor a finite number.
875
894
  *
876
895
  * @param value - Unknown headers
877
896
  * @returns Frozen-compatible header record
@@ -1056,7 +1075,8 @@ function matchesBrowserURL(url, pattern) {
1056
1075
  return new RegExp(`^${source}$`).test(url);
1057
1076
  }
1058
1077
  /**
1059
- * Decodes the `Page.addScriptToEvaluateOnNewDocument` result.
1078
+ * Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`
1079
+ * off-shape.
1060
1080
  *
1061
1081
  * @param value - Unknown protocol result
1062
1082
  * @returns Script identifier
@@ -1074,7 +1094,7 @@ function validateBrowserPoint(point) {
1074
1094
  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
1095
  }
1076
1096
  /**
1077
- * Validates the bounded keys of one trusted-input operation.
1097
+ * Validates the bounded delay, count, steps, and position of one trusted-input operation.
1078
1098
  *
1079
1099
  * @remarks
1080
1100
  * The parameter is `BrowserOperationOptions`, so one validator answers for a
@@ -1240,7 +1260,8 @@ function validateBrowserRange(value, field, minimum, maximum, inclusive = true)
1240
1260
  });
1241
1261
  }
1242
1262
  /**
1243
- * Decodes Accessibility-domain nodes into a flat serializable tree.
1263
+ * Decodes Accessibility-domain nodes into a flat serializable tree, throwing a `BrowserError`
1264
+ * off-shape.
1244
1265
  *
1245
1266
  * @param value - Unknown full or partial AX-tree result
1246
1267
  * @returns Valid accessibility snapshot
@@ -1276,7 +1297,7 @@ function readBrowserAccessibility(value) {
1276
1297
  };
1277
1298
  }
1278
1299
  /**
1279
- * Decodes an Accessibility-domain AXValue.
1300
+ * Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.
1280
1301
  *
1281
1302
  * @param value - Unknown AX value
1282
1303
  * @returns Underlying value
@@ -1301,7 +1322,7 @@ function concatBytes(chunks) {
1301
1322
  return result;
1302
1323
  }
1303
1324
  /**
1304
- * Decodes one `IO.read` response.
1325
+ * Decodes one `IO.read` response, throwing a `BrowserError` off-shape.
1305
1326
  *
1306
1327
  * @param value - Unknown protocol result
1307
1328
  * @returns Valid stream chunk
@@ -1314,7 +1335,7 @@ function readBrowserStreamChunk(value) {
1314
1335
  };
1315
1336
  }
1316
1337
  /**
1317
- * Decodes JavaScript precise coverage.
1338
+ * Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.
1318
1339
  *
1319
1340
  * @param value - Unknown `Profiler.takePreciseCoverage` result
1320
1341
  * @returns Script coverage
@@ -1342,7 +1363,7 @@ function readBrowserScriptCoverage(value) {
1342
1363
  });
1343
1364
  }
1344
1365
  /**
1345
- * Decodes CSS rule usage.
1366
+ * Decodes CSS rule usage, throwing a `BrowserError` off-shape.
1346
1367
  *
1347
1368
  * @param value - Unknown `CSS.stopRuleUsageTracking` result
1348
1369
  * @returns Stylesheet coverage
@@ -1366,7 +1387,7 @@ function readBrowserStyleCoverage(value) {
1366
1387
  }));
1367
1388
  }
1368
1389
  /**
1369
- * Decodes coverage ranges.
1390
+ * Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.
1370
1391
  *
1371
1392
  * @param value - Unknown ranges
1372
1393
  * @param script - Script index for diagnostics
@@ -1387,7 +1408,7 @@ function readBrowserCoverageRanges(value, script) {
1387
1408
  });
1388
1409
  }
1389
1410
  /**
1390
- * Decodes Performance-domain metrics.
1411
+ * Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.
1391
1412
  *
1392
1413
  * @param value - Unknown metrics result
1393
1414
  * @returns Valid metrics
@@ -1403,7 +1424,7 @@ function readBrowserMetrics(value) {
1403
1424
  });
1404
1425
  }
1405
1426
  /**
1406
- * Decodes one CPU profile.
1427
+ * Decodes one CPU profile, throwing a `BrowserError` off-shape.
1407
1428
  *
1408
1429
  * @param value - Unknown `Profiler.stop` result
1409
1430
  * @returns Valid profile
@@ -1436,7 +1457,7 @@ function readBrowserProfile(value) {
1436
1457
  };
1437
1458
  }
1438
1459
  /**
1439
- * Decodes a CPU profile call frame.
1460
+ * Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.
1440
1461
  *
1441
1462
  * @param value - Unknown call frame
1442
1463
  * @param node - Node index for diagnostics
@@ -1488,7 +1509,7 @@ function cookieToProtocol(cookie) {
1488
1509
  return result;
1489
1510
  }
1490
1511
  /**
1491
- * Decodes cookies returned by `Storage.getCookies`.
1512
+ * Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.
1492
1513
  *
1493
1514
  * @param value - Unknown protocol result
1494
1515
  * @returns Valid cookies
@@ -1498,7 +1519,7 @@ function readBrowserCookies(value) {
1498
1519
  return value["cookies"].map((candidate, index) => readBrowserCookie(candidate, index));
1499
1520
  }
1500
1521
  /**
1501
- * Decodes one Chromium cookie.
1522
+ * Decodes one Chromium cookie, throwing a `BrowserError` off-shape.
1502
1523
  *
1503
1524
  * @param value - Unknown cookie record
1504
1525
  * @param index - Source array position for diagnostics
@@ -1542,7 +1563,7 @@ function matchesBrowserCookieURL(cookie, value) {
1542
1563
  return domainMatches && pathMatches && secureMatches;
1543
1564
  }
1544
1565
  /**
1545
- * Decodes one in-page web-storage snapshot.
1566
+ * Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.
1546
1567
  *
1547
1568
  * @param value - Unknown evaluation result
1548
1569
  * @param origin - Origin represented by the result
@@ -1557,7 +1578,7 @@ function readBrowserStorageOrigin(value, origin) {
1557
1578
  };
1558
1579
  }
1559
1580
  /**
1560
- * Decodes a list of web-storage entries.
1581
+ * Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.
1561
1582
  *
1562
1583
  * @param value - Unknown entry list
1563
1584
  * @param origin - Origin used for diagnostics
@@ -1608,7 +1629,7 @@ function mediaToFeatures(media) {
1608
1629
  return features;
1609
1630
  }
1610
1631
  /**
1611
- * Decodes a Chromium runtime stack trace.
1632
+ * Decodes a Chromium runtime stack trace, skipping every off-shape call frame.
1612
1633
  *
1613
1634
  * @param value - Unknown stack trace or call-frame list
1614
1635
  * @returns Valid stack frames
@@ -1629,7 +1650,8 @@ function readBrowserStack(value) {
1629
1650
  return stack;
1630
1651
  }
1631
1652
  /**
1632
- * Decodes a Runtime remote object's printable value.
1653
+ * Decodes a Runtime remote object's printable value, falling back to its unserializable form
1654
+ * and then its description, or `undefined` when it carries none.
1633
1655
  *
1634
1656
  * @param value - Unknown remote object
1635
1657
  * @returns By-value data or a description
@@ -1641,7 +1663,8 @@ function readBrowserRemoteValue(value) {
1641
1663
  if ((0, _orkestrel_contract.isString)(value["description"])) return value["description"];
1642
1664
  }
1643
1665
  /**
1644
- * Decodes one CDP `Runtime.evaluate` result.
1666
+ * Decodes one CDP `Runtime.evaluate` result, throwing a `BrowserError` on a failed evaluation
1667
+ * and a `BrowserResultLimitError` past the guarded result size.
1645
1668
  *
1646
1669
  * @param value - Unknown CDP result
1647
1670
  * @returns The returned by-value payload, or undefined
@@ -1677,13 +1700,12 @@ function requireBrowserString(value, field) {
1677
1700
  throw new BrowserError(`${field} failed: no string value returned`);
1678
1701
  }
1679
1702
  /**
1680
- * Normalizes a raw list of recorded codegen actions.
1703
+ * Normalizes recorded codegen actions, collapsing consecutive `fill` actions on the same
1704
+ * selector into the latest value.
1681
1705
  *
1682
1706
  * @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.
1707
+ * A text input fires one `input` event per keystroke, so the compiled script reflects
1708
+ * the final typed value rather than every intermediate keystroke.
1687
1709
  *
1688
1710
  * @param actions - Raw recorded actions, in capture order
1689
1711
  * @returns Normalized actions, in the same order
@@ -1701,7 +1723,8 @@ function normalizeCodegenActions(actions) {
1701
1723
  return result;
1702
1724
  }
1703
1725
  /**
1704
- * Decodes a flattened CDP `Page.getFrameTree` result.
1726
+ * Decodes a flattened CDP `Page.getFrameTree` result into depth-first frame metadata, skipping
1727
+ * every off-shape frame.
1705
1728
  *
1706
1729
  * @param value - Unknown CDP result
1707
1730
  * @returns Frame metadata in depth-first, main-frame-first order
@@ -1730,7 +1753,8 @@ function readBrowserFrames(value) {
1730
1753
  return frames;
1731
1754
  }
1732
1755
  /**
1733
- * Decodes the first `DOM.getContentQuads` quad and its center.
1756
+ * Decodes the first `DOM.getContentQuads` quad and its center, throwing a `BrowserError`
1757
+ * off-shape.
1734
1758
  *
1735
1759
  * @param value - Unknown CDP result
1736
1760
  * @returns Decoded quad
@@ -1766,7 +1790,8 @@ function readBrowserQuad(value) {
1766
1790
  };
1767
1791
  }
1768
1792
  /**
1769
- * Extracts a keyboard chord such as `Control+Shift+P` into its parts.
1793
+ * Extracts a keyboard chord such as `Control+Shift+P` into its parts, throwing a
1794
+ * `BrowserError` on an empty chord or an unsupported modifier.
1770
1795
  *
1771
1796
  * @param value - Chord source
1772
1797
  * @returns Canonical modifiers and terminal key
@@ -1804,7 +1829,7 @@ function computeBrowserModifiers(modifiers) {
1804
1829
  /**
1805
1830
  * Computes the CDP Input pressed-button bitmask.
1806
1831
  *
1807
- * @param buttons - Currently pressed public mouse buttons
1832
+ * @param buttons - Pressed public mouse buttons
1808
1833
  * @returns Combined CDP pressed-button mask
1809
1834
  */
1810
1835
  function computeBrowserButtons(buttons) {
@@ -1944,7 +1969,8 @@ function keyToBrowserInput(value) {
1944
1969
  };
1945
1970
  }
1946
1971
  /**
1947
- * Decodes CDP snapshot sparse string data.
1972
+ * Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape
1973
+ * entry.
1948
1974
  *
1949
1975
  * @param value - Sparse `{ index, value }` record
1950
1976
  * @param strings - Snapshot string table
@@ -1964,7 +1990,8 @@ function readRareStringData(value, strings) {
1964
1990
  return decoded;
1965
1991
  }
1966
1992
  /**
1967
- * Decodes CDP snapshot sparse boolean data.
1993
+ * Decodes CDP snapshot sparse boolean data into a set of node indexes, skipping every
1994
+ * off-shape entry.
1968
1995
  *
1969
1996
  * @param value - Sparse `{ index }` record
1970
1997
  * @returns Set of node indexes whose value is true
@@ -1974,7 +2001,8 @@ function readRareBooleanData(value) {
1974
2001
  return new Set(parseNumberArray(value["index"]) ?? []);
1975
2002
  }
1976
2003
  /**
1977
- * Decodes CDP snapshot sparse integer data.
2004
+ * Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape
2005
+ * entry.
1978
2006
  *
1979
2007
  * @param value - Sparse `{ index, value }` record
1980
2008
  * @returns Node-index to integer map
@@ -1993,7 +2021,7 @@ function readRareIntegerData(value) {
1993
2021
  return decoded;
1994
2022
  }
1995
2023
  /**
1996
- * Decodes flattened CDP node attributes.
2024
+ * Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.
1997
2025
  *
1998
2026
  * @param value - Candidate string-index array
1999
2027
  * @param strings - Snapshot string table
@@ -2011,7 +2039,9 @@ function readBrowserAttributes(value, strings) {
2011
2039
  return Object.freeze(attributes);
2012
2040
  }
2013
2041
  /**
2014
- * Decodes a CDP `DOMSnapshot.captureSnapshot` result.
2042
+ * Decodes a CDP `DOMSnapshot.captureSnapshot` result into a serializable
2043
+ * `BrowserSnapshotInput`, throwing a `BrowserError` off-shape and a `BrowserResultLimitError`
2044
+ * past the configured node limit.
2015
2045
  *
2016
2046
  * @param value - Unknown CDP result
2017
2047
  * @param styles - Requested computed-style names, in protocol order
@@ -2021,8 +2051,8 @@ function readBrowserAttributes(value, strings) {
2021
2051
  function readBrowserSnapshot(value, styles = [], limit = BROWSER_SNAPSHOT_NODE_LIMIT) {
2022
2052
  if (!(0, _orkestrel_contract.isInteger)(limit) || limit < 0) throw new BrowserError("Browser snapshot limit must be a non-negative integer", void 0, { limit });
2023
2053
  if (!(0, _orkestrel_contract.isRecord)(value) || !(0, _orkestrel_contract.isArray)(value["strings"]) || !(0, _orkestrel_contract.isArray)(value["documents"])) throw new BrowserError("Malformed DOMSnapshot.captureSnapshot result");
2024
- if (!value["strings"].every(_orkestrel_contract.isString)) throw new BrowserError("Malformed DOMSnapshot string table");
2025
- const strings = value["strings"];
2054
+ const strings = (0, _orkestrel_contract.parseArray)(value["strings"], _orkestrel_contract.isString);
2055
+ if (strings === void 0) throw new BrowserError("Malformed DOMSnapshot string table");
2026
2056
  let count = 0;
2027
2057
  for (const document of value["documents"]) {
2028
2058
  if (!(0, _orkestrel_contract.isRecord)(document) || !(0, _orkestrel_contract.isRecord)(document["nodes"])) continue;
@@ -2140,7 +2170,7 @@ function readBrowserSnapshot(value, styles = [], limit = BROWSER_SNAPSHOT_NODE_L
2140
2170
  };
2141
2171
  }
2142
2172
  /**
2143
- * Tests whether a browser-node matcher is a declarative query.
2173
+ * Tests whether a browser-node matcher is a declarative query rather than a predicate.
2144
2174
  *
2145
2175
  * @param value - Browser-node query or predicate
2146
2176
  * @returns True if the matcher is a declarative query; false otherwise
@@ -2412,9 +2442,9 @@ function compileStorageClearExpression() {
2412
2442
  })()`;
2413
2443
  }
2414
2444
  /**
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.
2445
+ * Compiles a `Runtime.evaluate` expression so the in-page code stringifies its own result and
2446
+ * throws a recognizable sentinel error before an oversized result would overflow the CDP
2447
+ * transport frame.
2418
2448
  *
2419
2449
  * @remarks
2420
2450
  * A result whose `JSON.stringify` length exceeds `limit` throws
@@ -2439,7 +2469,7 @@ ${expression}
2439
2469
  ); 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
2470
  }
2441
2471
  /**
2442
- * Compiles recorded codegen actions into a replayable script.
2472
+ * Compiles recorded codegen actions into a replayable JavaScript or TypeScript script.
2443
2473
  *
2444
2474
  * @remarks
2445
2475
  * Emits one statement per action against a `page` object shaped like
@@ -4071,7 +4101,7 @@ var BrowserTracing = class {
4071
4101
  //#endregion
4072
4102
  //#region src/core/BrowserDiagnostics.ts
4073
4103
  /**
4074
- * Groups the diagnostic subentities beneath one page.
4104
+ * Groups the tracing, coverage, performance, and profiler classes beneath one page.
4075
4105
  *
4076
4106
  * @example
4077
4107
  * ```ts
@@ -4705,8 +4735,9 @@ var BrowserLocator = class BrowserLocator {
4705
4735
  }
4706
4736
  async texts() {
4707
4737
  const value = await this.#frame.evaluate(`(${compileLocatorListExpression(this.#query)}).map((element) => element.innerText)`);
4708
- if (!(0, _orkestrel_contract.isArray)(value) || !value.every(_orkestrel_contract.isString)) throw new BrowserError("Browser locator text list is malformed");
4709
- return value;
4738
+ const texts = (0, _orkestrel_contract.parseArray)(value, _orkestrel_contract.isString);
4739
+ if (texts === void 0) throw new BrowserError("Browser locator text list is malformed");
4740
+ return texts;
4710
4741
  }
4711
4742
  async html() {
4712
4743
  return await this.#string("outerHTML", "Browser locator HTML");
@@ -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}