import type { ApiManager } from '../../../framework-types/api-manager/ApiManager'; import type { EmptyObject } from '../../../framework-types/BaseTypes'; import type { LogLevel } from '../../../framework-types/effects/LoggerEffect'; import type { ContextHaving } from '../../../framework-types/execution-context/Types'; import type { BundleExportNames, PlayerConfig } from '../../bundles/Types'; import type { DeepPartial } from '../../Types'; import type { Constants, LoadControl } from '../core/Constants'; import type { MapStateAtom } from '../core/state/MapStateAtom'; import type { CoreEffects, CoreExportNames, CoreStateAtoms } from '../core/Types'; import type { CoreUtils } from '../core/utils/Types'; import type { createEventBus, extendEventBusTypes } 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 { StreamDataStructurePackageExports } from '../stream-data-structure/Types'; import type { StreamingPackageExports } from '../streaming/Types'; import type { ContextWithState } from '../Types'; import type { SourceRemovedError } from './SourceRemovedError'; import type { SourcesApiEvent } from './SourcesApiEvent'; import type VideoElementUtils from './VideoElementUtils'; export type { SourcesApiEvent } from './SourcesApiEvent'; 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 = DeepPartial & { attach?: boolean | AttachOptions; }; export interface AttachOptions { video?: HTMLVideoElement; container?: HTMLElement; } export type SourcesApiEventMap = { [SourcesApiEvent.SourceAdded]: SourceAddedEvent; [SourcesApiEvent.SourceRemoved]: SourceRemovedEvent; [SourcesApiEvent.VideoAttached]: VideoAttachedEvent; [SourcesApiEvent.VideoDetached]: VideoDetachedEvent; [SourcesApiEvent.SourceError]: SourceErrorEvent; }; export type SourceApiComponents = { apiManager: ApiManager; eventBus: EventBus; }; export type SourceApiComponentMap = MapStateAtom; 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; readonly video: HTMLVideoElement | undefined; readonly container: HTMLElement | undefined; readonly attached: boolean; } export type SourcesApiDependencies = { [CoreExportNames.Utils]: CoreUtils; [CoreExportNames.CoreEffects]: CoreEffects; [CoreExportNames.CoreStateAtoms]: CoreStateAtoms; [CoreExportNames.Constants]: Constants; [BundleExportNames.PlayerConfig]: PlayerConfig; [SourceExportNames.CreateSourceStateAtom]: CreateSourceStateAtom; [SourceExportNames.CreateSourceReference]: typeof createSourceReference; [SourceExportNames.SourceReferences]: SourceReferences; [EventBusExportNames.CreateEventBus]: typeof createEventBus; [EventBusExportNames.ExtendEventBusTypes]: typeof extendEventBusTypes; [PlayerApiExportNames.PlayerEventBus]: EventBus; } & StreamDataStructurePackageExports & StreamingPackageExports; export declare enum SourcesApiExportNames { SourceApiManager = "source-api-manager", VideoElementUtils = "video-element-utils", SourceEventBus = "source-event-bus", SourceApiComponentMap = "source-api-component-map", SourceRemovedError = "source-removed-error" } export type SourcesApiExports = { [SourcesApiExportNames.SourceApiManager]: ApiManager; [SourcesApiExportNames.VideoElementUtils]: typeof VideoElementUtils; [SourcesApiExportNames.SourceEventBus]: EventBus; [SourcesApiExportNames.SourceApiComponentMap]: SourceApiComponentMap; [SourcesApiExportNames.SourceRemovedError]: typeof SourceRemovedError; };