@fieldnotes/core 0.8.5 → 0.8.7
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 +1058 -375
- package/dist/index.d.cts +75 -31
- package/dist/index.d.ts +75 -31
- package/dist/index.js +1056 -375
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,20 @@ interface Size {
|
|
|
24
24
|
}
|
|
25
25
|
type Bounds = Point & Size;
|
|
26
26
|
|
|
27
|
+
declare class Quadtree {
|
|
28
|
+
private root;
|
|
29
|
+
private _size;
|
|
30
|
+
private readonly worldBounds;
|
|
31
|
+
constructor(worldBounds: Bounds);
|
|
32
|
+
get size(): number;
|
|
33
|
+
insert(id: string, bounds: Bounds): void;
|
|
34
|
+
remove(id: string): void;
|
|
35
|
+
update(id: string, newBounds: Bounds): void;
|
|
36
|
+
query(rect: Bounds): string[];
|
|
37
|
+
queryPoint(point: Point): string[];
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
interface BaseElement {
|
|
28
42
|
id: string;
|
|
29
43
|
type: string;
|
|
@@ -139,6 +153,7 @@ declare class ElementStore {
|
|
|
139
153
|
private elements;
|
|
140
154
|
private bus;
|
|
141
155
|
private layerOrderMap;
|
|
156
|
+
private spatialIndex;
|
|
142
157
|
get count(): number;
|
|
143
158
|
setLayerOrder(order: Map<string, number>): void;
|
|
144
159
|
getAll(): CanvasElement[];
|
|
@@ -152,13 +167,20 @@ declare class ElementStore {
|
|
|
152
167
|
clear(): void;
|
|
153
168
|
snapshot(): CanvasElement[];
|
|
154
169
|
loadSnapshot(elements: CanvasElement[]): void;
|
|
170
|
+
queryRect(rect: Bounds): CanvasElement[];
|
|
171
|
+
queryPoint(point: Point): CanvasElement[];
|
|
155
172
|
on<K extends keyof ElementStoreEvents>(event: K, listener: (data: ElementStoreEvents[K]) => void): () => void;
|
|
173
|
+
onChange(listener: () => void): () => void;
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
interface CameraOptions {
|
|
159
177
|
minZoom?: number;
|
|
160
178
|
maxZoom?: number;
|
|
161
179
|
}
|
|
180
|
+
interface CameraChangeInfo {
|
|
181
|
+
panned: boolean;
|
|
182
|
+
zoomed: boolean;
|
|
183
|
+
}
|
|
162
184
|
declare class Camera {
|
|
163
185
|
private x;
|
|
164
186
|
private y;
|
|
@@ -175,9 +197,12 @@ declare class Camera {
|
|
|
175
197
|
zoomAt(level: number, screenPoint: Point): void;
|
|
176
198
|
screenToWorld(screen: Point): Point;
|
|
177
199
|
worldToScreen(world: Point): Point;
|
|
200
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
178
201
|
toCSSTransform(): string;
|
|
179
|
-
onChange(listener: () => void): () => void;
|
|
180
|
-
private
|
|
202
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
203
|
+
private notifyPan;
|
|
204
|
+
private notifyZoom;
|
|
205
|
+
private notifyPanAndZoom;
|
|
181
206
|
}
|
|
182
207
|
|
|
183
208
|
declare class LayerManager {
|
|
@@ -198,6 +223,7 @@ declare class LayerManager {
|
|
|
198
223
|
reorderLayer(id: string, newOrder: number): void;
|
|
199
224
|
setLayerVisible(id: string, visible: boolean): boolean;
|
|
200
225
|
setLayerLocked(id: string, locked: boolean): boolean;
|
|
226
|
+
setLayerOpacity(id: string, opacity: number): void;
|
|
201
227
|
setActiveLayer(id: string): void;
|
|
202
228
|
moveElementToLayer(elementId: string, layerId: string): void;
|
|
203
229
|
snapshot(): Layer[];
|
|
@@ -281,6 +307,9 @@ interface Tool {
|
|
|
281
307
|
onActivate?(ctx: ToolContext): void;
|
|
282
308
|
onDeactivate?(ctx: ToolContext): void;
|
|
283
309
|
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
310
|
+
getOptions?(): object;
|
|
311
|
+
setOptions?(options: object): void;
|
|
312
|
+
onOptionsChange?(listener: () => void): () => void;
|
|
284
313
|
}
|
|
285
314
|
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
|
|
286
315
|
|
|
@@ -424,13 +453,11 @@ declare class Viewport {
|
|
|
424
453
|
private readonly historyRecorder;
|
|
425
454
|
readonly toolContext: ToolContext;
|
|
426
455
|
private resizeObserver;
|
|
427
|
-
private animFrameId;
|
|
428
456
|
private _snapToGrid;
|
|
429
457
|
private readonly _gridSize;
|
|
430
|
-
private
|
|
431
|
-
private
|
|
432
|
-
private
|
|
433
|
-
private interactingElementId;
|
|
458
|
+
private readonly renderLoop;
|
|
459
|
+
private readonly domNodeManager;
|
|
460
|
+
private readonly interactMode;
|
|
434
461
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
435
462
|
get ctx(): CanvasRenderingContext2D | null;
|
|
436
463
|
get snapToGrid(): boolean;
|
|
@@ -468,26 +495,14 @@ declare class Viewport {
|
|
|
468
495
|
updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
|
|
469
496
|
removeGrid(): void;
|
|
470
497
|
destroy(): void;
|
|
471
|
-
private startRenderLoop;
|
|
472
|
-
private render;
|
|
473
498
|
private startEditingElement;
|
|
474
499
|
private onTextEditStop;
|
|
475
500
|
private onDblClick;
|
|
476
501
|
private hitTestWorld;
|
|
477
|
-
private startInteracting;
|
|
478
502
|
stopInteracting(): void;
|
|
479
|
-
private onInteractNodePointerDown;
|
|
480
|
-
private onInteractKeyDown;
|
|
481
|
-
private onInteractPointerDown;
|
|
482
503
|
private onDragOver;
|
|
483
504
|
private onDrop;
|
|
484
|
-
private syncDomNode;
|
|
485
|
-
private renderDomContent;
|
|
486
505
|
private unbindArrowsFrom;
|
|
487
|
-
private hideDomNode;
|
|
488
|
-
private removeDomNode;
|
|
489
|
-
private clearDomNodes;
|
|
490
|
-
private reattachHtmlContent;
|
|
491
506
|
private createWrapper;
|
|
492
507
|
private createCanvas;
|
|
493
508
|
private createDomLayer;
|
|
@@ -496,6 +511,14 @@ declare class Viewport {
|
|
|
496
511
|
private observeResize;
|
|
497
512
|
}
|
|
498
513
|
|
|
514
|
+
interface RenderStatsSnapshot {
|
|
515
|
+
fps: number;
|
|
516
|
+
avgFrameMs: number;
|
|
517
|
+
p95FrameMs: number;
|
|
518
|
+
lastFrameMs: number;
|
|
519
|
+
frameCount: number;
|
|
520
|
+
}
|
|
521
|
+
|
|
499
522
|
declare class ElementRenderer {
|
|
500
523
|
private store;
|
|
501
524
|
private imageCache;
|
|
@@ -610,29 +633,25 @@ interface GridInput extends BaseDefaults {
|
|
|
610
633
|
declare function createGrid(input: GridInput): GridElement;
|
|
611
634
|
declare function createText(input: TextInput): TextElement;
|
|
612
635
|
|
|
613
|
-
interface Rect {
|
|
614
|
-
x: number;
|
|
615
|
-
y: number;
|
|
616
|
-
w: number;
|
|
617
|
-
h: number;
|
|
618
|
-
}
|
|
619
636
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
620
637
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
621
638
|
declare function getBendFromPoint(from: Point, to: Point, dragPoint: Point): number;
|
|
622
639
|
declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: number): number;
|
|
623
640
|
declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
|
|
624
|
-
declare function getArrowBounds(from: Point, to: Point, bend: number):
|
|
641
|
+
declare function getArrowBounds(from: Point, to: Point, bend: number): Bounds;
|
|
625
642
|
|
|
626
643
|
declare function isBindable(element: CanvasElement): boolean;
|
|
627
644
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
628
|
-
declare function
|
|
629
|
-
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
645
|
+
declare function getEdgeIntersection(bounds: Bounds, outsidePoint: Point): Point;
|
|
630
646
|
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
631
647
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
632
648
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
633
649
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
634
650
|
declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
|
|
635
651
|
|
|
652
|
+
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
653
|
+
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
654
|
+
|
|
636
655
|
declare class AddElementCommand implements Command {
|
|
637
656
|
private readonly element;
|
|
638
657
|
constructor(element: CanvasElement);
|
|
@@ -675,6 +694,8 @@ interface PencilToolOptions {
|
|
|
675
694
|
color?: string;
|
|
676
695
|
width?: number;
|
|
677
696
|
smoothing?: number;
|
|
697
|
+
minPointDistance?: number;
|
|
698
|
+
progressiveSimplifyThreshold?: number;
|
|
678
699
|
}
|
|
679
700
|
declare class PencilTool implements Tool {
|
|
680
701
|
readonly name = "pencil";
|
|
@@ -683,13 +704,20 @@ declare class PencilTool implements Tool {
|
|
|
683
704
|
private color;
|
|
684
705
|
private width;
|
|
685
706
|
private smoothing;
|
|
707
|
+
private minPointDistance;
|
|
708
|
+
private progressiveThreshold;
|
|
709
|
+
private nextSimplifyAt;
|
|
710
|
+
private optionListeners;
|
|
686
711
|
constructor(options?: PencilToolOptions);
|
|
687
712
|
onActivate(ctx: ToolContext): void;
|
|
688
713
|
onDeactivate(ctx: ToolContext): void;
|
|
714
|
+
getOptions(): PencilToolOptions;
|
|
715
|
+
onOptionsChange(listener: () => void): () => void;
|
|
689
716
|
setOptions(options: PencilToolOptions): void;
|
|
690
717
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
691
718
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
692
719
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
720
|
+
private notifyOptionsChange;
|
|
693
721
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
694
722
|
}
|
|
695
723
|
|
|
@@ -702,6 +730,7 @@ declare class EraserTool implements Tool {
|
|
|
702
730
|
private readonly radius;
|
|
703
731
|
private readonly cursor;
|
|
704
732
|
constructor(options?: EraserToolOptions);
|
|
733
|
+
getOptions(): EraserToolOptions;
|
|
705
734
|
onActivate(ctx: ToolContext): void;
|
|
706
735
|
onDeactivate(ctx: ToolContext): void;
|
|
707
736
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
@@ -738,7 +767,6 @@ declare class SelectTool implements Tool {
|
|
|
738
767
|
private getMarqueeRect;
|
|
739
768
|
private findElementsInRect;
|
|
740
769
|
private rectsOverlap;
|
|
741
|
-
private getElementBounds;
|
|
742
770
|
private hitTest;
|
|
743
771
|
private isInsideBounds;
|
|
744
772
|
}
|
|
@@ -757,8 +785,12 @@ declare class ArrowTool implements Tool {
|
|
|
757
785
|
private fromBinding;
|
|
758
786
|
private fromTarget;
|
|
759
787
|
private toTarget;
|
|
788
|
+
private optionListeners;
|
|
760
789
|
constructor(options?: ArrowToolOptions);
|
|
790
|
+
getOptions(): ArrowToolOptions;
|
|
791
|
+
onOptionsChange(listener: () => void): () => void;
|
|
761
792
|
setOptions(options: ArrowToolOptions): void;
|
|
793
|
+
private notifyOptionsChange;
|
|
762
794
|
private layerFilter;
|
|
763
795
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
764
796
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
@@ -776,8 +808,12 @@ declare class NoteTool implements Tool {
|
|
|
776
808
|
private backgroundColor;
|
|
777
809
|
private textColor;
|
|
778
810
|
private size;
|
|
811
|
+
private optionListeners;
|
|
779
812
|
constructor(options?: NoteToolOptions);
|
|
813
|
+
getOptions(): NoteToolOptions;
|
|
814
|
+
onOptionsChange(listener: () => void): () => void;
|
|
780
815
|
setOptions(options: NoteToolOptions): void;
|
|
816
|
+
private notifyOptionsChange;
|
|
781
817
|
onPointerDown(_state: PointerState, _ctx: ToolContext): void;
|
|
782
818
|
onPointerMove(_state: PointerState, _ctx: ToolContext): void;
|
|
783
819
|
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
@@ -793,8 +829,12 @@ declare class TextTool implements Tool {
|
|
|
793
829
|
private fontSize;
|
|
794
830
|
private color;
|
|
795
831
|
private textAlign;
|
|
832
|
+
private optionListeners;
|
|
796
833
|
constructor(options?: TextToolOptions);
|
|
834
|
+
getOptions(): TextToolOptions;
|
|
835
|
+
onOptionsChange(listener: () => void): () => void;
|
|
797
836
|
setOptions(options: TextToolOptions): void;
|
|
837
|
+
private notifyOptionsChange;
|
|
798
838
|
onActivate(ctx: ToolContext): void;
|
|
799
839
|
onDeactivate(ctx: ToolContext): void;
|
|
800
840
|
onPointerDown(_state: PointerState, _ctx: ToolContext): void;
|
|
@@ -832,7 +872,10 @@ declare class ShapeTool implements Tool {
|
|
|
832
872
|
private strokeColor;
|
|
833
873
|
private strokeWidth;
|
|
834
874
|
private fillColor;
|
|
875
|
+
private optionListeners;
|
|
835
876
|
constructor(options?: ShapeToolOptions);
|
|
877
|
+
getOptions(): ShapeToolOptions;
|
|
878
|
+
onOptionsChange(listener: () => void): () => void;
|
|
836
879
|
setOptions(options: ShapeToolOptions): void;
|
|
837
880
|
onActivate(_ctx: ToolContext): void;
|
|
838
881
|
onDeactivate(_ctx: ToolContext): void;
|
|
@@ -841,6 +884,7 @@ declare class ShapeTool implements Tool {
|
|
|
841
884
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
842
885
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
843
886
|
private computeRect;
|
|
887
|
+
private notifyOptionsChange;
|
|
844
888
|
private snap;
|
|
845
889
|
private onKeyDown;
|
|
846
890
|
private onKeyUp;
|
|
@@ -870,6 +914,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
870
914
|
undo(_store: ElementStore): void;
|
|
871
915
|
}
|
|
872
916
|
|
|
873
|
-
declare const VERSION = "0.8.
|
|
917
|
+
declare const VERSION = "0.8.7";
|
|
874
918
|
|
|
875
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
|
919
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, Quadtree, RemoveElementCommand, RemoveLayerCommand, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, boundsIntersect, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,20 @@ interface Size {
|
|
|
24
24
|
}
|
|
25
25
|
type Bounds = Point & Size;
|
|
26
26
|
|
|
27
|
+
declare class Quadtree {
|
|
28
|
+
private root;
|
|
29
|
+
private _size;
|
|
30
|
+
private readonly worldBounds;
|
|
31
|
+
constructor(worldBounds: Bounds);
|
|
32
|
+
get size(): number;
|
|
33
|
+
insert(id: string, bounds: Bounds): void;
|
|
34
|
+
remove(id: string): void;
|
|
35
|
+
update(id: string, newBounds: Bounds): void;
|
|
36
|
+
query(rect: Bounds): string[];
|
|
37
|
+
queryPoint(point: Point): string[];
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
interface BaseElement {
|
|
28
42
|
id: string;
|
|
29
43
|
type: string;
|
|
@@ -139,6 +153,7 @@ declare class ElementStore {
|
|
|
139
153
|
private elements;
|
|
140
154
|
private bus;
|
|
141
155
|
private layerOrderMap;
|
|
156
|
+
private spatialIndex;
|
|
142
157
|
get count(): number;
|
|
143
158
|
setLayerOrder(order: Map<string, number>): void;
|
|
144
159
|
getAll(): CanvasElement[];
|
|
@@ -152,13 +167,20 @@ declare class ElementStore {
|
|
|
152
167
|
clear(): void;
|
|
153
168
|
snapshot(): CanvasElement[];
|
|
154
169
|
loadSnapshot(elements: CanvasElement[]): void;
|
|
170
|
+
queryRect(rect: Bounds): CanvasElement[];
|
|
171
|
+
queryPoint(point: Point): CanvasElement[];
|
|
155
172
|
on<K extends keyof ElementStoreEvents>(event: K, listener: (data: ElementStoreEvents[K]) => void): () => void;
|
|
173
|
+
onChange(listener: () => void): () => void;
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
interface CameraOptions {
|
|
159
177
|
minZoom?: number;
|
|
160
178
|
maxZoom?: number;
|
|
161
179
|
}
|
|
180
|
+
interface CameraChangeInfo {
|
|
181
|
+
panned: boolean;
|
|
182
|
+
zoomed: boolean;
|
|
183
|
+
}
|
|
162
184
|
declare class Camera {
|
|
163
185
|
private x;
|
|
164
186
|
private y;
|
|
@@ -175,9 +197,12 @@ declare class Camera {
|
|
|
175
197
|
zoomAt(level: number, screenPoint: Point): void;
|
|
176
198
|
screenToWorld(screen: Point): Point;
|
|
177
199
|
worldToScreen(world: Point): Point;
|
|
200
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
178
201
|
toCSSTransform(): string;
|
|
179
|
-
onChange(listener: () => void): () => void;
|
|
180
|
-
private
|
|
202
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
203
|
+
private notifyPan;
|
|
204
|
+
private notifyZoom;
|
|
205
|
+
private notifyPanAndZoom;
|
|
181
206
|
}
|
|
182
207
|
|
|
183
208
|
declare class LayerManager {
|
|
@@ -198,6 +223,7 @@ declare class LayerManager {
|
|
|
198
223
|
reorderLayer(id: string, newOrder: number): void;
|
|
199
224
|
setLayerVisible(id: string, visible: boolean): boolean;
|
|
200
225
|
setLayerLocked(id: string, locked: boolean): boolean;
|
|
226
|
+
setLayerOpacity(id: string, opacity: number): void;
|
|
201
227
|
setActiveLayer(id: string): void;
|
|
202
228
|
moveElementToLayer(elementId: string, layerId: string): void;
|
|
203
229
|
snapshot(): Layer[];
|
|
@@ -281,6 +307,9 @@ interface Tool {
|
|
|
281
307
|
onActivate?(ctx: ToolContext): void;
|
|
282
308
|
onDeactivate?(ctx: ToolContext): void;
|
|
283
309
|
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
310
|
+
getOptions?(): object;
|
|
311
|
+
setOptions?(options: object): void;
|
|
312
|
+
onOptionsChange?(listener: () => void): () => void;
|
|
284
313
|
}
|
|
285
314
|
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
|
|
286
315
|
|
|
@@ -424,13 +453,11 @@ declare class Viewport {
|
|
|
424
453
|
private readonly historyRecorder;
|
|
425
454
|
readonly toolContext: ToolContext;
|
|
426
455
|
private resizeObserver;
|
|
427
|
-
private animFrameId;
|
|
428
456
|
private _snapToGrid;
|
|
429
457
|
private readonly _gridSize;
|
|
430
|
-
private
|
|
431
|
-
private
|
|
432
|
-
private
|
|
433
|
-
private interactingElementId;
|
|
458
|
+
private readonly renderLoop;
|
|
459
|
+
private readonly domNodeManager;
|
|
460
|
+
private readonly interactMode;
|
|
434
461
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
435
462
|
get ctx(): CanvasRenderingContext2D | null;
|
|
436
463
|
get snapToGrid(): boolean;
|
|
@@ -468,26 +495,14 @@ declare class Viewport {
|
|
|
468
495
|
updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
|
|
469
496
|
removeGrid(): void;
|
|
470
497
|
destroy(): void;
|
|
471
|
-
private startRenderLoop;
|
|
472
|
-
private render;
|
|
473
498
|
private startEditingElement;
|
|
474
499
|
private onTextEditStop;
|
|
475
500
|
private onDblClick;
|
|
476
501
|
private hitTestWorld;
|
|
477
|
-
private startInteracting;
|
|
478
502
|
stopInteracting(): void;
|
|
479
|
-
private onInteractNodePointerDown;
|
|
480
|
-
private onInteractKeyDown;
|
|
481
|
-
private onInteractPointerDown;
|
|
482
503
|
private onDragOver;
|
|
483
504
|
private onDrop;
|
|
484
|
-
private syncDomNode;
|
|
485
|
-
private renderDomContent;
|
|
486
505
|
private unbindArrowsFrom;
|
|
487
|
-
private hideDomNode;
|
|
488
|
-
private removeDomNode;
|
|
489
|
-
private clearDomNodes;
|
|
490
|
-
private reattachHtmlContent;
|
|
491
506
|
private createWrapper;
|
|
492
507
|
private createCanvas;
|
|
493
508
|
private createDomLayer;
|
|
@@ -496,6 +511,14 @@ declare class Viewport {
|
|
|
496
511
|
private observeResize;
|
|
497
512
|
}
|
|
498
513
|
|
|
514
|
+
interface RenderStatsSnapshot {
|
|
515
|
+
fps: number;
|
|
516
|
+
avgFrameMs: number;
|
|
517
|
+
p95FrameMs: number;
|
|
518
|
+
lastFrameMs: number;
|
|
519
|
+
frameCount: number;
|
|
520
|
+
}
|
|
521
|
+
|
|
499
522
|
declare class ElementRenderer {
|
|
500
523
|
private store;
|
|
501
524
|
private imageCache;
|
|
@@ -610,29 +633,25 @@ interface GridInput extends BaseDefaults {
|
|
|
610
633
|
declare function createGrid(input: GridInput): GridElement;
|
|
611
634
|
declare function createText(input: TextInput): TextElement;
|
|
612
635
|
|
|
613
|
-
interface Rect {
|
|
614
|
-
x: number;
|
|
615
|
-
y: number;
|
|
616
|
-
w: number;
|
|
617
|
-
h: number;
|
|
618
|
-
}
|
|
619
636
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
620
637
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
621
638
|
declare function getBendFromPoint(from: Point, to: Point, dragPoint: Point): number;
|
|
622
639
|
declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: number): number;
|
|
623
640
|
declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
|
|
624
|
-
declare function getArrowBounds(from: Point, to: Point, bend: number):
|
|
641
|
+
declare function getArrowBounds(from: Point, to: Point, bend: number): Bounds;
|
|
625
642
|
|
|
626
643
|
declare function isBindable(element: CanvasElement): boolean;
|
|
627
644
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
628
|
-
declare function
|
|
629
|
-
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
645
|
+
declare function getEdgeIntersection(bounds: Bounds, outsidePoint: Point): Point;
|
|
630
646
|
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
631
647
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
632
648
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
633
649
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
634
650
|
declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
|
|
635
651
|
|
|
652
|
+
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
653
|
+
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
654
|
+
|
|
636
655
|
declare class AddElementCommand implements Command {
|
|
637
656
|
private readonly element;
|
|
638
657
|
constructor(element: CanvasElement);
|
|
@@ -675,6 +694,8 @@ interface PencilToolOptions {
|
|
|
675
694
|
color?: string;
|
|
676
695
|
width?: number;
|
|
677
696
|
smoothing?: number;
|
|
697
|
+
minPointDistance?: number;
|
|
698
|
+
progressiveSimplifyThreshold?: number;
|
|
678
699
|
}
|
|
679
700
|
declare class PencilTool implements Tool {
|
|
680
701
|
readonly name = "pencil";
|
|
@@ -683,13 +704,20 @@ declare class PencilTool implements Tool {
|
|
|
683
704
|
private color;
|
|
684
705
|
private width;
|
|
685
706
|
private smoothing;
|
|
707
|
+
private minPointDistance;
|
|
708
|
+
private progressiveThreshold;
|
|
709
|
+
private nextSimplifyAt;
|
|
710
|
+
private optionListeners;
|
|
686
711
|
constructor(options?: PencilToolOptions);
|
|
687
712
|
onActivate(ctx: ToolContext): void;
|
|
688
713
|
onDeactivate(ctx: ToolContext): void;
|
|
714
|
+
getOptions(): PencilToolOptions;
|
|
715
|
+
onOptionsChange(listener: () => void): () => void;
|
|
689
716
|
setOptions(options: PencilToolOptions): void;
|
|
690
717
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
691
718
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
692
719
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
720
|
+
private notifyOptionsChange;
|
|
693
721
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
694
722
|
}
|
|
695
723
|
|
|
@@ -702,6 +730,7 @@ declare class EraserTool implements Tool {
|
|
|
702
730
|
private readonly radius;
|
|
703
731
|
private readonly cursor;
|
|
704
732
|
constructor(options?: EraserToolOptions);
|
|
733
|
+
getOptions(): EraserToolOptions;
|
|
705
734
|
onActivate(ctx: ToolContext): void;
|
|
706
735
|
onDeactivate(ctx: ToolContext): void;
|
|
707
736
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
@@ -738,7 +767,6 @@ declare class SelectTool implements Tool {
|
|
|
738
767
|
private getMarqueeRect;
|
|
739
768
|
private findElementsInRect;
|
|
740
769
|
private rectsOverlap;
|
|
741
|
-
private getElementBounds;
|
|
742
770
|
private hitTest;
|
|
743
771
|
private isInsideBounds;
|
|
744
772
|
}
|
|
@@ -757,8 +785,12 @@ declare class ArrowTool implements Tool {
|
|
|
757
785
|
private fromBinding;
|
|
758
786
|
private fromTarget;
|
|
759
787
|
private toTarget;
|
|
788
|
+
private optionListeners;
|
|
760
789
|
constructor(options?: ArrowToolOptions);
|
|
790
|
+
getOptions(): ArrowToolOptions;
|
|
791
|
+
onOptionsChange(listener: () => void): () => void;
|
|
761
792
|
setOptions(options: ArrowToolOptions): void;
|
|
793
|
+
private notifyOptionsChange;
|
|
762
794
|
private layerFilter;
|
|
763
795
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
764
796
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
@@ -776,8 +808,12 @@ declare class NoteTool implements Tool {
|
|
|
776
808
|
private backgroundColor;
|
|
777
809
|
private textColor;
|
|
778
810
|
private size;
|
|
811
|
+
private optionListeners;
|
|
779
812
|
constructor(options?: NoteToolOptions);
|
|
813
|
+
getOptions(): NoteToolOptions;
|
|
814
|
+
onOptionsChange(listener: () => void): () => void;
|
|
780
815
|
setOptions(options: NoteToolOptions): void;
|
|
816
|
+
private notifyOptionsChange;
|
|
781
817
|
onPointerDown(_state: PointerState, _ctx: ToolContext): void;
|
|
782
818
|
onPointerMove(_state: PointerState, _ctx: ToolContext): void;
|
|
783
819
|
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
@@ -793,8 +829,12 @@ declare class TextTool implements Tool {
|
|
|
793
829
|
private fontSize;
|
|
794
830
|
private color;
|
|
795
831
|
private textAlign;
|
|
832
|
+
private optionListeners;
|
|
796
833
|
constructor(options?: TextToolOptions);
|
|
834
|
+
getOptions(): TextToolOptions;
|
|
835
|
+
onOptionsChange(listener: () => void): () => void;
|
|
797
836
|
setOptions(options: TextToolOptions): void;
|
|
837
|
+
private notifyOptionsChange;
|
|
798
838
|
onActivate(ctx: ToolContext): void;
|
|
799
839
|
onDeactivate(ctx: ToolContext): void;
|
|
800
840
|
onPointerDown(_state: PointerState, _ctx: ToolContext): void;
|
|
@@ -832,7 +872,10 @@ declare class ShapeTool implements Tool {
|
|
|
832
872
|
private strokeColor;
|
|
833
873
|
private strokeWidth;
|
|
834
874
|
private fillColor;
|
|
875
|
+
private optionListeners;
|
|
835
876
|
constructor(options?: ShapeToolOptions);
|
|
877
|
+
getOptions(): ShapeToolOptions;
|
|
878
|
+
onOptionsChange(listener: () => void): () => void;
|
|
836
879
|
setOptions(options: ShapeToolOptions): void;
|
|
837
880
|
onActivate(_ctx: ToolContext): void;
|
|
838
881
|
onDeactivate(_ctx: ToolContext): void;
|
|
@@ -841,6 +884,7 @@ declare class ShapeTool implements Tool {
|
|
|
841
884
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
842
885
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
843
886
|
private computeRect;
|
|
887
|
+
private notifyOptionsChange;
|
|
844
888
|
private snap;
|
|
845
889
|
private onKeyDown;
|
|
846
890
|
private onKeyUp;
|
|
@@ -870,6 +914,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
870
914
|
undo(_store: ElementStore): void;
|
|
871
915
|
}
|
|
872
916
|
|
|
873
|
-
declare const VERSION = "0.8.
|
|
917
|
+
declare const VERSION = "0.8.7";
|
|
874
918
|
|
|
875
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
|
919
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, Quadtree, RemoveElementCommand, RemoveLayerCommand, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, boundsIntersect, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|