browserscale-ts 1.2.1 → 1.4.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/dist/options.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Locator } from "./locator.ts";
1
2
  /** Mouse button used by {@link CloudBrowser.click}. */
2
3
  export type Button = "left" | "right" | "middle";
3
4
  /** Mouse phase performed by {@link CloudBrowser.click}. */
@@ -24,6 +25,25 @@ export interface ClickOpts {
24
25
  */
25
26
  action?: ClickAction;
26
27
  }
28
+ /**
29
+ * Optional customization for {@link CloudBrowser.addReaction}. All fields are
30
+ * optional; missing or zero values mean "use the server default".
31
+ */
32
+ export interface ReactionOpts {
33
+ /**
34
+ * Override the click target. Omit to click the matched element itself.
35
+ * Provide a `css()`/`js()` {@link Locator} to click a different element,
36
+ * resolved in the matched element's frame (e.g. a modal's close "X").
37
+ * `node()`/`at()` locators are rejected.
38
+ */
39
+ on?: Locator;
40
+ /** Mouse button for the click. Default `"left"`. */
41
+ button?: Button;
42
+ /** `1` = single click (default), `2` = double-click. */
43
+ clickCount?: number;
44
+ /** Poll cadence in milliseconds for the shared page loop. Default 300. */
45
+ intervalMs?: number;
46
+ }
27
47
  /**
28
48
  * Optional customization for {@link CloudBrowser.fill}. All fields are
29
49
  * optional; missing values mean "use the server default".
@@ -41,6 +61,17 @@ export interface FillOpts {
41
61
  * in the field.
42
62
  */
43
63
  clearFirst?: boolean;
64
+ /**
65
+ * Budget in ms to make the field focusable+clickable (locate, scroll,
66
+ * settle, un-occlude), mirroring the click timeout. Omit for the server
67
+ * default (5000). `0` makes fill one-shot (no retry).
68
+ */
69
+ timeoutMs?: number;
70
+ /**
71
+ * Settle window in ms before the focus click, mirroring the click
72
+ * steady-time. Omit for the server default (750). `0` skips settling.
73
+ */
74
+ steadyMs?: number;
44
75
  }
45
76
  /**
46
77
  * Optional customization for {@link CloudBrowser.selectByIndex},
@@ -89,10 +120,58 @@ export interface GetDOMOpts {
89
120
  }
90
121
  /** Optional customization for {@link CloudBrowser.getObservation}. */
91
122
  export interface GetObservationOpts {
92
- /** Default 200. */
123
+ /**
124
+ * `"text"` (default) for the compact line format meant to be handed to a
125
+ * model as-is, or `"json"` for the structured form. Only the requested
126
+ * representation is built, so asking for one does not cost the other.
127
+ */
128
+ format?: "text" | "json";
129
+ /**
130
+ * Cap on emitted elements per frame. Default 800 — a safety net against
131
+ * runaway documents; `maxTotalTokens` is the limit that normally binds.
132
+ */
93
133
  maxElementsPerFrame?: number;
94
- /** Default 200. */
134
+ /**
135
+ * Cap on human-readable strings (labels, text, values) in characters.
136
+ * Default 300. Identifier-like attributes (type, name, role) have their own
137
+ * fixed, shorter cap and are unaffected.
138
+ */
95
139
  maxTextLength?: number;
140
+ /**
141
+ * Budget across ALL frames, in estimated tokens rather than characters —
142
+ * the same character count is worth roughly four times as many tokens in
143
+ * CJK text as in ASCII. Default 8000. Frames are visited in tree order and
144
+ * each gets whatever is left.
145
+ */
146
+ maxTotalTokens?: number;
147
+ /**
148
+ * Include element bounds as `bounds="x,y,w,h"`. Off by default; bounds cost
149
+ * about as much as the rest of a row and are rarely needed, since elements
150
+ * are addressed by backendNodeId.
151
+ */
152
+ includeBounds?: boolean;
153
+ /** Only emit elements intersecting the frame's current viewport. */
154
+ viewportOnly?: boolean;
155
+ /**
156
+ * Subtree scope — set exactly one of `backendNodeId`, `selector` or
157
+ * `jsExpression` to observe only that element's subtree (follow-up looks at
158
+ * a form then cost the form, not the ads around it). Omit all three for the
159
+ * whole page. Child iframes reached inside the scope are still visited.
160
+ */
161
+ backendNodeId?: number;
162
+ /** Scope root by CSS selector. */
163
+ selector?: string;
164
+ /**
165
+ * Scope root by JS expression that evaluates to a DOM Element (including
166
+ * `__wrc.shadow(...)` for closed shadow roots).
167
+ */
168
+ jsExpression?: string;
169
+ /**
170
+ * Where to look up the scope root: a specific `frameId`, omit for the main
171
+ * frame, or {@link AllFrames} to search every frame until found. Ignored when
172
+ * observing the whole page.
173
+ */
174
+ frameId?: string;
96
175
  }
