UNPKG

@readium/navigator

Version:

Next generation SDK for publications in Web Apps

114 lines (113 loc) 4.05 kB
import { Link, Locator, Publication, ReadingProgression } from "@readium/shared"; import { ContentProtectionConfig, PrintProtectionConfig, KeyboardPeripheral, KeyboardPeripheralEvent } from "@readium/navigator-html-injectables"; type cbb = (ok: boolean) => void; export interface KeyboardPeripheralEventData extends Omit<KeyboardPeripheralEvent, 'interactiveElement'> { interactiveElement?: Element; } export type IKeyboardPeripheralsConfig = Array<Omit<KeyboardPeripheral, 'type'> & { type: Exclude<string, 'developer_tools' | 'select_all' | 'print' | 'save'>; }>; export interface ProgressionRange { start: number; end: number; } export interface VisualNavigatorViewport { readingOrder: string[]; progressions: Map<string, ProgressionRange>; positions: number[] | null; } export interface IContentProtectionConfig extends ContentProtectionConfig { protectPrinting?: PrintProtectionConfig; checkAutomation?: boolean; checkIFrameEmbedding?: boolean; } export declare abstract class Navigator { abstract get publication(): Publication; abstract get currentLocator(): Locator; /** * Moves to the position in the publication corresponding to the given {Locator}. */ abstract go(locator: Locator, animated: boolean, cb: cbb): void; /** * Moves to the position in the publication targeted by the given link. */ abstract goLink(link: Link, animated: boolean, cb: cbb): void; /** * Moves to the next content portion (eg. page) in the reading progression direction. */ abstract goForward(animated: boolean, cb: cbb): void; /** * Moves to the previous content portion (eg. page) in the reading progression direction. */ abstract goBackward(animated: boolean, cb: cbb): void; /** * Destroy all resources associated with this navigator. Synonymous with "unmount" */ abstract destroy(): void; /** * Merges keyboard peripherals from content protection config with user-provided peripherals * Content protection peripherals are added first for priority, then user peripherals are added only if they don't conflict */ protected mergeKeyboardPeripherals(config: IContentProtectionConfig, keyboardPeripherals?: IKeyboardPeripheralsConfig): IKeyboardPeripheralsConfig; } export declare abstract class VisualNavigator extends Navigator { /** * Current reading progression direction. */ abstract get readingProgression(): ReadingProgression; /** * Moves to the left content portion (eg. page) relative to the reading progression direction. */ goLeft(animated: boolean | undefined, completion: cbb): void; /** * Moves to the right content portion (eg. page) relative to the reading progression direction. */ goRight(animated: boolean | undefined, completion: cbb): void; } export declare abstract class MediaNavigator extends Navigator { /** * Current playback state - is media currently playing? */ abstract get isPlaying(): boolean; /** * Current playback state - is media currently paused? */ abstract get isPaused(): boolean; /** * Duration of current media resource in seconds */ abstract get duration(): number; /** * Current time in seconds within the media resource */ abstract get currentTime(): number; /** * Play the current media resource */ abstract play(): void; /** * Pause the currently playing media */ abstract pause(): void; /** * Stop playback and reset to beginning */ abstract stop(): void; /** * Seek to specific time in seconds */ abstract seek(time: number): void; /** * Jump forward or backward by specified seconds */ abstract jump(seconds: number): void; /** * Skip forward by the configured interval */ abstract skipForward(): void; /** * Skip backward by the configured interval */ abstract skipBackward(): void; } export {};