@aperture-browser/session-react 0.0.0-init.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 +77 -0
- package/dist/headless-CKFacFX3.js +2135 -0
- package/dist/headless-CKFacFX3.js.map +1 -0
- package/dist/headless.d.ts +313 -0
- package/dist/headless.js +2 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +2212 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Taras Fomin
|
|
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,77 @@
|
|
|
1
|
+
# @aperture-browser/session-react
|
|
2
|
+
|
|
3
|
+
React components for embedding a live [Aperture](https://github.com/tarik02/aperture) browser session.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @aperture-browser/session-react effect react react-dom
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { ApertureSession } from "@aperture-browser/session-react";
|
|
11
|
+
import "@aperture-browser/session-react/styles.css";
|
|
12
|
+
|
|
13
|
+
export function SharedBrowser({ token }: { token: string }) {
|
|
14
|
+
return (
|
|
15
|
+
<div style={{ height: 600 }}>
|
|
16
|
+
<ApertureSession baseUrl="https://aperture.example" token={token} />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`token` is a share link's editor (`ape_…`) or viewer (`apv_…`) token; the component grants exactly what the link grants. Props:
|
|
23
|
+
|
|
24
|
+
- `baseUrl`: the Aperture instance, when it is not the page's own origin. The instance must list your origin in `embed_allowed_origins`.
|
|
25
|
+
- `features`: turns parts of the UI off, e.g. `{ tabs: false, menus: false }`. Each defaults to on: `tabs`, `navigation` (back, forward, reload), `addressBar`, `presence` (who else is connected), `drawing`, `menus` (stream, viewport, recording and input settings), `statusBadge`, `toaster` (turn it off if your app renders its own [sonner](https://sonner.emilkowal.ski) toaster).
|
|
26
|
+
- `theme`: `"light"`, `"dark"` or `"system"` (the default).
|
|
27
|
+
|
|
28
|
+
## Styles
|
|
29
|
+
|
|
30
|
+
`styles.css` styles everything inside the component's `.aperture-root` element: theme colors and a scoped reset. It does not touch your page's `html`, `body` or `:root`, and menus and tooltips render inside the root. It does include Tailwind utility classes, which your own unlayered CSS can override. For full isolation use [`@aperture-browser/session-element`](https://www.npmjs.com/package/@aperture-browser/session-element), which renders into Shadow DOM.
|
|
31
|
+
|
|
32
|
+
The component uses your page's font. To pick others, set `--aperture-font-sans` and `--aperture-font-mono` (used for URLs) on it or any ancestor, e.g. `--aperture-font-sans: "Inter", sans-serif`.
|
|
33
|
+
|
|
34
|
+
## Headless
|
|
35
|
+
|
|
36
|
+
`@aperture-browser/session-react/headless` has the session without any UI: no tab strip, toolbar, menus, stylesheet or UI dependencies. Build your own controls around it.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import {
|
|
40
|
+
ApertureProvider,
|
|
41
|
+
SessionViewport,
|
|
42
|
+
useSharedSession,
|
|
43
|
+
} from "@aperture-browser/session-react/headless";
|
|
44
|
+
|
|
45
|
+
function Browser({ token }: { token: string }) {
|
|
46
|
+
const { status, control } = useSharedSession({ token, onNotice: console.warn });
|
|
47
|
+
if (status !== "ready") return <p>{status}</p>;
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{control.targets.map((tab) => (
|
|
51
|
+
<button key={tab.id} onClick={() => control.activateTarget(tab.id)}>
|
|
52
|
+
{tab.title}
|
|
53
|
+
</button>
|
|
54
|
+
))}
|
|
55
|
+
<button onClick={() => control.historyBack()}>Back</button>
|
|
56
|
+
<SessionViewport control={control} style={{ height: 600 }} />
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const App = ({ token }: { token: string }) => (
|
|
62
|
+
<ApertureProvider baseUrl="https://aperture.example">
|
|
63
|
+
<Browser token={token} />
|
|
64
|
+
</ApertureProvider>
|
|
65
|
+
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `useSharedSession` resolves the token (`status` is `loading`, `ready`, `invalid`, `expired` or `unavailable`) and connects once it is ready. `control` lists the tabs and navigates, opens, closes and activates them.
|
|
69
|
+
- `SessionViewport` shows the active tab and forwards input to it. It is styled inline and takes `className` and `style`. `renderOverlay` receives the connection status, a placeholder reason while there is no picture yet, and cursor hints, for drawing your own overlays.
|
|
70
|
+
- `onNotice` receives the errors and confirmations the full UI shows as toasts.
|
|
71
|
+
- `control.commands` has the same actions as Effects that succeed once Aperture has carried them out and fail with a `LiveSessionError` otherwise, e.g. `yield* control.commands.navigate(url)`.
|
|
72
|
+
|
|
73
|
+
## Lower-level pieces
|
|
74
|
+
|
|
75
|
+
`SharedSession` is the same view without its own runtime, tooltip provider and toaster, for apps that provide them (`RuntimeProvider` with `makeApertureRuntime`, and `TooltipProvider`). `useBrowserControl` and `BrowserControlPane` drive and render a session for other credentials. These are what the Aperture web app is built from.
|
|
76
|
+
|
|
77
|
+
Requires `effect` 4 and React 19.
|