@fieldnotes/core 0.55.0 → 0.57.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.
package/dist/index.d.cts CHANGED
@@ -986,6 +986,265 @@ declare class RemotePingOverlay {
986
986
  private renderPings;
987
987
  }
988
988
 
989
+ interface MeasureToolOptions {
990
+ feetPerCell?: number;
991
+ color?: string;
992
+ }
993
+ interface Measurement {
994
+ start: Point;
995
+ end: Point;
996
+ worldDistance: number;
997
+ cells: number;
998
+ feet: number;
999
+ }
1000
+ /**
1001
+ * A raf-coalesced snapshot of the in-progress measurement — the outgoing
1002
+ * side of a shared live ruler. Emissions carry world coordinates, derived
1003
+ * distance, and the tool's current color so a host can forward them as
1004
+ * ephemeral presence without duplicating the tool's input handling.
1005
+ * Ephemeral by contract: presence only — never elements, history, or
1006
+ * persisted state.
1007
+ */
1008
+ interface MeasureEmission {
1009
+ readonly start: Point;
1010
+ readonly end: Point;
1011
+ readonly worldDistance: number;
1012
+ readonly cells: number;
1013
+ readonly feet: number;
1014
+ readonly color: string;
1015
+ }
1016
+ declare class MeasureTool implements Tool {
1017
+ readonly name = "measure";
1018
+ private start;
1019
+ private end;
1020
+ private gridSize;
1021
+ private gridType;
1022
+ private hexOrientation;
1023
+ private feetPerCell;
1024
+ private color;
1025
+ private optionListeners;
1026
+ private measurementListeners;
1027
+ private emissionRafId;
1028
+ constructor(options?: MeasureToolOptions);
1029
+ getOptions(): MeasureToolOptions;
1030
+ setOptions(options: MeasureToolOptions): void;
1031
+ onOptionsChange(listener: () => void): () => void;
1032
+ /**
1033
+ * Subscribes to raf-coalesced measurement snapshots. While a measurement is
1034
+ * in progress, listeners receive at most one snapshot per animation frame
1035
+ * carrying the latest state; `null` is delivered synchronously when the
1036
+ * measurement clears (pointer-up or deactivate). Emissions are ephemeral by
1037
+ * contract: presence only — never elements, history, or persisted state.
1038
+ */
1039
+ onMeasurement(listener: (emission: MeasureEmission | null) => void): () => void;
1040
+ onPointerDown(state: PointerState, ctx: ToolContext): void;
1041
+ onPointerMove(state: PointerState, ctx: ToolContext): void;
1042
+ onPointerUp(_state: PointerState, ctx: ToolContext): void;
1043
+ onDeactivate(_ctx: ToolContext): void;
1044
+ getMeasurement(): Measurement | null;
1045
+ renderOverlay(ctx: CanvasRenderingContext2D): void;
1046
+ private snapToGrid;
1047
+ private notifyOptionsChange;
1048
+ private scheduleEmission;
1049
+ private emitClear;
1050
+ private emit;
1051
+ }
1052
+
1053
+ /**
1054
+ * The wire shape of a shared-ruler presence payload. Presence data is untyped
1055
+ * on the wire, so hosts discriminate on `kind`; `isMeasurePresence` validates
1056
+ * a received payload before it reaches the overlay. Distance is
1057
+ * sender-authoritative: receivers render the payload's `feet`/`cells` and
1058
+ * never recompute from their own grid. Measurements are ephemeral by
1059
+ * contract: presence only — never elements, undo history, persisted canvas
1060
+ * state, or durable operations.
1061
+ */
1062
+ type MeasurePresence = {
1063
+ readonly kind: 'measure';
1064
+ readonly start: Point;
1065
+ readonly end: Point;
1066
+ readonly cells: number;
1067
+ readonly feet: number;
1068
+ readonly color?: string;
1069
+ } | {
1070
+ readonly kind: 'measure';
1071
+ readonly cleared: true;
1072
+ };
1073
+ declare const MEASURE_PRESENCE_KIND = "measure";
1074
+ declare function isMeasurePresence(data: unknown): data is MeasurePresence;
1075
+ /** Builds the presence payload for one local `MeasureTool` emission. */
1076
+ declare function toMeasurePresence(emission: MeasureEmission | null): MeasurePresence;
1077
+ /** The two viewport capabilities the overlay needs; `Viewport` satisfies it. */
1078
+ interface RemoteMeasureOverlayHost {
1079
+ registerOverlay(draw: OverlayRenderer): () => void;
1080
+ requestRender(): void;
1081
+ }
1082
+ interface RemoteMeasureOverlayOptions {
1083
+ /** Style fallback when a payload omits `color`. Default `'#FF5722'`. */
1084
+ color?: string;
1085
+ /** Full-opacity hold after a cleared payload. Default `1500`. */
1086
+ holdMs?: number;
1087
+ /** Linear fade to 0 after the hold. Default `400`. */
1088
+ fadeMs?: number;
1089
+ /** Stale active entries are treated as cleared after this. Default `30000`. */
1090
+ maxAgeMs?: number;
1091
+ }
1092
+ /**
1093
+ * Renders remote shared-ruler measurements through the viewport overlay
1094
+ * registration, independent of the viewer's active tool. Entries are stamped
1095
+ * with local receive time (remote clocks are never trusted). A cleared
1096
+ * payload holds the final measurement for `holdMs`, fades over `fadeMs`, and
1097
+ * deletes; presence-leave (`remove`) deletes immediately. An active entry not
1098
+ * updated for `maxAgeMs` is expired by a timer — an idle map never renders,
1099
+ * so expiry cannot ride on the draw path. The overlay never touches elements,
1100
+ * history, or persisted state, and never moves the viewer's camera.
1101
+ */
1102
+ declare class RemoteMeasureOverlay {
1103
+ private readonly host;
1104
+ private readonly color;
1105
+ private readonly holdMs;
1106
+ private readonly fadeMs;
1107
+ private readonly maxAgeMs;
1108
+ private readonly measurements;
1109
+ private unregister;
1110
+ private rafId;
1111
+ private disposed;
1112
+ constructor(host: RemoteMeasureOverlayHost, options?: RemoteMeasureOverlayOptions);
1113
+ private now;
1114
+ /**
1115
+ * Applies a presence payload from `sender` (any opaque per-sender key, e.g.
1116
+ * the envelope `from`). Non-measure or malformed payloads are ignored and
1117
+ * reported as `false`, so hosts can feed every presence frame through.
1118
+ */
1119
+ apply(sender: string, data: unknown): boolean;
1120
+ /** Removes a sender's ruler immediately (presence-leave/disconnect). */
1121
+ remove(sender: string): void;
1122
+ /** Removes every ruler immediately. */
1123
+ clear(): void;
1124
+ /** Number of senders with a visible (active or lingering) ruler. */
1125
+ get activeSenderCount(): number;
1126
+ /** Unregisters the overlay, cancels timers, stops animating. Idempotent. */
1127
+ dispose(): void;
1128
+ private beginLinger;
1129
+ private ensureAnimating;
1130
+ private tick;
1131
+ private renderMeasurements;
1132
+ }
1133
+
1134
+ /**
1135
+ * The one camera capability `PingInput` needs; `Camera` satisfies it. Screen
1136
+ * coordinates are element-local (the same space `Camera.screenToWorld`
1137
+ * expects).
1138
+ */
1139
+ interface PingInputHost {
1140
+ screenToWorld(screen: Point): Point;
1141
+ }
1142
+ interface PingInputOptions {
1143
+ /**
1144
+ * Opt-in for the long-press gesture. Off by default: a hidden hold-to-ping
1145
+ * gesture surprises users outside shared-canvas products, so hosts enable
1146
+ * it deliberately. The keyboard/programmatic paths (`pingAtPointer`,
1147
+ * `pingAt`) are always available. Default `false`.
1148
+ */
1149
+ longPressEnabled?: boolean;
1150
+ /** Hold duration before a still press pings. Default `600`. */
1151
+ longPressMs?: number;
1152
+ /** Maximum pointer travel while holding; moving further cancels. Default `8`. */
1153
+ slopPx?: number;
1154
+ /** Emission style forwarded to hosts; matches `PingTool` defaults. */
1155
+ color?: string;
1156
+ durationMs?: number;
1157
+ radius?: number;
1158
+ /**
1159
+ * Minimum interval between emitted pings, shared across the long-press and
1160
+ * keyboard/programmatic paths. Faster pings are dropped entirely. Default
1161
+ * `300`.
1162
+ */
1163
+ minIntervalMs?: number;
1164
+ /**
1165
+ * Host veto consulted at fire time on every path (e.g. return `false` while
1166
+ * a ping tool is active to avoid double pings). A veto does not consume the
1167
+ * rate-limit interval.
1168
+ */
1169
+ shouldPing?: () => boolean;
1170
+ }
1171
+ /**
1172
+ * Always-available ping input alongside the active tool: long-press-to-ping
1173
+ * plus keyboard/programmatic pings, independent of `PingTool`.
1174
+ *
1175
+ * `PingInput` is a passive observer by contract. Its DOM pointer listeners are
1176
+ * registered `passive: true` and it never calls `preventDefault`,
1177
+ * `stopPropagation`, or captures pointers, so the active tool, panning, and
1178
+ * pinch navigation behave exactly as if it were absent (with a pencil active,
1179
+ * a still hold pings AND the pencil still draws its dot). It also never
1180
+ * renders: hosts feed emissions into their own `RemotePingOverlay` under a
1181
+ * `'self'` sender key. Pings are ephemeral — no elements, no undo history, no
1182
+ * persisted state, no camera movement.
1183
+ *
1184
+ * The long-press gesture is opt-in via `longPressEnabled` (hosts whose users
1185
+ * would not expect hold-to-ping simply leave it off and keep the keyboard
1186
+ * paths). When enabled, a long-press arms on the first pointer down (mouse
1187
+ * primary button, touch, or pen), fires after `longPressMs` at the original
1188
+ * press position, and
1189
+ * cancels on movement past `slopPx`, a second pointer (two-finger
1190
+ * navigation), or pointer up/cancel/leave. Keyboard support is a capability,
1191
+ * not a binding: hosts call `pingAtPointer()` (last tracked hover position,
1192
+ * world-converted at call time) or `pingAt(world)` from their own shortcut
1193
+ * handling.
1194
+ */
1195
+ declare class PingInput {
1196
+ private readonly element;
1197
+ private readonly host;
1198
+ private longPressEnabled;
1199
+ private longPressMs;
1200
+ private slopPx;
1201
+ private color;
1202
+ private durationMs;
1203
+ private radius;
1204
+ private minIntervalMs;
1205
+ private shouldPing;
1206
+ private press;
1207
+ private readonly downPointers;
1208
+ private lastPointerScreen;
1209
+ private lastEmitAt;
1210
+ private disposed;
1211
+ private optionListeners;
1212
+ private pingListeners;
1213
+ private readonly handlePointerDown;
1214
+ private readonly handlePointerMove;
1215
+ private readonly handlePointerUp;
1216
+ private readonly handlePointerCancel;
1217
+ private readonly handlePointerLeave;
1218
+ constructor(element: HTMLElement, host: PingInputHost, options?: PingInputOptions);
1219
+ private now;
1220
+ getOptions(): PingInputOptions;
1221
+ setOptions(options: PingInputOptions): void;
1222
+ onOptionsChange(listener: () => void): () => void;
1223
+ /**
1224
+ * Subscribes to emitted pings. Listeners must not throw; a throwing
1225
+ * listener is isolated so it cannot break input handling or other
1226
+ * listeners.
1227
+ */
1228
+ onPing(listener: (emission: PingEmission) => void): () => void;
1229
+ /**
1230
+ * Pings at the last tracked pointer position (hover moves and presses),
1231
+ * world-converted at call time. Returns `false` when no pointer has been
1232
+ * seen yet, the host vetoes, or the rate limit drops the ping.
1233
+ */
1234
+ pingAtPointer(): boolean;
1235
+ /** Pings a world position directly. Same veto and rate limit as every path. */
1236
+ pingAt(world: Point): boolean;
1237
+ /** Removes all DOM listeners and cancels any pending press. Idempotent. */
1238
+ dispose(): void;
1239
+ private toLocal;
1240
+ private onPointerDown;
1241
+ private onPointerMove;
1242
+ private onPointerEnd;
1243
+ private cancelPress;
1244
+ private firePress;
1245
+ private emit;
1246
+ }
1247
+
989
1248
  interface ActiveFormats {
990
1249
  bold: boolean;
991
1250
  italic: boolean;
@@ -1346,39 +1605,6 @@ declare class ShapeTool implements Tool {
1346
1605
  private onKeyUp;
1347
1606
  }
1348
1607
 
1349
- interface MeasureToolOptions {
1350
- feetPerCell?: number;
1351
- }
1352
- interface Measurement {
1353
- start: Point;
1354
- end: Point;
1355
- worldDistance: number;
1356
- cells: number;
1357
- feet: number;
1358
- }
1359
- declare class MeasureTool implements Tool {
1360
- readonly name = "measure";
1361
- private start;
1362
- private end;
1363
- private gridSize;
1364
- private gridType;
1365
- private hexOrientation;
1366
- private feetPerCell;
1367
- private optionListeners;
1368
- constructor(options?: MeasureToolOptions);
1369
- getOptions(): MeasureToolOptions;
1370
- setOptions(options: MeasureToolOptions): void;
1371
- onOptionsChange(listener: () => void): () => void;
1372
- onPointerDown(state: PointerState, ctx: ToolContext): void;
1373
- onPointerMove(state: PointerState, ctx: ToolContext): void;
1374
- onPointerUp(_state: PointerState, ctx: ToolContext): void;
1375
- onDeactivate(_ctx: ToolContext): void;
1376
- getMeasurement(): Measurement | null;
1377
- renderOverlay(ctx: CanvasRenderingContext2D): void;
1378
- private snapToGrid;
1379
- private notifyOptionsChange;
1380
- }
1381
-
1382
1608
  interface TemplateToolOptions {
1383
1609
  templateShape?: TemplateShape;
1384
1610
  fillColor?: string;
@@ -1424,6 +1650,6 @@ declare class TemplateTool implements Tool {
1424
1650
  private notifyOptionsChange;
1425
1651
  }
1426
1652
 
1427
- declare const VERSION = "0.55.0";
1653
+ declare const VERSION = "0.57.0";
1428
1654
 
1429
- export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PING_PRESENCE_KIND, PencilTool, type PencilToolOptions, type PingEmission, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isLaserTrailPresence, isNearBezier, isPingPresence, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
1655
+ export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalStorageAdapter, MEASURE_PRESENCE_KIND, type MeasureEmission, type MeasurePresence, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PING_PRESENCE_KIND, PencilTool, type PencilToolOptions, type PingEmission, PingInput, type PingInputHost, type PingInputOptions, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemoteMeasureOverlay, type RemoteMeasureOverlayHost, type RemoteMeasureOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isLaserTrailPresence, isMeasurePresence, isNearBezier, isPingPresence, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toMeasurePresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
package/dist/index.d.ts CHANGED
@@ -986,6 +986,265 @@ declare class RemotePingOverlay {
986
986
  private renderPings;
987
987
  }
988
988
 
989
+ interface MeasureToolOptions {
990
+ feetPerCell?: number;
991
+ color?: string;
992
+ }
993
+ interface Measurement {
994
+ start: Point;
995
+ end: Point;
996
+ worldDistance: number;
997
+ cells: number;
998
+ feet: number;
999
+ }
1000
+ /**
1001
+ * A raf-coalesced snapshot of the in-progress measurement — the outgoing
1002
+ * side of a shared live ruler. Emissions carry world coordinates, derived
1003
+ * distance, and the tool's current color so a host can forward them as
1004
+ * ephemeral presence without duplicating the tool's input handling.
1005
+ * Ephemeral by contract: presence only — never elements, history, or
1006
+ * persisted state.
1007
+ */
1008
+ interface MeasureEmission {
1009
+ readonly start: Point;
1010
+ readonly end: Point;
1011
+ readonly worldDistance: number;
1012
+ readonly cells: number;
1013
+ readonly feet: number;
1014
+ readonly color: string;
1015
+ }
1016
+ declare class MeasureTool implements Tool {
1017
+ readonly name = "measure";
1018
+ private start;
1019
+ private end;
1020
+ private gridSize;
1021
+ private gridType;
1022
+ private hexOrientation;
1023
+ private feetPerCell;
1024
+ private color;
1025
+ private optionListeners;
1026
+ private measurementListeners;
1027
+ private emissionRafId;
1028
+ constructor(options?: MeasureToolOptions);
1029
+ getOptions(): MeasureToolOptions;
1030
+ setOptions(options: MeasureToolOptions): void;
1031
+ onOptionsChange(listener: () => void): () => void;
1032
+ /**
1033
+ * Subscribes to raf-coalesced measurement snapshots. While a measurement is
1034
+ * in progress, listeners receive at most one snapshot per animation frame
1035
+ * carrying the latest state; `null` is delivered synchronously when the
1036
+ * measurement clears (pointer-up or deactivate). Emissions are ephemeral by
1037
+ * contract: presence only — never elements, history, or persisted state.
1038
+ */
1039
+ onMeasurement(listener: (emission: MeasureEmission | null) => void): () => void;
1040
+ onPointerDown(state: PointerState, ctx: ToolContext): void;
1041
+ onPointerMove(state: PointerState, ctx: ToolContext): void;
1042
+ onPointerUp(_state: PointerState, ctx: ToolContext): void;
1043
+ onDeactivate(_ctx: ToolContext): void;
1044
+ getMeasurement(): Measurement | null;
1045
+ renderOverlay(ctx: CanvasRenderingContext2D): void;
1046
+ private snapToGrid;
1047
+ private notifyOptionsChange;
1048
+ private scheduleEmission;
1049
+ private emitClear;
1050
+ private emit;
1051
+ }
1052
+
1053
+ /**
1054
+ * The wire shape of a shared-ruler presence payload. Presence data is untyped
1055
+ * on the wire, so hosts discriminate on `kind`; `isMeasurePresence` validates
1056
+ * a received payload before it reaches the overlay. Distance is
1057
+ * sender-authoritative: receivers render the payload's `feet`/`cells` and
1058
+ * never recompute from their own grid. Measurements are ephemeral by
1059
+ * contract: presence only — never elements, undo history, persisted canvas
1060
+ * state, or durable operations.
1061
+ */
1062
+ type MeasurePresence = {
1063
+ readonly kind: 'measure';
1064
+ readonly start: Point;
1065
+ readonly end: Point;
1066
+ readonly cells: number;
1067
+ readonly feet: number;
1068
+ readonly color?: string;
1069
+ } | {
1070
+ readonly kind: 'measure';
1071
+ readonly cleared: true;
1072
+ };
1073
+ declare const MEASURE_PRESENCE_KIND = "measure";
1074
+ declare function isMeasurePresence(data: unknown): data is MeasurePresence;
1075
+ /** Builds the presence payload for one local `MeasureTool` emission. */
1076
+ declare function toMeasurePresence(emission: MeasureEmission | null): MeasurePresence;
1077
+ /** The two viewport capabilities the overlay needs; `Viewport` satisfies it. */
1078
+ interface RemoteMeasureOverlayHost {
1079
+ registerOverlay(draw: OverlayRenderer): () => void;
1080
+ requestRender(): void;
1081
+ }
1082
+ interface RemoteMeasureOverlayOptions {
1083
+ /** Style fallback when a payload omits `color`. Default `'#FF5722'`. */
1084
+ color?: string;
1085
+ /** Full-opacity hold after a cleared payload. Default `1500`. */
1086
+ holdMs?: number;
1087
+ /** Linear fade to 0 after the hold. Default `400`. */
1088
+ fadeMs?: number;
1089
+ /** Stale active entries are treated as cleared after this. Default `30000`. */
1090
+ maxAgeMs?: number;
1091
+ }
1092
+ /**
1093
+ * Renders remote shared-ruler measurements through the viewport overlay
1094
+ * registration, independent of the viewer's active tool. Entries are stamped
1095
+ * with local receive time (remote clocks are never trusted). A cleared
1096
+ * payload holds the final measurement for `holdMs`, fades over `fadeMs`, and
1097
+ * deletes; presence-leave (`remove`) deletes immediately. An active entry not
1098
+ * updated for `maxAgeMs` is expired by a timer — an idle map never renders,
1099
+ * so expiry cannot ride on the draw path. The overlay never touches elements,
1100
+ * history, or persisted state, and never moves the viewer's camera.
1101
+ */
1102
+ declare class RemoteMeasureOverlay {
1103
+ private readonly host;
1104
+ private readonly color;
1105
+ private readonly holdMs;
1106
+ private readonly fadeMs;
1107
+ private readonly maxAgeMs;
1108
+ private readonly measurements;
1109
+ private unregister;
1110
+ private rafId;
1111
+ private disposed;
1112
+ constructor(host: RemoteMeasureOverlayHost, options?: RemoteMeasureOverlayOptions);
1113
+ private now;
1114
+ /**
1115
+ * Applies a presence payload from `sender` (any opaque per-sender key, e.g.
1116
+ * the envelope `from`). Non-measure or malformed payloads are ignored and
1117
+ * reported as `false`, so hosts can feed every presence frame through.
1118
+ */
1119
+ apply(sender: string, data: unknown): boolean;
1120
+ /** Removes a sender's ruler immediately (presence-leave/disconnect). */
1121
+ remove(sender: string): void;
1122
+ /** Removes every ruler immediately. */
1123
+ clear(): void;
1124
+ /** Number of senders with a visible (active or lingering) ruler. */
1125
+ get activeSenderCount(): number;
1126
+ /** Unregisters the overlay, cancels timers, stops animating. Idempotent. */
1127
+ dispose(): void;
1128
+ private beginLinger;
1129
+ private ensureAnimating;
1130
+ private tick;
1131
+ private renderMeasurements;
1132
+ }
1133
+
1134
+ /**
1135
+ * The one camera capability `PingInput` needs; `Camera` satisfies it. Screen
1136
+ * coordinates are element-local (the same space `Camera.screenToWorld`
1137
+ * expects).
1138
+ */
1139
+ interface PingInputHost {
1140
+ screenToWorld(screen: Point): Point;
1141
+ }
1142
+ interface PingInputOptions {
1143
+ /**
1144
+ * Opt-in for the long-press gesture. Off by default: a hidden hold-to-ping
1145
+ * gesture surprises users outside shared-canvas products, so hosts enable
1146
+ * it deliberately. The keyboard/programmatic paths (`pingAtPointer`,
1147
+ * `pingAt`) are always available. Default `false`.
1148
+ */
1149
+ longPressEnabled?: boolean;
1150
+ /** Hold duration before a still press pings. Default `600`. */
1151
+ longPressMs?: number;
1152
+ /** Maximum pointer travel while holding; moving further cancels. Default `8`. */
1153
+ slopPx?: number;
1154
+ /** Emission style forwarded to hosts; matches `PingTool` defaults. */
1155
+ color?: string;
1156
+ durationMs?: number;
1157
+ radius?: number;
1158
+ /**
1159
+ * Minimum interval between emitted pings, shared across the long-press and
1160
+ * keyboard/programmatic paths. Faster pings are dropped entirely. Default
1161
+ * `300`.
1162
+ */
1163
+ minIntervalMs?: number;
1164
+ /**
1165
+ * Host veto consulted at fire time on every path (e.g. return `false` while
1166
+ * a ping tool is active to avoid double pings). A veto does not consume the
1167
+ * rate-limit interval.
1168
+ */
1169
+ shouldPing?: () => boolean;
1170
+ }
1171
+ /**
1172
+ * Always-available ping input alongside the active tool: long-press-to-ping
1173
+ * plus keyboard/programmatic pings, independent of `PingTool`.
1174
+ *
1175
+ * `PingInput` is a passive observer by contract. Its DOM pointer listeners are
1176
+ * registered `passive: true` and it never calls `preventDefault`,
1177
+ * `stopPropagation`, or captures pointers, so the active tool, panning, and
1178
+ * pinch navigation behave exactly as if it were absent (with a pencil active,
1179
+ * a still hold pings AND the pencil still draws its dot). It also never
1180
+ * renders: hosts feed emissions into their own `RemotePingOverlay` under a
1181
+ * `'self'` sender key. Pings are ephemeral — no elements, no undo history, no
1182
+ * persisted state, no camera movement.
1183
+ *
1184
+ * The long-press gesture is opt-in via `longPressEnabled` (hosts whose users
1185
+ * would not expect hold-to-ping simply leave it off and keep the keyboard
1186
+ * paths). When enabled, a long-press arms on the first pointer down (mouse
1187
+ * primary button, touch, or pen), fires after `longPressMs` at the original
1188
+ * press position, and
1189
+ * cancels on movement past `slopPx`, a second pointer (two-finger
1190
+ * navigation), or pointer up/cancel/leave. Keyboard support is a capability,
1191
+ * not a binding: hosts call `pingAtPointer()` (last tracked hover position,
1192
+ * world-converted at call time) or `pingAt(world)` from their own shortcut
1193
+ * handling.
1194
+ */
1195
+ declare class PingInput {
1196
+ private readonly element;
1197
+ private readonly host;
1198
+ private longPressEnabled;
1199
+ private longPressMs;
1200
+ private slopPx;
1201
+ private color;
1202
+ private durationMs;
1203
+ private radius;
1204
+ private minIntervalMs;
1205
+ private shouldPing;
1206
+ private press;
1207
+ private readonly downPointers;
1208
+ private lastPointerScreen;
1209
+ private lastEmitAt;
1210
+ private disposed;
1211
+ private optionListeners;
1212
+ private pingListeners;
1213
+ private readonly handlePointerDown;
1214
+ private readonly handlePointerMove;
1215
+ private readonly handlePointerUp;
1216
+ private readonly handlePointerCancel;
1217
+ private readonly handlePointerLeave;
1218
+ constructor(element: HTMLElement, host: PingInputHost, options?: PingInputOptions);
1219
+ private now;
1220
+ getOptions(): PingInputOptions;
1221
+ setOptions(options: PingInputOptions): void;
1222
+ onOptionsChange(listener: () => void): () => void;
1223
+ /**
1224
+ * Subscribes to emitted pings. Listeners must not throw; a throwing
1225
+ * listener is isolated so it cannot break input handling or other
1226
+ * listeners.
1227
+ */
1228
+ onPing(listener: (emission: PingEmission) => void): () => void;
1229
+ /**
1230
+ * Pings at the last tracked pointer position (hover moves and presses),
1231
+ * world-converted at call time. Returns `false` when no pointer has been
1232
+ * seen yet, the host vetoes, or the rate limit drops the ping.
1233
+ */
1234
+ pingAtPointer(): boolean;
1235
+ /** Pings a world position directly. Same veto and rate limit as every path. */
1236
+ pingAt(world: Point): boolean;
1237
+ /** Removes all DOM listeners and cancels any pending press. Idempotent. */
1238
+ dispose(): void;
1239
+ private toLocal;
1240
+ private onPointerDown;
1241
+ private onPointerMove;
1242
+ private onPointerEnd;
1243
+ private cancelPress;
1244
+ private firePress;
1245
+ private emit;
1246
+ }
1247
+
989
1248
  interface ActiveFormats {
990
1249
  bold: boolean;
991
1250
  italic: boolean;
@@ -1346,39 +1605,6 @@ declare class ShapeTool implements Tool {
1346
1605
  private onKeyUp;
1347
1606
  }
1348
1607
 
1349
- interface MeasureToolOptions {
1350
- feetPerCell?: number;
1351
- }
1352
- interface Measurement {
1353
- start: Point;
1354
- end: Point;
1355
- worldDistance: number;
1356
- cells: number;
1357
- feet: number;
1358
- }
1359
- declare class MeasureTool implements Tool {
1360
- readonly name = "measure";
1361
- private start;
1362
- private end;
1363
- private gridSize;
1364
- private gridType;
1365
- private hexOrientation;
1366
- private feetPerCell;
1367
- private optionListeners;
1368
- constructor(options?: MeasureToolOptions);
1369
- getOptions(): MeasureToolOptions;
1370
- setOptions(options: MeasureToolOptions): void;
1371
- onOptionsChange(listener: () => void): () => void;
1372
- onPointerDown(state: PointerState, ctx: ToolContext): void;
1373
- onPointerMove(state: PointerState, ctx: ToolContext): void;
1374
- onPointerUp(_state: PointerState, ctx: ToolContext): void;
1375
- onDeactivate(_ctx: ToolContext): void;
1376
- getMeasurement(): Measurement | null;
1377
- renderOverlay(ctx: CanvasRenderingContext2D): void;
1378
- private snapToGrid;
1379
- private notifyOptionsChange;
1380
- }
1381
-
1382
1608
  interface TemplateToolOptions {
1383
1609
  templateShape?: TemplateShape;
1384
1610
  fillColor?: string;
@@ -1424,6 +1650,6 @@ declare class TemplateTool implements Tool {
1424
1650
  private notifyOptionsChange;
1425
1651
  }
1426
1652
 
1427
- declare const VERSION = "0.55.0";
1653
+ declare const VERSION = "0.57.0";
1428
1654
 
1429
- export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PING_PRESENCE_KIND, PencilTool, type PencilToolOptions, type PingEmission, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isLaserTrailPresence, isNearBezier, isPingPresence, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
1655
+ export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalStorageAdapter, MEASURE_PRESENCE_KIND, type MeasureEmission, type MeasurePresence, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PING_PRESENCE_KIND, PencilTool, type PencilToolOptions, type PingEmission, PingInput, type PingInputHost, type PingInputOptions, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemoteMeasureOverlay, type RemoteMeasureOverlayHost, type RemoteMeasureOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isLaserTrailPresence, isMeasurePresence, isNearBezier, isPingPresence, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toMeasurePresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };