Skip to content

Commit 146272c

Browse files
authored
Include useKrispNoiseFilter in generated docs, + related improvements (#1055)
1 parent 2073a8a commit 146272c

File tree

12 files changed

+245
-71
lines changed

12 files changed

+245
-71
lines changed

.changeset/brown-taxis-appear.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@livekit/components-core": patch
3+
"@livekit/components-react": patch
4+
"@livekit/api-documenter": patch
5+
---
6+
7+
Include useKrispNoiseFilter in generated docs

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export type GridLayoutInfo = {
221221
export function isEqualTrackRef(a?: TrackReferenceOrPlaceholder, b?: TrackReferenceOrPlaceholder): boolean;
222222

223223
// @public (undocumented)
224-
export function isLocal(p: Participant): p is LocalParticipant;
224+
export function isLocal(p: Participant): boolean;
225225

226226
// @public
227227
export function isMobileBrowser(): boolean;
@@ -235,7 +235,7 @@ export function isParticipantTrackReferencePinned(trackRef: TrackReference, pinS
235235
export function isPlaceholderReplacement(currentTrackRef: TrackReferenceOrPlaceholder, nextTrackRef: TrackReferenceOrPlaceholder): boolean;
236236

237237
// @public (undocumented)
238-
export function isRemote(p: Participant): p is RemoteParticipant;
238+
export function isRemote(p: Participant): boolean;
239239

240240
// @public (undocumented)
241241
export function isSourcesWithOptions(sources: SourcesArray): sources is TrackSourceWithOptions[];

packages/core/tsdoc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3+
"extends": [ "../../tsdoc.json" ]
4+
}

packages/react/api-extractor.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
* DEFAULT VALUE: ""
1717
*/
1818
"extends": "../../api-extractor-shared.json",
19-
"mainEntryPointFilePath": "./dist/index.d.ts"
19+
"mainEntryPointFilePath": "./dist/index.docs.d.ts"
2020
}

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

+39-22
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import { CreateLocalTracksOptions } from 'livekit-client';
1313
import { DataPublishOptions } from 'livekit-client';
1414
import { DisconnectReason } from 'livekit-client';
1515
import { HTMLAttributes } from 'react';
16+
import { KrispNoiseFilterProcessor } from '@livekit/krisp-noise-filter';
1617
import { LocalAudioTrack } from 'livekit-client';
1718
import { LocalParticipant } from 'livekit-client';
1819
import { LocalTrack } from 'livekit-client';
1920
import { LocalTrackPublication } from 'livekit-client';
2021
import { LocalVideoTrack } from 'livekit-client';
2122
import { MediaDeviceFailure } from 'livekit-client';
23+
import { NoiseFilterOptions } from '@livekit/krisp-noise-filter';
2224
import { Participant } from 'livekit-client';
2325
import { ParticipantEvent } from 'livekit-client';
2426
import type { ParticipantKind } from 'livekit-client';
@@ -162,7 +164,7 @@ export const ChatIcon: (props: SVGProps<SVGSVGElement>) => React_2.JSX.Element;
162164

163165
export { ChatMessage }
164166

165-
// Warning: (ae-forgotten-export) The symbol "ChatOptions" needs to be exported by the entry point index.d.ts
167+
// Warning: (ae-forgotten-export) The symbol "ChatOptions" needs to be exported by the entry point index.docs.d.ts
166168
//
167169
// @public (undocumented)
168170
export interface ChatProps extends React_2.HTMLAttributes<HTMLDivElement>, ChatOptions {
@@ -445,12 +447,12 @@ export interface MediaDeviceSelectProps extends Omit<React_2.HTMLAttributes<HTML
445447
track?: LocalAudioTrack | LocalVideoTrack;
446448
}
447449

448-
// Warning: (ae-forgotten-export) The symbol "LegacyReceivedChatMessage" needs to be exported by the entry point index.d.ts
450+
// Warning: (ae-forgotten-export) The symbol "LegacyReceivedChatMessage" needs to be exported by the entry point index.docs.d.ts
449451
//
450452
// @public @deprecated (undocumented)
451453
export type MessageDecoder = (message: Uint8Array) => LegacyReceivedChatMessage;
452454

453-
// Warning: (ae-forgotten-export) The symbol "LegacyChatMessage" needs to be exported by the entry point index.d.ts
455+
// Warning: (ae-forgotten-export) The symbol "LegacyChatMessage" needs to be exported by the entry point index.docs.d.ts
454456
//
455457
// @public @deprecated (undocumented)
456458
export type MessageEncoder = (message: LegacyChatMessage) => Uint8Array;
@@ -500,7 +502,7 @@ export function ParticipantContextIfNeeded(props: React_2.PropsWithChildren<{
500502
participant?: Participant;
501503
}>): React_2.JSX.Element;
502504

503-
// Warning: (ae-forgotten-export) The symbol "RequireAtLeastOne" needs to be exported by the entry point index.d.ts
505+
// Warning: (ae-forgotten-export) The symbol "RequireAtLeastOne" needs to be exported by the entry point index.docs.d.ts
504506
//
505507
// @beta (undocumented)
506508
export type ParticipantIdentifier = RequireAtLeastOne<{
@@ -629,14 +631,14 @@ export const ScreenShareIcon: (props: SVGProps<SVGSVGElement>) => React_2.JSX.El
629631
// @internal (undocumented)
630632
export const ScreenShareStopIcon: (props: SVGProps<SVGSVGElement>) => React_2.JSX.Element;
631633

632-
// Warning: (ae-forgotten-export) The symbol "LogExtension" needs to be exported by the entry point index.d.ts
633-
// Warning: (ae-forgotten-export) The symbol "SetLogExtensionOptions" needs to be exported by the entry point index.d.ts
634+
// Warning: (ae-forgotten-export) The symbol "LogExtension" needs to be exported by the entry point index.docs.d.ts
635+
// Warning: (ae-forgotten-export) The symbol "SetLogExtensionOptions" needs to be exported by the entry point index.docs.d.ts
634636
//
635637
// @public
636638
export function setLogExtension(extension: LogExtension, options?: SetLogExtensionOptions): void;
637639

638-
// Warning: (ae-forgotten-export) The symbol "LogLevel" needs to be exported by the entry point index.d.ts
639-
// Warning: (ae-forgotten-export) The symbol "SetLogLevelOptions" needs to be exported by the entry point index.d.ts
640+
// Warning: (ae-forgotten-export) The symbol "LogLevel" needs to be exported by the entry point index.docs.d.ts
641+
// Warning: (ae-forgotten-export) The symbol "SetLogLevelOptions" needs to be exported by the entry point index.docs.d.ts
640642
//
641643
// @public
642644
export function setLogLevel(level: LogLevel, options?: SetLogLevelOptions): void;
@@ -692,19 +694,19 @@ export type TrackReference = {
692694
source: Track.Source;
693695
};
694696

695-
// Warning: (ae-forgotten-export) The symbol "TrackReferencePlaceholder" needs to be exported by the entry point index.d.ts
697+
// Warning: (ae-forgotten-export) The symbol "TrackReferencePlaceholder" needs to be exported by the entry point index.docs.d.ts
696698
//
697699
// @public (undocumented)
698700
export type TrackReferenceOrPlaceholder = TrackReference | TrackReferencePlaceholder;
699701

700-
// Warning: (ae-forgotten-export) The symbol "ToggleSource" needs to be exported by the entry point index.d.ts
702+
// Warning: (ae-forgotten-export) The symbol "ToggleSource" needs to be exported by the entry point index.docs.d.ts
701703
//
702704
// @public
703705
export const TrackToggle: <T extends ToggleSource>(props: TrackToggleProps<T> & React_2.RefAttributes<HTMLButtonElement>) => React_2.ReactNode;
704706

705707
// @public (undocumented)
706708
export interface TrackToggleProps<T extends ToggleSource> extends Omit<React_2.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {
707-
// Warning: (ae-forgotten-export) The symbol "CaptureOptionsBySource" needs to be exported by the entry point index.d.ts
709+
// Warning: (ae-forgotten-export) The symbol "CaptureOptionsBySource" needs to be exported by the entry point index.docs.d.ts
708710
//
709711
// (undocumented)
710712
captureOptions?: CaptureOptionsBySource<T>;
@@ -793,8 +795,8 @@ export function useConnectionState(room?: Room): ConnectionState_2;
793795
// @public (undocumented)
794796
export function useCreateLayoutContext(): LayoutContextType;
795797

796-
// Warning: (ae-forgotten-export) The symbol "ReceivedDataMessage" needs to be exported by the entry point index.d.ts
797-
// Warning: (ae-forgotten-export) The symbol "UseDataChannelReturnType" needs to be exported by the entry point index.d.ts
798+
// Warning: (ae-forgotten-export) The symbol "ReceivedDataMessage" needs to be exported by the entry point index.docs.d.ts
799+
// Warning: (ae-forgotten-export) The symbol "UseDataChannelReturnType" needs to be exported by the entry point index.docs.d.ts
798800
//
799801
// @public
800802
export function useDataChannel<T extends string>(topic: T, onMessage?: (msg: ReceivedDataMessage<T>) => void): UseDataChannelReturnType<T>;
@@ -829,7 +831,7 @@ export function useEnsureTrackRef(trackRef?: TrackReferenceOrPlaceholder): Track
829831
// @alpha
830832
export function useFacingMode(trackReference: TrackReferenceOrPlaceholder): 'user' | 'environment' | 'left' | 'right' | 'undefined';
831833

832-
// Warning: (ae-forgotten-export) The symbol "FeatureContext" needs to be exported by the entry point index.d.ts
834+
// Warning: (ae-forgotten-export) The symbol "FeatureContext" needs to be exported by the entry point index.docs.d.ts
833835
// Warning: (ae-internal-missing-underscore) The name "useFeatureContext" should be prefixed with an underscore because the declaration is marked as @internal
834836
//
835837
// @internal (undocumented)
@@ -887,6 +889,21 @@ export function useIsRecording(room?: Room): boolean;
887889
// @public
888890
export function useIsSpeaking(participant?: Participant): boolean;
889891

892+
// @beta
893+
export function useKrispNoiseFilter(options?: useKrispNoiseFilterOptions): {
894+
setNoiseFilterEnabled: (enable: boolean) => Promise<void>;
895+
isNoiseFilterEnabled: boolean;
896+
isNoiseFilterPending: boolean;
897+
processor: KrispNoiseFilterProcessor | undefined;
898+
};
899+
900+
// @beta (undocumented)
901+
export interface useKrispNoiseFilterOptions {
902+
// @internal (undocumented)
903+
filterOptions?: NoiseFilterOptions;
904+
trackRef?: TrackReferenceOrPlaceholder;
905+
}
906+
890907
// @public
891908
export function useLayoutContext(): LayoutContextType;
892909

@@ -1183,20 +1200,20 @@ export interface UseTokenOptions {
11831200
// @public
11841201
export function useTrackByName(name: string, participant?: Participant): TrackReferenceOrPlaceholder;
11851202

1186-
// Warning: (ae-forgotten-export) The symbol "TrackMutedIndicatorReturnType" needs to be exported by the entry point index.d.ts
1203+
// Warning: (ae-forgotten-export) The symbol "TrackMutedIndicatorReturnType" needs to be exported by the entry point index.docs.d.ts
11871204
//
11881205
// @public
11891206
export function useTrackMutedIndicator(trackRef?: TrackReferenceOrPlaceholder): TrackMutedIndicatorReturnType;
11901207

11911208
// @public
11921209
export function useTrackRefContext(): TrackReferenceOrPlaceholder;
11931210

1194-
// Warning: (ae-forgotten-export) The symbol "SourcesArray" needs to be exported by the entry point index.d.ts
1211+
// Warning: (ae-forgotten-export) The symbol "SourcesArray" needs to be exported by the entry point index.docs.d.ts
11951212
//
11961213
// @public
11971214
export function useTracks<T extends SourcesArray = Track.Source[]>(sources?: T, options?: UseTracksOptions): UseTracksHookReturnType<T>;
11981215

1199-
// Warning: (ae-forgotten-export) The symbol "TrackSourceWithOptions" needs to be exported by the entry point index.d.ts
1216+
// Warning: (ae-forgotten-export) The symbol "TrackSourceWithOptions" needs to be exported by the entry point index.docs.d.ts
12001217
//
12011218
// @public (undocumented)
12021219
export type UseTracksHookReturnType<T> = T extends Track.Source[] ? TrackReference[] : T extends TrackSourceWithOptions[] ? TrackReferenceOrPlaceholder[] : never;
@@ -1316,11 +1333,11 @@ export type WidgetState = {
13161333

13171334
// Warnings were encountered during analysis:
13181335
//
1319-
// src/context/layout-context.ts:10:3 - (ae-forgotten-export) The symbol "PinContextType" needs to be exported by the entry point index.d.ts
1320-
// src/context/layout-context.ts:11:3 - (ae-forgotten-export) The symbol "WidgetContextType" needs to be exported by the entry point index.d.ts
1321-
// src/hooks/useGridLayout.ts:27:6 - (ae-forgotten-export) The symbol "GridLayoutInfo" needs to be exported by the entry point index.d.ts
1322-
// src/hooks/useMediaDeviceSelect.ts:47:29 - (ae-forgotten-export) The symbol "SetMediaDeviceOptions" needs to be exported by the entry point index.d.ts
1323-
// src/hooks/useTrackTranscription.ts:43:38 - (ae-forgotten-export) The symbol "ReceivedTranscriptionSegment" needs to be exported by the entry point index.d.ts
1336+
// 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
1337+
// 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
1338+
// src/hooks/useGridLayout.ts:27:6 - (ae-forgotten-export) The symbol "GridLayoutInfo" needs to be exported by the entry point index.docs.d.ts
1339+
// src/hooks/useMediaDeviceSelect.ts:47:29 - (ae-forgotten-export) The symbol "SetMediaDeviceOptions" needs to be exported by the entry point index.docs.d.ts
1340+
// src/hooks/useTrackTranscription.ts:43:38 - (ae-forgotten-export) The symbol "ReceivedTranscriptionSegment" needs to be exported by the entry point index.docs.d.ts
13241341

13251342
// (No @packageDocumentation comment for this package)
13261343

packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts

+19-14
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@ import type { TrackReferenceOrPlaceholder } from '@livekit/components-core';
66
import { useLocalParticipant } from '../../..';
77

88
/**
9-
* @alpha
9+
* @beta
1010
*/
1111
export interface useKrispNoiseFilterOptions {
1212
/**
13-
* by default the hook will use the localParticipant's microphone track publication.
14-
* You can override this behavior by passing in a target TrackReference here
13+
* The track reference to use for the noise filter (defaults: local microphone track)
1514
*/
1615
trackRef?: TrackReferenceOrPlaceholder;
16+
/**
17+
* @internal
18+
*/
1719
filterOptions?: NoiseFilterOptions;
1820
}
1921

2022
/**
21-
* This hook is a convenience helper for enabling Krisp Enhanced Audio Noise Cancellation on LiveKit audio tracks.
22-
* It returns a `setNoiseFilterEnabled` method to conveniently toggle between enabled and disabled states.
23+
* Enable the Krisp enhanced noise cancellation feature for local audio tracks.
24+
*
25+
* Defaults to the localParticipant's microphone track publication, but you can override this behavior by passing in a different track reference.
2326
*
24-
* @remarks Krisp noise filter is a feature that's only supported on LiveKit cloud plans
25-
* @alpha
27+
* @package \@livekit/components-react/krisp
28+
* @remarks This filter requires that you install the `@livekit/krisp-noise-filter` package and is supported only on {@link https://cloud.livekit.io | LiveKit Cloud}.
29+
* @beta
2630
* @example
2731
* ```tsx
28-
* const krisp = useKrispNoiseFilter();
29-
* return <input
30-
type="checkbox"
31-
onChange={(ev) => krisp.setNoiseFilterEnabled(ev.target.checked)}
32-
checked={krisp.isNoiseFilterEnabled}
33-
disabled={krisp.isNoiseFilterPending}
34-
/>
32+
* const krisp = useKrispNoiseFilter();
33+
* return <input
34+
* type="checkbox"
35+
* onChange={(ev) => krisp.setNoiseFilterEnabled(ev.target.checked)}
36+
* checked={krisp.isNoiseFilterEnabled}
37+
* disabled={krisp.isNoiseFilterPending}
38+
* />
3539
* ```
40+
* @returns Use `setIsNoiseFilterEnabled` to enable/disable the noise filter.
3641
*/
3742
export function useKrispNoiseFilter(options: useKrispNoiseFilterOptions = {}) {
3843
const [shouldEnable, setShouldEnable] = React.useState(false);

packages/react/src/hooks/useIsMuted.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ export interface UseIsMutedOptions {
1616
* The `useIsMuted` hook is used to implement the `TrackMutedIndicator` or your custom implementation of it.
1717
* It returns a `boolean` that indicates if the track is muted or not.
1818
*
19-
* @example
19+
* @example With a track reference
2020
* ```tsx
2121
* const isMuted = useIsMuted(track);
2222
* ```
23+
*
24+
* @example With a track source / participant
25+
* ```tsx
26+
* const isMuted = useIsMuted('camera', { participant });
27+
* ```
28+
*
29+
* @param sourceOrTrackRef - Either a `TrackReference` or a `Track.Source` (see usage examples)
30+
* @param options - Additional options when using a `Track.Source`
31+
* @returns boolean indicating if the track is muted
32+
*
2333
* @public
2434
*/
2535
export function useIsMuted(trackRef: TrackReferenceOrPlaceholder): boolean;

packages/react/src/index.docs.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Used to merge the exports from the main index.ts file with the exports from the cloud/krisp/useKrispNoiseFilter.ts file for docs generation.
3+
*/
4+
5+
// Regular exports
6+
export * from './index';
7+
8+
// Cloud/Krisp exports
9+
export {
10+
useKrispNoiseFilter,
11+
type useKrispNoiseFilterOptions,
12+
} from './hooks/cloud/krisp/useKrispNoiseFilter';

packages/react/tsdoc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3+
"extends": [ "../../tsdoc.json" ]
4+
}

0 commit comments

Comments
 (0)