@fieldnotes/core 0.52.2 → 0.54.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.cjs +273 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -33
- package/dist/index.d.ts +157 -33
- package/dist/index.js +269 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -510,6 +510,15 @@ interface RenderStatsSnapshot {
|
|
|
510
510
|
frameCount: number;
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
/**
|
|
514
|
+
* A world-space draw callback rendered above elements on every frame,
|
|
515
|
+
* regardless of which tool is active. The context arrives with the camera
|
|
516
|
+
* transform applied; implementations must not assume exclusive context state
|
|
517
|
+
* (each renderer is wrapped in save/restore). A throwing renderer is isolated
|
|
518
|
+
* per frame and must not break the render loop.
|
|
519
|
+
*/
|
|
520
|
+
type OverlayRenderer = (ctx: CanvasRenderingContext2D) => void;
|
|
521
|
+
|
|
513
522
|
interface ElementStyle {
|
|
514
523
|
color?: string;
|
|
515
524
|
fillColor?: string;
|
|
@@ -583,6 +592,7 @@ declare class Viewport {
|
|
|
583
592
|
private readonly noteEditor;
|
|
584
593
|
private readonly arrowLabelEditor;
|
|
585
594
|
private readonly historyRecorder;
|
|
595
|
+
private transactionDepth;
|
|
586
596
|
private readonly selectionOps;
|
|
587
597
|
readonly toolContext: ToolContext;
|
|
588
598
|
private readonly marginViewport;
|
|
@@ -608,6 +618,15 @@ declare class Viewport {
|
|
|
608
618
|
setSmartGuides(enabled: boolean): void;
|
|
609
619
|
fitToContent(padding?: number): void;
|
|
610
620
|
requestRender(): void;
|
|
621
|
+
/**
|
|
622
|
+
* Registers a world-space overlay drawn above elements on every frame,
|
|
623
|
+
* regardless of the active tool — the surface for remote presence visuals
|
|
624
|
+
* such as laser trails, cursors, pings, and shared rulers. Overlays draw
|
|
625
|
+
* beneath the active tool's own `renderOverlay` and never touch elements,
|
|
626
|
+
* history, or persisted state. Returns an idempotent unsubscribe that also
|
|
627
|
+
* erases the overlay's last frame.
|
|
628
|
+
*/
|
|
629
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
611
630
|
exportState(): CanvasState;
|
|
612
631
|
exportJSON(): string;
|
|
613
632
|
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
@@ -616,6 +635,14 @@ declare class Viewport {
|
|
|
616
635
|
loadJSON(json: string): void;
|
|
617
636
|
setTool(name: string): void;
|
|
618
637
|
get shortcuts(): ShortcutsApi;
|
|
638
|
+
/**
|
|
639
|
+
* Groups synchronous local store and layer mutations into one undo step.
|
|
640
|
+
* Nested calls join the outer transaction. If the callback throws, mutations
|
|
641
|
+
* already applied remain undoable and the original error is rethrown.
|
|
642
|
+
*/
|
|
643
|
+
transaction<T>(operation: () => T): T;
|
|
644
|
+
/** Removes existing elements as one undoable operation and returns the number removed. */
|
|
645
|
+
removeElements(ids: Iterable<string>): number;
|
|
619
646
|
undo(): boolean;
|
|
620
647
|
redo(): boolean;
|
|
621
648
|
addImage(src: string, position: {
|
|
@@ -689,6 +716,134 @@ declare class Viewport {
|
|
|
689
716
|
private observeResize;
|
|
690
717
|
}
|
|
691
718
|
|
|
719
|
+
interface LaserToolOptions {
|
|
720
|
+
name?: string;
|
|
721
|
+
color?: string;
|
|
722
|
+
width?: number;
|
|
723
|
+
fadeMs?: number;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* A coalesced batch of locally drawn trail points, flushed at most once per
|
|
727
|
+
* animation frame — the outgoing side of a shared laser pointer. Emissions
|
|
728
|
+
* carry world coordinates and the tool's current style so a host can forward
|
|
729
|
+
* them as ephemeral presence without duplicating the tool's input handling.
|
|
730
|
+
*/
|
|
731
|
+
interface LaserTrailEmission {
|
|
732
|
+
/** World-space points recorded since the previous emission, oldest first. */
|
|
733
|
+
readonly points: readonly Point[];
|
|
734
|
+
readonly color: string;
|
|
735
|
+
readonly width: number;
|
|
736
|
+
readonly fadeMs: number;
|
|
737
|
+
}
|
|
738
|
+
declare class LaserTool implements Tool {
|
|
739
|
+
readonly name: string;
|
|
740
|
+
private color;
|
|
741
|
+
private width;
|
|
742
|
+
private fadeMs;
|
|
743
|
+
private trail;
|
|
744
|
+
private rafId;
|
|
745
|
+
private drawing;
|
|
746
|
+
private optionListeners;
|
|
747
|
+
private trailListeners;
|
|
748
|
+
private pendingEmission;
|
|
749
|
+
constructor(options?: LaserToolOptions);
|
|
750
|
+
private now;
|
|
751
|
+
onActivate(ctx: ToolContext): void;
|
|
752
|
+
onDeactivate(ctx: ToolContext): void;
|
|
753
|
+
getOptions(): LaserToolOptions;
|
|
754
|
+
onOptionsChange(listener: () => void): () => void;
|
|
755
|
+
/**
|
|
756
|
+
* Subscribes to coalesced trail emissions. Points recorded by pointer input
|
|
757
|
+
* are batched and delivered at most once per animation frame, keeping
|
|
758
|
+
* outgoing presence packets small. Listeners must not throw; a throwing
|
|
759
|
+
* listener is isolated so it cannot stall the fade loop.
|
|
760
|
+
*/
|
|
761
|
+
onTrail(listener: (emission: LaserTrailEmission) => void): () => void;
|
|
762
|
+
setOptions(options: LaserToolOptions): void;
|
|
763
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
764
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
765
|
+
private recordPoint;
|
|
766
|
+
onPointerUp(_state: PointerState, _ctx: ToolContext): void;
|
|
767
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
768
|
+
private ensureAnimating;
|
|
769
|
+
private flushEmission;
|
|
770
|
+
private tick;
|
|
771
|
+
private notifyOptionsChange;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* The wire shape of a laser-trail presence payload. Presence data is untyped
|
|
776
|
+
* on the wire, so hosts discriminate on `kind`; `isLaserTrailPresence`
|
|
777
|
+
* validates a received payload before it reaches the overlay. Trails are
|
|
778
|
+
* ephemeral by contract: they must travel as presence only — never as
|
|
779
|
+
* elements, undo history, persisted canvas state, or durable operations.
|
|
780
|
+
*/
|
|
781
|
+
interface LaserTrailPresence {
|
|
782
|
+
readonly kind: 'laser';
|
|
783
|
+
/** World-space points, oldest first. */
|
|
784
|
+
readonly points: readonly Point[];
|
|
785
|
+
readonly color?: string;
|
|
786
|
+
readonly width?: number;
|
|
787
|
+
readonly fadeMs?: number;
|
|
788
|
+
}
|
|
789
|
+
declare const LASER_TRAIL_PRESENCE_KIND = "laser";
|
|
790
|
+
declare function isLaserTrailPresence(data: unknown): data is LaserTrailPresence;
|
|
791
|
+
/** Builds the presence payload for one local `LaserTool` emission. */
|
|
792
|
+
declare function toLaserTrailPresence(emission: LaserTrailEmission): LaserTrailPresence;
|
|
793
|
+
/**
|
|
794
|
+
* The two viewport capabilities the overlay needs; `Viewport` satisfies it.
|
|
795
|
+
*/
|
|
796
|
+
interface RemoteLaserOverlayHost {
|
|
797
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
798
|
+
requestRender(): void;
|
|
799
|
+
}
|
|
800
|
+
interface RemoteLaserOverlayOptions {
|
|
801
|
+
/** Style fallbacks when a payload omits them. */
|
|
802
|
+
color?: string;
|
|
803
|
+
width?: number;
|
|
804
|
+
fadeMs?: number;
|
|
805
|
+
/** Per-sender point cap; oldest points drop first. Default `512`. */
|
|
806
|
+
maxPointsPerSender?: number;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Renders fading laser trails for remote senders through the viewport overlay
|
|
810
|
+
* registration, independent of the viewer's active tool. Points are stamped
|
|
811
|
+
* with local receive time (remote clocks are never trusted), fade like the
|
|
812
|
+
* local `LaserTool`, and a sender's trail disappears immediately on
|
|
813
|
+
* `remove()` — wire that to `presence-leave`/disconnect. The controller never
|
|
814
|
+
* touches elements, history, or persisted state.
|
|
815
|
+
*/
|
|
816
|
+
declare class RemoteLaserOverlay {
|
|
817
|
+
private readonly host;
|
|
818
|
+
private readonly color;
|
|
819
|
+
private readonly width;
|
|
820
|
+
private readonly fadeMs;
|
|
821
|
+
private readonly maxPointsPerSender;
|
|
822
|
+
private readonly trails;
|
|
823
|
+
private unregister;
|
|
824
|
+
private rafId;
|
|
825
|
+
private disposed;
|
|
826
|
+
constructor(host: RemoteLaserOverlayHost, options?: RemoteLaserOverlayOptions);
|
|
827
|
+
private now;
|
|
828
|
+
/**
|
|
829
|
+
* Applies a presence payload from `sender` (any opaque per-sender key, e.g.
|
|
830
|
+
* the envelope `from`). Non-laser or malformed payloads are ignored and
|
|
831
|
+
* reported as `false`, so hosts can feed every presence frame through.
|
|
832
|
+
*/
|
|
833
|
+
apply(sender: string, data: unknown): boolean;
|
|
834
|
+
/** Removes a sender's trail immediately (presence-leave/disconnect). */
|
|
835
|
+
remove(sender: string): void;
|
|
836
|
+
/** Removes every trail immediately. */
|
|
837
|
+
clear(): void;
|
|
838
|
+
/** Number of senders with a live (unfaded) trail. */
|
|
839
|
+
get activeSenderCount(): number;
|
|
840
|
+
/** Unregisters the overlay and stops the fade loop. Idempotent. */
|
|
841
|
+
dispose(): void;
|
|
842
|
+
private ensureAnimating;
|
|
843
|
+
private tick;
|
|
844
|
+
private renderTrails;
|
|
845
|
+
}
|
|
846
|
+
|
|
692
847
|
interface ActiveFormats {
|
|
693
848
|
bold: boolean;
|
|
694
849
|
italic: boolean;
|
|
@@ -1127,37 +1282,6 @@ declare class TemplateTool implements Tool {
|
|
|
1127
1282
|
private notifyOptionsChange;
|
|
1128
1283
|
}
|
|
1129
1284
|
|
|
1130
|
-
|
|
1131
|
-
name?: string;
|
|
1132
|
-
color?: string;
|
|
1133
|
-
width?: number;
|
|
1134
|
-
fadeMs?: number;
|
|
1135
|
-
}
|
|
1136
|
-
declare class LaserTool implements Tool {
|
|
1137
|
-
readonly name: string;
|
|
1138
|
-
private color;
|
|
1139
|
-
private width;
|
|
1140
|
-
private fadeMs;
|
|
1141
|
-
private trail;
|
|
1142
|
-
private rafId;
|
|
1143
|
-
private drawing;
|
|
1144
|
-
private optionListeners;
|
|
1145
|
-
constructor(options?: LaserToolOptions);
|
|
1146
|
-
private now;
|
|
1147
|
-
onActivate(ctx: ToolContext): void;
|
|
1148
|
-
onDeactivate(ctx: ToolContext): void;
|
|
1149
|
-
getOptions(): LaserToolOptions;
|
|
1150
|
-
onOptionsChange(listener: () => void): () => void;
|
|
1151
|
-
setOptions(options: LaserToolOptions): void;
|
|
1152
|
-
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
1153
|
-
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
1154
|
-
onPointerUp(_state: PointerState, _ctx: ToolContext): void;
|
|
1155
|
-
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
1156
|
-
private ensureAnimating;
|
|
1157
|
-
private tick;
|
|
1158
|
-
private notifyOptionsChange;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
declare const VERSION = "0.52.2";
|
|
1285
|
+
declare const VERSION = "0.54.0";
|
|
1162
1286
|
|
|
1163
|
-
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, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, 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, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
|
1287
|
+
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, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, 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, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.d.ts
CHANGED
|
@@ -510,6 +510,15 @@ interface RenderStatsSnapshot {
|
|
|
510
510
|
frameCount: number;
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
/**
|
|
514
|
+
* A world-space draw callback rendered above elements on every frame,
|
|
515
|
+
* regardless of which tool is active. The context arrives with the camera
|
|
516
|
+
* transform applied; implementations must not assume exclusive context state
|
|
517
|
+
* (each renderer is wrapped in save/restore). A throwing renderer is isolated
|
|
518
|
+
* per frame and must not break the render loop.
|
|
519
|
+
*/
|
|
520
|
+
type OverlayRenderer = (ctx: CanvasRenderingContext2D) => void;
|
|
521
|
+
|
|
513
522
|
interface ElementStyle {
|
|
514
523
|
color?: string;
|
|
515
524
|
fillColor?: string;
|
|
@@ -583,6 +592,7 @@ declare class Viewport {
|
|
|
583
592
|
private readonly noteEditor;
|
|
584
593
|
private readonly arrowLabelEditor;
|
|
585
594
|
private readonly historyRecorder;
|
|
595
|
+
private transactionDepth;
|
|
586
596
|
private readonly selectionOps;
|
|
587
597
|
readonly toolContext: ToolContext;
|
|
588
598
|
private readonly marginViewport;
|
|
@@ -608,6 +618,15 @@ declare class Viewport {
|
|
|
608
618
|
setSmartGuides(enabled: boolean): void;
|
|
609
619
|
fitToContent(padding?: number): void;
|
|
610
620
|
requestRender(): void;
|
|
621
|
+
/**
|
|
622
|
+
* Registers a world-space overlay drawn above elements on every frame,
|
|
623
|
+
* regardless of the active tool — the surface for remote presence visuals
|
|
624
|
+
* such as laser trails, cursors, pings, and shared rulers. Overlays draw
|
|
625
|
+
* beneath the active tool's own `renderOverlay` and never touch elements,
|
|
626
|
+
* history, or persisted state. Returns an idempotent unsubscribe that also
|
|
627
|
+
* erases the overlay's last frame.
|
|
628
|
+
*/
|
|
629
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
611
630
|
exportState(): CanvasState;
|
|
612
631
|
exportJSON(): string;
|
|
613
632
|
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
@@ -616,6 +635,14 @@ declare class Viewport {
|
|
|
616
635
|
loadJSON(json: string): void;
|
|
617
636
|
setTool(name: string): void;
|
|
618
637
|
get shortcuts(): ShortcutsApi;
|
|
638
|
+
/**
|
|
639
|
+
* Groups synchronous local store and layer mutations into one undo step.
|
|
640
|
+
* Nested calls join the outer transaction. If the callback throws, mutations
|
|
641
|
+
* already applied remain undoable and the original error is rethrown.
|
|
642
|
+
*/
|
|
643
|
+
transaction<T>(operation: () => T): T;
|
|
644
|
+
/** Removes existing elements as one undoable operation and returns the number removed. */
|
|
645
|
+
removeElements(ids: Iterable<string>): number;
|
|
619
646
|
undo(): boolean;
|
|
620
647
|
redo(): boolean;
|
|
621
648
|
addImage(src: string, position: {
|
|
@@ -689,6 +716,134 @@ declare class Viewport {
|
|
|
689
716
|
private observeResize;
|
|
690
717
|
}
|
|
691
718
|
|
|
719
|
+
interface LaserToolOptions {
|
|
720
|
+
name?: string;
|
|
721
|
+
color?: string;
|
|
722
|
+
width?: number;
|
|
723
|
+
fadeMs?: number;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* A coalesced batch of locally drawn trail points, flushed at most once per
|
|
727
|
+
* animation frame — the outgoing side of a shared laser pointer. Emissions
|
|
728
|
+
* carry world coordinates and the tool's current style so a host can forward
|
|
729
|
+
* them as ephemeral presence without duplicating the tool's input handling.
|
|
730
|
+
*/
|
|
731
|
+
interface LaserTrailEmission {
|
|
732
|
+
/** World-space points recorded since the previous emission, oldest first. */
|
|
733
|
+
readonly points: readonly Point[];
|
|
734
|
+
readonly color: string;
|
|
735
|
+
readonly width: number;
|
|
736
|
+
readonly fadeMs: number;
|
|
737
|
+
}
|
|
738
|
+
declare class LaserTool implements Tool {
|
|
739
|
+
readonly name: string;
|
|
740
|
+
private color;
|
|
741
|
+
private width;
|
|
742
|
+
private fadeMs;
|
|
743
|
+
private trail;
|
|
744
|
+
private rafId;
|
|
745
|
+
private drawing;
|
|
746
|
+
private optionListeners;
|
|
747
|
+
private trailListeners;
|
|
748
|
+
private pendingEmission;
|
|
749
|
+
constructor(options?: LaserToolOptions);
|
|
750
|
+
private now;
|
|
751
|
+
onActivate(ctx: ToolContext): void;
|
|
752
|
+
onDeactivate(ctx: ToolContext): void;
|
|
753
|
+
getOptions(): LaserToolOptions;
|
|
754
|
+
onOptionsChange(listener: () => void): () => void;
|
|
755
|
+
/**
|
|
756
|
+
* Subscribes to coalesced trail emissions. Points recorded by pointer input
|
|
757
|
+
* are batched and delivered at most once per animation frame, keeping
|
|
758
|
+
* outgoing presence packets small. Listeners must not throw; a throwing
|
|
759
|
+
* listener is isolated so it cannot stall the fade loop.
|
|
760
|
+
*/
|
|
761
|
+
onTrail(listener: (emission: LaserTrailEmission) => void): () => void;
|
|
762
|
+
setOptions(options: LaserToolOptions): void;
|
|
763
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
764
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
765
|
+
private recordPoint;
|
|
766
|
+
onPointerUp(_state: PointerState, _ctx: ToolContext): void;
|
|
767
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
768
|
+
private ensureAnimating;
|
|
769
|
+
private flushEmission;
|
|
770
|
+
private tick;
|
|
771
|
+
private notifyOptionsChange;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* The wire shape of a laser-trail presence payload. Presence data is untyped
|
|
776
|
+
* on the wire, so hosts discriminate on `kind`; `isLaserTrailPresence`
|
|
777
|
+
* validates a received payload before it reaches the overlay. Trails are
|
|
778
|
+
* ephemeral by contract: they must travel as presence only — never as
|
|
779
|
+
* elements, undo history, persisted canvas state, or durable operations.
|
|
780
|
+
*/
|
|
781
|
+
interface LaserTrailPresence {
|
|
782
|
+
readonly kind: 'laser';
|
|
783
|
+
/** World-space points, oldest first. */
|
|
784
|
+
readonly points: readonly Point[];
|
|
785
|
+
readonly color?: string;
|
|
786
|
+
readonly width?: number;
|
|
787
|
+
readonly fadeMs?: number;
|
|
788
|
+
}
|
|
789
|
+
declare const LASER_TRAIL_PRESENCE_KIND = "laser";
|
|
790
|
+
declare function isLaserTrailPresence(data: unknown): data is LaserTrailPresence;
|
|
791
|
+
/** Builds the presence payload for one local `LaserTool` emission. */
|
|
792
|
+
declare function toLaserTrailPresence(emission: LaserTrailEmission): LaserTrailPresence;
|
|
793
|
+
/**
|
|
794
|
+
* The two viewport capabilities the overlay needs; `Viewport` satisfies it.
|
|
795
|
+
*/
|
|
796
|
+
interface RemoteLaserOverlayHost {
|
|
797
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
798
|
+
requestRender(): void;
|
|
799
|
+
}
|
|
800
|
+
interface RemoteLaserOverlayOptions {
|
|
801
|
+
/** Style fallbacks when a payload omits them. */
|
|
802
|
+
color?: string;
|
|
803
|
+
width?: number;
|
|
804
|
+
fadeMs?: number;
|
|
805
|
+
/** Per-sender point cap; oldest points drop first. Default `512`. */
|
|
806
|
+
maxPointsPerSender?: number;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Renders fading laser trails for remote senders through the viewport overlay
|
|
810
|
+
* registration, independent of the viewer's active tool. Points are stamped
|
|
811
|
+
* with local receive time (remote clocks are never trusted), fade like the
|
|
812
|
+
* local `LaserTool`, and a sender's trail disappears immediately on
|
|
813
|
+
* `remove()` — wire that to `presence-leave`/disconnect. The controller never
|
|
814
|
+
* touches elements, history, or persisted state.
|
|
815
|
+
*/
|
|
816
|
+
declare class RemoteLaserOverlay {
|
|
817
|
+
private readonly host;
|
|
818
|
+
private readonly color;
|
|
819
|
+
private readonly width;
|
|
820
|
+
private readonly fadeMs;
|
|
821
|
+
private readonly maxPointsPerSender;
|
|
822
|
+
private readonly trails;
|
|
823
|
+
private unregister;
|
|
824
|
+
private rafId;
|
|
825
|
+
private disposed;
|
|
826
|
+
constructor(host: RemoteLaserOverlayHost, options?: RemoteLaserOverlayOptions);
|
|
827
|
+
private now;
|
|
828
|
+
/**
|
|
829
|
+
* Applies a presence payload from `sender` (any opaque per-sender key, e.g.
|
|
830
|
+
* the envelope `from`). Non-laser or malformed payloads are ignored and
|
|
831
|
+
* reported as `false`, so hosts can feed every presence frame through.
|
|
832
|
+
*/
|
|
833
|
+
apply(sender: string, data: unknown): boolean;
|
|
834
|
+
/** Removes a sender's trail immediately (presence-leave/disconnect). */
|
|
835
|
+
remove(sender: string): void;
|
|
836
|
+
/** Removes every trail immediately. */
|
|
837
|
+
clear(): void;
|
|
838
|
+
/** Number of senders with a live (unfaded) trail. */
|
|
839
|
+
get activeSenderCount(): number;
|
|
840
|
+
/** Unregisters the overlay and stops the fade loop. Idempotent. */
|
|
841
|
+
dispose(): void;
|
|
842
|
+
private ensureAnimating;
|
|
843
|
+
private tick;
|
|
844
|
+
private renderTrails;
|
|
845
|
+
}
|
|
846
|
+
|
|
692
847
|
interface ActiveFormats {
|
|
693
848
|
bold: boolean;
|
|
694
849
|
italic: boolean;
|
|
@@ -1127,37 +1282,6 @@ declare class TemplateTool implements Tool {
|
|
|
1127
1282
|
private notifyOptionsChange;
|
|
1128
1283
|
}
|
|
1129
1284
|
|
|
1130
|
-
|
|
1131
|
-
name?: string;
|
|
1132
|
-
color?: string;
|
|
1133
|
-
width?: number;
|
|
1134
|
-
fadeMs?: number;
|
|
1135
|
-
}
|
|
1136
|
-
declare class LaserTool implements Tool {
|
|
1137
|
-
readonly name: string;
|
|
1138
|
-
private color;
|
|
1139
|
-
private width;
|
|
1140
|
-
private fadeMs;
|
|
1141
|
-
private trail;
|
|
1142
|
-
private rafId;
|
|
1143
|
-
private drawing;
|
|
1144
|
-
private optionListeners;
|
|
1145
|
-
constructor(options?: LaserToolOptions);
|
|
1146
|
-
private now;
|
|
1147
|
-
onActivate(ctx: ToolContext): void;
|
|
1148
|
-
onDeactivate(ctx: ToolContext): void;
|
|
1149
|
-
getOptions(): LaserToolOptions;
|
|
1150
|
-
onOptionsChange(listener: () => void): () => void;
|
|
1151
|
-
setOptions(options: LaserToolOptions): void;
|
|
1152
|
-
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
1153
|
-
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
1154
|
-
onPointerUp(_state: PointerState, _ctx: ToolContext): void;
|
|
1155
|
-
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
1156
|
-
private ensureAnimating;
|
|
1157
|
-
private tick;
|
|
1158
|
-
private notifyOptionsChange;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
declare const VERSION = "0.52.2";
|
|
1285
|
+
declare const VERSION = "0.54.0";
|
|
1162
1286
|
|
|
1163
|
-
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, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, 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, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
|
1287
|
+
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, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, 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, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toLaserTrailPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|