@embedpdf/plugin-annotation 3.0.0-next.8 → 3.0.0

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.
Files changed (42) hide show
  1. package/README.md +129 -0
  2. package/dist/authoring.cjs +26 -0
  3. package/dist/authoring.d.cts +2 -0
  4. package/dist/authoring.d.ts +2 -0
  5. package/dist/authoring.js +2 -0
  6. package/dist/contract/host.cjs +19 -0
  7. package/dist/contract/host.d.cts +3 -0
  8. package/dist/contract/host.d.ts +3 -0
  9. package/dist/contract/host.js +3 -0
  10. package/dist/contract-BK2g1Rem.d.ts +1169 -0
  11. package/dist/contract-BtAl3Yo2.cjs +692 -0
  12. package/dist/contract-BtAl3Yo2.cjs.map +1 -0
  13. package/dist/contract-CBYEqnev.d.cts +1169 -0
  14. package/dist/contract-OwgW3JE8.js +651 -0
  15. package/dist/contract-OwgW3JE8.js.map +1 -0
  16. package/dist/contract.cjs +13 -0
  17. package/dist/contract.d.cts +2 -0
  18. package/dist/contract.d.ts +2 -0
  19. package/dist/contract.js +2 -0
  20. package/dist/host-contract-BzM2upsA.cjs +87 -0
  21. package/dist/host-contract-BzM2upsA.cjs.map +1 -0
  22. package/dist/host-contract-COF2Prd-.d.ts +335 -0
  23. package/dist/host-contract-CSKiuu3g.js +52 -0
  24. package/dist/host-contract-CSKiuu3g.js.map +1 -0
  25. package/dist/host-contract-CxOrR_pp.d.cts +335 -0
  26. package/dist/index.cjs +5434 -419
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +13 -59
  29. package/dist/index.d.ts +13 -59
  30. package/dist/index.js +5386 -398
  31. package/dist/index.js.map +1 -1
  32. package/package.json +24 -11
  33. package/dist/capability-2FkTVblD.cjs +0 -2806
  34. package/dist/capability-2FkTVblD.cjs.map +0 -1
  35. package/dist/capability-BNMRdnKf.js +0 -2741
  36. package/dist/capability-BNMRdnKf.js.map +0 -1
  37. package/dist/internal.cjs +0 -5
  38. package/dist/internal.d.cts +0 -13
  39. package/dist/internal.d.ts +0 -13
  40. package/dist/internal.js +0 -2
  41. package/dist/types-CvtDbnF5.d.cts +0 -912
  42. package/dist/types-Dy1RganE.d.ts +0 -912
