@robinandeer/rtc-session-components 0.1.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 @@
1
+ {"version":3,"sources":["../src/components/AvatarSession.tsx","../src/hooks/useAvatar.ts","../src/hooks/useAvatarSession.ts","../src/components/AvatarVideo.tsx","../src/hooks/useLocalMedia.ts","../src/components/UserVideo.tsx","../src/components/ControlBar.tsx","../src/components/ScreenShareVideo.tsx","../src/api/consume.ts"],"names":["ConnectionState","createContext","useRef","jsxs","LiveKitRoom","jsx","RoomAudioRenderer","useRoomContext","useConnectionState","useCallback","useContext","useRemoteParticipants","useState","useEffect","ParticipantEvent","useTracks","Track","isTrackReference","Fragment","VideoTrack","useLocalParticipant","useMediaDevices","TrackToggle"],"mappings":";;;;;;;;AAwCA,SAAS,mBAAmB,eAAA,EAAgD;AAC1E,EAAA,QAAQ,eAAA;AAAiB,IACvB,KAAKA,6BAAA,CAAgB,UAAA;AACnB,MAAA,OAAO,YAAA;AAAA,IACT,KAAKA,6BAAA,CAAgB,SAAA;AACnB,MAAA,OAAO,QAAA;AAAA,IACT,KAAKA,6BAAA,CAAgB,YAAA;AACnB,MAAA,OAAO,YAAA;AAAA,IACT,KAAKA,6BAAA,CAAgB,YAAA;AACnB,MAAA,OAAO,OAAA;AAAA,IACT;AACE,MAAA,OAAO,OAAA;AAAA;AAEb;AAEA,IAAM,oBAAA,GAAuBC,oBAAgD,IAAI,CAAA;AAQ1E,SAAS,aAAA,CAAc;AAAA,EAC5B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA,GAAQ,IAAA;AAAA,EACR,KAAA,GAAQ,IAAA;AAAA,EACR,KAAA;AAAA,EACA;AACF,CAAA,EAAuB;AACrB,EAAA,MAAM,QAAA,GAAWC,aAAqB,IAAI,CAAA;AAE1C,EAAA,MAAM,WAAA,GAAc,CAAC,KAAA,KAAiB;AACpC,IAAA,QAAA,CAAS,OAAA,GAAU,KAA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cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,IAAA,MAAM,SAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,SAAS,MAAM,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,CAAA;AAAA,EAC9E;AAEA,EAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AAEjC,EAAA,OAAO;AAAA,IACL,SAAA;AAAA,IACA,YAAY,IAAA,CAAK,GAAA;AAAA,IACjB,OAAO,IAAA,CAAK,KAAA;AAAA,IACZ,UAAU,IAAA,CAAK;AAAA,GACjB;AACF","file":"index.cjs","sourcesContent":["'use client';\n\n/**\n * AvatarSession Component\n *\n * Provides the session context for avatar interactions.\n * Wraps LiveKit's LiveKitRoom internally while exposing a clean API.\n *\n * @example\n * ```tsx\n * <AvatarSession credentials={credentials} onEnd={handleEnd}>\n * <AvatarVideo />\n * <ControlBar />\n * </AvatarSession>\n * ```\n */\n\nimport {\n createContext,\n useContext,\n useCallback,\n useRef,\n type ReactNode,\n} from 'react';\nimport {\n LiveKitRoom,\n useConnectionState,\n useRoomContext,\n RoomAudioRenderer,\n} from '@livekit/components-react';\nimport { ConnectionState } from 'livekit-client';\nimport type {\n SessionState,\n AvatarSessionContextValue,\n AvatarSessionProps,\n} from '../types';\n\n/**\n * Maps LiveKit connection state to our session state\n */\nfunction mapConnectionState(connectionState: ConnectionState): SessionState {\n switch (connectionState) {\n case ConnectionState.Connecting:\n return 'connecting';\n case ConnectionState.Connected:\n return 'active';\n case ConnectionState.Reconnecting:\n return 'connecting';\n case ConnectionState.Disconnected:\n return 'ended';\n default:\n return 'ended';\n }\n}\n\nconst AvatarSessionContext = createContext<AvatarSessionContextValue | null>(null);\n\n/**\n * AvatarSession component - the main entry point for avatar sessions\n *\n * Renders children within a LiveKit room context and provides session state.\n * This is a headless component that renders minimal DOM.\n */\nexport function AvatarSession({\n credentials,\n children,\n audio = true,\n video = true,\n onEnd,\n onError,\n}: AvatarSessionProps) {\n const errorRef = useRef<Error | null>(null);\n\n const handleError = (error: Error) => {\n errorRef.current = error;\n onError?.(error);\n };\n\n return (\n <LiveKitRoom\n serverUrl={credentials.livekitUrl}\n token={credentials.token}\n connect={true}\n audio={audio}\n video={video}\n onDisconnected={() => onEnd?.()}\n onError={handleError}\n options={{\n adaptiveStream: true,\n dynacast: true,\n }}\n >\n <AvatarSessionContextInner\n sessionId={credentials.sessionId}\n onEnd={onEnd}\n errorRef={errorRef}\n >\n {children}\n </AvatarSessionContextInner>\n <RoomAudioRenderer />\n </LiveKitRoom>\n );\n}\n\n/**\n * Inner context provider that has access to LiveKit room context\n */\nfunction AvatarSessionContextInner({\n sessionId,\n onEnd,\n errorRef,\n children,\n}: {\n sessionId: string;\n onEnd?: () => void;\n errorRef: React.RefObject<Error | null>;\n children: ReactNode;\n}) {\n const room = useRoomContext();\n const connectionState = useConnectionState();\n const onEndRef = useRef(onEnd);\n onEndRef.current = onEnd;\n\n const end = useCallback(async () => {\n try {\n // Send END_CALL message to the avatar\n const encoder = new TextEncoder();\n const data = encoder.encode(JSON.stringify({ type: 'END_CALL' }));\n await room.localParticipant.publishData(data, { reliable: true });\n } catch {\n // Ignore errors when sending end message\n }\n\n await room.disconnect();\n onEndRef.current?.();\n }, [room]);\n\n const contextValue: AvatarSessionContextValue = {\n state: mapConnectionState(connectionState),\n sessionId,\n error: errorRef.current,\n end,\n };\n\n return (\n <AvatarSessionContext.Provider value={contextValue}>\n {children}\n </AvatarSessionContext.Provider>\n );\n}\n\n/**\n * Hook to access the avatar session context\n * Must be used within an AvatarSession component\n */\nexport function useAvatarSessionContext(): AvatarSessionContextValue {\n const context = useContext(AvatarSessionContext);\n if (!context) {\n throw new Error('useAvatarSessionContext must be used within an AvatarSession');\n }\n return context;\n}\n\n/**\n * Hook to optionally access the avatar session context\n * Returns null if not within an AvatarSession\n */\nexport function useMaybeAvatarSessionContext(): AvatarSessionContextValue | null {\n return useContext(AvatarSessionContext);\n}\n","'use client';\n\n/**\n * useAvatar Hook\n *\n * Provides access to the remote avatar participant's video and audio tracks.\n * Uses LiveKit React hooks internally but exposes a clean API.\n *\n * @example\n * ```tsx\n * function AvatarDisplay() {\n * const { videoTrackRef, isSpeaking, hasVideo } = useAvatar();\n *\n * if (!hasVideo) {\n * return <Placeholder />;\n * }\n *\n * return (\n * <div data-speaking={isSpeaking}>\n * <VideoTrack trackRef={videoTrackRef} />\n * </div>\n * );\n * }\n * ```\n */\n\nimport { useState, useEffect } from 'react';\nimport {\n useRemoteParticipants,\n useTracks,\n isTrackReference,\n type TrackReferenceOrPlaceholder,\n} from '@livekit/components-react';\nimport {\n Track,\n ParticipantEvent,\n} from 'livekit-client';\nimport type { UseAvatarReturn } from '../types';\n\n/**\n * Hook to access the remote avatar participant's tracks and state\n *\n * @returns Avatar participant info, track references, and speaking state\n */\nexport function useAvatar(): UseAvatarReturn {\n const remoteParticipants = useRemoteParticipants();\n const avatarParticipant = remoteParticipants[0] ?? null;\n const avatarIdentity = avatarParticipant?.identity ?? null;\n\n const [isSpeaking, setIsSpeaking] = useState(false);\n\n useEffect(() => {\n if (!avatarParticipant) {\n setIsSpeaking(false);\n return;\n }\n\n setIsSpeaking(avatarParticipant.isSpeaking);\n\n const handleIsSpeakingChanged = (speaking: boolean) => {\n setIsSpeaking(speaking);\n };\n\n avatarParticipant.on(ParticipantEvent.IsSpeakingChanged, handleIsSpeakingChanged);\n\n return () => {\n avatarParticipant.off(ParticipantEvent.IsSpeakingChanged, handleIsSpeakingChanged);\n };\n }, [avatarParticipant]);\n\n const tracks = useTracks(\n [\n { source: Track.Source.Camera, withPlaceholder: true },\n { source: Track.Source.Microphone, withPlaceholder: true },\n ],\n { onlySubscribed: true }\n );\n\n let videoTrackRef: TrackReferenceOrPlaceholder | null = null;\n let audioTrackRef: TrackReferenceOrPlaceholder | null = null;\n\n for (const trackRef of tracks) {\n if (trackRef.participant.identity !== avatarIdentity) continue;\n\n if (trackRef.source === Track.Source.Camera && !videoTrackRef) {\n videoTrackRef = trackRef;\n } else if (trackRef.source === Track.Source.Microphone && !audioTrackRef) {\n audioTrackRef = trackRef;\n }\n\n if (videoTrackRef && audioTrackRef) break;\n }\n\n const hasVideo = videoTrackRef !== null && isTrackReference(videoTrackRef);\n const hasAudio = audioTrackRef !== null && isTrackReference(audioTrackRef);\n\n return {\n participant: avatarParticipant,\n videoTrackRef,\n audioTrackRef,\n isSpeaking,\n hasVideo,\n hasAudio,\n };\n}\n","'use client';\n\n/**\n * useAvatarSession Hook\n *\n * Provides access to the current avatar session state.\n * Returns a discriminated union based on session state for type-safe UI rendering.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const session = useAvatarSession();\n *\n * if (session.state === 'connecting') {\n * return <Loading />;\n * }\n *\n * if (session.state === 'error') {\n * return <Error message={session.error.message} />;\n * }\n *\n * return <ActiveSession onEnd={session.end} />;\n * }\n * ```\n */\n\nimport { useAvatarSessionContext } from '../components/AvatarSession';\nimport type { AvatarSessionContextValue } from '../types';\n\n/**\n * Discriminated union types for type-safe session state handling\n */\nexport type UseAvatarSessionReturn =\n | { state: 'idle'; sessionId: string; error: null; end: () => Promise<void> }\n | { state: 'connecting'; sessionId: string; error: null; end: () => Promise<void> }\n | { state: 'active'; sessionId: string; error: null; end: () => Promise<void> }\n | { state: 'ending'; sessionId: string; error: null; end: () => Promise<void> }\n | { state: 'ended'; sessionId: string; error: null; end: () => Promise<void> }\n | { state: 'error'; sessionId: string; error: Error; end: () => Promise<void> };\n\n/**\n * Hook to access the current avatar session state\n *\n * @returns Session state as a discriminated union\n */\nexport function useAvatarSession(): UseAvatarSessionReturn {\n const context = useAvatarSessionContext();\n return context as UseAvatarSessionReturn;\n}\n\nexport type { AvatarSessionContextValue };\n","'use client';\n\nimport type { ReactNode, ComponentPropsWithoutRef } from 'react';\nimport { VideoTrack, isTrackReference } from '@livekit/components-react';\nimport { useAvatar } from '../hooks/useAvatar';\nimport { useAvatarSession } from '../hooks/useAvatarSession';\nimport type { UseAvatarReturn } from '../types';\n\nexport interface AvatarVideoState {\n hasVideo: boolean;\n isConnecting: boolean;\n isSpeaking: boolean;\n trackRef: UseAvatarReturn['videoTrackRef'];\n}\n\nexport interface AvatarVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n children?: (state: AvatarVideoState) => ReactNode;\n}\n\nexport function AvatarVideo({ children, ...props }: AvatarVideoProps) {\n const session = useAvatarSession();\n const { videoTrackRef, isSpeaking, hasVideo } = useAvatar();\n\n const isConnecting = session.state === 'connecting';\n\n const state: AvatarVideoState = {\n hasVideo,\n isConnecting,\n isSpeaking,\n trackRef: videoTrackRef,\n };\n\n if (children) {\n return <>{children(state)}</>;\n }\n\n return (\n <div\n {...props}\n data-has-video={hasVideo}\n data-connecting={isConnecting}\n data-speaking={isSpeaking}\n >\n {hasVideo && videoTrackRef && isTrackReference(videoTrackRef) && (\n <VideoTrack trackRef={videoTrackRef} />\n )}\n </div>\n );\n}\n","'use client';\n\nimport { useCallback, useRef, useEffect } from 'react';\nimport { useLocalParticipant, useMediaDevices, useTracks } from '@livekit/components-react';\nimport { Track } from 'livekit-client';\nimport type { UseLocalMediaReturn } from '../types';\n\nexport function useLocalMedia(): UseLocalMediaReturn {\n const { localParticipant } = useLocalParticipant();\n\n const audioDevices = useMediaDevices({ kind: 'audioinput' });\n const videoDevices = useMediaDevices({ kind: 'videoinput' });\n\n const hasMic = audioDevices.length > 0;\n const hasCamera = videoDevices.length > 0;\n\n const isMicEnabled = localParticipant?.isMicrophoneEnabled ?? false;\n const isCameraEnabled = localParticipant?.isCameraEnabled ?? false;\n const isScreenShareEnabled = localParticipant?.isScreenShareEnabled ?? false;\n\n const isMicEnabledRef = useRef(isMicEnabled);\n const isCameraEnabledRef = useRef(isCameraEnabled);\n const isScreenShareEnabledRef = useRef(isScreenShareEnabled);\n\n useEffect(() => {\n isMicEnabledRef.current = isMicEnabled;\n }, [isMicEnabled]);\n\n useEffect(() => {\n isCameraEnabledRef.current = isCameraEnabled;\n }, [isCameraEnabled]);\n\n useEffect(() => {\n isScreenShareEnabledRef.current = isScreenShareEnabled;\n }, [isScreenShareEnabled]);\n\n const toggleMic = useCallback(() => {\n localParticipant?.setMicrophoneEnabled(!isMicEnabledRef.current);\n }, [localParticipant]);\n\n const toggleCamera = useCallback(() => {\n localParticipant?.setCameraEnabled(!isCameraEnabledRef.current);\n }, [localParticipant]);\n\n const toggleScreenShare = useCallback(() => {\n localParticipant?.setScreenShareEnabled(!isScreenShareEnabledRef.current);\n }, [localParticipant]);\n\n const tracks = useTracks([{ source: Track.Source.Camera, withPlaceholder: true }], {\n onlySubscribed: false,\n });\n\n const localIdentity = localParticipant?.identity;\n\n const localVideoTrackRef =\n tracks.find(\n (trackRef) =>\n trackRef.participant.identity === localIdentity && trackRef.source === Track.Source.Camera\n ) ?? null;\n\n return {\n hasMic,\n hasCamera,\n isMicEnabled,\n isCameraEnabled,\n isScreenShareEnabled,\n toggleMic,\n toggleCamera,\n toggleScreenShare,\n localVideoTrackRef,\n };\n}\n","'use client';\n\nimport type { ReactNode, ComponentPropsWithoutRef } from 'react';\nimport { VideoTrack, isTrackReference } from '@livekit/components-react';\nimport { useLocalMedia } from '../hooks/useLocalMedia';\nimport type { UseLocalMediaReturn } from '../types';\n\nexport interface UserVideoState {\n hasVideo: boolean;\n isCameraEnabled: boolean;\n trackRef: UseLocalMediaReturn['localVideoTrackRef'];\n}\n\nexport interface UserVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n mirror?: boolean;\n children?: (state: UserVideoState) => ReactNode;\n}\n\nexport function UserVideo({ children, mirror = true, ...props }: UserVideoProps) {\n const { localVideoTrackRef, isCameraEnabled } = useLocalMedia();\n\n const hasVideo = localVideoTrackRef !== null && isTrackReference(localVideoTrackRef);\n\n const state: UserVideoState = {\n hasVideo,\n isCameraEnabled,\n trackRef: localVideoTrackRef,\n };\n\n if (children) {\n return <>{children(state)}</>;\n }\n\n return (\n <div\n {...props}\n data-has-video={hasVideo}\n data-camera-enabled={isCameraEnabled}\n data-mirror={mirror}\n >\n {hasVideo && localVideoTrackRef && isTrackReference(localVideoTrackRef) && (\n <VideoTrack trackRef={localVideoTrackRef} />\n )}\n </div>\n );\n}\n","'use client';\n\nimport type { ReactNode, ComponentPropsWithoutRef } from 'react';\nimport { TrackToggle } from '@livekit/components-react';\nimport { Track } from 'livekit-client';\nimport { useLocalMedia } from '../hooks/useLocalMedia';\nimport { useAvatarSession } from '../hooks/useAvatarSession';\n\nexport interface ControlBarState {\n isMicEnabled: boolean;\n isCameraEnabled: boolean;\n toggleMic: () => void;\n toggleCamera: () => void;\n endCall: () => Promise<void>;\n isActive: boolean;\n}\n\nexport interface ControlBarProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n showMicrophone?: boolean;\n showCamera?: boolean;\n showScreenShare?: boolean;\n showEndCall?: boolean;\n children?: (state: ControlBarState) => ReactNode;\n}\n\nexport function ControlBar({\n children,\n showMicrophone = true,\n showCamera = true,\n showScreenShare = false,\n showEndCall = true,\n ...props\n}: ControlBarProps) {\n const session = useAvatarSession();\n const { isMicEnabled, isCameraEnabled, toggleMic, toggleCamera } = useLocalMedia();\n\n const isActive = session.state === 'active';\n\n const state: ControlBarState = {\n isMicEnabled,\n isCameraEnabled,\n toggleMic,\n toggleCamera,\n endCall: session.end,\n isActive,\n };\n\n if (children) {\n return <>{children(state)}</>;\n }\n\n if (!isActive) {\n return null;\n }\n\n return (\n <div {...props} data-active={isActive}>\n {showMicrophone && (\n <button\n type=\"button\"\n onClick={toggleMic}\n data-control=\"microphone\"\n data-enabled={isMicEnabled}\n aria-label={isMicEnabled ? 'Mute microphone' : 'Unmute microphone'}\n >\n <MicrophoneIcon />\n </button>\n )}\n {showCamera && (\n <button\n type=\"button\"\n onClick={toggleCamera}\n data-control=\"camera\"\n data-enabled={isCameraEnabled}\n aria-label={isCameraEnabled ? 'Turn off camera' : 'Turn on camera'}\n >\n <CameraIcon />\n </button>\n )}\n {showScreenShare && (\n <TrackToggle source={Track.Source.ScreenShare} showIcon={false} data-control=\"screen-share\">\n <ScreenShareIcon />\n </TrackToggle>\n )}\n {showEndCall && (\n <button type=\"button\" onClick={session.end} data-control=\"end-call\" aria-label=\"End call\">\n <span>Leave</span>\n </button>\n )}\n </div>\n );\n}\n\nfunction MicrophoneIcon() {\n return (\n <svg width=\"20\" height=\"20\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" aria-hidden=\"true\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z\"\n />\n </svg>\n );\n}\n\nfunction CameraIcon() {\n return (\n <svg width=\"20\" height=\"20\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" aria-hidden=\"true\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z\"\n />\n </svg>\n );\n}\n\nfunction ScreenShareIcon() {\n return (\n <svg width=\"20\" height=\"20\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" aria-hidden=\"true\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z\"\n />\n </svg>\n );\n}\n","'use client';\n\nimport type { ReactNode, ComponentPropsWithoutRef } from 'react';\nimport {\n useLocalParticipant,\n useTracks,\n VideoTrack,\n isTrackReference,\n type TrackReferenceOrPlaceholder,\n} from '@livekit/components-react';\nimport { Track } from 'livekit-client';\n\nexport interface ScreenShareVideoState {\n isSharing: boolean;\n trackRef: TrackReferenceOrPlaceholder | null;\n}\n\nexport interface ScreenShareVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n children?: (state: ScreenShareVideoState) => ReactNode;\n}\n\nexport function ScreenShareVideo({ children, ...props }: ScreenShareVideoProps) {\n const { localParticipant } = useLocalParticipant();\n\n const tracks = useTracks(\n [{ source: Track.Source.ScreenShare, withPlaceholder: false }],\n { onlySubscribed: false }\n );\n\n const localIdentity = localParticipant?.identity;\n\n const screenShareTrackRef = tracks.find(\n (trackRef) =>\n trackRef.participant.identity === localIdentity &&\n trackRef.source === Track.Source.ScreenShare\n ) ?? null;\n\n const isSharing = screenShareTrackRef !== null && isTrackReference(screenShareTrackRef);\n\n const state: ScreenShareVideoState = {\n isSharing,\n trackRef: screenShareTrackRef,\n };\n\n if (children) {\n return <>{children(state)}</>;\n }\n\n if (!isSharing) {\n return null;\n }\n\n return (\n <div {...props} data-sharing={isSharing}>\n {screenShareTrackRef && isTrackReference(screenShareTrackRef) && (\n <VideoTrack trackRef={screenShareTrackRef} />\n )}\n </div>\n );\n}\n","/**\n * Runway API - Consume Session\n *\n * Client for the Runway /consume endpoint.\n * Retrieves LiveKit credentials for an existing session.\n *\n * @example\n * ```tsx\n * const credentials = await consumeSession({\n * sessionId: 'sess_abc123',\n * });\n *\n * // Use credentials with AvatarSession\n * <AvatarSession credentials={credentials}>\n * ...\n * </AvatarSession>\n * ```\n */\n\nimport type { SessionCredentials, ConsumeSessionOptions } from '../types';\n\nconst DEFAULT_BASE_URL = 'https://api.runwayml.com/v1';\n\n/**\n * Consume a session to get LiveKit credentials\n *\n * This calls the Runway API's /consume endpoint to retrieve\n * the LiveKit connection details for an existing session.\n *\n * @param options - Session ID and optional base URL\n * @returns SessionCredentials for connecting to the avatar\n */\nexport async function consumeSession(\n options: ConsumeSessionOptions\n): Promise<SessionCredentials> {\n const { sessionId, baseUrl = DEFAULT_BASE_URL } = options;\n\n const response = await fetch(`${baseUrl}/realtime/sessions/${sessionId}/consume`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to consume session: ${response.status} ${errorText}`);\n }\n\n const data = await response.json();\n\n return {\n sessionId,\n livekitUrl: data.url,\n token: data.token,\n roomName: data.roomName,\n };\n}\n"]}
@@ -0,0 +1,257 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _livekit_components_react from '@livekit/components-react';
3
+ import { TrackReferenceOrPlaceholder } from '@livekit/components-react';
4
+ export { RoomAudioRenderer as AudioRenderer } from '@livekit/components-react';
5
+ import * as livekit_client from 'livekit-client';
6
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
7
+
8
+ /**
9
+ * @runwayml/avatars-react Types
10
+ *
11
+ * Shared types for the avatar session library.
12
+ */
13
+ /**
14
+ * Client-side session states for UI rendering
15
+ */
16
+ type SessionState = 'idle' | 'connecting' | 'active' | 'ending' | 'ended' | 'error';
17
+ /**
18
+ * Connection credentials returned from the Runway API
19
+ * Used to connect to the LiveKit room for the avatar session
20
+ */
21
+ interface SessionCredentials {
22
+ /** Unique session identifier */
23
+ sessionId: string;
24
+ /** LiveKit server URL */
25
+ livekitUrl: string;
26
+ /** Authentication token for the LiveKit room */
27
+ token: string;
28
+ /** Name of the LiveKit room */
29
+ roomName: string;
30
+ }
31
+ /**
32
+ * Options for consuming a session from the Runway API
33
+ */
34
+ interface ConsumeSessionOptions {
35
+ /** The session ID to consume */
36
+ sessionId: string;
37
+ /** Optional base URL for the Runway API (defaults to production) */
38
+ baseUrl?: string;
39
+ }
40
+ /**
41
+ * Avatar session context value exposed to consumers
42
+ */
43
+ interface AvatarSessionContextValue {
44
+ /** Current session state */
45
+ state: SessionState;
46
+ /** Session identifier */
47
+ sessionId: string;
48
+ /** Current error, if any */
49
+ error: Error | null;
50
+ /** End the current session */
51
+ end: () => Promise<void>;
52
+ }
53
+ /**
54
+ * Props for the AvatarSession component
55
+ */
56
+ interface AvatarSessionProps {
57
+ /** Connection credentials from Runway API */
58
+ credentials: SessionCredentials;
59
+ /** Children to render inside the session */
60
+ children: React.ReactNode;
61
+ /** Enable audio on connect (default: true) */
62
+ audio?: boolean;
63
+ /** Enable video on connect (default: true) */
64
+ video?: boolean;
65
+ /** Callback when session ends */
66
+ onEnd?: () => void;
67
+ /** Callback when an error occurs */
68
+ onError?: (error: Error) => void;
69
+ }
70
+ /**
71
+ * Return type for useAvatar hook
72
+ */
73
+ interface UseAvatarReturn {
74
+ /** The remote avatar participant */
75
+ participant: livekit_client.RemoteParticipant | null;
76
+ /** The avatar's video track reference (for use with VideoTrack component) */
77
+ videoTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
78
+ /** The avatar's audio track reference */
79
+ audioTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
80
+ /** Whether the avatar is currently speaking */
81
+ isSpeaking: boolean;
82
+ /** Whether the avatar has video */
83
+ hasVideo: boolean;
84
+ /** Whether the avatar has audio */
85
+ hasAudio: boolean;
86
+ }
87
+ /**
88
+ * Return type for useLocalMedia hook
89
+ */
90
+ interface UseLocalMediaReturn {
91
+ /** Whether a microphone device is available */
92
+ hasMic: boolean;
93
+ /** Whether a camera device is available */
94
+ hasCamera: boolean;
95
+ /** Whether the microphone is currently enabled */
96
+ isMicEnabled: boolean;
97
+ /** Whether the camera is currently enabled */
98
+ isCameraEnabled: boolean;
99
+ /** Whether screen sharing is currently enabled */
100
+ isScreenShareEnabled: boolean;
101
+ /** Toggle the microphone on/off */
102
+ toggleMic: () => void;
103
+ /** Toggle the camera on/off */
104
+ toggleCamera: () => void;
105
+ /** Toggle screen sharing on/off */
106
+ toggleScreenShare: () => void;
107
+ /** The local video track reference */
108
+ localVideoTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
109
+ }
110
+
111
+ /**
112
+ * AvatarSession component - the main entry point for avatar sessions
113
+ *
114
+ * Renders children within a LiveKit room context and provides session state.
115
+ * This is a headless component that renders minimal DOM.
116
+ */
117
+ declare function AvatarSession({ credentials, children, audio, video, onEnd, onError, }: AvatarSessionProps): react_jsx_runtime.JSX.Element;
118
+ /**
119
+ * Hook to access the avatar session context
120
+ * Must be used within an AvatarSession component
121
+ */
122
+ declare function useAvatarSessionContext(): AvatarSessionContextValue;
123
+ /**
124
+ * Hook to optionally access the avatar session context
125
+ * Returns null if not within an AvatarSession
126
+ */
127
+ declare function useMaybeAvatarSessionContext(): AvatarSessionContextValue | null;
128
+
129
+ interface AvatarVideoState {
130
+ hasVideo: boolean;
131
+ isConnecting: boolean;
132
+ isSpeaking: boolean;
133
+ trackRef: UseAvatarReturn['videoTrackRef'];
134
+ }
135
+ interface AvatarVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
136
+ children?: (state: AvatarVideoState) => ReactNode;
137
+ }
138
+ declare function AvatarVideo({ children, ...props }: AvatarVideoProps): react_jsx_runtime.JSX.Element;
139
+
140
+ interface UserVideoState {
141
+ hasVideo: boolean;
142
+ isCameraEnabled: boolean;
143
+ trackRef: UseLocalMediaReturn['localVideoTrackRef'];
144
+ }
145
+ interface UserVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
146
+ mirror?: boolean;
147
+ children?: (state: UserVideoState) => ReactNode;
148
+ }
149
+ declare function UserVideo({ children, mirror, ...props }: UserVideoProps): react_jsx_runtime.JSX.Element;
150
+
151
+ interface ControlBarState {
152
+ isMicEnabled: boolean;
153
+ isCameraEnabled: boolean;
154
+ toggleMic: () => void;
155
+ toggleCamera: () => void;
156
+ endCall: () => Promise<void>;
157
+ isActive: boolean;
158
+ }
159
+ interface ControlBarProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
160
+ showMicrophone?: boolean;
161
+ showCamera?: boolean;
162
+ showScreenShare?: boolean;
163
+ showEndCall?: boolean;
164
+ children?: (state: ControlBarState) => ReactNode;
165
+ }
166
+ declare function ControlBar({ children, showMicrophone, showCamera, showScreenShare, showEndCall, ...props }: ControlBarProps): react_jsx_runtime.JSX.Element | null;
167
+
168
+ interface ScreenShareVideoState {
169
+ isSharing: boolean;
170
+ trackRef: TrackReferenceOrPlaceholder | null;
171
+ }
172
+ interface ScreenShareVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
173
+ children?: (state: ScreenShareVideoState) => ReactNode;
174
+ }
175
+ declare function ScreenShareVideo({ children, ...props }: ScreenShareVideoProps): react_jsx_runtime.JSX.Element | null;
176
+
177
+ /**
178
+ * Discriminated union types for type-safe session state handling
179
+ */
180
+ type UseAvatarSessionReturn = {
181
+ state: 'idle';
182
+ sessionId: string;
183
+ error: null;
184
+ end: () => Promise<void>;
185
+ } | {
186
+ state: 'connecting';
187
+ sessionId: string;
188
+ error: null;
189
+ end: () => Promise<void>;
190
+ } | {
191
+ state: 'active';
192
+ sessionId: string;
193
+ error: null;
194
+ end: () => Promise<void>;
195
+ } | {
196
+ state: 'ending';
197
+ sessionId: string;
198
+ error: null;
199
+ end: () => Promise<void>;
200
+ } | {
201
+ state: 'ended';
202
+ sessionId: string;
203
+ error: null;
204
+ end: () => Promise<void>;
205
+ } | {
206
+ state: 'error';
207
+ sessionId: string;
208
+ error: Error;
209
+ end: () => Promise<void>;
210
+ };
211
+ /**
212
+ * Hook to access the current avatar session state
213
+ *
214
+ * @returns Session state as a discriminated union
215
+ */
216
+ declare function useAvatarSession(): UseAvatarSessionReturn;
217
+
218
+ /**
219
+ * Hook to access the remote avatar participant's tracks and state
220
+ *
221
+ * @returns Avatar participant info, track references, and speaking state
222
+ */
223
+ declare function useAvatar(): UseAvatarReturn;
224
+
225
+ declare function useLocalMedia(): UseLocalMediaReturn;
226
+
227
+ /**
228
+ * Runway API - Consume Session
229
+ *
230
+ * Client for the Runway /consume endpoint.
231
+ * Retrieves LiveKit credentials for an existing session.
232
+ *
233
+ * @example
234
+ * ```tsx
235
+ * const credentials = await consumeSession({
236
+ * sessionId: 'sess_abc123',
237
+ * });
238
+ *
239
+ * // Use credentials with AvatarSession
240
+ * <AvatarSession credentials={credentials}>
241
+ * ...
242
+ * </AvatarSession>
243
+ * ```
244
+ */
245
+
246
+ /**
247
+ * Consume a session to get LiveKit credentials
248
+ *
249
+ * This calls the Runway API's /consume endpoint to retrieve
250
+ * the LiveKit connection details for an existing session.
251
+ *
252
+ * @param options - Session ID and optional base URL
253
+ * @returns SessionCredentials for connecting to the avatar
254
+ */
255
+ declare function consumeSession(options: ConsumeSessionOptions): Promise<SessionCredentials>;
256
+
257
+ export { AvatarSession, type AvatarSessionContextValue, type AvatarSessionProps, AvatarVideo, type AvatarVideoProps, type AvatarVideoState, type ConsumeSessionOptions, ControlBar, type ControlBarProps, type ControlBarState, ScreenShareVideo, type ScreenShareVideoProps, type ScreenShareVideoState, type SessionCredentials, type SessionState, type UseAvatarReturn, type UseAvatarSessionReturn, type UseLocalMediaReturn, UserVideo, type UserVideoProps, type UserVideoState, consumeSession, useAvatar, useAvatarSession, useAvatarSessionContext, useLocalMedia, useMaybeAvatarSessionContext };
@@ -0,0 +1,257 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _livekit_components_react from '@livekit/components-react';
3
+ import { TrackReferenceOrPlaceholder } from '@livekit/components-react';
4
+ export { RoomAudioRenderer as AudioRenderer } from '@livekit/components-react';
5
+ import * as livekit_client from 'livekit-client';
6
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
7
+
8
+ /**
9
+ * @runwayml/avatars-react Types
10
+ *
11
+ * Shared types for the avatar session library.
12
+ */
13
+ /**
14
+ * Client-side session states for UI rendering
15
+ */
16
+ type SessionState = 'idle' | 'connecting' | 'active' | 'ending' | 'ended' | 'error';
17
+ /**
18
+ * Connection credentials returned from the Runway API
19
+ * Used to connect to the LiveKit room for the avatar session
20
+ */
21
+ interface SessionCredentials {
22
+ /** Unique session identifier */
23
+ sessionId: string;
24
+ /** LiveKit server URL */
25
+ livekitUrl: string;
26
+ /** Authentication token for the LiveKit room */
27
+ token: string;
28
+ /** Name of the LiveKit room */
29
+ roomName: string;
30
+ }
31
+ /**
32
+ * Options for consuming a session from the Runway API
33
+ */
34
+ interface ConsumeSessionOptions {
35
+ /** The session ID to consume */
36
+ sessionId: string;
37
+ /** Optional base URL for the Runway API (defaults to production) */
38
+ baseUrl?: string;
39
+ }
40
+ /**
41
+ * Avatar session context value exposed to consumers
42
+ */
43
+ interface AvatarSessionContextValue {
44
+ /** Current session state */
45
+ state: SessionState;
46
+ /** Session identifier */
47
+ sessionId: string;
48
+ /** Current error, if any */
49
+ error: Error | null;
50
+ /** End the current session */
51
+ end: () => Promise<void>;
52
+ }
53
+ /**
54
+ * Props for the AvatarSession component
55
+ */
56
+ interface AvatarSessionProps {
57
+ /** Connection credentials from Runway API */
58
+ credentials: SessionCredentials;
59
+ /** Children to render inside the session */
60
+ children: React.ReactNode;
61
+ /** Enable audio on connect (default: true) */
62
+ audio?: boolean;
63
+ /** Enable video on connect (default: true) */
64
+ video?: boolean;
65
+ /** Callback when session ends */
66
+ onEnd?: () => void;
67
+ /** Callback when an error occurs */
68
+ onError?: (error: Error) => void;
69
+ }
70
+ /**
71
+ * Return type for useAvatar hook
72
+ */
73
+ interface UseAvatarReturn {
74
+ /** The remote avatar participant */
75
+ participant: livekit_client.RemoteParticipant | null;
76
+ /** The avatar's video track reference (for use with VideoTrack component) */
77
+ videoTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
78
+ /** The avatar's audio track reference */
79
+ audioTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
80
+ /** Whether the avatar is currently speaking */
81
+ isSpeaking: boolean;
82
+ /** Whether the avatar has video */
83
+ hasVideo: boolean;
84
+ /** Whether the avatar has audio */
85
+ hasAudio: boolean;
86
+ }
87
+ /**
88
+ * Return type for useLocalMedia hook
89
+ */
90
+ interface UseLocalMediaReturn {
91
+ /** Whether a microphone device is available */
92
+ hasMic: boolean;
93
+ /** Whether a camera device is available */
94
+ hasCamera: boolean;
95
+ /** Whether the microphone is currently enabled */
96
+ isMicEnabled: boolean;
97
+ /** Whether the camera is currently enabled */
98
+ isCameraEnabled: boolean;
99
+ /** Whether screen sharing is currently enabled */
100
+ isScreenShareEnabled: boolean;
101
+ /** Toggle the microphone on/off */
102
+ toggleMic: () => void;
103
+ /** Toggle the camera on/off */
104
+ toggleCamera: () => void;
105
+ /** Toggle screen sharing on/off */
106
+ toggleScreenShare: () => void;
107
+ /** The local video track reference */
108
+ localVideoTrackRef: _livekit_components_react.TrackReferenceOrPlaceholder | null;
109
+ }
110
+
111
+ /**
112
+ * AvatarSession component - the main entry point for avatar sessions
113
+ *
114
+ * Renders children within a LiveKit room context and provides session state.
115
+ * This is a headless component that renders minimal DOM.
116
+ */
117
+ declare function AvatarSession({ credentials, children, audio, video, onEnd, onError, }: AvatarSessionProps): react_jsx_runtime.JSX.Element;
118
+ /**
119
+ * Hook to access the avatar session context
120
+ * Must be used within an AvatarSession component
121
+ */
122
+ declare function useAvatarSessionContext(): AvatarSessionContextValue;
123
+ /**
124
+ * Hook to optionally access the avatar session context
125
+ * Returns null if not within an AvatarSession
126
+ */
127
+ declare function useMaybeAvatarSessionContext(): AvatarSessionContextValue | null;
128
+
129
+ interface AvatarVideoState {
130
+ hasVideo: boolean;
131
+ isConnecting: boolean;
132
+ isSpeaking: boolean;
133
+ trackRef: UseAvatarReturn['videoTrackRef'];
134
+ }
135
+ interface AvatarVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
136
+ children?: (state: AvatarVideoState) => ReactNode;
137
+ }
138
+ declare function AvatarVideo({ children, ...props }: AvatarVideoProps): react_jsx_runtime.JSX.Element;
139
+
140
+ interface UserVideoState {
141
+ hasVideo: boolean;
142
+ isCameraEnabled: boolean;
143
+ trackRef: UseLocalMediaReturn['localVideoTrackRef'];
144
+ }
145
+ interface UserVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
146
+ mirror?: boolean;
147
+ children?: (state: UserVideoState) => ReactNode;
148
+ }
149
+ declare function UserVideo({ children, mirror, ...props }: UserVideoProps): react_jsx_runtime.JSX.Element;
150
+
151
+ interface ControlBarState {
152
+ isMicEnabled: boolean;
153
+ isCameraEnabled: boolean;
154
+ toggleMic: () => void;
155
+ toggleCamera: () => void;
156
+ endCall: () => Promise<void>;
157
+ isActive: boolean;
158
+ }
159
+ interface ControlBarProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
160
+ showMicrophone?: boolean;
161
+ showCamera?: boolean;
162
+ showScreenShare?: boolean;
163
+ showEndCall?: boolean;
164
+ children?: (state: ControlBarState) => ReactNode;
165
+ }
166
+ declare function ControlBar({ children, showMicrophone, showCamera, showScreenShare, showEndCall, ...props }: ControlBarProps): react_jsx_runtime.JSX.Element | null;
167
+
168
+ interface ScreenShareVideoState {
169
+ isSharing: boolean;
170
+ trackRef: TrackReferenceOrPlaceholder | null;
171
+ }
172
+ interface ScreenShareVideoProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
173
+ children?: (state: ScreenShareVideoState) => ReactNode;
174
+ }
175
+ declare function ScreenShareVideo({ children, ...props }: ScreenShareVideoProps): react_jsx_runtime.JSX.Element | null;
176
+
177
+ /**
178
+ * Discriminated union types for type-safe session state handling
179
+ */
180
+ type UseAvatarSessionReturn = {
181
+ state: 'idle';
182
+ sessionId: string;
183
+ error: null;
184
+ end: () => Promise<void>;
185
+ } | {
186
+ state: 'connecting';
187
+ sessionId: string;
188
+ error: null;
189
+ end: () => Promise<void>;
190
+ } | {
191
+ state: 'active';
192
+ sessionId: string;
193
+ error: null;
194
+ end: () => Promise<void>;
195
+ } | {
196
+ state: 'ending';
197
+ sessionId: string;
198
+ error: null;
199
+ end: () => Promise<void>;
200
+ } | {
201
+ state: 'ended';
202
+ sessionId: string;
203
+ error: null;
204
+ end: () => Promise<void>;
205
+ } | {
206
+ state: 'error';
207
+ sessionId: string;
208
+ error: Error;
209
+ end: () => Promise<void>;
210
+ };
211
+ /**
212
+ * Hook to access the current avatar session state
213
+ *
214
+ * @returns Session state as a discriminated union
215
+ */
216
+ declare function useAvatarSession(): UseAvatarSessionReturn;
217
+
218
+ /**
219
+ * Hook to access the remote avatar participant's tracks and state
220
+ *
221
+ * @returns Avatar participant info, track references, and speaking state
222
+ */
223
+ declare function useAvatar(): UseAvatarReturn;
224
+
225
+ declare function useLocalMedia(): UseLocalMediaReturn;
226
+
227
+ /**
228
+ * Runway API - Consume Session
229
+ *
230
+ * Client for the Runway /consume endpoint.
231
+ * Retrieves LiveKit credentials for an existing session.
232
+ *
233
+ * @example
234
+ * ```tsx
235
+ * const credentials = await consumeSession({
236
+ * sessionId: 'sess_abc123',
237
+ * });
238
+ *
239
+ * // Use credentials with AvatarSession
240
+ * <AvatarSession credentials={credentials}>
241
+ * ...
242
+ * </AvatarSession>
243
+ * ```
244
+ */
245
+
246
+ /**
247
+ * Consume a session to get LiveKit credentials
248
+ *
249
+ * This calls the Runway API's /consume endpoint to retrieve
250
+ * the LiveKit connection details for an existing session.
251
+ *
252
+ * @param options - Session ID and optional base URL
253
+ * @returns SessionCredentials for connecting to the avatar
254
+ */
255
+ declare function consumeSession(options: ConsumeSessionOptions): Promise<SessionCredentials>;
256
+
257
+ export { AvatarSession, type AvatarSessionContextValue, type AvatarSessionProps, AvatarVideo, type AvatarVideoProps, type AvatarVideoState, type ConsumeSessionOptions, ControlBar, type ControlBarProps, type ControlBarState, ScreenShareVideo, type ScreenShareVideoProps, type ScreenShareVideoState, type SessionCredentials, type SessionState, type UseAvatarReturn, type UseAvatarSessionReturn, type UseLocalMediaReturn, UserVideo, type UserVideoProps, type UserVideoState, consumeSession, useAvatar, useAvatarSession, useAvatarSessionContext, useLocalMedia, useMaybeAvatarSessionContext };