import type { ApiManager } from '../../../framework-types/api-manager/ApiManager'; import type { EmptyObject } from '../../../framework-types/BaseTypes'; import type { ContextHaving } from '../../../framework-types/execution-context/Types'; import type { BundleExportNames, PlayerConfig } from '../../bundles/Types'; import type { Constants, LoadControl } from '../core/Constants'; import type { CoreEffects, CoreExportNames, CoreStateAtoms } from '../core/Types'; import type { Logger, LogLevel } from '../core/utils/Logger'; import type { CoreUtils } from '../core/utils/Types'; import type { createEventBus } from '../event-bus/EventBus'; import type { EventBus, EventBusExportNames } from '../event-bus/Types'; import type { PlayerApiExportNames } from '../player-api/Types'; import type { SourceConfig } from '../source/atoms/SourceConfigAtom'; import type { CreateSourceStateAtom, SourceOptions } from '../source/atoms/SourceStateAtom'; import type { createSourceReference } from '../source/SourceReference'; import type { SourceExportNames, SourceReference, SourceReferences } from '../source/Types'; import type { ContextWithState } from '../Types'; import type VideoElementUtils from './VideoElementUtils'; export interface SourcesApiObject { list(): SourceApi[]; add(config: SourceConfig, options?: SourceOptionsWithAttach, insertAt?: number): SourceApi; remove(source: SourceApi): void; attachVideo(source: SourceApi, options?: AttachOptions): void; detachVideo(source: SourceApi): void; } export type SourceOptionsWithAttach = Partial & { attach?: boolean | AttachOptions; }; export interface AttachOptions { video?: HTMLVideoElement; container?: HTMLElement; } export declare enum SourcesApiEvent { SourceAdded = "source-added", SourceRemoved = "source-removed", VideoAttached = "video-attached", VideoDetached = "video-detached", SourceError = "source-error" } export type SourcesApiEventMap = { [SourcesApiEvent.SourceAdded]: SourceAddedEvent; [SourcesApiEvent.SourceRemoved]: SourceRemovedEvent; [SourcesApiEvent.VideoAttached]: VideoAttachedEvent; [SourcesApiEvent.VideoDetached]: VideoDetachedEvent; [SourcesApiEvent.SourceError]: SourceErrorEvent; }; export type SourcesMap = Map; export type SourcesApiContext = ContextHaving; export type VideoAttachedEvent = { videoElement: HTMLVideoElement; sourceId: string; }; export type VideoDetachedEvent = { videoElement: HTMLVideoElement; sourceId: string; }; export type SourceAddedEvent = { sourceId: string; sourceConfig: SourceConfig; sourceOptions?: Partial; }; export type SourceRemovedEvent = { sourceId: string; sourceConfig: SourceConfig; }; export type SourceErrorEvent = { sourceId: string; sourceConfig: SourceConfig; error: Error; }; export type SourcesApi = { events: EventBus; sources: SourcesApiObject; }; export interface SourceApiBase { logLevel: LogLevel; loadControl: LoadControl; readonly id: string; readonly events: EventBus; } export type SourcesApiDependencies = { [CoreExportNames.Utils]: CoreUtils; [CoreExportNames.CoreEffects]: CoreEffects; [CoreExportNames.CoreStateAtoms]: CoreStateAtoms; [BundleExportNames.Logger]: Logger; [CoreExportNames.Constants]: Constants; [BundleExportNames.PlayerConfig]: PlayerConfig; [SourceExportNames.CreateSourceStateAtom]: CreateSourceStateAtom; [SourceExportNames.CreateSourceReference]: typeof createSourceReference; [SourceExportNames.SourceReferences]: SourceReferences; [EventBusExportNames.CreateEventBus]: typeof createEventBus; [PlayerApiExportNames.PlayerEventBus]: EventBus; }; export declare enum SourcesApiExportNames { SourceApiManager = "source-api-manager", VideoElementUtils = "video-element-utils", SourceEventBus = "source-event-bus" } export type SourcesApiExports = { [SourcesApiExportNames.SourceApiManager]: ApiManager; [SourcesApiExportNames.VideoElementUtils]: typeof VideoElementUtils; [SourcesApiExportNames.SourceEventBus]: EventBus; };