import { type JSX, type ReactNode, type RefObject, type SetStateAction } from 'react'; import { WebView } from 'react-native-webview'; import type { Marker } from '@edgepdf/types'; import type { InboundMessages } from './bridge-types'; export interface ViewerContextValue { /** Ref attached to the underlying WebView — set by EdgePDFViewer. */ webViewRef: RefObject; /** True after the web runtime emits PDF_MAP_READY. */ isReady: boolean; /** Markers currently tracked by the viewer (synced from bridge events). */ markers: Marker[]; /** Current map zoom level (updated on VIEW_CHANGED). */ zoom: number | null; /** Current map center [lat, lng] (updated on VIEW_CHANGED). */ center: [number, number] | null; /** Whether the viewer is in fullscreen mode. */ isFullscreen: boolean; /** * Marker icon names the loaded `viewer.html` can render, reported on * PDF_MAP_READY. Empty until then, and empty against a viewer build that * predates the feature — treat empty as "unknown", not as "none". */ availableMarkerIcons: string[]; /** Toggle fullscreen mode (registered by the viewer component). */ toggleFullscreen?: () => void; /** * Send a typed message into the web runtime running inside the WebView. * Safe to call before the WebView loads — the call is silently ignored * if the ref is not yet attached. */ postToWebView: (type: K, payload: InboundMessages[K]) => void; /** * @internal — Used by EdgePDFViewer to sync state from bridge messages. * Accepts a plain value or a functional updater for `markers`. */ _update: (updates: { isReady?: boolean; markers?: SetStateAction; zoom?: number | null; center?: [number, number] | null; isFullscreen?: boolean; toggleFullscreen?: () => void; availableMarkerIcons?: string[]; }) => void; } export interface ViewerProviderProps { children: ReactNode; } /** * ViewerProvider — wraps a screen or subtree that contains one EdgePDFViewer. * * Create one provider per viewer instance. Hooks (`useViewer`, `useMarkers`, * `useZoom`) must be consumed within this provider. * * @example * ```tsx * * * * * ``` */ export declare function ViewerProvider({ children }: ViewerProviderProps): JSX.Element; /** * Access the raw viewer context. * * Prefer the specialised hooks (`useViewer`, `useMarkers`, `useZoom`) * unless you need direct context access. * * @throws {Error} When used outside a ViewerProvider. */ export declare function useViewerContext(): ViewerContextValue; //# sourceMappingURL=viewer-context.d.ts.map