Skip to content

Commit

Permalink
[FCE-1038] Update types exports (and typedoc) to make yarn docs hap…
Browse files Browse the repository at this point in the history
…py (#247)

## Description

Export all types that are visible to end user, but were not yet exported
Fix typedoc syntax marked as incorrect
Update typedoc config to avoid part of validation for libraries that are
not actively supported

## Motivation and Context

I want to update our documentation, but as part of this process I want
to remove warnings (and also add missing types into docs)

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to
      not work as expected)
  • Loading branch information
mironiasty authored Jan 17, 2025
1 parent 319e04c commit 1138eeb
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ jobs:

- name: Run typecheck 🚓
run: yarn tsc

- name: Run docs generation 📘
run: yarn docs
6 changes: 6 additions & 0 deletions packages/protobufs/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://typedoc.org/schema.json",
"validation": {
"notExported": false
}
}
3 changes: 1 addition & 2 deletions packages/react-client/src/FishjamProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface FishjamProviderProps extends PropsWithChildren {
/**
* Set preferred constraints.
* @param {MediaStreamConstraints} constraints - The media stream constraints as defined by the Web API.
* @external {@link https://udn.realityripple.com/docs/Web/API/MediaStreamConstraints MediaStreamConstraints}
* @see {@link https://udn.realityripple.com/docs/Web/API/MediaStreamConstraints MediaStreamConstraints}
*/
constraints?: Pick<MediaStreamConstraints, "audio" | "video">;
/**
Expand All @@ -49,7 +49,6 @@ export interface FishjamProviderProps extends PropsWithChildren {
/**
* Provides the Fishjam Context
* @category Components
* @param
*/
export function FishjamProvider(props: FishjamProviderProps) {
const fishjamClientRef = useRef(new FishjamClient({ reconnect: props.reconnect }));
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/devices/DeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import EventEmitter from "events";
import type TypedEmitter from "typed-emitter";

import type {
DeviceError,
DeviceManagerStatus,
DevicesStatus,
DeviceState,
Media,
MediaManager,
MediaStatus,
} from "../types/internal";
import type { DeviceType, PersistLastDeviceHandlers, TrackMiddleware } from "../types/public";
import type { DeviceError, DeviceType, PersistLastDeviceHandlers, TrackMiddleware } from "../types/public";
import { parseUserMediaError } from "../utils/errors";
import { createStorageConfig } from "../utils/localStorage";
import { setupOnEndedCallback } from "../utils/track";
Expand Down
3 changes: 2 additions & 1 deletion packages/react-client/src/devices/mediaInitializer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CurrentDevices, DeviceError } from "../types/internal";
import type { CurrentDevices } from "../types/internal";
import type { DeviceError } from "../types/public";
import { NOT_FOUND_ERROR, OVERCONSTRAINED_ERROR, PERMISSION_DENIED, UNHANDLED_ERROR } from "../utils/errors";
import { prepareConstraints } from "./constraints";

Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/hooks/devices/useCamera.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DeviceError } from "../../types/internal";
import type { DeviceItem, TrackMiddleware } from "../../types/public";
import type { DeviceError, DeviceItem, TrackMiddleware } from "../../types/public";
import { useDeviceApi } from "../internal/device/useDeviceApi";
import { useFishjamContext } from "../internal/useFishjamContext";

Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/hooks/devices/useMicrophone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DeviceError } from "../../types/internal";
import type { DeviceItem, TrackMiddleware } from "../../types/public";
import type { DeviceError, DeviceItem, TrackMiddleware } from "../../types/public";
import { useDeviceApi } from "../internal/device/useDeviceApi";
import { useFishjamContext } from "../internal/useFishjamContext";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Component, FishjamClient, GenericMetadata, MessageEvents, Peer } from "@fishjam-cloud/ts-client";
import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";

import type { PeerId } from "../../types/internal";
import type { PeerId } from "../../types/public";

