/** * Viewer host context — the bridge between an embedding application * and the core viewer components. Two contexts live here: * * - {@link ViewerHostContext}: cross-cutting host config (API base * paths, read-only flag, debug toggle, optional pdf.js fallback). * - {@link ViewerServicesContext}: the {@link ViewerServices} object * carrying all the data-source protocols (page images, layers, * separations, annotations, etc.). Components read services via * {@link useViewerServices}; components decide between wired, * fallback, and hidden render modes via {@link useFallbackMode}. * * Hosts mount a `` at the root of their * app and supply concrete values; the no-op defaults exported below * keep an unwired viewer renderable but quiet. * * @public */ import type { PdfFallbackAdapter, ViewerServices } from "../plugin/services"; /** * Values the host application supplies to the viewer's core * components. Cross-cutting toggles, base API paths, and the * optional PDF fallback adapter live here; per-feature data sources * are on {@link ViewerServices}. * * @public */ export interface ViewerHostContextValue { /** * Base path for viewer API calls (no trailing slash). The viewer * itself never builds URLs from this — it's plumbed through for * host-side service implementations that want a single source of * truth (e.g. a host's `getPageImageUrl` returning * ``${apiBase}/page/${n}.png``). Leave empty if your services * compose URLs differently. */ apiBase: string; /** * Base path for job-level API calls (findings, reports, etc.). * Same plumbing convention as {@link apiBase}. */ jobApiBase: string; /** * When true, hides write-only UI (annotations, verdict, comparison * initiation). Public-token / share-link viewers run with this on. */ readOnly: boolean; /** * When true, components log a one-shot ``console.info`` whenever * they self-hide because their backing service is unwired. Off by * default so production embeds stay quiet. Hosts typically derive * this from an environment flag (``import.meta.env.DEV``, * ``process.env.NODE_ENV !== "production"``, etc.). */ debug?: boolean; /** * Optional URL to the raw PDF file. Consumed by the pdf.js fallback * adapter (see ``createPdfJsFallback``) and by base components when * no service is wired. * * **Security**: this is a pure renderer. Whatever URL the host puts * here is fetched by the user's browser as-is — sign it, scope it, * and expire it like any other PDF download link. Never point this * at an unauthenticated path that exposes documents the viewer's * user shouldn't see. */ pdfUrl?: string; /** * Optional in-browser fallback adapter used when a richer service * is unwired. See {@link PdfFallbackAdapter}. Hosts that don't set * this get hide-on-unwired behaviour for every fallback-capable * tool; hosts that set it (e.g. via ``createPdfJsFallback``) get * graceful degradation instead. */ pdfFallback?: PdfFallbackAdapter; } /** * React context object. Default value is intentionally empty so a * misconfigured viewer renders nothing surprising — components that * read `apiBase` should treat the empty string as "no host wired up". * * @public */ export declare const ViewerHostContext: import("react").Context; /** * Hook for reading the current `ViewerHostContextValue`. Returns the * default empty values when no provider is mounted. * * @public */ export declare function useViewerHost(): ViewerHostContextValue; /** * No-op default services. URL builders return empty strings; the * other protocols are filled with the no-op stubs already defined * in `core/plugin/services`. Hosts that supply a partial * `ViewerServices` in their provider override only the fields they * actually have. * * Choosing empty-string for URL builders (rather than throwing) * keeps the boundary forgiving — a misconfigured viewer renders * blank tiles, but doesn't crash. */ declare const defaultViewerServices: ViewerServices; /** * React context carrying the active `ViewerServices` instance. * `` mounts a host's * concrete implementation; downstream plugin packs typically expose * a factory like `createMyHostViewerServices(...)` that returns one. * * @public */ export declare const ViewerServicesContext: import("react").Context; /** * Hook for reading the active `ViewerServices`. Returns the no-op * defaults when no provider is mounted. * * @public */ export declare function useViewerServices(): ViewerServices; /** * One-shot ``console.info`` for components that self-hide because * their backing service is unwired. Silent unless ``host.debug`` is * on, and deduped per-component-name so a thousand re-renders don't * spam the console. * * @public */ export declare function logUnwiredHide(componentName: string, serviceName: string): void; /** * Helper hook used by fallback-capable components. Returns a stable * tuple describing how the component should render its data source: * * - ``mode: "wired"`` — host provided the dedicated service; use it. * - ``mode: "fallback"`` — service unwired but ``pdfFallback`` is * present; use the fallback adapter. * - ``mode: "hidden"`` — neither is available; render ``null``. * * Components are responsible for calling {@link logUnwiredHide} from * an effect when they choose to hide; this hook deliberately doesn't * log on its own so callers control the message. * * @public */ export declare function useFallbackMode(service: object | null | undefined): "wired" | "fallback" | "hidden"; export { isUnwired, markUnwired } from "../plugin/services"; export type { LensPDFProviderProps } from "./LensPDFProvider"; export { LensPDFProvider } from "./LensPDFProvider"; export { createPdfJsFallback } from "./pdfFallback"; export type { PdfValidationResult } from "./pdfValidation"; export { validatePdfFile, validatePdfUrl } from "./pdfValidation"; export type { ParsedShareParams, ShareLinkOptions } from "./shareLink"; export { generateShareLink, parseShareParams } from "./shareLink"; export type { UseLensPDFOptions, UseLensPDFReturn } from "./useLensPDF"; export { useLensPDF } from "./useLensPDF"; /** * Pre-built services where every protocol is a no-op default tagged * with the unwired marker. Hosts that only need a partial override * can spread this and replace the fields they've wired: * * ```ts * const services = { ...defaultUnwiredServices, pageImages: myPageImages }; * ``` * * @public */ export { defaultViewerServices as defaultUnwiredServices }; //# sourceMappingURL=index.d.ts.map