import * as Effect from "effect/Effect"; import * as Schema from "effect/Schema"; import { ApiCredentials, IceServer } from "@aperture-browser/api-client"; //#region src/browser-input.d.ts type BrowserInputMessage = { type: "input.mouse"; targetId: string; action: "move" | "down" | "up" | "click" | "doubleClick"; x: number; y: number; button?: "left" | "middle" | "right" | "none"; buttons?: number; clickCount?: number; modifiers?: number; } | { type: "input.wheel"; targetId: string; x: number; y: number; deltaX: number; deltaY: number; modifiers?: number; } | { type: "input.key"; targetId: string; action: "down" | "up" | "char"; key?: string; code?: string; text?: string; unmodifiedText?: string; modifiers?: number; windowsVirtualKeyCode?: number; nativeVirtualKeyCode?: number; location?: number; autoRepeat?: boolean; isKeypad?: boolean; } | { type: "clipboard.copy"; targetId: string; } | { type: "clipboard.cut"; targetId: string; } | { type: "clipboard.paste"; targetId: string; items: Array<{ mimeType: string; data: string; }>; }; //#endregion //#region src/input-keycodes.d.ts declare const evdevKeycodeByCode: Readonly>; //#endregion //#region src/keyboard.d.ts type KeyboardInputMessage = Extract; declare function keyboardModifiers(event: KeyboardEvent | MouseEvent | WheelEvent): number; declare function isPrintableKey(event: KeyboardEvent): boolean; declare function keyboardInputMessage(event: KeyboardEvent, action: KeyboardInputMessage["action"]): Omit; declare function shouldForwardBrowserShortcut(event: KeyboardEvent): boolean; declare function windowsVirtualKeyCodeForCodeOrKey(code: string | undefined, key: string | undefined): number; //#endregion //#region src/protocol.d.ts declare const LIVE_SESSION_PROTOCOL = "aperture-session.v1"; type CollaborationRole = "owner" | "editor" | "viewer"; type CollaborationLeaseMode = "implicit" | "explicit"; type CollaborationPhase = "idle" | "connecting" | "connected" | "disconnected"; interface CollaborationCursor { clientId: string; targetId: string; x: number; y: number; } type CollaborationPaintPhase = "start" | "move" | "end"; interface CollaborationPaintPoint { targetId: string; strokeId: string; color: string; width: number; phase: CollaborationPaintPhase; x: number; y: number; } type CollaborationPaintEvent = { type: "point"; message: CollaborationPaintPoint & { clientId: string; }; } | { type: "clear"; }; interface CollaborationError { code: string; message: string; } /** * Server messages are decoded strictly: an unknown property means the server speaks a * protocol revision this client does not understand. */ declare const strictParseOptions: { readonly onExcessProperty: "error"; }; declare const PresentationQuality: Schema.Struct<{ readonly profile: Schema.String; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly keyframeInterval: Schema.Number; }>; declare const Presentation: Schema.Struct<{ readonly quality: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>; declare const Target: Schema.Struct<{ readonly id: Schema.String; readonly type: Schema.String; readonly title: Schema.String; readonly url: Schema.String; readonly loading: Schema.Boolean; readonly viewport: Schema.optionalKey>; }>; declare const Participant: Schema.Struct<{ readonly clientId: Schema.String; readonly name: Schema.String; readonly avatarHash: Schema.String; readonly role: Schema.Literals; readonly activeTargetId: Schema.optionalKey; readonly followingClientId: Schema.optionalKey; readonly holdingInput: Schema.Boolean; readonly leaseMode: Schema.optionalKey>; readonly recovering: Schema.optionalKey; }>; declare const Snapshot: Schema.Struct<{ readonly type: Schema.Literal<"session.snapshot">; readonly clientId: Schema.String; readonly resumeSecret: Schema.String; readonly role: Schema.Literals; readonly transport: Schema.Literals; readonly holderClientId: Schema.optionalKey; readonly mode: Schema.optionalKey>; readonly activeTargetId: Schema.optionalKey; readonly targets: Schema.withDecodingDefaultKey>; }>>, never>; readonly participants: Schema.withDecodingDefaultKey; readonly activeTargetId: Schema.optionalKey; readonly followingClientId: Schema.optionalKey; readonly holdingInput: Schema.Boolean; readonly leaseMode: Schema.optionalKey>; readonly recovering: Schema.optionalKey; }>>, never>; readonly recordings: Schema.withDecodingDefaultKey; readonly targetId: Schema.String; readonly captureGeneration: Schema.Number; readonly status: Schema.Literals; readonly stopReason: Schema.optionalKey; readonly path: Schema.String; readonly startedAt: Schema.String; readonly stoppedAt: Schema.optionalKey; readonly sizeBytes: Schema.optionalKey; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly codec: Schema.String; }>>, never>; readonly presentation: Schema.Struct<{ readonly quality: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>; }>; declare const CommandResult: Schema.Struct<{ readonly type: Schema.Literals; readonly requestId: Schema.String; readonly ok: Schema.Boolean; readonly code: Schema.optionalKey; readonly message: Schema.optionalKey; readonly targetId: Schema.optionalKey; readonly recording: Schema.optionalKey; readonly targetId: Schema.String; readonly captureGeneration: Schema.Number; readonly status: Schema.Literals; readonly stopReason: Schema.optionalKey; readonly path: Schema.String; readonly startedAt: Schema.String; readonly stoppedAt: Schema.optionalKey; readonly sizeBytes: Schema.optionalKey; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly codec: Schema.String; }>>; readonly presentation: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>>; }>; declare const LiveSessionServerMessage: Schema.Union; readonly clientId: Schema.String; readonly resumeSecret: Schema.String; readonly role: Schema.Literals; readonly transport: Schema.Literals; readonly holderClientId: Schema.optionalKey; readonly mode: Schema.optionalKey>; readonly activeTargetId: Schema.optionalKey; readonly targets: Schema.withDecodingDefaultKey>; }>>, never>; readonly participants: Schema.withDecodingDefaultKey; readonly activeTargetId: Schema.optionalKey; readonly followingClientId: Schema.optionalKey; readonly holdingInput: Schema.Boolean; readonly leaseMode: Schema.optionalKey>; readonly recovering: Schema.optionalKey; }>>, never>; readonly recordings: Schema.withDecodingDefaultKey; readonly targetId: Schema.String; readonly captureGeneration: Schema.Number; readonly status: Schema.Literals; readonly stopReason: Schema.optionalKey; readonly path: Schema.String; readonly startedAt: Schema.String; readonly stoppedAt: Schema.optionalKey; readonly sizeBytes: Schema.optionalKey; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly codec: Schema.String; }>>, never>; readonly presentation: Schema.Struct<{ readonly quality: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>; }>, Schema.Struct<{ readonly type: Schema.Literal<"presence.state">; readonly participants: Schema.withDecodingDefaultKey; readonly activeTargetId: Schema.optionalKey; readonly followingClientId: Schema.optionalKey; readonly holdingInput: Schema.Boolean; readonly leaseMode: Schema.optionalKey>; readonly recovering: Schema.optionalKey; }>>, never>; }>, Schema.Struct<{ readonly type: Schema.Literal<"input.state">; readonly holderClientId: Schema.optionalKey; readonly mode: Schema.optionalKey>; }>, Schema.Struct<{ readonly type: Schema.Literal<"presence.cursor">; readonly clientId: Schema.String; readonly targetId: Schema.String; readonly x: Schema.Number; readonly y: Schema.Number; readonly realtimeCounter: Schema.Number; }>, Schema.Struct<{ readonly type: Schema.Literal<"presence.cursor.clear">; readonly clientId: Schema.String; readonly realtimeCounter: Schema.Number; }>, Schema.Struct<{ readonly type: Schema.Literal<"paint.point">; readonly clientId: Schema.String; readonly targetId: Schema.String; readonly strokeId: Schema.String; readonly color: Schema.String; readonly width: Schema.Number; readonly phase: Schema.Literals; readonly x: Schema.Number; readonly y: Schema.Number; readonly realtimeCounter: Schema.optionalKey; }>, Schema.Struct<{ readonly type: Schema.Literal<"targets.state">; readonly activeTargetId: Schema.optionalKey; readonly targets: Schema.withDecodingDefaultKey>; }>>, never>; }>, Schema.Struct<{ readonly type: Schema.Literal<"recordings.state">; readonly recordings: Schema.withDecodingDefaultKey; readonly targetId: Schema.String; readonly captureGeneration: Schema.Number; readonly status: Schema.Literals; readonly stopReason: Schema.optionalKey; readonly path: Schema.String; readonly startedAt: Schema.String; readonly stoppedAt: Schema.optionalKey; readonly sizeBytes: Schema.optionalKey; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly codec: Schema.String; }>>, never>; }>, Schema.Struct<{ readonly type: Schema.Literal<"presentation.state">; readonly presentation: Schema.Struct<{ readonly quality: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>; }>, Schema.Struct<{ readonly type: Schema.Literal<"error">; readonly code: Schema.String; readonly message: Schema.String; }>, Schema.Struct<{ readonly type: Schema.Literals; readonly requestId: Schema.String; readonly ok: Schema.Boolean; readonly code: Schema.optionalKey; readonly message: Schema.optionalKey; readonly targetId: Schema.optionalKey; readonly recording: Schema.optionalKey; readonly targetId: Schema.String; readonly captureGeneration: Schema.Number; readonly status: Schema.Literals; readonly stopReason: Schema.optionalKey; readonly path: Schema.String; readonly startedAt: Schema.String; readonly stoppedAt: Schema.optionalKey; readonly sizeBytes: Schema.optionalKey; readonly fps: Schema.Number; readonly bitrateKbps: Schema.Number; readonly codec: Schema.String; }>>; readonly presentation: Schema.optionalKey>; readonly profiles: Schema.$Array>; readonly cursorVisible: Schema.Boolean; }>>; }>]>; /** Decodes one JSON text frame from the server, or returns undefined when it is invalid. */ declare const decodeServerMessage: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Option").Option<{ readonly type: "target.select.result" | "target.create.result" | "target.close.result" | "page.navigate.result" | "page.history-back.result" | "page.history-forward.result" | "page.reload.result" | "page.stop-loading.result" | "viewport.set.result" | "presentation.quality.set.result" | "presentation.cursor.set.result" | "recording.start.result" | "recording.stop.result" | "recording.cancel.result"; readonly requestId: string; readonly ok: boolean; readonly message?: string | undefined; readonly code?: string | undefined; readonly targetId?: string | undefined; readonly recording?: { readonly targetId: string; readonly mode: "tab" | "viewer"; readonly status: "starting" | "running" | "stopped" | "failed"; readonly recordingId: string; readonly captureGeneration: number; readonly path: string; readonly startedAt: string; readonly fps: number; readonly bitrateKbps: number; readonly codec: string; readonly stopReason?: string | undefined; readonly stoppedAt?: string | undefined; readonly sizeBytes?: number | undefined; } | undefined; readonly presentation?: { readonly profiles: readonly { readonly id: string; readonly label: string; readonly codec: string; readonly mimeType: string; readonly sdpFmtpLine: string; }[]; readonly cursorVisible: boolean; readonly quality?: { readonly profile: string; readonly fps: number; readonly bitrateKbps: number; readonly keyframeInterval: number; } | undefined; } | undefined; } | { readonly type: "session.snapshot"; readonly presentation: { readonly profiles: readonly { readonly id: string; readonly label: string; readonly codec: string; readonly mimeType: string; readonly sdpFmtpLine: string; }[]; readonly cursorVisible: boolean; readonly quality?: { readonly profile: string; readonly fps: number; readonly bitrateKbps: number; readonly keyframeInterval: number; } | undefined; }; readonly role: "viewer" | "owner" | "editor"; readonly transport: "webrtc" | "websocket"; readonly targets: readonly { readonly type: string; readonly id: string; readonly title: string; readonly url: string; readonly loading: boolean; readonly viewport?: { readonly width: number; readonly height: number; readonly contentWidth: number; readonly contentHeight: number; readonly canvasWidth: number; readonly canvasHeight: number; readonly deviceScaleFactor: number; } | undefined; }[]; readonly participants: readonly { readonly role: "viewer" | "owner" | "editor" | "automation"; readonly clientId: string; readonly name: string; readonly avatarHash: string; readonly holdingInput: boolean; readonly activeTargetId?: string | undefined; readonly followingClientId?: string | undefined; readonly leaseMode?: "implicit" | "explicit" | undefined; readonly recovering?: boolean | undefined; }[]; readonly clientId: string; readonly recordings: readonly { readonly targetId: string; readonly mode: "tab" | "viewer"; readonly status: "starting" | "running" | "stopped" | "failed"; readonly recordingId: string; readonly captureGeneration: number; readonly path: string; readonly startedAt: string; readonly fps: number; readonly bitrateKbps: number; readonly codec: string; readonly stopReason?: string | undefined; readonly stoppedAt?: string | undefined; readonly sizeBytes?: number | undefined; }[]; readonly resumeSecret: string; readonly mode?: "implicit" | "explicit" | undefined; readonly holderClientId?: string | undefined; readonly activeTargetId?: string | undefined; } | { readonly type: "presence.state"; readonly participants: readonly { readonly role: "viewer" | "owner" | "editor" | "automation"; readonly clientId: string; readonly name: string; readonly avatarHash: string; readonly holdingInput: boolean; readonly activeTargetId?: string | undefined; readonly followingClientId?: string | undefined; readonly leaseMode?: "implicit" | "explicit" | undefined; readonly recovering?: boolean | undefined; }[]; } | { readonly type: "input.state"; readonly mode?: "implicit" | "explicit" | undefined; readonly holderClientId?: string | undefined; } | { readonly type: "presence.cursor"; readonly clientId: string; readonly targetId: string; readonly x: number; readonly y: number; readonly realtimeCounter: number; } | { readonly type: "presence.cursor.clear"; readonly clientId: string; readonly realtimeCounter: number; } | { readonly type: "paint.point"; readonly targetId: string; readonly width: number; readonly clientId: string; readonly x: number; readonly y: number; readonly phase: "start" | "move" | "end"; readonly strokeId: string; readonly color: string; readonly realtimeCounter?: number | undefined; } | { readonly type: "targets.state"; readonly targets: readonly { readonly type: string; readonly id: string; readonly title: string; readonly url: string; readonly loading: boolean; readonly viewport?: { readonly width: number; readonly height: number; readonly contentWidth: number; readonly contentHeight: number; readonly canvasWidth: number; readonly canvasHeight: number; readonly deviceScaleFactor: number; } | undefined; }[]; readonly activeTargetId?: string | undefined; } | { readonly type: "recordings.state"; readonly recordings: readonly { readonly targetId: string; readonly mode: "tab" | "viewer"; readonly status: "starting" | "running" | "stopped" | "failed"; readonly recordingId: string; readonly captureGeneration: number; readonly path: string; readonly startedAt: string; readonly fps: number; readonly bitrateKbps: number; readonly codec: string; readonly stopReason?: string | undefined; readonly stoppedAt?: string | undefined; readonly sizeBytes?: number | undefined; }[]; } | { readonly type: "presentation.state"; readonly presentation: { readonly profiles: readonly { readonly id: string; readonly label: string; readonly codec: string; readonly mimeType: string; readonly sdpFmtpLine: string; }[]; readonly cursorVisible: boolean; readonly quality?: { readonly profile: string; readonly fps: number; readonly bitrateKbps: number; readonly keyframeInterval: number; } | undefined; }; } | { readonly type: "error"; readonly code: string; readonly message: string; }>; type LiveSessionServerMessage = typeof LiveSessionServerMessage.Type; type LiveSessionSnapshot = typeof Snapshot.Type; type LiveSessionTarget = typeof Target.Type; type LiveSessionCommandResult = typeof CommandResult.Type; type LiveSessionPresentation = typeof Presentation.Type; type LiveSessionPresentationQuality = typeof PresentationQuality.Type; type CollaborationParticipant = typeof Participant.Type; declare const RasterFrameHeader: Schema.Struct<{ readonly type: Schema.Literal<"presentation.frame">; readonly targetId: Schema.String; readonly width: Schema.Number; readonly height: Schema.Number; }>; type LiveSessionRasterFrame = Omit & { data: Blob; }; //#endregion //#region src/viewport.d.ts interface ViewportPreset { id: string; label: string; width: number; height: number; deviceScaleFactor: number; } declare const VIEWPORT_PRESETS: ViewportPreset[]; declare const DEFAULT_VIEWPORT: ViewportPreset; declare const VIEWPORT_DEVICE_SCALE_FACTORS: readonly [1, 1.5, 2, 3]; declare const STALE_FRAME_MS = 3000; interface RenderMetrics { scale: number; offsetX: number; offsetY: number; renderedWidth: number; renderedHeight: number; } declare function createViewportPreset(width: number, height: number, deviceScaleFactor: number): ViewportPreset; declare function formatViewportScale(deviceScaleFactor: number): string; declare function computeRenderMetrics(containerWidth: number, containerHeight: number, viewportWidth: number, viewportHeight: number): RenderMetrics; declare function mapClientToViewport(clientX: number, clientY: number, rect: DOMRect, viewportWidth: number, viewportHeight: number): { x: number; y: number; } | null; declare namespace connection_d_exports { export { LiveSessionConnection, LiveSessionConnectionCallbacks, LiveSessionConnectionOptions, LiveSessionError, LiveSessionSnapshot, LiveSessionTransportKind, make }; } declare const LiveSessionError_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & { readonly _tag: "LiveSessionError"; } & Readonly; /** A live session operation that could not complete. */ declare class LiveSessionError extends LiveSessionError_base<{ readonly message: string; }> {} interface SessionHelloIdentity { name: string; avatarHash: string; } type LiveSessionTransportKind = "webrtc" | "websocket"; interface LiveSessionConnectionCallbacks { onPhase: (phase: "connecting" | "connected" | "disconnected" | "error") => void; onMessage: (message: LiveSessionServerMessage) => void; onFrame: (frame: LiveSessionRasterFrame | null) => void; onStream: (stream: MediaStream | null) => void; onTransport: (transport: LiveSessionTransportKind | null) => void; onError: (message: string) => void; } interface LiveSessionConnectionOptions { baseUrl?: string; sessionId: string; credentials: ApiCredentials; sessionToken?: string; identity: SessionHelloIdentity; iceServers: readonly IceServer[]; webrtcSupported: boolean; callbacks: LiveSessionConnectionCallbacks; } interface LiveSessionConnection { /** Replaces the current session transport with a fresh one. */ readonly reconnect: Effect.Effect; /** Switches presentation to the given transport once it is ready. */ readonly selectTransport: (kind: LiveSessionTransportKind) => Effect.Effect; readonly sendReliable: (message: Record) => boolean; readonly sendRealtime: (message: Record) => boolean; /** Sends a command and waits for its result message. */ readonly command: (type: string, payload?: Record) => Effect.Effect; } /** * Opens a live session connection. It prefers WebRTC presentation, falls back to * WebSocket raster frames, and keeps retrying WebRTC in the background. Closing the scope * closes every transport and fails pending commands. */ declare const make: (options: LiveSessionConnectionOptions) => Effect.Effect<{ reconnect: Effect.Effect; selectTransport: (kind: LiveSessionTransportKind) => Effect.Effect; sendReliable: (message: Record) => boolean; sendRealtime: (message: Record) => boolean; command: (type: string, payload?: Record | undefined) => Effect.Effect<{ readonly type: "target.select.result" | "target.create.result" | "target.close.result" | "page.navigate.result" | "page.history-back.result" | "page.history-forward.result" | "page.reload.result" | "page.stop-loading.result" | "viewport.set.result" | "presentation.quality.set.result" | "presentation.cursor.set.result" | "recording.start.result" | "recording.stop.result" | "recording.cancel.result"; readonly requestId: string; readonly ok: boolean; readonly message?: string | undefined; readonly code?: string | undefined; readonly targetId?: string | undefined; readonly recording?: { readonly targetId: string; readonly mode: "tab" | "viewer"; readonly status: "starting" | "running" | "stopped" | "failed"; readonly recordingId: string; readonly captureGeneration: number; readonly path: string; readonly startedAt: string; readonly fps: number; readonly bitrateKbps: number; readonly codec: string; readonly stopReason?: string | undefined; readonly stoppedAt?: string | undefined; readonly sizeBytes?: number | undefined; } | undefined; readonly presentation?: { readonly profiles: readonly { readonly id: string; readonly label: string; readonly codec: string; readonly mimeType: string; readonly sdpFmtpLine: string; }[]; readonly cursorVisible: boolean; readonly quality?: { readonly profile: string; readonly fps: number; readonly bitrateKbps: number; readonly keyframeInterval: number; } | undefined; } | undefined; }, LiveSessionError, never>; }, never, import("effect/Scope").Scope>; //#endregion export { BrowserInputMessage, CollaborationCursor, CollaborationError, CollaborationLeaseMode, CollaborationPaintEvent, CollaborationPaintPhase, CollaborationPaintPoint, CollaborationParticipant, CollaborationPhase, CollaborationRole, DEFAULT_VIEWPORT, LIVE_SESSION_PROTOCOL, LiveSessionCommandResult, connection_d_exports as LiveSessionConnection, LiveSessionError, LiveSessionPresentation, LiveSessionPresentationQuality, LiveSessionRasterFrame, LiveSessionServerMessage, LiveSessionSnapshot, LiveSessionTarget, type LiveSessionTransportKind, RasterFrameHeader, RenderMetrics, STALE_FRAME_MS, VIEWPORT_DEVICE_SCALE_FACTORS, VIEWPORT_PRESETS, ViewportPreset, computeRenderMetrics, createViewportPreset, decodeServerMessage, evdevKeycodeByCode, formatViewportScale, isPrintableKey, keyboardInputMessage, keyboardModifiers, mapClientToViewport, shouldForwardBrowserShortcut, strictParseOptions, windowsVirtualKeyCodeForCodeOrKey }; //# sourceMappingURL=index.d.ts.map