@aperture-browser/session-element 0.0.0-init.0 → 0.0.0-nightly.82.2e4f6368108f
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 +3 -47
- package/dist/aperture-B1SPAy_g.js +26 -0
- package/dist/aperture-session-view.js +1 -1
- package/dist/aperture-session.js +1 -1
- package/package.json +2 -2
- package/dist/aperture-t-Xm6-Va.js +0 -22
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# @aperture-browser/session-element
|
|
2
2
|
|
|
3
|
-
Custom elements that embed a live [Aperture](https://github.com/tarik02/aperture) browser session in any page
|
|
3
|
+
Custom elements that embed a live [Aperture](https://github.com/tarik02/aperture) browser session in any page, isolated in Shadow DOM.
|
|
4
4
|
|
|
5
5
|
- `<aperture-session>`: the session with its UI: tabs, toolbar and menus.
|
|
6
|
-
- `<aperture-session-view>`: the session alone, for pages that build their own controls.
|
|
7
|
-
|
|
8
|
-
## `<aperture-session>`
|
|
6
|
+
- `<aperture-session-view>`: the session alone, with a JavaScript API for pages that build their own controls.
|
|
9
7
|
|
|
10
8
|
```html
|
|
11
9
|
<script type="module" src="https://cdn.jsdelivr.net/npm/@aperture-browser/session-element/dist/aperture-session.js"></script>
|
|
@@ -17,46 +15,4 @@ Custom elements that embed a live [Aperture](https://github.com/tarik02/aperture
|
|
|
17
15
|
></aperture-session>
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Attributes:
|
|
23
|
-
|
|
24
|
-
- `token`: a share link's editor (`ape_…`) or viewer (`apv_…`) token; the element grants exactly what the link grants.
|
|
25
|
-
- `base-url`: the Aperture instance, when it is not the page's own origin. The instance must list your origin in `embed_allowed_origins`.
|
|
26
|
-
- `hide`: parts of the UI to leave out, separated by spaces: `tabs`, `navigation` (back, forward, reload), `address-bar`, `presence`, `drawing`, `menus`, `status-badge`, `toaster`.
|
|
27
|
-
|
|
28
|
-
The `features` property takes the same switches as the React component's `features` prop, e.g. `element.features = { tabs: false, addressBar: false }`. It is applied on top of `hide`.
|
|
29
|
-
- `theme`: `light`, `dark` or `system` (the default).
|
|
30
|
-
|
|
31
|
-
The element fills the size you give it. It uses the page's font; set `--aperture-font-sans` and `--aperture-font-mono` (used for URLs) on the element to pick others. It adds one `<style>` to the page for its CSS custom property registrations, which browsers ignore inside shadow roots.
|
|
32
|
-
|
|
33
|
-
## `<aperture-session-view>`
|
|
34
|
-
|
|
35
|
-
```html
|
|
36
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aperture-browser/session-element/dist/aperture-session-view.js"></script>
|
|
37
|
-
|
|
38
|
-
<aperture-session-view id="session" base-url="https://aperture.example" token="ape_…"></aperture-session-view>
|
|
39
|
-
|
|
40
|
-
<script type="module">
|
|
41
|
-
const session = document.getElementById("session");
|
|
42
|
-
session.addEventListener("aperture-change", ({ detail }) => {
|
|
43
|
-
console.log(detail.status, detail.tabs, detail.activeTabId);
|
|
44
|
-
});
|
|
45
|
-
await session.whenConnected();
|
|
46
|
-
await session.navigate("https://example.com");
|
|
47
|
-
</script>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Or from a bundler: `import "@aperture-browser/session-element/headless";`.
|
|
51
|
-
|
|
52
|
-
It takes the `token` and `base-url` attributes and shows the active tab, forwarding input to it.
|
|
53
|
-
|
|
54
|
-
- `snapshot` holds the current state: `status` (`loading`, `ready`, `invalid`, `expired` or `unavailable`), `role`, `connection`, `tabs` (`id`, `title`, `url`, `loading`) and `activeTabId`. The `aperture-change` event carries each new snapshot.
|
|
55
|
-
- Methods: `navigate(url)`, `back()`, `forward()`, `reload()`, `stop()`, `openTab(url?)`, `closeTab(id)`, `activateTab(id)`. They act on the active tab where it applies and return a promise that resolves once Aperture has carried the command out; `openTab` resolves with the new tab's id. The promise rejects with an `Error` (`_tag` `LiveSessionError`) whose `message` says why: the session is not connected yet, or Aperture refused the command, for example a viewer token trying to navigate.
|
|
56
|
-
- `whenConnected()` resolves with the snapshot once the session is connected, and rejects if the token turns out invalid, expired or unavailable.
|
|
57
|
-
- `reconnect()` drops the connection and opens it again.
|
|
58
|
-
- The `aperture-notice` event carries errors and confirmations (`level`, `message`) that `<aperture-session>` would show as toasts.
|
|
59
|
-
|
|
60
|
-
Both elements load a shared module next to them, so a page that uses both loads React and the session core once.
|
|
61
|
-
|
|
62
|
-
React apps that want to share their own React copy can use [`@aperture-browser/session-react`](https://www.npmjs.com/package/@aperture-browser/session-react) instead, which has the same full and headless split.
|
|
18
|
+
Documentation: https://aperture-browser-docs.pages.dev/docs/packages/session-element
|