@browserbox/hyper-frame 3.0.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 +662 -0
- package/README.md +153 -0
- package/TRADEMARK.md +16 -0
- package/package.json +20 -0
- package/src/hyper-frame.js +3986 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Hyper-Frame
|
|
2
|
+
|
|
3
|
+
**`<hyper-frame>` — an iframe that can frame any website.**
|
|
4
|
+
|
|
5
|
+
Install via npm:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i --save @browserbox/hyper-frame
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<script type="module" src="https://hyper-frame.art/hyper-frame.js"></script>
|
|
13
|
+
<hyper-frame
|
|
14
|
+
id="bbx"
|
|
15
|
+
login-link="https://example.com:9999/login?token=your_login_link"
|
|
16
|
+
embedder-origin="https://app.example.com"
|
|
17
|
+
ui-visible="false"
|
|
18
|
+
allow-user-toggle-ui="false"
|
|
19
|
+
width="100%"
|
|
20
|
+
height="600">
|
|
21
|
+
</hyper-frame>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Before starting a self-hosted BrowserBox instance set the allowed embedder origins:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export ALLOWED_EMBEDDING_ORIGINS="https://your-site.example.com https://other-embedder.example.com"
|
|
28
|
+
bbx stop
|
|
29
|
+
bbx setup -p 8888
|
|
30
|
+
bbx start
|
|
31
|
+
cat ~/.config/dosaygo/bbpro/login.link
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const bbx = document.querySelector('hyper-frame');
|
|
38
|
+
await bbx.whenReady();
|
|
39
|
+
|
|
40
|
+
await bbx.page.navigate('https://example.com');
|
|
41
|
+
const tabs = await bbx.tabs.list();
|
|
42
|
+
const firstTab = tabs[0];
|
|
43
|
+
if (firstTab?.id) {
|
|
44
|
+
await bbx.tabs.activate(firstTab.id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await bbx.click('a.my-link');
|
|
48
|
+
await bbx.waitForSelector('.result');
|
|
49
|
+
const title = await bbx.evaluate('document.title');
|
|
50
|
+
|
|
51
|
+
const screenshot = await bbx.capture.frame({ format: 'jpeg', quality: 80 });
|
|
52
|
+
|
|
53
|
+
await bbx.frameCapture(true);
|
|
54
|
+
const frame = await bbx.getFrame();
|
|
55
|
+
|
|
56
|
+
await bbx.cleanSlate('https://example.com');
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Element Attributes
|
|
60
|
+
|
|
61
|
+
| Attribute | Required | Default | Description |
|
|
62
|
+
|-----------|----------|---------|-------------|
|
|
63
|
+
| `login-link` | yes | — | Full BrowserBox login URL with auth token |
|
|
64
|
+
| `width` | no | `"100%"` | CSS width (px if bare number) |
|
|
65
|
+
| `height` | no | `"100%"` | CSS height (px if bare number) |
|
|
66
|
+
| `embedder-origin` | no | `"*"` | Restrict postMessage origin |
|
|
67
|
+
| `request-timeout-ms` | no | `30000` | API call timeout (ms) |
|
|
68
|
+
| `ui-visible` | no | `true` | Show/hide BrowserBox chrome UI |
|
|
69
|
+
| `allow-user-toggle-ui` | no | `true` | Allow user to toggle UI visibility |
|
|
70
|
+
| `interaction-mode` | no | `"full"` | Policy preset: `full`, `limited`, `view-only` |
|
|
71
|
+
| `policy` | no | — | Additional local policy restrictions |
|
|
72
|
+
| `chrome` | no | `"default"` | Chrome presentation hint: `none`, `minimal`, `default`, `custom` |
|
|
73
|
+
| `augment-root` | no | `"open"` | Augment inspectability hint: `open` or `closed` |
|
|
74
|
+
| `capture` | no | `"snapshot"` | Capture policy hint: `off`, `snapshot`, `sampled` |
|
|
75
|
+
| `media-permissions` | no | `"default"` | Set to `"none"` to deny mic/camera/display-capture |
|
|
76
|
+
| `session-unload-warning` | no | `"default"` | Set to `"none"` to suppress beforeunload warning |
|
|
77
|
+
| `beforeunload-behavior` | no | `"default"` | `"leave"` to auto-depart, `"remain"` to auto-stay |
|
|
78
|
+
|
|
79
|
+
## Namespaced API
|
|
80
|
+
|
|
81
|
+
Access via the element (`bbx.tabs.list()`) or via `bbx.session` facade.
|
|
82
|
+
|
|
83
|
+
### `session`
|
|
84
|
+
|
|
85
|
+
| Property / Method | Returns | Description |
|
|
86
|
+
|-------------------|---------|-------------|
|
|
87
|
+
| `session.id` | `string \| null` | Routing machine ID |
|
|
88
|
+
| `session.usable` | `boolean` | Whether session is usable |
|
|
89
|
+
| `session.ready` | `boolean` | Whether API handshake completed |
|
|
90
|
+
| `session.transport` | `string` | Transport mode |
|
|
91
|
+
| `session.health()` | `Promise<HealthReport>` | Probe browser and transport |
|
|
92
|
+
| `session.capabilities()` | `Promise<object>` | Query supported capabilities |
|
|
93
|
+
| `session.disconnect()` | `void` | Tear down the session |
|
|
94
|
+
| `session.refresh()` | `void` | Reload the embedded iframe |
|
|
95
|
+
|
|
96
|
+
### `tabs`
|
|
97
|
+
|
|
98
|
+
| Method | Returns | Description |
|
|
99
|
+
|--------|---------|-------------|
|
|
100
|
+
| `tabs.list()` | `Promise<Tab[]>` | List all open tabs |
|
|
101
|
+
| `tabs.getActive()` | `Promise<Tab>` | Get the active tab |
|
|
102
|
+
| `tabs.create({ url, active? })` | `Promise<Tab>` | Open a new tab |
|
|
103
|
+
| `tabs.activate(tabId)` | `Promise` | Switch to a tab by ID |
|
|
104
|
+
| `tabs.close(tabId)` | `Promise` | Close a tab by ID |
|
|
105
|
+
| `tabs.closeAll()` | `Promise` | Close all tabs |
|
|
106
|
+
|
|
107
|
+
### `page`
|
|
108
|
+
|
|
109
|
+
| Method | Returns | Description |
|
|
110
|
+
|--------|---------|-------------|
|
|
111
|
+
| `page.navigate(url, opts?)` | `Promise<NavResult>` | Navigate the active tab |
|
|
112
|
+
| `page.url()` | `Promise<string>` | Active tab URL |
|
|
113
|
+
| `page.title()` | `Promise<string>` | Active tab title |
|
|
114
|
+
| `page.reload()` | `Promise` | Reload the active tab |
|
|
115
|
+
| `page.back()` | `Promise<boolean>` | Navigate back |
|
|
116
|
+
| `page.forward()` | `Promise<boolean>` | Navigate forward |
|
|
117
|
+
| `page.stop()` | `Promise` | Stop loading |
|
|
118
|
+
| `page.text(opts?)` | `Promise<string>` | Extract page text |
|
|
119
|
+
| `page.metrics()` | `Promise<PageMetrics>` | Viewport/document dimensions |
|
|
120
|
+
|
|
121
|
+
### `capture`
|
|
122
|
+
|
|
123
|
+
| Method | Returns | Description |
|
|
124
|
+
|--------|---------|-------------|
|
|
125
|
+
| `capture.frame(opts?)` | `Promise<string>` | Full-page screenshot |
|
|
126
|
+
| `capture.viewport(opts?)` | `Promise<string>` | Viewport screenshot |
|
|
127
|
+
| `capture.enable(enabled?)` | `Promise<boolean>` | Enable/disable frame capture |
|
|
128
|
+
| `capture.next()` | `Promise<FramePacket \| null>` | Consume latest frame |
|
|
129
|
+
|
|
130
|
+
## Events
|
|
131
|
+
|
|
132
|
+
| Event | Detail | Description |
|
|
133
|
+
|-------|--------|-------------|
|
|
134
|
+
| `ready` | `{ type }` | Legacy handshake completed |
|
|
135
|
+
| `api-ready` | `{ methods, policy? }` | Modern API available |
|
|
136
|
+
| `ready-timeout` | `{ timeoutMs, error }` | Handshake timed out |
|
|
137
|
+
| `tab-created` | `{ index, id, url }` | New tab opened |
|
|
138
|
+
| `tab-closed` | `{ index, id }` | Tab closed |
|
|
139
|
+
| `tab-updated` | `{ id, url, title, faviconDataURI }` | Tab metadata updated |
|
|
140
|
+
| `active-tab-changed` | `{ index, id }` | Active tab switched |
|
|
141
|
+
| `did-navigate` | `{ tabId, url }` | Navigation committed |
|
|
142
|
+
| `policy-denied` | `{ url, reason }` | Navigation blocked |
|
|
143
|
+
| `usability-changed` | `{ usable: boolean }` | Usability state changed |
|
|
144
|
+
| `sos` | `{ reasonCode, message, retryUrl }` | Fatal unusable signal |
|
|
145
|
+
| `disconnected` | — | Session ended |
|
|
146
|
+
|
|
147
|
+
## Errors
|
|
148
|
+
|
|
149
|
+
API failures use stable `BrowserBoxError` codes: `ERR_NOT_READY`, `ERR_POLICY_DENIED`, `ERR_TIMEOUT`, `ERR_TRANSPORT`, `ERR_UNSUPPORTED`, `ERR_INVALID_ARGUMENT`, `ERR_NOT_FOUND`, `ERR_CONFLICT`, `ERR_INTERNAL`.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
AGPL-3.0-or-later
|
package/TRADEMARK.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Trademark Notice
|
|
2
|
+
|
|
3
|
+
"BrowserBox" and associated logos are trademarks of DOSAYGO.
|
|
4
|
+
|
|
5
|
+
This repository's open-source license grants copyright permissions for the code, but it does not grant rights to use DOSAYGO trademarks except for truthful, nominative reference.
|
|
6
|
+
|
|
7
|
+
You may:
|
|
8
|
+
- Refer to BrowserBox to describe compatibility or origin.
|
|
9
|
+
- State factual relationships (for example, "forked from BrowserBox").
|
|
10
|
+
|
|
11
|
+
You may not:
|
|
12
|
+
- Use BrowserBox branding, logos, or trade dress in a way that implies endorsement, partnership, or official status.
|
|
13
|
+
- Use confusingly similar product/repository names for redistributed versions.
|
|
14
|
+
- Represent your build or hosted service as an official BrowserBox offering.
|
|
15
|
+
|
|
16
|
+
For brand/trademark permission requests, contact: legal@dosaygo.com
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@browserbox/hyper-frame",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"author": "@dosy",
|
|
5
|
+
"description": "Hyper-Frame — an iframe that can frame any website",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "src/hyper-frame.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/hyper-frame.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"browserbox",
|
|
13
|
+
"hyper-frame",
|
|
14
|
+
"iframe",
|
|
15
|
+
"custom-element",
|
|
16
|
+
"rbi",
|
|
17
|
+
"remote-browser"
|
|
18
|
+
],
|
|
19
|
+
"license": "AGPL-3.0-or-later"
|
|
20
|
+
}
|