@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 +14 -18
- package/dist/src/core/index.cjs +122 -91
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +463 -102
- package/dist/src/core/index.d.ts +463 -102
- package/dist/src/core/index.js +122 -91
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +93 -31
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +154 -56
- package/dist/src/server/index.d.ts +154 -56
- package/dist/src/server/index.js +93 -31
- package/dist/src/server/index.js.map +1 -1
- package/package.json +16 -17
package/dist/src/core/index.js
CHANGED
|
@@ -71,14 +71,17 @@ var BASE64_LOOKUP = Object.freeze({
|
|
|
71
71
|
"+": 62,
|
|
72
72
|
"/": 63
|
|
73
73
|
});
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Sets the default timeout for browser connection, requests, and navigation, `30_000`
|
|
76
|
+
* milliseconds.
|
|
77
|
+
*/
|
|
75
78
|
var BROWSER_DEFAULT_TIMEOUT_MS = 3e4;
|
|
76
79
|
/**
|
|
77
|
-
* Caps the serialized-character length for an `evaluate()`/`content()` result
|
|
78
|
-
* enforced
|
|
80
|
+
* Caps the serialized-character length for an `evaluate()`/`content()` result at `2_500_000`,
|
|
81
|
+
* enforced in-page before the result is returned to CDP.
|
|
79
82
|
*
|
|
80
83
|
* @remarks
|
|
81
|
-
* This counts UTF-16
|
|
84
|
+
* This counts UTF-16 string length (`String#length`), not transport bytes —
|
|
82
85
|
* the actual CDP frame is UTF-8 encoded (up to 3 bytes/char for common
|
|
83
86
|
* multibyte content) and carries additional JSON/CDP framing overhead on top
|
|
84
87
|
* of the raw content. A `Runtime.evaluate` result above this size, once
|
|
@@ -94,8 +97,8 @@ var BROWSER_DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
94
97
|
*/
|
|
95
98
|
var BROWSER_RESULT_LIMIT = 25e5;
|
|
96
99
|
/**
|
|
97
|
-
* Names the distinctive prefix for the in-page result-limit sentinel error,
|
|
98
|
-
* followed by the serialized length.
|
|
100
|
+
* Names the distinctive prefix for the in-page result-limit sentinel error,
|
|
101
|
+
* `'[[ORKESTREL_BROWSER_RESULT_LIMIT]]'`, immediately followed by the serialized length.
|
|
99
102
|
*
|
|
100
103
|
* @remarks
|
|
101
104
|
* Deliberately unlikely to appear in a page's own thrown error text (unlike
|
|
@@ -105,18 +108,29 @@ var BROWSER_RESULT_LIMIT = 25e5;
|
|
|
105
108
|
*/
|
|
106
109
|
var BROWSER_RESULT_LIMIT_SENTINEL_PREFIX = "[[ORKESTREL_BROWSER_RESULT_LIMIT]]";
|
|
107
110
|
/**
|
|
108
|
-
* Matches the in-page result-limit sentinel error message, anchored
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
111
|
+
* Matches the in-page result-limit sentinel error message, anchored immediately after the
|
|
112
|
+
* `Error:` (optionally `Uncaught Error:`) prefix Chromium prepends to a thrown error's
|
|
113
|
+
* description, `/^(?:Uncaught )?Error: \[\[ORKESTREL_BROWSER_RESULT_LIMIT\]\](\d+)/`.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* The anchor matches the guard's own throw only at the start of the message, rather than
|
|
117
|
+
* wherever the substring happens to occur.
|
|
113
118
|
*/
|
|
114
119
|
var BROWSER_RESULT_LIMIT_PATTERN = new RegExp(`^(?:Uncaught )?Error: \\[\\[ORKESTREL_BROWSER_RESULT_LIMIT\\]\\](\\d+)`);
|
|
115
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Sets the poll interval while waiting for a selector to appear, `100` milliseconds.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* A wait adds the same interval as slack to its own CDP call timeout, so the in-page poll
|
|
125
|
+
* expires before the call carrying it. Host-side CDP readiness probes wait it out between
|
|
126
|
+
* attempts.
|
|
127
|
+
*/
|
|
116
128
|
var BROWSER_WAIT_POLL_INTERVAL_MS = 100;
|
|
117
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.
|
|
131
|
+
*/
|
|
118
132
|
var BROWSER_SNAPSHOT_NODE_LIMIT = 1e5;
|
|
119
|
-
/** Names the isolated world used for iframe evaluation
|
|
133
|
+
/** Names the isolated world used for iframe evaluation, `'__orkestrelBrowserFrame'`. */
|
|
120
134
|
var BROWSER_FRAME_WORLD_NAME = "__orkestrelBrowserFrame";
|
|
121
135
|
/** Names the attribute the semantic test-id selector uses. */
|
|
122
136
|
var BROWSER_TEST_ID_ATTRIBUTE = "data-testid";
|
|
@@ -157,13 +171,13 @@ var BROWSER_MOUSE_BUTTON_MASKS = Object.freeze({
|
|
|
157
171
|
*/
|
|
158
172
|
var BROWSER_HAR_CREATOR = Object.freeze({
|
|
159
173
|
name: "@orkestrel/browser",
|
|
160
|
-
version: "0.0.
|
|
174
|
+
version: "0.0.16"
|
|
161
175
|
});
|
|
162
176
|
/** Names the attribute that tags temporary screenshot styles and masks. */
|
|
163
177
|
var BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
|
|
164
178
|
/**
|
|
165
|
-
* Bounds
|
|
166
|
-
*
|
|
179
|
+
* Bounds the best-effort `Page.stopLoading` call issued after a failed `navigate()` at `1_000`
|
|
180
|
+
* milliseconds.
|
|
167
181
|
*
|
|
168
182
|
* @remarks
|
|
169
183
|
* A wedged renderer can make the underlying CDP call hang for the full
|
|
@@ -172,23 +186,26 @@ var BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
|
|
|
172
186
|
* it. Best-effort only — never masks the original navigate error.
|
|
173
187
|
*/
|
|
174
188
|
var BROWSER_STOP_LOADING_TIMEOUT_MS = 1e3;
|
|
175
|
-
/** Sets the default viewport width
|
|
189
|
+
/** Sets the default viewport width, `1280` pixels. */
|
|
176
190
|
var BROWSER_DEFAULT_VIEWPORT_WIDTH = 1280;
|
|
177
|
-
/** Sets the default viewport height
|
|
191
|
+
/** Sets the default viewport height, `720` pixels. */
|
|
178
192
|
var BROWSER_DEFAULT_VIEWPORT_HEIGHT = 720;
|
|
179
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Names the CDP runtime binding the codegen recorder script calls into,
|
|
195
|
+
* `'__orkestrelBrowserCodegen'`.
|
|
196
|
+
*/
|
|
180
197
|
var BROWSER_CODEGEN_BINDING_NAME = "__orkestrelBrowserCodegen";
|
|
181
198
|
/**
|
|
182
199
|
* Holds the in-page recorder script injected through `Page.addScriptToEvaluateOnNewDocument`
|
|
183
200
|
* and `Runtime.evaluate`.
|
|
184
201
|
*
|
|
185
202
|
* @remarks
|
|
186
|
-
* Attaches capturing-phase listeners for `click`, `input` (fill), and
|
|
187
|
-
* `
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* install exactly once per document (`window[name]` sentinel) so
|
|
191
|
-
* injection on every new document is idempotent.
|
|
203
|
+
* Attaches capturing-phase listeners for `click`, `input` (fill), and `change` (select) on
|
|
204
|
+
* `document`, builds a stable CSS selector for the target element, and forwards each action
|
|
205
|
+
* to the CDP binding ({@link BROWSER_CODEGEN_BINDING_NAME}) as a JSON string payload. A
|
|
206
|
+
* `contenteditable` fill is captured through `input` events, the same way an input or a
|
|
207
|
+
* textarea is. Guarded to install exactly once per document (`window[name]` sentinel) so
|
|
208
|
+
* repeated injection on every new document is idempotent.
|
|
192
209
|
*/
|
|
193
210
|
var BROWSER_CODEGEN_SOURCE = `(() => {
|
|
194
211
|
const bindingName = ${JSON.stringify(BROWSER_CODEGEN_BINDING_NAME)}
|
|
@@ -281,11 +298,11 @@ var BROWSER_CODEGEN_SOURCE = `(() => {
|
|
|
281
298
|
//#endregion
|
|
282
299
|
//#region src/core/errors.ts
|
|
283
300
|
/**
|
|
284
|
-
* Represents the base error for all browser automation operations
|
|
301
|
+
* Represents the base error for all browser automation operations, carrying the code
|
|
302
|
+
* `BROWSER_ERROR` and a `context` record.
|
|
285
303
|
*
|
|
286
304
|
* @remarks
|
|
287
|
-
*
|
|
288
|
-
* callers can branch in a `catch` without parsing message strings.
|
|
305
|
+
* A caller branches in a `catch` on the `code` rather than parsing message strings.
|
|
289
306
|
*/
|
|
290
307
|
var BrowserError = class extends Error {
|
|
291
308
|
code;
|
|
@@ -298,7 +315,8 @@ var BrowserError = class extends Error {
|
|
|
298
315
|
}
|
|
299
316
|
};
|
|
300
317
|
/**
|
|
301
|
-
* Reports that a selector-based lookup or wait timed out without the element appearing
|
|
318
|
+
* Reports that a selector-based lookup or wait timed out without the element appearing, under
|
|
319
|
+
* the code `BROWSER_SELECTOR_ERROR`.
|
|
302
320
|
*/
|
|
303
321
|
var BrowserSelectorError = class extends BrowserError {
|
|
304
322
|
constructor(message, context) {
|
|
@@ -307,12 +325,12 @@ var BrowserSelectorError = class extends BrowserError {
|
|
|
307
325
|
}
|
|
308
326
|
};
|
|
309
327
|
/**
|
|
310
|
-
* Reports that a CDP request received an error response from the remote endpoint
|
|
328
|
+
* Reports that a CDP request received an error response from the remote endpoint, under the
|
|
329
|
+
* code `BROWSER_CDP_ERROR`, with the `method`, the CDP `code`, the `message`, and any `data`
|
|
330
|
+
* in its context.
|
|
311
331
|
*
|
|
312
332
|
* @remarks
|
|
313
|
-
*
|
|
314
|
-
* `message`, and `data` (when present) in `context`, so callers can branch
|
|
315
|
-
* on the protocol-level error instead of parsing the message string.
|
|
333
|
+
* Branch on the protocol-level error in `context` instead of parsing the message string.
|
|
316
334
|
*/
|
|
317
335
|
var CDPError = class extends BrowserError {
|
|
318
336
|
constructor(message, context) {
|
|
@@ -321,9 +339,9 @@ var CDPError = class extends BrowserError {
|
|
|
321
339
|
}
|
|
322
340
|
};
|
|
323
341
|
/**
|
|
324
|
-
* Reports that a CDP request could not be sent or completed because the client was not in
|
|
325
|
-
*
|
|
326
|
-
*
|
|
342
|
+
* Reports that a CDP request could not be sent or completed because the client was not in a
|
|
343
|
+
* connectable state — not connected, closed while connecting, or the connection dropped
|
|
344
|
+
* mid-request — under the code `BROWSER_CDP_CONNECTION_ERROR`.
|
|
327
345
|
*/
|
|
328
346
|
var CDPConnectionError = class extends BrowserError {
|
|
329
347
|
constructor(message, context) {
|
|
@@ -332,7 +350,8 @@ var CDPConnectionError = class extends BrowserError {
|
|
|
332
350
|
}
|
|
333
351
|
};
|
|
334
352
|
/**
|
|
335
|
-
* Reports that a pending CDP request was not answered within its timeout window
|
|
353
|
+
* Reports that a pending CDP request was not answered within its timeout window, under the
|
|
354
|
+
* code `BROWSER_CDP_TIMEOUT_ERROR`.
|
|
336
355
|
*/
|
|
337
356
|
var CDPTimeoutError = class extends BrowserError {
|
|
338
357
|
constructor(message, context) {
|
|
@@ -341,8 +360,9 @@ var CDPTimeoutError = class extends BrowserError {
|
|
|
341
360
|
}
|
|
342
361
|
};
|
|
343
362
|
/**
|
|
344
|
-
* Reports that an `evaluate()`/`content()` result exceeded {@link BROWSER_RESULT_LIMIT}
|
|
345
|
-
*
|
|
363
|
+
* Reports that an `evaluate()`/`content()` result exceeded {@link BROWSER_RESULT_LIMIT} and
|
|
364
|
+
* was rejected in-page before it could overflow the CDP transport frame, under the code
|
|
365
|
+
* `BROWSER_RESULT_LIMIT_ERROR`.
|
|
346
366
|
*/
|
|
347
367
|
var BrowserResultLimitError = class extends BrowserError {
|
|
348
368
|
constructor(message, context) {
|
|
@@ -351,7 +371,7 @@ var BrowserResultLimitError = class extends BrowserError {
|
|
|
351
371
|
}
|
|
352
372
|
};
|
|
353
373
|
/**
|
|
354
|
-
* Narrows an unknown value to BrowserError
|
|
374
|
+
* Narrows an unknown value to a `BrowserError`.
|
|
355
375
|
*
|
|
356
376
|
* @param value - Value to check
|
|
357
377
|
* @returns True if value is a BrowserError instance; false otherwise
|
|
@@ -360,7 +380,7 @@ function isBrowserError(value) {
|
|
|
360
380
|
return isInstance(value, BrowserError);
|
|
361
381
|
}
|
|
362
382
|
/**
|
|
363
|
-
* Narrows an unknown value to BrowserSelectorError
|
|
383
|
+
* Narrows an unknown value to a `BrowserSelectorError`.
|
|
364
384
|
*
|
|
365
385
|
* @param value - Value to check
|
|
366
386
|
* @returns True if value is a BrowserSelectorError instance; false otherwise
|
|
@@ -369,7 +389,7 @@ function isBrowserSelectorError(value) {
|
|
|
369
389
|
return isInstance(value, BrowserSelectorError);
|
|
370
390
|
}
|
|
371
391
|
/**
|
|
372
|
-
* Narrows an unknown value to CDPError
|
|
392
|
+
* Narrows an unknown value to a `CDPError`.
|
|
373
393
|
*
|
|
374
394
|
* @param value - Value to check
|
|
375
395
|
* @returns True if value is a CDPError instance; false otherwise
|
|
@@ -378,7 +398,7 @@ function isCDPError(value) {
|
|
|
378
398
|
return isInstance(value, CDPError);
|
|
379
399
|
}
|
|
380
400
|
/**
|
|
381
|
-
* Narrows an unknown value to CDPConnectionError
|
|
401
|
+
* Narrows an unknown value to a `CDPConnectionError`.
|
|
382
402
|
*
|
|
383
403
|
* @param value - Value to check
|
|
384
404
|
* @returns True if value is a CDPConnectionError instance; false otherwise
|
|
@@ -387,7 +407,7 @@ function isCDPConnectionError(value) {
|
|
|
387
407
|
return isInstance(value, CDPConnectionError);
|
|
388
408
|
}
|
|
389
409
|
/**
|
|
390
|
-
* Narrows an unknown value to CDPTimeoutError
|
|
410
|
+
* Narrows an unknown value to a `CDPTimeoutError`.
|
|
391
411
|
*
|
|
392
412
|
* @param value - Value to check
|
|
393
413
|
* @returns True if value is a CDPTimeoutError instance; false otherwise
|
|
@@ -396,7 +416,7 @@ function isCDPTimeoutError(value) {
|
|
|
396
416
|
return isInstance(value, CDPTimeoutError);
|
|
397
417
|
}
|
|
398
418
|
/**
|
|
399
|
-
* Narrows an unknown value to BrowserResultLimitError
|
|
419
|
+
* Narrows an unknown value to a `BrowserResultLimitError`.
|
|
400
420
|
*
|
|
401
421
|
* @param value - Value to check
|
|
402
422
|
* @returns True if value is a BrowserResultLimitError instance; false otherwise
|
|
@@ -728,8 +748,8 @@ function parseCodegenActionPayload(payload) {
|
|
|
728
748
|
}
|
|
729
749
|
}
|
|
730
750
|
/**
|
|
731
|
-
* Coerces a `Page.frameNavigated` CDP event to a `navigate` codegen action, or
|
|
732
|
-
*
|
|
751
|
+
* Coerces a `Page.frameNavigated` CDP event to a `navigate` codegen action, or `undefined`
|
|
752
|
+
* off-shape and for every frame but the top-level one.
|
|
733
753
|
*
|
|
734
754
|
* @remarks
|
|
735
755
|
* Only the top-level (main) frame's navigation is recorded — a frame
|
|
@@ -772,8 +792,7 @@ function parseSnapshotString(strings, index) {
|
|
|
772
792
|
return strings[index];
|
|
773
793
|
}
|
|
774
794
|
/**
|
|
775
|
-
* Coerces a
|
|
776
|
-
* off-shape.
|
|
795
|
+
* Coerces a four-number CSS-pixel rectangle to a `BrowserRect`, or `undefined` off-shape.
|
|
777
796
|
*
|
|
778
797
|
* @param value - Candidate four-number array
|
|
779
798
|
* @returns A rectangle, or undefined
|
|
@@ -870,7 +889,8 @@ function browserHeadersToProtocol(headers) {
|
|
|
870
889
|
}));
|
|
871
890
|
}
|
|
872
891
|
/**
|
|
873
|
-
* 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.
|
|
874
894
|
*
|
|
875
895
|
* @param value - Unknown headers
|
|
876
896
|
* @returns Frozen-compatible header record
|
|
@@ -1055,7 +1075,8 @@ function matchesBrowserURL(url, pattern) {
|
|
|
1055
1075
|
return new RegExp(`^${source}$`).test(url);
|
|
1056
1076
|
}
|
|
1057
1077
|
/**
|
|
1058
|
-
* Decodes the `Page.addScriptToEvaluateOnNewDocument` result
|
|
1078
|
+
* Decodes the `Page.addScriptToEvaluateOnNewDocument` result, throwing a `BrowserError`
|
|
1079
|
+
* off-shape.
|
|
1059
1080
|
*
|
|
1060
1081
|
* @param value - Unknown protocol result
|
|
1061
1082
|
* @returns Script identifier
|
|
@@ -1073,7 +1094,7 @@ function validateBrowserPoint(point) {
|
|
|
1073
1094
|
if (!isFiniteNumber(point.x) || !isFiniteNumber(point.y)) throw new BrowserError("Browser input coordinates must be finite", void 0, { point });
|
|
1074
1095
|
}
|
|
1075
1096
|
/**
|
|
1076
|
-
* Validates the bounded
|
|
1097
|
+
* Validates the bounded delay, count, steps, and position of one trusted-input operation.
|
|
1077
1098
|
*
|
|
1078
1099
|
* @remarks
|
|
1079
1100
|
* The parameter is `BrowserOperationOptions`, so one validator answers for a
|
|
@@ -1239,7 +1260,8 @@ function validateBrowserRange(value, field, minimum, maximum, inclusive = true)
|
|
|
1239
1260
|
});
|
|
1240
1261
|
}
|
|
1241
1262
|
/**
|
|
1242
|
-
* 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.
|
|
1243
1265
|
*
|
|
1244
1266
|
* @param value - Unknown full or partial AX-tree result
|
|
1245
1267
|
* @returns Valid accessibility snapshot
|
|
@@ -1275,7 +1297,7 @@ function readBrowserAccessibility(value) {
|
|
|
1275
1297
|
};
|
|
1276
1298
|
}
|
|
1277
1299
|
/**
|
|
1278
|
-
* Decodes an Accessibility-domain AXValue.
|
|
1300
|
+
* Decodes an Accessibility-domain AXValue, or `undefined` when the record carries none.
|
|
1279
1301
|
*
|
|
1280
1302
|
* @param value - Unknown AX value
|
|
1281
1303
|
* @returns Underlying value
|
|
@@ -1300,7 +1322,7 @@ function concatBytes(chunks) {
|
|
|
1300
1322
|
return result;
|
|
1301
1323
|
}
|
|
1302
1324
|
/**
|
|
1303
|
-
* Decodes one `IO.read` response.
|
|
1325
|
+
* Decodes one `IO.read` response, throwing a `BrowserError` off-shape.
|
|
1304
1326
|
*
|
|
1305
1327
|
* @param value - Unknown protocol result
|
|
1306
1328
|
* @returns Valid stream chunk
|
|
@@ -1313,7 +1335,7 @@ function readBrowserStreamChunk(value) {
|
|
|
1313
1335
|
};
|
|
1314
1336
|
}
|
|
1315
1337
|
/**
|
|
1316
|
-
* Decodes JavaScript precise coverage.
|
|
1338
|
+
* Decodes JavaScript precise coverage, throwing a `BrowserError` off-shape.
|
|
1317
1339
|
*
|
|
1318
1340
|
* @param value - Unknown `Profiler.takePreciseCoverage` result
|
|
1319
1341
|
* @returns Script coverage
|
|
@@ -1341,7 +1363,7 @@ function readBrowserScriptCoverage(value) {
|
|
|
1341
1363
|
});
|
|
1342
1364
|
}
|
|
1343
1365
|
/**
|
|
1344
|
-
* Decodes CSS rule usage.
|
|
1366
|
+
* Decodes CSS rule usage, throwing a `BrowserError` off-shape.
|
|
1345
1367
|
*
|
|
1346
1368
|
* @param value - Unknown `CSS.stopRuleUsageTracking` result
|
|
1347
1369
|
* @returns Stylesheet coverage
|
|
@@ -1365,7 +1387,7 @@ function readBrowserStyleCoverage(value) {
|
|
|
1365
1387
|
}));
|
|
1366
1388
|
}
|
|
1367
1389
|
/**
|
|
1368
|
-
* Decodes coverage ranges.
|
|
1390
|
+
* Decodes and normalizes coverage ranges, throwing a `BrowserError` off-shape.
|
|
1369
1391
|
*
|
|
1370
1392
|
* @param value - Unknown ranges
|
|
1371
1393
|
* @param script - Script index for diagnostics
|
|
@@ -1386,7 +1408,7 @@ function readBrowserCoverageRanges(value, script) {
|
|
|
1386
1408
|
});
|
|
1387
1409
|
}
|
|
1388
1410
|
/**
|
|
1389
|
-
* Decodes Performance-domain metrics.
|
|
1411
|
+
* Decodes Performance-domain metrics, throwing a `BrowserError` off-shape.
|
|
1390
1412
|
*
|
|
1391
1413
|
* @param value - Unknown metrics result
|
|
1392
1414
|
* @returns Valid metrics
|
|
@@ -1402,7 +1424,7 @@ function readBrowserMetrics(value) {
|
|
|
1402
1424
|
});
|
|
1403
1425
|
}
|
|
1404
1426
|
/**
|
|
1405
|
-
* Decodes one CPU profile.
|
|
1427
|
+
* Decodes one CPU profile, throwing a `BrowserError` off-shape.
|
|
1406
1428
|
*
|
|
1407
1429
|
* @param value - Unknown `Profiler.stop` result
|
|
1408
1430
|
* @returns Valid profile
|
|
@@ -1435,7 +1457,7 @@ function readBrowserProfile(value) {
|
|
|
1435
1457
|
};
|
|
1436
1458
|
}
|
|
1437
1459
|
/**
|
|
1438
|
-
* Decodes a CPU profile call frame.
|
|
1460
|
+
* Decodes a CPU profile call frame, throwing a `BrowserError` off-shape.
|
|
1439
1461
|
*
|
|
1440
1462
|
* @param value - Unknown call frame
|
|
1441
1463
|
* @param node - Node index for diagnostics
|
|
@@ -1487,7 +1509,7 @@ function cookieToProtocol(cookie) {
|
|
|
1487
1509
|
return result;
|
|
1488
1510
|
}
|
|
1489
1511
|
/**
|
|
1490
|
-
* Decodes cookies
|
|
1512
|
+
* Decodes the cookies `Storage.getCookies` returns, throwing a `BrowserError` off-shape.
|
|
1491
1513
|
*
|
|
1492
1514
|
* @param value - Unknown protocol result
|
|
1493
1515
|
* @returns Valid cookies
|
|
@@ -1497,7 +1519,7 @@ function readBrowserCookies(value) {
|
|
|
1497
1519
|
return value["cookies"].map((candidate, index) => readBrowserCookie(candidate, index));
|
|
1498
1520
|
}
|
|
1499
1521
|
/**
|
|
1500
|
-
* Decodes one Chromium cookie.
|
|
1522
|
+
* Decodes one Chromium cookie, throwing a `BrowserError` off-shape.
|
|
1501
1523
|
*
|
|
1502
1524
|
* @param value - Unknown cookie record
|
|
1503
1525
|
* @param index - Source array position for diagnostics
|
|
@@ -1541,7 +1563,7 @@ function matchesBrowserCookieURL(cookie, value) {
|
|
|
1541
1563
|
return domainMatches && pathMatches && secureMatches;
|
|
1542
1564
|
}
|
|
1543
1565
|
/**
|
|
1544
|
-
* Decodes one in-page web-storage snapshot.
|
|
1566
|
+
* Decodes one in-page web-storage snapshot, throwing a `BrowserError` off-shape.
|
|
1545
1567
|
*
|
|
1546
1568
|
* @param value - Unknown evaluation result
|
|
1547
1569
|
* @param origin - Origin represented by the result
|
|
@@ -1556,7 +1578,7 @@ function readBrowserStorageOrigin(value, origin) {
|
|
|
1556
1578
|
};
|
|
1557
1579
|
}
|
|
1558
1580
|
/**
|
|
1559
|
-
* Decodes a list of web-storage entries.
|
|
1581
|
+
* Decodes a list of web-storage entries, throwing a `BrowserError` off-shape.
|
|
1560
1582
|
*
|
|
1561
1583
|
* @param value - Unknown entry list
|
|
1562
1584
|
* @param origin - Origin used for diagnostics
|
|
@@ -1607,7 +1629,7 @@ function mediaToFeatures(media) {
|
|
|
1607
1629
|
return features;
|
|
1608
1630
|
}
|
|
1609
1631
|
/**
|
|
1610
|
-
* Decodes a Chromium runtime stack trace.
|
|
1632
|
+
* Decodes a Chromium runtime stack trace, skipping every off-shape call frame.
|
|
1611
1633
|
*
|
|
1612
1634
|
* @param value - Unknown stack trace or call-frame list
|
|
1613
1635
|
* @returns Valid stack frames
|
|
@@ -1628,7 +1650,8 @@ function readBrowserStack(value) {
|
|
|
1628
1650
|
return stack;
|
|
1629
1651
|
}
|
|
1630
1652
|
/**
|
|
1631
|
-
* 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.
|
|
1632
1655
|
*
|
|
1633
1656
|
* @param value - Unknown remote object
|
|
1634
1657
|
* @returns By-value data or a description
|
|
@@ -1640,7 +1663,8 @@ function readBrowserRemoteValue(value) {
|
|
|
1640
1663
|
if (isString(value["description"])) return value["description"];
|
|
1641
1664
|
}
|
|
1642
1665
|
/**
|
|
1643
|
-
* 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.
|
|
1644
1668
|
*
|
|
1645
1669
|
* @param value - Unknown CDP result
|
|
1646
1670
|
* @returns The returned by-value payload, or undefined
|
|
@@ -1676,13 +1700,12 @@ function requireBrowserString(value, field) {
|
|
|
1676
1700
|
throw new BrowserError(`${field} failed: no string value returned`);
|
|
1677
1701
|
}
|
|
1678
1702
|
/**
|
|
1679
|
-
* Normalizes
|
|
1703
|
+
* Normalizes recorded codegen actions, collapsing consecutive `fill` actions on the same
|
|
1704
|
+
* selector into the latest value.
|
|
1680
1705
|
*
|
|
1681
1706
|
* @remarks
|
|
1682
|
-
*
|
|
1683
|
-
*
|
|
1684
|
-
* compiled script reflects the final typed value rather than every
|
|
1685
|
-
* 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.
|
|
1686
1709
|
*
|
|
1687
1710
|
* @param actions - Raw recorded actions, in capture order
|
|
1688
1711
|
* @returns Normalized actions, in the same order
|
|
@@ -1700,7 +1723,8 @@ function normalizeCodegenActions(actions) {
|
|
|
1700
1723
|
return result;
|
|
1701
1724
|
}
|
|
1702
1725
|
/**
|
|
1703
|
-
* 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.
|
|
1704
1728
|
*
|
|
1705
1729
|
* @param value - Unknown CDP result
|
|
1706
1730
|
* @returns Frame metadata in depth-first, main-frame-first order
|
|
@@ -1729,7 +1753,8 @@ function readBrowserFrames(value) {
|
|
|
1729
1753
|
return frames;
|
|
1730
1754
|
}
|
|
1731
1755
|
/**
|
|
1732
|
-
* 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.
|
|
1733
1758
|
*
|
|
1734
1759
|
* @param value - Unknown CDP result
|
|
1735
1760
|
* @returns Decoded quad
|
|
@@ -1765,7 +1790,8 @@ function readBrowserQuad(value) {
|
|
|
1765
1790
|
};
|
|
1766
1791
|
}
|
|
1767
1792
|
/**
|
|
1768
|
-
* 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.
|
|
1769
1795
|
*
|
|
1770
1796
|
* @param value - Chord source
|
|
1771
1797
|
* @returns Canonical modifiers and terminal key
|
|
@@ -1803,7 +1829,7 @@ function computeBrowserModifiers(modifiers) {
|
|
|
1803
1829
|
/**
|
|
1804
1830
|
* Computes the CDP Input pressed-button bitmask.
|
|
1805
1831
|
*
|
|
1806
|
-
* @param buttons -
|
|
1832
|
+
* @param buttons - Pressed public mouse buttons
|
|
1807
1833
|
* @returns Combined CDP pressed-button mask
|
|
1808
1834
|
*/
|
|
1809
1835
|
function computeBrowserButtons(buttons) {
|
|
@@ -1943,7 +1969,8 @@ function keyToBrowserInput(value) {
|
|
|
1943
1969
|
};
|
|
1944
1970
|
}
|
|
1945
1971
|
/**
|
|
1946
|
-
* Decodes CDP snapshot sparse string data
|
|
1972
|
+
* Decodes CDP snapshot sparse string data into a node-index map, skipping every off-shape
|
|
1973
|
+
* entry.
|
|
1947
1974
|
*
|
|
1948
1975
|
* @param value - Sparse `{ index, value }` record
|
|
1949
1976
|
* @param strings - Snapshot string table
|
|
@@ -1963,7 +1990,8 @@ function readRareStringData(value, strings) {
|
|
|
1963
1990
|
return decoded;
|
|
1964
1991
|
}
|
|
1965
1992
|
/**
|
|
1966
|
-
* 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.
|
|
1967
1995
|
*
|
|
1968
1996
|
* @param value - Sparse `{ index }` record
|
|
1969
1997
|
* @returns Set of node indexes whose value is true
|
|
@@ -1973,7 +2001,8 @@ function readRareBooleanData(value) {
|
|
|
1973
2001
|
return new Set(parseNumberArray(value["index"]) ?? []);
|
|
1974
2002
|
}
|
|
1975
2003
|
/**
|
|
1976
|
-
* Decodes CDP snapshot sparse integer data
|
|
2004
|
+
* Decodes CDP snapshot sparse integer data into a node-index map, skipping every off-shape
|
|
2005
|
+
* entry.
|
|
1977
2006
|
*
|
|
1978
2007
|
* @param value - Sparse `{ index, value }` record
|
|
1979
2008
|
* @returns Node-index to integer map
|
|
@@ -1992,7 +2021,7 @@ function readRareIntegerData(value) {
|
|
|
1992
2021
|
return decoded;
|
|
1993
2022
|
}
|
|
1994
2023
|
/**
|
|
1995
|
-
* Decodes flattened CDP node attributes.
|
|
2024
|
+
* Decodes flattened CDP node attributes into a frozen record, skipping every off-shape pair.
|
|
1996
2025
|
*
|
|
1997
2026
|
* @param value - Candidate string-index array
|
|
1998
2027
|
* @param strings - Snapshot string table
|
|
@@ -2010,7 +2039,9 @@ function readBrowserAttributes(value, strings) {
|
|
|
2010
2039
|
return Object.freeze(attributes);
|
|
2011
2040
|
}
|
|
2012
2041
|
/**
|
|
2013
|
-
* 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.
|
|
2014
2045
|
*
|
|
2015
2046
|
* @param value - Unknown CDP result
|
|
2016
2047
|
* @param styles - Requested computed-style names, in protocol order
|
|
@@ -2139,7 +2170,7 @@ function readBrowserSnapshot(value, styles = [], limit = BROWSER_SNAPSHOT_NODE_L
|
|
|
2139
2170
|
};
|
|
2140
2171
|
}
|
|
2141
2172
|
/**
|
|
2142
|
-
* 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.
|
|
2143
2174
|
*
|
|
2144
2175
|
* @param value - Browser-node query or predicate
|
|
2145
2176
|
* @returns True if the matcher is a declarative query; false otherwise
|
|
@@ -2411,9 +2442,9 @@ function compileStorageClearExpression() {
|
|
|
2411
2442
|
})()`;
|
|
2412
2443
|
}
|
|
2413
2444
|
/**
|
|
2414
|
-
* Compiles a `Runtime.evaluate` expression so the
|
|
2415
|
-
*
|
|
2416
|
-
*
|
|
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.
|
|
2417
2448
|
*
|
|
2418
2449
|
* @remarks
|
|
2419
2450
|
* A result whose `JSON.stringify` length exceeds `limit` throws
|
|
@@ -2438,7 +2469,7 @@ ${expression}
|
|
|
2438
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 })()`;
|
|
2439
2470
|
}
|
|
2440
2471
|
/**
|
|
2441
|
-
* Compiles recorded codegen actions into a replayable script.
|
|
2472
|
+
* Compiles recorded codegen actions into a replayable JavaScript or TypeScript script.
|
|
2442
2473
|
*
|
|
2443
2474
|
* @remarks
|
|
2444
2475
|
* Emits one statement per action against a `page` object shaped like
|
|
@@ -4070,7 +4101,7 @@ var BrowserTracing = class {
|
|
|
4070
4101
|
//#endregion
|
|
4071
4102
|
//#region src/core/BrowserDiagnostics.ts
|
|
4072
4103
|
/**
|
|
4073
|
-
* Groups the
|
|
4104
|
+
* Groups the tracing, coverage, performance, and profiler classes beneath one page.
|
|
4074
4105
|
*
|
|
4075
4106
|
* @example
|
|
4076
4107
|
* ```ts
|
|
@@ -7371,7 +7402,7 @@ var BrowserContext = class {
|
|
|
7371
7402
|
//#endregion
|
|
7372
7403
|
//#region src/core/factories.ts
|
|
7373
7404
|
/**
|
|
7374
|
-
* Creates a
|
|
7405
|
+
* Creates a `CDPClientInterface` bound to the given `CDPTransportInterface`.
|
|
7375
7406
|
*
|
|
7376
7407
|
* @param options - The transport (and optional timeout) the client uses
|
|
7377
7408
|
* @returns A {@link CDPClientInterface}
|
|
@@ -7388,7 +7419,7 @@ function createCDPClient(options) {
|
|
|
7388
7419
|
return new CDPClient(options);
|
|
7389
7420
|
}
|
|
7390
7421
|
/**
|
|
7391
|
-
* Creates a navigable
|
|
7422
|
+
* Creates a navigable `BrowserSnapshotInterface` over decoded `BrowserSnapshotInput` data.
|
|
7392
7423
|
*
|
|
7393
7424
|
* @param input - Captured documents and computed-style names
|
|
7394
7425
|
* @returns A {@link BrowserSnapshotInterface}
|