@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,335 @@
1
+ import { Et as TextItem, G as ArmedStampInfo, K as ArmedStampPreview, Kt as EditorSelection, N as AnnotationSelectionAnchor, Vt as ResolvedTool, Y as Behavior, ft as ImageGhost, gt as LinkNavItem, i as AnnotationAnchor, o as AnnotationCapability, r as Annotation$1 } from "./contract-CBYEqnev.cjs";
2
+ import { ChromeNode, EditableKinds, Effect, Id, KindName, Model, Point, Quad, Rect, RenderItem, SceneNode, Session, SnapSettings, TextEndAnchor, ViewEnv } from "@embedpdf/core-annotation";
3
+ import { EventHook, PredictedOp, Unsubscribe } from "@embedpdf/core";
4
+ import { Rotation } from "@embedpdf/core-geometry";
5
+ import { AnnotationAppearanceImage, AnnotationPosition, AnnotationRef, ChangeOp, ImageSource, PageMeasurementViewport, PageRef, PdfMeasure, RichTextParagraph, SerializedEngineError } from "@embedpdf/engine-core/runtime";
6
+ import { AnnotationCommitEntry, AnnotationCommitResult } from "@embedpdf/plugin-actions/contract/host";
7
+ import { AppearancePicture } from "@embedpdf/plugin-render/contract/host";
8
+ //#region src/model.d.ts
9
+ /** Where the active tool's ghost is: the pointer on a page, and how that page shows there. */
10
+ interface GhostPointer {
11
+ readonly toolId: string;
12
+ readonly page: PageRef;
13
+ readonly point: Point;
14
+ /** The page's display rotation at the pointer (an upright tool lays its click out as seen). */
15
+ readonly displayRotation?: Rotation;
16
+ /** The page's zoom at the pointer (a screen-sized icon's size depends on it). */
17
+ readonly zoom?: number;
18
+ }
19
+ /** A sibling plugin's placement gesture with one of this plugin's tools: its press, and the pointer now. */
20
+ interface ForeignPlacement {
21
+ readonly toolId: string;
22
+ readonly page: PageRef;
23
+ readonly from: Point;
24
+ readonly to: Point;
25
+ }
26
+ interface AnnotationModel {
27
+ /** The core's session: selection, hover, the gesture in progress, tool settings. */
28
+ readonly session: Session;
29
+ /**
30
+ * Records this session renders from their description instead of the
31
+ * engine's raster: the ones it edited or created. Another session's edit
32
+ * hands a record back to the raster (see sync/confirmed.ts).
33
+ */
34
+ readonly vector: Readonly<Record<Id, true>>;
35
+ /**
36
+ * Where the active tool's ghost is: the pointer, while a click there would
37
+ * make something. Only the pointer is state; what the ghost paints is
38
+ * derived from it and the tool's live defaults (tools/ghost.ts).
39
+ */
40
+ readonly ghostAt: GhostPointer | null;
41
+ /**
42
+ * A placement a sibling plugin's gesture is making with one of this
43
+ * plugin's tools (the form palette's drag-to-place). Once it is a drag it
44
+ * paints as a drawing in progress (tools/ghost.ts).
45
+ */
46
+ readonly placing: ForeignPlacement | null;
47
+ /**
48
+ * The text editor's selection inside the annotation being edited (flat
49
+ * offsets over its plain text), or null. It is state because the property
50
+ * surface reads it: while a range is held, the text style keys report and
51
+ * change the runs it covers; at a caret, the text typed there next, with the
52
+ * style chosen at the caret.
53
+ */
54
+ readonly textSelection: EditorSelection | null;
55
+ }
56
+ //#endregion
57
+ //#region src/priorities.d.ts
58
+ /**
59
+ * The interaction-hub priorities of the annotation plugin's handlers — the
60
+ * public contract a sibling plugin builds on when it needs to sit above or
61
+ * below one of them for the same gesture. Priority only breaks ties between
62
+ * simultaneously-eligible handlers (the tool's tags decide eligibility).
63
+ *
64
+ * 100 annotation-edit select/move/resize over an existing annotation
65
+ * 95 annotation-place click-to-place an armed payload on empty page space
66
+ * 55 annotation-draw drag-create under a draw tool (below text-select)
67
+ * 50 annotation-marquee empty-space selection, the final fallback
68
+ *
69
+ * Hover runs in the same order, so a handler's hover sees the cursor claims
70
+ * of every handler above it: a create handler shows its tool's ghost only
71
+ * where nothing above it claims the pointer (an annotation, text).
72
+ *
73
+ * A handler that must win a click over an existing annotation while a
74
+ * placing tool is active (a signature mark dropped onto a signature field)
75
+ * registers above {@link ANNOTATION_EDIT_PRIORITY}, not merely above place:
76
+ * the edit handler captures first over any annotation, a widget included.
77
+ */
78
+ declare const ANNOTATION_EDIT_PRIORITY = 100;
79
+ declare const ANNOTATION_PLACE_PRIORITY = 95;
80
+ declare const ANNOTATION_DRAW_PRIORITY = 55;
81
+ declare const ANNOTATION_MARQUEE_PRIORITY = 50;
82
+ //#endregion
83
+ //#region src/host-contract.d.ts
84
+ /**
85
+ * One annotation's look at rest in one of its states, as the render layer
86
+ * paints it: the engine's picture, or, while the annotation's create is on
87
+ * its way, the one this device made (a placed stamp's preview), which the
88
+ * engine's replaces. `version` is the record's picture version it shows
89
+ * (`RenderItem.pictureVersion`): one drawn at another version shows another look.
90
+ */
91
+ interface AnnotationAppearancePicture extends Pick<AnnotationAppearanceImage, 'ref' | 'mode' | 'state' | 'rect'> {
92
+ readonly image: ImageSource;
93
+ readonly version: number;
94
+ }
95
+ /**
96
+ * A sibling plugin that lends this plugin records it owns (the form plugin's
97
+ * widgets), so they are selected, moved, resized, restyled and deleted with
98
+ * the annotation tools. This plugin never stores them: it shows them as the
99
+ * lender says, and an edit of one becomes the lender's ops, in the same change
100
+ * as the rest of the edit.
101
+ */
102
+ interface AnnotationLender {
103
+ /** Who owns the records, for a refusal that sends you there (`'form'`). */
104
+ readonly owner: string;
105
+ /**
106
+ * Its records as the engine confirmed them and as they show, each list the
107
+ * same object until it changes; `null` while it lends none.
108
+ */
109
+ records(): {
110
+ readonly confirmed: readonly Annotation$1[];
111
+ readonly shown: readonly Annotation$1[];
112
+ } | null;
113
+ /**
114
+ * The ops that write a message's effects on its records, all at once:
115
+ * `model` is the model the message left, `before` the one it started from
116
+ * (a record it deleted is there).
117
+ */
118
+ opsOf(effects: readonly Effect[], model: Model, before: Model): readonly ChangeOp[];
119
+ /** What undoing these ops looks like. */
120
+ undoOf(ops: readonly ChangeOp[]): readonly PredictedOp[];
121
+ /** The ops that move these records of one page to `position` in its drawing order. */
122
+ reorderOps(page: PageRef, refs: readonly AnnotationRef[], position: AnnotationPosition): readonly ChangeOp[];
123
+ /** Whether this session may change and delete the record. */
124
+ getAuthority(record: Annotation$1): {
125
+ readonly update: boolean;
126
+ readonly delete: boolean;
127
+ };
128
+ /** What its records' pictures on a page depend on: a new value means new pictures. */
129
+ getPictureEpoch(page: PageRef): string;
130
+ /** A record's confirmed picture version; kept for one that went, so an undo brings it back with it. */
131
+ getPictureVersion(record: AnnotationRef): number;
132
+ /**
133
+ * The record's look as it shows isn't its confirmed look yet, whatever changed it (a restyle,
134
+ * a resize, one just placed, a change the lender made itself): it draws live, by its
135
+ * {@link painter}, until the engine's picture of it is there.
136
+ */
137
+ isPending(record: AnnotationRef): boolean;
138
+ /**
139
+ * How the lender draws the record live: the record upright in `box` (its box, or where a
140
+ * gesture has it), in page space; `null` for one it doesn't draw. A record with a painter
141
+ * draws live while a gesture reshapes it, as a square does.
142
+ */
143
+ painter(record: Annotation$1): ((box: Rect) => readonly SceneNode[]) | null;
144
+ /** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */
145
+ renderAppearances(page: PageRef, scale: number, signal?: AbortSignal): Promise<readonly AppearancePicture[]>;
146
+ }
147
+ interface RecalibrationReport {
148
+ page: PageRef;
149
+ scale: PdfMeasure;
150
+ /** Page-wide read failure: no complete annotation set was available to recalculate. */
151
+ error?: SerializedEngineError;
152
+ updated: AnnotationRef[];
153
+ skipped: {
154
+ ref: AnnotationRef;
155
+ reason: 'no-authority' | 'locked' | 'foreign-measure' | 'unavailable';
156
+ }[];
157
+ failed: {
158
+ ref: AnnotationRef;
159
+ error: SerializedEngineError;
160
+ }[];
161
+ }
162
+ interface CapturedAnnotationDraft {
163
+ tool: string;
164
+ page: PageRef;
165
+ from: Point;
166
+ to: Point;
167
+ }
168
+ /**
169
+ * Ghost render buckets: powers of two from 128 px up to `cap`. The same policy
170
+ * the page renderer uses — one bitmap per size class, never per zoom step.
171
+ */
172
+ declare function previewBucket(devicePixelWidth: number, maxWidth?: number): number;
173
+ /**
174
+ * The host (framework) surface: everything the render layer, the interaction hub,
175
+ * and sibling plugins need, on top of the public {@link AnnotationCapability}.
176
+ * Host-only: sibling plugins and framework adapters import the token from
177
+ * `@embedpdf/plugin-annotation/contract/host`. Never use it from application code.
178
+ */
179
+ interface AnnotationHostCapability extends AnnotationCapability {
180
+ setPageViewports(page: PageRef, viewports: PageMeasurementViewport[] | undefined, fallback: PdfMeasure): void;
181
+ remeasurePage(page: PageRef, scale: PdfMeasure): Promise<RecalibrationReport>;
182
+ /** A distance draft was captured (the measurement plugin turns it into a calibration). */
183
+ readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;
184
+ getDistanceCreationPage(): PageRef | null;
185
+ /**
186
+ * The selection's anchor as a page shows it: its rotation handle where the
187
+ * page's view puts it (screen-sized, so it depends on the zoom), for a menu
188
+ * that stays clear of it. `selection.getAnchor()` is the same without a view.
189
+ */
190
+ getSelectionAnchorIn(view: {
191
+ scale?: number;
192
+ rotation?: Rotation;
193
+ zoom?: number;
194
+ }): AnnotationSelectionAnchor | null;
195
+ /**
196
+ * Where UI attaches to one annotation (its page and the box around what it
197
+ * shows, a drag in progress included), or `null` for one that isn't here.
198
+ * Without a view, an annotation that keeps its size on screen carries
199
+ * `boundsIn` for the view it's shown in.
200
+ */
201
+ getAnnotationAnchor(ref: AnnotationRef, view?: ViewEnv): AnnotationAnchor | null;
202
+ listPageItems(page: PageRef, view?: ViewEnv): RenderItem[];
203
+ /**
204
+ * The text boxes the layer draws as elements: the ones typed in or redrawn
205
+ * live. A saved, idle one shows its engine picture instead.
206
+ */
207
+ listTextItems(page: PageRef, view?: ViewEnv): TextItem[];
208
+ /**
209
+ * One free text's text box in every state, saved and idle included: for a
210
+ * renderer that draws the box itself (`useRichTextEditor`), which no
211
+ * engine picture is drawn under. `null` for one that isn't a free text here.
212
+ */
213
+ getTextItem(ref: AnnotationRef, view?: ViewEnv): TextItem | null;
214
+ listChromeNodes(page: PageRef, scale?: number, rotation?: Rotation, zoom?: number): ChromeNode[];
215
+ listLinkItems(page: PageRef): LinkNavItem[];
216
+ /**
217
+ * What a page's pictures depend on: its baked records at their picture
218
+ * versions, the stamps this session placed, the pictures kept for an undone
219
+ * delete and the lender's widgets. Load the pictures again when it changes,
220
+ * or when the appearance scale (`render.getAppearanceScale`) does.
221
+ */
222
+ getAppearanceEpoch(page: PageRef): string;
223
+ /**
224
+ * Every picture a page's annotations show at rest, in every state, each
225
+ * with its record's picture version: the engine's (through the render
226
+ * plugin; none without it), the lender's, and this session's placed stamps.
227
+ */
228
+ renderAppearances(page: PageRef, scale: number, signal?: AbortSignal): Promise<AnnotationAppearancePicture[]>;
229
+ /**
230
+ * Resolves once the annotations mirror has applied every confirmed change
231
+ * it knows of, including page re-reads that events started.
232
+ */
233
+ whenSynced(): Promise<void>;
234
+ getEditingId(): Id | null;
235
+ beginTextEditAt(page: PageRef, point: Point, scale?: number, rotation?: Rotation, zoom?: number): boolean;
236
+ draftContents(ref: AnnotationRef, text: string): void;
237
+ /** Returns the paragraphs it keeps: the text typed at the caret takes a style chosen there. */
238
+ draftRichText(ref: AnnotationRef, doc: {
239
+ paragraphs: RichTextParagraph[];
240
+ }): {
241
+ paragraphs: RichTextParagraph[];
242
+ };
243
+ setTextSelection(ref: AnnotationRef, range: {
244
+ start: number;
245
+ end: number;
246
+ } | null): void;
247
+ /**
248
+ * The CSS family list a face is drawn with in a text box (`id`; `null` for
249
+ * none yet): the font programs the engine draws it in, with the fonts
250
+ * plugin installed.
251
+ */
252
+ getCssFontFamily(face: {
253
+ family: string;
254
+ weight: number;
255
+ italic: boolean;
256
+ }, id: string | null): string;
257
+ /** The family a CSS family a text box was drawn with stands for, for text the browser drew itself. */
258
+ getFamilyOfCss(cssFamily: string): string | undefined;
259
+ getHitKind(page: PageRef, point: Point, scale?: number, rotation?: Rotation, zoom?: number, touch?: boolean): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';
260
+ claimsTouchAt(page: PageRef, point: Point, scale?: number, rotation?: Rotation, zoom?: number): boolean;
261
+ getCursorAt(page: PageRef, point: Point, scale?: number, rotation?: Rotation, zoom?: number): string | null;
262
+ hoverAt(at: {
263
+ page: PageRef;
264
+ point: Point;
265
+ scale?: number;
266
+ rotation?: Rotation;
267
+ zoom?: number;
268
+ } | null): void;
269
+ editPointer(phase: 'down' | 'move' | 'up', page: PageRef, point: Point, shift: boolean, scale?: number, rotation?: Rotation, zoom?: number, touch?: boolean): void;
270
+ marqueePointer(phase: 'down' | 'move' | 'up', page: PageRef, point: Point, shift: boolean, scale?: number, rotation?: Rotation, zoom?: number): void;
271
+ createPointer(tool: string, phase: 'down' | 'move' | 'up', page: PageRef, point: Point, finish?: boolean, displayRotation?: Rotation): void;
272
+ finishInkDraft(): void;
273
+ /** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */
274
+ placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;
275
+ placeArmedStamp(page: PageRef, point: Point, displayRotation?: Rotation): boolean;
276
+ requestStampAt(page: PageRef, point: Point, displayRotation?: Rotation): boolean;
277
+ /**
278
+ * Turn the text selection into what the tool makes of it (markup, a caret,
279
+ * a replace-text pair) and clear the selection; `false`, and nothing, for a
280
+ * tool that makes nothing of a selection, without create authority, or
281
+ * without a selection.
282
+ */
283
+ applyToolToSelection(toolId: string): boolean;
284
+ createMarkup(subtype: KindName, page: PageRef, quads: Quad[], preset?: string): void;
285
+ createCaret(page: PageRef, anchor: TextEndAnchor): void;
286
+ createReplaceText(page: PageRef, quads: Quad[], anchor: TextEndAnchor, preset?: string): void;
287
+ previewMarkup(subtype: KindName, quadsByPage: Record<number, Quad[]>, preset?: string): void;
288
+ clearMarkupPreview(): void;
289
+ /**
290
+ * Put the tool's ghost at a hover, what a click there would make;
291
+ * `displayRotation` and `zoom` are the page's view there. The handler that
292
+ * would take the click calls it, only where the click would reach it and
293
+ * the user may create; a tool without a ghost clears it.
294
+ */
295
+ hoverGhostAt(toolId: string, page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): void;
296
+ clearGhost(): void;
297
+ /**
298
+ * A sibling plugin's placement gesture with one of this plugin's tools (the
299
+ * form palette's drag-to-place): its press and the pointer now. Once it is a
300
+ * drag, the page paints what releasing places; under that the tool's ghost
301
+ * still shows the click.
302
+ */
303
+ previewPlacement(toolId: string, page: PageRef, from: Point, to: Point): void;
304
+ clearPlacementPreview(): void;
305
+ /** The armed stamp's ghost on a page, for the render layer's `<img>`. */
306
+ getImageGhost(page: PageRef): ImageGhost | null;
307
+ /** The armed stamp: a new object on every arm, null when nothing is armed. */
308
+ getArmedStamp(): ArmedStampInfo | null;
309
+ /** Render the armed stamp's ghost preview for a device pixel width (cached per size bucket). */
310
+ renderArmedStampPreview(devicePixelWidth?: number): Promise<ArmedStampPreview | null>;
311
+ /**
312
+ * Show a sibling's records with the annotations and edit them with the same
313
+ * tools (see {@link AnnotationLender}). One lender at a time; returns the
314
+ * release.
315
+ */
316
+ lend(lender: AnnotationLender): Unsubscribe;
317
+ listResolvedTools(): ResolvedTool[];
318
+ getResolvedTool(id: string): ResolvedTool | null;
319
+ getToolSubtype(id: string): KindName;
320
+ registerBehavior(behavior: Behavior): Unsubscribe;
321
+ /** The engaged behavior that owns this annotation now, or `null`. */
322
+ getBehaviorFor(annotation: Annotation$1): Behavior | null;
323
+ pruneEngagedSelection(): void;
324
+ commitScriptEffects(entries: AnnotationCommitEntry[]): Promise<AnnotationCommitResult>;
325
+ }
326
+ /**
327
+ * The annotation capability token, typed to the full
328
+ * {@link AnnotationHostCapability} (the package internals and `/contract/host`
329
+ * use this view). The package root exports the same runtime token narrowed to
330
+ * {@link AnnotationCapability}.
331
+ */
332
+ declare const AnnotationToken: import("@embedpdf/core").CapabilityToken<AnnotationHostCapability>;
333
+ //#endregion
334
+ export { CapturedAnnotationDraft as a, ANNOTATION_DRAW_PRIORITY as c, ANNOTATION_PLACE_PRIORITY as d, AnnotationModel as f, AnnotationToken as i, ANNOTATION_EDIT_PRIORITY as l, AnnotationHostCapability as n, RecalibrationReport as o, AnnotationLender as r, previewBucket as s, AnnotationAppearancePicture as t, ANNOTATION_MARQUEE_PRIORITY as u };
335
+ //# sourceMappingURL=host-contract-CxOrR_pp.d.cts.map