@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
@@ -1,912 +0,0 @@
1
- import { PageObjectNumber } from "@embedpdf/core";
2
- import { PageRotation } from "@embedpdf/core-geometry";
3
- import { AnnotationAppearanceImage, AnnotationDTO, AnnotationDraft, AnnotationPatch, AnnotationRef, AttachmentContent, AttachmentFileSource, BinarySource, InkIntent, PdfLinkTarget, PdfRect } from "@embedpdf/engine-core/runtime";
4
- import { AnnotationFlags, AnnotationProps, AnnotationPropsPatch, ChromeNode, ClickCreate, CreationDraftAnchor, Geom, Id, InkStraightenOptions, Model, PropKey, PropSpec, Rect, RenderItem, SnapSettings, Subtype, TextEndAnchor, TextQuad, Vec, ViewEnv } from "@embedpdf/core-annotation";
5
- //#region src/tools.d.ts
6
- /**
7
- * How a stamp-family tool resolves the image bytes it places — pure DATA, so a
8
- * tool table stays JSON-serializable (config can come from a file, a DB, or the
9
- * server). Evaluated at CLICK time, so the user picks the spot first, then the
10
- * source:
11
- * - `{ kind: 'bytes' }` — fixed bytes: a company rubber-stamp.
12
- * - `{ kind: 'prompt' }` — ask the environment for bytes. The plugin does NOT
13
- * know how (a file dialog is DOM); the file-picker port (`FilePickerProvider`),
14
- * installed by the framework adapter, fulfils it. Resolve `null` there to cancel.
15
- */
16
- type StampSourceSpec = {
17
- kind: 'bytes';
18
- source: BinarySource;
19
- } | PromptSourceSpec;
20
- /**
21
- * The ask-the-environment resolution, shared by every click-then-pick tool
22
- * (a stamp's `'prompt'` source, the file-attachment tool). `accept` is the
23
- * file-dialog filter the picker request carries — a UX hint only, the engine
24
- * sniffs/validates the bytes for real. Unset = any file.
25
- */
26
- interface PromptSourceSpec {
27
- kind: 'prompt';
28
- accept?: string;
29
- }
30
- /** Declarative result of committing a text selection while a tool is active. */
31
- type SelectionAuthoring = {
32
- kind: 'markup';
33
- } | {
34
- kind: 'text-edit';
35
- operation: 'insert' | 'replace';
36
- };
37
- /**
38
- * The armed tool's IN-PAGE preview:
39
- * - `footprint` — the EXACT box a click would place, in the page (content
40
- * space, page-clamped, WYSIWYG). Meaningful only when the box is
41
- * determinable: an armed stamp payload, or a `clickCreate` size.
42
- * - `false` — no preview.
43
- * WHICH tool is armed is the CURSOR's job, not a ghost's: give the tool an
44
- * image cursor built from your toolbar icon (the hub's `setToolCursor` + the
45
- * web package's `svgCursor`), and the hub's claim/gap arbitration keeps it
46
- * honest over annotations, form fields, and page gaps.
47
- */
48
- type GhostPolicy = false | {
49
- mode: 'footprint';
50
- };
51
- /** Time/geometry policy for freehand ink authoring. */
52
- interface InkAuthoringOptions {
53
- /** Group strokes made within this interval into one `/InkList`; 0 commits immediately. */
54
- groupStrokesMs?: number;
55
- /** Optional pure straight-line recognition applied to each completed stroke. */
56
- straighten?: InkStraightenOptions;
57
- }
58
- /**
59
- * The creation properties each known authoring kind actually consumes. This is
60
- * deliberately separate from the flat internal patch vocabulary: it gives tool
61
- * configuration precise compile-time and runtime validation while mixed-selection
62
- * edits can keep using `AnnotationPropsPatch`.
63
- */
64
- declare const TOOL_DEFAULT_KEYS: {
65
- readonly square: readonly ["color", "interiorColor", "opacity", "strokeWidth", "border"];
66
- readonly circle: readonly ["color", "interiorColor", "opacity", "strokeWidth", "border"];
67
- readonly line: readonly ["color", "interiorColor", "opacity", "strokeWidth", "border", "lineEndings"];
68
- readonly polygon: readonly ["color", "interiorColor", "opacity", "strokeWidth", "border"];
69
- readonly polyline: readonly ["color", "interiorColor", "opacity", "strokeWidth", "border", "lineEndings"];
70
- readonly ink: readonly ["color", "opacity", "strokeWidth", "blendMode"];
71
- readonly 'free-text': readonly ["fontFamily", "fontSize", "fontColor", "textAlign", "opacity", "interiorColor", "color", "strokeWidth", "border"];
72
- readonly 'free-text-callout': readonly ["fontFamily", "fontSize", "fontColor", "textAlign", "opacity", "interiorColor", "color", "strokeWidth", "border", "lineEndings"];
73
- readonly highlight: readonly ["color", "opacity", "blendMode"];
74
- readonly underline: readonly ["color", "opacity", "blendMode"];
75
- readonly strikeout: readonly ["color", "opacity", "blendMode"];
76
- readonly squiggly: readonly ["color", "opacity", "blendMode"];
77
- readonly caret: readonly ["color", "opacity"];
78
- readonly redact: readonly ["color", "interiorColor", "opacity", "fontFamily", "fontSize", "fontColor", "textAlign"];
79
- readonly stamp: readonly [];
80
- readonly link: readonly ["link"];
81
- readonly text: readonly ["icon", "color", "opacity"];
82
- readonly 'file-attachment': readonly ["icon", "color", "opacity"];
83
- readonly 'widget-text': readonly ["color", "interiorColor", "strokeWidth", "border", "fontFamily", "fontSize", "fontColor", "textAlign"];
84
- readonly 'widget-choice': readonly ["color", "interiorColor", "strokeWidth", "border", "fontFamily", "fontSize", "fontColor", "textAlign"];
85
- readonly 'widget-toggle': readonly ["color", "interiorColor", "strokeWidth", "border"];
86
- };
87
- type ToolAuthoringKind = keyof typeof TOOL_DEFAULT_KEYS;
88
- type ToolDefaultKey<K extends ToolAuthoringKind> = (typeof TOOL_DEFAULT_KEYS)[K][number];
89
- type ToolDefaultsFor<K extends ToolAuthoringKind> = [ToolDefaultKey<K>] extends [never] ? never : Pick<AnnotationPropsPatch, ToolDefaultKey<K>>;
90
- /**
91
- * A tool definition — the public config vocabulary. Every field except `id` is
92
- * optional: the common cases are "configure a built-in" (`{ id, defaults }`) and
93
- * "add a preset" (`{ id, extends, defaults }`).
94
- */
95
- interface AnnotationToolDef<K extends ToolAuthoringKind = ToolAuthoringKind> {
96
- /** Stable tool id — the value passed to `activateTool` and the `defaults` key. */
97
- id: string;
98
- /** Inherit `subtype` / `propsKind` / `cursor` / `enables` / `source` /
99
- * `selection` / `intent` / `ink` / `meta`
100
- * from an existing tool id (a built-in or another entry). Own fields win. */
101
- extends?: string;
102
- /** The ROUTING KIND this tool authors — the core's client kind (the geometry
103
- * it draws + the props key). Usually the PDF subtype, but not always:
104
- * `free-text-callout` routes the callout gesture onto a free-text
105
- * annotation, and `widget-text`/`widget-choice`/`widget-toggle` are client
106
- * views of the ONE PDF `widget` subtype (a form tool's commit goes through
107
- * `doc.forms`, never this plugin — see the form plugin's tool table).
108
- * Defaults to the inherited kind, or the id when neither is given. */
109
- subtype?: Subtype;
110
- /** The kind whose editable-property specs a style panel shows for this tool.
111
- * Defaults to `subtype` (a callout authors `free-text` props, for example). */
112
- propsKind?: string;
113
- /** ADVANCED: the `defaults` key this tool reads/writes. Defaults to the id, and
114
- * that is almost always right — override it only to alias a shared defaults bag
115
- * (the built-in insert-caret tool points its preset at the `caret` key). */
116
- preset?: string;
117
- /** Seed defaults for newly drawn annotations — the flat AnnotationProps patch,
118
- * merged over any inherited defaults (line endings merge per side). */
119
- defaults?: ToolDefaultsFor<K>;
120
- /**
121
- * `/F` annotation flags seeded on everything this tool creates, merged over
122
- * the drawn default (`print` set — Acrobat parity) and any inherited seed.
123
- * A note tool passes `{ noZoom: true, noRotate: true }` so its icons stay
124
- * screen-sized and upright (the spec's rule for Text annotations).
125
- */
126
- flags?: Partial<AnnotationFlags>;
127
- /** The pointer cursor while this tool is active. Defaults inherited / `crosshair`. */
128
- cursor?: string;
129
- /** Interaction capability tags this tool enables (which handlers wake up). */
130
- enables?: string[];
131
- /**
132
- * How the click-to-place payload resolves. Stamps take the full spec
133
- * ({@link StampSourceSpec}: fixed bytes or prompt); file attachments are
134
- * prompt-only ({@link PromptSourceSpec} — the file always comes from the
135
- * environment). Other kinds carry no payload.
136
- */
137
- source?: K extends 'stamp' ? StampSourceSpec : K extends 'file-attachment' ? PromptSourceSpec : never;
138
- /** What a committed text selection authors. Omit for pointer/click tools. */
139
- selection?: SelectionAuthoring;
140
- /** PDF `/IT` authored by an intent-bearing ink preset. */
141
- intent?: K extends 'ink' ? InkIntent : never;
142
- /** Ink-only stroke grouping and straightening policy. */
143
- ink?: K extends 'ink' ? InkAuthoringOptions : never;
144
- /**
145
- * Place annotations UPRIGHT: counter-rotate what this tool creates against the
146
- * page's TOTAL display rotation (document /Rotate + any stage view rotation),
147
- * so it reads horizontally exactly as the author saw it — Adobe's behaviour
148
- * for stamps and text on rotated pages. WYSIWYG at authoring time: the
149
- * rotation is baked into the annotation, so a save keeps what the author saw
150
- * (other viewers apply only /Rotate — document that when view rotation is in
151
- * play). Box kinds only (stamp / free-text, where reading orientation is
152
- * meaningful); ignored by vertex kinds and callouts. Default: on for the
153
- * built-in `stamp` and `free-text` tools, off elsewhere.
154
- */
155
- upright?: boolean;
156
- /**
157
- * What a bare CLICK creates (v2's `clickBehavior`): a default-size shape
158
- * centred on the point / a default-length line from it / free-text's
159
- * type-here box — page-clamped, in PDF pt. `false` = drag-only. Defaults:
160
- * on for the built-in square/circle/line/free-text, off elsewhere.
161
- */
162
- clickCreate?: ClickCreate | false;
163
- /**
164
- * The armed-tool in-page preview ({@link GhostPolicy}). Defaults: inherited,
165
- * else off (the built-in stamp declares `footprint`).
166
- */
167
- ghost?: GhostPolicy;
168
- /** Opaque presentation hints (label/icon…) for a toolbar or cursor that builds
169
- * itself from the tool table. Never read by the plugin or the interaction hub. */
170
- meta?: Record<string, unknown>;
171
- }
172
- interface BuiltinToolKindMap {
173
- square: 'square';
174
- circle: 'circle';
175
- line: 'line';
176
- polygon: 'polygon';
177
- polyline: 'polyline';
178
- ink: 'ink';
179
- 'ink-highlight': 'ink';
180
- 'free-text': 'free-text';
181
- 'free-text-callout': 'free-text-callout';
182
- highlight: 'highlight';
183
- underline: 'underline';
184
- strikeout: 'strikeout';
185
- squiggly: 'squiggly';
186
- 'insert-text': 'caret';
187
- 'replace-text': 'strikeout';
188
- redact: 'redact';
189
- stamp: 'stamp';
190
- note: 'text';
191
- attachment: 'file-attachment';
192
- link: 'link';
193
- }
194
- type DirectToolDef = { [K in ToolAuthoringKind]: Omit<AnnotationToolDef<K>, 'subtype'> & {
195
- subtype: K;
196
- }; }[ToolAuthoringKind];
197
- type BuiltinToolOverride = { [I in keyof BuiltinToolKindMap]: Omit<AnnotationToolDef<BuiltinToolKindMap[I]>, 'id' | 'extends' | 'subtype'> & {
198
- id: I;
199
- extends?: never;
200
- subtype?: never;
201
- }; }[keyof BuiltinToolKindMap];
202
- type ExtendedBuiltinToolDef = { [I in keyof BuiltinToolKindMap]: Omit<AnnotationToolDef<BuiltinToolKindMap[I]>, 'extends' | 'subtype'> & {
203
- extends: I;
204
- subtype?: never;
205
- }; }[keyof BuiltinToolKindMap];
206
- /** Public tool input: known overrides, known-base presets, or an explicit subtype. */
207
- type AnnotationToolInput = DirectToolDef | BuiltinToolOverride | ExtendedBuiltinToolDef;
208
- /** A fully-resolved tool — what the plugin, handlers, and registration loop read. */
209
- interface ResolvedTool {
210
- id: string;
211
- /** Routing token for the draw core + the created annotation's PDF subtype. */
212
- subtype: Subtype;
213
- /** The `defaults` key (always the tool id) — keeps same-subtype tools apart. */
214
- preset: string;
215
- /** The `propsFor` key for the style panel. */
216
- propsKind: string;
217
- cursor: string;
218
- enables: ReadonlySet<string>;
219
- defaults?: AnnotationPropsPatch;
220
- /** `/F` seed for created annotations (see {@link AnnotationToolDef.flags}). */
221
- flags?: Partial<AnnotationFlags>;
222
- source?: StampSourceSpec;
223
- selection?: SelectionAuthoring;
224
- intent?: InkIntent;
225
- ink?: InkAuthoringOptions;
226
- /** Counter-rotate creations against the page's display rotation (see
227
- * {@link AnnotationToolDef.upright}). */
228
- upright: boolean;
229
- /** What a bare click creates, or `false` for drag-only. */
230
- clickCreate: ClickCreate | false;
231
- /** The armed-tool in-page preview ({@link GhostPolicy}). */
232
- ghost: GhostPolicy;
233
- meta?: Record<string, unknown>;
234
- }
235
- /**
236
- * The built-in tools — a data mirror of v2's registrations (shapes + lines + ink
237
- * + free text in the draw channel, text markup + caret behind text selection, and
238
- * the click-to-place stamp). Order is display-neutral; the toolbar owns layout.
239
- */
240
- declare const DEFAULT_TOOLS: AnnotationToolInput[];
241
- /**
242
- * Resolve {@link DEFAULT_TOOLS} + embedder overrides into the ready-to-use table.
243
- * A same-id override merges over the built-in; a new id adds a tool; `extends`
244
- * inherits from an already-defined tool. Keyed by id, so lookups are O(1).
245
- */
246
- declare function buildToolRegistry(overrides?: AnnotationToolInput[]): Map<string, ResolvedTool>;
247
- //#endregion
248
- //#region src/types.d.ts
249
- /**
250
- * Selection-chrome settings: the outline, resize/vertex handles, and the rotate
251
- * knob. ONE unit story — every length is CSS px, screen-constant across zoom
252
- * (the plugin converts to content units per event/page via the view scale).
253
- * Every color falls back to `accent`, so the common case is one line:
254
- * `annotationPlugin({ chrome: { accent: '#e91e63' } })`. Deep-partial merged
255
- * over {@link DEFAULT_CHROME}; live-adjustable via
256
- * {@link AnnotationCapability.setChrome}.
257
- */
258
- interface ChromeSettings {
259
- /** The one color every chrome piece derives from unless overridden. */
260
- accent: string;
261
- outline: {
262
- /** ONE style at rest AND while rotated — the box never flips style mid-gesture. */
263
- style: 'solid' | 'dashed';
264
- /** Stroke width, px. */
265
- width: number;
266
- /** Overrides `accent`. */
267
- color?: string;
268
- };
269
- /** Resize + vertex handles (independent of the knob — size them apart). */
270
- handles: {
271
- /** Visual square side, px. */
272
- size: number;
273
- /** Grab-zone square side, px — keep ≥ 24 for touch. */
274
- hitSize: number;
275
- fill: string;
276
- /** Overrides `accent`. */
277
- stroke?: string;
278
- };
279
- /** The rotate handle. Page-bound placement (flip/clamp) always applies. */
280
- knob: {
281
- /** Grab-dot diameter, px. */
282
- size: number;
283
- /** Grab-zone square side, px — keep ≥ 24 for touch. */
284
- hitSize: number;
285
- /** Stalk length, px — selection edge to dot centre. */
286
- offset: number;
287
- /** Draw the connector stalk. */
288
- stalk: boolean;
289
- fill: string;
290
- /** Overrides `accent` (dot outline + stalk). */
291
- stroke?: string;
292
- };
293
- /** The rotation guides shown while a rotate gesture runs: a fixed 0°/90°
294
- * reference cross + a live indicator line, drawn as full-bleed chords of the
295
- * page through the pivot. */
296
- guides: {
297
- /** Show the guides at all. Default true. */
298
- enabled: boolean;
299
- style: 'solid' | 'dashed';
300
- /** Stroke width, px. */
301
- width: number;
302
- /** The fixed reference cross. Color overrides `accent`. */
303
- axisColor?: string;
304
- axisOpacity: number;
305
- /** The line riding the live angle. Color overrides `accent`. */
306
- indicatorColor?: string;
307
- indicatorOpacity: number;
308
- };
309
- }
310
- /** Deep-partial patch for {@link ChromeSettings} — config + `setChrome` input. */
311
- interface ChromeSettingsPatch {
312
- accent?: string;
313
- outline?: Partial<ChromeSettings['outline']>;
314
- handles?: Partial<ChromeSettings['handles']>;
315
- knob?: Partial<ChromeSettings['knob']>;
316
- guides?: Partial<ChromeSettings['guides']>;
317
- }
318
- interface AnnotationState {
319
- model: Model;
320
- chrome: ChromeSettings;
321
- /**
322
- * The armed tool's FOOTPRINT ghost: where (and what) the NEXT click would
323
- * place — the stamp's fitted image box, or a click-create tool's default
324
- * geometry — computed by the same rules the placement uses (WYSIWYG). In the
325
- * store (not the capability closure) because it is RENDERED — vector ghosts
326
- * ride `pageItems`, image ghosts (stamp) render via the framework's
327
- * `ToolGhost`. The armed bytes stay out of the store.
328
- */
329
- toolGhost: ToolGhost | null;
330
- /** Bumps on every arm/disarm — the render layer's cue to rebuild (or drop)
331
- * the ghost preview object URL. Never rendered itself. */
332
- stampArmEpoch: number;
333
- }
334
- /** The armed tool's would-be placement under the cursor (content space). */
335
- type ToolGhost = {
336
- pon: PageObjectNumber;
337
- /** The exact box the click's placement would use. */
338
- box: Rect;
339
- /** The tool's upright counter-rotation at this hover (deg, CW). */
340
- rot: number;
341
- } & ({
342
- kind: 'image';
343
- } | {
344
- kind: 'vector';
345
- toolId: string;
346
- geom: Geom;
347
- });
348
- /** Registration options for {@link annotationPlugin} — the initial values of the
349
- * live-adjustable {@link AnnotationCapability.setSnap} /
350
- * {@link AnnotationCapability.setChrome} settings. */
351
- interface AnnotationConfig {
352
- snap?: {
353
- /** Alignment guides while moving (snap to other annotations + the page).
354
- * Default true. */
355
- guides?: boolean;
356
- /** Guide snap tolerance, content units (PDF pt). Default 5. */
357
- guideThreshold?: number;
358
- /** Snap the rotate gesture onto `rotationAngles`. Default true. */
359
- rotation?: boolean;
360
- /** Default `[0, 90, 180, 270]`. */
361
- rotationAngles?: number[];
362
- /** Rotation snap tolerance, degrees. Default 4. */
363
- rotationThreshold?: number;
364
- };
365
- /** Selection-chrome styling + grab geometry (all lengths CSS px). */
366
- chrome?: ChromeSettingsPatch;
367
- /**
368
- * Add or configure authoring tools at load. Entries MERGE over the built-ins by
369
- * id (configure one — `{ id: 'ink', defaults: { strokeWidth: 6 } }`), ADD a new
370
- * tool (a fresh id), or make a preset with `extends`
371
- * (`{ id: 'arrow', extends: 'line', defaults: { lineEndings: { end: 'open-arrow' } } }`).
372
- * See {@link AnnotationToolDef}. The runtime equivalent is
373
- * {@link AnnotationCapability.registerTool}.
374
- */
375
- tools?: AnnotationToolInput[];
376
- }
377
- type AnnotationAction = {
378
- type: 'SET_MODEL';
379
- model: Model;
380
- } | {
381
- type: 'SET_CHROME';
382
- patch: ChromeSettingsPatch;
383
- } | {
384
- type: 'SET_TOOL_GHOST';
385
- ghost: ToolGhost | null;
386
- } | {
387
- type: 'STAMP_ARM_CHANGED';
388
- };
389
- /** A plugin (forms, links) marks some annotations as interactive: while engaged,
390
- * they render their own DOM and are NOT geometry-editable. Suspend → editable. */
391
- /**
392
- * One clickable link area on a page (content space): a standalone link
393
- * annotation, or one segment of a parent's ATTACHED link. See
394
- * {@link AnnotationHostCapability.linkItemsOn}.
395
- */
396
- interface LinkNavItem {
397
- /** Stable per-page key: the annot id, `#n`-suffixed for attached segments. */
398
- id: string;
399
- rect: Rect;
400
- target: PdfLinkTarget;
401
- }
402
- interface Behavior {
403
- id: string;
404
- matches(a: {
405
- subtype: Subtype;
406
- ref: AnnotationRef | null;
407
- }): boolean;
408
- engaged(): boolean;
409
- }
410
- /**
411
- * The current selection's editable properties, ready to render: the ordered
412
- * {@link PropSpec}s EVERY selected kind declares (a mixed selection shows the
413
- * shared subset, in the first kind's order), the first member's `values`, and
414
- * which keys differ across members (`mixed` — render an indeterminate control).
415
- * Empty `specs` = nothing selected / nothing editable.
416
- */
417
- interface SelectionProps {
418
- specs: PropSpec[];
419
- values: Partial<AnnotationProps>;
420
- mixed: PropKey[];
421
- }
422
- /**
423
- * The selection's `/F` flag state, ready for a menu/sidebar: one value per
424
- * flag — `true`/`false` when every selected annotation agrees, `null` when
425
- * they differ (render an indeterminate control). The read half of
426
- * {@link AnnotationCapability.updateSelectionFlags}.
427
- */
428
- type SelectionFlags = { [K in keyof AnnotationFlags]: boolean | null; };
429
- /**
430
- * A free-text annotation projected for the framework: the box (content space,
431
- * live gesture applied) + the plain text + an `editing` flag + a ready-to-spread
432
- * CSS style. The framework renders ONE editable element from this and nothing
433
- * more — all the mapping (fonts, colours, alignment) is done here, once.
434
- */
435
- interface TextItem {
436
- id: Id;
437
- ref: AnnotationRef | null;
438
- box: Rect;
439
- contents: string;
440
- editing: boolean;
441
- /** Applied rotation (deg, CW). `box` is the UNROTATED text box; the framework
442
- * rotates the editable element about its centre by this. 0/undefined = none. */
443
- rot?: number;
444
- css: {
445
- fontFamily: string;
446
- /** Content units (the framework multiplies by the page scale). */
447
- fontSize: number;
448
- lineHeight: number;
449
- color: string;
450
- align: 'left' | 'center' | 'right';
451
- padding: number;
452
- /** `/C` box background as a CSS colour, or null for transparent. */
453
- background: string | null;
454
- };
455
- }
456
- /**
457
- * The PUBLIC annotation API — the documented, stable surface for application code
458
- * (toolbars, sidebars, app logic). Resolve it with the token re-exported from the
459
- * package root (`@embedpdf/plugin-annotation`).
460
- *
461
- * Framework-only plumbing (render projection, pointer gestures, behavior
462
- * registration) lives on {@link AnnotationHostCapability}, reachable only through
463
- * the `@embedpdf/plugin-annotation/internal` entry. Both are the SAME runtime
464
- * object — two typed lenses on one token — so app code simply can't see the host
465
- * methods.
466
- */
467
- interface AnnotationCapability {
468
- /**
469
- * Create an annotation on a page. `draft` is the engine-core draft for its
470
- * subtype (PDF-space, sRGB). Resolves to the new annotation's durable `ref`.
471
- * The same path the draw tools use, so programmatic and interactive creation
472
- * share one optimistic flow + one event stream.
473
- */
474
- create(pon: PageObjectNumber, draft: AnnotationDraft): Promise<AnnotationRef>;
475
- /**
476
- * Patch an existing annotation. `patch` is the engine-core patch for the
477
- * annotation's subtype — style, endings, contents, geometry are ALL just
478
- * fields here (there is no separate "set style"). Attribution is automatic
479
- * from the session identity.
480
- */
481
- update(ref: AnnotationRef, patch: AnnotationPatch): Promise<void>;
482
- /** Delete an annotation by ref. */
483
- delete(ref: AnnotationRef): Promise<void>;
484
- /**
485
- * Restyle the current selection with ONE flat property patch — the write half
486
- * of {@link getSelectionProps}. Each selected annotation takes the keys its
487
- * kind declares (`propsFor`) and ignores the rest, so a single patch restyles
488
- * a mixed selection. Optimistic: the model updates immediately; one engine
489
- * write per changed member re-syncs from the authoritative DTO.
490
- */
491
- updateSelection(patch: AnnotationPropsPatch): void;
492
- /**
493
- * Merge a `/F` flags patch into the current selection — the write half of
494
- * {@link getSelectionFlags}. Optimistic; one flags-only engine write per
495
- * changed member, which never re-bakes an appearance. Deliberately NOT
496
- * blocked by `locked`: this is how you unlock (Acrobat's Locked checkbox
497
- * stays live on a locked annotation). E.g. `{ locked: true }`,
498
- * `{ print: false }`, `{ hidden: true }`.
499
- */
500
- updateSelectionFlags(patch: Partial<AnnotationFlags>): void;
501
- /**
502
- * The selection's `/F` flag state: per-flag `true`/`false`, or `null` when
503
- * the selected annotations disagree (indeterminate). `null` overall when
504
- * nothing is selected. Stable reference between model changes.
505
- */
506
- getSelectionFlags(): SelectionFlags | null;
507
- /**
508
- * The selection's editable properties: ordered specs shared by every selected
509
- * kind + current values + which keys are mixed. THE way to build a property
510
- * sidebar/toolbar — render `specs` in order, write back via
511
- * {@link updateSelection}. Stable reference between model changes.
512
- */
513
- getSelectionProps(): SelectionProps;
514
- /** The ordered property specs a TOOL's target kind declares (callout → the
515
- * free-text kind). Drives the same sidebar when nothing is selected, paired
516
- * with {@link currentDefaults}/{@link setDefaults}. */
517
- propsForTool(toolId: string): PropSpec[];
518
- canCreate(): boolean;
519
- canEdit(ref: AnnotationRef): boolean;
520
- canDelete(ref: AnnotationRef): boolean;
521
- /** The annotation for a ref, or null if unknown / not yet committed. */
522
- get(ref: AnnotationRef): AnnotationDTO | null;
523
- /** Every committed annotation on a page, in z-order. */
524
- list(pon: PageObjectNumber): AnnotationDTO[];
525
- /** The selected annotations as DTOs (skips not-yet-committed drafts). */
526
- getSelected(): AnnotationDTO[];
527
- selection(): Id[];
528
- /** The current selection as durable annotation refs (skips not-yet-committed drafts). */
529
- getSelection(): AnnotationRef[];
530
- /**
531
- * Select an annotation by ref programmatically — e.g. auto-selecting a
532
- * freshly placed form widget. Selecting a group member takes the whole
533
- * group, exactly like a click. Unknown/unselectable refs no-op. `add`
534
- * extends the current selection instead of replacing it.
535
- */
536
- select(ref: AnnotationRef, options?: {
537
- add?: boolean;
538
- }): void;
539
- /** Group the current selection into one unit (the bottom-most member is the
540
- * primary; the rest become `/RT /Group` subordinates). Page-local: no-op
541
- * unless 2+ committed annotations on a single page are selected. */
542
- group(): Promise<void>;
543
- /** Ungroup the group(s) the current selection touches — every subordinate
544
- * becomes top-level again. */
545
- ungroup(): Promise<void>;
546
- /** Whether {@link group} would do something for the current selection. */
547
- canGroup(): boolean;
548
- /** Whether {@link ungroup} would do something for the current selection. */
549
- canUngroup(): boolean;
550
- /** Patch a tool's defaults for newly drawn annotations — the SAME flat
551
- * vocabulary {@link updateSelection} writes. */
552
- setDefaults(subtype: Subtype, patch: AnnotationPropsPatch): void;
553
- /** The RESOLVED full props bag a tool will use for new annotations. */
554
- currentDefaults(subtype: Subtype): AnnotationProps;
555
- /** Live-adjust snapping — wire a UI toggle here (e.g.
556
- * `setSnap({ guides: false })`). Initial values come from the plugin's
557
- * registration config ({@link AnnotationConfig}). */
558
- setSnap(patch: Partial<SnapSettings>): void;
559
- /** The current snap settings. */
560
- snapSettings(): SnapSettings;
561
- /** Live-adjust the selection chrome — wire theming here (e.g.
562
- * `setChrome({ accent: '#e91e63' })`). Deep-partial merge; initial values
563
- * come from the plugin's registration config ({@link AnnotationConfig}). */
564
- setChrome(patch: ChromeSettingsPatch): void;
565
- /** The current (fully resolved) chrome settings. */
566
- chromeSettings(): ChromeSettings;
567
- /** Rotate the current selection a quarter-turn clockwise about its centre
568
- * (a single shape's own centre / the union-box centre for a group). */
569
- rotateSelection90(): void;
570
- /** Reset the current selection to its as-authored orientation (rotation → 0). */
571
- resetSelectionRotation(): void;
572
- /**
573
- * Arm the stamp tool: `source` (PNG, JPEG, or single-page PDF bytes —
574
- * format sniffed, never trusted) becomes the content of the next stamp(s)
575
- * placed by clicking a page. The placement rect is sized from the image's
576
- * intrinsic aspect ratio around `targetWidth` (PDF points, default 150)
577
- * and centred on the click. Also activates the `'stamp'` interaction tool;
578
- * the payload stays armed for repeat placement until the tool changes or
579
- * {@link disarmStamp} is called. Resolves once the payload is validated.
580
- */
581
- armStamp(input: StampToolInput): Promise<void>;
582
- /** Drop the armed stamp payload (a tool change away from 'stamp' does this too). */
583
- disarmStamp(): void;
584
- /**
585
- * Install the ONE file-picker port every click-then-pick tool resolves
586
- * through (see {@link FilePickerProvider}) — the stamp `'prompt'` source and
587
- * the file-attachment tool today. The framework adapter installs a
588
- * file-dialog provider by default; pass your own (asset library, cloud
589
- * drive — switch on `req.subtype` / `req.toolId`), or `null` to make
590
- * click-then-pick tools inert. One slot; last write wins.
591
- */
592
- setFilePickerProvider(provider: FilePickerProvider | null): void;
593
- /**
594
- * Decode and return the file embedded in a FileAttachment annotation —
595
- * bytes plus the name/mime needed to hand it to the user. Listings carry
596
- * only metadata (`FileAttachmentAnnotationDTO.file`); this is the explicit
597
- * bytes-out call. Throws when the engine transport has not shipped
598
- * attachment download (feature-detected).
599
- */
600
- downloadAttachment(ref: AnnotationRef): Promise<AttachmentContent>;
601
- /**
602
- * Register (or replace, by id) an authoring tool at runtime — the imperative
603
- * mirror of the `tools` config. Same {@link AnnotationToolDef} vocabulary
604
- * (`extends`, per-tool `defaults`, …). Returns an unregister fn.
605
- */
606
- registerTool(def: AnnotationToolInput): () => void;
607
- /**
608
- * Turn the CURRENT text selection into markup annotations — one per
609
- * selected page, from the selection's oriented per-line quads — then clear
610
- * the selection. The one-call form of what the markup tools do on
611
- * commit, made for selection-menu buttons ("Highlight") and automation.
612
- * `preset` is a tool id whose defaults style the markup (e.g.
613
- * `'highlight'`); defaults to the subtype's own. Returns false (and does
614
- * nothing) when no selection plugin is installed or nothing is selected.
615
- */
616
- markupFromSelection(subtype: Subtype, preset?: string): boolean;
617
- /** Commit the in-progress multi-click creation draft (no-op when there is
618
- * none, or it can't finish yet — see `creationDraftAnchor().canFinish`). */
619
- finishCreationDraft(): void;
620
- /** Discard the in-progress multi-click creation draft. */
621
- cancelCreationDraft(): void;
622
- deleteSelection(): void;
623
- deselect(): void;
624
- cancel(): void;
625
- }
626
- /** Payload for {@link AnnotationCapability.armStamp}. */
627
- interface StampToolInput {
628
- /** PNG, JPEG, or single-page PDF bytes (`Blob | Uint8Array | BinaryPayload`). */
629
- source: BinarySource;
630
- /** Placed width in PDF points (height follows the intrinsic aspect). Default 150. */
631
- targetWidth?: number;
632
- /**
633
- * A browser-paintable render of `source` for the hover ghost (PNG/JPEG).
634
- * Required for the ghost when `source` is PDF bytes — the browser cannot
635
- * paint those; the caller (e.g. a stamp library) supplies its cached page
636
- * render. Raster sources default to the source itself; omit everywhere
637
- * else and the tool simply shows no ghost.
638
- */
639
- preview?: BinarySource;
640
- /**
641
- * The source's intrinsic size in PDF points. Raster sources are measured
642
- * from their own header, but PDF bytes carry no sniffable dimensions —
643
- * callers that know the page size (a stamp library does, from import)
644
- * pass it here so placement honours the true aspect instead of falling
645
- * back to a square.
646
- */
647
- intrinsicSize?: {
648
- width: number;
649
- height: number;
650
- };
651
- }
652
- /** The armed stamp's paintable preview, for the render layer's ghost `<img>`. */
653
- interface ArmedStampPreview {
654
- bytes: Uint8Array;
655
- mimeType?: string;
656
- }
657
- /**
658
- * What the {@link FilePickerProvider} is asked for: which tool clicked (id +
659
- * the kind it creates), the tool's `accept` filter, and the page-space point
660
- * the click landed on — enough to route per tool (asset library for stamps,
661
- * cloud drive for attachments) or position a picker near the click. Pure
662
- * data — the request crosses the plugin↔adapter boundary as a message.
663
- */
664
- interface FilePromptRequest {
665
- toolId: string;
666
- /** The kind the placement creates — the routing key for per-tool pickers. */
667
- subtype: Subtype;
668
- /** The tool's file-dialog filter hint (from the tool def). UX only —
669
- * the engine sniffs/validates the bytes for real. */
670
- accept?: string;
671
- pon: PageObjectNumber;
672
- /** The content-space point the placement is centred on. */
673
- point: Vec;
674
- }
675
- /**
676
- * The ONE environment port behind every click-then-pick tool — the stamp
677
- * `'prompt'` source and the file-attachment tool (the file is picked AFTER
678
- * the spot): given a click, produce the file to place, `null` to cancel. The
679
- * plugin declares this contract but never implements it — "get bytes from the
680
- * environment" is a DOM concern (a file dialog), so the framework adapter
681
- * installs the implementation via
682
- * {@link AnnotationCapability.setFilePickerProvider}. This keeps the plugin
683
- * DOM-free (Rust-portable) while the zero-config file dialog works out of the
684
- * box. The return shape is the engine's file vocabulary: a stamp consumes
685
- * only `data`; an attachment embeds the whole thing. A picked `File` carries
686
- * its own name and mime — a provider returning raw bytes for an attachment
687
- * must supply `name` itself.
688
- */
689
- type FilePickerProvider = (req: FilePromptRequest) => Promise<AttachmentFileSource | null>;
690
- /**
691
- * The HOST (framework) surface: everything the render layer, the interaction hub,
692
- * and sibling plugins need, on top of the public {@link AnnotationCapability}.
693
- * Internal — import the token from `@embedpdf/plugin-annotation/internal`, never
694
- * from application code.
695
- */
696
- interface AnnotationHostCapability extends AnnotationCapability {
697
- /** `view` (the page's scale + total display rotation, from its transform)
698
- * projects screen-anchored (`noZoom`/`noRotate`) bodies to their effective
699
- * footprint. Pass it from the page context; absent → stored geometry. */
700
- pageItems(pon: PageObjectNumber, view?: ViewEnv): RenderItem[];
701
- /** `scale` (view px per content unit, from the page's transform) converts the
702
- * px chrome settings into content units — pass it so the knob stalk and grab
703
- * zones are screen-constant. `rotation` (the page's total display rotation)
704
- * and `zoom` (the page's zoom RELATIVE to its 100% baseline —
705
- * `transform.zoom`, NOT `viewScale`) complete the view env for
706
- * screen-anchored bodies. Absent scale → settings are read as content
707
- * units. */
708
- chrome(pon: PageObjectNumber, scale?: number, rotation?: PageRotation, zoom?: number): ChromeNode[];
709
- /** The anchor for a selection-aware floating menu: the primary page + the
710
- * selection's union box on that page (content space), or null when nothing
711
- * selectable is selected. One anchor regardless of cross-page selection.
712
- * `scale`/`rotation`/`zoom` as in {@link chrome} (the anchor page's view). */
713
- selectionAnchor(scale?: number, rotation?: PageRotation, zoom?: number): {
714
- pon: PageObjectNumber;
715
- bounds: Rect;
716
- knob?: Vec;
717
- } | null;
718
- /** The anchor + action state for a live multi-click creation draft, or null. */
719
- creationDraftAnchor(): CreationDraftAnchor | null;
720
- /** Cache key for a page's baked appearances: the COMMITTED id + AP box of every
721
- * baked annotation (gesture previews excluded). Changes exactly once per
722
- * committed create/geometry-edit, so the render layer refetches rasters then —
723
- * and only then (a stamp resize re-fits its AP engine-side, for example). */
724
- appearanceEpoch(pon: PageObjectNumber): string;
725
- /**
726
- * The scale a baked appearance should render at for a desired device
727
- * scale — `snapAppearanceScale` over the document's `renderPolicy` (the
728
- * kernel-materialized fact; identity under `continuous`). THE identity a
729
- * render layer keys its bake effect on: inside an appearance-lattice rung,
730
- * zoom ticks produce the same value → no re-bake; crossing a rung re-bakes
731
- * once. This plugin owns its raster product end to end — the policy is a
732
- * document fact, not another plugin's possession.
733
- */
734
- bakeScale(renderScale: number): number;
735
- /** The engine's rendered /AP appearance images for a page — the `baked` visual. */
736
- appearances(pon: PageObjectNumber, scale: number, signal?: AbortSignal): Promise<AnnotationAppearanceImage[]>;
737
- /** Convert an engine appearance rect (PDF user space) to a content-space box, so
738
- * the renderer places the baked bitmap by its OWN `/Rect` without touching the
739
- * PDF↔content seam. Null if the page's crop box is unknown. */
740
- toContentBox(pon: PageObjectNumber, rect: PdfRect): Rect | null;
741
- ensurePage(pon: PageObjectNumber): void;
742
- /**
743
- * Drop and RE-READ one page's annotations from the engine — the hook for
744
- * cross-plane mutations (e.g. `doc.forms.createField`/`deleteField`
745
- * changing the page's widget population underneath this plugin). Resolves
746
- * when the fresh page is in the model, so a caller can select what it just
747
- * created.
748
- */
749
- reloadPage(pon: PageObjectNumber): Promise<void>;
750
- /** The free-text boxes on a page, ready to render as editable elements.
751
- * `view` as in {@link pageItems}. */
752
- textItems(pon: PageObjectNumber, view?: ViewEnv): TextItem[];
753
- /** The id of the annotation currently being text-edited, or null. Read live (not
754
- * from a stale render) so the editor can tell a real exit from a focus-steal. */
755
- currentEditing(): Id | null;
756
- /** Enter text-edit on a free-text annotation (focus its editable element). */
757
- beginTextEdit(ref: AnnotationRef): void;
758
- /** Enter text-edit on whatever free-text box is under a content point — wired
759
- * to a double-click / long-press by the interaction edit handler. Returns
760
- * whether an editable free-text was actually found and opened; false lets
761
- * the caller fall through to a normal press (so a long-press on a highlight
762
- * selects it instead of being swallowed by a no-op edit attempt). */
763
- beginTextEditAt(pon: PageObjectNumber, point: Vec, scale?: number, rotation?: PageRotation, zoom?: number): boolean;
764
- /** Apply the editor's plain text — optimistic locally, debounced to the engine. */
765
- setContents(ref: AnnotationRef, text: string): void;
766
- /** Leave text-edit (flush any pending write). */
767
- endTextEdit(): void;
768
- /** What's under a content point — for the edit handler's capture decision.
769
- * `scale` (the page's view px per content unit) keeps grab zones
770
- * screen-constant; `rotation` + `zoom` (relative, `transform.zoom`)
771
- * complete the view env for screen-anchored bodies. Pass all three from
772
- * the pointer sample. */
773
- hitKind(pon: PageObjectNumber, point: Vec, scale?: number, rotation?: PageRotation, zoom?: number,
774
- /** Widen grab zones to finger-sized targets (pass `pointerType === 'touch'`). */
775
- touch?: boolean): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';
776
- /**
777
- * TOUCH CONSENT (the interaction hub's `claimsTouch` predicate): should a
778
- * finger landing here own a TOOL gesture instead of navigating? True over
779
- * the selection's chrome (resize handles, rotate knob, group box) and over
780
- * the body of an already-SELECTED, transformable annotation — never over an
781
- * unselected one, so annotation-dense pages still scroll; tap-select first
782
- * is the platform convention (Apple Markup). Uses finger-sized grab zones.
783
- * Pure read.
784
- */
785
- claimsTouchAt(pon: PageObjectNumber, point: Vec, scale?: number, rotation?: PageRotation, zoom?: number): boolean;
786
- /** The cursor to show at a content point (resize over a handle, move/pointer over a body, else null). */
787
- cursorAt(pon: PageObjectNumber, point: Vec, scale?: number, rotation?: PageRotation, zoom?: number): string | null;
788
- /**
789
- * Report the pointer's position for hover state (`null` = off every page).
790
- * Diffs the topmost hit against the model and dispatches only on CHANGE
791
- * (enter/leave cadence) — drives scene-level hover affordances like the
792
- * redaction mark's applied-look preview. Called from the edit handler's
793
- * onHover, which already samples every move for cursor claims.
794
- */
795
- hoverAt(at: {
796
- pon: PageObjectNumber;
797
- point: Vec;
798
- scale?: number;
799
- rotation?: PageRotation;
800
- zoom?: number;
801
- } | null): void;
802
- behaviorFor(a: {
803
- subtype: Subtype;
804
- ref: AnnotationRef | null;
805
- }): Behavior | null;
806
- /**
807
- * The clickable link areas of a page (content space): standalone link
808
- * annotations plus every ATTACHED-link segment (folded children — their
809
- * rects derived by the SAME rule the reconciler writes, so the clickable
810
- * area and the written `/Rect`s can't disagree). Hidden annotations are
811
- * excluded. THE data feed for the navigation plane (plugin-link);
812
- * memoized by model identity for selector use.
813
- */
814
- linkItemsOn(pon: PageObjectNumber): LinkNavItem[];
815
- /** Drop selected annotations whose Behavior is currently ENGAGED — inert
816
- * things cannot stay selected. Call after anything that flips engagement
817
- * (the plugin wires it to tool changes). */
818
- pruneEngagedSelection(): void;
819
- editPointer(phase: 'down' | 'move' | 'up', pon: PageObjectNumber, point: Vec, shift: boolean, scale?: number, rotation?: PageRotation, zoom?: number,
820
- /** Finger-sized grab zones for the gesture's own hit resolution — pass the
821
- * sample's `pointerType === 'touch'` so the gesture grabs exactly what
822
- * {@link claimsTouchAt} claimed. */
823
- touch?: boolean): void;
824
- marqueePointer(phase: 'down' | 'move' | 'up', pon: PageObjectNumber, point: Vec, shift: boolean, scale?: number, rotation?: PageRotation, zoom?: number): void;
825
- /** Run the draw gesture for an authoring TOOL (by id). The plugin resolves it
826
- * to a routing subtype + defaults preset; a bare subtype also works (headless).
827
- * `displayRotation` (the DOWN sample's page rotation: /Rotate + view rotation)
828
- * feeds the tool's `upright` policy — omit it and upright is a no-op. */
829
- createPointer(tool: string, phase: 'down' | 'move' | 'up', pon: PageObjectNumber, point: Vec, finish?: boolean, displayRotation?: PageRotation): void;
830
- /** Commit the strokes currently buffered by an ink tool's grouping window. */
831
- finishInkDraft(): void;
832
- /** Create one text-markup annotation on a page from the selected text's
833
- * per-line oriented quads (content space) — the `text-selection` create
834
- * gesture. Axis-aligned callers build quads with `textQuadFromRect`. */
835
- createMarkup(subtype: Subtype, pon: PageObjectNumber, quads: TextQuad[], preset?: string): void;
836
- /** Create a caret annotation at a text-selection end anchor. */
837
- createCaret(pon: PageObjectNumber, anchor: TextEndAnchor): void;
838
- /** Create one Adobe-compatible Caret + StrikeOut replace-text group. */
839
- createReplaceText(pon: PageObjectNumber, quads: TextQuad[], anchor: TextEndAnchor, preset?: string): void;
840
- /** Set the live markup preview from the selection's per-page quads (renders a
841
- * ghost that looks like the markup it will become). */
842
- previewMarkup(subtype: Subtype, quadsByPage: Record<number, TextQuad[]>, preset?: string): void;
843
- clearMarkupPreview(): void;
844
- /** Place the armed stamp centred on a content point. Returns false (no
845
- * capture) when nothing is armed. `displayRotation` (the click sample's page
846
- * rotation) feeds the active tool's `upright` policy. */
847
- placeArmedStamp(pon: PageObjectNumber, point: Vec, displayRotation?: PageRotation): boolean;
848
- /**
849
- * The one click-to-place entry for every payload-carrying tool (stamp /
850
- * note / file attachment) — the place handler forwards each down here.
851
- * Armed payload first, then the active tool's kind routes; returns whether
852
- * the click was consumed.
853
- */
854
- placeAt(pon: PageObjectNumber, point: Vec, displayRotation?: PageRotation): boolean;
855
- /** Whether a stamp payload is armed — the hover handler's cheap pre-check. */
856
- hasArmedStamp(): boolean;
857
- /**
858
- * Update the armed tool's FOOTPRINT ghost to a content point — the stamp's
859
- * fitted image box (same fit + clamp as placement), or a click-create tool's
860
- * default geometry (same anchor + clamp as the click commit). The ghost IS
861
- * the placement, never an approximation. Tools without a determinable
862
- * footprint (or with a `false` ghost policy) clear instead.
863
- */
864
- ghostHoverAt(toolId: string, pon: PageObjectNumber, point: Vec, displayRotation?: PageRotation): void;
865
- /** Drop the hover ghost (pointer left the pages / a gesture started). */
866
- clearGhost(): void;
867
- /**
868
- * Drive the transient placement preview during an EXTERNALLY-owned creation
869
- * gesture (the form plugin's drag-to-place): the box the commit would use,
870
- * page-clamped, styled from the TOOL's defaults, painted through the same
871
- * ghost pipeline as every footprint. Sibling plugins call THIS — never the
872
- * annotation store directly.
873
- */
874
- setPlacementPreview(toolId: string, pon: PageObjectNumber, box: Rect): void;
875
- /** Drop the placement preview (gesture ended — commit, cancel, or error). */
876
- clearPlacementPreview(): void;
877
- /** The armed tool's footprint ghost on a page (content space), or null.
878
- * Vector ghosts also ride {@link pageItems}; only `kind: 'image'` ghosts
879
- * need the framework's blit. */
880
- toolGhost(pon: PageObjectNumber): ToolGhost | null;
881
- /** The armed stamp's paintable preview bytes, or null (no ghost to show). */
882
- armedStampPreview(): ArmedStampPreview | null;
883
- /** Bumps on arm/disarm — keys the render layer's preview object-URL lifetime. */
884
- stampArmEpoch(): number;
885
- /**
886
- * Resolve the ACTIVE tool's {@link StampSourceSpec} for a click and place a
887
- * stamp centred on `point`: fixed `bytes` land immediately; a `'prompt'` source
888
- * asks the installed {@link FilePickerProvider} (placement is dropped if it
889
- * cancels, or if the tool/document changed while it was open). Returns false
890
- * (no capture) when the active tool has no source. The click-then-pick
891
- * counterpart of {@link placeArmedStamp}. `displayRotation` as on
892
- * {@link placeArmedStamp}.
893
- */
894
- requestStampAt(pon: PageObjectNumber, point: Vec, displayRotation?: PageRotation): boolean;
895
- /** Every resolved tool (built-ins + config `tools`), for the registration loop. */
896
- tools(): ResolvedTool[];
897
- /** One resolved tool by id, or null when it is not registered. */
898
- tool(id: string): ResolvedTool | null;
899
- /** A tool's routing subtype (arrow → `line`) — how the draw handler picks the
900
- * gesture and the created annotation's PDF kind. Falls back to the id. */
901
- toolSubtype(id: string): Subtype;
902
- registerBehavior(b: Behavior): () => void;
903
- }
904
- /**
905
- * The annotation capability token. Typed to the full {@link AnnotationHostCapability}
906
- * here (the package internals + the `/internal` entry use this view). The package
907
- * root re-exports the SAME token narrowed to {@link AnnotationCapability}.
908
- */
909
- declare const AnnotationToken: import("@embedpdf/core").CapabilityToken<AnnotationHostCapability>;
910
- //#endregion
911
- export { PromptSourceSpec as C, ToolAuthoringKind as D, StampSourceSpec as E, ToolDefaultsFor as O, InkAuthoringOptions as S, SelectionAuthoring as T, ToolGhost as _, AnnotationState as a, DEFAULT_TOOLS as b, ChromeSettings as c, FilePromptRequest as d, LinkNavItem as f, TextItem as g, StampToolInput as h, AnnotationHostCapability as i, buildToolRegistry as k, ChromeSettingsPatch as l, SelectionProps as m, AnnotationCapability as n, AnnotationToken as o, SelectionFlags as p, AnnotationConfig as r, Behavior as s, AnnotationAction as t, FilePickerProvider as u, AnnotationToolDef as v, ResolvedTool as w, GhostPolicy as x, AnnotationToolInput as y };
912
- //# sourceMappingURL=types-CvtDbnF5.d.cts.map