@@ -0,0 +1,1169 @@
1
+ import { BatchResult, DeepPartial, EventHook, EventOrigin, OperationOptions, PluginErrorInfo, ResourceStatus, SettingsApi, Unsubscribe } from "@embedpdf/core";
2
+ import { MountableFontProgram } from "@embedpdf/plugin-fonts/contract";
3
+ import { AnnotationTransfer } from "@embedpdf/engine-core/public";
4
+ import { Annotation, Annotation as Annotation$1, AnnotationBundle, AnnotationBundle as AnnotationBundle$1, AnnotationDraft, AnnotationDraft as AnnotationDraft$1, AnnotationImportDrop, AnnotationImportDrop as AnnotationImportDrop$1, AnnotationImportOptions, AnnotationImportOptions as AnnotationImportOptions$1, AnnotationPatch, AnnotationPatch as AnnotationPatch$1, AnnotationPosition, AnnotationPosition as AnnotationPosition$1, AnnotationRef, AnnotationRef as AnnotationRef$1, AnnotationResourceRole, AnnotationResourceRole as AnnotationResourceRole$1, AnnotationResources, AnnotationResources as AnnotationResources$1, AnnotationSubtype, AnnotationSubtype as AnnotationSubtype$1, AttachmentContent, AttachmentFileSource, AttachmentFileSource as AttachmentFileSource$1, BinarySource, Color, CommentThread, CommentThread as CommentThread$1, CommentThreadReview, PageRef, PdfActionTree, PdfLinkTarget, PdfLinkTarget as PdfLinkTarget$1, ReviewStatus, RichTextBody, RichTextParagraph, WidgetAppearance } from "@embedpdf/engine-core/runtime";
5
+ import { AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationOption, AnnotationProperty, AnnotationProperty as AnnotationProperty$1, BlendMode, ClickCreate, ClickCreate as ClickCreate$1, CreationDraftAnchor, EditableKind, EditableKinds, EditableKinds as EditableKinds$1, FieldValues, FieldValues as FieldValues$1, FlagKey, HandleRole, InkStraightenOptions, KindName, LineEnding, LineEndings, MeasurementIntent, Rect, RichTextRange, RichTextStyleDelta, RotationAnchor, SnapSettings, SnapSettings as SnapSettings$1, TextAlign, ViewEnv } from "@embedpdf/core-annotation";
6
+ import "@embedpdf/plugin-interaction/contract";
7
+ import { Point as Point$1 } from "@embedpdf/core-geometry";
8
+ //#region src/rich-text.d.ts
9
+ type TextFormat = 'bold' | 'italic' | 'underline';
10
+ /** The editor's selection inside one free-text annotation: flat offsets over
11
+ * the plain projection (paragraphs joined by `\n`). */
12
+ interface TextSelection extends RichTextRange {
13
+ id: string;
14
+ }
15
+ /**
16
+ * The editor's selection as the plugin keeps it: at a caret, with the style
17
+ * chosen there for the text typed next. A selection that moves is a new one,
18
+ * without it.
19
+ */
20
+ interface EditorSelection extends TextSelection {
21
+ readonly typing?: RichTextStyleDelta;
22
+ }
23
+ /** The face a run or a body names. */
24
+ interface Face {
25
+ family: string;
26
+ weight?: number;
27
+ italic?: boolean;
28
+ }
29
+ //#endregion
30
+ //#region src/tools/definitions.d.ts
31
+ /**
32
+ * How a stamp-family tool resolves the image bytes it places — pure data, so a
33
+ * tool table stays JSON-serializable (config can come from a file, a DB, or the
34
+ * server). Evaluated at click time, so the user picks the spot first, then the
35
+ * source:
36
+ * - `{ kind: 'bytes' }` — fixed bytes: a company rubber-stamp.
37
+ * - `{ kind: 'prompt' }` — ask the environment for bytes. The plugin does not
38
+ * know how (a file dialog is DOM); the file-picker port (`FilePickerProvider`),
39
+ * installed by the framework adapter, fulfils it. Resolve `null` there to cancel.
40
+ */
41
+ type StampSourceSpec = {
42
+ kind: 'bytes';
43
+ source: BinarySource;
44
+ } | PromptSourceSpec;
45
+ /**
46
+ * The ask-the-environment resolution, shared by every click-then-pick tool
47
+ * (a stamp's `'prompt'` source, the file-attachment tool). `accept` is the
48
+ * file-dialog filter the picker request carries — a UX hint only, the engine
49
+ * sniffs/validates the bytes for real. Unset = any file.
50
+ */
51
+ interface PromptSourceSpec {
52
+ kind: 'prompt';
53
+ accept?: string;
54
+ }
55
+ /**
56
+ * The tool `stamps.arm` activates — and the only tool an armed payload survives
57
+ * onto (plus the legacy `annotation-stamp` tag, honoured for embedder configs
58
+ * written before the tags were unified). Placement consults the armed payload
59
+ * before the active tool's own `source` spec, so a payload must not outlive
60
+ * its tool onto a sibling stamp preset: an `image` preset's click has to open
61
+ * its own picker, not silently place whatever the stamp panel last armed.
62
+ */
63
+ declare const ARMED_STAMP_TOOL_ID = "stamp";
64
+ /** Declarative result of committing a text selection while a tool is active. */
65
+ type SelectionAuthoring = {
66
+ kind: 'markup';
67
+ } | {
68
+ kind: 'text-edit';
69
+ operation: 'insert' | 'replace';
70
+ };
71
+ /**
72
+ * The tool's ghost: a see-through copy of what a click would place, following
73
+ * the pointer, drawn with the tool's current defaults exactly where and as
74
+ * the click will make it. `true` shows it half see-through, `{ opacity }`
75
+ * as opaque as you say (0–1; `--epdf-ghost-opacity` wins over it from CSS),
76
+ * `false` hides it. It shows only where a click creates: a tool whose click
77
+ * makes nothing (ink, a polygon, `clickCreate: false`) has none, and it hides
78
+ * over an annotation or text, where the click does something else.
79
+ * The cursor says which tool is active; the ghost says where the click lands.
80
+ */
81
+ type GhostPolicy = boolean | {
82
+ opacity: number;
83
+ };
84
+ /** A resolved ghost: how opaque it paints, or `false` for none. */
85
+ type ResolvedGhost = false | {
86
+ opacity: number;
87
+ };
88
+ /** Time/geometry policy for freehand ink authoring. */
89
+ interface InkAuthoringOptions {
90
+ /** Group strokes made within this interval into one `/InkList`; 0 commits immediately. */
91
+ groupStrokesMs?: number;
92
+ /** Optional pure straight-line recognition applied to each completed stroke. */
93
+ straighten?: InkStraightenOptions;
94
+ }
95
+ /**
96
+ * The fields no tool's defaults may set: where the annotation goes (that comes
97
+ * from the drawing), its identity and relationships, and what the engine
98
+ * stamps or keeps by itself.
99
+ */
100
+ declare const NOT_DEFAULTS: readonly ["ref", "page", "index", "hasAppearance", "appearanceState", "nm", "rect", "box", "linePoints", "vertices", "inkList", "quadPoints", "calloutLine", "captionCenter", "measure", "reply", "popup", "parent", "groupId", "author", "createdAt", "modifiedAt", "userId", "createdBy", "modifiedBy", "importedBy", "actions"];
101
+ type NotDefault = (typeof NOT_DEFAULTS)[number];
102
+ /**
103
+ * The fields each known authoring kind's defaults may set: any field a create
104
+ * from the tool takes besides where it goes, flags and `contents` included.
105
+ * A key outside it stops the app at startup, naming the tool and the field.
106
+ */
107
+ declare const TOOL_DEFAULT_FIELDS: {
108
+ readonly square: readonly string[];
109
+ readonly circle: readonly string[];
110
+ readonly line: readonly string[];
111
+ readonly polygon: readonly string[];
112
+ readonly polyline: readonly string[];
113
+ readonly ink: readonly string[];
114
+ readonly 'free-text': readonly string[];
115
+ readonly 'free-text-callout': readonly string[];
116
+ readonly highlight: readonly string[];
117
+ readonly underline: readonly string[];
118
+ readonly strikeout: readonly string[];
119
+ readonly squiggly: readonly string[];
120
+ readonly caret: readonly string[];
121
+ readonly redact: readonly string[];
122
+ readonly stamp: readonly string[];
123
+ readonly link: readonly string[];
124
+ readonly text: readonly string[];
125
+ readonly 'file-attachment': readonly string[];
126
+ readonly 'widget-text': readonly ["color", "interiorColor", "strokeWidth", "borderStyle", "fontFamily", "fontSize", "fontColor", "textAlign"];
127
+ readonly 'widget-choice': readonly ["color", "interiorColor", "strokeWidth", "borderStyle", "fontFamily", "fontSize", "fontColor", "textAlign"];
128
+ readonly 'widget-button': readonly ["color", "interiorColor", "strokeWidth", "borderStyle", "fontFamily", "fontSize", "fontColor", "textAlign"];
129
+ readonly 'widget-toggle': readonly ["color", "interiorColor", "strokeWidth", "borderStyle"];
130
+ readonly 'widget-radio': readonly ["color", "interiorColor", "strokeWidth", "borderStyle"];
131
+ readonly 'widget-box': readonly ["color", "interiorColor", "strokeWidth", "borderStyle"];
132
+ };
133
+ type ToolAuthoringKind = keyof typeof TOOL_DEFAULT_FIELDS;
134
+ /** The draft a kind's creates are: a callout is a free text; a form tool's kind is a widget's appearance. */
135
+ type ToolDraftOf<K extends ToolAuthoringKind> = K extends `widget-${string}` ? Partial<Pick<WidgetAppearance, (typeof TOOL_DEFAULT_FIELDS)[K][number] & keyof WidgetAppearance>> : Omit<Partial<Extract<AnnotationDraft, {
136
+ subtype: K extends 'free-text-callout' ? 'free-text' : K;
137
+ }>>, NotDefault | 'subtype' | 'richText'>;
138
+ /** A tool's rich text is its body: the formatting what it types starts with. */
139
+ type ToolRichText = {
140
+ richText?: {
141
+ body: Partial<RichTextBody>;
142
+ };
143
+ };
144
+ /**
145
+ * The defaults a tool of kind `K` takes: any field of what it draws, flags
146
+ * included, except where it goes (`box`, `rect`, points), which the drawing
147
+ * gives.
148
+ */
149
+ type ToolDefaultsFor<K extends ToolAuthoringKind> = ToolDraftOf<K> & (K extends 'free-text' | 'free-text-callout' ? ToolRichText : unknown);
150
+ /**
151
+ * A tool definition — the public config vocabulary. Every field except `id` is
152
+ * optional: the common cases are "configure a built-in" (`{ id, defaults }`) and
153
+ * "add a preset" (`{ id, extends, defaults }`).
154
+ */
155
+ interface AnnotationToolDefinition<K extends ToolAuthoringKind = ToolAuthoringKind> {
156
+ /** Stable tool id — the value passed to `activateTool` and the `defaults` key. */
157
+ id: string;
158
+ /** Inherit `subtype` / `fieldsKind` / `cursor` / `enables` / `source` /
159
+ * `selection` / `intent` / `ink` / `meta`
160
+ * from an existing tool id (a built-in or another entry). Own fields win. */
161
+ extends?: string;
162
+ /** The routing kind this tool authors — the core's client kind (the geometry
163
+ * it draws + the props key). Usually the PDF subtype, but not always:
164
+ * `free-text-callout` routes the callout gesture onto a free-text
165
+ * annotation, and `widget-text`/`widget-choice`/`widget-toggle`/`widget-radio` are client
166
+ * views of the one PDF `widget` subtype (a form tool's commit goes through
167
+ * `doc.forms`, never this plugin — see the form plugin's tool table).
168
+ * Defaults to the inherited kind, or the id when neither is given. */
169
+ subtype?: KindName;
170
+ /** The kind whose editable fields a style panel shows for this tool.
171
+ * Defaults to `subtype`. */
172
+ fieldsKind?: string;
173
+ /** Advanced: the `defaults` key this tool reads/writes. Defaults to the id, and
174
+ * that is almost always right — override it only to alias a shared defaults bag
175
+ * (the built-in insert-caret tool points its preset at the `caret` key). */
176
+ preset?: string;
177
+ /** The engine fields what the tool draws takes, besides its shape: a draft
178
+ * without its shape, merged over any inherited defaults (each value whole).
179
+ * The engine's defaults fill in what they leave out. */
180
+ defaults?: ToolDefaultsFor<K>;
181
+ /**
182
+ * `/F` annotation flags seeded on everything this tool creates, merged over
183
+ * the drawn default (`print` set — Acrobat parity) and any inherited seed.
184
+ * A note tool passes `{ noZoom: true, noRotate: true }` so its icons stay
185
+ * screen-sized and upright (the spec's rule for Text annotations).
186
+ */
187
+ flags?: Partial<AnnotationFlags>;
188
+ /** The pointer cursor while this tool is active. Defaults inherited / `crosshair`. */
189
+ cursor?: string;
190
+ /** Interaction capability tags this tool enables (which handlers wake up). */
191
+ enables?: string[];
192
+ /**
193
+ * How the click-to-place payload resolves. Stamps take the full spec
194
+ * ({@link StampSourceSpec}: fixed bytes or prompt); file attachments are
195
+ * prompt-only ({@link PromptSourceSpec} — the file always comes from the
196
+ * environment). Other kinds carry no payload.
197
+ */
198
+ source?: K extends 'stamp' ? StampSourceSpec : K extends 'file-attachment' ? PromptSourceSpec : never;
199
+ /** What a committed text selection authors. Omit for pointer/click tools. */
200
+ selection?: SelectionAuthoring;
201
+ /** Ink-only stroke grouping and straightening policy. */
202
+ ink?: K extends 'ink' ? InkAuthoringOptions : never;
203
+ /**
204
+ * Place annotations upright: counter-rotate what this tool creates against the
205
+ * page's total display rotation (document /Rotate + any stage view rotation),
206
+ * so it reads horizontally exactly as the author saw it — Adobe's behaviour
207
+ * for stamps and text on rotated pages. WYSIWYG at authoring time: the
208
+ * rotation is baked into the annotation, so a save keeps what the author saw
209
+ * (other viewers apply only /Rotate — document that when view rotation is in
210
+ * play). A drawing without a reading direction bakes no turn: a clicked
211
+ * square or circle swaps its sides instead, so it shows its `clickCreate`
212
+ * size as the author sees the page, and a clicked line points the way its
213
+ * `clickCreate` says there; a drag, and a callout's leader, follow the
214
+ * pointer. Default: on for the built-in `stamp`, `free-text`, `note`,
215
+ * `attachment`, `square`, `circle` and `line` tools, off elsewhere.
216
+ */
217
+ upright?: boolean;
218
+ /**
219
+ * What a bare click creates ({@link ClickCreate}): a default-size shape
220
+ * centred on the point, a default-length line centred on it, free text's
221
+ * type-here box hanging from it — page-clamped, in PDF pt. `false` =
222
+ * drag-only. Defaults: on for the built-in square/circle/line/free-text,
223
+ * off elsewhere.
224
+ */
225
+ clickCreate?: ClickCreate | false;
226
+ /**
227
+ * The tool's ghost ({@link GhostPolicy}). Defaults: inherited, else off;
228
+ * on for the built-in click-to-place tools (stamp, note, attachment).
229
+ */
230
+ ghost?: GhostPolicy;
231
+ /**
232
+ * What happens after this tool creates an annotation: select it, keep the
233
+ * tool, start typing in a text box. Wins over the `afterCreate` setting for
234
+ * every tool; what it leaves out comes from there.
235
+ */
236
+ afterCreate?: Partial<AfterCreateSettings>;
237
+ /** Your own data, such as a label and an icon for a toolbar that builds itself
238
+ * from the tool table. The plugin keeps it and never reads it. */
239
+ meta?: Record<string, unknown>;
240
+ }
241
+ interface BuiltinToolKindMap {
242
+ square: 'square';
243
+ circle: 'circle';
244
+ line: 'line';
245
+ distance: 'line';
246
+ perimeter: 'polyline';
247
+ area: 'polygon';
248
+ calibrate: 'line';
249
+ polygon: 'polygon';
250
+ polyline: 'polyline';
251
+ ink: 'ink';
252
+ 'ink-highlight': 'ink';
253
+ 'free-text': 'free-text';
254
+ 'free-text-callout': 'free-text-callout';
255
+ highlight: 'highlight';
256
+ underline: 'underline';
257
+ strikeout: 'strikeout';
258
+ squiggly: 'squiggly';
259
+ 'insert-text': 'caret';
260
+ 'replace-text': 'strikeout';
261
+ redact: 'redact';
262
+ stamp: 'stamp';
263
+ note: 'text';
264
+ attachment: 'file-attachment';
265
+ link: 'link';
266
+ }
267
+ type DirectToolDef = { [K in ToolAuthoringKind]: Omit<AnnotationToolDefinition<K>, 'subtype'> & {
268
+ subtype: K;
269
+ }; }[ToolAuthoringKind];
270
+ type BuiltinToolOverride = { [I in keyof BuiltinToolKindMap]: Omit<AnnotationToolDefinition<BuiltinToolKindMap[I]>, 'id' | 'extends' | 'subtype'> & {
271
+ id: I;
272
+ extends?: undefined;
273
+ subtype?: undefined;
274
+ }; }[keyof BuiltinToolKindMap];
275
+ type ExtendedBuiltinToolDef = { [I in keyof BuiltinToolKindMap]: Omit<AnnotationToolDefinition<BuiltinToolKindMap[I]>, 'extends' | 'subtype'> & {
276
+ extends: I;
277
+ subtype?: undefined;
278
+ }; }[keyof BuiltinToolKindMap];
279
+ /** Public tool input: known overrides, known-base presets, or an explicit subtype. */
280
+ type AnnotationToolInput = DirectToolDef | BuiltinToolOverride | ExtendedBuiltinToolDef;
281
+ /** A fully-resolved tool — what the plugin, handlers, and registration loop read. */
282
+ interface ResolvedTool {
283
+ id: string;
284
+ /** Routing token for the draw core + the created annotation's PDF subtype. */
285
+ subtype: KindName;
286
+ /** The `defaults` key (always the tool id) — keeps same-subtype tools apart. */
287
+ preset: string;
288
+ /** The kind whose properties the style panel shows (`propertiesOf(kindNamed(…))`). */
289
+ fieldsKind: string;
290
+ cursor: string;
291
+ enables: ReadonlySet<string>;
292
+ defaults?: FieldValues;
293
+ /** `/F` seed for created annotations (see {@link AnnotationToolDefinition.flags}). */
294
+ flags?: Partial<AnnotationFlags>;
295
+ source?: StampSourceSpec;
296
+ selection?: SelectionAuthoring;
297
+ ink?: InkAuthoringOptions;
298
+ /** Counter-rotate creations against the page's display rotation (see
299
+ * {@link AnnotationToolDefinition.upright}). */
300
+ upright: boolean;
301
+ /** What a bare click creates, or `false` for drag-only. */
302
+ clickCreate: ClickCreate | false;
303
+ /** The tool's ghost ({@link GhostPolicy}): how opaque it paints, or `false` for none. */
304
+ ghost: ResolvedGhost;
305
+ /** Its own `afterCreate` (see {@link AnnotationToolDefinition.afterCreate}), over the setting. */
306
+ afterCreate?: Partial<AfterCreateSettings>;
307
+ /** A line gesture is captured, not created ({@link CAPTURE_TOOLS}). */
308
+ capture: boolean;
309
+ meta?: Record<string, unknown>;
310
+ }
311
+ /**
312
+ * The built-in tools, as data (shapes + lines + ink
313
+ * + free text in the draw channel, text markup + caret behind text selection, and
314
+ * the click-to-place stamp). Order is display-neutral; the toolbar owns layout.
315
+ */
316
+ declare const DEFAULT_TOOLS: AnnotationToolInput[];
317
+ //#endregion
318
+ //#region src/token.d.ts
319
+ declare const AnnotationToken: import("@embedpdf/core").CapabilityToken<AnnotationCapability>;
320
+ //#endregion
321
+ //#region src/state.d.ts
322
+ /** Whether the annotations are read, and the ones selected, under the pointer and being typed in. */
323
+ interface AnnotationState {
324
+ /** `loading` until the document's annotations are in, then `ready`; `forbidden` or `error` when they can't load. */
325
+ readonly status: ResourceStatus;
326
+ /** The selected annotations, as the user sees them. */
327
+ readonly selected: readonly Annotation[];
328
+ /** The annotation under the pointer, or `null`. */
329
+ readonly hovered: Annotation | null;
330
+ /** The text box being typed in, or `null`. */
331
+ readonly editing: Annotation | null;
332
+ }
333
+ declare const annotationState: import("@embedpdf/core").StateDeclaration<AnnotationCapability, AnnotationState>;
334
+ //#endregion
335
+ //#region src/contract.d.ts
336
+ /** `'solid'` or `'dashed'` (4 pixels on, 3 off). */
337
+ type LineStyle = 'solid' | 'dashed';
338
+ /**
339
+ * How a selection looks: its outline, its handles and rotation handle, the
340
+ * lines shown while snapping and turning, the box dragged to select, a text
341
+ * box's outline while typing, and the angle while turning. Every size is in
342
+ * screen pixels, so it looks the same at every zoom. A color left `null`
343
+ * follows the part named in its doc, and in the end `accent`; every color,
344
+ * width and dash can also come from a CSS variable (`--epdf-annotation-*`),
345
+ * which wins over the setting.
346
+ */
347
+ interface ChromeSettings {
348
+ /** The color of every part below that has none of its own; `null` follows the viewer's accent. */
349
+ readonly accent: string | null;
350
+ /** The box around the selection. */
351
+ readonly outline: {
352
+ /** `null` follows `accent`. */
353
+ readonly color: string | null;
354
+ readonly style: LineStyle;
355
+ /** Line width, px. */
356
+ readonly width: number;
357
+ };
358
+ /** The resize and point handles. */
359
+ readonly handles: {
360
+ readonly shape: 'square' | 'circle';
361
+ /** What you see, px. */
362
+ readonly size: number;
363
+ /** What you can grab, px: keep it at 24 or more for touch. */
364
+ readonly hitSize: number;
365
+ readonly fill: string;
366
+ /** `null` follows `accent`. */
367
+ readonly stroke: string | null;
368
+ };
369
+ /** The round handle that turns the selection, on a short line (its stalk) above it. */
370
+ readonly rotationHandle: {
371
+ /** `false`: no rotation handle; the selection turns only from code. */
372
+ readonly enabled: boolean;
373
+ /** Its diameter, px. */
374
+ readonly size: number;
375
+ /** What you can grab, px. */
376
+ readonly hitSize: number;
377
+ /** How far it sits from the selection's edge, px. */
378
+ readonly offset: number;
379
+ /** `false` hides the line from the edge to it. */
380
+ readonly stalk: boolean;
381
+ /** `null` follows `handles.fill`. */
382
+ readonly fill: string | null;
383
+ /** `null` follows `handles.stroke`. */
384
+ readonly stroke: string | null;
385
+ };
386
+ /** The lines shown while snapping (alignment) and while turning (rotation). */
387
+ readonly guides: {
388
+ /** `false`: no rotation guides while turning. */
389
+ readonly enabled: boolean;
390
+ /** What a move snaps to. */
391
+ readonly color: string;
392
+ /** The reference cross and the angle line while turning; `null` follows `accent`. */
393
+ readonly rotationColor: string | null;
394
+ readonly style: LineStyle;
395
+ /** Line width of both kinds, px. */
396
+ readonly width: number;
397
+ };
398
+ /**
399
+ * The box you drag to select several annotations, one value: a change
400
+ * replaces it whole, and a color it leaves out is `null` again.
401
+ */
402
+ readonly marquee: {
403
+ /** `null`: `accent` at 8%. */
404
+ readonly fill: string | null;
405
+ /** `null` follows `accent`. */
406
+ readonly stroke: string | null;
407
+ };
408
+ /** The outline of a text box while you type in it; `null` follows `accent`. */
409
+ readonly textOutline: string | null;
410
+ /** The angle shown next to the pointer while you turn a selection. */
411
+ readonly readout: {
412
+ readonly enabled: boolean;
413
+ readonly background: string;
414
+ readonly color: string;
415
+ };
416
+ }
417
+ /**
418
+ * A tool's defaults: the fields its next annotation starts with, its own over
419
+ * the engine's. Which fields there are depends on the tool's kind; the style
420
+ * fields most tools have are typed, the rest read as `unknown`.
421
+ */
422
+ interface ToolDefaults {
423
+ /** `null` on a shape or line tool: no stroke. */
424
+ readonly color?: string | null;
425
+ readonly interiorColor?: string | null;
426
+ readonly opacity?: number;
427
+ readonly strokeWidth?: number;
428
+ readonly fontFamily?: string;
429
+ readonly fontSize?: number;
430
+ readonly fontColor?: string;
431
+ readonly textAlign?: 'left' | 'center' | 'right';
432
+ readonly icon?: string;
433
+ readonly contents?: string | null;
434
+ readonly [field: string]: unknown;
435
+ }
436
+ /** What happens after a tool creates an annotation. A tool's own `afterCreate` wins over this. */
437
+ interface AfterCreateSettings {
438
+ /** Select the new annotation. */
439
+ readonly select: boolean;
440
+ /** `'stay'` keeps the tool active; `'default'` goes back to the default tool, usually `pointer`. */
441
+ readonly tool: 'stay' | 'default';
442
+ /** For text boxes: start typing in the new box right away. */
443
+ readonly editText: boolean;
444
+ }
445
+ /**
446
+ * The annotation settings: what `annotationPlugin(config)` registers over
447
+ * {@link ANNOTATION_DEFAULTS}. `snap`, `chrome`, `afterCreate` and `editable`
448
+ * change for every open document with `updateSettings()`; `tools` is read
449
+ * when a document opens (add a tool to an open one with `tools.register()`).
450
+ */
451
+ interface AnnotationSettings {
452
+ /**
453
+ * Change the built-in tools or add your own. An entry with a built-in's id
454
+ * changes it (`{ id: 'ink', defaults: { strokeWidth: 6 } }`), a new id adds
455
+ * a tool, and `extends` starts from another tool.
456
+ */
457
+ readonly tools: readonly AnnotationToolInput[];
458
+ readonly afterCreate: AfterCreateSettings;
459
+ readonly chrome: ChromeSettings;
460
+ /** Snapping to other annotations and the page while moving, and to angles while turning. */
461
+ readonly snap: SnapSettings;
462
+ /**
463
+ * Which annotations people may change by hand: `true`, every one; `false`,
464
+ * none; or a list of the kinds they may, by subtype (`'highlight'`), a
465
+ * measurement by its intent (`'line-dimension'`). One left out can still be
466
+ * selected, read and commented on, but not moved, resized, turned,
467
+ * restyled, typed in or deleted. Only the interface: your code still
468
+ * changes it, and `canUpdate()` and `canDelete()` don't change.
469
+ */
470
+ readonly editable: EditableKinds;
471
+ }
472
+ /** What the annotation settings are when the app registers none. */
473
+ declare const ANNOTATION_DEFAULTS: AnnotationSettings;
474
+ /** What `annotationPlugin(config)` takes: any of the settings, merged over the defaults. */
475
+ type AnnotationConfig = DeepPartial<AnnotationSettings>;
476
+ /**
477
+ * The armed stamp's ghost: its image, see-through, in the box a click at the
478
+ * pointer would place it in (page space). Every other tool's ghost paints
479
+ * with the page's items (`source: 'ghost'`).
480
+ */
481
+ interface ImageGhost {
482
+ readonly page: PageRef;
483
+ /** The box the stamp's placement would use, before its turn. */
484
+ readonly box: Rect;
485
+ /** The tool's upright turn at this hover (degrees clockwise). */
486
+ readonly rot: number;
487
+ /** How opaque it paints (0–1); `--epdf-ghost-opacity` wins over it. */
488
+ readonly opacity: number;
489
+ }
490
+ /**
491
+ * One clickable link area on a page (page space): a standalone link
492
+ * annotation, or one segment of a parent's attached link. See
493
+ * {@link AnnotationHostCapability.listLinkItems}.
494
+ */
495
+ interface LinkNavItem {
496
+ /** Stable per-page key: the annot id, `#n`-suffixed for attached segments. */
497
+ readonly id: string;
498
+ /** The clickable area in page space. */
499
+ readonly bounds: Rect;
500
+ readonly target: PdfLinkTarget;
501
+ /**
502
+ * True for a link child riding an editable annotation (an `/RT /Group`
503
+ * subordinate): a property of its parent while authoring, a nav behavior
504
+ * only while reading. The nav layer stands its anchors down for attached
505
+ * items whenever the active tool enables `annotation-edit`, so the parent
506
+ * stays selectable/movable; standalone document links navigate regardless.
507
+ */
508
+ readonly attached: boolean;
509
+ /** The full payload-carrying `/A` tree, when one exists: the action
510
+ * engine's dispatch input. `target` remains its root projection. */
511
+ readonly activate?: PdfActionTree;
512
+ /** The annotation ref, carried for ActionSource context. */
513
+ readonly ref?: AnnotationRef;
514
+ /** Which `/AA` hover trees this link carries: the nav layer's pump flags
515
+ * (tree-less hover must cost zero dispatches). Links are behavior-inert
516
+ * to the annotation plane's hover feed while navigable, so their
517
+ * cursorEnter/cursorExit can only fire from the LinkLayer anchors. */
518
+ readonly hoverEvents?: {
519
+ enter: boolean;
520
+ exit: boolean;
521
+ };
522
+ }
523
+ /**
524
+ * A plugin (forms, links) or an interactive renderer marks some annotations as
525
+ * interactive: while engaged, they render their own DOM, take the pointer and
526
+ * are not geometry-editable. Not engaged, they are edited like any other.
527
+ */
528
+ interface Behavior {
529
+ readonly id: string;
530
+ /** Whether this behavior is about the annotation at all. */
531
+ matches(annotation: Annotation): boolean;
532
+ /** Whether it owns the annotation now (read live: the active tool, the app's mode). */
533
+ engaged(annotation: Annotation): boolean;
534
+ }
535
+ /**
536
+ * What a style panel shows: the {@link AnnotationProperty}s in display order,
537
+ * their current `values` by key, and which differ across the selection
538
+ * (`mixed`, shown as "mixed").
539
+ *
540
+ * For the selection, the properties are the ones every selected kind has (a
541
+ * mixed selection shows the shared ones, in the first kind's order), and the
542
+ * values the first member's; empty `properties` means nothing is selected. For
543
+ * a tool, they are its kind's, with its defaults over the engine's. The
544
+ * border's value is three keys (`borderStyle`, `dashArray`,
545
+ * `cloudyIntensity`); a text's font, size, colour and alignment read as the
546
+ * text shows (a free text's `fontColor` follows its `color` when it has none).
547
+ */
548
+ interface AnnotationProperties {
549
+ readonly properties: readonly AnnotationProperty[];
550
+ readonly values: FieldValues;
551
+ readonly mixed: readonly string[];
552
+ }
553
+ /**
554
+ * A free-text annotation projected for the framework: the box (page space,
555
+ * live gesture applied) + the plain text + an `editing` flag + a ready-to-spread
556
+ * CSS style. The framework renders one editable element from this and nothing
557
+ * more: all the mapping (fonts, colours, alignment) is done here, once. The
558
+ * element paints the text only: the box's fill and border are the vector
559
+ * scene's (`listPageItems`), the same for a plain box and a callout, so the
560
+ * live view matches the baked appearance.
561
+ */
562
+ interface TextItem {
563
+ readonly id: string;
564
+ readonly ref: AnnotationRef | null;
565
+ readonly box: Rect;
566
+ readonly contents: string;
567
+ /** The rich paragraphs the editor renders and edits (run deltas over the
568
+ * body, which `css` carries). `contents` is their plain projection. */
569
+ readonly richText: {
570
+ paragraphs: RichTextParagraph[];
571
+ };
572
+ /** The face of its text without one of its own: the body's. */
573
+ readonly face: {
574
+ family: string;
575
+ weight: number;
576
+ italic: boolean;
577
+ };
578
+ /**
579
+ * The font programs its text is drawn in (`css.fontFamily` and the runs'
580
+ * families name them): mount them where the box is drawn
581
+ * (`createFontMounts` in `@embedpdf/web`). Empty without the fonts plugin.
582
+ */
583
+ readonly programs: readonly MountableFontProgram[];
584
+ readonly editing: boolean;
585
+ /** Applied rotation (deg, CW). `box` is the unrotated text box; the framework
586
+ * rotates the editable element about its centre by this. 0/undefined = none. */
587
+ readonly rot?: number;
588
+ readonly css: {
589
+ fontFamily: string;
590
+ /** Content units (the framework multiplies by the page scale). The line
591
+ * height is not here: the editor binding states the engine's line model
592
+ * per face on the element itself (`@embedpdf/web`, `lineModelFor`). */
593
+ fontSize: number;
594
+ color: string;
595
+ /** The body's formatting (runs override it as inline spans). */
596
+ fontWeight: number;
597
+ fontStyle: 'normal' | 'italic';
598
+ textDecoration: 'none' | 'underline';
599
+ align: 'left' | 'center' | 'right';
600
+ padding: number;
601
+ };
602
+ }
603
+ /** What `comments.deleteThread()` did: everything went, or nothing did and `failed` says why. */
604
+ interface ThreadDeleteResult {
605
+ readonly deleted: AnnotationRef[];
606
+ readonly failed: Array<{
607
+ ref: AnnotationRef;
608
+ error: unknown;
609
+ }>;
610
+ }
611
+ /** The public shape of a tool: a named preset over a kind. */
612
+ interface AnnotationTool {
613
+ readonly id: string;
614
+ readonly subtype: KindName;
615
+ /** The defaults key this tool reads and writes. */
616
+ readonly preset: string;
617
+ readonly cursor: string;
618
+ readonly enables: readonly string[];
619
+ readonly defaults?: FieldValues;
620
+ /** The tool's ghost, what a click would place following the pointer: how opaque it paints, or `false`. */
621
+ readonly ghost: ResolvedGhost;
622
+ /** Your own data from the tool's definition, such as a label and an icon. */
623
+ readonly meta?: Readonly<Record<string, unknown>>;
624
+ }
625
+ /** A polygon or polyline being drawn: where it is, how many points it has, and whether it can end. */
626
+ type CreationDraft = CreationDraftAnchor;
627
+ /** A turn in progress: its page, the pointer there, and the angle so far (degrees clockwise). */
628
+ type AnnotationRotationAnchor = RotationAnchor;
629
+ /** Where a menu attaches to the selection: its page and the box around it (page space). */
630
+ interface AnnotationSelectionAnchor {
631
+ readonly page: PageRef;
632
+ readonly bounds: Rect;
633
+ /** The rotation handle's middle, so a menu can stay clear of it; absent without one. */
634
+ readonly rotationHandle?: Point$1;
635
+ }
636
+ /** Where UI attaches to one annotation: its page and the box around what it shows (page space). */
637
+ interface AnnotationAnchor {
638
+ readonly page: PageRef;
639
+ readonly bounds: Rect;
640
+ /**
641
+ * For an annotation that keeps its size or stays upright on screen (a note):
642
+ * the box in a given view, where `bounds` is the box at 100%. `<Anchored>`
643
+ * calls it, so the anchor doesn't change while people zoom. Absent for
644
+ * every other annotation.
645
+ */
646
+ readonly boundsIn?: (view: ViewEnv) => Rect | null;
647
+ }
648
+ /** An annotation was added: the engine's record, whoever added it. */
649
+ interface AnnotationCreatedEvent {
650
+ readonly annotation: Annotation;
651
+ readonly origin: EventOrigin;
652
+ }
653
+ /** An annotation was changed: the engine's record after the change. */
654
+ interface AnnotationUpdatedEvent {
655
+ readonly annotation: Annotation;
656
+ readonly origin: EventOrigin;
657
+ }
658
+ /** Annotations were deleted: one, and what went with it (its popup, replies and review states). */
659
+ interface AnnotationDeletedEvent {
660
+ /** Everything that went, the annotation first. */
661
+ readonly refs: readonly AnnotationRef[];
662
+ readonly page: PageRef;
663
+ readonly origin: EventOrigin;
664
+ }
665
+ /** The drawing order on a page changed: `order` is the page's annotations, bottom to top. */
666
+ interface AnnotationReorderedEvent {
667
+ readonly page: PageRef;
668
+ readonly order: readonly AnnotationRef[];
669
+ readonly origin: EventOrigin;
670
+ }
671
+ /** Annotations were read again (a document opening, a page re-read): not a list of creates. */
672
+ interface AnnotationResyncedEvent {
673
+ readonly pages: readonly PageRef[] | 'all';
674
+ }
675
+ /**
676
+ * The engine refused a change the user made (a revoked grant, a lock set
677
+ * elsewhere). The change is already gone from the view, which shows the
678
+ * engine's record again; this says why, so a UI can tell the user.
679
+ */
680
+ interface AnnotationWriteFailedEvent {
681
+ /** The existing annotations the refused write carried; empty for a refused create. */
682
+ readonly refs: readonly AnnotationRef[];
683
+ readonly error: PluginErrorInfo;
684
+ }
685
+ /** The selection changed. */
686
+ interface AnnotationSelectionChangedEvent {
687
+ readonly refs: readonly AnnotationRef[];
688
+ readonly previousRefs: readonly AnnotationRef[];
689
+ }
690
+ /** A polygon or polyline started, got a point, or ended. */
691
+ interface AnnotationDraftChangedEvent {
692
+ readonly draft: CreationDraft | null;
693
+ }
694
+ /** Typing in a text box started (`ref`) or ended (`null`). */
695
+ interface AnnotationEditingChangedEvent {
696
+ readonly ref: AnnotationRef | null;
697
+ }
698
+ /** The pointer moved onto an annotation (`ref`), or off it (`null`). */
699
+ interface AnnotationHoverChangedEvent {
700
+ readonly ref: AnnotationRef | null;
701
+ }
702
+ /** A tool's defaults changed, from your UI or your code. */
703
+ interface ToolDefaultsChangedEvent {
704
+ readonly toolId: string;
705
+ /** The tool's defaults now, as `tools.getDefaults(toolId)` returns them. */
706
+ readonly defaults: ToolDefaults;
707
+ }
708
+ /** A thread changed through this viewer. */
709
+ interface CommentThreadChangedEvent {
710
+ readonly rootRef: AnnotationRef;
711
+ readonly type: 'reply' | 'text' | 'status' | 'marked' | 'deleted';
712
+ }
713
+ /** Which annotations `list()` returns: every field narrows. */
714
+ interface AnnotationFilter {
715
+ /** Only these pages, as refs or indexes. */
716
+ readonly pages?: readonly (PageRef | number)[];
717
+ readonly subtype?: AnnotationSubtype;
718
+ }
719
+ /** What `import()` did: the new annotations, where each bundle ref went, and what was left out. */
720
+ interface AnnotationImportResult {
721
+ /** The new annotations, in bundle order. */
722
+ readonly annotations: readonly Annotation[];
723
+ /** Each imported annotation's ref in the bundle, and its new ref here. */
724
+ readonly refMap: ReadonlyArray<{
725
+ readonly from: AnnotationRef;
726
+ readonly to: AnnotationRef;
727
+ }>;
728
+ /** What was left out, and why, in bundle order. */
729
+ readonly dropped: readonly AnnotationImportDrop[];
730
+ }
731
+ /** Which annotations `export()` takes. */
732
+ interface AnnotationExportSelection {
733
+ /** These annotations, with what they point at and their replies. */
734
+ readonly refs?: readonly AnnotationRef[];
735
+ /** Every annotation on these pages, as refs or indexes. */
736
+ readonly pages?: readonly (PageRef | number)[];
737
+ }
738
+ /** The selection: what is selected, and the verbs that change it as one. */
739
+ interface AnnotationSelectionCapability {
740
+ /** Select these annotations; an annotation in a group brings its group. */
741
+ select(refs: readonly AnnotationRef[]): void;
742
+ /** Add these annotations to the selection, with their groups. */
743
+ add(refs: readonly AnnotationRef[]): void;
744
+ /** Select everything that can be selected, on one page or in the whole document. */
745
+ selectAll(page?: PageRef | number): void;
746
+ /**
747
+ * Select everything a box on a page touches of what it paints (its lines,
748
+ * or the inside of a filled shape), with the rest of each one's group, as
749
+ * dragging on empty space does. Throws `not-found` for a page that isn't
750
+ * in the document.
751
+ */
752
+ selectInRect(page: PageRef | number, rect: Rect): void;
753
+ /** Clear the selection. */
754
+ clear(): void;
755
+ /** The selected annotations, as the user sees them. */
756
+ getSelected(): readonly Annotation[];
757
+ /**
758
+ * Change the selected annotations: each takes the fields its kind has, and
759
+ * skips the rest. A function changes each relative to itself. A text box's
760
+ * font, size, colour and formats change all of its text; while words are
761
+ * selected in a text box being typed in, those words, and at its caret, the
762
+ * text typed there next. Resolves once the engine wrote every change, with
763
+ * what it refused in `failed`.
764
+ */
765
+ update(changes: AnnotationPatch | ((annotation: Annotation) => AnnotationPatch), options?: OperationOptions): Promise<BatchResult<AnnotationRef, AnnotationRef>>;
766
+ /** Link the selected annotations to a page or a website, or remove their links with `null`. */
767
+ updateLink(target: PdfLinkTarget | null, options?: OperationOptions): Promise<BatchResult<AnnotationRef, AnnotationRef>>;
768
+ /** What a style panel shows for the selection. The same object while nothing changes. */
769
+ getProperties(): AnnotationProperties;
770
+ /** Delete every selected annotation. */
771
+ delete(options?: OperationOptions): Promise<BatchResult<AnnotationRef, AnnotationRef>>;
772
+ /** Turn the selection a quarter turn: `90` clockwise, `-90` the other way. */
773
+ rotateBy(degrees: 90 | -90, options?: OperationOptions): Promise<void>;
774
+ /** Turn the selection upright again. */
775
+ resetRotation(options?: OperationOptions): Promise<void>;
776
+ /** Make the selected annotations one group, saved the way Acrobat saves it. */
777
+ group(options?: OperationOptions): Promise<void>;
778
+ /** Split the selected groups up again. */
779
+ ungroup(options?: OperationOptions): Promise<void>;
780
+ /** Whether the selection can be grouped: two or more on one page, each changeable. */
781
+ canGroup(): boolean;
782
+ /** Whether the selection holds a group that can be split. */
783
+ canUngroup(): boolean;
784
+ /**
785
+ * Where a menu attaches: the selection's page and the box around it, or
786
+ * `null` with nothing selected, or while a gesture moves, resizes or turns it.
787
+ */
788
+ getAnchor(): AnnotationSelectionAnchor | null;
789
+ /** While the selection is being turned: the pointer's point and the angle so far, or `null`. */
790
+ getRotationAnchor(): AnnotationRotationAnchor | null;
791
+ }
792
+ /** A polygon or polyline being drawn, a click per point. */
793
+ interface AnnotationDraftCapability {
794
+ /** The shape being drawn, or `null`. */
795
+ get(): CreationDraft | null;
796
+ /** End the shape and create it, as a double-click does. Resolves `null` when there was none to make. */
797
+ finish(options?: OperationOptions): Promise<{
798
+ annotation: Annotation;
799
+ } | null>;
800
+ /** Drop the shape being drawn. */
801
+ cancel(): void;
802
+ }
803
+ /** Typing in a text box. */
804
+ interface AnnotationTextCapability {
805
+ /** Start typing in a text box, as a double-click does. */
806
+ begin(ref: AnnotationRef): void;
807
+ /** Stop typing, and save what was typed. */
808
+ end(options?: OperationOptions): Promise<void>;
809
+ /** The text box being typed in, or `null`. */
810
+ getEditing(): Annotation | null;
811
+ /**
812
+ * Bold, italic or underline on or off: for the selected words, the text
813
+ * typed next at the caret, or all the text of each selected box. On, unless
814
+ * all of it already has it.
815
+ */
816
+ toggleFormat(format: TextFormat, options?: OperationOptions): Promise<void>;
817
+ }
818
+ /** The tools: what a click or a drag creates, with which defaults. */
819
+ interface AnnotationToolsCapability {
820
+ /** Every tool, the built-in ones and yours. */
821
+ list(): readonly AnnotationTool[];
822
+ /** One tool, or `null`. */
823
+ get(id: string): AnnotationTool | null;
824
+ /** Add a tool while the app runs, or replace the one with the same id. Returns a function that removes it. */
825
+ register(tool: AnnotationToolInput): Unsubscribe;
826
+ /** The fields a tool's next annotation starts with: its defaults over the engine's. The same object until they change. */
827
+ getDefaults(id: string): ToolDefaults;
828
+ /**
829
+ * Change a tool's defaults for the drawings that follow: each value whole,
830
+ * as in a patch. They stay in this viewer. Fires `onDefaultsChanged`.
831
+ */
832
+ updateDefaults(id: string, changes: FieldValues): void;
833
+ /** What a style panel for the tool shows, the same shape as `selection.getProperties()`. */
834
+ getProperties(id: string): AnnotationProperties;
835
+ /** A tool's defaults changed. */
836
+ readonly onDefaultsChanged: EventHook<ToolDefaultsChangedEvent>;
837
+ }
838
+ /** A stamp's bytes, to arm for a click or to place from code. */
839
+ interface StampInput {
840
+ /** PNG, JPEG, or one-page PDF bytes (`Blob | Uint8Array | BinaryPayload`). */
841
+ source: BinarySource;
842
+ /** Placed width in PDF points (height follows the picture). Default: the picture's own width. */
843
+ targetWidth?: number;
844
+ /** The placed annotation's `/Name`: the stamp identifier (standard or custom). */
845
+ name?: string;
846
+ /** The placed annotation's `/Subj`. */
847
+ subject?: string;
848
+ /**
849
+ * The hover ghost's image. Either fixed bytes (PNG/JPEG) or, for vector
850
+ * sources, which are only right at one size on screen, a
851
+ * {@link StampPreviewProvider} the ghost asks for a render at the device
852
+ * pixel width it shows at. Raster sources default to themselves; without
853
+ * one a PDF source shows no ghost.
854
+ */
855
+ preview?: BinarySource | StampPreviewProvider;
856
+ /**
857
+ * The source's own size in PDF points. Raster sources are measured from
858
+ * their header, but PDF bytes carry no size a sniff can read: a caller that
859
+ * knows it (a stamp library does) passes it here so placement keeps the
860
+ * picture's aspect.
861
+ */
862
+ intrinsicSize?: {
863
+ width: number;
864
+ height: number;
865
+ };
866
+ }
867
+ /** Where `stamps.place()` puts a stamp, without a click. */
868
+ interface StampPlacement {
869
+ /** The page, as a ref or an index. */
870
+ readonly page: PageRef | number;
871
+ /** Where its middle goes, in page space. The size comes from the picture. */
872
+ readonly center: Point$1;
873
+ /** Placed width in PDF points; default the picture's own (or the stamp's `targetWidth`). */
874
+ readonly targetWidth?: number;
875
+ /** Its turn, degrees clockwise. Default 0. */
876
+ readonly rotation?: number;
877
+ /** Select it, as placing it with a click would. Default false: code never changes the selection. */
878
+ readonly select?: boolean;
879
+ }
880
+ /** Stamps placed from bytes: armed for the next click, or placed from code. */
881
+ interface AnnotationStampsCapability {
882
+ /**
883
+ * Arm a stamp's bytes so the next click places them, as the `stamp` tool
884
+ * does after picking a file. Rejects `invalid-input` for bytes that aren't
885
+ * PNG, JPEG or a one-page PDF.
886
+ */
887
+ arm(stamp: StampInput, options?: OperationOptions): Promise<void>;
888
+ /** Disarm the stamp. */
889
+ disarm(): void;
890
+ /** Whether a stamp is armed. */
891
+ isArmed(): boolean;
892
+ /**
893
+ * Place a stamp's bytes with its middle on `center`, sized by its picture
894
+ * and kept on the page, as a click would. Resolves `{ annotation }`.
895
+ * Rejects `permission-denied` without `annotations:create`, `not-found` for
896
+ * a page that isn't in the document, `invalid-input` for bytes that aren't
897
+ * a picture.
898
+ */
899
+ place(stamp: StampInput, placement: StampPlacement, options?: OperationOptions): Promise<{
900
+ annotation: Annotation;
901
+ }>;
902
+ }
903
+ /** Links attached to annotations (a link child), or a link annotation's own target. */
904
+ interface AnnotationLinksCapability {
905
+ /** Where an annotation links to, or `null`. */
906
+ get(ref: AnnotationRef): PdfLinkTarget | null;
907
+ /** Link an annotation to a page or a website. */
908
+ set(ref: AnnotationRef, target: PdfLinkTarget, options?: OperationOptions): Promise<void>;
909
+ /** Remove an annotation's link. */
910
+ clear(ref: AnnotationRef, options?: OperationOptions): Promise<void>;
911
+ }
912
+ /**
913
+ * Comments and replies: threads over the annotations. Every verb is a plain
914
+ * annotation create, change or delete, so other people's changes, this
915
+ * viewer's and reloads all show in `listThreads()`.
916
+ */
917
+ interface CommentsCapability {
918
+ /** Every thread, in reading order: by page, then from the top of the page. */
919
+ listThreads(): readonly CommentThread[];
920
+ /** The thread a comment is in (its first comment, a reply or a review state), or `null`. */
921
+ getThread(ref: AnnotationRef): CommentThread | null;
922
+ /**
923
+ * Reply to the thread's first comment, whichever comment you pass.
924
+ * Resolves `{ annotation }`. Rejects `permission-denied` without
925
+ * `annotations:create`.
926
+ */
927
+ reply(ref: AnnotationRef, text: string, options?: OperationOptions): Promise<{
928
+ annotation: Annotation;
929
+ }>;
930
+ /** Change a comment's text. Rejects `permission-denied` when `canSetText(ref)` is false. */
931
+ setText(ref: AnnotationRef, text: string, options?: OperationOptions): Promise<void>;
932
+ /** Set the user's review state on a thread, such as `'accepted'`. */
933
+ setStatus(ref: AnnotationRef, state: string, options?: OperationOptions): Promise<void>;
934
+ /** Check a thread off for the user, or clear the check mark. */
935
+ setMarked(ref: AnnotationRef, marked: boolean, options?: OperationOptions): Promise<void>;
936
+ /** Delete a comment with its replies; the first comment of a thread deletes the thread. */
937
+ delete(ref: AnnotationRef, options?: OperationOptions): Promise<void>;
938
+ /** Delete a whole thread, all of it or none. */
939
+ deleteThread(ref: AnnotationRef, options?: OperationOptions): Promise<ThreadDeleteResult>;
940
+ /** Whether the user may reply to this thread (`annotations:create`). */
941
+ canReply(ref: AnnotationRef): boolean;
942
+ /** Whether the user may change this comment's text (`annotations:update`, and not `lockedContents`). */
943
+ canSetText(ref: AnnotationRef): boolean;
944
+ /** Whether the user may set a review state on this thread (`annotations:create`). */
945
+ canSetStatus(ref: AnnotationRef): boolean;
946
+ /** Whether the user may check this thread off (`annotations:create`). */
947
+ canSetMarked(ref: AnnotationRef): boolean;
948
+ /**
949
+ * Whether the user may delete this comment with its replies (`annotations:delete`): the
950
+ * comment unlocked, and every reply too.
951
+ */
952
+ canDelete(ref: AnnotationRef): boolean;
953
+ /** Whether the user may delete this thread: `canDelete()` of its first comment. */
954
+ canDeleteThread(ref: AnnotationRef): boolean;
955
+ /** A thread changed through this viewer: a reply, a text, a review state, a check mark or a delete. */
956
+ readonly onThreadChanged: EventHook<CommentThreadChangedEvent>;
957
+ }
958
+ /**
959
+ * The annotation API: the documented, stable surface for application code.
960
+ * Resolve it with the token re-exported from the package root
961
+ * (`@embedpdf/plugin-annotation`). Framework-only plumbing lives on
962
+ * {@link AnnotationHostCapability} in `@embedpdf/plugin-annotation/contract/host`.
963
+ */
964
+ interface AnnotationCapability extends SettingsApi<AnnotationSettings> {
965
+ /**
966
+ * The annotation as the user sees it: the engine's record with any change
967
+ * the user made applied, as the engine will apply it. A new annotation shows
968
+ * before the engine confirms it, under the `nm` ref it was created with.
969
+ */
970
+ get(ref: AnnotationRef): Annotation | null;
971
+ /** Every annotation in drawing order, or the ones on some pages or of one kind. */
972
+ list(filter?: AnnotationFilter): readonly Annotation[];
973
+ /**
974
+ * The topmost annotation at a point on a page, or `null`. A selected
975
+ * annotation's handles count as the annotation. A page that isn't in the
976
+ * document has none.
977
+ */
978
+ getAt(page: PageRef | number, point: Point$1): Annotation | null;
979
+ /** Whether a change the user made to it waits for the engine. */
980
+ isPending(ref: AnnotationRef): boolean;
981
+ /** `loading` until the document's annotations are in, then `ready`; `forbidden` or `error` when they can't load. */
982
+ getStatus(): ResourceStatus;
983
+ /** The annotation under the pointer, or `null`. */
984
+ getHovered(): Annotation | null;
985
+ /** Read every annotation from the engine again. */
986
+ refresh(options?: OperationOptions): Promise<void>;
987
+ /**
988
+ * Create an annotation from its kind and fields: what they leave out takes
989
+ * the `tool`'s defaults when one is named, then the engine's. Bytes travel
990
+ * beside them (a stamp's `appearance`, a file attachment's `file`). It
991
+ * shows at once; resolves `{ annotation }` with the engine's record.
992
+ * `select` selects it, as drawing it would; without it, code never changes
993
+ * the selection. A read of another annotation makes the same one again (a
994
+ * copy): its own fields are written, and where it is comes from `page`.
995
+ * Rejects `permission-denied` without `annotations:create`, `not-found` for
996
+ * a page that isn't in the document or an unknown `tool`, `invalid-input`
997
+ * for a kind the engine doesn't know or a value a write can't make (another
998
+ * app's beveled border).
999
+ */
1000
+ create(page: PageRef | number, draft: AnnotationDraft | Annotation, resources?: AnnotationResources, options?: OperationOptions & {
1001
+ tool?: string;
1002
+ select?: boolean;
1003
+ }): Promise<{
1004
+ annotation: Annotation;
1005
+ }>;
1006
+ /**
1007
+ * What a text tool makes of the selected text, one annotation per page: a
1008
+ * highlight, underline, strikeout or squiggly line, an insertion caret, a
1009
+ * replacement or a redaction mark. Resolves `{ annotations }` (empty
1010
+ * without a text selection). The text selection is cleared afterwards
1011
+ * unless `clear` is `false`. Rejects `permission-denied` without
1012
+ * `annotations:create`, `not-found` for a tool that makes nothing of
1013
+ * selected text.
1014
+ */
1015
+ createFromSelection(tool: string, options?: OperationOptions & {
1016
+ clear?: boolean;
1017
+ }): Promise<{
1018
+ annotations: readonly Annotation[];
1019
+ }>;
1020
+ /**
1021
+ * Change the fields the patch names, as given: the engine works out what
1022
+ * follows (a free text's body from its font, a measurement's label from its
1023
+ * points, a drawn kind's shape from a new `rect`). New bytes replace what
1024
+ * they are for. It shows at once; resolves `{ annotation }` with the
1025
+ * engine's record. Rejects `not-found` for an annotation that isn't here.
1026
+ */
1027
+ update(ref: AnnotationRef, patch: AnnotationPatch, resources?: AnnotationResources, options?: OperationOptions): Promise<{
1028
+ annotation: Annotation;
1029
+ }>;
1030
+ /** Delete an annotation, with its popup and its replies. Fires `onDeleted`. */
1031
+ delete(ref: AnnotationRef, options?: OperationOptions): Promise<void>;
1032
+ /**
1033
+ * Change the drawing order on one page: the annotations go together, in
1034
+ * the order given, right after or before a neighbour annotation of the page
1035
+ * (`{ after: ref }`, `{ before: ref }`), or to the bottom (`'start'`) or the
1036
+ * top (`'end'`). Shows at once; fires `onReordered`. Rejects `invalid-input`
1037
+ * for refs on different pages and `not-found` for a neighbour that isn't
1038
+ * there. Widgets paint above every annotation and are ordered by the form.
1039
+ */
1040
+ reorder(refs: readonly AnnotationRef[], position: AnnotationPosition, options?: OperationOptions): Promise<void>;
1041
+ /**
1042
+ * Take annotations out as a bundle, with the bytes they carry (a stamp's
1043
+ * drawing, an attached file): every annotation, a selection of them (with
1044
+ * what they point at and their replies), or some pages'. Waits for pending
1045
+ * changes first. Rejects `permission-denied` without `doc.download`.
1046
+ */
1047
+ export(selection?: AnnotationExportSelection, options?: OperationOptions): Promise<AnnotationBundle>;
1048
+ /**
1049
+ * Put a bundle's annotations into this document, as one change: they show
1050
+ * once it's done. Resolves `{ annotations, refMap, dropped }`. Rejects
1051
+ * `permission-denied` without `annotations:create` (and, for the default
1052
+ * `attribution: 'restore'`, `doc.annotate.import`).
1053
+ */
1054
+ import(bundle: AnnotationBundle, options?: AnnotationImportOptions & OperationOptions): Promise<AnnotationImportResult>;
1055
+ /**
1056
+ * Download a stamp's drawing (`'appearance'`) or an attachment's file
1057
+ * (`'file'`): the bytes `create()` takes to make it again. Rejects
1058
+ * `permission-denied` without `doc.download`, `not-found` for an annotation
1059
+ * that isn't here, `invalid-input` for a role its kind doesn't have.
1060
+ */
1061
+ downloadResource(ref: AnnotationRef, role: AnnotationResourceRole, options?: OperationOptions): Promise<Uint8Array>;
1062
+ readonly links: AnnotationLinksCapability;
1063
+ readonly selection: AnnotationSelectionCapability;
1064
+ readonly draft: AnnotationDraftCapability;
1065
+ readonly text: AnnotationTextCapability;
1066
+ readonly tools: AnnotationToolsCapability;
1067
+ readonly stamps: AnnotationStampsCapability;
1068
+ readonly comments: CommentsCapability;
1069
+ /**
1070
+ * Set the function that gives the `stamp` and `attachment` tools their
1071
+ * file, `null` to make them do nothing. Returns a function that removes it.
1072
+ */
1073
+ setFilePickerProvider(provider: FilePickerProvider | null): Unsubscribe;
1074
+ /** Whether the user may see annotations (`doc.annotate.read`). */
1075
+ canRead(): boolean;
1076
+ /** Whether the user may create annotations (`annotations:create`). */
1077
+ canCreate(): boolean;
1078
+ /** Whether the user may change this annotation: its permission and its own `locked` flag. */
1079
+ canUpdate(ref: AnnotationRef): boolean;
1080
+ /**
1081
+ * Whether the user may delete this annotation, and with it its replies, review states and
1082
+ * popups: the permission for each of them and their `locked` flags.
1083
+ */
1084
+ canDelete(ref: AnnotationRef): boolean;
1085
+ /**
1086
+ * Whether the `editable` setting lets people change this annotation by
1087
+ * hand; `false` for one the document doesn't have. Whether a change would
1088
+ * succeed is `canUpdate()` and `canDelete()`.
1089
+ */
1090
+ isEditable(ref: AnnotationRef): boolean;
1091
+ /** Stop a drag, or a polygon in progress. */
1092
+ cancel(): void;
1093
+ /** An annotation was added, once the engine saved it. */
1094
+ readonly onCreated: EventHook<AnnotationCreatedEvent>;
1095
+ /** An annotation was changed, once the engine saved it. */
1096
+ readonly onUpdated: EventHook<AnnotationUpdatedEvent>;
1097
+ /** Annotations were deleted: one, plus its popup and replies. */
1098
+ readonly onDeleted: EventHook<AnnotationDeletedEvent>;
1099
+ /** The drawing order on a page changed. */
1100
+ readonly onReordered: EventHook<AnnotationReorderedEvent>;
1101
+ /** Annotations were read again, as after loading a document. */
1102
+ readonly onResynced: EventHook<AnnotationResyncedEvent>;
1103
+ /** The engine refused a change the user made; the view already shows the engine's record again. */
1104
+ readonly onWriteFailed: EventHook<AnnotationWriteFailedEvent>;
1105
+ /** The selection changed. */
1106
+ readonly onSelectionChanged: EventHook<AnnotationSelectionChangedEvent>;
1107
+ /** A polygon or polyline is being drawn, or ended. */
1108
+ readonly onDraftChanged: EventHook<AnnotationDraftChangedEvent>;
1109
+ /** Typing in a text box started or ended. */
1110
+ readonly onEditingChanged: EventHook<AnnotationEditingChangedEvent>;
1111
+ /** The pointer moved onto an annotation, or off it. */
1112
+ readonly onHoverChanged: EventHook<AnnotationHoverChangedEvent>;
1113
+ }
1114
+ type MarkupSubtype = 'highlight' | 'underline' | 'strikeout' | 'squiggly';
1115
+ /** The armed stamp: its placement size and identity. */
1116
+ interface ArmedStampInfo {
1117
+ /** Placement size in PDF points. */
1118
+ readonly width: number;
1119
+ readonly height: number;
1120
+ readonly name?: string;
1121
+ readonly subject?: string;
1122
+ }
1123
+ /** The armed stamp's paintable preview, for the render layer's ghost `<img>`. */
1124
+ interface ArmedStampPreview {
1125
+ readonly bytes: Uint8Array;
1126
+ readonly mimeType?: string;
1127
+ }
1128
+ /**
1129
+ * Resolution-aware ghost preview: "give me this stamp at `devicePixelWidth`
1130
+ * pixels wide". The annotation plugin buckets the request (see
1131
+ * `previewBucket`) and caches per bucket for the arm's lifetime, so a zoom
1132
+ * gesture never renders per frame and one render serves a zoom range. A stamp
1133
+ * library renders its page lazily through its asset engine; a raster returns
1134
+ * itself (it cannot get sharper than its pixels).
1135
+ */
1136
+ type StampPreviewProvider = (devicePixelWidth: number) => Promise<ArmedStampPreview | null>;
1137
+ /**
1138
+ * What the {@link FilePickerProvider} is asked for: which tool clicked (id +
1139
+ * the kind it creates), the tool's `accept` filter, and the page-space point
1140
+ * the click landed on: enough to route per tool (asset library for stamps,
1141
+ * cloud drive for attachments) or position a picker near the click. Plain
1142
+ * data: the request crosses the plugin↔adapter boundary as a message.
1143
+ */
1144
+ interface FilePromptRequest {
1145
+ toolId: string;
1146
+ /** The kind the placement creates: the routing key for per-tool pickers. */
1147
+ subtype: KindName;
1148
+ /** The tool's file-dialog filter hint (from the tool def). UX only:
1149
+ * the engine sniffs and validates the bytes. */
1150
+ accept?: string;
1151
+ page: PageRef;
1152
+ /** The page-space point the placement is centred on. */
1153
+ point: Point$1;
1154
+ }
1155
+ /**
1156
+ * The one environment port behind every click-then-pick tool (the stamp
1157
+ * `'prompt'` source and the file-attachment tool, whose file is picked after
1158
+ * the spot): given a click, produce the file to place, `null` to cancel. The
1159
+ * plugin declares this contract but never implements it: a file dialog is a
1160
+ * DOM concern, so the framework adapter installs the implementation via
1161
+ * {@link AnnotationCapability.setFilePickerProvider}. The return shape is the
1162
+ * engine's file vocabulary: a stamp takes only `data`; an attachment embeds
1163
+ * the whole thing. A picked `File` carries its own name and type; a provider
1164
+ * returning raw bytes for an attachment must supply `name` itself.
1165
+ */
1166
+ type FilePickerProvider = (request: FilePromptRequest) => Promise<AttachmentFileSource | null>;
1167
+ //#endregion
1168
+ export { Color as $, AnnotationResources$1 as A, AnnotationState as At, AnnotationTool as B, ResolvedGhost as Bt, AnnotationPatch$1 as C, StampPlacement as Ct, AnnotationRef$1 as D, ThreadDeleteResult as Dt, AnnotationProperty$1 as E, TextItem as Et, AnnotationSelectionChangedEvent as F, AnnotationToolInput as Ft, ArmedStampInfo as G, ToolDefaultsFor as Gt, AnnotationTransfer as H, SelectionAuthoring as Ht, AnnotationSettings as I, DEFAULT_TOOLS as It, AttachmentFileSource$1 as J, TextFormat as Jt, ArmedStampPreview as K, EditorSelection as Kt, AnnotationStampsCapability as L, GhostPolicy as Lt, AnnotationRotationAnchor as M, AnnotationToken as Mt, AnnotationSelectionAnchor as N, ARMED_STAMP_TOOL_ID as Nt, AnnotationReorderedEvent as O, ToolDefaults as Ot, AnnotationSelectionCapability as P, AnnotationToolDefinition as Pt, ClickCreate$1 as Q, AnnotationSubtype$1 as R, InkAuthoringOptions as Rt, AnnotationOption as S, StampInput as St, AnnotationProperties as T, TextAlign as Tt, AnnotationUpdatedEvent as U, StampSourceSpec as Ut, AnnotationToolsCapability as V, ResolvedTool as Vt, AnnotationWriteFailedEvent as W, ToolAuthoringKind as Wt, BlendMode as X, Behavior as Y, TextSelection as Yt, ChromeSettings as Z, AnnotationHoverChangedEvent as _, MarkupSubtype as _t, AnnotationBundle$1 as a, EditableKind as at, AnnotationImportResult as b, ReviewStatus as bt, AnnotationCreatedEvent as c, FilePickerProvider as ct, AnnotationDraftCapability as d, HandleRole as dt, CommentThread$1 as et, AnnotationDraftChangedEvent as f, ImageGhost as ft, AnnotationFlags$1 as g, LinkNavItem as gt, AnnotationFilter as h, LineStyle as ht, AnnotationAnchor as i, CreationDraft as it, AnnotationResyncedEvent as j, annotationState as jt, AnnotationResourceRole$1 as k, ToolDefaultsChangedEvent as kt, AnnotationDeletedEvent as l, FilePromptRequest as lt, AnnotationExportSelection as m, LineEndings as mt, AfterCreateSettings as n, CommentThreadReview as nt, AnnotationCapability as o, EditableKinds$1 as ot, AnnotationEditingChangedEvent as p, LineEnding as pt, AttachmentContent as q, Face as qt, Annotation$1 as r, CommentsCapability as rt, AnnotationConfig as s, FieldValues$1 as st, ANNOTATION_DEFAULTS as t, CommentThreadChangedEvent as tt, AnnotationDraft$1 as u, FlagKey as ut, AnnotationImportDrop$1 as v, MeasurementIntent as vt, AnnotationPosition$1 as w, StampPreviewProvider as wt, AnnotationLinksCapability as x, SnapSettings$1 as xt, AnnotationImportOptions$1 as y, PdfLinkTarget$1 as yt, AnnotationTextCapability as z, PromptSourceSpec as zt };
1169
+ //# sourceMappingURL=contract-BK2g1Rem.d.ts.map