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/dist/locator.js CHANGED
@@ -1,4 +1,3 @@
1
- import { DefaultSteadyMs, DefaultVisible } from "./defaults.js";
2
1
  import { BrowserScaleError } from "./errors.js";
3
2
  /**
4
3
  * AllFrames is the sentinel for "match in every frame on the page".
@@ -53,9 +52,9 @@ export class Locator {
53
52
  * Enforces or disables the visibility check for this Locator's wait
54
53
  * condition.
55
54
  *
56
- * Pass `false` to opt out of the default `DefaultVisible` (true). Has
57
- * no effect when used as an action target — actions never check
58
- * visibility before dispatching.
55
+ * Visibility is required by default, so pass `false` to wait for DOM
56
+ * presence alone. Has no effect when used as an action target — actions
57
+ * never check visibility before dispatching.
59
58
  *
60
59
  * @param v - true to require visibility, false to skip the check
61
60
  *
@@ -71,9 +70,9 @@ export class Locator {
71
70
  * Requires the element to keep a stable position and size for at least
72
71
  * `ms` milliseconds before the wait matches.
73
72
  *
74
- * Pass 0 to disable the default `DefaultSteadyMs` (500). Has no effect
75
- * for js() expressions that return a non-Element value, nor when used
76
- * as an action target.
73
+ * Settling defaults to 500ms, so pass 0 to match the instant the element
74
+ * is found. Has no effect for js() expressions that return a non-Element
75
+ * value, nor when used as an action target.
77
76
  *
78
77
  * @param ms - steady-state duration in milliseconds; 0 disables
79
78
  *
@@ -132,19 +131,11 @@ export class Locator {
132
131
  // ── Constructors (top-level functions re-export these) ──────────────
133
132
  /** @internal */
134
133
  static _css(selector) {
135
- return new Locator({
136
- selector,
137
- visibleFlag: DefaultVisible,
138
- steadyMs: DefaultSteadyMs,
139
- });
134
+ return new Locator({ selector });
140
135
  }
141
136
  /** @internal */
142
137
  static _js(expression) {
143
- return new Locator({
144
- jsExpression: expression,
145
- visibleFlag: DefaultVisible,
146
- steadyMs: DefaultSteadyMs,
147
- });
138
+ return new Locator({ jsExpression: expression });
148
139
  }
149
140
  /** @internal */
