@aperture-browser/session-client 0.0.0-stage → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +36 -2
- package/dist/effect.d.ts +2 -0
- package/dist/effect.js +2 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/session-CSF1mk8K.js +2990 -0
- package/dist/session-CSF1mk8K.js.map +1 -0
- package/dist/session-Di6f5DYK.d.ts +2892 -0
- package/package.json +48 -3
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
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aperture-browser/session-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A framework-free client for one [Aperture](https://github.com/tarik02/aperture) session in a browser: the live protocol, the session's picture and sound, input, and its HTTP routes. For a ready-made workbench use `@aperture-browser/session-react` or `@aperture-browser/session-element`.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @aperture-browser/session-client@beta effect
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
While Aperture is in beta its packages are under the dist-tag `beta`; a package has the version of the server it speaks to.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { connect } from "@aperture-browser/session-client";
|
|
13
|
+
|
|
14
|
+
// `url` is the session's base; `token` a ticket from the control plane.
|
|
15
|
+
const session = connect({ url: "https://aperture.example.com/n/<node>/sessions/<id>", token: ticket });
|
|
16
|
+
|
|
17
|
+
const detach = session.attach({
|
|
18
|
+
video: document.querySelector("video")!,
|
|
19
|
+
canvas: document.querySelector("canvas")!,
|
|
20
|
+
keys: document.querySelector("textarea")!,
|
|
21
|
+
stage: document.querySelector<HTMLElement>("#stage")!,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
session.subscribe(() => {
|
|
25
|
+
const { targets, selected } = session.getSnapshot();
|
|
26
|
+
console.log(targets.map((target) => target.title), selected);
|
|
27
|
+
});
|
|
28
|
+
session.go({ url: "https://example.com" });
|
|
29
|
+
|
|
30
|
+
// Later:
|
|
31
|
+
detach();
|
|
32
|
+
session.close();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`getSnapshot` and `subscribe` are a store, as `useSyncExternalStore` takes one. What is sent over the session socket is not answered: its effect shows in the snapshot. The session's HTTP routes (`recordings`, `pace`, `screenshots`, `upload`, `storageState`) return promises that reject with `SessionError`.
|
|
36
|
+
|
|
37
|
+
`@aperture-browser/session-client/effect` has the same client as an Effect service, with the generated protocol messages.
|
package/dist/effect.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as PointerMark, A as ClipboardEvent, B as HeldTab, Ct as statusOf, D as http_d_exports, Dt as SessionError, Et as live_pb_d_exports, F as FORMATS, G as NO_FEATURES, H as LeaseAction, I as Failure, J as Pace, K as PAGE_MODES, L as Features, M as Connection, N as Download, O as ALONGS, Ot as Address, P as DownloadState, Q as PictureWay, R as FileRequest, St as restoringOf, Tt as targetOf, U as Member, V as LEASE_ACTIONS, W as Menu, X as Picture, Y as PageMode, Z as PictureSettings, _t as menuOf, a as PictureChange, at as Snapshot, bt as presenceOf, c as SnapshotStore, ct as Target, d as Surfaces, dt as VideoStatus, et as Presence, f as KEYS, ft as downloadOf, gt as formatOf, ht as fileRequestOf, i as GoOptions, it as STROKE_PHASE, j as ClipboardForm, k as Along, l as layer, lt as VideoFormat, mt as featuresOf, n as Destination, nt as Restoring, o as Session, ot as StrokePhase, pt as failureOf, q as PIXELS, rt as Role, s as SessionService, st as StrokePoint, t as ConnectOptions, tt as QUALITIES, u as make, ut as VideoQuality, vt as paceOf, wt as strokeOf, xt as qualityOf, yt as pointerOf, z as Grant } from "./session-Di6f5DYK.js";
|
|
2
|
+
export { type ALONGS, type Address, type Along, type ClipboardEvent, type ClipboardForm, type ConnectOptions, type Connection, type Destination, type Download, type DownloadState, type FORMATS, type Failure, type Features, type FileRequest, type GoOptions, type Grant, type HeldTab, KEYS, type LEASE_ACTIONS, type LeaseAction, type Member, type Menu, type NO_FEATURES, type PAGE_MODES, type PIXELS, type Pace, type PageMode, type Picture, type PictureChange, type PictureSettings, type PictureWay, type PointerMark, type Presence, type QUALITIES, type Restoring, type Role, type STROKE_PHASE, Session, SessionError, http_d_exports as SessionHttp, type SessionService, type Snapshot, type SnapshotStore, type StrokePhase, type StrokePoint, type Surfaces, type Target, type VideoFormat, type VideoQuality, type VideoStatus, type downloadOf, type failureOf, type featuresOf, type fileRequestOf, type formatOf, layer, make, type menuOf, type paceOf, type pointerOf, type presenceOf, live_pb_d_exports as proto, type qualityOf, type restoringOf, type statusOf, type strokeOf, type targetOf };
|
package/dist/effect.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { $ as PointerMark, A as ClipboardEvent, B as HeldTab, C as StorageStateAsked, Dt as SessionError, E as ViewportSize, H as LeaseAction, I as Failure, J as Pace, L as Features, M as Connection, N as Download, P as DownloadState, Q as PictureWay, R as FileRequest, S as StorageState, T as Uploaded, U as Member, W as Menu, X as Picture, Y as PageMode, Z as PictureSettings, _ as RecordingEdit, a as PictureChange, at as Snapshot, b as StartRecording, ct as Target, d as Surfaces, dt as VideoStatus, et as Presence, g as RecordingBurst, h as RecordingAnnotation, i as GoOptions, j as ClipboardForm, k as Along, lt as VideoFormat, m as Recording, n as Destination, nt as Restoring, ot as StrokePhase, p as EditRecording, r as FitOptions, rt as Role, st as StrokePoint, t as ConnectOptions, ut as VideoQuality, v as RecordingOptions, w as UploadProgress, x as StateCookie, y as Screenshot, z as Grant } from "./session-Di6f5DYK.js";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* One session, watched and controlled. Its requests reject with `SessionError`; what goes
|
|
6
|
+
* over the session socket is not answered, and shows in the snapshot when it took effect.
|
|
7
|
+
*/
|
|
8
|
+
interface Session {
|
|
9
|
+
/** Referentially stable until something changes. */
|
|
10
|
+
readonly getSnapshot: () => Snapshot;
|
|
11
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
12
|
+
/** Watches a tab, named by its number. */
|
|
13
|
+
readonly select: (tab: number) => void;
|
|
14
|
+
readonly go: (to: Destination, options?: GoOptions) => void;
|
|
15
|
+
readonly newTab: () => void;
|
|
16
|
+
readonly closeTab: (tab: number) => void;
|
|
17
|
+
/**
|
|
18
|
+
* `fit` has the watched target's viewport follow the attached stage's size. With
|
|
19
|
+
* `whenFree` the fitting waits until the tab is this member's to size: until it holds the
|
|
20
|
+
* tab, or nobody holds it and nobody else watches it.
|
|
21
|
+
*/
|
|
22
|
+
readonly setViewport: (viewport: ViewportSize | "fit", options?: FitOptions) => void;
|
|
23
|
+
/** Gives the watched target another scale and leaves its size, fitted or not, as it is. */
|
|
24
|
+
readonly setScale: (scale: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets how the watched tab's pages are shown, for a member that holds the tab. Where
|
|
27
|
+
* that changes how they are shown, the page loads again.
|
|
28
|
+
*/
|
|
29
|
+
readonly setMode: (mode: PageMode) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Changes how the picture comes. A key that is left out keeps what it has; one that is
|
|
32
|
+
* there and undefined leaves the choice to the session again.
|
|
33
|
+
*/
|
|
34
|
+
readonly setPicture: (change: PictureChange) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Mutes a tab for this client, or lets it be heard again. A tab is heard while it is
|
|
37
|
+
* watched, once the browser lets a page play sound: after the first click or key.
|
|
38
|
+
*/
|
|
39
|
+
readonly setMuted: (tab: number, muted: boolean) => void;
|
|
40
|
+
readonly lease: (action: LeaseAction) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Shows the picture in `video` or `canvas`, whichever `picture.way` needs, and takes
|
|
43
|
+
* the pointer, the wheel, the keyboard, input methods, the clipboard and what is
|
|
44
|
+
* dropped on them. Gives what detaches them. One set of surfaces at a time.
|
|
45
|
+
*/
|
|
46
|
+
readonly attach: (surfaces: Surfaces) => () => void;
|
|
47
|
+
/** Gives the keyboard to the session, as a click on the picture does. */
|
|
48
|
+
readonly focus: () => void;
|
|
49
|
+
readonly dismissMenu: () => void;
|
|
50
|
+
/** Asks for a picture the watched page shows; it comes as what the session copied. */
|
|
51
|
+
readonly copyPicture: (url: string) => void;
|
|
52
|
+
/** Puts content on the session's clipboard, for a paste there to take. */
|
|
53
|
+
readonly writeClipboard: (forms: readonly ClipboardForm[]) => void;
|
|
54
|
+
/**
|
|
55
|
+
* What is copied in the session. This browser's clipboard was offered it before the
|
|
56
|
+
* listener hears of it, and `written` tells whether it took it.
|
|
57
|
+
*/
|
|
58
|
+
readonly onClipboard: (listener: (event: ClipboardEvent) => void) => () => void;
|
|
59
|
+
/**
|
|
60
|
+
* What this client asked for with `go`, `closeTab`, `copyPicture` or `chooseFiles` and
|
|
61
|
+
* the session did not do, with the reason.
|
|
62
|
+
*/
|
|
63
|
+
readonly onFailure: (listener: (failure: Failure) => void) => () => void;
|
|
64
|
+
/**
|
|
65
|
+
* A finger moved the watched tab's page, by this much of the target's pixels each time:
|
|
66
|
+
* down the page where `y` is more than nothing. It tells what the finger did, whether
|
|
67
|
+
* or not the page had anywhere to go.
|
|
68
|
+
*/
|
|
69
|
+
readonly onDragged: (listener: (by: {
|
|
70
|
+
readonly x: number;
|
|
71
|
+
readonly y: number;
|
|
72
|
+
}) => void) => () => void;
|
|
73
|
+
/** Where the other members' pointers are on the watched tab, as they move. */
|
|
74
|
+
readonly onPointer: (listener: (pointer: PointerMark) => void) => () => void;
|
|
75
|
+
/** The strokes the other members draw over the watched tab, point by point. */
|
|
76
|
+
readonly onStroke: (listener: (point: StrokePoint) => void) => () => void;
|
|
77
|
+
/** Follows a member to whichever tab it watches; nobody when left out. */
|
|
78
|
+
readonly follow: (member?: number) => void;
|
|
79
|
+
/** Shows the others a point of a stroke over the watched tab, in its logical pixels. */
|
|
80
|
+
readonly draw: (stroke: number, phase: StrokePhase, at: {
|
|
81
|
+
readonly x: number;
|
|
82
|
+
readonly y: number;
|
|
83
|
+
}) => void;
|
|
84
|
+
/** Shows the others where this pointer is while it gives no input; nowhere when left out. */
|
|
85
|
+
readonly point: (at?: {
|
|
86
|
+
readonly x: number;
|
|
87
|
+
readonly y: number;
|
|
88
|
+
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Pastes into the session: the forms given, or what this browser's clipboard has where
|
|
91
|
+
* a page may read it. False when there was nothing to paste.
|
|
92
|
+
*/
|
|
93
|
+
readonly paste: (forms?: readonly ClipboardForm[]) => Promise<boolean>;
|
|
94
|
+
/** Copies what is selected in the session; it comes as what the session copied. */
|
|
95
|
+
readonly copySelection: () => void;
|
|
96
|
+
readonly selectAll: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Puts content on this browser's clipboard from a click, for what the session copied
|
|
99
|
+
* and the clipboard did not take by itself: text is copied, a picture opens to be
|
|
100
|
+
* copied by hand.
|
|
101
|
+
*/
|
|
102
|
+
readonly copyHere: (forms: readonly ClipboardForm[]) => Promise<boolean>;
|
|
103
|
+
readonly upload: (file: File, onProgress?: (progress: UploadProgress) => void) => Promise<Uploaded>;
|
|
104
|
+
readonly uploads: () => Promise<Uploaded[]>;
|
|
105
|
+
readonly removeUpload: (name: string) => Promise<void>;
|
|
106
|
+
/** Answers a page's request for files with uploads, by name; with none it is dismissed. */
|
|
107
|
+
readonly chooseFiles: (request: number, names: readonly string[]) => void;
|
|
108
|
+
/** An authenticated URL of one of the session's files, such as `downloads/<name>`. */
|
|
109
|
+
readonly fileUrl: (path: string) => string;
|
|
110
|
+
/** The tab as it looks now; `width` asks for a smaller picture, that many pixels wide. */
|
|
111
|
+
readonly screenshotUrl: (tab: number, width?: number) => string;
|
|
112
|
+
/**
|
|
113
|
+
* The tab as it looked a moment ago, small: for a list of the tabs. The session makes
|
|
114
|
+
* one in a while, however often it is asked.
|
|
115
|
+
*/
|
|
116
|
+
readonly previewUrl: (tab: number) => string;
|
|
117
|
+
/**
|
|
118
|
+
* The icon of the target's page, which the session fetches as its browser does anything
|
|
119
|
+
* else of the page: the page's site is told nothing of who watches. None for a page
|
|
120
|
+
* that is not of the web.
|
|
121
|
+
*/
|
|
122
|
+
readonly faviconUrl: (target: Target) => string | undefined;
|
|
123
|
+
readonly recordings: {
|
|
124
|
+
readonly list: () => Promise<Recording[]>;
|
|
125
|
+
readonly get: (id: string) => Promise<Recording>;
|
|
126
|
+
readonly start: (options?: StartRecording) => Promise<Recording>; /** Stops a recording; its edit is made with `options`. */
|
|
127
|
+
readonly stop: (id: string, options?: EditRecording) => Promise<Recording>; /** Makes the edit of a stopped recording again, with other options. */
|
|
128
|
+
readonly edit: (id: string, options?: EditRecording) => Promise<Recording>; /** Has a running recording go on with another tab. */
|
|
129
|
+
readonly retarget: (id: string, tab: number) => Promise<Recording>; /** Adds an annotation to the recording named, or to the only one that runs. */
|
|
130
|
+
readonly annotate: (annotation: RecordingAnnotation, id?: string) => Promise<void>;
|
|
131
|
+
};
|
|
132
|
+
/** The cookies and local storage of the session's browser, for whoever runs the session. */
|
|
133
|
+
readonly storageState: {
|
|
134
|
+
readonly export: (asked?: StorageStateAsked) => Promise<StorageState>;
|
|
135
|
+
readonly import: (state: StorageState) => Promise<void>;
|
|
136
|
+
};
|
|
137
|
+
/** How the session's automation moves the pointer in what is recorded. */
|
|
138
|
+
readonly pace: {
|
|
139
|
+
readonly get: () => Promise<Pace>;
|
|
140
|
+
readonly set: (pace: Pace) => Promise<Pace>;
|
|
141
|
+
};
|
|
142
|
+
readonly screenshots: {
|
|
143
|
+
readonly list: () => Promise<Screenshot[]>; /** Takes one of a tab, the newest when none is named, and keeps it in the files. */
|
|
144
|
+
readonly take: (tab?: number) => Promise<Screenshot>;
|
|
145
|
+
};
|
|
146
|
+
/** Ends the session's client: what is attached, the picture, the sound, the socket. */
|
|
147
|
+
readonly close: () => void;
|
|
148
|
+
}
|
|
149
|
+
/** Connects to a session at once; the snapshot tells how far the connection is. */
|
|
150
|
+
declare const connect: (options: ConnectOptions) => Session;
|
|
151
|
+
//#endregion
|
|
152
|
+
export { type Along, type ClipboardEvent, type ClipboardForm, type ConnectOptions, type Connection, type Destination, type Download, type DownloadState, type EditRecording, type Failure, type Features, type FileRequest, type FitOptions, type GoOptions, type Grant, type HeldTab, type LeaseAction, type Member, type Menu, type Pace, type PageMode, type Picture, type PictureChange, type PictureSettings, type PictureWay, type PointerMark, type Presence, type Recording, type RecordingAnnotation, type RecordingBurst, type RecordingEdit, type RecordingOptions, type Restoring, type Role, type Screenshot, Session, SessionError, type Snapshot, type StartRecording, type StateCookie, type StorageState, type StorageStateAsked, type StrokePhase, type StrokePoint, type Surfaces, type Target, type UploadProgress, type Uploaded, type VideoFormat, type VideoQuality, type VideoStatus, type ViewportSize, connect };
|
|
153
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { r as make, s as SessionError } from "./session-CSF1mk8K.js";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Exit from "effect/Exit";
|
|
4
|
+
import * as Scope from "effect/Scope";
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
const promised = (effect) => Effect.runPromise(effect);
|
|
7
|
+
/** Connects to a session at once; the snapshot tells how far the connection is. */
|
|
8
|
+
const connect = (options) => {
|
|
9
|
+
const scope = Scope.makeUnsafe();
|
|
10
|
+
const session = Effect.runSync(Scope.provide(make(options), scope));
|
|
11
|
+
return {
|
|
12
|
+
getSnapshot: session.store.get,
|
|
13
|
+
subscribe: session.store.subscribe,
|
|
14
|
+
select: (tab) => Effect.runSync(session.select(tab)),
|
|
15
|
+
go: (to, given) => Effect.runSync(session.go(to, given)),
|
|
16
|
+
newTab: () => Effect.runSync(session.newTab),
|
|
17
|
+
closeTab: (tab) => Effect.runSync(session.closeTab(tab)),
|
|
18
|
+
setViewport: (viewport, options) => Effect.runSync(session.setViewport(viewport, options)),
|
|
19
|
+
setScale: (scale) => Effect.runSync(session.setScale(scale)),
|
|
20
|
+
setMode: (mode) => Effect.runSync(session.setMode(mode)),
|
|
21
|
+
setPicture: (change) => Effect.runSync(session.setPicture(change)),
|
|
22
|
+
setMuted: (tab, muted) => Effect.runSync(session.setMuted(tab, muted)),
|
|
23
|
+
lease: (action) => Effect.runSync(session.lease(action)),
|
|
24
|
+
attach: (surfaces) => {
|
|
25
|
+
const attached = Scope.forkUnsafe(scope);
|
|
26
|
+
Effect.runSync(Scope.provide(session.attach(surfaces), attached));
|
|
27
|
+
return () => Effect.runSync(Scope.close(attached, Exit.void));
|
|
28
|
+
},
|
|
29
|
+
focus: () => Effect.runSync(session.focus),
|
|
30
|
+
dismissMenu: () => Effect.runSync(session.dismissMenu),
|
|
31
|
+
copyPicture: (url) => Effect.runSync(session.copyPicture(url)),
|
|
32
|
+
writeClipboard: (forms) => Effect.runSync(session.writeClipboard(forms)),
|
|
33
|
+
onClipboard: session.onClipboard,
|
|
34
|
+
onFailure: session.onFailure,
|
|
35
|
+
onDragged: session.onDragged,
|
|
36
|
+
onPointer: session.onPointer,
|
|
37
|
+
onStroke: session.onStroke,
|
|
38
|
+
follow: (member) => Effect.runSync(session.follow(member)),
|
|
39
|
+
draw: (stroke, phase, at) => Effect.runSync(session.draw(stroke, phase, at)),
|
|
40
|
+
point: (at) => Effect.runSync(session.point(at)),
|
|
41
|
+
paste: (forms) => promised(session.paste(forms)),
|
|
42
|
+
copySelection: () => Effect.runSync(session.copySelection),
|
|
43
|
+
selectAll: () => Effect.runSync(session.selectAll),
|
|
44
|
+
copyHere: (forms) => promised(session.copyHere(forms)),
|
|
45
|
+
upload: (file, onProgress) => promised(session.upload(file, onProgress)),
|
|
46
|
+
uploads: () => promised(session.uploads),
|
|
47
|
+
removeUpload: (name) => promised(session.removeUpload(name)),
|
|
48
|
+
chooseFiles: (request, names) => Effect.runSync(session.chooseFiles(request, names)),
|
|
49
|
+
fileUrl: session.fileUrl,
|
|
50
|
+
screenshotUrl: session.screenshotUrl,
|
|
51
|
+
previewUrl: session.previewUrl,
|
|
52
|
+
faviconUrl: session.faviconUrl,
|
|
53
|
+
recordings: {
|
|
54
|
+
list: () => promised(session.recordings.list),
|
|
55
|
+
get: (id) => promised(session.recordings.get(id)),
|
|
56
|
+
start: (started) => promised(session.recordings.start(started)),
|
|
57
|
+
stop: (id, options) => promised(session.recordings.stop(id, options)),
|
|
58
|
+
edit: (id, options) => promised(session.recordings.edit(id, options)),
|
|
59
|
+
retarget: (id, tab) => promised(session.recordings.retarget(id, tab)),
|
|
60
|
+
annotate: (annotation, id) => promised(session.recordings.annotate(annotation, id))
|
|
61
|
+
},
|
|
62
|
+
storageState: {
|
|
63
|
+
export: (asked) => promised(session.storageState.export(asked)),
|
|
64
|
+
import: (state) => promised(session.storageState.import(state))
|
|
65
|
+
},
|
|
66
|
+
pace: {
|
|
67
|
+
get: () => promised(session.pace.get),
|
|
68
|
+
set: (pace) => promised(session.pace.set(pace))
|
|
69
|
+
},
|
|
70
|
+
screenshots: {
|
|
71
|
+
list: () => promised(session.screenshots.list),
|
|
72
|
+
take: (tab) => promised(session.screenshots.take(tab))
|
|
73
|
+
},
|
|
74
|
+
close: () => {
|
|
75
|
+
Effect.runFork(Scope.close(scope, Exit.void));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { SessionError, connect };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Scope from \"effect/Scope\";\nimport type {\n EditRecording,\n Recording,\n RecordingAnnotation,\n Screenshot,\n StartRecording,\n StorageState,\n StorageStateAsked,\n Uploaded,\n UploadProgress,\n ViewportSize,\n} from \"./http.ts\";\nimport type { Surfaces } from \"./input.ts\";\nimport type {\n ClipboardEvent,\n ClipboardForm,\n Failure,\n LeaseAction,\n Pace,\n PageMode,\n PointerMark,\n Snapshot,\n StrokePhase,\n StrokePoint,\n Target,\n} from \"./model.ts\";\nimport {\n type ConnectOptions,\n type Destination,\n type FitOptions,\n type GoOptions,\n make,\n type PictureChange,\n} from \"./session.ts\";\n\nexport { SessionError } from \"./errors.ts\";\nexport type {\n EditRecording,\n Recording,\n RecordingAnnotation,\n RecordingBurst,\n RecordingEdit,\n RecordingOptions,\n Screenshot,\n StartRecording,\n StateCookie,\n StorageState,\n StorageStateAsked,\n Uploaded,\n UploadProgress,\n ViewportSize,\n} from \"./http.ts\";\nexport type { Surfaces } from \"./input.ts\";\nexport type {\n Along,\n ClipboardEvent,\n ClipboardForm,\n Connection,\n Download,\n DownloadState,\n Failure,\n Features,\n Pace,\n Grant,\n FileRequest,\n HeldTab,\n LeaseAction,\n PageMode,\n PointerMark,\n StrokePhase,\n StrokePoint,\n Member,\n Menu,\n Picture,\n PictureSettings,\n PictureWay,\n Presence,\n Restoring,\n Role,\n Snapshot,\n Target,\n VideoFormat,\n VideoQuality,\n VideoStatus,\n} from \"./model.ts\";\nexport type {\n ConnectOptions,\n Destination,\n FitOptions,\n GoOptions,\n PictureChange,\n} from \"./session.ts\";\n\n/**\n * One session, watched and controlled. Its requests reject with `SessionError`; what goes\n * over the session socket is not answered, and shows in the snapshot when it took effect.\n */\nexport interface Session {\n /** Referentially stable until something changes. */\n readonly getSnapshot: () => Snapshot;\n readonly subscribe: (listener: () => void) => () => void;\n\n /** Watches a tab, named by its number. */\n readonly select: (tab: number) => void;\n readonly go: (to: Destination, options?: GoOptions) => void;\n readonly newTab: () => void;\n readonly closeTab: (tab: number) => void;\n /**\n * `fit` has the watched target's viewport follow the attached stage's size. With\n * `whenFree` the fitting waits until the tab is this member's to size: until it holds the\n * tab, or nobody holds it and nobody else watches it.\n */\n readonly setViewport: (viewport: ViewportSize | \"fit\", options?: FitOptions) => void;\n /** Gives the watched target another scale and leaves its size, fitted or not, as it is. */\n readonly setScale: (scale: number) => void;\n /**\n * Sets how the watched tab's pages are shown, for a member that holds the tab. Where\n * that changes how they are shown, the page loads again.\n */\n readonly setMode: (mode: PageMode) => void;\n /**\n * Changes how the picture comes. A key that is left out keeps what it has; one that is\n * there and undefined leaves the choice to the session again.\n */\n readonly setPicture: (change: PictureChange) => void;\n /**\n * Mutes a tab for this client, or lets it be heard again. A tab is heard while it is\n * watched, once the browser lets a page play sound: after the first click or key.\n */\n readonly setMuted: (tab: number, muted: boolean) => void;\n readonly lease: (action: LeaseAction) => void;\n /**\n * Shows the picture in `video` or `canvas`, whichever `picture.way` needs, and takes\n * the pointer, the wheel, the keyboard, input methods, the clipboard and what is\n * dropped on them. Gives what detaches them. One set of surfaces at a time.\n */\n readonly attach: (surfaces: Surfaces) => () => void;\n /** Gives the keyboard to the session, as a click on the picture does. */\n readonly focus: () => void;\n readonly dismissMenu: () => void;\n /** Asks for a picture the watched page shows; it comes as what the session copied. */\n readonly copyPicture: (url: string) => void;\n /** Puts content on the session's clipboard, for a paste there to take. */\n readonly writeClipboard: (forms: readonly ClipboardForm[]) => void;\n /**\n * What is copied in the session. This browser's clipboard was offered it before the\n * listener hears of it, and `written` tells whether it took it.\n */\n readonly onClipboard: (listener: (event: ClipboardEvent) => void) => () => void;\n /**\n * What this client asked for with `go`, `closeTab`, `copyPicture` or `chooseFiles` and\n * the session did not do, with the reason.\n */\n readonly onFailure: (listener: (failure: Failure) => void) => () => void;\n /**\n * A finger moved the watched tab's page, by this much of the target's pixels each time:\n * down the page where `y` is more than nothing. It tells what the finger did, whether\n * or not the page had anywhere to go.\n */\n readonly onDragged: (\n listener: (by: { readonly x: number; readonly y: number }) => void,\n ) => () => void;\n /** Where the other members' pointers are on the watched tab, as they move. */\n readonly onPointer: (listener: (pointer: PointerMark) => void) => () => void;\n /** The strokes the other members draw over the watched tab, point by point. */\n readonly onStroke: (listener: (point: StrokePoint) => void) => () => void;\n /** Follows a member to whichever tab it watches; nobody when left out. */\n readonly follow: (member?: number) => void;\n /** Shows the others a point of a stroke over the watched tab, in its logical pixels. */\n readonly draw: (\n stroke: number,\n phase: StrokePhase,\n at: { readonly x: number; readonly y: number },\n ) => void;\n /** Shows the others where this pointer is while it gives no input; nowhere when left out. */\n readonly point: (at?: { readonly x: number; readonly y: number }) => void;\n /**\n * Pastes into the session: the forms given, or what this browser's clipboard has where\n * a page may read it. False when there was nothing to paste.\n */\n readonly paste: (forms?: readonly ClipboardForm[]) => Promise<boolean>;\n /** Copies what is selected in the session; it comes as what the session copied. */\n readonly copySelection: () => void;\n readonly selectAll: () => void;\n /**\n * Puts content on this browser's clipboard from a click, for what the session copied\n * and the clipboard did not take by itself: text is copied, a picture opens to be\n * copied by hand.\n */\n readonly copyHere: (forms: readonly ClipboardForm[]) => Promise<boolean>;\n\n readonly upload: (\n file: File,\n onProgress?: (progress: UploadProgress) => void,\n ) => Promise<Uploaded>;\n readonly uploads: () => Promise<Uploaded[]>;\n readonly removeUpload: (name: string) => Promise<void>;\n /** Answers a page's request for files with uploads, by name; with none it is dismissed. */\n readonly chooseFiles: (request: number, names: readonly string[]) => void;\n /** An authenticated URL of one of the session's files, such as `downloads/<name>`. */\n readonly fileUrl: (path: string) => string;\n /** The tab as it looks now; `width` asks for a smaller picture, that many pixels wide. */\n readonly screenshotUrl: (tab: number, width?: number) => string;\n /**\n * The tab as it looked a moment ago, small: for a list of the tabs. The session makes\n * one in a while, however often it is asked.\n */\n readonly previewUrl: (tab: number) => string;\n /**\n * The icon of the target's page, which the session fetches as its browser does anything\n * else of the page: the page's site is told nothing of who watches. None for a page\n * that is not of the web.\n */\n readonly faviconUrl: (target: Target) => string | undefined;\n readonly recordings: {\n readonly list: () => Promise<Recording[]>;\n readonly get: (id: string) => Promise<Recording>;\n readonly start: (options?: StartRecording) => Promise<Recording>;\n /** Stops a recording; its edit is made with `options`. */\n readonly stop: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Makes the edit of a stopped recording again, with other options. */\n readonly edit: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Has a running recording go on with another tab. */\n readonly retarget: (id: string, tab: number) => Promise<Recording>;\n /** Adds an annotation to the recording named, or to the only one that runs. */\n readonly annotate: (annotation: RecordingAnnotation, id?: string) => Promise<void>;\n };\n /** The cookies and local storage of the session's browser, for whoever runs the session. */\n readonly storageState: {\n readonly export: (asked?: StorageStateAsked) => Promise<StorageState>;\n readonly import: (state: StorageState) => Promise<void>;\n };\n /** How the session's automation moves the pointer in what is recorded. */\n readonly pace: {\n readonly get: () => Promise<Pace>;\n readonly set: (pace: Pace) => Promise<Pace>;\n };\n readonly screenshots: {\n readonly list: () => Promise<Screenshot[]>;\n /** Takes one of a tab, the newest when none is named, and keeps it in the files. */\n readonly take: (tab?: number) => Promise<Screenshot>;\n };\n /** Ends the session's client: what is attached, the picture, the sound, the socket. */\n readonly close: () => void;\n}\n\nconst promised = <A, E>(effect: Effect.Effect<A, E>) => Effect.runPromise(effect);\n\n/** Connects to a session at once; the snapshot tells how far the connection is. */\nexport const connect = (options: ConnectOptions): Session => {\n const scope = Scope.makeUnsafe();\n const session = Effect.runSync(Scope.provide(make(options), scope));\n\n return {\n getSnapshot: session.store.get,\n subscribe: session.store.subscribe,\n select: (tab) => Effect.runSync(session.select(tab)),\n go: (to, given) => Effect.runSync(session.go(to, given)),\n newTab: () => Effect.runSync(session.newTab),\n closeTab: (tab) => Effect.runSync(session.closeTab(tab)),\n setViewport: (viewport, options) => Effect.runSync(session.setViewport(viewport, options)),\n setScale: (scale) => Effect.runSync(session.setScale(scale)),\n setMode: (mode) => Effect.runSync(session.setMode(mode)),\n setPicture: (change) => Effect.runSync(session.setPicture(change)),\n setMuted: (tab, muted) => Effect.runSync(session.setMuted(tab, muted)),\n lease: (action) => Effect.runSync(session.lease(action)),\n attach: (surfaces) => {\n const attached = Scope.forkUnsafe(scope);\n Effect.runSync(Scope.provide(session.attach(surfaces), attached));\n return () => Effect.runSync(Scope.close(attached, Exit.void));\n },\n focus: () => Effect.runSync(session.focus),\n dismissMenu: () => Effect.runSync(session.dismissMenu),\n copyPicture: (url) => Effect.runSync(session.copyPicture(url)),\n writeClipboard: (forms) => Effect.runSync(session.writeClipboard(forms)),\n onClipboard: session.onClipboard,\n onFailure: session.onFailure,\n onDragged: session.onDragged,\n onPointer: session.onPointer,\n onStroke: session.onStroke,\n follow: (member) => Effect.runSync(session.follow(member)),\n draw: (stroke, phase, at) => Effect.runSync(session.draw(stroke, phase, at)),\n point: (at) => Effect.runSync(session.point(at)),\n paste: (forms) => promised(session.paste(forms)),\n copySelection: () => Effect.runSync(session.copySelection),\n selectAll: () => Effect.runSync(session.selectAll),\n copyHere: (forms) => promised(session.copyHere(forms)),\n upload: (file, onProgress) => promised(session.upload(file, onProgress)),\n uploads: () => promised(session.uploads),\n removeUpload: (name) => promised(session.removeUpload(name)),\n chooseFiles: (request, names) => Effect.runSync(session.chooseFiles(request, names)),\n fileUrl: session.fileUrl,\n screenshotUrl: session.screenshotUrl,\n previewUrl: session.previewUrl,\n faviconUrl: session.faviconUrl,\n recordings: {\n list: () => promised(session.recordings.list),\n get: (id) => promised(session.recordings.get(id)),\n start: (started) => promised(session.recordings.start(started)),\n stop: (id, options) => promised(session.recordings.stop(id, options)),\n edit: (id, options) => promised(session.recordings.edit(id, options)),\n retarget: (id, tab) => promised(session.recordings.retarget(id, tab)),\n annotate: (annotation, id) => promised(session.recordings.annotate(annotation, id)),\n },\n storageState: {\n export: (asked) => promised(session.storageState.export(asked)),\n import: (state) => promised(session.storageState.import(state)),\n },\n pace: {\n get: () => promised(session.pace.get),\n set: (pace) => promised(session.pace.set(pace)),\n },\n screenshots: {\n list: () => promised(session.screenshots.list),\n take: (tab) => promised(session.screenshots.take(tab)),\n },\n close: () => {\n Effect.runFork(Scope.close(scope, Exit.void));\n },\n };\n};\n"],"mappings":";;;;;AAyPA,MAAM,YAAkB,WAAgC,OAAO,WAAW,MAAM;;AAGhF,MAAa,WAAW,YAAqC;CAC3D,MAAM,QAAQ,MAAM,WAAW;CAC/B,MAAM,UAAU,OAAO,QAAQ,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,CAAC;CAElE,OAAO;EACL,aAAa,QAAQ,MAAM;EAC3B,WAAW,QAAQ,MAAM;EACzB,SAAS,QAAQ,OAAO,QAAQ,QAAQ,OAAO,GAAG,CAAC;EACnD,KAAK,IAAI,UAAU,OAAO,QAAQ,QAAQ,GAAG,IAAI,KAAK,CAAC;EACvD,cAAc,OAAO,QAAQ,QAAQ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
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|