pdfrx_web
    Preparing search index...

    Class PdfrxViewerStore

    Owns one PdfrxViewer instance on behalf of a React tree.

    React cannot construct the viewer itself, because new PdfrxViewer(container) needs a DOM node that only exists once PdfViewerSurface has rendered — which is a descendant of the provider. So the provider creates this store, the surface calls attach with its <div>, and every hook subscribes here. The store is a plain object with no React dependency, which also makes it straightforward to test.

    Instances are created by PdfrxProvider; you normally reach one through usePdfrxStore() rather than constructing it.

    Index
    thumbnails: ThumbnailCache = ...

    Shared by every usePdfPageThumbnail under this provider.

    • get documentGeneration(): number

      Increments on every document change; useful as a cache key.

      Returns number

    • get error(): unknown

      The error thrown by the most recent open attempt, or null.

      Returns unknown

    • get errorFileName(): string | null

      File associated with an import error, or null for document-open errors.

      Returns string | null

    • get pagesRevision(): number

      Increments when pages are added, removed, rotated or reordered.

      Returns number

    • get passwordProvider(): PdfPasswordProvider | undefined

      The effective default password provider: the app-supplied one, or the batteries-included fallback when none was supplied. Used by every built-in open path and read by callers that open outside the store (e.g. importing pages into the current document).

      Returns PdfPasswordProvider | undefined

    • get searchQuery(): string

      The text currently in the search box.

      Returns string

    • get surfaceElement(): HTMLElement | null

      DOM surface currently hosting the viewer, or null before mount.

      Returns HTMLElement | null

    • Creates the viewer inside element. Called by PdfViewerSurface on mount. Re-attaching the same element (StrictMode's remount) reuses the existing viewer instead of rebuilding the worker.

      Parameters

      • element: HTMLElement

        The element value (HTMLElement).

      Returns void

    • Clears error (e.g. when the user dismisses the error banner). A no-op when there is no error. The next open attempt also clears it.

      Returns void

    • Returns unknown

      The latest viewer error, or null when no error is active.

    • Opens a document imperatively, bypassing the src prop. Rejects with the open error (which is also recorded on error).

      Parameters

      Returns Promise<void>

      The resolved Promise.

    • Shows an error from a built-in import action in the viewer app's error banner.

      Parameters

      • error: unknown

        The error value (unknown).

      • fileName: string

        The fileName value (string).

      Returns void

    • Sets the app's context-menu builder (or null for the localized default). Read at menu-show time, so no viewer rebuild is needed.

      Parameters

      Returns void

    • Sets the fallback used only when no app password provider was supplied.

      Parameters

      • provider: PdfPasswordProvider | undefined

        The provider value (PdfPasswordProvider or undefined).

      Returns void

    • Sets the app-supplied image decoder (from the imageDecoder prop).

      Parameters

      • decoder: PdfImageDecoder | undefined

        The decoder value (PdfImageDecoder or undefined).

      Returns void

    • Sets the app-supplied default password provider (from the passwordProvider prop).

      Parameters

      • provider: PdfPasswordProvider | undefined

        The provider value (PdfPasswordProvider or undefined).

      Returns void

    • Sets the search text and starts (or clears) the search.

      startTextSearch ignores a pattern identical to the last one, so re-running the same query needs resetTextSearch() first — force does that for you.

      Parameters

      • query: string

        The query value (string).

      • Optionaloptions: StartTextSearchOptions & { force?: boolean }

        Options that customize the operation.

      Returns void

    • Declares which document should be shown. A no-op when the source is equivalent to the current one, so passing an inline src string on every render does not reopen the document.

      Parameters

      Returns void

    • Sets the strings the default context menu is built from. Called by the provider; the menu reads the latest value when it opens, so no viewer rebuild is needed.

      Parameters

      Returns void

    • Subscribes to viewer/error/document changes. Returns an unsubscribe function.

      Parameters

      • listener: () => void

        The callback to invoke when the value changes.

      Returns () => void

      A function that removes the listener.

    • Merges new option values into the object the viewer reads from. Most options take effect immediately; engine, engineOptions and initialFit are only consulted at construction, so changing those requires remounting the provider.

      Parameters

      Returns void