import type { Marker, MarkerIcon, ImageInfo } from '@edgepdf/types'; export type ZoomControlsPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; export interface InboundMessages { INIT_PDF_MAP: { imageInfo: ImageInfo; zoom?: number; center?: [number, number]; sourceMode?: 'pmtiles'; pmtilesKey?: string; /** Show zoom in/out buttons (default: true) */ showZoomControls?: boolean; /** Position of the zoom controls (default: 'top-right') */ zoomControlsPosition?: ZoomControlsPosition; /** Show current zoom level indicator (default: true) */ showZoomLevel?: boolean; /** Allow creating annotations by tapping the map (default: true) */ enableAnnotation?: boolean; /** Show the edit button on marker popups (default: true) */ showEditButton?: boolean; /** Show the delete button on marker popups (default: true) */ showDeleteButton?: boolean; /** * Icon given to markers created by tapping the map. * * Without this, tap-created markers can only be legacy PNG pins — the * native side would have to catch every `MARKER_CREATED` and immediately * send an `UPDATE_MARKER` back, which flickers. Omit to keep the pin. */ defaultMarkerIcon?: MarkerIcon; }; RANGE_RESPONSE: { id: string; base64Data: string; etag?: string; expires?: string; cacheControl?: string; }; SET_MARKERS: { markers: Marker[]; }; ADD_MARKER: { marker: Marker; }; REMOVE_MARKER: { markerId: string; }; UPDATE_MARKER: { marker: Marker; }; FOCUS_MARKER: { markerId: string; zoom?: number; animate?: boolean; offsetLeft?: number; offsetRight?: number; offsetTop?: number; offsetBottom?: number; }; SET_VIEW: { center: [number, number]; zoom: number; }; SET_ACTIVE_MARKER: { markerId: string | null; }; /** Dynamically enable or disable annotation (marker creation on map tap). */ SET_ANNOTATION_ENABLED: { enabled: boolean; }; /** * Change the icon given to markers created by tapping the map. Pass `null` * to go back to the legacy PNG pin. */ SET_DEFAULT_MARKER_ICON: { icon: MarkerIcon | null; }; } export interface OutboundMessages { /** Sent immediately after the message listener is registered — guarantees * the web runtime is ready to receive INIT_PDF_MAP from the native side. */ WEB_RUNTIME_READY: Record; PDF_MAP_READY: { /** * Every marker icon name this `viewer.html` build can render. * * Reported here rather than exposed as a function because the registry * lives inside the WebView bundle — the native side has no way to call * into it, and the set is frozen at build time so one snapshot on ready * is enough. Lets the host validate names (or drive a picker) instead of * discovering a version skew as a fallback glyph. * * Optional on this side of the bridge even though the runtime always * sends it: RN JS updates over the air while the inlined `viewer.html` * does not, so a newer app can be talking to a viewer build that predates * the field. */ availableMarkerIcons?: string[]; }; RANGE_REQUEST: { id: string; offset: number; length: number; etag?: string; }; MAP_CLICK: { imageCoords?: { x: number; y: number; }; leafletCoords: [number, number]; }; MARKER_CLICK: { markerId: string; }; MARKER_CREATED: { marker: Marker; }; MARKER_UPDATED: { marker: Marker; }; MARKER_DELETED: { markerId: string; }; MARKER_DRAG_END: { marker: Marker; }; VIEW_CHANGED: { center: [number, number]; zoom: number; }; ERROR: { message: string; }; } /** * Discriminated union of all messages sent from the WebView to React Native. * Use this as the parsed type in a switch-on-`type` handler to get automatic * per-case narrowing without manual casts. */ export type OutboundMessage = { [K in keyof OutboundMessages]: { type: K; } & OutboundMessages[K]; }[keyof OutboundMessages]; /** * Discriminated union of all messages sent from React Native into the WebView. * Useful when building custom dispatch loops or testing bridge handlers. */ export type InboundMessage = { [K in keyof InboundMessages]: { type: K; } & InboundMessages[K]; }[keyof InboundMessages]; //# sourceMappingURL=bridge-types.d.ts.map