@embedpdf/core-annotation 3.0.0-next.13 → 3.0.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnnotationDTO, AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationRef, BlendMode, BlendMode as BlendMode$1, CaretIntent, InkIntent, LineEnding, LineEndings, NO_ANNOTATION_FLAGS, PdfLinkTarget, PdfPoint, PdfRect, RichTextDocumentInput, RichTextParagraph, RichTextRunStyle, StrikeoutIntent } from "@embedpdf/engine-core/runtime";
1
+ import { AnnotationDTO, AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationRef, BlendMode, BlendMode as BlendMode$1, CaretIntent, InkIntent, LineDimensionCaption, LineEnding, LineEndings, LineLeader, NO_ANNOTATION_FLAGS, PdfLinkTarget, PdfMeasurement, PdfPoint, PdfRect, RichTextDocumentInput, RichTextParagraph, RichTextRunStyle, ShapeDimensionCaption, StrikeoutIntent } from "@embedpdf/engine-core/runtime";
2
2
  import { PageObjectNumber } from "@embedpdf/core";
3
3
  import { PageRotation, Point, Rect as Rect$1, Size, TextQuad, TextQuad as TextQuad$1 } from "@embedpdf/core-geometry";
4
4
  //#region src/flags.d.ts
@@ -46,6 +46,92 @@ declare const annotDeletable: (a: FlagBearer) => boolean;
46
46
  /** `/Contents` text edits — the contents counterpart of `locked`. */
47
47
  declare const annotContentsEditable: (a: FlagBearer) => boolean;
48
48
  //#endregion
49
+ //#region src/measurement-shape.d.ts
50
+ interface ShapeMeasurementAppearance {
51
+ intent: 'PolyLineDimension' | 'PolygonDimension';
52
+ measure: PdfMeasurement | null;
53
+ caption: ShapeDimensionCaption;
54
+ crop: PdfRect;
55
+ text: string;
56
+ }
57
+ interface ShapeMeasurementLayout {
58
+ caption: DistanceCaptionLayout | null;
59
+ visualBounds: Rect;
60
+ selectionPoints: Vec[];
61
+ }
62
+ /** The public caption center stays in PDF space; the editor draws in content space. */
63
+ declare function shapeCaptionPoint(appearance: ShapeMeasurementAppearance): Vec | undefined;
64
+ declare function withShapeCaptionPoint(appearance: ShapeMeasurementAppearance, center: Vec): ShapeMeasurementAppearance;
65
+ declare function transformMeasurementCaption(appearance: MeasurementAppearance | undefined, transform: (point: Vec) => Vec): MeasurementAppearance | undefined;
66
+ declare function shapeMeasurementReadout(geom: Geom, appearance: ShapeMeasurementAppearance): import("@embedpdf/engine-core/runtime").MeasurementReadout | import("@embedpdf/engine-core/runtime").MeasurementUnavailable;
67
+ declare function shapeMeasurementLabel(geom: Geom, appearance: ShapeMeasurementAppearance): string;
68
+ /** Match the native shape-caption anchor, including an interior fallback for concave areas. */
69
+ declare function automaticShapeCaptionCenter(points: readonly Vec[], closed: boolean): Vec;
70
+ declare function shapeMeasurementLayout(geom: Geom, appearance: ShapeMeasurementAppearance, style: Style): ShapeMeasurementLayout | null;
71
+ declare function measurementLayout(geom: Geom, appearance: MeasurementAppearance, style: Style): ShapeMeasurementLayout | null;
72
+ declare function measurementSelectionQuad(geom: Geom, appearance: MeasurementAppearance, style: Style): Quad;
73
+ declare function moveMeasurementCaption(geom: Geom, appearance: MeasurementAppearance, delta: Vec, style: Style): MeasurementAppearance;
74
+ //#endregion
75
+ //#region src/measurement.d.ts
76
+ type MeasurementAppearance = DistanceAppearance | ShapeMeasurementAppearance;
77
+ /**
78
+ * A distance annotation's render projection. Offsets stay in directed PDF line
79
+ * axes. The crop keeps numeric rounding in the original PDF coordinate frame.
80
+ */
81
+ interface DistanceAppearance {
82
+ intent: 'LineDimension';
83
+ measure: PdfMeasurement | null;
84
+ caption: LineDimensionCaption;
85
+ leader?: LineLeader;
86
+ crop: PdfRect;
87
+ text: string;
88
+ }
89
+ interface DistanceSegment {
90
+ from: Vec;
91
+ to: Vec;
92
+ }
93
+ interface DistanceCaptionLayout {
94
+ text: string;
95
+ center: Vec;
96
+ along: Vec;
97
+ normal: Vec;
98
+ width: number;
99
+ height: number;
100
+ bounds: Quad;
101
+ }
102
+ /** One layout drives the preview, selection, handles, and hit testing. */
103
+ interface DistanceLayout {
104
+ along: Vec;
105
+ normal: Vec;
106
+ length: number;
107
+ measuredStart: Vec;
108
+ measuredEnd: Vec;
109
+ dimensionStart: Vec;
110
+ dimensionEnd: Vec;
111
+ dimensionSegments: DistanceSegment[];
112
+ leaderSegments: DistanceSegment[];
113
+ captionConnector: DistanceSegment[];
114
+ caption: DistanceCaptionLayout | null;
115
+ arrowPlacement: 'inside' | 'outside';
116
+ endings: RenderNode[];
117
+ selectionPoints: Vec[];
118
+ visualBounds: Rect;
119
+ }
120
+ declare function distanceLabel(geom: Geom, appearance: DistanceAppearance): string;
121
+ declare function distanceLayout(geom: Geom, appearance: DistanceAppearance, strokeWidth: number): DistanceLayout | null;
122
+ declare function expandDistanceBounds(bounds: Rect, padding: number): Rect;
123
+ declare function distanceSelectionQuad(geom: Geom, appearance: DistanceAppearance, strokeWidth: number): Quad;
124
+ declare function distanceHandles(layout: DistanceLayout): Handle[];
125
+ declare function distanceCaptionHit(layout: {
126
+ caption: DistanceCaptionLayout | null;
127
+ }, point: Vec, margin?: number): boolean;
128
+ declare function distanceHit(layout: DistanceLayout, point: Vec, strokeWidth: number, margin: number): boolean;
129
+ declare function distanceCaptionAt(geom: Geom, appearance: DistanceAppearance, width: number): Vec | null;
130
+ declare function distanceLeaderLength(geom: Geom, point: Vec): number;
131
+ declare function moveDistanceCaption(geom: Geom, appearance: DistanceAppearance, delta: Vec): DistanceAppearance;
132
+ declare function distanceScene(geom: Geom, appearance: DistanceAppearance, style: Style): SceneNode[];
133
+ declare function measurementCaptionScene(caption: DistanceCaptionLayout | null, style: Style): SceneNode[];
134
+ //#endregion
49
135
  //#region src/types.d.ts
