import type { AudioCaptureOptions } from 'livekit-client'; import { BehaviorSubject } from 'rxjs'; import { ChatMessage } from 'livekit-client'; import { ConnectionQuality } from 'livekit-client'; import { ConnectionState } from 'livekit-client'; import { DataPacket_Kind } from 'livekit-client'; import { DataPublishOptions } from 'livekit-client'; import { Encryption_Type } from 'livekit-client'; import { LocalAudioTrack } from 'livekit-client'; import { LocalParticipant } from 'livekit-client'; import { LocalVideoTrack } from 'livekit-client'; import loglevel from 'loglevel'; import { Observable } from 'rxjs'; import { Participant } from 'livekit-client'; import { ParticipantEvent } from 'livekit-client'; import type { ParticipantEventCallbacks } from 'livekit-client/dist/src/room/participant/Participant'; import type { ParticipantKind } from 'livekit-client'; import type { ParticipantPermission } from '@livekit/protocol'; import type { PublicationEventCallbacks } from 'livekit-client/dist/src/room/track/TrackPublication'; import { RemoteParticipant } from 'livekit-client'; import { Room } from 'livekit-client'; import { RoomEvent } from 'livekit-client'; import type { RoomEventCallbacks } from 'livekit-client/dist/src/room/Room'; import type { ScreenShareCaptureOptions } from 'livekit-client'; import { SendTextOptions } from 'livekit-client'; import { setLogLevel as setLogLevel_2 } from 'livekit-client'; import type { TextStreamInfo } from 'livekit-client/dist/src/room/types'; import { Track } from 'livekit-client'; import { TrackEvent as TrackEvent_2 } from 'livekit-client'; import { TrackPublication } from 'livekit-client'; import type { TrackPublishOptions } from 'livekit-client'; import { TranscriptionSegment } from 'livekit-client'; import type { VideoCaptureOptions } from 'livekit-client'; export declare function activeSpeakerObserver(room: Room): Observable; export declare function addMediaTimestampToTranscription(segment: TranscriptionSegment, timestamps: { timestamp: number; rtpTimestamp?: number; }): ReceivedTranscriptionSegment; export declare const allParticipantEvents: ParticipantEvent[]; export declare const allParticipantRoomEvents: RoomEvent[]; export declare const allRemoteParticipantEvents: ParticipantEvent[]; export declare const allRemoteParticipantRoomEvents: RoomEvent[]; export declare const attachIfSubscribed: (publication: TrackPublication | undefined, element: HTMLMediaElement | null | undefined) => void; export declare type AudioSource = Track.Source.Microphone | Track.Source.ScreenShareAudio; export declare interface BaseDataMessage { topic?: T; payload: Uint8Array; } export declare type CaptureOptionsBySource = T extends Track.Source.Camera ? VideoCaptureOptions : T extends Track.Source.Microphone ? AudioCaptureOptions : T extends Track.Source.ScreenShare ? ScreenShareCaptureOptions : never; export { ChatMessage } /** @public */ export declare type ChatOptions = { /** @deprecated the new chat API doesn't rely on encoders and decoders anymore and uses a dedicated chat API instead */ messageEncoder?: (message: LegacyChatMessage) => Uint8Array; /** @deprecated the new chat API doesn't rely on encoders and decoders anymore and uses a dedicated chat API instead */ messageDecoder?: (message: Uint8Array) => LegacyReceivedChatMessage; channelTopic?: string; /** @deprecated the new chat API doesn't rely on update topics anymore and uses a dedicated chat API instead */ updateChannelTopic?: string; }; export declare function computeMenuPosition(button: HTMLElement, menu: HTMLElement, onUpdate?: (x: number, y: number) => void): () => void; export declare function connectedParticipantObserver(room: Room, identity: string, options?: ConnectedParticipantObserverOptions): Observable; export declare type ConnectedParticipantObserverOptions = { additionalEvents?: ParticipantEvent[]; }; export declare function connectedParticipantsObserver(room: Room, options?: ConnectedParticipantsObserverOptions): Observable; declare type ConnectedParticipantsObserverOptions = { additionalRoomEvents?: RoomEvent[]; }; export declare function connectionStateObserver(room: Room): Observable; export declare function createActiveDeviceObservable(room: Room, kind: MediaDeviceKind): Observable; export declare function createChatObserver(room: Room): Observable<[message: ChatMessage, participant?: LocalParticipant | RemoteParticipant | undefined]>; export declare function createConnectionQualityObserver(participant: Participant): Observable; export declare function createDataObserver(room: Room): Observable<[payload: Uint8Array, participant?: RemoteParticipant | undefined, kind?: DataPacket_Kind | undefined, topic?: string | undefined, encryptionType?: Encryption_Type | undefined]>; export declare const createDefaultGrammar: () => { email: RegExp; url: RegExp; }; export declare function createEmailRegExp({ exact }?: { exact?: boolean; }): RegExp; /** * Returns true if the user is interacting with the HTML element, * and returns false if there is no interaction for a specified period of time. * * @internal */ export declare function createInteractingObservable(htmlElement: HTMLElement | null, inactiveAfter?: number): Observable; export declare function createIsSpeakingObserver(participant: Participant): Observable; export declare function createMediaDeviceObserver(kind?: MediaDeviceKind, onError?: (e: Error) => void, requestPermissions?: boolean): Observable; export declare function createTrackObserver(participant: Participant, options: TrackIdentifier): Observable<{ publication: TrackPublication | undefined; }>; export declare function createUrlRegExp(options: RegExOptions): RegExp; export declare const cssPrefix = "lk"; export declare const DataTopic: { readonly CHAT: "lk.chat"; readonly TRANSCRIPTION: "lk.transcription"; }; /** * @returns An array of unique (by id) `TranscriptionSegment`s. Latest wins. If the resulting array would be longer than `windowSize`, the array will be reduced to `windowSize` length */ export declare function dedupeSegments(prevSegments: T[], newSegments: T[], windowSize: number): T[]; export declare const defaultUserChoices: LocalUserChoices; export declare function didActiveSegmentsChange(prevActive: T[], newActive: T[]): boolean; export declare function encryptionStatusObservable(room: Room, participant: Participant | undefined): Observable; export declare function getActiveTranscriptionSegments(segments: ReceivedTranscriptionSegment[], syncTimes: { timestamp: number; rtpTimestamp?: number; }, maxAge?: number): ReceivedTranscriptionSegment[]; /** * Calculates the scrollbar width by creating two HTML elements * and messaging the difference. * @internal */ export declare function getScrollBarWidth(): number; export declare function getTrackByIdentifier(options: TrackIdentifier): TrackPublication | undefined; /** * Returns a id to identify the `TrackReference` or `TrackReferencePlaceholder` based on * participant, track source and trackSid. * @remarks * The id pattern is: `${participantIdentity}_${trackSource}_${trackSid}` for `TrackReference` * and `${participantIdentity}_${trackSource}_placeholder` for `TrackReferencePlaceholder`. */ export declare function getTrackReferenceId(trackReference: TrackReferenceOrPlaceholder | number): string; /** Returns the Source of the TrackReference. */ export declare function getTrackReferenceSource(trackReference: TrackReferenceOrPlaceholder): Track.Source; export declare const GRID_LAYOUTS: GridLayoutDefinition[]; /** * @public */ export declare type GridLayoutDefinition = { /** Column count of the grid layout. */ columns: number; /** Row count of the grid layout. */ rows: number; /** * Minimum grid container width required to use this layout. * @remarks * If this constraint is not met, we try to select a layout with fewer tiles * (`tiles=columns*rows`) that is within the constraint. */ minWidth?: number; /** * Minimum grid container height required to use this layout. * @remarks * If this constraint is not met, we try to select a layout with fewer tiles * (`tiles=columns*rows`) that is within the constraint. */ minHeight?: number; /** * For which orientation the layout definition should be applied. * Will be used for both landscape and portrait if no value is specified. */ orientation?: 'landscape' | 'portrait'; }; export declare type GridLayoutInfo = { /** Layout name (convention `x`). */ name: string; /** Column count of the layout. */ columns: number; /** Row count of the layout. */ rows: number; /** Maximum tiles that fit into this layout. */ maxTiles: number; /** Minimum width required to use this layout. */ minWidth: number; /** Minimum height required to use this layout. */ minHeight: number; orientation?: 'landscape' | 'portrait'; }; export declare function isEqualTrackRef(a?: TrackReferenceOrPlaceholder, b?: TrackReferenceOrPlaceholder): boolean; export declare function isLocal(p: Participant): boolean; /** * Mobile browser detection based on `navigator.userAgent` string. * Defaults to returning `false` if not in a browser. * * @remarks * This should only be used if feature detection or other methods do not work! * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#mobile_device_detection */ export declare function isMobileBrowser(): boolean; /** * Check if the participant track reference is pinned. */ export declare function isParticipantTrackReferencePinned(trackRef: TrackReference, pinState: PinState | undefined): boolean; /** * Check if the current `currentTrackRef` is the placeholder for next `nextTrackRef`. * Based on the participant identity and the source. * @internal */ export declare function isPlaceholderReplacement(currentTrackRef: TrackReferenceOrPlaceholder, nextTrackRef: TrackReferenceOrPlaceholder): boolean; export declare function isRemote(p: Participant): boolean; export declare function isSourcesWithOptions(sources: SourcesArray): sources is TrackSourceWithOptions[]; export declare function isSourceWitOptions(source: SourcesArray[number]): source is TrackSourceWithOptions; /** @internal */ export declare function isTrackReference(trackReference: unknown): trackReference is TrackReference; /** * Check if the `TrackReference` is pinned. */ export declare function isTrackReferencePinned(trackReference: TrackReferenceOrPlaceholder, pinState: PinState | undefined): boolean; export declare function isTrackReferencePlaceholder(trackReference?: TrackReferenceOrPlaceholder): trackReference is TrackReferencePlaceholder; /** * @internal */ export declare function isWeb(): boolean; export declare interface LegacyChatMessage extends ChatMessage { ignoreLegacy?: boolean; } /** @deprecated */ export declare const LegacyDataTopic: { readonly CHAT: "lk-chat-topic"; }; export declare interface LegacyReceivedChatMessage extends ReceivedChatMessage { ignoreLegacy?: boolean; } /** * Reads the user choices from local storage, or returns the default settings if none are found. * @remarks * The deprecated parameters `e2ee` and `sharedPassphrase` are not read from local storage * and always return the value from the passed `defaults` or internal defaults. * @alpha */ export declare function loadUserChoices(defaults?: Partial, /** * Whether to prevent loading from local storage and return default values instead. * @defaultValue false */ preventLoad?: boolean): LocalUserChoices; /** * @public * Represents the user's choices for video and audio input devices, * as well as their username. */ export declare type LocalUserChoices = { /** * Whether video input is enabled. * @defaultValue `true` */ videoEnabled: boolean; /** * Whether audio input is enabled. * @defaultValue `true` */ audioEnabled: boolean; /** * The device ID of the video input device to use. * @defaultValue `''` */ videoDeviceId: string; /** * The device ID of the audio input device to use. * @defaultValue `''` */ audioDeviceId: string; /** * The username to use. * @defaultValue `''` */ username: string; }; export declare const log: loglevel.Logger; declare type LogExtension = (level: LogLevel, msg: string, context?: object) => void; declare type LogLevel = Parameters[0]; export declare type MediaToggleType = { pendingObserver: Observable; toggle: (forceState?: boolean, captureOptions?: CaptureOptionsBySource) => Promise; className: string; enabledObserver: Observable; }; /** * @public * @deprecated the new chat API doesn't rely on encoders and decoders anymore and uses a dedicated chat API instead */ export declare type MessageDecoder = (message: Uint8Array) => LegacyReceivedChatMessage; /** * @public * @deprecated the new chat API doesn't rely on encoders and decoders anymore and uses a dedicated chat API instead */ export declare type MessageEncoder = (message: LegacyChatMessage) => Uint8Array; export declare function mutedObserver(trackRef: TrackReferenceOrPlaceholder): Observable; export declare function observeParticipantEvents(participant: T, ...events: ParticipantEvent[]): Observable; export declare function observeParticipantMedia(participant: T): Observable>; export declare function observeRoomEvents(room: Room, ...events: RoomEvent[]): Observable; export declare function observeTrackEvents(track: TrackPublication, ...events: TrackEvent_2[]): Observable; /** An enum of first party livekit attributes generated by the serverside agents sdk */ export declare enum ParticipantAgentAttributes { AgentState = "lk.agent.state", PublishOnBehalf = "lk.publish_on_behalf", TranscriptionFinal = "lk.transcription_final", TranscriptionSegmentId = "lk.segment_id", TranscribedTrackId = "lk.transcribed_track_id" } export declare function participantAttributesObserver(participant: Participant): Observable<{ changed: Readonly>; attributes: Readonly>; }>; export declare function participantAttributesObserver(participant: undefined): Observable<{ changed: undefined; attributes: undefined; }>; export declare function participantByIdentifierObserver(room: Room, { kind, identity }: ParticipantIdentifier, options?: ConnectedParticipantObserverOptions): Observable; /** @internal */ export declare interface ParticipantClickEvent { participant: Participant; track?: TrackPublication; } export declare function participantEventSelector(participant: Participant, event: T): Observable]>>; export declare type ParticipantFilter = Parameters['0']; /** * @beta */ export declare type ParticipantIdentifier = RequireAtLeastOne<{ kind: ParticipantKind; identity: string; }, 'identity' | 'kind'>; export declare function participantInfoObserver(participant?: Participant): Observable<{ name: string | undefined; identity: string; metadata: string | undefined; } | { name: string | undefined; identity: string; metadata: string | undefined; }> | undefined; export declare interface ParticipantMedia { isCameraEnabled: boolean; isMicrophoneEnabled: boolean; isScreenShareEnabled: boolean; microphoneTrack?: TrackPublication; cameraTrack?: TrackPublication; participant: T; } export declare function participantPermissionObserver(participant: Participant): Observable; export declare const participantTrackEvents: ParticipantEvent[]; export declare type ParticipantTrackIdentifier = RequireAtLeastOne<{ sources: Track.Source[]; name: string; kind: Track.Kind; }, 'sources' | 'name' | 'kind'>; export declare function participantTracksObservable(participant: Participant, trackIdentifier: ParticipantTrackIdentifier): Observable; export declare const PIN_DEFAULT_STATE: PinState; /** @public */ export declare type PinState = TrackReferenceOrPlaceholder[]; export declare type ReceivedAgentTranscriptionMessage = ReceivedMessageWithType<'agentTranscript', { message: string; }>; /** @public */ export declare type ReceivedChatMessage = Omit & { type?: 'chatMessage'; }; /** @private */ declare type ReceivedChatMessageWithRequiredType = ReceivedMessageWithType<'chatMessage', ChatMessage & { from?: Participant; attributes?: Record; }>; export declare interface ReceivedDataMessage extends BaseDataMessage { from?: Participant; } /** @beta */ export declare type ReceivedMessage = ReceivedUserTranscriptionMessage | ReceivedAgentTranscriptionMessage | ReceivedChatMessage; declare type ReceivedMessageWithType = { id: string; timestamp: number; type: Type; from?: Participant; attributes?: Record; } & Metadata; export declare type ReceivedTranscriptionSegment = TranscriptionSegment & { receivedAtMediaTimestamp: number; receivedAt: number; }; export declare type ReceivedUserTranscriptionMessage = ReceivedMessageWithType<'userTranscript', { message: string; }>; export declare function recordingStatusObservable(room: Room): Observable; declare interface RegExOptions { /** Only match an exact string. Useful with `RegExp#test` to check if a string is a URL. @defaultValue false */ readonly exact?: boolean; } declare type RequireAtLeastOne = Pick> & { [K in Keys]-?: Required> & Partial>>; }[Keys]; export declare type RequireOnlyOne = Pick> & { [K in Keys]-?: Required> & Partial, undefined>>; }[Keys]; export declare function roomAudioPlaybackAllowedObservable(room: Room): Observable<{ canPlayAudio: boolean; }>; export declare function roomEventSelector(room: Room, event: T): Observable>; export declare function roomInfoObserver(room: Room): Observable<{ name: string; metadata: string | undefined; }>; export declare function roomObserver(room: Room): Observable; export declare function roomVideoPlaybackAllowedObservable(room: Room): Observable<{ canPlayVideo: boolean; }>; /** * Saves user choices to local storage. * @alpha */ export declare function saveUserChoices(userChoices: LocalUserChoices, /** * Whether to prevent saving user choices to local storage. */ preventSave?: boolean): void; export declare function screenShareObserver(room: Room): Observable; export declare type ScreenShareTrackMap = Array<{ participant: Participant; tracks: Array; }>; export declare function selectGridLayout(layoutDefinitions: GridLayoutDefinition[], participantCount: number, width: number, height: number): GridLayoutInfo; /** Publish data from the LocalParticipant. */ export declare function sendMessage(localParticipant: LocalParticipant, payload: Uint8Array, options?: DataPublishOptions): Promise; export declare type SentMessage = ChatMessage; export declare function setDifference(setA: Set, setB: Set): Set; /** * Set the log extension for both the `@livekit/components-react` package and the `@livekit-client` package. * To set the `@livekit-client` log extension, use the `liveKitClientLogExtension` prop on the `options` object. * @public */ export declare function setLogExtension(extension: LogExtension, options?: SetLogExtensionOptions): void; declare type SetLogExtensionOptions = { liveKitClientLogExtension?: LogExtension; }; /** * Set the log level for both the `@livekit/components-react` package and the `@livekit-client` package. * To set the `@livekit-client` log independently, use the `liveKitClientLogLevel` prop on the `options` object. * @public */ export declare function setLogLevel(level: LogLevel, options?: SetLogLevelOptions): void; declare type SetLogLevelOptions = { liveKitClientLogLevel?: LogLevel; }; export declare type SetMediaDeviceOptions = { /** * If true, adds an `exact` constraint to the getUserMedia request. * The request will fail if this option is true and the device specified is not actually available */ exact?: boolean; }; export declare function setupChat(room: Room, options?: ChatOptions): { messageObservable: Observable; isSendingObservable: BehaviorSubject; send: (message: string, options?: SendTextOptions) => Promise; }; export declare function setupChatMessageHandler(room: Room): { chatObservable: Observable<[message: ChatMessage, participant?: LocalParticipant | RemoteParticipant | undefined]>; send: (text: string, options: SendTextOptions) => Promise; edit: (text: string, originalMsg: ChatMessage) => Promise<{ readonly message: string; readonly editTimestamp: number; readonly id: string; readonly timestamp: number; readonly attachedFiles?: Array; }>; }; export declare function setupChatToggle(): { className: string; }; export declare function setupClearPinButton(): { className: string; }; export declare function setupConnectionQualityIndicator(participant: Participant): { className: "lk-connection-quality"; connectionQualityObserver: Observable; }; export declare function setupDataMessageHandler(room: Room, topic?: T | [T, ...T[]], onMessage?: (msg: ReceivedDataMessage) => void): { messageObservable: Observable<{ payload: Uint8Array; topic: T; from: RemoteParticipant | undefined; }>; isSendingObservable: Observable; send: (payload: Uint8Array, options?: DataPublishOptions) => Promise; }; export declare function setupDeviceSelector(kind: MediaDeviceKind, room: Room, localTrack?: LocalAudioTrack | LocalVideoTrack): { className: string; activeDeviceObservable: Observable; setActiveMediaDevice: (id: string, options?: SetMediaDeviceOptions) => Promise; }; export declare function setupDisconnectButton(room: Room): { className: string; disconnect: (stopTracks?: boolean) => void; }; export declare function setupFocusToggle(): { className: string; }; export declare function setupLiveKitRoom(): { className: string; }; export declare function setupManualToggle(): { className: string; toggle: (forceState?: boolean) => Promise; enabledObserver: Observable; pendingObserver: Observable; }; export declare function setupMediaToggle(source: T, room: Room, options?: CaptureOptionsBySource, publishOptions?: TrackPublishOptions, onError?: (error: Error) => void): MediaToggleType; export declare function setupMediaTrack(trackIdentifier: TrackIdentifier): { className: string; trackObserver: Observable; }; export declare function setupParticipantName(participant: Participant): { className: string; infoObserver: Observable< { name: string | undefined; identity: string; metadata: string | undefined; } | { name: string | undefined; identity: string; metadata: string | undefined; }> | undefined; }; export declare function setupParticipantTile(): { className: string; }; export declare function setupStartAudio(): { className: string; roomAudioPlaybackAllowedObservable: typeof roomAudioPlaybackAllowedObservable; handleStartAudioPlayback: (room: Room) => Promise; }; export declare function setupStartVideo(): { className: string; roomVideoPlaybackAllowedObservable: typeof roomVideoPlaybackAllowedObservable; handleStartVideoPlayback: (room: Room) => Promise; }; export declare function setupTextStream(room: Room, topic: string): Observable; export declare function setupTrackMutedIndicator(trackRef: TrackReferenceOrPlaceholder): { className: string; mediaMutedObserver: Observable; }; /** * Default sort for participants, it'll order participants by: * 1. local participant * 2. dominant speaker (speaker with the loudest audio level) * 3. other speakers that are recently active * 4. participants with video on * 5. by joinedAt */ export declare function sortParticipants(participants: Participant[]): Participant[]; /** * Default sort for `TrackReferenceOrPlaceholder`, it'll order participants by: * 1. local camera track (publication.isLocal) * 2. remote screen_share track * 3. local screen_share track * 4. remote dominant speaker camera track (sorted by speaker with the loudest audio level) * 5. other remote speakers that are recently active * 6. remote unmuted camera tracks * 7. remote tracks sorted by joinedAt */ export declare function sortTrackReferences(tracks: TrackReferenceOrPlaceholder[]): TrackReferenceOrPlaceholder[]; export declare type SourcesArray = Track.Source[] | TrackSourceWithOptions[]; /** * Returns `true` if the browser supports screen sharing. */ export declare function supportsScreenSharing(): boolean; export declare interface TextStreamData { text: string; participantInfo: { identity: string; }; streamInfo: TextStreamInfo; } export declare type ToggleSource = Exclude; export declare function tokenize(input: string, grammar: T): (string | { type: keyof T; content: string; })[]; export declare type TokenizeGrammar = { [type: string]: RegExp; }; export declare function trackEventSelector(publication: TrackPublication | Track, event: T): Observable]>>; /** * The TrackIdentifier type is used to select Tracks either based on * - Track.Source and/or name of the track, e.g. `{source: Track.Source.Camera}` or `{name: "my-track"}` * - TrackReference (participant and publication) * @internal */ export declare type TrackIdentifier = TrackSource | TrackReference; export declare function trackObservable(track: TrackPublication): Observable; /** @public */ export declare type TrackReference = { participant: Participant; publication: TrackPublication; source: Track.Source; }; export declare type TrackReferenceFilter = Parameters['0']; export declare type TrackReferenceId = ReturnType; /** @public */ export declare type TrackReferenceOrPlaceholder = TrackReference | TrackReferencePlaceholder; /** @public */ export declare type TrackReferencePlaceholder = { participant: Participant; publication?: never; source: Track.Source; }; export declare function trackReferencesObservable(room: Room, sources: Track.Source[], options: TrackReferencesObservableOptions): Observable<{ trackReferences: TrackReference[]; participants: Participant[]; }>; declare type TrackReferencesObservableOptions = { additionalRoomEvents?: RoomEvent[]; onlySubscribed?: boolean; }; export declare type TrackSource = RequireAtLeastOne<{ source: T; name: string; participant: Participant; }, 'name' | 'source'>; export declare type TrackSourceWithOptions = { source: Track.Source; withPlaceholder: boolean; }; export declare function trackSyncTimeObserver(track: Track): Observable; export declare function trackTranscriptionObserver(publication: TrackPublication): Observable<[transcription: TranscriptionSegment[]]>; declare type UpdatableItem = TrackReferenceOrPlaceholder | number; /** Divide the list of elements into pages and and check if pages need updating. */ export declare function updatePages(currentList: T[], nextList: T[], maxItemsOnPage: number): T[]; export declare type VideoSource = Track.Source.Camera | Track.Source.ScreenShare; export declare function wasClickOutside(insideElement: HTMLElement, event: MouseEvent): boolean; export declare const WIDGET_DEFAULT_STATE: WidgetState; /** @public */ export declare type WidgetState = { showChat: boolean; unreadMessages: number; showSettings?: boolean; }; export { }