browserscale-ts 1.5.0 → 1.7.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 +30 -0
- package/dist/browser.d.ts +4 -1
- package/dist/browser.js +5 -0
- package/dist/browserscale.browser.js +1581 -46
- package/dist/client.d.ts +316 -7
- package/dist/client.js +588 -7
- package/dist/dom-mirror.d.ts +271 -0
- package/dist/dom-mirror.js +613 -0
- package/dist/gen/wrc_pb.d.ts +1251 -87
- package/dist/gen/wrc_pb.js +214 -44
- package/dist/index.d.ts +31 -1
- package/dist/index.js +61 -0
- package/dist/internal/convert.d.ts +8 -2
- package/dist/internal/convert.js +39 -0
- package/dist/network-capture.d.ts +84 -0
- package/dist/network-capture.js +107 -0
- package/dist/scripts.d.ts +205 -0
- package/dist/scripts.js +234 -0
- package/dist/types.d.ts +157 -0
- package/dist/ws-transport.d.ts +15 -1
- package/dist/ws-transport.js +155 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,11 +60,37 @@ Rent an isolated browser session in seconds, automate it with human-like input,
|
|
|
60
60
|
through. Wait for, block, mock or modify requests and responses without
|
|
61
61
|
leaving the SDK; mark repeated assets as static with `setStaticPaths` to
|
|
62
62
|
serve them from a server-side cache and cut proxy bandwidth on repeat runs.
|
|
63
|
+
- **Streaming network capture** — `captureNetwork` reports every request the
|
|
64
|
+
session completes as it happens, and "every request" is literal: capture sits
|
|
65
|
+
in the browser process rather than in a page, so cross-process iframes,
|
|
66
|
+
workers and service workers are included, the headers are the ones actually
|
|
67
|
+
put on the wire, and each hop of a redirect chain arrives as its own exchange.
|
|
68
|
+
Requests are never paused, so the page loads at full speed.
|
|
69
|
+
- **Live DOM mirror** — `mirrorDom` holds the page as one incrementally updated
|
|
70
|
+
tree: the browser sends the top once and from then on only what changed in the
|
|
71
|
+
part you expanded, so a page churning inside a collapsed subtree costs one
|
|
72
|
+
number per batch instead of a re-serialized document. An `<iframe>` is an
|
|
73
|
+
ordinary element whose one child is the document it hosts, however deeply
|
|
74
|
+
nested or cross-origin, and `getDomRevision` is the O(1) change detector to
|
|
75
|
+
poll when you are not consuming events.
|
|
63
76
|
- **Agent-friendly observation** — `getObservation` returns one line per visible
|
|
64
77
|
element across every frame, under headers carrying the URL, title and scroll
|
|
65
78
|
offset, with live form state (typed values, checkbox state, `<select>`
|
|
66
79
|
options) and a node handle to act on. A model reasons over what matters
|
|
67
80
|
instead of raw HTML, and doesn't need a JS round-trip to ask where it is.
|
|
81
|
+
- **Scripts that run inside the browser** — `runScript` sends JavaScript to the
|
|
82
|
+
session and runs it in the browser process itself, with a `browser` object
|
|
83
|
+
giving it the same operations this SDK exposes — but as local calls rather than
|
|
84
|
+
network round trips, so a loop that polls or walks a list costs microseconds
|
|
85
|
+
per step instead of tens of milliseconds. The log streams back as the script
|
|
86
|
+
produces it. `startScript` leaves a script running without the caller, which is
|
|
87
|
+
how work outlives the process that started it, and `followScript` attaches to
|
|
88
|
+
one already under way.
|
|
89
|
+
- **Sessions you can find again** — `listBrowsers` reports what an API key is
|
|
90
|
+
paying for: ids, proxy, egress address and remaining rental. A session
|
|
91
|
+
therefore outlives the process that rented it — recover it after a restart, or
|
|
92
|
+
from another machine entirely, and hand the `grpcUrl` it reports straight to
|
|
93
|
+
`connectSession`.
|
|
68
94
|
- **Flow-optimized TypeScript** — fully typed promise-based API, `wait` races
|
|
69
95
|
multiple outcomes, JS locators target elements by page logic when CSS is
|
|
70
96
|
not enough. Runs in Node.js (native gRPC) and the browser (WebSocket via
|
|
@@ -120,12 +146,16 @@ reports the element that occluded the click.
|
|
|
120
146
|
| --- | --- |
|
|
121
147
|
| `rentBrowser(cfg)` | Rent a fresh session (`new BrowserConfig(key, secs, host, port, user, pass)`). |
|
|
122
148
|
| `connectSession(grpcUrl, apiKey, sessionId)` | Attach to an existing session by id (from a prior rent). |
|
|
149
|
+
| `listBrowsers(apiKey)` | The sessions a key currently holds, each with the `grpcUrl` to hand to `connectSession`. |
|
|
123
150
|
| `browser.navigate(url, opts?)` | Load a URL. |
|
|
124
151
|
| `browser.wait(condition, opts?)` | Wait for a locator condition; returns the matched `frameId`. |
|
|
125
152
|
| `browser.click(target, opts?)` | Human-like click; throws a rich `ClickError` on failure. |
|
|
126
153
|
| `browser.fill(target, text, opts?)` | Per-key typing that fires real input events; `insertText` for bulk commit. |
|
|
127
154
|
| `browser.evaluate(expr)` | Run JS in the page/frame and get a typed value back. |
|
|
155
|
+
| `browser.runScript(source)` | Run JavaScript in the browser process, where every operation is a local call; `startScript` leaves it running, `followScript` watches one already going. |
|
|
128
156
|
| `browser.getObservation(opts?)` | Compact, node-handle-tagged view of the visible page across frames; `opts` tunes budgets and format. |
|
|
157
|
+
| `browser.captureNetwork(opts, onExchange)` | Stream every request the session completes, optionally with response bodies. |
|
|
158
|
+
| `browser.mirrorDom(opts, onChange, onResync?)` | Live, incrementally updated copy of the page's DOM across every frame. |
|
|
129
159
|
| `browser.solveCaptcha(opts?)` | Solve an interactive challenge in the live browser. |
|
|
130
160
|
| `browser.stopBrowser()` | Release the rental. |
|
|
131
161
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ 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
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, ElementRef, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, } from "./types.ts";
|
|
8
|
+
export type { Rect, FrameInfo, PageInfo, Header, InterceptedRequest, InterceptedResponse, NetworkExchange, NetworkResourceType, NetworkServedFrom, NetworkBodies, NetworkCaptureOptions, WaitResult, WaitConditionStatus, OccluderInfo, ElementRef, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, BrowserInfo, } 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
|
+
export { ScriptRun, ScriptFollow, type ScriptEvent, type ScriptEventHandler, type ScriptFinished, type ScriptLogEntry, type ScriptResult, type ScriptRunInfo, } from "./scripts.ts";
|
|
12
|
+
export { NetworkCapture, type NetworkExchangeHandler } from "./network-capture.ts";
|
|
13
|
+
export { DomMirror, type DomNode, type DomSnapshot, type DomMirrorOptions, type DomChangeHandler, type DomResyncHandler, type DomResyncReason, } from "./dom-mirror.ts";
|
|
11
14
|
export type { CookieParam } from "./cookies.ts";
|
|
12
15
|
export type { StorageItem, StorageOriginEntry } from "./storage.ts";
|
|
13
16
|
export type { AuthSession, DbscSession } from "./auth-session.ts";
|
package/dist/browser.js
CHANGED
|
@@ -10,6 +10,11 @@ export { Locator, css, js, node, at, AllFrames } from "./locator.js";
|
|
|
10
10
|
export { DefaultWaitTimeoutMs, DefaultVisible, DefaultSteadyMs, } from "./defaults.js";
|
|
11
11
|
// Errors — base class plus the typed semantic-failure subclasses
|
|
12
12
|
export { BrowserScaleError, ClickError, FillError, DragError, ScrollError, MoveError, SelectOptionError, WaitError, } from "./errors.js";
|
|
13
|
+
// Scripts (automation running inside the browser process)
|
|
14
|
+
export { ScriptRun, ScriptFollow, } from "./scripts.js";
|
|
15
|
+
// Network capture (traffic log)
|
|
16
|
+
export { NetworkCapture } from "./network-capture.js";
|
|
17
|
+
export { DomMirror, } from "./dom-mirror.js";
|
|
13
18
|
// Browser-side factory functions ───────────────────────────────────────
|
|
14
19
|
/**
|
|
15
20
|
* Attaches a {@link CloudBrowser} to an existing session over a raw
|