From b7d7087d87d1a55ef30c8672ce4123e8a6c28947 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 10 Oct 2023 10:11:01 +0200 Subject: [PATCH 1/4] feat(apidocs): fix API docs warnings --- src/components/PlayerView/index.tsx | 2 + src/index.ts | 3 ++ src/offline/offlineContentManager.ts | 31 ++++++++++++- src/offline/offlineContentManagerListener.ts | 29 ------------ src/subtitleTrack.ts | 47 +++++++++++++++----- src/ui/custommessagehandler.ts | 32 ++++++++----- src/ui/custommessagesender.ts | 1 + src/utils.ts | 15 ------- 8 files changed, 92 insertions(+), 68 deletions(-) delete mode 100644 src/utils.ts diff --git a/src/components/PlayerView/index.tsx b/src/components/PlayerView/index.tsx index f6519daf..108720e8 100644 --- a/src/components/PlayerView/index.tsx +++ b/src/components/PlayerView/index.tsx @@ -83,6 +83,8 @@ function dispatch(command: string, node: NodeHandle, ...args: any[]) { /** * Component that provides the Bitmovin Player UI and default UI handling to an attached `Player` instance. * This component needs a `Player` instance to work properly so make sure one is passed to it as a prop. + * + * @param options configuration options */ export function PlayerView({ style, diff --git a/src/index.ts b/src/index.ts index 540f5089..67e942a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,3 +15,6 @@ export * from './offline'; export * from './thumbnail'; export * from './remoteControlConfig'; export * from './bitmovinCastManager'; +export * from './audioTrack'; +export * from './media'; +export * from './tweaksConfig'; diff --git a/src/offline/offlineContentManager.ts b/src/offline/offlineContentManager.ts index 78f2ff54..e7ea40c6 100644 --- a/src/offline/offlineContentManager.ts +++ b/src/offline/offlineContentManager.ts @@ -8,8 +8,8 @@ import NativeInstance from '../nativeInstance'; import { SourceConfig } from '../source'; import { BitmovinNativeOfflineEventData, - handleBitmovinNativeOfflineEvent, OfflineContentManagerListener, + OfflineEventType, } from './offlineContentManagerListener'; import { OfflineContentConfig } from './offlineContentConfig'; import { OfflineDownloadRequest } from './offlineDownloadRequest'; @@ -39,6 +39,35 @@ interface NativeOfflineModule extends NativeModule { const OfflineModule = NativeModules.BitmovinOfflineModule as NativeOfflineModule; +const handleBitmovinNativeOfflineEvent = ( + data: BitmovinNativeOfflineEventData, + listeners: Set +) => { + listeners.forEach((listener) => { + if (!listener) return; + + if (data.eventType === OfflineEventType.onCompleted) { + listener.onCompleted?.(data); + } else if (data.eventType === OfflineEventType.onError) { + listener.onError?.(data); + } else if (data.eventType === OfflineEventType.onProgress) { + listener.onProgress?.(data); + } else if (data.eventType === OfflineEventType.onOptionsAvailable) { + listener.onOptionsAvailable?.(data); + } else if (data.eventType === OfflineEventType.onDrmLicenseUpdated) { + listener.onDrmLicenseUpdated?.(data); + } else if (data.eventType === OfflineEventType.onDrmLicenseExpired) { + listener.onDrmLicenseExpired?.(data); + } else if (data.eventType === OfflineEventType.onSuspended) { + listener.onSuspended?.(data); + } else if (data.eventType === OfflineEventType.onResumed) { + listener.onResumed?.(data); + } else if (data.eventType === OfflineEventType.onCanceled) { + listener.onCanceled?.(data); + } + }); +}; + /** * Provides the means to download and store sources locally that can be played back with a Player * without an active network connection. An OfflineContentManager instance can be created via diff --git a/src/offline/offlineContentManagerListener.ts b/src/offline/offlineContentManagerListener.ts index 14b01aee..e4b4ed39 100644 --- a/src/offline/offlineContentManagerListener.ts +++ b/src/offline/offlineContentManagerListener.ts @@ -156,32 +156,3 @@ export interface OfflineContentManagerListener { onResumed?: (e: OnResumedEvent) => void; onCanceled?: (e: OnCanceledEvent) => void; } - -export const handleBitmovinNativeOfflineEvent = ( - data: BitmovinNativeOfflineEventData, - listeners: Set -) => { - listeners.forEach((listener) => { - if (!listener) return; - - if (data.eventType === OfflineEventType.onCompleted) { - listener.onCompleted?.(data); - } else if (data.eventType === OfflineEventType.onError) { - listener.onError?.(data); - } else if (data.eventType === OfflineEventType.onProgress) { - listener.onProgress?.(data); - } else if (data.eventType === OfflineEventType.onOptionsAvailable) { - listener.onOptionsAvailable?.(data); - } else if (data.eventType === OfflineEventType.onDrmLicenseUpdated) { - listener.onDrmLicenseUpdated?.(data); - } else if (data.eventType === OfflineEventType.onDrmLicenseExpired) { - listener.onDrmLicenseExpired?.(data); - } else if (data.eventType === OfflineEventType.onSuspended) { - listener.onSuspended?.(data); - } else if (data.eventType === OfflineEventType.onResumed) { - listener.onResumed?.(data); - } else if (data.eventType === OfflineEventType.onCanceled) { - listener.onCanceled?.(data); - } - }); -}; diff --git a/src/subtitleTrack.ts b/src/subtitleTrack.ts index 3c1effe1..608dc2c0 100644 --- a/src/subtitleTrack.ts +++ b/src/subtitleTrack.ts @@ -1,5 +1,3 @@ -import { MakeRequired } from './utils'; - /** * Supported subtitle/caption file formats. */ @@ -10,7 +8,7 @@ export enum SubtitleFormat { } /** - * Represents a custom subtitle track source that can be added to `SourceConfig.subtitleTracks`. + * Describes a subtitle track. */ export interface SubtitleTrack { /** @@ -48,13 +46,40 @@ export interface SubtitleTrack { } /** - * Helper type that represents an entry in `SourceConfig.subtitleTracks` list. + * A subtitle track that can be added to `SourceConfig.subtitleTracks`. * - * Since `SubtitleTrack` has all of its properties as optionals for total compatibility with - * values that may be sent from native code, this type serves as a reinforcer of what properties - * should be required during the registration of an external subtitle track from JS. */ -export type SideLoadedSubtitleTrack = MakeRequired< - SubtitleTrack, - 'url' | 'label' | 'language' | 'format' ->; +export interface SideLoadedSubtitleTrack { + /** + * The URL to the timed file, e.g. WebVTT file. + */ + url: string; + /** + * The label for this track. + */ + label: string; + /** + * The unique identifier for this track. If no value is provided, a random UUIDv4 will be generated for it. + */ + identifier?: string; + /** + * Specifies the file format to be used by this track. + */ + format: SubtitleFormat; + /** + * If set to true, this track would be considered as default. Default is `false`. + */ + isDefault?: boolean; + /** + * Tells if a subtitle track is forced. If set to `true` it means that the player should automatically + * select and switch this subtitle according to the selected audio language. Forced subtitles do + * not appear in `Player.getAvailableSubtitles`. + * + * Default is `false`. + */ + isForced?: boolean; + /** + * The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc. + */ + language: string; +} diff --git a/src/ui/custommessagehandler.ts b/src/ui/custommessagehandler.ts index 86749226..d78e725c 100644 --- a/src/ui/custommessagehandler.ts +++ b/src/ui/custommessagehandler.ts @@ -1,5 +1,22 @@ import { CustomMessageSender } from './custommessagesender'; +export interface CustomMessageHandlerProps { + /** + * A function that will be called when the Player UI sends a synchronous message to the integration. + */ + onReceivedSynchronousMessage: ( + message: string, + data: string | undefined + ) => string | undefined; + /** + * A function that will be called when the Player UI sends an asynchronous message to the integration. + */ + onReceivedAsynchronousMessage: ( + message: string, + data: string | undefined + ) => void; +} + /** * Android and iOS only. * For Android it requires Player SDK version 3.39.0 or higher. @@ -16,6 +33,7 @@ export class CustomMessageHandler { data: string | undefined ) => void; + /** @internal */ customMessageSender?: CustomMessageSender; /** @@ -23,22 +41,12 @@ export class CustomMessageHandler { * * Creates a new `CustomMessageHandler` instance to handle two-way communication between the integation and the Player UI. * - * @param onReceivedSynchronousMessage - A function that will be called when the Player UI sends a synchronous message to the integration. - * @param onReceivedAsynchronousMessage - A function that will be called when the Player UI sends an asynchronous message to the integration. + * @param options - Configuration options for the `CustomMessageHandler` instance. */ constructor({ onReceivedSynchronousMessage, onReceivedAsynchronousMessage, - }: { - onReceivedSynchronousMessage: ( - message: string, - data: string | undefined - ) => string | undefined; - onReceivedAsynchronousMessage: ( - message: string, - data: string | undefined - ) => void; - }) { + }: CustomMessageHandlerProps) { this.onReceivedSynchronousMessage = onReceivedSynchronousMessage; this.onReceivedAsynchronousMessage = onReceivedAsynchronousMessage; } diff --git a/src/ui/custommessagesender.ts b/src/ui/custommessagesender.ts index 8ce74d8e..ab211d4e 100644 --- a/src/ui/custommessagesender.ts +++ b/src/ui/custommessagesender.ts @@ -1,3 +1,4 @@ +/** @internal */ export interface CustomMessageSender { sendMessage(message: string, data: string | undefined): void; } diff --git a/src/utils.ts b/src/utils.ts deleted file mode 100644 index 61809deb..00000000 --- a/src/utils.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Utility type that maps the specified optional props from the target `Type` to be - * required props. Note all the other props stay unaffected. - * - * @example - * type MyType = { - * a?: string; - * b?: number; - * c?: boolean; - * }; - * - * type MyRequiredType = MakeRequired // => { a: string; b?: number; c: boolean; } - */ -export type MakeRequired = Omit & - Required>; From 899d1d5eb9e74ec329f06c027f174a25f988993b Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 10 Oct 2023 10:11:33 +0200 Subject: [PATCH 2/4] feat(apidocs): turn on treat warnings as errors --- typedoc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/typedoc.json b/typedoc.json index 311e1f04..c66b7739 100644 --- a/typedoc.json +++ b/typedoc.json @@ -8,5 +8,6 @@ "excludeExternals": true, "includeVersion": true, "entryPoints": ["./src"], - "exclude": ["./example/**/*"] + "exclude": ["./example/**/*"], + "treatWarningsAsErrors": true } From 1411673679e15d960228193ef5ecebbecf84a257 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 10 Oct 2023 10:15:03 +0200 Subject: [PATCH 3/4] feat(apidocs): improve SideLoadedSubtitleTrack API --- src/subtitleTrack.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/subtitleTrack.ts b/src/subtitleTrack.ts index 608dc2c0..f2003a54 100644 --- a/src/subtitleTrack.ts +++ b/src/subtitleTrack.ts @@ -58,6 +58,10 @@ export interface SideLoadedSubtitleTrack { * The label for this track. */ label: string; + /** + * The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc. + */ + language: string; /** * The unique identifier for this track. If no value is provided, a random UUIDv4 will be generated for it. */ @@ -78,8 +82,4 @@ export interface SideLoadedSubtitleTrack { * Default is `false`. */ isForced?: boolean; - /** - * The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc. - */ - language: string; } From c73c55d7196ee4b0dbc84f3f22a75a75f274b7f0 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 10 Oct 2023 15:00:46 +0200 Subject: [PATCH 4/4] feat(apidocs): simplify SideLoadedSubtitleTrack definition --- src/subtitleTrack.ts | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/subtitleTrack.ts b/src/subtitleTrack.ts index f2003a54..950f3987 100644 --- a/src/subtitleTrack.ts +++ b/src/subtitleTrack.ts @@ -49,37 +49,9 @@ export interface SubtitleTrack { * A subtitle track that can be added to `SourceConfig.subtitleTracks`. * */ -export interface SideLoadedSubtitleTrack { - /** - * The URL to the timed file, e.g. WebVTT file. - */ +export interface SideLoadedSubtitleTrack extends SubtitleTrack { url: string; - /** - * The label for this track. - */ label: string; - /** - * The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc. - */ language: string; - /** - * The unique identifier for this track. If no value is provided, a random UUIDv4 will be generated for it. - */ - identifier?: string; - /** - * Specifies the file format to be used by this track. - */ format: SubtitleFormat; - /** - * If set to true, this track would be considered as default. Default is `false`. - */ - isDefault?: boolean; - /** - * Tells if a subtitle track is forced. If set to `true` it means that the player should automatically - * select and switch this subtitle according to the selected audio language. Forced subtitles do - * not appear in `Player.getAvailableSubtitles`. - * - * Default is `false`. - */ - isForced?: boolean; }