@repa/document-viewer 0.0.0-stage → 0.1.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,36 @@
1
+ Repa SDK Pre-Release Evaluation License
2
+
3
+ Copyright (c) 2026 Repa. All rights reserved.
4
+
5
+ Subject to the restrictions below, Repa grants you a limited, revocable,
6
+ non-exclusive, non-transferable, non-sublicensable license to install and use
7
+ this pre-release SDK solely to evaluate Repa and to develop and test
8
+ integrations that communicate with Repa services using credentials you are
9
+ authorized to use.
10
+
11
+ You may not:
12
+
13
+ 1. use the SDK in production or provide it as part of a production service;
14
+ 2. copy, publish, redistribute, sublicense, sell, rent, lease, or otherwise
15
+ make the SDK available to another party;
16
+ 3. modify the SDK, create derivative works from it, or reverse engineer,
17
+ decompile, or disassemble it, except to the limited extent applicable law
18
+ expressly prohibits this restriction;
19
+ 4. use the SDK or information derived from it to create or improve a product
20
+ or service that competes with Repa; or
21
+ 5. remove or alter proprietary notices.
22
+
23
+ Repa and its licensors retain all ownership and intellectual-property rights
24
+ in the SDK. No rights are granted except those stated expressly in this
25
+ license. Access to Repa services remains subject to the applicable service
26
+ terms and may be suspended or terminated independently of this license.
27
+
28
+ This license terminates automatically if you breach it or when Repa replaces
29
+ this pre-release license for the SDK version you use. On termination, you must
30
+ stop using and delete the SDK.
31
+
32
+ THE SDK IS PRE-RELEASE SOFTWARE PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT
33
+ WARRANTIES OR CONDITIONS OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY LAW,
34
+ REPA WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL,
35
+ OR EXEMPLARY DAMAGES, OR FOR LOSS OF DATA, PROFITS, REVENUE, OR BUSINESS,
36
+ ARISING FROM OR RELATED TO THE SDK.
package/README.md CHANGED
@@ -1,3 +1,243 @@
1
- # Temporary Holding Version
1
+ # `@repa/document-viewer`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Read-only browser rendering for immutable DSDX documents. The package provides
4
+ exact-font canvas rendering, fingerprint-bound semantic selection, and
5
+ occurrence-aware geometry for blocks, placeholders, tables, rows, and cells.
6
+
7
+ The framework-neutral API is exported from `@repa/document-viewer`. React
8
+ bindings are available from `@repa/document-viewer/react` and use the same
9
+ runtime. The package contains one separately compiled viewer-only WASM binary;
10
+ it has no editor, mutation, save, history, or persistence capability. The inert
11
+ `@repa/document-viewer/build-info.json` export identifies this exact viewer
12
+ artifact and, when generated by the capability-aware artifact pipeline, records
13
+ its compiled font reader capabilities. It is metadata, not proof that a deployed
14
+ application uses that artifact. Applications must verify its output hashes and
15
+ bind it to their actual deployment; missing capability evidence is unavailable.
16
+
17
+
18
+ The document contract starts at DSDX `1.0.0`, including the embedded font
19
+ closure's `schemaVersion: "1.0.0"`, independently of package releases. Pre-reset
20
+ integer versions are rejected. Supported same-major versions retain their source
21
+ identity and exact font closure; optional extensions are preserved. Unknown
22
+ required rendering features block rendering instead of silently changing output.
23
+ Edit-only requirements do not prevent read-only viewing.
24
+
25
+ ## Framework-neutral use
26
+
27
+ Font delivery is limited to three active reads per document and six across viewer
28
+ instances in the same module. Files retain the closure's exact order. A failed
29
+ read cancels remaining work for that load; a retry starts a fresh load. Each
30
+ source read has a 30 second deadline (`font-read-timeout`); the complete font
31
+ loading phase, including queue time, has a 120 second deadline
32
+ (`font-load-timeout`). Cancellation releases viewer delivery slots even if a
33
+ callback never settles, and late results cannot adopt a cancelled load. Sources
34
+ must forward the supplied abort signal to their transport so the underlying
35
+ network work also stops. These are failure deadlines, not loading performance targets.
36
+
37
+ ```ts
38
+ import { createDocumentViewer } from "@repa/document-viewer";
39
+
40
+ const viewer = await createDocumentViewer({
41
+ container: document.querySelector("#document")!,
42
+ fontFiles: async ({ fileHash, byteLength }, { packageFingerprint, signal }) => {
43
+ // Your application endpoint authenticates its user and proxies server-only
44
+ // documents.fonts.fileBytes for this exact document/version and fingerprint.
45
+ const query = new URLSearchParams({ expectedFingerprint: packageFingerprint });
46
+ const response = await fetch(
47
+ `/documents/${documentId}/versions/${documentVersionId}/fonts/${fileHash}?${query}`,
48
+ { signal, cache: "no-store" },
49
+ );
50
+ if (!response.ok) throw new Error(`Font ${fileHash} is unavailable`);
51
+ const bytes = new Uint8Array(await response.arrayBuffer());
52
+ if (bytes.byteLength !== byteLength)
53
+ throw new Error("Font length mismatch");
54
+ return bytes;
55
+ },
56
+ onSelectionChange: ({ selection, structures }) => {
57
+ console.log(selection?.text, structures?.blocks);
58
+ },
59
+ onPointerTargetChange: ({ target, input }) => {
60
+ console.log(input.pointerType, target?.selectableText, target?.structures);
61
+ },
62
+ resolvePointerCursor: ({ target }) =>
63
+ target.structures.placeholders.length > 0 ? "pointer" : undefined,
64
+ onStructureSelectionChange: ({ selection }) => {
65
+ if (selection?.kind === "block") console.log(selection.target.blockId);
66
+ },
67
+ });
68
+
69
+ await viewer.load(dsdxBytes);
70
+
71
+ // Application-owned canonical coordinates can drive selection without using
72
+ // geometry as authority. Text and rectangles are recomputed by the viewer.
73
+ const saved = viewer.selection();
74
+ if (saved) {
75
+ viewer.selectRanges({
76
+ packageFingerprint: saved.packageFingerprint,
77
+ ranges: saved.ranges,
78
+ direction: saved.direction,
79
+ });
80
+ }
81
+
82
+ // Text ranges and whole structures are separate interaction modes.
83
+ viewer.setSelectionMode("block");
84
+ viewer.setSelectionMode("table");
85
+ viewer.setSelectionMode("row");
86
+ viewer.setSelectionMode("cell");
87
+ viewer.setSelectionMode("text");
88
+ ```
89
+
90
+ The host owns document/font transport, authorization, caching, storage, and
91
+ persistence. On a repa server integration, obtain an exact authorized version
92
+ with server-only `@repa/client`. First select ready version metadata using
93
+ `documents.versions.get` and require its non-null fingerprint:
94
+
95
+ ```ts
96
+ const selectedVersion = await repa.documents.versions.get({
97
+ projectId,
98
+ documentId,
99
+ documentVersionId,
100
+ });
101
+ if (selectedVersion.processing.status !== "ready" || !selectedVersion.fingerprint) {
102
+ throw new Error("The selected document version is not ready.");
103
+ }
104
+ const bytes = await repa.documents.packageBytes({
105
+ projectId,
106
+ documentId,
107
+ documentVersionId,
108
+ expectedFingerprint: selectedVersion.fingerprint,
109
+ });
110
+ ```
111
+
112
+ Stream or proxy those bytes through an application endpoint. Never put the
113
+ repa API key or `@repa/client` in a browser bundle. The viewer's font callback
114
+ receives exact content hashes and byte lengths from the DSDX closure; it cannot
115
+ substitute a family or system font.
116
+
117
+ The viewer observes container resizes and repaints at the active device pixel
118
+ ratio. Use `setZoom`, `setDevicePixelRatio`, `resize`, and `scrollToPage` when a
119
+ host needs explicit viewport control. These operations change presentation
120
+ only; canonical selection and structure coordinates remain in page points.
121
+ Browser and trackpad zoom gestures remain browser-owned even when they begin
122
+ over the viewer. Applications should expose explicit controls for viewer zoom
123
+ and update the controlled React `zoom` value from those controls.
124
+
125
+ Pointer target events combine browser-owned input metadata (`mouse`, `pen`,
126
+ `touch`, buttons, primary-pointer state, and modifiers) with one WASM-resolved
127
+ semantic target. The target reports whether text is directly selectable and
128
+ the occurrence-aware structures under that page-space point. The viewer uses
129
+ an I-beam over selectable text and the default cursor elsewhere; return a
130
+ different closed `DocumentPointerCursor` from `resolvePointerCursor` for
131
+ application-specific targets such as placeholders. A null target is emitted
132
+ when the pointer leaves. Secondary clicks and non-primary pointers do not start
133
+ selection, and structure hover is suspended while a selection drag owns pointer
134
+ capture.
135
+ In text mode, a drag beginning in page whitespace resolves to the nearest
136
+ visible text line rather than an empty drawing/layout paragraph, so dragging
137
+ from before the first glyph still creates the expected canonical range.
138
+
139
+ `text` is the default selection mode and produces canonical semantic text
140
+ ranges suitable for placeholder authoring. `block`, `table`, `row`, and `cell`
141
+ modes activate the smallest matching semantic structure and emit
142
+ `onStructureSelectionChange`; they do not manufacture a text range or a
143
+ placeholder. Structure geometry is highlighted for presentation, while the
144
+ application remains responsible for assigning a stable alias before using a
145
+ structure in a show/hide/repeat contract. A selected projection block includes
146
+ `sourceBlockId` or `sourceTableId` when it maps to a canonical DSDX structure;
147
+ use that source identity only as the input to the alias-assignment project,
148
+ not as a persisted contract target. Use `selectionMode` in React or
149
+ `setSelectionMode` on the imperative viewer to switch modes at runtime.
150
+
151
+ The host owns viewport dimensions and scrolling. Give the element surrounding
152
+ the viewer a bounded block size plus `overflow: auto`; the rendered page keeps
153
+ its zoomed dimensions so the host can provide horizontal and vertical
154
+ scrollbars without clipping or scaling the canonical canvas.
155
+
156
+ ## React / Next.js client component
157
+
158
+ ```tsx
159
+ "use client";
160
+
161
+ import { useState } from "react";
162
+ import { DocumentViewerCanvas } from "@repa/document-viewer/react";
163
+
164
+ export function ContractDocument({ bytes }: { bytes: Uint8Array }) {
165
+ const [zoom, setZoom] = useState(1);
166
+ return (
167
+ <section>
168
+ <div role="group" aria-label="Document zoom">
169
+ <button onClick={() => setZoom((value) => Math.max(0.6, value - 0.1))}>
170
+ Zoom out
171
+ </button>
172
+ <button onClick={() => setZoom(1)}>Reset zoom</button>
173
+ <button onClick={() => setZoom((value) => Math.min(2, value + 0.1))}>
174
+ Zoom in
175
+ </button>
176
+ </div>
177
+ <DocumentViewerCanvas
178
+ bytes={bytes}
179
+ selectionMode="block"
180
+ zoom={zoom}
181
+ minimumZoom={0.6}
182
+ maximumZoom={2}
183
+ fontFiles={async ({ fileHash }, { signal }) => {
184
+ const response = await fetch(`/api/fonts/${fileHash}`, { signal });
185
+ return new Uint8Array(await response.arrayBuffer());
186
+ }}
187
+ onSelectionChange={({ selection, structures }) => {
188
+ // Application-owned contract or placeholder actions belong here.
189
+ console.log(selection, structures);
190
+ }}
191
+ onPointerTargetChange={({ target, input }) => {
192
+ console.log(input.pointerType, target);
193
+ }}
194
+ resolvePointerCursor={({ target }) =>
195
+ target.structures.placeholders.length ? "pointer" : undefined
196
+ }
197
+ onStructureSelectionChange={({ selection }) => {
198
+ console.log(selection);
199
+ }}
200
+ />
201
+ </section>
202
+ );
203
+ }
204
+ ```
205
+
206
+ Use a Next.js Route Handler to fetch `packageBytes` with server-held
207
+ credentials and return `application/vnd.devcited.dsdx+zip`. Browser components
208
+ receive bytes only.
209
+
210
+ ## Semantic authority versus geometry
211
+
212
+ `DocumentSelection.packageFingerprint` and its ordered paragraph-local
213
+ `ranges[]` are authoritative. Each range contains canonical paragraph/story and
214
+ layout-occurrence identity plus UTF-8 byte offsets and caret affinity (`Upstream`
215
+ or `Downstream`, matching the engine's serialized values). Use these
216
+ values with the exact snapshot to construct a `@repa/dsdx` transaction.
217
+
218
+ `selection.geometry`, structure rectangles, and hit-test coordinates are
219
+ presentation data. Use them for highlights, hover targets, menus, and overlays;
220
+ never use a rectangle as a mutation or contract target. Restoring a selection
221
+ against another package fails with a `DocumentViewerError` whose code is
222
+ `stale-snapshot`.
223
+
224
+ Use `selectRanges` when a contract-manager or search result already has
225
+ fingerprint-bound canonical ranges. Use `restoreSelection` for a complete
226
+ selection previously emitted by the engine. Both paths fail closed on a stale
227
+ fingerprint and recompute the current text and geometry.
228
+
229
+ `DocumentSemanticSurface` is the common read seam for contract-manager code:
230
+ snapshot identity, selection, structures, occurrence identity, and page-space
231
+ geometry. A future separately published `@repa/document-editor` will implement
232
+ the same seam and add mutations in its own package and WASM binary. It is not
233
+ included here.
234
+
235
+ Call `dispose()` when an imperative viewer is unmounted. The React binding does
236
+ this automatically.
237
+
238
+ The application font proxy calls `documents.fonts.fileBytes` with the callback's
239
+ `packageFingerprint`, exact document/version, requested hash, and
240
+ `purpose: "previewPrint"`. It returns private, non-cacheable bytes and authorizes
241
+ its own user; a font hash alone grants no access. This path supports eligible
242
+ embedded fonts as well as published closure members. A stale fingerprint must
243
+ remain a selection conflict, not silently refresh the viewer's document.
@@ -0,0 +1,250 @@
1
+ interface DocumentFontFileRequirement {
2
+ readonly fileHash: string;
3
+ readonly byteLength: number;
4
+ }
5
+ interface DocumentFontRequirements {
6
+ readonly packageFingerprint: string;
7
+ readonly fontClosureSha256: string;
8
+ readonly fontReleaseDigest: string;
9
+ readonly files: readonly DocumentFontFileRequirement[];
10
+ }
11
+ interface DocumentFontRequestContext {
12
+ readonly packageFingerprint: string;
13
+ readonly signal: AbortSignal;
14
+ }
15
+ type DocumentViewerFontSource = (requirement: DocumentFontFileRequirement, context: DocumentFontRequestContext) => Promise<Uint8Array>;
16
+ interface DocumentPageSnapshot {
17
+ readonly pageIndex: number;
18
+ readonly widthPt: number;
19
+ readonly heightPt: number;
20
+ }
21
+ interface DocumentViewerSnapshot {
22
+ readonly packageFingerprint: string;
23
+ readonly fontClosureSha256: string;
24
+ readonly fontReleaseDigest: string;
25
+ readonly pageCount: number;
26
+ readonly pageWidthPt: number;
27
+ readonly pageHeightPt: number;
28
+ readonly pages: readonly DocumentPageSnapshot[];
29
+ }
30
+ type DocumentCaretAffinity = "Upstream" | "Downstream";
31
+ type DocumentSelectionDirection = "forward" | "backward";
32
+ interface DocumentSemanticRange {
33
+ readonly paragraphId: string;
34
+ readonly storyKind: string;
35
+ readonly layoutOccurrenceId: string;
36
+ readonly startByte: number;
37
+ readonly endByte: number;
38
+ readonly startAffinity: DocumentCaretAffinity;
39
+ readonly endAffinity: DocumentCaretAffinity;
40
+ }
41
+ interface DocumentRect {
42
+ readonly pageIndex: number;
43
+ readonly xPt: number;
44
+ readonly yPt: number;
45
+ readonly widthPt: number;
46
+ readonly heightPt: number;
47
+ }
48
+ interface DocumentSelectionGeometry {
49
+ readonly rects: readonly DocumentRect[];
50
+ readonly caret: DocumentRect | null;
51
+ readonly generation: number;
52
+ }
53
+ interface DocumentSelection {
54
+ readonly packageFingerprint: string;
55
+ readonly ranges: readonly DocumentSemanticRange[];
56
+ readonly direction: DocumentSelectionDirection;
57
+ readonly text: string;
58
+ readonly geometry: DocumentSelectionGeometry;
59
+ }
60
+ /**
61
+ * Canonical application-owned coordinates for programmatic selection. Text
62
+ * and geometry are intentionally recomputed by the exact viewer runtime.
63
+ */
64
+ interface DocumentSelectionTarget {
65
+ readonly packageFingerprint: string;
66
+ readonly ranges: readonly DocumentSemanticRange[];
67
+ readonly direction?: DocumentSelectionDirection;
68
+ }
69
+ interface DocumentBlockGeometry {
70
+ readonly blockId: string;
71
+ readonly sourceBlockId: string | null;
72
+ readonly sourceTableId: string | null;
73
+ readonly partId: string;
74
+ readonly kind: string;
75
+ readonly order: number;
76
+ readonly layoutOccurrenceId: string;
77
+ readonly rects: readonly DocumentRect[];
78
+ }
79
+ interface DocumentPlaceholderGeometry {
80
+ readonly occurrenceId: string;
81
+ readonly canonicalKey: string;
82
+ readonly partId: string;
83
+ readonly blockId: string | null;
84
+ readonly paragraphId: string | null;
85
+ readonly storyKind: string | null;
86
+ readonly layoutOccurrenceId: string | null;
87
+ readonly rawText: string;
88
+ readonly rects: readonly DocumentRect[];
89
+ }
90
+ interface DocumentRowGeometry {
91
+ readonly rowId: string | null;
92
+ readonly sourceRowIndex: number;
93
+ readonly layoutRowIndex: number;
94
+ readonly layoutOccurrenceId: string;
95
+ readonly repeatedHeaderOrdinal: number | null;
96
+ readonly rect: DocumentRect;
97
+ }
98
+ interface DocumentCellGeometry {
99
+ readonly cellId: string;
100
+ readonly rowId: string | null;
101
+ readonly sourceRowIndex: number;
102
+ readonly startColumnIndex: number;
103
+ readonly endColumnIndex: number;
104
+ readonly layoutOccurrenceId: string;
105
+ readonly repeatedHeaderOrdinal: number | null;
106
+ readonly paragraphIds: readonly string[];
107
+ readonly rect: DocumentRect;
108
+ readonly contentRect: DocumentRect;
109
+ }
110
+ interface DocumentTableOccurrenceGeometry {
111
+ readonly layoutOccurrenceId: string;
112
+ readonly pageIndex: number;
113
+ readonly storyKind: string;
114
+ readonly sourceStartRowIndex: number;
115
+ readonly sourceEndRowIndex: number;
116
+ readonly rect: DocumentRect;
117
+ readonly rows: readonly DocumentRowGeometry[];
118
+ readonly cells: readonly DocumentCellGeometry[];
119
+ }
120
+ interface DocumentTableGeometry {
121
+ readonly tableId: string;
122
+ readonly occurrences: readonly DocumentTableOccurrenceGeometry[];
123
+ }
124
+ interface DocumentStructureIndex {
125
+ readonly packageFingerprint: string;
126
+ readonly blocks: readonly DocumentBlockGeometry[];
127
+ readonly placeholders: readonly DocumentPlaceholderGeometry[];
128
+ readonly tables: readonly DocumentTableGeometry[];
129
+ }
130
+ interface DocumentStructureMatches {
131
+ readonly packageFingerprint: string;
132
+ readonly blocks: readonly DocumentBlockGeometry[];
133
+ readonly placeholders: readonly DocumentPlaceholderGeometry[];
134
+ readonly tables: readonly DocumentTableGeometry[];
135
+ readonly rows: readonly DocumentRowGeometry[];
136
+ readonly cells: readonly DocumentCellGeometry[];
137
+ }
138
+ type DocumentStructureSelectionKind = "block" | "table" | "row" | "cell";
139
+ type DocumentSelectionMode = "text" | DocumentStructureSelectionKind;
140
+ type DocumentStructureSelection = {
141
+ readonly packageFingerprint: string;
142
+ readonly kind: "block";
143
+ readonly target: DocumentBlockGeometry;
144
+ readonly geometry: readonly DocumentRect[];
145
+ } | {
146
+ readonly packageFingerprint: string;
147
+ readonly kind: "table";
148
+ readonly target: DocumentTableGeometry;
149
+ readonly geometry: readonly DocumentRect[];
150
+ } | {
151
+ readonly packageFingerprint: string;
152
+ readonly kind: "row";
153
+ readonly target: DocumentRowGeometry;
154
+ readonly geometry: readonly DocumentRect[];
155
+ } | {
156
+ readonly packageFingerprint: string;
157
+ readonly kind: "cell";
158
+ readonly target: DocumentCellGeometry;
159
+ readonly geometry: readonly DocumentRect[];
160
+ };
161
+ interface DocumentPoint {
162
+ readonly pageIndex: number;
163
+ readonly xPt: number;
164
+ readonly yPt: number;
165
+ }
166
+ type DocumentPointerType = "mouse" | "pen" | "touch" | "unknown";
167
+ interface DocumentPointerInput {
168
+ readonly pointerType: DocumentPointerType;
169
+ readonly isPrimary: boolean;
170
+ readonly buttons: number;
171
+ readonly modifiers: {
172
+ readonly alt: boolean;
173
+ readonly control: boolean;
174
+ readonly meta: boolean;
175
+ readonly shift: boolean;
176
+ };
177
+ }
178
+ type DocumentPointerCursor = "auto" | "default" | "text" | "pointer" | "crosshair" | "cell" | "grab" | "grabbing" | "col-resize" | "row-resize";
179
+ interface DocumentPointerTarget {
180
+ readonly packageFingerprint: string;
181
+ readonly point: DocumentPoint;
182
+ readonly selectableText: boolean;
183
+ readonly structures: DocumentStructureMatches;
184
+ }
185
+ interface DocumentPointerTargetChangeEvent {
186
+ readonly target: DocumentPointerTarget | null;
187
+ readonly input: DocumentPointerInput;
188
+ }
189
+ interface DocumentSelectionChangeEvent {
190
+ readonly selection: DocumentSelection | null;
191
+ readonly structures: DocumentStructureMatches | null;
192
+ readonly input: DocumentPointerInput | null;
193
+ }
194
+ interface DocumentStructureSelectionChangeEvent {
195
+ readonly selection: DocumentStructureSelection | null;
196
+ readonly input: DocumentPointerInput | null;
197
+ }
198
+ interface DocumentViewerOptions {
199
+ readonly container: HTMLElement;
200
+ readonly fontFiles: DocumentViewerFontSource;
201
+ readonly initialZoom?: number;
202
+ readonly minimumZoom?: number;
203
+ readonly maximumZoom?: number;
204
+ readonly devicePixelRatio?: number;
205
+ readonly initialSelectionMode?: DocumentSelectionMode;
206
+ readonly onSelectionChange?: (event: DocumentSelectionChangeEvent) => void;
207
+ readonly onStructureSelectionChange?: (event: DocumentStructureSelectionChangeEvent) => void;
208
+ readonly onPointerTargetChange?: (event: DocumentPointerTargetChangeEvent) => void;
209
+ readonly resolvePointerCursor?: (event: DocumentPointerTargetChangeEvent & {
210
+ readonly target: DocumentPointerTarget;
211
+ }) => DocumentPointerCursor | undefined;
212
+ readonly onError?: (error: DocumentViewerError) => void;
213
+ }
214
+ /**
215
+ * Framework- and capability-neutral semantic surface. Application layers such
216
+ * as a contract manager can consume this interface from either a viewer or a
217
+ * future editor without depending on either concrete runtime.
218
+ */
219
+ interface DocumentSemanticSurface {
220
+ readonly snapshot: DocumentViewerSnapshot | null;
221
+ selectionMode(): DocumentSelectionMode;
222
+ setSelectionMode(mode: DocumentSelectionMode): void;
223
+ selection(): DocumentSelection | null;
224
+ structureSelection(): DocumentStructureSelection | null;
225
+ selectRanges(target: DocumentSelectionTarget): DocumentSelection;
226
+ restoreSelection(selection: DocumentSelection): DocumentSelection;
227
+ clearSelection(): void;
228
+ structures(): DocumentStructureIndex;
229
+ hitTestPointerTarget(point: DocumentPoint): DocumentPointerTarget;
230
+ hitTestStructures(point: DocumentPoint): DocumentStructureMatches;
231
+ structuresForSelection(): DocumentStructureMatches;
232
+ }
233
+ interface DocumentViewer extends DocumentSemanticSurface {
234
+ load(bytes: Uint8Array): Promise<DocumentViewerSnapshot>;
235
+ zoom(): number;
236
+ setZoom(zoom: number): void;
237
+ setDevicePixelRatio(devicePixelRatio: number): void;
238
+ resize(): void;
239
+ scrollToPage(pageIndex: number): void;
240
+ dispose(): void;
241
+ }
242
+ declare class DocumentViewerError extends Error {
243
+ readonly code: string;
244
+ readonly cause: unknown;
245
+ constructor(code: string, message: string, cause?: unknown);
246
+ }
247
+
248
+ declare function createDocumentViewer(options: DocumentViewerOptions): Promise<DocumentViewer>;
249
+
250
+ export { type DocumentBlockGeometry, type DocumentCaretAffinity, type DocumentCellGeometry, type DocumentFontFileRequirement, type DocumentFontRequestContext, type DocumentFontRequirements, type DocumentPageSnapshot, type DocumentPlaceholderGeometry, type DocumentPoint, type DocumentPointerCursor, type DocumentPointerInput, type DocumentPointerTarget, type DocumentPointerTargetChangeEvent, type DocumentPointerType, type DocumentRect, type DocumentRowGeometry, type DocumentSelection, type DocumentSelectionChangeEvent, type DocumentSelectionDirection, type DocumentSelectionGeometry, type DocumentSelectionMode, type DocumentSelectionTarget, type DocumentSemanticRange, type DocumentSemanticSurface, type DocumentStructureIndex, type DocumentStructureMatches, type DocumentStructureSelection, type DocumentStructureSelectionChangeEvent, type DocumentStructureSelectionKind, type DocumentTableGeometry, type DocumentTableOccurrenceGeometry, type DocumentViewer, DocumentViewerError, type DocumentViewerFontSource, type DocumentViewerOptions, type DocumentViewerSnapshot, createDocumentViewer };