const eventNames = [
"socketClose",
Expand Down
2 changes: 0 additions & 2 deletions packages/react-client/src/hooks/useConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export interface JoinRoomConfig<PeerMetadata extends GenericMetadata = GenericMe
export interface UseConnectionResult {
/**
* Join room and start streaming camera and microphone
*
* @param {JoinRoomConfig}
*/
joinRoom: <PeerMetadata extends GenericMetadata = GenericMetadata>(
config: JoinRoomConfig<PeerMetadata>,
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/hooks/usePeers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import type {
TrackMetadata,
} from "@fishjam-cloud/ts-client";

import type { PeerId } from "../types/internal";
import type { Track } from "../types/public";
import type { PeerId, Track } from "../types/public";
import { useFishjamContext } from "./internal/useFishjamContext";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/hooks/useVAD.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TrackContext, VadStatus } from "@fishjam-cloud/ts-client";
import { useEffect, useMemo, useState } from "react";

import type { PeerId, TrackId } from "../types/internal";
import type { PeerId, TrackId } from "../types/public";
import { useFishjamClientState } from "./internal/useFishjamClientState";
import { useFishjamContext } from "./internal/useFishjamContext";

Expand Down
11 changes: 10 additions & 1 deletion packages/react-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
export { FishjamProvider, type FishjamProviderProps } from "./FishjamProvider";
export { useCamera, type UseCameraResult } from "./hooks/devices/useCamera";
export { useInitializeDevices, type UseInitializeDevicesResult } from "./hooks/devices/useInitializeDevices";
export {
useInitializeDevices,
type UseInitializeDevicesParams,
type UseInitializeDevicesResult,
} from "./hooks/devices/useInitializeDevices";
export { useMicrophone, type UseMicrophoneResult } from "./hooks/devices/useMicrophone";
export { type JoinRoomConfig, useConnection, type UseConnectionResult } from "./hooks/useConnection";
export { type PeerWithTracks, usePeers, type UsePeersResult } from "./hooks/usePeers";
export { useScreenShare, type UseScreenshareResult } from "./hooks/useScreenShare";
export { useUpdatePeerMetadata } from "./hooks/useUpdatePeerMetadata";
export { useVAD } from "./hooks/useVAD";
export type {
BandwidthLimits,
DeviceError,
DeviceItem,
PeerId,
PeerStatus,
PersistLastDeviceHandlers,
SimulcastBandwidthLimits,
StreamConfig,
Track,
TrackId,
TrackMiddleware,
TracksMiddleware,
} from "./types/public";
Expand Down
11 changes: 1 addition & 10 deletions packages/react-client/src/types/internal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type { DeviceType, Track, TrackMiddleware, TracksMiddleware } from "./public";

export type TrackId = string;
export type PeerId = string;
import type { DeviceError, DeviceType, Track, TrackMiddleware, TracksMiddleware } from "./public";

export type DevicesStatus = "OK" | "Error" | "Not requested" | "Requesting";
export type MediaStatus = "OK" | "Error" | "Not requested" | "Requesting";
Expand Down Expand Up @@ -30,12 +27,6 @@ export type DeviceState = {
currentMiddleware: TrackMiddleware | null;
};

export type DeviceError =
| { name: "OverconstrainedError" }
| { name: "NotAllowedError" }
| { name: "NotFoundError" }
| { name: "UNHANDLED_ERROR" };

export type CurrentDevices = { videoinput: MediaDeviceInfo | null; audioinput: MediaDeviceInfo | null };

export interface MediaManager {
Expand Down
11 changes: 10 additions & 1 deletion packages/react-client/src/types/public.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { SimulcastConfig, TrackMetadata, Variant } from "@fishjam-cloud/ts-client";

import type { DeviceError, DeviceManagerStatus, TrackId } from "./internal";
import type { DeviceManagerStatus } from "./internal";

export type TrackId = string;
export type PeerId = string;

export type Track = {
stream: MediaStream | null;
Expand Down Expand Up @@ -57,3 +60,9 @@ export type StreamConfig = { simulcast?: Variant[] | false };
export type BandwidthLimits = { singleStream: number; simulcast: SimulcastBandwidthLimits };

export type DeviceType = "audio" | "video";

export type DeviceError =
| { name: "OverconstrainedError" }
| { name: "NotAllowedError" }
| { name: "NotFoundError" }
| { name: "UNHANDLED_ERROR" };
2 changes: 1 addition & 1 deletion packages/react-client/src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DeviceError } from "../types/internal";
import type { DeviceError } from "../types/public";

export const PERMISSION_DENIED: DeviceError = { name: "NotAllowedError" };
export const OVERCONSTRAINED_ERROR: DeviceError = { name: "OverconstrainedError" };
Expand Down
5 changes: 4 additions & 1 deletion packages/react-client/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"categoryOrder": ["Connection", "Devices", "Screenshare", "Components", "*", "Debugging"],
"sort": ["kind", "alphabetical"],
"kindSortOrder": ["Method", "Function"],
"readme": "none"
"readme": "none",
"validation": {
"notExported": true
}
}
3 changes: 1 addition & 2 deletions packages/ts-client/src/FishjamClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gene
}

/**
* Uses the {@link !WebSocket} connection and {@link !WebRTCEndpoint | WebRTCEndpoint} to join to the room. Registers the callbacks to
* Uses the WebSocket connection and {@link !WebRTCEndpoint | WebRTCEndpoint} to join to the room. Registers the callbacks to
* handle the events emitted by the {@link !WebRTCEndpoint | WebRTCEndpoint}. Make sure that peer metadata is serializable.
*
* @example
Expand Down Expand Up @@ -214,7 +214,6 @@ export class FishjamClient<PeerMetadata = GenericMetadata, ServerMetadata = Gene
*
* @return {Promise<RTCStatsReport>}
*
* @external RTCPeerConnection#getStats()
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
*/
public async getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport> {
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
MessageEvents,
Metadata,
Peer,
TrackContextEvents,
TrackMetadata,
} from './types';
export type {
Expand All @@ -21,7 +22,6 @@ export type {
SimulcastConfig,
TrackBandwidthLimit,
TrackContext,
TrackContextEvents,
VadStatus,
WebRTCEndpointEvents,
} from '@fishjam-cloud/webrtc-client';
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type Metadata<PeerMetadata = GenericMetadata, ServerMetadata = GenericMet
server: ServerMetadata;
};

type TrackContextEvents = {
export type TrackContextEvents = {
encodingChanged: (context: FishjamTrackContext) => void;
voiceActivityChanged: (context: FishjamTrackContext) => void;
};
Expand Down
1 change: 0 additions & 1 deletion packages/webrtc-client/src/webRTCEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export class WebRTCEndpoint extends (EventEmitter as new () => TypedEmitter<Requ
*
* @return {Promise<RTCStatsReport>}
*
* @external RTCPeerConnection#getStats()
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
*/
public async getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport> {
Expand Down
5 changes: 4 additions & 1 deletion packages/webrtc-client/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"$schema": "https://typedoc.org/schema.json",
"includeVersion": true,
"entryPoints": ["src/index.ts"],
"readme": "none"
"readme": "none",
"validation": {
"notExported": false
}
}
4 changes: 3 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"plugin": ["typedoc-material-theme"],
"themeColor": "#FCF6E7",
"sort": ["kind", "alphabetical"],
"kindSortOrder": ["Method", "Function"]
"kindSortOrder": ["Method", "Function"],
"treatValidationWarningsAsErrors": true,
"treatWarningsAsErrors": true
}

0 comments on commit 1138eeb

Please sign in to comment.