97
176
  /** Optional customization for {@link CloudBrowser.screenshot}. */
98
177
  export interface ScreenshotOpts {
package/dist/types.d.ts CHANGED
@@ -100,6 +100,38 @@ export interface OccluderInfo {
100
100
  * invisible, a real click would fall through.
101
101
  */
102
102
  hittableWhileInvisible: boolean;
103
+ /**
104
+ * Computed position keyword. `"fixed"`/`"sticky"` means the blocker is pinned
105
+ * (by itself or an ancestor) and stays put no matter where the pointer goes —
106
+ * clear it by scrolling the target out from under it; ordinary overlays often
107
+ * collapse once the pointer leaves.
108
+ */
109
+ position: string;
110
+ }
111
+ /**
112
+ * ElementRef is a lightweight descriptor of an element — enough to identify it
113
+ * (and decide what to do) without another DOM round-trip. It names the element
114
+ * that stole focus in a {@link FillError} focus-loss failure.
115
+ */
116
+ export interface ElementRef {
117
+ backendNodeId: number;
118
+ /** Upper-case tag name, e.g. "INPUT", "BUTTON", "DIV". */
119
+ tagName: string;
120
+ /** id attribute, if present. */
121
+ id?: string;
122
+ /** name attribute, if present. */
123
+ name?: string;
124
+ /** class attribute, if present. */
125
+ className?: string;
126
+ /** `<input>` type, if the element is an `<input>`. */
127
+ inputType?: string;
128
+ /** Whitespace-collapsed textContent/value snippet (max 120 chars). */
129
+ text?: string;
130
+ /**
131
+ * Whether this element is itself an editable text sink (input / textarea /
132
+ * contenteditable).
133
+ */
134
+ editable: boolean;
103
135
  }
104
136
  /**
105
137
  * WaitConditionStatus is the per-condition diagnostic carried by
@@ -181,15 +213,6 @@ export interface SelectOptionResult {
181
213
  selectedValue: string;
182
214
  selectedText: string;
183
215
  }
184
- /**
185
- * ObservationResult is the compact page snapshot returned by
186
- * {@link CloudBrowser.getObservation} — the visible, interactive elements
187
- * rendered as prompt-friendly text and as JSON.
188
- */
189
- export interface ObservationResult {
190
- text: string;
191
- json: string;
192
- }
193
216
  /**
194
217
  * ScreenshotResult is a single captured image of the page, returned by
195
218
  * {@link CloudBrowser.screenshot}. `dataBase64` holds the encoded image bytes
@@ -246,3 +269,37 @@ export interface RentResponse {
246
269
  acceptLanguage: string;
247
270
  fingerprint: string;
248
271
  }
272
+ /**
273
+ * IceServer is one entry for a WebRTC `RTCPeerConnection`'s `iceServers`
274
+ * config: a TURN (or STUN) URL plus the short-lived credentials to
275
+ * authenticate with it. Pass these to your peer before creating the offer.
276
+ */
277
+ export interface IceServer {
278
+ /** ICE server URLs (e.g. `turn:relay.example.com:3478?transport=udp`). */
279
+ urls: string[];
280
+ /** Short-lived TURN REST username (empty for plain STUN). */
281
+ username: string;
282
+ /** Short-lived TURN REST credential (empty for plain STUN). */
283
+ credential: string;
284
+ }
285
+ /**
286
+ * ReactionInfo describes a still-pending reaction, as returned by
287
+ * {@link CloudBrowser.listReactions}. One-shot reactions that have already
288
+ * fired are gone and never appear here.
289
+ */
290
+ export interface ReactionInfo {
291
+ /** Stable id assigned by {@link CloudBrowser.addReaction} (pass to removeReaction). */
292
+ reactionId: string;
293
+ /** Set if the reaction matches by CSS selector. */
294
+ matchSelector: string;
295
+ /** Set if the reaction matches by JS expression. */
296
+ matchJsExpression: string;
297
+ /** Set if the click target differs from the matched element. */
298
+ actionSelector: string;
299
+ /** Set if the click target differs from the matched element. */
300
+ actionJsExpression: string;
301
+ /** Frame scope: `""` for the main frame, a specific frameId, or `AllFrames`. */
302
+ frameId: string;
303
+ /** Whether the match additionally requires the element to be visible. */
304
+ visible: boolean;
305
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserscale-ts",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Official SDK for browserscale — undetected stealth browsers in the cloud. Rent real Chromium sessions with unique fingerprints, built-in proxies, captcha solving, human-like input and live video — scale web scraping and automation without running a single browser yourself.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",