browserscale-ts 1.1.0 → 1.2.1

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 CHANGED
@@ -1,10 +1,21 @@
1
- # browserscale-ts — browserscale SDK for TypeScript
1
+ <div align="center">
2
2
 
3
- Official TypeScript SDK for [browserscale](https://browserscale.cloud): real
4
- Chromium browsers in the cloud, driven over gRPC. Rent an isolated browser
5
- session in seconds, automate it with human-like input, intercept network
6
- traffic, solve captchas, and watch a live video stream of everything your
7
- script does.
3
+ # browserscale-ts
4
+
5
+ **The official TypeScript SDK for [browserscale](https://browserscale.cloud) — real Chromium browsers in the cloud, driven over gRPC.**
6
+
7
+ Rent an isolated browser session in seconds, automate it with human-like input, intercept network traffic, solve captchas, and watch a live video stream of everything your script does. Runs in Node.js and the browser.
8
+
9
+ [![npm](https://img.shields.io/npm/v/browserscale-ts?logo=npm)](https://www.npmjs.com/package/browserscale-ts)
10
+ ![Node](https://img.shields.io/badge/node-%E2%89%A518-339933?logo=node.js&logoColor=white)
11
+ ![Types](https://img.shields.io/badge/types-included-3178C6?logo=typescript&logoColor=white)
12
+ ![License: MIT](https://img.shields.io/badge/license-MIT-blue)
13
+
14
+ [Install](#install) · [Quickstart](#quickstart) · [Core API](#core-api) · [Docs](#documentation) · [Ecosystem](#ecosystem)
15
+
16
+ </div>
17
+
18
+ ---
8
19
 
9
20
  ## Features
10
21
 
@@ -64,7 +75,7 @@ script does.
64
75
  npm install browserscale-ts
65
76
  ```
66
77
 
67
- Requires Node 18+. Ships as an ES module with bundled type declarations.
78
+ Requires **Node 18+**. Ships as an ES module with bundled type declarations.
68
79
 
69
80
  ## Quickstart
70
81
 
@@ -98,6 +109,29 @@ main();
98
109
  Run it and you should see `title: Example Domain`. Get an API key from your
99
110
  [dashboard](https://browserscale.cloud/dashboard/api-keys).
100
111
 
112
+ ## Core API
113
+
114
+ Fully typed and promise-based. Failures throw typed error classes (`ClickError`,
115
+ `WaitError`, `FillError`, …) carrying structured detail — e.g. a `ClickError`
116
+ reports the element that occluded the click.
117
+
118
+ | Call | What it does |
119
+ | --- | --- |
120
+ | `rentBrowser(cfg)` | Rent a fresh session (`new BrowserConfig(key, secs, host, port, user, pass)`). |
121
+ | `connectSession(grpcUrl, apiKey, sessionId)` | Attach to an existing session by id (from a prior rent). |
122
+ | `browser.navigate(url, opts?)` | Load a URL. |
123
+ | `browser.wait(condition, opts?)` | Wait for a locator condition; returns the matched `frameId`. |
124
+ | `browser.click(target, opts?)` | Human-like click; throws a rich `ClickError` on failure. |
125
+ | `browser.fill(target, text, opts?)` | Per-key typing that fires real input events; `insertText` for bulk commit. |
126
+ | `browser.evaluate(expr)` | Run JS in the page/frame and get a typed value back. |
127
+ | `browser.getObservation(opts?)` | Compact, node-handle-tagged view of interactive elements across frames. |
128
+ | `browser.solveCaptcha(opts?)` | Solve an interactive challenge in the live browser. |
129
+ | `browser.stopBrowser()` | Release the rental. |
130
+
131
+ Locators: `css(...)`, `js(...)` (target by page logic when CSS can't). Plus
132
+ cookies, storage, network interception, mouse/scroll/drag/select/key events, and
133
+ canvas reads — see the full reference below.
134
+
101
135
  ## Documentation
102
136
 
103
137
  - [Introduction](https://browserscale.cloud/docs) — what browserscale is, use cases and
@@ -113,10 +147,23 @@ Run it and you should see `title: Example Domain`. Get an API key from your
113
147
  - [TypeScript API reference](https://browserscale.cloud/docs/api-reference/ts) —
114
148
  every method, type and option with runnable examples
115
149
 
116
- ## Go
150
+ ## Browser usage
151
+
152
+ The default entry point uses native gRPC (Node.js). To drive a session from a
153
+ browser over WebSocket, import the browser build:
154
+
155
+ ```ts
156
+ import { rentBrowser, css } from "browserscale-ts/browser";
157
+ ```
158
+
159
+ ## Ecosystem
117
160
 
118
- Prefer Go? Use the Go SDK:
119
- [browserscale-go](https://github.com/browserscale/browserscale-go).
161
+ | Project | Role |
162
+ | --- | --- |
163
+ | **browserscale-ts** (you are here) | The TypeScript SDK (Node.js + browser). |
164
+ | [**browserscale-go**](https://github.com/browserscale/browserscale-go) | The Go SDK. |
165
+ | [**browserscale-cli**](https://github.com/browserscale/browserscale-cli) | `browserscale init` — scaffold a runnable automation module (Go). |
166
+ | [**browserscale-kit**](https://github.com/browserscale/browserscale-kit) | Go toolkit around the browser: config, store, queues, proxies, logging, mail. |
120
167
 
121
168
  ## License
122
169
 
package/dist/browser.d.ts CHANGED
@@ -4,8 +4,8 @@ export { WebSocketTransport } from "./ws-transport.ts";
4
4
  export { BrowserConfig } from "./config.ts";
5
5
  export { Locator, css, js, node, at, AllFrames } from "./locator.ts";
6
6
  export { DefaultWaitTimeoutMs, DefaultVisible, DefaultSteadyMs, } from "./defaults.ts";
7
- export { BrowserScaleError } from "./errors.ts";
8
- export type { Rect, FrameInfo, PageInfo, Header, InterceptedRequest, InterceptedResponse, WaitResult, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ObservationResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, } from "./types.ts";
7
+ export { BrowserScaleError, ClickError, FillError, DragError, ScrollError, MoveError, SelectOptionError, WaitError, } from "./errors.ts";
8
+ export type { Rect, FrameInfo, PageInfo, Header, InterceptedRequest, InterceptedResponse, WaitResult, WaitConditionStatus, OccluderInfo, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ObservationResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, } from "./types.ts";
9
9
  export type { Button, ClickAction, ClickOpts, FillOpts, SelectOpts, WaitOpts, WaitUntil, NavigateOpts, LoadHTMLOpts, GetDOMOpts, GetObservationOpts, ScreenshotOpts, ReadCanvasOpts, } from "./options.ts";
10
10
  export { type RequestPattern, type HeaderModification, type HeaderModificationAction, } from "./network.ts";
11
11
  export type { CookieParam } from "./cookies.ts";
package/dist/browser.js CHANGED
@@ -8,8 +8,8 @@ export { BrowserConfig } from "./config.js";
8
8
  export { Locator, css, js, node, at, AllFrames } from "./locator.js";
9
9
  // Defaults the SDK applies before sending a request
10
10
  export { DefaultWaitTimeoutMs, DefaultVisible, DefaultSteadyMs, } from "./defaults.js";
11
- // Errors
12
- export { BrowserScaleError } from "./errors.js";
11
+ // Errors — base class plus the typed semantic-failure subclasses
12
+ export { BrowserScaleError, ClickError, FillError, DragError, ScrollError, MoveError, SelectOptionError, WaitError, } from "./errors.js";
13
13
  // Browser-side factory functions ───────────────────────────────────────
14
14
  /**
15
15
  * Attaches a {@link CloudBrowser} to an existing session over a raw