browserscale-ts 1.5.0 → 1.7.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 +33 -0
- package/dist/browser.d.ts +4 -1
- package/dist/browser.js +5 -0
- package/dist/browserscale.browser.js +1583 -46
- package/dist/client.d.ts +318 -7
- package/dist/client.js +590 -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,40 @@ 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 beside the browser** — `runScript` sends JavaScript to the
|
|
82
|
+
session, where it runs in an isolate of its own and reaches the document
|
|
83
|
+
through the engine: a cross-origin `<iframe>` is read as plain
|
|
84
|
+
`contentDocument` with no frame ids anywhere, values come back as live objects
|
|
85
|
+
you can assign to rather than snapshots, an element can be handed straight to
|
|
86
|
+
`browser.click`, and the page sees nothing injected. Steps cost microseconds
|
|
87
|
+
rather than network round trips, so loops are affordable. The log streams back
|
|
88
|
+
as the script produces it; `startScript` leaves a script running without the
|
|
89
|
+
caller, which is how work outlives the process that started it, and
|
|
90
|
+
`followScript` attaches to one already under way. A guide for it is still to
|
|
91
|
+
come.
|
|
92
|
+
- **Sessions you can find again** — `listBrowsers` reports what an API key is
|
|
93
|
+
paying for: ids, proxy, egress address and remaining rental. A session
|
|
94
|
+
therefore outlives the process that rented it — recover it after a restart, or
|
|
95
|
+
from another machine entirely, and hand the `grpcUrl` it reports straight to
|
|
96
|
+
`connectSession`.
|
|
68
97
|
- **Flow-optimized TypeScript** — fully typed promise-based API, `wait` races
|
|
69
98
|
multiple outcomes, JS locators target elements by page logic when CSS is
|
|
70
99
|
not enough. Runs in Node.js (native gRPC) and the browser (WebSocket via
|
|
@@ -120,12 +149,16 @@ reports the element that occluded the click.
|
|
|
120
149
|
| --- | --- |
|
|
121
150
|
| `rentBrowser(cfg)` | Rent a fresh session (`new BrowserConfig(key, secs, host, port, user, pass)`). |
|
|
122
151
|
| `connectSession(grpcUrl, apiKey, sessionId)` | Attach to an existing session by id (from a prior rent). |
|
|
152
|
+
| `listBrowsers(apiKey)` | The sessions a key currently holds, each with the `grpcUrl` to hand to `connectSession`. |
|
|
123
153
|
| `browser.navigate(url, opts?)` | Load a URL. |
|
|
124
154
|
| `browser.wait(condition, opts?)` | Wait for a locator condition; returns the matched `frameId`. |
|
|
125
155
|
| `browser.click(target, opts?)` | Human-like click; throws a rich `ClickError` on failure. |
|
|
126
156
|
| `browser.fill(target, text, opts?)` | Per-key typing that fires real input events; `insertText` for bulk commit. |
|
|
127
157
|
| `browser.evaluate(expr)` | Run JS in the page/frame and get a typed value back. |
|
|
158
|
+
| `browser.runScript(source)` | Run JavaScript beside the browser, where cross-origin frames are property access and every step is local; `startScript` leaves it running, `followScript` watches one already going. |
|
|
128
159
|
| `browser.getObservation(opts?)` | Compact, node-handle-tagged view of the visible page across frames; `opts` tunes budgets and format. |
|
|
160
|
+
| `browser.captureNetwork(opts, onExchange)` | Stream every request the session completes, optionally with response bodies. |
|
|
161
|
+
| `browser.mirrorDom(opts, onChange, onResync?)` | Live, incrementally updated copy of the page's DOM across every frame. |
|
|
129
162
|
| `browser.solveCaptcha(opts?)` | Solve an interactive challenge in the live browser. |
|
|
130
163
|
| `browser.stopBrowser()` | Release the rental. |
|
|
131
164
|
|
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
|