@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.
@@ -0,0 +1,313 @@
1
+ import { CSSProperties, DependencyList, ReactNode } from "react";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Stream from "effect/Stream";
4
+ import { BrowserInputMessage, CollaborationCursor, CollaborationError, CollaborationLeaseMode, CollaborationPaintEvent, CollaborationPaintPoint, CollaborationParticipant, CollaborationPhase, CollaborationRole, CollaborationRole as CollaborationRole$1, LiveSessionCommandResult, LiveSessionConnection, LiveSessionError, LiveSessionError as LiveSessionError$1, LiveSessionPresentation, LiveSessionPresentationQuality, LiveSessionRasterFrame, LiveSessionTarget, ViewportPreset } from "@aperture-browser/live-session";
5
+ import { ApiCredentials, ApiServices, BrowserStatus, IceServer, Recording } from "@aperture-browser/api-client";
6
+ import * as ManagedRuntime from "effect/ManagedRuntime";
7
+
8
+ //#region src/hooks/use-live-session.d.ts
9
+ interface InputDimensions {
10
+ width: number;
11
+ height: number;
12
+ }
13
+ interface LiveSessionMediaSize {
14
+ width: number;
15
+ height: number;
16
+ deviceScaleFactor: number;
17
+ canvasWidth: number;
18
+ canvasHeight: number;
19
+ }
20
+ type LiveSessionMediaSelection = {
21
+ kind: "jpeg";
22
+ } | {
23
+ kind: "webrtc";
24
+ quality: LiveSessionPresentationQuality;
25
+ } | {
26
+ kind: "webrtc-retry";
27
+ };
28
+ interface CollaborationControl {
29
+ phase: CollaborationPhase;
30
+ role: CollaborationRole;
31
+ clientId: string;
32
+ holderClientId: string | null;
33
+ leaseMode: CollaborationLeaseMode | null;
34
+ hasControl: boolean;
35
+ canRequestControl: boolean;
36
+ lastError: CollaborationError | null;
37
+ participants: readonly CollaborationParticipant[];
38
+ cursors: ReadonlyMap<string, CollaborationCursor>;
39
+ paintEvents: Stream.Stream<CollaborationPaintEvent>;
40
+ followingClientId: string | null;
41
+ claim: (targetId: string, mode: CollaborationLeaseMode) => boolean;
42
+ release: () => boolean;
43
+ setActiveTarget: (targetId: string | null) => boolean;
44
+ follow: (clientId: string | null) => boolean;
45
+ sendCursor: (targetId: string, x: number, y: number, dimensions: InputDimensions) => boolean;
46
+ sendPaintPoint: (point: CollaborationPaintPoint) => boolean;
47
+ clearCursor: () => boolean;
48
+ sendInput: (message: BrowserInputMessage, dimensions: InputDimensions) => boolean;
49
+ }
50
+ interface UseLiveSessionOptions {
51
+ sessionId: string | null;
52
+ displayName?: string | null;
53
+ credentials: ApiCredentials | null;
54
+ sessionToken?: string;
55
+ role: CollaborationRole;
56
+ enabled: boolean;
57
+ webrtcSupported: boolean;
58
+ iceServers: readonly IceServer[];
59
+ }
60
+ interface LiveSessionControl {
61
+ phase: "idle" | "connecting" | "connected" | "disconnected" | "error";
62
+ targets: readonly LiveSessionTarget[];
63
+ activeTargetId: string | null;
64
+ /** The newest raster frame, starting with the current one. */
65
+ frames: Stream.Stream<LiveSessionRasterFrame | null>;
66
+ mediaStream: MediaStream | null;
67
+ mediaSize: LiveSessionMediaSize | null;
68
+ transport: "webrtc" | "websocket" | null;
69
+ presentation: LiveSessionPresentation | null;
70
+ mediaSwitching: boolean;
71
+ recordings: readonly Recording[];
72
+ collaboration: CollaborationControl;
73
+ sendBrowserInput: (message: BrowserInputMessage, dimensions: InputDimensions) => boolean;
74
+ selectTarget: (targetId: string) => boolean;
75
+ requestSelectTarget: (targetId: string) => Effect.Effect<void, LiveSessionConnection.LiveSessionError>;
76
+ command: (type: string, payload?: Record<string, unknown>) => boolean;
77
+ request: (type: string, payload?: Record<string, unknown>) => Effect.Effect<LiveSessionCommandResult, LiveSessionConnection.LiveSessionError>;
78
+ selectPresentation: (selection: LiveSessionMediaSelection) => Effect.Effect<void, LiveSessionConnection.LiveSessionError>;
79
+ reconnect: () => void;
80
+ }
81
+ declare const collaborationPaintLifetimeMs = 7000;
82
+ declare function useLiveSession({
83
+ sessionId,
84
+ displayName,
85
+ credentials,
86
+ sessionToken,
87
+ role,
88
+ enabled,
89
+ webrtcSupported,
90
+ iceServers
91
+ }: UseLiveSessionOptions): LiveSessionControl;
92
+ //#endregion
93
+ //#region src/hooks/use-browser-control.d.ts
94
+ interface SessionNotice {
95
+ readonly level: "error" | "success";
96
+ readonly message: string;
97
+ }
98
+ interface UseBrowserControlOptions {
99
+ sessionId: string | null;
100
+ credentials: ApiCredentials | null;
101
+ displayName?: string | null;
102
+ sessionToken?: string;
103
+ collaborationRole?: CollaborationRole$1;
104
+ enabled?: boolean;
105
+ webrtcProducerSupported?: boolean;
106
+ webrtcIceServers?: readonly IceServer[];
107
+ onNotice?: (notice: SessionNotice) => void;
108
+ }
109
+ interface BrowserViewportSize {
110
+ width: number;
111
+ height: number;
112
+ }
113
+ interface BrowserCommands {
114
+ readonly navigate: (url: string) => Effect.Effect<void, LiveSessionError$1>;
115
+ readonly historyBack: () => Effect.Effect<void, LiveSessionError$1>;
116
+ readonly historyForward: () => Effect.Effect<void, LiveSessionError$1>;
117
+ readonly reload: (targetId?: string) => Effect.Effect<void, LiveSessionError$1>;
118
+ readonly stopLoading: () => Effect.Effect<void, LiveSessionError$1>;
119
+ readonly createTarget: (url?: string) => Effect.Effect<string | null, LiveSessionError$1>;
120
+ readonly closeTarget: (targetId: string) => Effect.Effect<void, LiveSessionError$1>;
121
+ readonly activateTarget: (targetId: string) => Effect.Effect<void, LiveSessionError$1>;
122
+ }
123
+ type BrowserMediaPath = "webrtc-live" | "websocket-live";
124
+ type BrowserMediaPhase = "idle" | "connecting" | "live" | "failed";
125
+ interface UseBrowserControlResult {
126
+ phase: LiveSessionControl["phase"];
127
+ targets: readonly LiveSessionTarget[];
128
+ activeTargetId: string | null;
129
+ activeTarget: LiveSessionTarget | null;
130
+ frames: Stream.Stream<LiveSessionRasterFrame | null>;
131
+ mediaPhase: BrowserMediaPhase;
132
+ mediaStream: MediaStream | null;
133
+ mediaStreamSettings: LiveSessionPresentationQuality | null;
134
+ mediaVideoProfiles: LiveSessionPresentation["profiles"];
135
+ mediaSize: {
136
+ width: number;
137
+ height: number;
138
+ deviceScaleFactor: number;
139
+ canvasWidth: number;
140
+ canvasHeight: number;
141
+ } | null;
142
+ mediaPath: BrowserMediaPath;
143
+ mediaTargetId: string | null;
144
+ mediaSwitching: boolean;
145
+ viewport: ViewportPreset;
146
+ browserViewportSize: BrowserViewportSize | null;
147
+ viewportAutoSync: boolean;
148
+ captured: boolean;
149
+ recordings: readonly Recording[];
150
+ recordingBusy: boolean;
151
+ remoteCursorEnabled: boolean;
152
+ collaboration: CollaborationControl;
153
+ commands: BrowserCommands;
154
+ setCaptured: (captured: boolean) => void;
155
+ setInputDimensions: (size: BrowserViewportSize) => void;
156
+ setViewport: (viewport: ViewportPreset) => void;
157
+ setBrowserViewportSize: (size: BrowserViewportSize) => void;
158
+ setViewportAutoSync: (enabled: boolean) => void;
159
+ setViewportToBrowserSize: () => void;
160
+ setWebRTCStreamSettings: (settings: LiveSessionPresentationQuality) => boolean;
161
+ selectMediaStream: (selection: LiveSessionMediaSelection) => boolean;
162
+ sendInput: (message: BrowserInputMessage) => boolean;
163
+ activateTarget: (targetId: string) => void;
164
+ reorderTargets: (sourceTargetId: string, destinationTargetId: string, placement: "before" | "after") => void;
165
+ createTarget: (url?: string) => void;
166
+ duplicateTarget: (target: LiveSessionTarget) => void;
167
+ closeTarget: (targetId: string) => void;
168
+ navigate: (url: string) => void;
169
+ reload: (targetId: string) => void;
170
+ stopLoading: () => void;
171
+ historyBack: () => void;
172
+ historyForward: () => void;
173
+ startRecording: (mode: "tab" | "viewer") => void;
174
+ stopRecording: (recordingId: string) => void;
175
+ cancelRecording: (recordingId: string) => void;
176
+ setRemoteCursorEnabled: (enabled: boolean) => void;
177
+ reconnect: () => void;
178
+ }
179
+ declare function useBrowserControl({
180
+ sessionId,
181
+ credentials,
182
+ displayName,
183
+ sessionToken,
184
+ collaborationRole,
185
+ enabled,
186
+ webrtcProducerSupported,
187
+ webrtcIceServers,
188
+ onNotice
189
+ }: UseBrowserControlOptions): UseBrowserControlResult;
190
+ //#endregion
191
+ //#region src/components/session-viewport.d.ts
192
+ interface SessionViewportProps {
193
+ control: UseBrowserControlResult;
194
+ viewport?: ViewportPreset;
195
+ localCursorEnabled?: boolean;
196
+ paintingEnabled?: boolean;
197
+ onPaintingEnabledChange?: (enabled: boolean) => void;
198
+ onNotice?: (notice: SessionNotice) => void;
199
+ className?: string;
200
+ style?: CSSProperties;
201
+ renderOverlay?: (overlay: SessionViewportOverlay) => ReactNode;
202
+ }
203
+ type SessionViewportStatus = "webrtc" | "websocket" | "offline";
204
+ type SessionViewportPlaceholder = "connecting" | "connecting-media" | "switching" | "disconnected" | "waiting";
205
+ interface SessionViewportOverlay {
206
+ readonly status: SessionViewportStatus;
207
+ readonly placeholder: SessionViewportPlaceholder | null;
208
+ readonly cursorHint: {
209
+ readonly text: string;
210
+ readonly x: number;
211
+ readonly y: number;
212
+ } | null;
213
+ readonly followedCursor: {
214
+ readonly name: string;
215
+ readonly x: number;
216
+ readonly y: number;
217
+ } | null;
218
+ readonly collaborationError: string | null;
219
+ }
220
+ declare function SessionViewport({
221
+ control,
222
+ viewport,
223
+ localCursorEnabled,
224
+ paintingEnabled,
225
+ onPaintingEnabledChange,
226
+ onNotice,
227
+ className,
228
+ style,
229
+ renderOverlay
230
+ }: SessionViewportProps): import("react").JSX.Element;
231
+ //#endregion
232
+ //#region src/runtime.d.ts
233
+ type ApertureRuntime = ManagedRuntime.ManagedRuntime<ApiServices, never>;
234
+ interface ApertureRuntimeOptions {
235
+ readonly baseUrl?: string;
236
+ }
237
+ declare const makeApertureRuntime: (options?: ApertureRuntimeOptions) => ApertureRuntime;
238
+ //#endregion
239
+ //#region src/effect.d.ts
240
+ declare const RuntimeProviderMissingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
241
+ readonly _tag: "RuntimeProviderMissingError";
242
+ } & Readonly<A>;
243
+ /** A hook below needed the app runtime, but no RuntimeProvider is above the component. */
244
+ declare class RuntimeProviderMissingError extends RuntimeProviderMissingError_base {
245
+ readonly message = "useRuntime must be used inside RuntimeProvider";
246
+ }
247
+ declare function RuntimeProvider({
248
+ runtime,
249
+ baseUrl,
250
+ children
251
+ }: {
252
+ runtime: ApertureRuntime;
253
+ baseUrl?: string;
254
+ children: ReactNode;
255
+ }): import("react").JSX.Element;
256
+ declare function useRuntime(): ApertureRuntime;
257
+ declare function useBaseUrl(): string | undefined;
258
+ /**
259
+ * Runs an effect while the component is mounted, restarting it when `deps` change, like
260
+ * `useEffect`. Return `undefined` to run nothing. The fiber is interrupted synchronously
261
+ * on cleanup, so its synchronous finalizers have run before the next effect starts.
262
+ */
263
+ declare function useFork(effect: () => Effect.Effect<unknown, never, ApiServices> | undefined, deps: DependencyList): void;
264
+ /**
265
+ * Returns an event handler that forks the effect `callback` builds. Fibers still running
266
+ * when the component unmounts are interrupted.
267
+ */
268
+ declare function useEffectCallback<Args extends ReadonlyArray<unknown>>(callback: (...args: Args) => Effect.Effect<unknown, never, ApiServices>, deps: DependencyList): (...args: Args) => void;
269
+ /**
270
+ * Returns a function that runs an API call for promise-based callers such as TanStack
271
+ * Query. Aborting the signal interrupts the request.
272
+ */
273
+ declare function useRunApi(): <A, E>(call: Effect.Effect<A, E, ApiServices>, options?: {
274
+ readonly signal?: AbortSignal;
275
+ }) => Promise<A>;
276
+ //#endregion
277
+ //#region src/provider.d.ts
278
+ interface ApertureProviderProps {
279
+ readonly baseUrl?: string;
280
+ readonly children?: ReactNode;
281
+ }
282
+ declare function ApertureProvider({
283
+ baseUrl,
284
+ children
285
+ }: ApertureProviderProps): import("react").JSX.Element | null;
286
+ //#endregion
287
+ //#region src/shared-session.d.ts
288
+ interface ShareToken {
289
+ readonly token: string;
290
+ readonly sessionId: string;
291
+ readonly role: "editor" | "viewer";
292
+ }
293
+ declare function parseShareToken(token: string): ShareToken | null;
294
+ type SharedSessionStatus = "invalid" | "loading" | "expired" | "unavailable" | "ready";
295
+ interface UseSharedSessionOptions {
296
+ readonly token: string;
297
+ readonly displayName?: string | null;
298
+ readonly onNotice?: (notice: SessionNotice) => void;
299
+ }
300
+ interface UseSharedSessionResult {
301
+ readonly status: SharedSessionStatus;
302
+ readonly share: ShareToken | null;
303
+ readonly browser: BrowserStatus | null;
304
+ readonly control: UseBrowserControlResult;
305
+ }
306
+ declare function useSharedSession({
307
+ token,
308
+ displayName,
309
+ onNotice
310
+ }: UseSharedSessionOptions): UseSharedSessionResult;
311
+ //#endregion
312
+ export { ApertureProvider, ApertureProviderProps, ApertureRuntime, ApertureRuntimeOptions, BrowserCommands, BrowserMediaPath, BrowserMediaPhase, CollaborationControl, type CollaborationCursor, type CollaborationError, type CollaborationLeaseMode, type CollaborationPaintEvent, type CollaborationPaintPoint, type CollaborationParticipant, type CollaborationPhase, type CollaborationRole, LiveSessionControl, LiveSessionError, LiveSessionMediaSelection, LiveSessionMediaSize, RuntimeProvider, RuntimeProviderMissingError, SessionNotice, SessionViewport, SessionViewportOverlay, SessionViewportPlaceholder, SessionViewportProps, SessionViewportStatus, ShareToken, SharedSessionStatus, UseBrowserControlResult, UseSharedSessionOptions, UseSharedSessionResult, collaborationPaintLifetimeMs, makeApertureRuntime, parseShareToken, useBaseUrl, useBrowserControl, useEffectCallback, useFork, useLiveSession, useRunApi, useRuntime, useSharedSession };
313
+ //# sourceMappingURL=headless.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { a as makeApertureRuntime, c as collaborationPaintLifetimeMs, d as RuntimeProviderMissingError, f as useBaseUrl, g as useRuntime, h as useRunApi, i as ApertureProvider, l as useLiveSession, m as useFork, n as parseShareToken, o as useBrowserControl, p as useEffectCallback, r as useSharedSession, s as SessionViewport, t as LiveSessionError, u as RuntimeProvider } from "./headless-CKFacFX3.js";
2
+ export { ApertureProvider, LiveSessionError, RuntimeProvider, RuntimeProviderMissingError, SessionViewport, collaborationPaintLifetimeMs, makeApertureRuntime, parseShareToken, useBaseUrl, useBrowserControl, useEffectCallback, useFork, useLiveSession, useRunApi, useRuntime, useSharedSession };
@@ -0,0 +1,99 @@
1
+ import { ApertureProvider, ApertureProviderProps, ApertureRuntime, ApertureRuntimeOptions, BrowserCommands, BrowserMediaPath, BrowserMediaPhase, CollaborationControl, CollaborationCursor, CollaborationError, CollaborationLeaseMode, CollaborationPaintEvent, CollaborationPaintPoint, CollaborationParticipant, CollaborationPhase, CollaborationRole, LiveSessionControl, LiveSessionError, LiveSessionMediaSelection, LiveSessionMediaSize, RuntimeProvider, RuntimeProviderMissingError, SessionNotice, SessionViewport, SessionViewportOverlay, SessionViewportPlaceholder, SessionViewportProps, SessionViewportStatus, ShareToken, SharedSessionStatus, UseBrowserControlResult, UseSharedSessionOptions, UseSharedSessionResult, collaborationPaintLifetimeMs, makeApertureRuntime, parseShareToken, useBaseUrl, useBrowserControl, useEffectCallback, useFork, useLiveSession, useRunApi, useRuntime, useSharedSession } from "./headless.js";
2
+ import { ReactNode } from "react";
3
+ import * as Effect from "effect/Effect";
4
+ import { CollaborationRole as CollaborationRole$1 } from "@aperture-browser/live-session";
5
+
6
+ //#region src/features.d.ts
7
+ interface SessionFeatures {
8
+ readonly tabs?: boolean;
9
+ readonly navigation?: boolean;
10
+ readonly addressBar?: boolean;
11
+ readonly presence?: boolean;
12
+ readonly drawing?: boolean;
13
+ readonly devTools?: boolean;
14
+ readonly menus?: boolean;
15
+ readonly statusBadge?: boolean;
16
+ }
17
+ interface ApertureSessionFeatures extends SessionFeatures {
18
+ readonly toaster?: boolean;
19
+ }
20
+ type ResolvedSessionFeatures = Required<SessionFeatures>;
21
+ declare function resolveSessionFeatures(features?: SessionFeatures): ResolvedSessionFeatures;
22
+ //#endregion
23
+ //#region src/aperture-session.d.ts
24
+ interface SharedSessionProps {
25
+ readonly token: string;
26
+ readonly features?: SessionFeatures;
27
+ readonly leading?: ReactNode;
28
+ }
29
+ interface ApertureSessionProps extends SharedSessionProps {
30
+ readonly baseUrl?: string;
31
+ readonly features?: ApertureSessionFeatures;
32
+ readonly theme?: "light" | "dark" | "system";
33
+ readonly className?: string;
34
+ }
35
+ declare function ApertureSession({
36
+ baseUrl,
37
+ theme,
38
+ className,
39
+ ...props
40
+ }: ApertureSessionProps): import("react").JSX.Element;
41
+ declare function SharedSession({
42
+ token,
43
+ features,
44
+ leading
45
+ }: SharedSessionProps): import("react").JSX.Element;
46
+ declare function devToolsUrl(origin: string, cdpUrl: string, sessionToken: string): string;
47
+ //#endregion
48
+ //#region src/clipboard.d.ts
49
+ declare const ClipboardError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
50
+ readonly _tag: "ClipboardError";
51
+ } & Readonly<A>;
52
+ /** The browser refused to write to the clipboard. */
53
+ declare class ClipboardError extends ClipboardError_base<{
54
+ readonly cause?: unknown;
55
+ }> {
56
+ readonly message = "Clipboard write is unavailable";
57
+ }
58
+ declare const copyText: (value: string) => Effect.Effect<void, ClipboardError>;
59
+ /** Copies `value`, then runs `onCopied`, or shows an error toast if the copy fails. */
60
+ declare const copyTextWithToast: (value: string, onCopied?: () => void) => Effect.Effect<void, never, never>;
61
+ //#endregion
62
+ //#region src/components/browser-control-pane.d.ts
63
+ type BrowserControlPaneProps = {
64
+ control: UseBrowserControlResult;
65
+ leading?: ReactNode;
66
+ features?: SessionFeatures;
67
+ collaborationRole: CollaborationRole$1;
68
+ cdpUrl: string | null;
69
+ shareUrls: {
70
+ editor: string;
71
+ viewer: string;
72
+ } | null;
73
+ onSessionDetails?: () => void;
74
+ };
75
+ declare function BrowserControlPane({
76
+ control,
77
+ leading,
78
+ features: featureOverrides,
79
+ collaborationRole,
80
+ cdpUrl,
81
+ shareUrls,
82
+ onSessionDetails
83
+ }: BrowserControlPaneProps): import("react").JSX.Element;
84
+ //#endregion
85
+ //#region src/components/browser-viewport.d.ts
86
+ interface BrowserViewportProps extends Omit<SessionViewportProps, "renderOverlay" | "onNotice"> {
87
+ statusBadge?: boolean;
88
+ }
89
+ declare function BrowserViewport({
90
+ statusBadge,
91
+ className,
92
+ ...props
93
+ }: BrowserViewportProps): import("react").JSX.Element;
94
+ //#endregion
95
+ //#region src/notices.d.ts
96
+ declare function showNotice(notice: SessionNotice): void;
97
+ //#endregion
98
+ export { ApertureProvider, ApertureProviderProps, ApertureRuntime, ApertureRuntimeOptions, ApertureSession, ApertureSessionFeatures, ApertureSessionProps, BrowserCommands, BrowserControlPane, BrowserMediaPath, BrowserMediaPhase, BrowserViewport, BrowserViewportProps, ClipboardError, CollaborationControl, type CollaborationCursor, type CollaborationError, type CollaborationLeaseMode, type CollaborationPaintEvent, type CollaborationPaintPoint, type CollaborationParticipant, type CollaborationPhase, type CollaborationRole, LiveSessionControl, LiveSessionError, LiveSessionMediaSelection, LiveSessionMediaSize, ResolvedSessionFeatures, RuntimeProvider, RuntimeProviderMissingError, SessionFeatures, SessionNotice, SessionViewport, SessionViewportOverlay, SessionViewportPlaceholder, SessionViewportProps, SessionViewportStatus, ShareToken, SharedSession, SharedSessionProps, SharedSessionStatus, UseBrowserControlResult, UseSharedSessionOptions, UseSharedSessionResult, collaborationPaintLifetimeMs, copyText, copyTextWithToast, devToolsUrl, makeApertureRuntime, parseShareToken, resolveSessionFeatures, showNotice, useBaseUrl, useBrowserControl, useEffectCallback, useFork, useLiveSession, useRunApi, useRuntime, useSharedSession };
99
+ //# sourceMappingURL=index.d.ts.map