150
141
  static _node(backendNodeId) {
@@ -162,9 +153,10 @@ export class Locator {
162
153
  * css waits for / targets an element matching the given CSS selector.
163
154
  *
164
155
  * When used in {@link CloudBrowser.wait}/{@link CloudBrowser.waitAny}, the
165
- * returned Locator carries the SDK defaults `DefaultVisible` (true) and
166
- * `DefaultSteadyMs` (500). Override per call with `.visible(false)` /
167
- * `.steady(ms)` (use `.steady(0)` to disable the steady check).
156
+ * condition requires the element to be visible and to hold still for 500ms
157
+ * before it matches — the API's defaults for a condition that does not set
158
+ * them. Override per call with `.visible(false)` / `.steady(ms)` (use
159
+ * `.steady(0)` to disable the steady check).
168
160
  *
169
161
  * When used as an action target (click, fill, …) the visible/steady
170
162
  * fields are ignored — there are no corresponding fields on the action
@@ -186,8 +178,8 @@ export function css(selector) {
186
178
  /**
187
179
  * js waits for / targets the result of a JavaScript expression.
188
180
  *
189
- * Same wait defaults as {@link css} (`DefaultVisible`=true,
190
- * `DefaultSteadyMs`=500); these only apply when the expression returns a
181
+ * Same wait defaults as {@link css} (visible, 500ms steady); these only
182
+ * apply when the expression returns a
191
183
  * DOM Element. For non-Element truthy values (boolean, string, number,
192
184
  * plain object) both fields are no-ops and the condition matches as soon
193
185
  * as the value is truthy. Use `.visible(false)` / `.steady(0)` to opt out.
@@ -77,8 +77,9 @@ export declare class NetworkCapture {
77
77
  * {@link CloudBrowser.stopNetworkCapture} instead: stop awaits the reader,
78
78
  * which cannot finish while the handler it called is still running.
79
79
  *
80
- * @throws UNKNOWN_ERROR - the capture could not be disarmed; the local reader
81
- * is shut down regardless
80
+ * Rejects only on a transport failure, and the local reader is shut down
81
+ * regardless. Disarming a capture that is not running is a no-op rather than a
82
+ * failure, so there are no error codes to branch on.
82
83
  */
83
84
  stop(): Promise<void>;
84
85
  }
@@ -88,8 +88,9 @@ export class NetworkCapture {
88
88
  * {@link CloudBrowser.stopNetworkCapture} instead: stop awaits the reader,
89
89
  * which cannot finish while the handler it called is still running.
90
90
  *
91
- * @throws UNKNOWN_ERROR - the capture could not be disarmed; the local reader
92
- * is shut down regardless
91
+ * Rejects only on a transport failure, and the local reader is shut down
92
+ * regardless. Disarming a capture that is not running is a no-op rather than a
93
+ * failure, so there are no error codes to branch on.
93
94
  */
94
95
  async stop() {
95
96
  if (this.stopped)
package/dist/options.d.ts CHANGED
@@ -92,7 +92,7 @@ export interface SelectOpts {
92
92
  }
93
93
  /** Optional customization for {@link CloudBrowser.wait} / {@link CloudBrowser.waitForAny}. */
94
94
  export interface WaitOpts {
95
- /** Default `DefaultWaitTimeoutMs` (30 000 ms). */
95
+ /** Omitted leaves it to the API, which defaults to 30 000 ms. */
96
96
  timeoutMs?: number;
97
97
  }
98
98
  /** Lifecycle event {@link CloudBrowser.navigate} waits for before returning. */
package/dist/scripts.d.ts CHANGED
@@ -144,7 +144,8 @@ export declare class ScriptRun {
144
144
  *
145
145
  * @returns how the script ended
146
146
  *
147
- * @throws UNKNOWN_ERROR - the outcome could not be observed
147
+ * Rejects only on a transport failure - the connection dying, or the run being
148
+ * abandoned. A script that threw is a normal outcome and arrives in the result.
148
149
  */
149
150
  wait(): Promise<ScriptFinished>;
150
151
  /**
@@ -155,8 +156,8 @@ export declare class ScriptRun {
155
156
  * at its next operation in the page. Either way the handler sees a `finished`
156
157
  * with `stopped` set, unless the local reader is torn down first.
157
158
  *
158
- * @throws UNKNOWN_ERROR - the run could not be cancelled server-side; the
159
- * local reader is detached regardless
159
+ * Rejects only on a transport failure, and the local reader is detached
160
+ * regardless. Cancelling a run that has already finished is a no-op.
160
161
  */
161
162
  stop(): Promise<void>;
162
163
  /**
package/dist/scripts.js CHANGED
@@ -122,7 +122,8 @@ export class ScriptRun {
122
122
  *
123
123
  * @returns how the script ended
124
124
  *
125
- * @throws UNKNOWN_ERROR - the outcome could not be observed
125
+ * Rejects only on a transport failure - the connection dying, or the run being
126
+ * abandoned. A script that threw is a normal outcome and arrives in the result.
126
127
  */
127
128
  async wait() {
128
129
  await this.endedPromise;
@@ -140,8 +141,8 @@ export class ScriptRun {
140
141
  * at its next operation in the page. Either way the handler sees a `finished`
141
142
  * with `stopped` set, unless the local reader is torn down first.
142
143
  *
143
- * @throws UNKNOWN_ERROR - the run could not be cancelled server-side; the
144
- * local reader is detached regardless
144
+ * Rejects only on a transport failure, and the local reader is detached
145
+ * regardless. Cancelling a run that has already finished is a no-op.
145
146
  */
146
147
  async stop() {
147
148
  if (this.detached)
package/dist/types.d.ts CHANGED
@@ -167,6 +167,11 @@ export interface NetworkCaptureOptions {
167
167
  * argument order) and where the matched element lives.
168
168
  */
169
169
  export interface WaitResult {
170
+ /**
171
+ * False iff nothing matched before the deadline. Redundant with `index` being
172
+ * -1, and carried so every command answers the same question the same way.
173
+ */
174
+ success: boolean;
170
175
  index: number;
171
176
  frameId: string;
172
177
  backendNodeId: number;
@@ -283,6 +288,13 @@ export interface NavigateResult {
283
288
  * purely a TS hint, not a runtime guarantee.
284
289
  */
285
290
  export interface EvaluateResult<T = unknown> {
291
+ /**
292
+ * False only when the expression never produced a value, which rejects the
293
+ * call — so a resolved result always has this true. An expression that answers
294
+ * falsy is a successful evaluation, so this does not mean "the answer was
295
+ * false".
296
+ */
297
+ success: boolean;
286
298
  value: T;
287
299
  backendNodeId: number;
288
300
  isVisible: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserscale-ts",
3
- "version": "1.7.0",
3
+ "version": "1.8.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",