@venn-lang/browser 0.1.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/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/index.d.ts +232 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +641 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/src/actions/capture.ts +50 -0
- package/src/actions/frame.ts +18 -0
- package/src/actions/index.ts +26 -0
- package/src/actions/input.ts +105 -0
- package/src/actions/navigation.ts +89 -0
- package/src/actions/support.ts +17 -0
- package/src/actions/wait.ts +24 -0
- package/src/drivers/fake-driver.ts +101 -0
- package/src/drivers/fake-driver.types.ts +64 -0
- package/src/drivers/index.ts +9 -0
- package/src/drivers/real-driver.ts +28 -0
- package/src/index.ts +10 -0
- package/src/matchers/index.ts +6 -0
- package/src/matchers/text.ts +22 -0
- package/src/matchers/visible.ts +18 -0
- package/src/plugin.ts +25 -0
- package/src/plugin.types.ts +13 -0
- package/src/port/browser-driver.port.ts +33 -0
- package/src/port/browser-driver.types.ts +108 -0
- package/src/port/index.ts +21 -0
- package/src/port/preview-provider.port.ts +13 -0
- package/src/port/preview-provider.types.ts +28 -0
- package/src/preview/fake-preview.ts +37 -0
- package/src/preview/index.ts +2 -0
- package/src/preview/none-preview.ts +15 -0
- package/src/resources/browser-resource.ts +15 -0
- package/src/resources/index.ts +6 -0
- package/src/resources/page-resource.ts +15 -0
- package/src/types.ts +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vinicius Borges
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# @venn-lang/browser
|
|
2
|
+
|
|
3
|
+
> The `browser` namespace: sixteen verbs that drive a page, plus two element matchers and the ports the driving actually goes through.
|
|
4
|
+
|
|
5
|
+
Venn's grammar knows nothing about browsers. This package adds the vocabulary: `browser.visit`, `browser.click`, `browser.fill` and the rest arrive as a plugin, exactly the way a third-party package would add them. None of them touch a browser directly. Every verb calls a `BrowserDriver`, a port with two implementations, so a flow can run against a real engine or against a deterministic in-memory model with the same source unchanged.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Nothing to install: the plugin ships inside the CLI's stdlib. Declare it in the file that needs it, and the runner loads it.
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
use "venn/browser"
|
|
13
|
+
use "venn/browser" as web # or under an alias
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
module demo.signin
|
|
20
|
+
|
|
21
|
+
use "venn/browser"
|
|
22
|
+
use "venn/assert"
|
|
23
|
+
|
|
24
|
+
flow "Sign in" {
|
|
25
|
+
step "open the app" {
|
|
26
|
+
const page = browser.newContext { viewport: { width: 1280, height: 800 } }
|
|
27
|
+
browser.visit "/login"
|
|
28
|
+
browser.fill "#email" "ada@example.test"
|
|
29
|
+
browser.fill "#password" "hunter2"
|
|
30
|
+
browser.click "button[type=submit]"
|
|
31
|
+
browser.waitFor { text: "Welcome back" }
|
|
32
|
+
browser.waitForUrl "/dashboard"
|
|
33
|
+
|
|
34
|
+
const shot = browser.screenshot "after-login"
|
|
35
|
+
expect shot.name == "after-login"
|
|
36
|
+
expect page.url != null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`venn test` runs this offline against the fake driver the stdlib binds by default.
|
|
42
|
+
|
|
43
|
+
## Verbs
|
|
44
|
+
|
|
45
|
+
The namespace is `browser`. Positional arguments come first, the options map last.
|
|
46
|
+
|
|
47
|
+
| Verb | Gives back |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `browser.launch { engine, headless }` | `browser.Browser` |
|
|
50
|
+
| `browser.newContext { locale, viewport }` | `browser.Page` |
|
|
51
|
+
| `browser.visit "url" { headers }` | nothing |
|
|
52
|
+
| `browser.click "selector"` | nothing |
|
|
53
|
+
| `browser.fill "selector" "value"` | nothing |
|
|
54
|
+
| `browser.select "selector" "value"` | nothing |
|
|
55
|
+
| `browser.hover "selector"` | nothing |
|
|
56
|
+
| `browser.press "key"` | nothing |
|
|
57
|
+
| `browser.upload "selector" { file }` | nothing |
|
|
58
|
+
| `browser.download "selector"` | `browser.Download` |
|
|
59
|
+
| `browser.screenshot "name"` | `browser.Screenshot` |
|
|
60
|
+
| `browser.waitFor { text, selector, timeout }` | nothing |
|
|
61
|
+
| `browser.waitForUrl "url"` | nothing |
|
|
62
|
+
| `browser.evaluate "script"` | whatever the script returned |
|
|
63
|
+
| `browser.frame "name"` | nothing |
|
|
64
|
+
| `browser.clearCookies` | nothing |
|
|
65
|
+
|
|
66
|
+
`press` takes one argument or two. With one, it is the key and the page has focus. With two, the first is the selector to focus and the second is the key: `browser.press "#email" "Control+A"`.
|
|
67
|
+
|
|
68
|
+
`select` matches the option's value, not its label. `waitFor` takes its condition as options, so the wait is `browser.waitFor { text: "Welcome back" }`, never a bare argument. Its `timeout` is written as a string or as a number of milliseconds (`{ timeout: "5s" }`, `{ timeout: 5000 }`); a bare duration literal is not accepted there in this build.
|
|
69
|
+
|
|
70
|
+
## Types and matchers
|
|
71
|
+
|
|
72
|
+
The plugin publishes five names under `browser.`:
|
|
73
|
+
|
|
74
|
+
| Type | Shape |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| `browser.Browser` | opaque handle carrying `id` and `engine` |
|
|
77
|
+
| `browser.Page` | opaque handle carrying `id` and `url` |
|
|
78
|
+
| `browser.Element` | `{ visible, text, value }`, open |
|
|
79
|
+
| `browser.Download` | `{ path, bytes }` |
|
|
80
|
+
| `browser.Screenshot` | `{ name, path }` |
|
|
81
|
+
|
|
82
|
+
`Browser` and `Page` stay opaque because they are live things owned by the driver. `Download` and `Screenshot` are plain data the verbs hand back, so a flow reads their fields.
|
|
83
|
+
|
|
84
|
+
Two matchers apply to an `Element` subject: `visible` passes when the element model says it is visible, and `text` passes when the element's text equals or contains the argument.
|
|
85
|
+
|
|
86
|
+
The plugin also declares two resources, `Browser` (worker scope) and `Page` (flow scope). The runtime does not execute `resource` declarations yet, so they describe the surface rather than open anything.
|
|
87
|
+
|
|
88
|
+
## Ports
|
|
89
|
+
|
|
90
|
+
Two ports, both with a real implementation and a double, which is the condition for being a port at all.
|
|
91
|
+
|
|
92
|
+
### `BrowserDriverPort`
|
|
93
|
+
|
|
94
|
+
`venn.port.browser-driver`, contract version 1, requires the `net` capability. Sixteen methods, one per verb. Every action reaches it through `ctx.port(BrowserDriverPort)`, so a verb never knows which engine is underneath.
|
|
95
|
+
|
|
96
|
+
| Implementation | What it is |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `createFakeBrowserDriver(options?)` | A deterministic, offline driver over an in-memory DOM model. Preload elements and a starting URL; read back `state` and `element(selector)`. |
|
|
99
|
+
| `createRealBrowserDriver()` | The real-engine stub. Every method throws `VN8090`, because engine automation is out of scope for the language repository. |
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { createFakeBrowserDriver } from "@venn-lang/browser";
|
|
103
|
+
|
|
104
|
+
const driver = createFakeBrowserDriver({ elements: { "#email": { visible: true } } });
|
|
105
|
+
await driver.visit({ url: "/dashboard" });
|
|
106
|
+
await driver.fill({ selector: "#email", value: "a@b.test" });
|
|
107
|
+
|
|
108
|
+
driver.state.url; // "/dashboard"
|
|
109
|
+
driver.state.history; // ["/dashboard"]
|
|
110
|
+
driver.element("#email"); // { visible: true, text: "", value: "a@b.test" }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The fake records `url`, `history`, `clicks`, `fills`, `frame` and `cookiesCleared`, which is what a test asserts against.
|
|
114
|
+
|
|
115
|
+
### `PreviewProviderPort`
|
|
116
|
+
|
|
117
|
+
`venn.port.preview-provider`, contract version 1, requires nothing. Three methods, `start`, `stop` and `latestFrame`, for the live frame stream a studio UI renders. Frame streaming is CDP-only on some engines and polled on others, which is why it is a port and not a method on the driver. A frame is the control-plane pointer (`seq`, `width`, `height`, `mime`, `data`), not a pixel buffer.
|
|
118
|
+
|
|
119
|
+
| Implementation | What it is |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `createNonePreviewProvider()` | The zero-cost default for CI. Starts nothing, never yields a frame. |
|
|
122
|
+
| `createFakePreviewProvider()` | Returns a canned JPEG frame for any worker that has been started. |
|
|
123
|
+
|
|
124
|
+
## API
|
|
125
|
+
|
|
126
|
+
| Export | What it is |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `browserPlugin` (also the default export) | The `PluginDefinition`: namespace `browser`, requires `net`, carrying the actions, matchers, resources and types. |
|
|
129
|
+
| `BrowserDriverPort`, `BrowserDriver` | The port descriptor and its interface. |
|
|
130
|
+
| `PreviewProviderPort`, `PreviewProvider` | The frame-stream port descriptor and its interface. |
|
|
131
|
+
| `createFakeBrowserDriver`, `createRealBrowserDriver` | The two driver implementations. |
|
|
132
|
+
| `createNonePreviewProvider`, `createFakePreviewProvider` | The two preview implementations. |
|
|
133
|
+
| `FakeBrowserDriver`, `FakeBrowserState`, `FakeDriverOptions`, `FakeElement`, `FillRecord` | The fake driver's inspection surface. |
|
|
134
|
+
| `LaunchOptions`, `ContextOptions`, `Viewport`, `VisitArgs`, `FillArgs`, `PressArgs`, `UploadArgs`, `DownloadArgs`, `WaitForArgs`, `EvaluateArgs`, `FrameArgs` | The driver's argument types. |
|
|
135
|
+
| `BrowserHandle`, `PageHandle`, `DownloadResult`, `ScreenshotResult` | What the driver returns. |
|
|
136
|
+
| `PreviewTarget`, `PreviewFrame` | The preview port's argument and result types. |
|
|
137
|
+
|
|
138
|
+
## Binding a driver
|
|
139
|
+
|
|
140
|
+
A host chooses the implementation once, at startup. `@venn-lang/stdlib` binds the fake for both ports; pass your own binding to override it.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { BrowserDriverPort, createRealBrowserDriver } from "@venn-lang/browser";
|
|
144
|
+
import { createRunner } from "@venn-lang/runtime";
|
|
145
|
+
|
|
146
|
+
const runner = createRunner({
|
|
147
|
+
host,
|
|
148
|
+
plugins,
|
|
149
|
+
sink,
|
|
150
|
+
ports: [{ port: BrowserDriverPort, impl: createRealBrowserDriver() }],
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`BrowserDriverPort` requires `net`. A host that does not offer it fails at bind time with a readable problem, rather than with a `TypeError` in the middle of a flow.
|
|
155
|
+
|
|
156
|
+
## See also
|
|
157
|
+
|
|
158
|
+
- [`@venn-lang/sdk`](../sdk) for `definePlugin`, `defineAction` and `defineMatcher`, the API this package is built on.
|
|
159
|
+
- [`@venn-lang/contracts`](../contracts) for `Port`, `Host` and capability negotiation.
|
|
160
|
+
- [`@venn-lang/stdlib`](../stdlib) for the plugin list and the default port bindings the CLI runs with.
|
|
161
|
+
- [`@venn-lang/mail`](../std-mail) for the sibling plugin that checks the email a browser flow triggered.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Port } from "@venn-lang/contracts";
|
|
2
|
+
import { PluginDefinition } from "@venn-lang/sdk";
|
|
3
|
+
//#region src/port/browser-driver.types.d.ts
|
|
4
|
+
/** How an engine is launched. Both fields fall back to the driver's default. */
|
|
5
|
+
interface LaunchOptions {
|
|
6
|
+
engine?: string;
|
|
7
|
+
headless?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A viewport size, in CSS pixels. */
|
|
10
|
+
interface Viewport {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
/** How an isolated context is opened. */
|
|
15
|
+
interface ContextOptions {
|
|
16
|
+
locale?: string;
|
|
17
|
+
viewport?: Viewport;
|
|
18
|
+
}
|
|
19
|
+
/** Where to navigate, and what to send with the request. */
|
|
20
|
+
interface VisitArgs {
|
|
21
|
+
url: string;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
/** A selector paired with the value to write. Shared by `fill` and `select`. */
|
|
25
|
+
interface FillArgs {
|
|
26
|
+
selector: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
/** A key press. Without a `selector`, the page holds focus. */
|
|
30
|
+
interface PressArgs {
|
|
31
|
+
key: string;
|
|
32
|
+
selector?: string;
|
|
33
|
+
}
|
|
34
|
+
/** A file input, and the path of the file to hand it. */
|
|
35
|
+
interface UploadArgs {
|
|
36
|
+
selector: string;
|
|
37
|
+
file: string;
|
|
38
|
+
}
|
|
39
|
+
/** What to click to start a download. */
|
|
40
|
+
interface DownloadArgs {
|
|
41
|
+
selector: string;
|
|
42
|
+
}
|
|
43
|
+
/** A page condition to wait on. Every field is optional; `timeout` is in milliseconds. */
|
|
44
|
+
interface WaitForArgs {
|
|
45
|
+
text?: string;
|
|
46
|
+
selector?: string;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
}
|
|
49
|
+
/** JavaScript to run inside the page. */
|
|
50
|
+
interface EvaluateArgs {
|
|
51
|
+
script: string;
|
|
52
|
+
}
|
|
53
|
+
/** An iframe to enter, named or selected. */
|
|
54
|
+
interface FrameArgs {
|
|
55
|
+
name: string;
|
|
56
|
+
}
|
|
57
|
+
/** A live engine. The nominal `browser.Browser`. */
|
|
58
|
+
interface BrowserHandle {
|
|
59
|
+
id: string;
|
|
60
|
+
engine: string;
|
|
61
|
+
}
|
|
62
|
+
/** A live isolated context. The nominal `browser.Page`. */
|
|
63
|
+
interface PageHandle {
|
|
64
|
+
id: string;
|
|
65
|
+
/** Where the context points at the moment the handle is taken. */
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
68
|
+
/** Where a downloaded file landed, and how big it is. */
|
|
69
|
+
interface DownloadResult {
|
|
70
|
+
path: string;
|
|
71
|
+
bytes: number;
|
|
72
|
+
}
|
|
73
|
+
/** Where a screenshot landed, under the name it was asked for. */
|
|
74
|
+
interface ScreenshotResult {
|
|
75
|
+
name: string;
|
|
76
|
+
path: string;
|
|
77
|
+
}
|
|
78
|
+
/** The contract every `browser` verb goes through. */
|
|
79
|
+
interface BrowserDriver {
|
|
80
|
+
launch(opts: LaunchOptions): Promise<BrowserHandle>;
|
|
81
|
+
newContext(opts: ContextOptions): Promise<PageHandle>;
|
|
82
|
+
visit(args: VisitArgs): Promise<void>;
|
|
83
|
+
click(selector: string): Promise<void>;
|
|
84
|
+
fill(args: FillArgs): Promise<void>;
|
|
85
|
+
select(args: FillArgs): Promise<void>;
|
|
86
|
+
hover(selector: string): Promise<void>;
|
|
87
|
+
press(args: PressArgs): Promise<void>;
|
|
88
|
+
upload(args: UploadArgs): Promise<void>;
|
|
89
|
+
download(args: DownloadArgs): Promise<DownloadResult>;
|
|
90
|
+
screenshot(name: string): Promise<ScreenshotResult>;
|
|
91
|
+
waitFor(args: WaitForArgs): Promise<void>;
|
|
92
|
+
waitForUrl(url: string): Promise<void>;
|
|
93
|
+
evaluate(args: EvaluateArgs): Promise<unknown>;
|
|
94
|
+
frame(args: FrameArgs): Promise<void>;
|
|
95
|
+
clearCookies(): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/port/browser-driver.port.d.ts
|
|
99
|
+
/**
|
|
100
|
+
* The port every `browser` verb reaches through. Requires the `net` capability,
|
|
101
|
+
* so a host without it fails to load the plugin rather than failing mid-run.
|
|
102
|
+
*
|
|
103
|
+
* `methods` must list every method a verb calls. An omission is not checked at
|
|
104
|
+
* load time, so it surfaces as a TypeError mid-run instead of a legible VN2011.
|
|
105
|
+
*/
|
|
106
|
+
declare const BrowserDriverPort: Port<BrowserDriver>;
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/port/preview-provider.types.d.ts
|
|
109
|
+
/** Which worker's frame stream a call targets. Workers stream independently. */
|
|
110
|
+
interface PreviewTarget {
|
|
111
|
+
worker: number;
|
|
112
|
+
}
|
|
113
|
+
/** One captured frame, encoded in `data` under the stated `mime`. */
|
|
114
|
+
interface PreviewFrame {
|
|
115
|
+
/** Rises by one per frame, so a consumer can tell a repeat from a fresh capture. */
|
|
116
|
+
seq: number;
|
|
117
|
+
width: number;
|
|
118
|
+
height: number;
|
|
119
|
+
mime: string;
|
|
120
|
+
data: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* What feeds a live view of a running browser.
|
|
124
|
+
*
|
|
125
|
+
* Two strategies exist behind it: a screencast, which only CDP engines offer,
|
|
126
|
+
* and polling for everything else.
|
|
127
|
+
*/
|
|
128
|
+
interface PreviewProvider {
|
|
129
|
+
/** Begins capturing for a worker. Capturing costs, so nothing streams unstarted. */
|
|
130
|
+
start(target: PreviewTarget): Promise<void>;
|
|
131
|
+
stop(target: PreviewTarget): Promise<void>;
|
|
132
|
+
/** The most recent frame, or `undefined` when the worker is not streaming. */
|
|
133
|
+
latestFrame(target: PreviewTarget): PreviewFrame | undefined;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/port/preview-provider.port.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* The port a live view of a run pulls frames from. Requires no capability: both
|
|
139
|
+
* implementations here are in-process, so the port loads anywhere.
|
|
140
|
+
*/
|
|
141
|
+
declare const PreviewProviderPort: Port<PreviewProvider>;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/drivers/fake-driver.types.d.ts
|
|
144
|
+
/** The in-memory model of one DOM element, as the matchers see it. */
|
|
145
|
+
interface FakeElement {
|
|
146
|
+
visible: boolean;
|
|
147
|
+
text: string;
|
|
148
|
+
value: string;
|
|
149
|
+
}
|
|
150
|
+
/** One recorded `fill` or `select` call. */
|
|
151
|
+
interface FillRecord {
|
|
152
|
+
selector: string;
|
|
153
|
+
value: string;
|
|
154
|
+
}
|
|
155
|
+
/** Everything the fake driver records, so a test can assert on what a flow did. */
|
|
156
|
+
interface FakeBrowserState {
|
|
157
|
+
url: string;
|
|
158
|
+
/** Every URL visited, in order. `visit` and `waitForUrl` both append. */
|
|
159
|
+
history: string[];
|
|
160
|
+
clicks: string[];
|
|
161
|
+
fills: FillRecord[];
|
|
162
|
+
/** The iframe currently entered, or `undefined` at the top level. */
|
|
163
|
+
frame: string | undefined;
|
|
164
|
+
cookiesCleared: number;
|
|
165
|
+
/** What `evaluate` resolves to, whatever the script says. */
|
|
166
|
+
evalResult: unknown;
|
|
167
|
+
elements: Map<string, FakeElement>;
|
|
168
|
+
}
|
|
169
|
+
/** What to preload the fake driver's page with. */
|
|
170
|
+
interface FakeDriverOptions {
|
|
171
|
+
/** Elements by selector. Missing fields default to visible with empty text. */
|
|
172
|
+
elements?: Record<string, Partial<FakeElement>>;
|
|
173
|
+
url?: string;
|
|
174
|
+
}
|
|
175
|
+
/** The fake driver, plus the state a test reads back. */
|
|
176
|
+
interface FakeBrowserDriver extends BrowserDriver {
|
|
177
|
+
readonly state: FakeBrowserState;
|
|
178
|
+
element(selector: string): FakeElement | undefined;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/drivers/fake-driver.d.ts
|
|
182
|
+
/**
|
|
183
|
+
* The offline `BrowserDriver`. Every method resolves at once against an
|
|
184
|
+
* in-memory page, so a test never waits on a real browser.
|
|
185
|
+
*
|
|
186
|
+
* @param options elements to preload and the URL to start at.
|
|
187
|
+
* @returns a fresh driver whose `state` records what the flow did.
|
|
188
|
+
*/
|
|
189
|
+
declare function createFakeBrowserDriver(options?: FakeDriverOptions): FakeBrowserDriver;
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/drivers/real-driver.d.ts
|
|
192
|
+
/**
|
|
193
|
+
* The engine-driving `BrowserDriver`. Not wired up in this repo, which ships
|
|
194
|
+
* the language rather than an automation backend.
|
|
195
|
+
*
|
|
196
|
+
* Methods are generated from the port descriptor, so the stub cannot fall
|
|
197
|
+
* behind the interface.
|
|
198
|
+
*
|
|
199
|
+
* @returns a driver whose every method throws, so the gap is a legible failure
|
|
200
|
+
* rather than a test that passes against nothing.
|
|
201
|
+
* @throws {VennError} `VN8090` on any call.
|
|
202
|
+
*/
|
|
203
|
+
declare function createRealBrowserDriver(): BrowserDriver;
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/plugin.d.ts
|
|
206
|
+
/**
|
|
207
|
+
* The `@venn-lang/browser` plugin. Registers the `browser` namespace: sixteen verbs,
|
|
208
|
+
* the `visible` and `text` matchers, the `Browser` and `Page` resources, and
|
|
209
|
+
* the nominal types those hand around. Requires the `net` capability.
|
|
210
|
+
*/
|
|
211
|
+
declare const browserPlugin: PluginDefinition;
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/preview/fake-preview.d.ts
|
|
214
|
+
/**
|
|
215
|
+
* The in-memory `PreviewProvider`. Hands back a fixed JPEG for any worker that
|
|
216
|
+
* has been started, and nothing for one that has not.
|
|
217
|
+
*
|
|
218
|
+
* @returns a fresh provider with no worker streaming.
|
|
219
|
+
*/
|
|
220
|
+
declare function createFakePreviewProvider(): PreviewProvider;
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/preview/none-preview.d.ts
|
|
223
|
+
/**
|
|
224
|
+
* The `PreviewProvider` that captures nothing. The default on CI, where nobody
|
|
225
|
+
* is watching and a frame stream is pure cost.
|
|
226
|
+
*
|
|
227
|
+
* @returns a provider that accepts every call and never yields a frame.
|
|
228
|
+
*/
|
|
229
|
+
declare function createNonePreviewProvider(): PreviewProvider;
|
|
230
|
+
//#endregion
|
|
231
|
+
export { type BrowserDriver, BrowserDriverPort, type BrowserHandle, type ContextOptions, type DownloadArgs, type DownloadResult, type EvaluateArgs, type FakeBrowserDriver, type FakeBrowserState, type FakeDriverOptions, type FakeElement, type FillArgs, type FillRecord, type FrameArgs, type LaunchOptions, type PageHandle, type PressArgs, type PreviewFrame, type PreviewProvider, PreviewProviderPort, type PreviewTarget, type ScreenshotResult, type UploadArgs, type Viewport, type VisitArgs, type WaitForArgs, browserPlugin, browserPlugin as default, createFakeBrowserDriver, createFakePreviewProvider, createNonePreviewProvider, createRealBrowserDriver };
|
|
232
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/port/browser-driver.types.ts","../src/port/browser-driver.port.ts","../src/port/preview-provider.types.ts","../src/port/preview-provider.port.ts","../src/drivers/fake-driver.types.ts","../src/drivers/fake-driver.ts","../src/drivers/real-driver.ts","../src/plugin.ts","../src/preview/fake-preview.ts","../src/preview/none-preview.ts"],"mappings":";;;;UACiB;EACf;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf;EACA,WAAW;;;UAII;EACf;EACA,UAAU;;;UAIK;EACf;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf;;;UAIe;EACf;EACA;EACA;;;UAIe;EACf;;;UAIe;EACf;;;UAIe;EACf;EACA;;;UAIe;EACf;;EAEA;;;UAIe;EACf;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf,OAAO,MAAM,gBAAgB,QAAQ;EACrC,WAAW,MAAM,iBAAiB,QAAQ;EAC1C,MAAM,MAAM,YAAY;EACxB,MAAM,mBAAmB;EACzB,KAAK,MAAM,WAAW;EACtB,OAAO,MAAM,WAAW;EACxB,MAAM,mBAAmB;EACzB,MAAM,MAAM,YAAY;EACxB,OAAO,MAAM,aAAa;EAC1B,SAAS,MAAM,eAAe,QAAQ;EACtC,WAAW,eAAe,QAAQ;EAClC,QAAQ,MAAM,cAAc;EAC5B,WAAW,cAAc;EACzB,SAAS,MAAM,eAAe;EAC9B,MAAM,MAAM,YAAY;EACxB,gBAAgB;;;;;;;;;;;cChGL,mBAAmB,KAAK;;;;UCTpB;EACf;;;UAIe;;EAEf;EACA;EACA;EACA;EACA;;;;;;;;UASe;;EAEf,MAAM,QAAQ,gBAAgB;EAC9B,KAAK,QAAQ,gBAAgB;;EAE7B,YAAY,QAAQ,gBAAgB;;;;;;;;cCnBzB,qBAAqB,KAAK;;;;UCJtB;EACf;EACA;EACA;;;UAIe;EACf;EACA;;;UAIe;EACf;;EAEA;EACA;EACA,OAAO;;EAEP;EACA;;EAEA;EACA,UAAU,YAAY;;;UAIP;;EAEf,WAAW,eAAe,QAAQ;EAClC;;;UAIe,0BAA0B;WAChC,OAAO;EAChB,QAAQ,mBAAmB;;;;;;;;;;;iBCoDb,wBAAwB,UAAS,oBAAyB;;;;;;;;;;;;;;iBCvE1D,2BAA2B;;;;;;;;cCT9B,eAAe;;;;;;;;;iBCgBZ,6BAA6B;;;;;;;;;iBCpB7B,6BAA6B"}
|