import { BlockWindowEvent, Book, LinkEvent, LoadEvent, RelocateEvent, TOCItem } from './types'; import { ParserInput, ParserOptions } from './parser'; import { BookRange, TextChunk, TextProvider, TextSearchResult } from './location'; import { PageSurface } from './page-surface'; import { LayoutMode, ReaderMark, Renderer, RendererNavigationHooks, RendererStyles } from './renderer'; import { ReaderThemeInput } from './theme'; import { RebookExtensionCommandRegistration, RebookExtensionContributionIndex, RebookExtension, RebookExtensionManifest, RebookExtensionSettingInspection, RebookExtensionRegistryInstallOptions, RebookPluginLike } from './extensions'; import { TrialLimitController, TrialTOCAccessItem } from '../plugins/trial-limit'; import { ContentUnitSearchResult, SearchOptions, SearchResult } from '../search'; export interface ReaderSessionConfig { /** Create a renderer instance for the current platform. */ createRenderer: (hooks?: RendererNavigationHooks) => Renderer; /** Parser options, including platform adapters. */ parserOptions?: ParserOptions | (() => ParserOptions); /** Plugins to transform the book before rendering. */ plugins?: readonly RebookPluginLike[]; } export interface TOCViewItem { /** Stable key for rendering and expansion state. */ id: string; /** Display label. */ label: string; /** Opaque navigation target. Pass this to reader.goTo() or reader.canGoTo(). */ target: string; /** True when trial/access policy prevents navigation to this item. */ disabled: boolean; /** True when this item is the current reading location. */ active: boolean; /** Nested TOC items ready for recursive UI rendering. */ children?: readonly TOCViewItem[]; } export interface TOCViewOptions { items?: readonly TOCItem[]; location?: RelocateEvent | null; } /** * High-level reader API shared by browser and Mini Program hosts. */ export declare class ReaderSession { private renderer; private book; private config; private readonly extensionRegistry; private readonly extensionHost; private readonly pluginEntries; private registeredListeners; constructor(config: ReaderSessionConfig); /** * Open a book from a file, URL, Blob, or ArrayBuffer. */ open(input: ParserInput): Promise; /** * Open an already-parsed book. */ openBook(inputBook: Book): Promise; /** * Get the current book. */ getBook(): Book | null; /** * Get book metadata. */ getMetadata(): import('./types').BookMetadata | undefined; /** * Install an extension for future book opens. Existing open books are not rewrapped automatically. */ installExtension(extension: RebookExtension, options?: RebookExtensionRegistryInstallOptions): RebookExtension; /** * Uninstall an extension by id for future book opens. */ uninstallExtension(id: string): boolean; /** * Get an installed extension package by id. */ getExtension(id: string): RebookExtension | undefined; /** * Check whether an extension package is installed. */ hasExtension(id: string): boolean; /** * List installed extension packages. */ getInstalledExtensions(): readonly RebookExtension[]; /** * List installed extension manifests for UI, settings, and future marketplace integrations. */ getExtensionManifests(): readonly RebookExtensionManifest[]; /** * List typed contribution points declared by installed extensions. */ getExtensionContributions(): RebookExtensionContributionIndex; /** * List commands registered by activated extensions. */ getExtensionCommands(): readonly RebookExtensionCommandRegistration[]; /** * Check whether an activated extension command has a handler registered. */ hasExtensionCommand(id: string): boolean; /** * Execute a command registered during extension activation. */ executeExtensionCommand(id: string, ...args: readonly unknown[]): Promise; /** * List settings declared by installed/activated extensions with effective values. */ getExtensionSettings(extensionId?: string): readonly RebookExtensionSettingInspection[]; /** * Read one extension setting, falling back to the manifest default when present. */ getExtensionSetting(extensionId: string, key: string, fallback?: T): T; /** * Update one extension setting for subsequent command activation and plugin behavior. */ updateExtensionSetting(extensionId: string, key: string, value: T): void; /** * Export host-managed extension setting values for persistence. */ getExtensionSettingsSnapshot(): Record>; /** * Restore host-managed extension setting values from persisted state. */ loadExtensionSettingsSnapshot(snapshot: Record> | undefined): void; /** * Get table of contents. */ getTOC(): readonly TOCItem[] | undefined; /** * Search the current book's readable text. */ search(query: string, options?: SearchOptions): Promise; /** * Search the current book and group matches by readable content unit. */ searchContentUnits(query: string, options?: Omit): Promise; /** * Get the current book's trial policy controller, if installed. */ getTrialLimit(): TrialLimitController | null; /** * Check whether the current trial policy allows navigation to a target. * Books without a trial policy are unrestricted. */ canGoTo(target: string | number): boolean; /** * Check whether the current trial policy allows moving to the next page. * Books without a trial policy are unrestricted. */ canGoNext(): boolean; /** * Get trial-aware TOC items for the current book. */ getTrialTOCItems(items?: readonly TOCItem[]): TrialTOCAccessItem[]; /** * Get TOC hrefs allowed by the current trial policy. */ getAllowedTOCHrefs(): string[]; /** * Get the current trial-aware TOC item for the reader location. */ getCurrentTrialTOCItem(items?: TrialTOCAccessItem[]): TrialTOCAccessItem | null; /** * Get TOC items ready for reader UI rendering. * * The returned tree includes active and trial-disabled state so hosts only * need to render labels and pass item.target back to goTo(). */ getTOCViewItems(options?: TOCViewOptions): TOCViewItem[]; /** * Navigate to a location. */ goTo(target: number | string): Promise; /** * Go to next page. */ next(): Promise; /** * Go to previous page. */ prev(): Promise; /** * Navigate right (respects RTL). */ goRight(): Promise; /** * Navigate left (respects RTL). */ goLeft(): Promise; /** * Navigate by fraction (0-1). */ goToFraction(fraction: number): Promise; /** * Get section fractions for progress bar. */ getSectionFractions(): number[]; /** * Reload the current section while preserving the current reading position. */ refresh(): Promise; /** * Get current reading location. */ getLocation(): RelocateEvent | null; /** * Get current TOC item based on location. */ getCurrentTOCItem(location?: RelocateEvent | null): TOCItem | null; /** * Get the currently composed page surface, when the active renderer exposes one. */ getCurrentSurface(): PageSurface | null; /** * Get a text provider for the currently composed surface. */ getCurrentTextProvider(): TextProvider | null; /** * Get visible/current surface text through the unified surface model. */ getCurrentText(range?: BookRange): Promise; /** * Search visible/current surface text through the unified surface model. */ searchCurrentText(query: string, range?: BookRange): Promise; /** * Update styles. */ setStyles(styles: RendererStyles): void; /** * Switch reader theme. */ setTheme(theme: ReaderThemeInput): void; /** * Set layout mode. */ setLayout(mode: LayoutMode): void; /** * Set maximum number of visible columns (pages). */ setSpread(maxColumns: number): void; /** * Add or replace a transient render mark such as the current TTS segment, * search hit, translation state, or annotation preview. */ setMark(mark: ReaderMark): void; /** * Remove a render mark by id. */ removeMark(id: string): void; /** * Clear render marks. When kind is provided, only marks of that kind are cleared. */ clearMarks(kind?: string): void; /** * Get current render marks. */ getMarks(): ReaderMark[]; /** * Register an event listener. */ on(event: 'load', listener: (e: LoadEvent) => void): void; on(event: 'relocate', listener: (e: RelocateEvent) => void): void; on(event: 'link', listener: (e: LinkEvent) => void): void; on(event: 'block-window', listener: (e: BlockWindowEvent) => void): void; /** * Remove an event listener. */ off(event: string, listener: (e: unknown) => void): void; /** * Close the current book and clean up book resources. */ close(): void; /** * Destroy the reader and release all resources. */ destroy(): void; protected getRenderer(): Renderer; private createRenderer; private canNavigate; private resetRenderer; private getParserOptions; private addPluginEntry; } //# sourceMappingURL=reader.d.ts.map