browserscale-ts 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -78
- package/dist/browser.js +1 -1
- package/dist/browserscale.browser.js +427 -162
- package/dist/client.d.ts +241 -62
- package/dist/client.js +312 -83
- package/dist/defaults.d.ts +11 -9
- package/dist/defaults.js +15 -12
- package/dist/dom-mirror.d.ts +27 -0
- package/dist/dom-mirror.js +27 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.js +37 -0
- package/dist/gen/wrc_pb.d.ts +348 -91
- package/dist/gen/wrc_pb.js +53 -58
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -5
- package/dist/internal/convert.js +1 -0
- package/dist/locator.d.ts +12 -11
- package/dist/locator.js +14 -22
- package/dist/network-capture.d.ts +3 -2
- package/dist/network-capture.js +3 -2
- package/dist/options.d.ts +1 -1
- package/dist/scripts.d.ts +4 -3
- package/dist/scripts.js +4 -3
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -13,9 +13,7 @@ import type { AuthSession } from "./auth-session.ts";
|
|
|
13
13
|
* CloudBrowser is the SDK-side handle for an active browserscale browser session.
|
|
14
14
|
*
|
|
15
15
|
* One CloudBrowser corresponds to exactly one browser context, which
|
|
16
|
-
* always has at least one page
|
|
17
|
-
* primary page server-side — the proto's page_id field is currently
|
|
18
|
-
* ignored server-side, so the SDK never sets it.
|
|
16
|
+
* always has at least one page; its commands act on the primary page.
|
|
19
17
|
*
|
|
20
18
|
* Construct via rentBrowser() / createWebSocketBrowser() — never
|
|
21
19
|
* directly.
|
|
@@ -42,7 +40,8 @@ export declare class CloudBrowser {
|
|
|
42
40
|
* {@link createWebSocketBrowser} the rental stays untouched; only the
|
|
43
41
|
* transport is closed.
|
|
44
42
|
*
|
|
45
|
-
*
|
|
43
|
+
* Rejects only when the stop API or the transport close fails. The session is
|
|
44
|
+
* released either way; retrying a stop is safe.
|
|
46
45
|
*
|
|
47
46
|
* @example
|
|
48
47
|
* await browser.stopBrowser();
|
|
@@ -60,7 +59,9 @@ export declare class CloudBrowser {
|
|
|
60
59
|
* @param proxyUsername - proxy auth user; empty for unauthenticated proxies
|
|
61
60
|
* @param proxyPassword - proxy auth password; empty for unauthenticated proxies
|
|
62
61
|
*
|
|
63
|
-
*
|
|
62
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
63
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
64
|
+
* are no error codes to branch on.
|
|
64
65
|
*
|
|
65
66
|
* @example
|
|
66
67
|
* await browser.setProxy("proxy.example.com", 8080, "user", "pass");
|
|
@@ -76,7 +77,9 @@ export declare class CloudBrowser {
|
|
|
76
77
|
*
|
|
77
78
|
* @returns PageInfo[] for every page currently open in the context
|
|
78
79
|
*
|
|
79
|
-
*
|
|
80
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
81
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
82
|
+
* are no error codes to branch on.
|
|
80
83
|
*
|
|
81
84
|
* @example
|
|
82
85
|
* const pages = await browser.getPages();
|
|
@@ -96,7 +99,16 @@ export declare class CloudBrowser {
|
|
|
96
99
|
* @returns NavigateResult with the final resolved URL and the frameId
|
|
97
100
|
* of the main frame after navigation
|
|
98
101
|
*
|
|
99
|
-
* @throws
|
|
102
|
+
* @throws timeout - nothing committed before the deadline; the page may still
|
|
103
|
+
* be loading, so a longer timeout can be the whole fix
|
|
104
|
+
* @throws net_error - the URL never loaded: DNS, TLS, a refused connection, or
|
|
105
|
+
* a proxy that could not reach it. The message carries the underlying net
|
|
106
|
+
* error name, which is what separates a bad proxy from a bad host - worth
|
|
107
|
+
* logging, since the two need different fixes
|
|
108
|
+
* @throws crashed - the renderer died mid-navigation; the page is unusable and
|
|
109
|
+
* has to be navigated again
|
|
110
|
+
*
|
|
111
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
100
112
|
*
|
|
101
113
|
* @example
|
|
102
114
|
* await browser.navigate("https://example.com");
|
|
@@ -114,7 +126,11 @@ export declare class CloudBrowser {
|
|
|
114
126
|
* @param html - response body to serve
|
|
115
127
|
* @param opts - optional headers and statusCode (default 200)
|
|
116
128
|
*
|
|
117
|
-
* @throws
|
|
129
|
+
* @throws timeout - the page never requested the URL, so the prepared
|
|
130
|
+
* response had nobody to hand it to; usually the navigation was cancelled
|
|
131
|
+
* or redirected away before reaching it
|
|
132
|
+
*
|
|
133
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
118
134
|
*
|
|
119
135
|
* @example
|
|
120
136
|
* await browser.loadHTML("https://example.com", "<h1>hi</h1>");
|
|
@@ -133,16 +149,34 @@ export declare class CloudBrowser {
|
|
|
133
149
|
* The generic T is a TypeScript hint only — there is no runtime
|
|
134
150
|
* validation that the JS expression actually returned that type.
|
|
135
151
|
*
|
|
152
|
+
* A falsy answer and a broken expression are different outcomes. Returning
|
|
153
|
+
* null, false or undefined is a successful evaluation and resolves normally;
|
|
154
|
+
* an expression that throws or will not compile rejects with a
|
|
155
|
+
* {@link CommandError}, so a typo can never read as "the page says null".
|
|
156
|
+
*
|
|
136
157
|
* @param expression - JavaScript expression evaluated in the main frame
|
|
137
158
|
*
|
|
138
159
|
* @returns EvaluateResult with either value (non-Element) or element
|
|
139
160
|
* metadata (Element)
|
|
140
161
|
*
|
|
141
|
-
* @throws
|
|
162
|
+
* @throws {@link CommandError} - code `"threw"` (the expression raised; the
|
|
163
|
+
* message carries the exception text), `"not_run"` (it could not be
|
|
164
|
+
* compiled, or execution never started), `"aborted"` (the browser stopped
|
|
165
|
+
* execution) or `"no_context"` (the frame had no live script context)
|
|
142
166
|
*
|
|
143
167
|
* @example
|
|
144
168
|
* const res = await browser.evaluate<string>("document.title");
|
|
145
169
|
* console.log(res.value);
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* // Telling a false answer from a broken expression.
|
|
173
|
+
* try {
|
|
174
|
+
* const res = await browser.evaluate<boolean>("window.__ready === true");
|
|
175
|
+
* if (!res.value) { /* legitimately not ready yet *\/ }
|
|
176
|
+
* } catch (e) {
|
|
177
|
+
* if (e instanceof CommandError) throw new Error(`expression broken: ${e.message}`);
|
|
178
|
+
* throw e;
|
|
179
|
+
* }
|
|
146
180
|
*/
|
|
147
181
|
evaluate<T = unknown>(expression: string): Promise<EvaluateResult<T>>;
|
|
148
182
|
/**
|
|
@@ -438,7 +472,9 @@ export declare class CloudBrowser {
|
|
|
438
472
|
* @returns DOMResult with the JSON string in `.dom` (the `.hash` field
|
|
439
473
|
* is populated by {@link getDOMHash}, not by this call)
|
|
440
474
|
*
|
|
441
|
-
*
|
|
475
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
476
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
477
|
+
* are no error codes to branch on.
|
|
442
478
|
*
|
|
443
479
|
* @example
|
|
444
480
|
* const { dom } = await browser.getDOM();
|
|
@@ -456,7 +492,9 @@ export declare class CloudBrowser {
|
|
|
456
492
|
*
|
|
457
493
|
* @returns 16-char hex string (the first 8 bytes of sha256 of the DOM JSON)
|
|
458
494
|
*
|
|
459
|
-
*
|
|
495
|
+
* Rejects only on a transport failure. The hash is computed from a serialized
|
|
496
|
+
* tree, so there is no semantic failure of its own and no error codes to branch
|
|
497
|
+
* on.
|
|
460
498
|
*
|
|
461
499
|
* @example
|
|
462
500
|
* const hash = await browser.getDOMHash();
|
|
@@ -496,7 +534,11 @@ export declare class CloudBrowser {
|
|
|
496
534
|
*
|
|
497
535
|
* @returns the observation in the requested format, ready to hand to a model
|
|
498
536
|
*
|
|
499
|
-
* @throws
|
|
537
|
+
* @throws not_found - the requested scope root is not on the page, so there
|
|
538
|
+
* was nothing to observe. Distinct from an observation that comes back
|
|
539
|
+
* empty, which means the scope exists and holds nothing worth reporting
|
|
540
|
+
*
|
|
541
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
500
542
|
*
|
|
501
543
|
* @example
|
|
502
544
|
* const obs = await browser.getObservation();
|
|
@@ -517,7 +559,11 @@ export declare class CloudBrowser {
|
|
|
517
559
|
* @returns ScreenshotResult with the base64 image in `dataBase64` and the
|
|
518
560
|
* physical pixel `width`/`height`
|
|
519
561
|
*
|
|
520
|
-
* @throws
|
|
562
|
+
* @throws capture_failed - the page had no frame to copy. A page that has not
|
|
563
|
+
* produced one yet, or is not being composited at the moment, has nothing to
|
|
564
|
+
* hand over; retrying after it renders usually works
|
|
565
|
+
*
|
|
566
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
521
567
|
*
|
|
522
568
|
* @example
|
|
523
569
|
* const shot = await browser.screenshot({ format: "png" });
|
|
@@ -541,11 +587,15 @@ export declare class CloudBrowser {
|
|
|
541
587
|
* canvas `width`/`height`, resolved `frameId`/`backendNodeId` and the
|
|
542
588
|
* `originClean` flag
|
|
543
589
|
*
|
|
544
|
-
* @throws
|
|
545
|
-
* @throws
|
|
546
|
-
* @throws
|
|
547
|
-
*
|
|
548
|
-
*
|
|
590
|
+
* @throws not_found - no element matched the locator
|
|
591
|
+
* @throws not_element - the expression was truthy but did not yield an element
|
|
592
|
+
* @throws not_readable - the target was found but is not a readable canvas
|
|
593
|
+
*
|
|
594
|
+
* A target that is empty, uses `at(x, y)` or names several things at once is
|
|
595
|
+
* rejected before anything is sent. A closed page or a frame that is gone is a
|
|
596
|
+
* transport failure rather than a code.
|
|
597
|
+
*
|
|
598
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
549
599
|
*
|
|
550
600
|
* @example
|
|
551
601
|
* const res = await browser.readCanvas(css("#game canvas"));
|
|
@@ -568,7 +618,9 @@ export declare class CloudBrowser {
|
|
|
568
618
|
*
|
|
569
619
|
* @param patterns - URL wildcards to block; empty array clears the list
|
|
570
620
|
*
|
|
571
|
-
*
|
|
621
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
622
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
623
|
+
* are no error codes to branch on.
|
|
572
624
|
*
|
|
573
625
|
* @example
|
|
574
626
|
* await browser.setBlockList([
|
|
@@ -589,7 +641,9 @@ export declare class CloudBrowser {
|
|
|
589
641
|
* @param blobName - server-side identifier of the snapshot to serve from
|
|
590
642
|
* @param patterns - URL wildcards to redirect to the cache; empty disables
|
|
591
643
|
*
|
|
592
|
-
*
|
|
644
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
645
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
646
|
+
* are no error codes to branch on.
|
|
593
647
|
*
|
|
594
648
|
* @example
|
|
595
649
|
* await browser.setStaticPaths("snap-2026-05", ["*.example.com/*"]);
|
|
@@ -610,7 +664,12 @@ export declare class CloudBrowser {
|
|
|
610
664
|
* (the captured method/URL/headers/body; null if intercepted with
|
|
611
665
|
* no body)
|
|
612
666
|
*
|
|
613
|
-
* @throws
|
|
667
|
+
* @throws timeout - no request matched any pattern before the deadline.
|
|
668
|
+
* Nothing occurring is an answer, and it stays distinguishable from a
|
|
669
|
+
* connection that died on the way. Supplying no patterns is a caller mistake
|
|
670
|
+
* rather than an outcome, and rejects separately
|
|
671
|
+
*
|
|
672
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
614
673
|
*
|
|
615
674
|
* @example
|
|
616
675
|
* const { index, request } = await browser.waitForAnyRequest(
|
|
@@ -638,6 +697,13 @@ export declare class CloudBrowser {
|
|
|
638
697
|
* @returns object with `index` (matched pattern index) and `response`
|
|
639
698
|
* (the captured status/headers/body; null if no body was returned)
|
|
640
699
|
*
|
|
700
|
+
* @throws timeout - no response matched any pattern before the deadline.
|
|
701
|
+
* Nothing occurring is an answer, and it stays distinguishable from a
|
|
702
|
+
* connection that died on the way. Supplying no patterns is a caller mistake
|
|
703
|
+
* rather than an outcome, and rejects separately
|
|
704
|
+
*
|
|
705
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
706
|
+
*
|
|
641
707
|
* @example
|
|
642
708
|
* const { index, response } = await browser.waitForAnyResponse(
|
|
643
709
|
* [{ url: "*\/api/login" }],
|
|
@@ -667,7 +733,10 @@ export declare class CloudBrowser {
|
|
|
667
733
|
* were actually sent on the wire after modifications were applied;
|
|
668
734
|
* null when no request payload was reported
|
|
669
735
|
*
|
|
670
|
-
* @throws
|
|
736
|
+
* @throws timeout - no matching request appeared before the deadline, so
|
|
737
|
+
* nothing was modified
|
|
738
|
+
*
|
|
739
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
671
740
|
*
|
|
672
741
|
* @example
|
|
673
742
|
* const req = await browser.modifyRequest("*\/api/me", {
|
|
@@ -708,7 +777,9 @@ export declare class CloudBrowser {
|
|
|
708
777
|
* @returns NetworkCapture handle for stopping the capture and inspecting how
|
|
709
778
|
* it ended
|
|
710
779
|
*
|
|
711
|
-
*
|
|
780
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
781
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
782
|
+
* are no error codes to branch on.
|
|
712
783
|
*
|
|
713
784
|
* @example
|
|
714
785
|
* const capture = await browser.captureNetwork(
|
|
@@ -732,7 +803,9 @@ export declare class CloudBrowser {
|
|
|
732
803
|
*
|
|
733
804
|
* @param opts - which requests to capture and whether to keep bodies
|
|
734
805
|
*
|
|
735
|
-
*
|
|
806
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
807
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
808
|
+
* are no error codes to branch on.
|
|
736
809
|
*/
|
|
737
810
|
startNetworkCapture(opts: NetworkCaptureOptions): Promise<void>;
|
|
738
811
|
/**
|
|
@@ -740,7 +813,8 @@ export declare class CloudBrowser {
|
|
|
740
813
|
*
|
|
741
814
|
* @returns whether a capture was running
|
|
742
815
|
*
|
|
743
|
-
*
|
|
816
|
+
* Rejects only on a transport failure. Stopping a capture that is not running
|
|
817
|
+
* is a no-op rather than a failure, so there are no error codes to branch on.
|
|
744
818
|
*/
|
|
745
819
|
stopNetworkCapture(): Promise<boolean>;
|
|
746
820
|
/**
|
|
@@ -757,7 +831,8 @@ export declare class CloudBrowser {
|
|
|
757
831
|
* @returns NetworkCapture attached to whatever capture is running; onExchange
|
|
758
832
|
* simply never fires when none is
|
|
759
833
|
*
|
|
760
|
-
*
|
|
834
|
+
* Rejects only on a transport failure: opening the subscription has no semantic
|
|
835
|
+
* failure of its own.
|
|
761
836
|
*/
|
|
762
837
|
streamNetworkExchanges(onExchange: NetworkExchangeHandler): Promise<NetworkCapture>;
|
|
763
838
|
/**
|
|
@@ -810,13 +885,21 @@ export declare class CloudBrowser {
|
|
|
810
885
|
* @param onResync called when the copy had to be rebuilt, after the new tree
|
|
811
886
|
* is in place. Rebuilding is automatic; this is for telling the user why
|
|
812
887
|
* their expanded nodes collapsed.
|
|
813
|
-
* @throws
|
|
888
|
+
* @throws mirror_failed - the page could not be serialized, usually a document
|
|
889
|
+
* that went away while the tree was being built. No mirror is left running
|
|
890
|
+
*
|
|
891
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
814
892
|
*/
|
|
815
893
|
mirrorDom(opts: DomMirrorOptions, onChange: DomChangeHandler, onResync?: DomResyncHandler): Promise<DomMirror>;
|
|
816
894
|
/**
|
|
817
895
|
* Starts (or restarts) the page's mirror and returns the main document,
|
|
818
896
|
* without subscribing to changes. {@link CloudBrowser.mirrorDom} is what you
|
|
819
897
|
* normally want; this is the raw command.
|
|
898
|
+
*
|
|
899
|
+
* @throws mirror_failed - the page could not be serialized, usually a document
|
|
900
|
+
* that went away while the tree was being built. No mirror is left running
|
|
901
|
+
*
|
|
902
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
820
903
|
*/
|
|
821
904
|
startDomMirror(opts?: DomMirrorOptions): Promise<DomSnapshot>;
|
|
822
905
|
/** Stops the page's mirror, every frame of it. Idempotent. */
|
|
@@ -827,6 +910,17 @@ export declare class CloudBrowser {
|
|
|
827
910
|
*
|
|
828
911
|
* On an `<iframe>` the one child is the document it hosts, and this call is
|
|
829
912
|
* what starts mirroring that frame.
|
|
913
|
+
*
|
|
914
|
+
* An id that is simply unknown is not a failure: the call resolves with an
|
|
915
|
+
* empty result.
|
|
916
|
+
*
|
|
917
|
+
* @throws not_mirrored - the page has no mirror, or frameId is not part of the
|
|
918
|
+
* one it has; start a mirror first, and after a resync fetch the current tree
|
|
919
|
+
* before addressing nodes again
|
|
920
|
+
* @throws mirror_failed - the subtree could not be serialized, usually a
|
|
921
|
+
* document that went away mid-read
|
|
922
|
+
*
|
|
923
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
830
924
|
*/
|
|
831
925
|
getDomChildren(backendNodeId: number, frameId?: string, depth?: number): Promise<{
|
|
832
926
|
children: string;
|
|
@@ -835,6 +929,13 @@ export declare class CloudBrowser {
|
|
|
835
929
|
/**
|
|
836
930
|
* Stops reporting changes inside a node, and inside any frame below it.
|
|
837
931
|
* {@link DomMirror.collapse} calls this.
|
|
932
|
+
*
|
|
933
|
+
* @throws not_mirrored - the page has no mirror, or frameId is not part of
|
|
934
|
+
* the one it has; this is what replaying ids from a tree that has since
|
|
935
|
+
* been resynced looks like, so fetch the current tree and address the node
|
|
936
|
+
* again
|
|
937
|
+
*
|
|
938
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
838
939
|
*/
|
|
839
940
|
releaseDomSubtree(backendNodeId: number, frameId?: string): Promise<void>;
|
|
840
941
|
/**
|
|
@@ -842,6 +943,16 @@ export declare class CloudBrowser {
|
|
|
842
943
|
* with its own children, crossing into frames where it has to and starting
|
|
843
944
|
* the ones it passes through. {@link DomMirror.reveal} calls this and
|
|
844
945
|
* splices it in.
|
|
946
|
+
*
|
|
947
|
+
* An id that is simply unknown is not a failure: the call resolves with an
|
|
948
|
+
* empty result.
|
|
949
|
+
*
|
|
950
|
+
* @throws not_mirrored - the page has no mirror, or frameId is not part of the
|
|
951
|
+
* one it has
|
|
952
|
+
* @throws mirror_failed - the path could not be serialized, usually a document
|
|
953
|
+
* that went away mid-read
|
|
954
|
+
*
|
|
955
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
845
956
|
*/
|
|
846
957
|
revealDomNode(backendNodeId: number, frameId?: string): Promise<{
|
|
847
958
|
path: string;
|
|
@@ -856,6 +967,10 @@ export declare class CloudBrowser {
|
|
|
856
967
|
* whole tree just to hash it. The two answer different questions: a hash
|
|
857
968
|
* compares content, a revision only says whether this document moved since
|
|
858
969
|
* you last asked.
|
|
970
|
+
*
|
|
971
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
972
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
973
|
+
* are no error codes to branch on.
|
|
859
974
|
*/
|
|
860
975
|
getDomRevision(frameId?: string): Promise<number>;
|
|
861
976
|
/**
|
|
@@ -863,7 +978,9 @@ export declare class CloudBrowser {
|
|
|
863
978
|
*
|
|
864
979
|
* @returns CookieParam[], one per cookie in the context
|
|
865
980
|
*
|
|
866
|
-
*
|
|
981
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
982
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
983
|
+
* are no error codes to branch on.
|
|
867
984
|
*
|
|
868
985
|
* @example
|
|
869
986
|
* const cookies = await browser.getCookies();
|
|
@@ -878,7 +995,9 @@ export declare class CloudBrowser {
|
|
|
878
995
|
*
|
|
879
996
|
* @param cookies - cookies to write; empty array is a no-op
|
|
880
997
|
*
|
|
881
|
-
*
|
|
998
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
999
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1000
|
+
* are no error codes to branch on.
|
|
882
1001
|
*
|
|
883
1002
|
* @example
|
|
884
1003
|
* await browser.setCookies([
|
|
@@ -889,7 +1008,9 @@ export declare class CloudBrowser {
|
|
|
889
1008
|
/**
|
|
890
1009
|
* Deletes every cookie in the browser context.
|
|
891
1010
|
*
|
|
892
|
-
*
|
|
1011
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1012
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1013
|
+
* are no error codes to branch on.
|
|
893
1014
|
*
|
|
894
1015
|
* @example
|
|
895
1016
|
* await browser.clearCookies();
|
|
@@ -908,7 +1029,9 @@ export declare class CloudBrowser {
|
|
|
908
1029
|
*
|
|
909
1030
|
* @returns StorageOriginEntry[], one per origin with localStorage data
|
|
910
1031
|
*
|
|
911
|
-
*
|
|
1032
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1033
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1034
|
+
* are no error codes to branch on.
|
|
912
1035
|
*
|
|
913
1036
|
* @example
|
|
914
1037
|
* const storage = await browser.getStorage();
|
|
@@ -928,7 +1051,9 @@ export declare class CloudBrowser {
|
|
|
928
1051
|
*
|
|
929
1052
|
* @param storage - entries to write, grouped by origin
|
|
930
1053
|
*
|
|
931
|
-
*
|
|
1054
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1055
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1056
|
+
* are no error codes to branch on.
|
|
932
1057
|
*
|
|
933
1058
|
* @example
|
|
934
1059
|
* await browser.setStorage([
|
|
@@ -948,7 +1073,9 @@ export declare class CloudBrowser {
|
|
|
948
1073
|
* @param origin - if set, only this origin's storage is deleted
|
|
949
1074
|
* (e.g. "https://example.com"); omit to delete all origins
|
|
950
1075
|
*
|
|
951
|
-
*
|
|
1076
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1077
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1078
|
+
* are no error codes to branch on.
|
|
952
1079
|
*
|
|
953
1080
|
* @example
|
|
954
1081
|
* // Wipe one origin.
|
|
@@ -968,7 +1095,9 @@ export declare class CloudBrowser {
|
|
|
968
1095
|
*
|
|
969
1096
|
* @returns AuthSession, or undefined when there is nothing to export
|
|
970
1097
|
*
|
|
971
|
-
*
|
|
1098
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1099
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1100
|
+
* are no error codes to branch on.
|
|
972
1101
|
*
|
|
973
1102
|
* @example
|
|
974
1103
|
* const auth = await browser.getAuthSession();
|
|
@@ -984,7 +1113,9 @@ export declare class CloudBrowser {
|
|
|
984
1113
|
*
|
|
985
1114
|
* @param session - session as returned by getAuthSession()
|
|
986
1115
|
*
|
|
987
|
-
*
|
|
1116
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1117
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1118
|
+
* are no error codes to branch on.
|
|
988
1119
|
*
|
|
989
1120
|
* @example
|
|
990
1121
|
* await browser.setAuthSession(saved);
|
|
@@ -1006,7 +1137,9 @@ export declare class CloudBrowser {
|
|
|
1006
1137
|
* @returns InspectResult with the resolved backendNodeId, frameId, tag
|
|
1007
1138
|
* name, trimmed textContent, visibility and bounds
|
|
1008
1139
|
*
|
|
1009
|
-
*
|
|
1140
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1141
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1142
|
+
* are no error codes to branch on.
|
|
1010
1143
|
*
|
|
1011
1144
|
* @example
|
|
1012
1145
|
* const r = await browser.inspectAtPosition(200, 300);
|
|
@@ -1023,7 +1156,9 @@ export declare class CloudBrowser {
|
|
|
1023
1156
|
* @param frameId - id of the frame the node lives in; empty string
|
|
1024
1157
|
* targets the main frame
|
|
1025
1158
|
*
|
|
1026
|
-
*
|
|
1159
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1160
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1161
|
+
* are no error codes to branch on.
|
|
1027
1162
|
*
|
|
1028
1163
|
* @example
|
|
1029
1164
|
* await browser.highlightNode(res.backendNodeId, res.frameId);
|
|
@@ -1039,7 +1174,11 @@ export declare class CloudBrowser {
|
|
|
1039
1174
|
*
|
|
1040
1175
|
* @param text - the text to insert at the caret
|
|
1041
1176
|
*
|
|
1042
|
-
* @throws
|
|
1177
|
+
* @throws no_focus - nothing in the page holds focus, so there is no caret to
|
|
1178
|
+
* insert at; click the field first
|
|
1179
|
+
* @throws busy - another action is already running on this page
|
|
1180
|
+
*
|
|
1181
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
1043
1182
|
*
|
|
1044
1183
|
* @example
|
|
1045
1184
|
* await browser.insertText("hello world");
|
|
@@ -1065,7 +1204,10 @@ export declare class CloudBrowser {
|
|
|
1065
1204
|
* @param opts - optional: `clearFirst` clears the focused field (Ctrl+A,
|
|
1066
1205
|
* Delete) before typing
|
|
1067
1206
|
*
|
|
1068
|
-
*
|
|
1207
|
+
* `type` has no semantic failure of its own: the keys land wherever focus
|
|
1208
|
+
* happens to be, so there is no target it can miss. Only the page or context
|
|
1209
|
+
* being torn down mid-stream surfaces, and that is a transport failure rather
|
|
1210
|
+
* than a code.
|
|
1069
1211
|
*
|
|
1070
1212
|
* @example
|
|
1071
1213
|
* // OTP field that auto-advances across boxes.
|
|
@@ -1088,7 +1230,11 @@ export declare class CloudBrowser {
|
|
|
1088
1230
|
* `modifiers` (bit-flag: Alt=1, Ctrl=2, Meta=4, Shift=8),
|
|
1089
1231
|
* `location` (0=standard, 1=left, 2=right, 3=numpad)
|
|
1090
1232
|
*
|
|
1091
|
-
* @throws
|
|
1233
|
+
* @throws no_focus - nothing in the page holds focus, so the key has nowhere
|
|
1234
|
+
* to go; click the field first
|
|
1235
|
+
* @throws busy - another action is already running on this page
|
|
1236
|
+
*
|
|
1237
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
1092
1238
|
*
|
|
1093
1239
|
* @example
|
|
1094
1240
|
* // Ctrl+A
|
|
@@ -1126,7 +1272,9 @@ export declare class CloudBrowser {
|
|
|
1126
1272
|
*
|
|
1127
1273
|
* @returns the selected text, or `""` when nothing is selected
|
|
1128
1274
|
*
|
|
1129
|
-
*
|
|
1275
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1276
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1277
|
+
* are no error codes to branch on.
|
|
1130
1278
|
*
|
|
1131
1279
|
* @example
|
|
1132
1280
|
* const sel = await browser.getSelection();
|
|
@@ -1148,8 +1296,10 @@ export declare class CloudBrowser {
|
|
|
1148
1296
|
*
|
|
1149
1297
|
* @returns empty string on success — the solution is applied server-side
|
|
1150
1298
|
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1299
|
+
* Rejects when no captcha appeared within imeoutMs, or when the one that did
|
|
1300
|
+
* could not be solved within
|
|
1301
|
+
etryAmount attempts. Neither carries a code:
|
|
1302
|
+
* solving runs outside the page, so there is no per-command code set here.
|
|
1153
1303
|
*
|
|
1154
1304
|
* @example
|
|
1155
1305
|
* await browser.solveCaptcha({ retryAmount: 2 });
|
|
@@ -1169,7 +1319,8 @@ export declare class CloudBrowser {
|
|
|
1169
1319
|
*
|
|
1170
1320
|
* @returns the ICE servers for the client `RTCPeerConnection`
|
|
1171
1321
|
*
|
|
1172
|
-
*
|
|
1322
|
+
* Rejects when TURN is not configured on the server. That is a deployment
|
|
1323
|
+
* condition rather than a per-call outcome, so it carries no code.
|
|
1173
1324
|
*
|
|
1174
1325
|
* @example
|
|
1175
1326
|
* const ice = await browser.getStreamConfig();
|
|
@@ -1186,8 +1337,16 @@ export declare class CloudBrowser {
|
|
|
1186
1337
|
* @returns the SDP answer to apply as the remote description, plus the
|
|
1187
1338
|
* viewport to map input coordinates into
|
|
1188
1339
|
*
|
|
1189
|
-
* @throws
|
|
1190
|
-
*
|
|
1340
|
+
* @throws already_active - a stream is already running on this session; stop it
|
|
1341
|
+
* before starting another
|
|
1342
|
+
* @throws negotiation_failed - the browser could not agree on a connection. The
|
|
1343
|
+
* message carries the negotiator's own diagnostic, which is usually where the
|
|
1344
|
+
* actual cause is
|
|
1345
|
+
*
|
|
1346
|
+
* An empty offer or an unconfigured TURN setup is a caller mistake rather than
|
|
1347
|
+
* an outcome, and rejects separately.
|
|
1348
|
+
*
|
|
1349
|
+
* @see {@link CommandError} for reading the code off the rejection
|
|
1191
1350
|
*
|
|
1192
1351
|
* @example
|
|
1193
1352
|
* const { answerSdp, viewport } = await browser.startStream(offer.sdp);
|
|
@@ -1198,17 +1357,18 @@ export declare class CloudBrowser {
|
|
|
1198
1357
|
* Tears down the live video stream for the session's page. Safe to call even
|
|
1199
1358
|
* if no stream is running.
|
|
1200
1359
|
*
|
|
1201
|
-
*
|
|
1360
|
+
* Rejects only on a transport failure. Stopping a stream that is not running is
|
|
1361
|
+
* a no-op rather than a failure, so there are no error codes to branch on.
|
|
1202
1362
|
*
|
|
1203
1363
|
* @example
|
|
1204
1364
|
* await browser.stopStream();
|
|
1205
1365
|
*/
|
|
1206
1366
|
stopStream(): Promise<void>;
|
|
1207
1367
|
/**
|
|
1208
|
-
* Registers a one-shot "reaction":
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1368
|
+
* Registers a one-shot "reaction": the browser watches for the `match`
|
|
1369
|
+
* locator in the background and, as soon as it matches, clicks it the same
|
|
1370
|
+
* way {@link CloudBrowser.click} does (scroll, human path, occlusion check) —
|
|
1371
|
+
* then removes itself. The reaction yields to any in-flight input
|
|
1212
1372
|
* action and only fires while the pointer is idle, so a reaction naturally
|
|
1213
1373
|
* slots into the gaps of a retrying foreground action (e.g. it dismisses a
|
|
1214
1374
|
* newsletter modal blocking a {@link CloudBrowser.click}, after which the
|
|
@@ -1247,6 +1407,10 @@ export declare class CloudBrowser {
|
|
|
1247
1407
|
*
|
|
1248
1408
|
* @returns true if a pending reaction with this id existed and was removed
|
|
1249
1409
|
*
|
|
1410
|
+
* Removing an id that is not registered is a no-op rather than an error, so the
|
|
1411
|
+
* returned boolean - not a rejection - is what tells you whether anything was
|
|
1412
|
+
* there. Rejects only on a transport failure.
|
|
1413
|
+
*
|
|
1250
1414
|
* @example
|
|
1251
1415
|
* const removed = await browser.removeReaction(id);
|
|
1252
1416
|
*/
|
|
@@ -1257,6 +1421,10 @@ export declare class CloudBrowser {
|
|
|
1257
1421
|
*
|
|
1258
1422
|
* @returns the pending reactions for the page
|
|
1259
1423
|
*
|
|
1424
|
+
* Rejects only on a transport failure - a dead session, a page that is gone,
|
|
1425
|
+
* a broken connection. This call has no semantic failure of its own, so there
|
|
1426
|
+
* are no error codes to branch on.
|
|
1427
|
+
*
|
|
1260
1428
|
* @example
|
|
1261
1429
|
* const pending = await browser.listReactions();
|
|
1262
1430
|
* for (const r of pending) console.log(r.reactionId, r.matchSelector);
|
|
@@ -1265,12 +1433,14 @@ export declare class CloudBrowser {
|
|
|
1265
1433
|
/**
|
|
1266
1434
|
* Runs `source` in the session's browser and waits for it to finish.
|
|
1267
1435
|
*
|
|
1268
|
-
* The script
|
|
1269
|
-
* page, and reaches the
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
1436
|
+
* The script runs beside the browser, in a V8 isolate of its own rather than
|
|
1437
|
+
* in the page, and reaches the document through the engine: a cross-origin
|
|
1438
|
+
* `<iframe>` is read as plain `contentDocument` with no frame ids anywhere,
|
|
1439
|
+
* values come back as live objects it can assign to rather than snapshots, an
|
|
1440
|
+
* element can be handed straight to `browser.click`, and the page sees nothing
|
|
1441
|
+
* injected. Steps cost microseconds rather than network round trips, so work
|
|
1442
|
+
* that is chatty by nature — polling for a selector, walking a list,
|
|
1443
|
+
* following pagination — is affordable there. A guide for it is still to come.
|
|
1274
1444
|
*
|
|
1275
1445
|
* This waits for as long as the script runs, and cannot be bounded: the run
|
|
1276
1446
|
* id needed to cancel only arrives with the reply. Use
|
|
@@ -1283,7 +1453,10 @@ export declare class CloudBrowser {
|
|
|
1283
1453
|
* @returns the return value and the script's whole console output. A script
|
|
1284
1454
|
* that threw is reported as `success: false`, not as a rejection
|
|
1285
1455
|
*
|
|
1286
|
-
*
|
|
1456
|
+
* Rejects only on a transport failure. A script that fails to compile or throws
|
|
1457
|
+
* is not a rejection: the returned result has success: false and
|
|
1458
|
+
esult holds
|
|
1459
|
+
* the message, so a broken script stays distinguishable from a broken connection.
|
|
1287
1460
|
*
|
|
1288
1461
|
* @example
|
|
1289
1462
|
* const result = await browser.runScript(`
|
|
@@ -1318,7 +1491,8 @@ export declare class CloudBrowser {
|
|
|
1318
1491
|
*
|
|
1319
1492
|
* @returns ScriptRun handle for awaiting or cancelling the run
|
|
1320
1493
|
*
|
|
1321
|
-
*
|
|
1494
|
+
* Rejects only on a transport failure: a script that fails to compile or throws
|
|
1495
|
+
* surfaces on the run itself rather than here.
|
|
1322
1496
|
*
|
|
1323
1497
|
* @example
|
|
1324
1498
|
* const run = await browser.startScript(source, (ev) => {
|
|
@@ -1345,7 +1519,8 @@ export declare class CloudBrowser {
|
|
|
1345
1519
|
*
|
|
1346
1520
|
* @returns ScriptFollow handle for stopping the subscription
|
|
1347
1521
|
*
|
|
1348
|
-
*
|
|
1522
|
+
* Rejects only on a transport failure: opening the subscription has no semantic
|
|
1523
|
+
* failure of its own.
|
|
1349
1524
|
*
|
|
1350
1525
|
* @example
|
|
1351
1526
|
* const follow = await browser.followScript(runId, (ev) => {
|
|
@@ -1370,7 +1545,9 @@ export declare class CloudBrowser {
|
|
|
1370
1545
|
* @returns how many runs were cancelled; 0 when the id named nothing in
|
|
1371
1546
|
* flight
|
|
1372
1547
|
*
|
|
1373
|
-
*
|
|
1548
|
+
* Rejects only on a transport failure. Cancelling runs that have already
|
|
1549
|
+
* finished, or none at all, is a no-op - read the returned count to learn how
|
|
1550
|
+
* many were actually stopped.
|
|
1374
1551
|
*
|
|
1375
1552
|
* @example
|
|
1376
1553
|
* await browser.stopScripts(""); // abandon everything running
|
|
@@ -1386,7 +1563,9 @@ export declare class CloudBrowser {
|
|
|
1386
1563
|
*
|
|
1387
1564
|
* @returns one entry per run still executing
|
|
1388
1565
|
*
|
|
1389
|
-
*
|
|
1566
|
+
* Rejects only on a transport failure - a dead session, a broken connection.
|
|
1567
|
+
* This call has no semantic failure of its own, so there are no error codes to
|
|
1568
|
+
* branch on.
|
|
1390
1569
|
*
|
|
1391
1570
|
* @example
|
|
1392
1571
|
* for (const run of await browser.listScriptRuns()) {
|