50
136
  /**
51
137
  * Content-space point/rect (y-down, PDF points, crop-relative) — the viewer space.
@@ -245,6 +331,10 @@ type PropKey = keyof AnnotationProps;
245
331
  */
246
332
  type PatchScope = {
247
333
  kind: 'geometry';
334
+ } | {
335
+ kind: 'caption';
336
+ } | {
337
+ kind: 'leader';
248
338
  } | {
249
339
  kind: 'props';
250
340
  keys: PropKey[];
@@ -268,6 +358,7 @@ interface Annot {
268
358
  text: string;
269
359
  repeat: boolean;
270
360
  };
361
+ measure?: MeasurementAppearance;
271
362
  /** `/Name` icon — present only for icon kinds (text note, file attachment).
272
363
  * Like `style`, a projection of `data`, editable via `setProps`. */
273
364
  icon?: string;
@@ -404,8 +495,20 @@ type Draft = {
404
495
  /** The tool's `/F` seed, captured at DOWN like `upright` — merged over
405
496
  * {@link DRAWN_FLAGS} at commit (a note tool sets noZoom/noRotate). */
406
497
  flags?: Partial<AnnotationFlags$1>;
498
+ } | {
499
+ g: 'create-distance';
500
+ step: 'endpoints' | 'offset';
501
+ subtype: 'line';
502
+ preset: string;
503
+ pon: PageObjectNumber;
504
+ from: Vec;
505
+ to: Vec;
506
+ measure: DistanceAppearance;
507
+ flags?: Partial<AnnotationFlags$1>;
407
508
  } | {
408
509
  g: 'create-line';
510
+ measure?: MeasurementAppearance;
511
+ capture?: string;
409
512
  subtype: Subtype;
410
513
  preset?: string;
411
514
  pon: PageObjectNumber;
@@ -417,6 +520,7 @@ type Draft = {
417
520
  flags?: Partial<AnnotationFlags$1>;
418
521
  } | {
419
522
  g: 'create-poly';
523
+ measure?: ShapeMeasurementAppearance;
420
524
  subtype: Subtype;
421
525
  preset?: string;
422
526
  pon: PageObjectNumber;
@@ -483,6 +587,16 @@ type Draft = {
483
587
  base: Rect;
484
588
  cur: Rect;
485
589
  view?: ViewEnv;
590
+ } | {
591
+ g: 'caption';
592
+ id: Id;
593
+ start: Vec;
594
+ delta: Vec;
595
+ } | {
596
+ g: 'leader';
597
+ id: Id;
598
+ start: Vec;
599
+ delta: number;
486
600
  } | {
487
601
  g: 'marquee';
488
602
  pon: PageObjectNumber;
@@ -631,6 +745,8 @@ type Msg = {
631
745
  in: PointerInput;
632
746
  } | {
633
747
  t: 'createPointer';
748
+ measure?: MeasurementAppearance;
749
+ capture?: string;
634
750
  phase: 'down' | 'move' | 'up';
635
751
  subtype: Subtype;
636
752
  /** The authoring tool's `defaults` key (see {@link Draft}). Defaults to `subtype`. */
@@ -767,6 +883,11 @@ type Msg = {
767
883
  t: 'endTextEdit';
768
884
  };
769
885
  type Effect = {
886
+ fx: 'captured';
887
+ tool: string;
888
+ pon: number;
889
+ geom: Geom;
890
+ } | {
770
891
  fx: 'create';
771
892
  id: Id;
772
893
  } | {
@@ -850,6 +971,7 @@ interface RenderItem {
850
971
  text: string;
851
972
  repeat: boolean;
852
973
  };
974
+ measure?: MeasurementAppearance;
853
975
  /**
854
976
  * Applied rotation (deg, CW), or 0/undefined. For BOX kinds (`rect`/`text`)
855
977
  * `box` is the UNROTATED visual box and the renderer applies this rotation
@@ -940,6 +1062,7 @@ type SceneNode = {
940
1062
  text: string;
941
1063
  fontSize: number;
942
1064
  fontFamily?: string;
1065
+ rotation?: number;
943
1066
  paint: Paint;
944
1067
  };
945
1068
  /** Pure geometry settings for recognising and axis-snapping a freehand stroke. */
@@ -1623,9 +1746,9 @@ declare function uprightAnchoredRect(anchor: Vec, width: number, height: number,
1623
1746
  */
1624
1747
  declare function fitStampBox(center: Vec, desired: Size, page: Size, rotCW: number): Rect;
1625
1748
  /** Reset a geom to its as-authored orientation (`rot → 0`). Box: drop `rot`.
1626
- * Vertex: spin the points by `-rot` about their centroid so they return to the
1627
- * orientation they were drawn at, in place. */
1628
- declare function geomResetRotation(g: Geom): Geom;
1749
+ * Vertex: spin the points by `-rot` about the supplied selection center.
1750
+ * Geometry-only callers retain the centroid default. */
1751
+ declare function geomResetRotation(g: Geom, pivot?: Vec): Geom;
1629
1752
  /**
1630
1753
  * The oriented selection box (OBB) of a rotatable geom: four corners (in order
1631
1754
  * nw, ne, se, sw of the LOCAL box, transformed) + the angle. For a box this is
@@ -1832,6 +1955,14 @@ declare function cloudyBorderExtent(intensity: number, strokeWidth: number, elli
1832
1955
  */
1833
1956
  declare function cloudyPath(box: Rect, ellipse: boolean, intensity: number, strokeWidth: number): string;
1834
1957
  //#endregion
1958
+ //#region src/selection.d.ts
1959
+ interface SelectionFrame {
1960
+ corners: Quad;
1961
+ center: Vec;
1962
+ angle: number;
1963
+ }
1964
+ declare function annotationSelectionFrame(annotation: Annot, view?: ViewEnv): SelectionFrame;
1965
+ //#endregion
1835
1966
  //#region src/scene.d.ts
1836
1967
  /** The full painted scene for one annotation. */
1837
1968
  declare function scene(item: RenderItem): SceneNode[];
@@ -1844,5 +1975,5 @@ declare function scene(item: RenderItem): SceneNode[];
1844
1975
  */
1845
1976
  declare function straightenInkStroke(points: readonly Vec[], options: InkStraightenOptions): Vec[];
1846
1977
  //#endregion
1847
- export { type AnchorMode, type Annot, type AnnotationFlags, type AnnotationKind, type AnnotationProps, type AnnotationPropsPatch, type BlendMode, type Border, type Callout, type ChromeGeom, type ChromeNode, type ClickCreate, type ClickPlacement, type CreationDraftAnchor, type Cursor, DEFAULT_CHROME_GEOM, DRAWN_FLAGS, type Draft, type Effect, FLAG_KEYS, type FlagBearer, type Geom, type GroupCaps, type Guide, type Handle, type Id, type InkStraightenOptions, KINDS, type KindCaps, type LineEnding, type LineEndings, MIN_DRAG, MITER_LIMIT, type Model, type Msg, NO_ANNOTATION_FLAGS, type Paint, type PatchScope, type PointerInput, type PropKey, type PropSpec, type Quad, RECT_HANDLES, ROTATE_KNOB_OFFSET, type Rect, type RectHandle, type RenderItem, type RenderNode, type RichTextRange, type RichTextStyleDelta, type SceneNode, type SnapResult, type SnapSettings, type Style, type Subtype, type Target, type TextAlign, type TextBox, type TextEndAnchor, type TextQuad, type TextStyle, type Vec, type ViewEnv, anchorModeOf, anchorOf, anchoredBox, anchoredGeom, anchoredStrokeWidth, annotContentsEditable, annotDeletable, annotInteractive, annotTransformable, applyProps, applyStyleToRange, calloutConnection, calloutLinePoints, canMove, capsFor, caretGeomFromAnchor, caretRectFromAnchor, caretRectFromTextEnd, centroidOf, chrome, clampRectToBox, clickCreateGeom, cloudyBorderExtent, cloudyPath, computeMoveSnap, contentToPdfPoint, contentToPdfRect, creationDraftAnchor, cursorAt, defaultsFor, expandGroups, fitStampBox, flagsEqual, geomBounds, geomDragHandle, geomHandles, geomHit, geomPdfBounds, geomResetRotation, geomRotateAbout, geomRotation, geomScaleAbout, geomScene, geomTranslate, geomVisualBounds, groupCaps, groupKeyOf, groupMembers, groupResizeAnchor, groupResizeBox, groupResizeFactors, hitTest, initialModel, initialStyle, initialTextStyle, interactive, isAttachedLink, isConversationOnly, isPlainRichText, isRotatableGeom, isSelectable, isSubstrateOnly, linkChildrenOf, linkOf, locateOffset, mergeFlags, normalizeDeg, normalizeRuns, obbFromGeom, pageItems, paragraphsFromPlainText, pdfToContentPoint, pdfToContentRect, placeRotateKnob, plainTextOf, pointInQuad, propsFor, quadIntersectsRect, rangeHasStyle, readProp, rectFromPoints, resolveClickPlacement, richTextLength, rotateDraftDelta, rotateKnob, rotatedAabb, rotatedHandleCursor, sameStyleDelta, scene, selectedItems, selectionAnchor, selectionBounds, selectionBoundsOnPage, selectionCenter, selectionKnob, selectionQuad, shapeRectFor, sharedProps, splitRunsAt, straightenInkStroke, styleAt, styleFromProps, textBoxes, textPlateInset, textStyleFromProps, transposedAboutCenter, unanchoredGeom, unionRect, update, uprightAnchoredRect, uprightRotation, viewable };
1978
+ export { type AnchorMode, type Annot, type AnnotationFlags, type AnnotationKind, type AnnotationProps, type AnnotationPropsPatch, type BlendMode, type Border, type Callout, type ChromeGeom, type ChromeNode, type ClickCreate, type ClickPlacement, type CreationDraftAnchor, type Cursor, DEFAULT_CHROME_GEOM, DRAWN_FLAGS, DistanceAppearance, DistanceCaptionLayout, DistanceLayout, DistanceSegment, type Draft, type Effect, FLAG_KEYS, type FlagBearer, type Geom, type GroupCaps, type Guide, type Handle, type Id, type InkStraightenOptions, KINDS, type KindCaps, type LineEnding, type LineEndings, MIN_DRAG, MITER_LIMIT, MeasurementAppearance, type Model, type Msg, NO_ANNOTATION_FLAGS, type Paint, type PatchScope, type PointerInput, type PropKey, type PropSpec, type Quad, RECT_HANDLES, ROTATE_KNOB_OFFSET, type Rect, type RectHandle, type RenderItem, type RenderNode, type RichTextRange, type RichTextStyleDelta, type SceneNode, type SelectionFrame, ShapeMeasurementAppearance, ShapeMeasurementLayout, type SnapResult, type SnapSettings, type Style, type Subtype, type Target, type TextAlign, type TextBox, type TextEndAnchor, type TextQuad, type TextStyle, type Vec, type ViewEnv, anchorModeOf, anchorOf, anchoredBox, anchoredGeom, anchoredStrokeWidth, annotContentsEditable, annotDeletable, annotInteractive, annotTransformable, annotationSelectionFrame, applyProps, applyStyleToRange, automaticShapeCaptionCenter, calloutConnection, calloutLinePoints, canMove, capsFor, caretGeomFromAnchor, caretRectFromAnchor, caretRectFromTextEnd, centroidOf, chrome, clampRectToBox, clickCreateGeom, cloudyBorderExtent, cloudyPath, computeMoveSnap, contentToPdfPoint, contentToPdfRect, creationDraftAnchor, cursorAt, defaultsFor, distanceCaptionAt, distanceCaptionHit, distanceHandles, distanceHit, distanceLabel, distanceLayout, distanceLeaderLength, distanceScene, distanceSelectionQuad, expandDistanceBounds, expandGroups, fitStampBox, flagsEqual, geomBounds, geomDragHandle, geomHandles, geomHit, geomPdfBounds, geomResetRotation, geomRotateAbout, geomRotation, geomScaleAbout, geomScene, geomTranslate, geomVisualBounds, groupCaps, groupKeyOf, groupMembers, groupResizeAnchor, groupResizeBox, groupResizeFactors, hitTest, initialModel, initialStyle, initialTextStyle, interactive, isAttachedLink, isConversationOnly, isPlainRichText, isRotatableGeom, isSelectable, isSubstrateOnly, linkChildrenOf, linkOf, locateOffset, measurementCaptionScene, measurementLayout, measurementSelectionQuad, mergeFlags, moveDistanceCaption, moveMeasurementCaption, normalizeDeg, normalizeRuns, obbFromGeom, pageItems, paragraphsFromPlainText, pdfToContentPoint, pdfToContentRect, placeRotateKnob, plainTextOf, pointInQuad, propsFor, quadIntersectsRect, rangeHasStyle, readProp, rectFromPoints, resolveClickPlacement, richTextLength, rotateDraftDelta, rotateKnob, rotatedAabb, rotatedHandleCursor, sameStyleDelta, scene, selectedItems, selectionAnchor, selectionBounds, selectionBoundsOnPage, selectionCenter, selectionKnob, selectionQuad, shapeCaptionPoint, shapeMeasurementLabel, shapeMeasurementLayout, shapeMeasurementReadout, shapeRectFor, sharedProps, splitRunsAt, straightenInkStroke, styleAt, styleFromProps, textBoxes, textPlateInset, textStyleFromProps, transformMeasurementCaption, transposedAboutCenter, unanchoredGeom, unionRect, update, uprightAnchoredRect, uprightRotation, viewable, withShapeCaptionPoint };
1848
1979
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AnnotationDTO, AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationRef, BlendMode, BlendMode as BlendMode$1, CaretIntent, InkIntent, LineEnding, LineEndings, NO_ANNOTATION_FLAGS, PdfLinkTarget, PdfPoint, PdfRect, RichTextDocumentInput, RichTextParagraph, RichTextRunStyle, StrikeoutIntent } from "@embedpdf/engine-core/runtime";
2
1
  import { PageRotation, Point, Rect as Rect$1, Size, TextQuad, TextQuad as TextQuad$1 } from "@embedpdf/core-geometry";
2
+ import { AnnotationDTO, AnnotationFlags, AnnotationFlags as AnnotationFlags$1, AnnotationRef, BlendMode, BlendMode as BlendMode$1, CaretIntent, InkIntent, LineDimensionCaption, LineEnding, LineEndings, LineLeader, NO_ANNOTATION_FLAGS, PdfLinkTarget, PdfMeasurement, PdfPoint, PdfRect, RichTextDocumentInput, RichTextParagraph, RichTextRunStyle, ShapeDimensionCaption, StrikeoutIntent } from "@embedpdf/engine-core/runtime";
3
3
  import { PageObjectNumber } from "@embedpdf/core";
4
4
  //#region src/flags.d.ts
5
5
  /** The `/F` every freshly DRAWN annotation starts with: `print` set (Acrobat
@@ -46,6 +46,92 @@ declare const annotDeletable: (a: FlagBearer) => boolean;
46
46
  /** `/Contents` text edits — the contents counterpart of `locked`. */
47
47
  declare const annotContentsEditable: (a: FlagBearer) => boolean;
48
48
  //#endregion
49
+ //#region src/measurement-shape.d.ts
50
+ interface ShapeMeasurementAppearance {
51
+ intent: 'PolyLineDimension' | 'PolygonDimension';
52
+ measure: PdfMeasurement | null;
53
+ caption: ShapeDimensionCaption;
54
+ crop: PdfRect;
55
+ text: string;
56
+ }
57
+ interface ShapeMeasurementLayout {
58
+ caption: DistanceCaptionLayout | null;
59
+ visualBounds: Rect;
60
+ selectionPoints: Vec[];
61
+ }
62
+ /** The public caption center stays in PDF space; the editor draws in content space. */
63
+ declare function shapeCaptionPoint(appearance: ShapeMeasurementAppearance): Vec | undefined;
64
+ declare function withShapeCaptionPoint(appearance: ShapeMeasurementAppearance, center: Vec): ShapeMeasurementAppearance;
65
+ declare function transformMeasurementCaption(appearance: MeasurementAppearance | undefined, transform: (point: Vec) => Vec): MeasurementAppearance | undefined;
66
+ declare function shapeMeasurementReadout(geom: Geom, appearance: ShapeMeasurementAppearance): import("@embedpdf/engine-core/runtime").MeasurementReadout | import("@embedpdf/engine-core/runtime").MeasurementUnavailable;
67
+ declare function shapeMeasurementLabel(geom: Geom, appearance: ShapeMeasurementAppearance): string;
68
+ /** Match the native shape-caption anchor, including an interior fallback for concave areas. */
69
+ declare function automaticShapeCaptionCenter(points: readonly Vec[], closed: boolean): Vec;
70
+ declare function shapeMeasurementLayout(geom: Geom, appearance: ShapeMeasurementAppearance, style: Style): ShapeMeasurementLayout | null;
71
+ declare function measurementLayout(geom: Geom, appearance: MeasurementAppearance, style: Style): ShapeMeasurementLayout | null;
72
+ declare function measurementSelectionQuad(geom: Geom, appearance: MeasurementAppearance, style: Style): Quad;
73
+ declare function moveMeasurementCaption(geom: Geom, appearance: MeasurementAppearance, delta: Vec, style: Style): MeasurementAppearance;
74
+ //#endregion
75
+ //#region src/measurement.d.ts
76
+ type MeasurementAppearance = DistanceAppearance | ShapeMeasurementAppearance;
77
+ /**
78
+ * A distance annotation's render projection. Offsets stay in directed PDF line
79
+ * axes. The crop keeps numeric rounding in the original PDF coordinate frame.
80
+ */
81
+ interface DistanceAppearance {
82
+ intent: 'LineDimension';
83
+ measure: PdfMeasurement | null;
84
+ caption: LineDimensionCaption;
85
+ leader?: LineLeader;
86
+ crop: PdfRect;
87
+ text: string;
88
+ }
89
+ interface DistanceSegment {
90
+ from: Vec;
91
+ to: Vec;
92
+ }
93
+ interface DistanceCaptionLayout {
94
+ text: string;
95
+ center: Vec;
96
+ along: Vec;
97
+ normal: Vec;
98
+ width: number;
99
+ height: number;
100
+ bounds: Quad;
101
+ }
102
+ /** One layout drives the preview, selection, handles, and hit testing. */
103
+ interface DistanceLayout {
104
+ along: Vec;
105
+ normal: Vec;
106
+ length: number;
107
+ measuredStart: Vec;
108
+ measuredEnd: Vec;
109
+ dimensionStart: Vec;
110
+ dimensionEnd: Vec;
111
+ dimensionSegments: DistanceSegment[];
112
+ leaderSegments: DistanceSegment[];
113
+ captionConnector: DistanceSegment[];
114
+ caption: DistanceCaptionLayout | null;
115
+ arrowPlacement: 'inside' | 'outside';
116
+ endings: RenderNode[];
117
+ selectionPoints: Vec[];
118
+ visualBounds: Rect;
119
+ }
120
+ declare function distanceLabel(geom: Geom, appearance: DistanceAppearance): string;
121
+ declare function distanceLayout(geom: Geom, appearance: DistanceAppearance, strokeWidth: number): DistanceLayout | null;
122
+ declare function expandDistanceBounds(bounds: Rect, padding: number): Rect;
123
+ declare function distanceSelectionQuad(geom: Geom, appearance: DistanceAppearance, strokeWidth: number): Quad;
124
+ declare function distanceHandles(layout: DistanceLayout): Handle[];
125
+ declare function distanceCaptionHit(layout: {
126
+ caption: DistanceCaptionLayout | null;
127
+ }, point: Vec, margin?: number): boolean;
128
+ declare function distanceHit(layout: DistanceLayout, point: Vec, strokeWidth: number, margin: number): boolean;
129
+ declare function distanceCaptionAt(geom: Geom, appearance: DistanceAppearance, width: number): Vec | null;
130
+ declare function distanceLeaderLength(geom: Geom, point: Vec): number;
131
+ declare function moveDistanceCaption(geom: Geom, appearance: DistanceAppearance, delta: Vec): DistanceAppearance;
132
+ declare function distanceScene(geom: Geom, appearance: DistanceAppearance, style: Style): SceneNode[];
133
+ declare function measurementCaptionScene(caption: DistanceCaptionLayout | null, style: Style): SceneNode[];
134
+ //#endregion
49
135
  //#region src/types.d.ts
50
136
  /**
51
137
  * Content-space point/rect (y-down, PDF points, crop-relative) — the viewer space.
@@ -245,6 +331,10 @@ type PropKey = keyof AnnotationProps;
245
331
  */
246
332
  type PatchScope = {
247
333
  kind: 'geometry';
334
+ } | {
335
+ kind: 'caption';
336
+ } | {
337
+ kind: 'leader';
248
338
  } | {
249
339
  kind: 'props';
250
340
  keys: PropKey[];
@@ -268,6 +358,7 @@ interface Annot {
268
358
  text: string;
269
359
  repeat: boolean;
270
360
  };
361
+ measure?: MeasurementAppearance;
271
362
  /** `/Name` icon — present only for icon kinds (text note, file attachment).
272
363
  * Like `style`, a projection of `data`, editable via `setProps`. */
273
364
  icon?: string;
@@ -404,8 +495,20 @@ type Draft = {
404
495
  /** The tool's `/F` seed, captured at DOWN like `upright` — merged over
405
496
  * {@link DRAWN_FLAGS} at commit (a note tool sets noZoom/noRotate). */
406
497
  flags?: Partial<AnnotationFlags$1>;
498
+ } | {
499
+ g: 'create-distance';
500
+ step: 'endpoints' | 'offset';
501
+ subtype: 'line';
502
+ preset: string;
503
+ pon: PageObjectNumber;
504
+ from: Vec;
505
+ to: Vec;
506
+ measure: DistanceAppearance;
507
+ flags?: Partial<AnnotationFlags$1>;
407
508
  } | {
408
509
  g: 'create-line';
510
+ measure?: MeasurementAppearance;
511
+ capture?: string;
409
512
  subtype: Subtype;
410
513
  preset?: string;
411
514
  pon: PageObjectNumber;
@@ -417,6 +520,7 @@ type Draft = {
417
520
  flags?: Partial<AnnotationFlags$1>;
418
521
  } | {
419
522
  g: 'create-poly';
523
+ measure?: ShapeMeasurementAppearance;
420
524
  subtype: Subtype;
421
525
  preset?: string;
422
526
  pon: PageObjectNumber;
@@ -483,6 +587,16 @@ type Draft = {
483
587
  base: Rect;
484
588
  cur: Rect;
485
589
  view?: ViewEnv;
590
+ } | {
591
+ g: 'caption';
592
+ id: Id;
593
+ start: Vec;
594
+ delta: Vec;
595
+ } | {
596
+ g: 'leader';
597
+ id: Id;
598
+ start: Vec;
599
+ delta: number;
486
600
  } | {
487
601
  g: 'marquee';
488
602
  pon: PageObjectNumber;
@@ -631,6 +745,8 @@ type Msg = {
631
745
  in: PointerInput;
632
746
  } | {
633
747
  t: 'createPointer';
748
+ measure?: MeasurementAppearance;
749
+ capture?: string;
634
750
  phase: 'down' | 'move' | 'up';
635
751
  subtype: Subtype;
636
752
  /** The authoring tool's `defaults` key (see {@link Draft}). Defaults to `subtype`. */
@@ -767,6 +883,11 @@ type Msg = {
767
883
  t: 'endTextEdit';
768
884
  };
769
885
  type Effect = {
886
+ fx: 'captured';
887
+ tool: string;
888
+ pon: number;
889
+ geom: Geom;
890
+ } | {
770
891
  fx: 'create';
771
892
  id: Id;
772
893
  } | {
@@ -850,6 +971,7 @@ interface RenderItem {
850
971
  text: string;
851
972
  repeat: boolean;
852
973
  };
974
+ measure?: MeasurementAppearance;
853
975
  /**
854
976
  * Applied rotation (deg, CW), or 0/undefined. For BOX kinds (`rect`/`text`)
855
977
  * `box` is the UNROTATED visual box and the renderer applies this rotation
@@ -940,6 +1062,7 @@ type SceneNode = {
940
1062
  text: string;
941
1063
  fontSize: number;
942
1064
  fontFamily?: string;
1065
+ rotation?: number;
943
1066
  paint: Paint;
944
1067
  };
945
1068
  /** Pure geometry settings for recognising and axis-snapping a freehand stroke. */
@@ -1623,9 +1746,9 @@ declare function uprightAnchoredRect(anchor: Vec, width: number, height: number,
1623
1746
  */
1624
1747
  declare function fitStampBox(center: Vec, desired: Size, page: Size, rotCW: number): Rect;
1625
1748
  /** Reset a geom to its as-authored orientation (`rot → 0`). Box: drop `rot`.
1626
- * Vertex: spin the points by `-rot` about their centroid so they return to the
1627
- * orientation they were drawn at, in place. */
1628
- declare function geomResetRotation(g: Geom): Geom;
1749
+ * Vertex: spin the points by `-rot` about the supplied selection center.
1750
+ * Geometry-only callers retain the centroid default. */
1751
+ declare function geomResetRotation(g: Geom, pivot?: Vec): Geom;
1629
1752
  /**
1630
1753
  * The oriented selection box (OBB) of a rotatable geom: four corners (in order
1631
1754
  * nw, ne, se, sw of the LOCAL box, transformed) + the angle. For a box this is
@@ -1832,6 +1955,14 @@ declare function cloudyBorderExtent(intensity: number, strokeWidth: number, elli
1832
1955
  */
1833
1956
  declare function cloudyPath(box: Rect, ellipse: boolean, intensity: number, strokeWidth: number): string;
1834
1957
  //#endregion
1958
+ //#region src/selection.d.ts
1959
+ interface SelectionFrame {
1960
+ corners: Quad;
1961
+ center: Vec;
1962
+ angle: number;
1963
+ }
1964
+ declare function annotationSelectionFrame(annotation: Annot, view?: ViewEnv): SelectionFrame;
1965
+ //#endregion
1835
1966
  //#region src/scene.d.ts
1836
1967
  /** The full painted scene for one annotation. */
1837
1968
  declare function scene(item: RenderItem): SceneNode[];
@@ -1844,5 +1975,5 @@ declare function scene(item: RenderItem): SceneNode[];
1844
1975
  */
1845
1976
  declare function straightenInkStroke(points: readonly Vec[], options: InkStraightenOptions): Vec[];
1846
1977
  //#endregion
1847
- export { type AnchorMode, type Annot, type AnnotationFlags, type AnnotationKind, type AnnotationProps, type AnnotationPropsPatch, type BlendMode, type Border, type Callout, type ChromeGeom, type ChromeNode, type ClickCreate, type ClickPlacement, type CreationDraftAnchor, type Cursor, DEFAULT_CHROME_GEOM, DRAWN_FLAGS, type Draft, type Effect, FLAG_KEYS, type FlagBearer, type Geom, type GroupCaps, type Guide, type Handle, type Id, type InkStraightenOptions, KINDS, type KindCaps, type LineEnding, type LineEndings, MIN_DRAG, MITER_LIMIT, type Model, type Msg, NO_ANNOTATION_FLAGS, type Paint, type PatchScope, type PointerInput, type PropKey, type PropSpec, type Quad, RECT_HANDLES, ROTATE_KNOB_OFFSET, type Rect, type RectHandle, type RenderItem, type RenderNode, type RichTextRange, type RichTextStyleDelta, type SceneNode, type SnapResult, type SnapSettings, type Style, type Subtype, type Target, type TextAlign, type TextBox, type TextEndAnchor, type TextQuad, type TextStyle, type Vec, type ViewEnv, anchorModeOf, anchorOf, anchoredBox, anchoredGeom, anchoredStrokeWidth, annotContentsEditable, annotDeletable, annotInteractive, annotTransformable, applyProps, applyStyleToRange, calloutConnection, calloutLinePoints, canMove, capsFor, caretGeomFromAnchor, caretRectFromAnchor, caretRectFromTextEnd, centroidOf, chrome, clampRectToBox, clickCreateGeom, cloudyBorderExtent, cloudyPath, computeMoveSnap, contentToPdfPoint, contentToPdfRect, creationDraftAnchor, cursorAt, defaultsFor, expandGroups, fitStampBox, flagsEqual, geomBounds, geomDragHandle, geomHandles, geomHit, geomPdfBounds, geomResetRotation, geomRotateAbout, geomRotation, geomScaleAbout, geomScene, geomTranslate, geomVisualBounds, groupCaps, groupKeyOf, groupMembers, groupResizeAnchor, groupResizeBox, groupResizeFactors, hitTest, initialModel, initialStyle, initialTextStyle, interactive, isAttachedLink, isConversationOnly, isPlainRichText, isRotatableGeom, isSelectable, isSubstrateOnly, linkChildrenOf, linkOf, locateOffset, mergeFlags, normalizeDeg, normalizeRuns, obbFromGeom, pageItems, paragraphsFromPlainText, pdfToContentPoint, pdfToContentRect, placeRotateKnob, plainTextOf, pointInQuad, propsFor, quadIntersectsRect, rangeHasStyle, readProp, rectFromPoints, resolveClickPlacement, richTextLength, rotateDraftDelta, rotateKnob, rotatedAabb, rotatedHandleCursor, sameStyleDelta, scene, selectedItems, selectionAnchor, selectionBounds, selectionBoundsOnPage, selectionCenter, selectionKnob, selectionQuad, shapeRectFor, sharedProps, splitRunsAt, straightenInkStroke, styleAt, styleFromProps, textBoxes, textPlateInset, textStyleFromProps, transposedAboutCenter, unanchoredGeom, unionRect, update, uprightAnchoredRect, uprightRotation, viewable };
1978
+ export { type AnchorMode, type Annot, type AnnotationFlags, type AnnotationKind, type AnnotationProps, type AnnotationPropsPatch, type BlendMode, type Border, type Callout, type ChromeGeom, type ChromeNode, type ClickCreate, type ClickPlacement, type CreationDraftAnchor, type Cursor, DEFAULT_CHROME_GEOM, DRAWN_FLAGS, DistanceAppearance, DistanceCaptionLayout, DistanceLayout, DistanceSegment, type Draft, type Effect, FLAG_KEYS, type FlagBearer, type Geom, type GroupCaps, type Guide, type Handle, type Id, type InkStraightenOptions, KINDS, type KindCaps, type LineEnding, type LineEndings, MIN_DRAG, MITER_LIMIT, MeasurementAppearance, type Model, type Msg, NO_ANNOTATION_FLAGS, type Paint, type PatchScope, type PointerInput, type PropKey, type PropSpec, type Quad, RECT_HANDLES, ROTATE_KNOB_OFFSET, type Rect, type RectHandle, type RenderItem, type RenderNode, type RichTextRange, type RichTextStyleDelta, type SceneNode, type SelectionFrame, ShapeMeasurementAppearance, ShapeMeasurementLayout, type SnapResult, type SnapSettings, type Style, type Subtype, type Target, type TextAlign, type TextBox, type TextEndAnchor, type TextQuad, type TextStyle, type Vec, type ViewEnv, anchorModeOf, anchorOf, anchoredBox, anchoredGeom, anchoredStrokeWidth, annotContentsEditable, annotDeletable, annotInteractive, annotTransformable, annotationSelectionFrame, applyProps, applyStyleToRange, automaticShapeCaptionCenter, calloutConnection, calloutLinePoints, canMove, capsFor, caretGeomFromAnchor, caretRectFromAnchor, caretRectFromTextEnd, centroidOf, chrome, clampRectToBox, clickCreateGeom, cloudyBorderExtent, cloudyPath, computeMoveSnap, contentToPdfPoint, contentToPdfRect, creationDraftAnchor, cursorAt, defaultsFor, distanceCaptionAt, distanceCaptionHit, distanceHandles, distanceHit, distanceLabel, distanceLayout, distanceLeaderLength, distanceScene, distanceSelectionQuad, expandDistanceBounds, expandGroups, fitStampBox, flagsEqual, geomBounds, geomDragHandle, geomHandles, geomHit, geomPdfBounds, geomResetRotation, geomRotateAbout, geomRotation, geomScaleAbout, geomScene, geomTranslate, geomVisualBounds, groupCaps, groupKeyOf, groupMembers, groupResizeAnchor, groupResizeBox, groupResizeFactors, hitTest, initialModel, initialStyle, initialTextStyle, interactive, isAttachedLink, isConversationOnly, isPlainRichText, isRotatableGeom, isSelectable, isSubstrateOnly, linkChildrenOf, linkOf, locateOffset, measurementCaptionScene, measurementLayout, measurementSelectionQuad, mergeFlags, moveDistanceCaption, moveMeasurementCaption, normalizeDeg, normalizeRuns, obbFromGeom, pageItems, paragraphsFromPlainText, pdfToContentPoint, pdfToContentRect, placeRotateKnob, plainTextOf, pointInQuad, propsFor, quadIntersectsRect, rangeHasStyle, readProp, rectFromPoints, resolveClickPlacement, richTextLength, rotateDraftDelta, rotateKnob, rotatedAabb, rotatedHandleCursor, sameStyleDelta, scene, selectedItems, selectionAnchor, selectionBounds, selectionBoundsOnPage, selectionCenter, selectionKnob, selectionQuad, shapeCaptionPoint, shapeMeasurementLabel, shapeMeasurementLayout, shapeMeasurementReadout, shapeRectFor, sharedProps, splitRunsAt, straightenInkStroke, styleAt, styleFromProps, textBoxes, textPlateInset, textStyleFromProps, transformMeasurementCaption, transposedAboutCenter, unanchoredGeom, unionRect, update, uprightAnchoredRect, uprightRotation, viewable, withShapeCaptionPoint };
1848
1979
  //# sourceMappingURL=index.d.ts.map