Skip to content

Commit 46cebf3

Browse files
committed
chore: commit latest api-extractor data
1 parent bddfe08 commit 46cebf3

File tree

2 files changed

+82
-124
lines changed

2 files changed

+82
-124
lines changed

packages/react/etc/components-react.api.md

Lines changed: 60 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,71 @@
44
55
```ts
66

7-
import { AudioAnalyserOptions } from 'livekit-client';
8-
import { AudioCaptureOptions } from 'livekit-client';
7+
import type { AudioAnalyserOptions } from 'livekit-client';
8+
import type { AudioCaptureOptions } from 'livekit-client';
99
import { CaptureOptionsBySource } from '@livekit/components-core';
1010
import { ChatMessage } from '@livekit/components-core';
1111
import { ChatOptions } from '@livekit/components-core';
1212
import { ConnectionQuality } from 'livekit-client';
1313
import { ConnectionState as ConnectionState_2 } from 'livekit-client';
14-
import { CreateLocalTracksOptions } from 'livekit-client';
15-
import { DataPublishOptions } from 'livekit-client';
16-
import { default as default_2 } from 'typed-emitter';
17-
import { DisconnectReason } from 'livekit-client';
14+
import type { CreateLocalTracksOptions } from 'livekit-client';
15+
import type { DataPublishOptions } from 'livekit-client';
16+
import type { DisconnectReason } from 'livekit-client';
1817
import { EventMap } from 'typed-emitter';
1918
import { GridLayoutDefinition } from '@livekit/components-core';
20-
import { GridLayoutInfo } from '@livekit/components-core';
21-
import { HTMLAttributes } from 'react';
19+
import type { GridLayoutInfo } from '@livekit/components-core';
20+
import type { HTMLAttributes } from 'react';
2221
import { isTrackReference } from '@livekit/components-core';
23-
import { JWTPayload } from 'jose';
24-
import { KrispNoiseFilterProcessor } from '@livekit/krisp-noise-filter';
22+
import type { KrispNoiseFilterProcessor } from '@livekit/krisp-noise-filter';
2523
import { LocalAudioTrack } from 'livekit-client';
2624
import { LocalParticipant } from 'livekit-client';
27-
import { LocalTrack } from 'livekit-client';
25+
import type { LocalTrack } from 'livekit-client';
2826
import { LocalTrackPublication } from 'livekit-client';
2927
import { LocalUserChoices } from '@livekit/components-core';
3028
import { LocalVideoTrack } from 'livekit-client';
31-
import { MediaDeviceFailure } from 'livekit-client';
29+
import type { MediaDeviceFailure } from 'livekit-client';
3230
import { MessageDecoder } from '@livekit/components-core';
3331
import { MessageEncoder } from '@livekit/components-core';
34-
import { NoiseFilterOptions } from '@livekit/krisp-noise-filter';
32+
import type { NoiseFilterOptions } from '@livekit/krisp-noise-filter';
3533
import { Participant } from 'livekit-client';
3634
import { ParticipantClickEvent } from '@livekit/components-core';
37-
import { ParticipantEvent } from 'livekit-client';
35+
import type { ParticipantEvent } from 'livekit-client';
3836
import { ParticipantIdentifier } from '@livekit/components-core';
39-
import { ParticipantPermission } from '@livekit/protocol';
37+
import type { ParticipantPermission } from '@livekit/protocol';
4038
import { PinState } from '@livekit/components-core';
4139
import * as React_2 from 'react';
4240
import { ReceivedChatMessage } from '@livekit/components-core';
43-
import { ReceivedDataMessage } from '@livekit/components-core';
41+
import type { ReceivedDataMessage } from '@livekit/components-core';
4442
import { ReceivedMessage } from '@livekit/components-core';
4543
import { ReceivedTranscriptionSegment } from '@livekit/components-core';
46-
import { RemoteAudioTrack } from 'livekit-client';
44+
import type { RemoteAudioTrack } from 'livekit-client';
4745
import { RemoteParticipant } from 'livekit-client';
4846
import { Room } from 'livekit-client';
49-
import { RoomConfiguration } from '@livekit/protocol';
5047
import { RoomConnectOptions } from 'livekit-client';
51-
import { RoomEvent } from 'livekit-client';
52-
import { RoomOptions } from 'livekit-client';
53-
import { ScreenShareCaptureOptions } from 'livekit-client';
48+
import type { RoomEvent } from 'livekit-client';
49+
import type { RoomOptions } from 'livekit-client';
50+
import type { ScreenShareCaptureOptions } from 'livekit-client';
5451
import { SendTextOptions } from 'livekit-client';
5552
import { setLogExtension } from '@livekit/components-core';
5653
import { setLogLevel } from '@livekit/components-core';
5754
import { SetMediaDeviceOptions } from '@livekit/components-core';
58-
import { SourcesArray } from '@livekit/components-core';
59-
import { SVGProps } from 'react';
55+
import type { SourcesArray } from '@livekit/components-core';
56+
import type { SVGProps } from 'react';
6057
import { TextStreamData } from '@livekit/components-core';
61-
import { ToggleSource } from '@livekit/components-core';
62-
import { TokenSourceResponse } from '@livekit/protocol';
58+
import type { ToggleSource } from '@livekit/components-core';
59+
import { TokenSourceConfigurable } from 'livekit-client';
60+
import { TokenSourceFetchOptions } from 'livekit-client';
61+
import { TokenSourceFixed } from 'livekit-client';
6362
import { Track } from 'livekit-client';
64-
import { TrackProcessor } from 'livekit-client';
65-
import { TrackPublication } from 'livekit-client';
63+
import type { TrackProcessor } from 'livekit-client';
64+
import type { TrackPublication } from 'livekit-client';
6665
import { TrackPublishOptions } from 'livekit-client';
6766
import { TrackReference } from '@livekit/components-core';
6867
import { TrackReferenceOrPlaceholder } from '@livekit/components-core';
69-
import { TrackSourceWithOptions } from '@livekit/components-core';
70-
import { TranscriptionSegment } from 'livekit-client';
71-
import { VideoCaptureOptions } from 'livekit-client';
68+
import type { TrackSourceWithOptions } from '@livekit/components-core';
69+
import type { TranscriptionSegment } from 'livekit-client';
70+
import TypedEventEmitter from 'typed-emitter';
71+
import type { VideoCaptureOptions } from 'livekit-client';
7272
import { WidgetState } from '@livekit/components-core';
7373

7474
// @public (undocumented)
@@ -169,9 +169,6 @@ export interface BarVisualizerProps extends React_2.HTMLProps<HTMLDivElement> {
169169
trackRef?: TrackReferenceOrPlaceholder;
170170
}
171171

172-
// @public (undocumented)
173-
export type CamelToSnakeCase<Str extends string> = Str extends `${infer First}${infer Rest}` ? `${First extends Capitalize<First> ? '_' : ''}${Lowercase<First>}${CamelToSnakeCase<Rest>}` : Str;
174-
175172
// Warning: (ae-internal-missing-underscore) The name "CameraDisabledIcon" should be prefixed with an underscore because the declaration is marked as @internal
176173
//
177174
// @internal (undocumented)
@@ -312,9 +309,6 @@ export interface DisconnectButtonProps extends React_2.ButtonHTMLAttributes<HTML
312309
stopTracks?: boolean;
313310
}
314311

315-
// @public (undocumented)
316-
export type EndpointOptions = Omit<RequestInit, 'body'>;
317-
318312
// Warning: (ae-internal-missing-underscore) The name "FeatureFlags" should be prefixed with an underscore because the declaration is marked as @internal
319313
//
320314
// @internal (undocumented)
@@ -647,11 +641,6 @@ export interface RoomNameProps extends React_2.HTMLAttributes<HTMLSpanElement> {
647641
childrenPosition?: 'before' | 'after';
648642
}
649643

650-
// @public (undocumented)
651-
export type SandboxTokenServerOptions = {
652-
baseUrl?: string;
653-
};
654-
655644
// Warning: (ae-internal-missing-underscore) The name "ScreenShareIcon" should be prefixed with an underscore because the declaration is marked as @internal
656645
//
657646
// @internal (undocumented)
@@ -677,8 +666,14 @@ export type SessionConnectOptions = {
677666
publishOptions?: TrackPublishOptions;
678667
};
679668
};
669+
roomConnectOptions?: RoomConnectOptions;
680670
};
681671

672+
// Warning: (ae-internal-missing-underscore) The name "SessionContext" should be prefixed with an underscore because the declaration is marked as @internal
673+
//
674+
// @internal (undocumented)
675+
export const SessionContext: React_2.Context<UseSessionReturn | undefined>;
676+
682677
// @public (undocumented)
683678
export enum SessionEvent {
684679
// (undocumented)
@@ -687,6 +682,15 @@ export enum SessionEvent {
687682
MediaDevicesError = "MediaDevicesError"
688683
}
689684

685+
// @public
686+
export function SessionProvider(props: SessionProviderProps): React_2.JSX.Element;
687+
688+
// @public (undocumented)
689+
export type SessionProviderProps = {
690+
session: UseSessionReturn;
691+
children: React_2.ReactNode;
692+
};
693+
690694
export { setLogExtension }
691695

692696
export { setLogLevel }
@@ -712,73 +716,6 @@ export { TextStreamData }
712716
// @public
713717
export function Toast(props: React_2.HTMLAttributes<HTMLDivElement>): React_2.JSX.Element;
714718

715-
// @public (undocumented)
716-
export type TokenSource = TokenSourceFixed | TokenSourceConfigurable;
717-
718-
// @public (undocumented)
719-
export const TokenSource: {
720-
literal(literalOrFn: LiteralOrFn): TokenSourceLiteral;
721-
custom(customFn: CustomFn): TokenSourceCustom;
722-
endpoint(url: string, options?: EndpointOptions): TokenSourceEndpoint;
723-
sandboxTokenServer(sandboxId: string, options: SandboxTokenServerOptions): TokenSourceSandboxTokenServer;
724-
};
725-
726-
// @public (undocumented)
727-
export abstract class TokenSourceConfigurable {
728-
// (undocumented)
729-
abstract fetch(options: TokenSourceOptions): Promise<TokenSourceResponseObject>;
730-
}
731-
732-
// @public (undocumented)
733-
export abstract class TokenSourceFixed {
734-
// (undocumented)
735-
abstract fetch(): Promise<TokenSourceResponseObject>;
736-
}
737-
738-
// @public (undocumented)
739-
export class TokenSourceLiteral extends TokenSourceFixed {
740-
constructor(literalOrFn: LiteralOrFn);
741-
// (undocumented)
742-
fetch(): Promise<TokenSourceResponseObject>;
743-
}
744-
745-
// @public (undocumented)
746-
export type TokenSourceOptions = {
747-
roomName?: string;
748-
participantName?: string;
749-
participantIdentity?: string;
750-
participantMetadata?: string;
751-
participantAttributes?: {
752-
[key: string]: string;
753-
};
754-
agentName?: string;
755-
agentMetadata?: string;
756-
};
757-
758-
// @public (undocumented)
759-
export abstract class TokenSourceRefreshable extends TokenSourceConfigurable {
760-
// (undocumented)
761-
fetch(options: TokenSourceOptions): Promise<TokenSourceResponseObject>;
762-
// Warning: (ae-forgotten-export) The symbol "TokenPayload" needs to be exported by the entry point index.docs.d.ts
763-
//
764-
// (undocumented)
765-
getCachedResponseJwtPayload(): TokenPayload | null;
766-
// (undocumented)
767-
protected isSameAsCachedOptions(options: TokenSourceOptions): boolean;
768-
// (undocumented)
769-
protected shouldUseCachedValue(options: TokenSourceOptions): boolean;
770-
// (undocumented)
771-
protected abstract update(options: TokenSourceOptions): Promise<TokenSourceResponse>;
772-
}
773-
774-
// @public (undocumented)
775-
export type TokenSourceResponseObject = Required<NonNullable<ConstructorParameters<typeof TokenSourceResponse>[0]>>;
776-
777-
// @public (undocumented)
778-
export class TokenSourceSandboxTokenServer extends TokenSourceEndpoint {
779-
constructor(sandboxId: string, options: SandboxTokenServerOptions);
780-
}
781-
782719
// @public
783720
export function TrackLoop({ tracks, ...props }: TrackLoopProps): React_2.JSX.Element;
784721

@@ -847,7 +784,7 @@ export const UnfocusToggleIcon: (props: SVGProps<SVGSVGElement>) => React_2.JSX.
847784
// Warning: (ae-forgotten-export) The symbol "SessionStub" needs to be exported by the entry point index.docs.d.ts
848785
//
849786
// @public
850-
export function useAgent(session: SessionStub): UseAgentReturn;
787+
export function useAgent(session?: SessionStub): UseAgentReturn;
851788

852789
// Warning: (ae-forgotten-export) The symbol "AgentStateCases" needs to be exported by the entry point index.docs.d.ts
853790
// Warning: (ae-forgotten-export) The symbol "AgentActions" needs to be exported by the entry point index.docs.d.ts
@@ -941,12 +878,15 @@ export function useEnsureParticipant(participant?: Participant): Participant;
941878
// @public
942879
export function useEnsureRoom(room?: Room): Room;
943880

881+
// @public
882+
export function useEnsureSession(session?: UseSessionReturn): UseSessionReturn;
883+
944884
// @public
945885
export function useEnsureTrackRef(trackRef?: TrackReferenceOrPlaceholder): TrackReferenceOrPlaceholder;
946886

947887
// @public (undocumented)
948-
export function useEvents<Emitter extends default_2<EventMap>, EmitterEventMap extends (Emitter extends default_2<infer EM> ? EM : never), Event extends Parameters<Emitter["on"]>[0], Callback extends EmitterEventMap[Event]>(instance: Emitter | {
949-
subtle: {
888+
export function useEvents<Emitter extends TypedEventEmitter<EventMap>, EmitterEventMap extends Emitter extends TypedEventEmitter<infer EM> ? EM : never, Event extends Parameters<Emitter['on']>[0], Callback extends EmitterEventMap[Event]>(instance: Emitter | {
889+
internal: {
950890
emitter: Emitter;
951891
};
952892
} | null | undefined, event: Event, handlerFn: Callback | undefined, dependencies?: React.DependencyList): void;
@@ -1065,6 +1005,9 @@ export function useMaybeParticipantContext(): Participant | undefined;
10651005
// @public
10661006
export function useMaybeRoomContext(): Room | undefined;
10671007

1008+
// @public
1009+
export function useMaybeSessionContext(): UseSessionReturn | undefined;
1010+
10681011
// @public
10691012
export function useMaybeTrackRefContext(): TrackReferenceOrPlaceholder | undefined;
10701013

@@ -1176,7 +1119,7 @@ export interface UseParticipantTileProps<T extends HTMLElement> extends React_2.
11761119
// Warning: (ae-forgotten-export) The symbol "UseParticipantTracksOptions" needs to be exported by the entry point index.docs.d.ts
11771120
//
11781121
// @public
1179-
export function useParticipantTracks<TrackSource extends Track.Source>(sources: Array<TrackSource>, optionsOrParticipantIdentity?: UseParticipantTracksOptions | UseParticipantTracksOptions["participantIdentity"]): Array<TrackReference>;
1122+
export function useParticipantTracks<TrackSource extends Track.Source>(sources: Array<TrackSource>, optionsOrParticipantIdentity?: UseParticipantTracksOptions | UseParticipantTracksOptions['participantIdentity']): Array<TrackReference>;
11801123

11811124
// @alpha
11821125
export function usePersistentUserChoices(options?: UsePersistentUserChoicesOptions): {
@@ -1272,8 +1215,11 @@ export function useSession(tokenSource: TokenSourceConfigurable, options?: UseSe
12721215
// @public (undocumented)
12731216
export function useSession(tokenSource: TokenSourceFixed, options?: UseSessionFixedOptions): UseSessionReturn;
12741217

1218+
// @public
1219+
export function useSessionContext(): UseSessionReturn;
1220+
12751221
// @public (undocumented)
1276-
export function useSessionMessages(session: UseSessionReturn): UseSessionMessagesReturn;
1222+
export function useSessionMessages(session?: UseSessionReturn): UseSessionMessagesReturn;
12771223

12781224
// @public (undocumented)
12791225
export type UseSessionMessagesReturn = {
@@ -1351,7 +1297,7 @@ export function useTextStream(topic: string, options?: UseTextStreamOptions): {
13511297
textStreams: TextStreamData[];
13521298
};
13531299

1354-
// @public (undocumented)
1300+
// @beta (undocumented)
13551301
export type UseTextStreamOptions = {
13561302
room?: Room;
13571303
};
@@ -1437,12 +1383,6 @@ export interface UseVisualStableUpdateOptions {
14371383
// @beta
14381384
export function useVoiceAssistant(): VoiceAssistant;
14391385

1440-
// Warning: (ae-forgotten-export) The symbol "ArrayValuesToSnakeCase" needs to be exported by the entry point index.docs.d.ts
1441-
// Warning: (ae-forgotten-export) The symbol "ObjectKeysToSnakeCase" needs to be exported by the entry point index.docs.d.ts
1442-
//
1443-
// @public (undocumented)
1444-
export type ValueToSnakeCase<Value> = Value extends Array<infer Item> ? ArrayValuesToSnakeCase<Item> : Value extends object ? ObjectKeysToSnakeCase<Value> : Value;
1445-
14461386
// @public
14471387
export function VideoConference({ chatMessageFormatter, chatMessageDecoder, chatMessageEncoder, SettingsComponent, ...props }: VideoConferenceProps): React_2.JSX.Element;
14481388

@@ -1507,10 +1447,6 @@ export { WidgetState }
15071447

15081448
// Warnings were encountered during analysis:
15091449
//
1510-
// src/TokenSource.ts:303:3 - (ae-forgotten-export) The symbol "LiteralOrFn" needs to be exported by the entry point index.docs.d.ts
1511-
// src/TokenSource.ts:313:3 - (ae-forgotten-export) The symbol "CustomFn" needs to be exported by the entry point index.docs.d.ts
1512-
// src/TokenSource.ts:313:3 - (ae-forgotten-export) The symbol "TokenSourceCustom" needs to be exported by the entry point index.docs.d.ts
1513-
// src/TokenSource.ts:322:3 - (ae-forgotten-export) The symbol "TokenSourceEndpoint" needs to be exported by the entry point index.docs.d.ts
15141450
// src/context/layout-context.ts:10:3 - (ae-forgotten-export) The symbol "PinContextType" needs to be exported by the entry point index.docs.d.ts
15151451
// src/context/layout-context.ts:11:3 - (ae-forgotten-export) The symbol "WidgetContextType" needs to be exported by the entry point index.docs.d.ts
15161452

packages/react/src/context/room-context.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { Room } from 'livekit-client';
22
import * as React from 'react';
3+
import { useMaybeSessionContext } from './session-context';
4+
import { UseSessionReturn } from '../hooks';
35

46
/** @public */
57
export const RoomContext = React.createContext<Room | undefined>(undefined);
@@ -40,3 +42,23 @@ export function useEnsureRoom(room?: Room) {
4042
}
4143
return r;
4244
}
45+
46+
/**
47+
* Ensures that a room is provided, either via context or explicitly as room / session props of the
48+
* consuming component.
49+
* If no room can be found, an error is thrown.
50+
* @public
51+
*/
52+
export function useEnsureRoomFromProps<P extends { room?: Room; session?: UseSessionReturn }>(
53+
props: P,
54+
): Room {
55+
const sessionContext = useMaybeSessionContext();
56+
const roomContext = useMaybeRoomContext();
57+
const room = props.session?.room ?? props.room ?? sessionContext?.room ?? roomContext;
58+
if (!room) {
59+
throw new Error(
60+
'No room or session provided. Make sure you are inside a Room context, SessionProvider component, or pass the room or session explicitly as props',
61+
);
62+
}
63+
return room;
64+
}

0 commit comments

Comments
 (0)