@fieldnotes/core 0.8.6 → 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 +630 -130
- package/dist/index.d.cts +46 -14
- package/dist/index.d.ts +46 -14
- package/dist/index.js +628 -130
- 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,6 +167,8 @@ 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;
|
|
156
173
|
onChange(listener: () => void): () => void;
|
|
157
174
|
}
|
|
@@ -160,6 +177,10 @@ interface CameraOptions {
|
|
|
160
177
|
minZoom?: number;
|
|
161
178
|
maxZoom?: number;
|
|
162
179
|
}
|
|
180
|
+
interface CameraChangeInfo {
|
|
181
|
+
panned: boolean;
|
|
182
|
+
zoomed: boolean;
|
|
183
|
+
}
|
|
163
184
|
declare class Camera {
|
|
164
185
|
private x;
|
|
165
186
|
private y;
|
|
@@ -176,9 +197,12 @@ declare class Camera {
|
|
|
176
197
|
zoomAt(level: number, screenPoint: Point): void;
|
|
177
198
|
screenToWorld(screen: Point): Point;
|
|
178
199
|
worldToScreen(world: Point): Point;
|
|
200
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
179
201
|
toCSSTransform(): string;
|
|
180
|
-
onChange(listener: () => void): () => void;
|
|
181
|
-
private
|
|
202
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
203
|
+
private notifyPan;
|
|
204
|
+
private notifyZoom;
|
|
205
|
+
private notifyPanAndZoom;
|
|
182
206
|
}
|
|
183
207
|
|
|
184
208
|
declare class LayerManager {
|
|
@@ -487,6 +511,14 @@ declare class Viewport {
|
|
|
487
511
|
private observeResize;
|
|
488
512
|
}
|
|
489
513
|
|
|
514
|
+
interface RenderStatsSnapshot {
|
|
515
|
+
fps: number;
|
|
516
|
+
avgFrameMs: number;
|
|
517
|
+
p95FrameMs: number;
|
|
518
|
+
lastFrameMs: number;
|
|
519
|
+
frameCount: number;
|
|
520
|
+
}
|
|
521
|
+
|
|
490
522
|
declare class ElementRenderer {
|
|
491
523
|
private store;
|
|
492
524
|
private imageCache;
|
|
@@ -601,29 +633,25 @@ interface GridInput extends BaseDefaults {
|
|
|
601
633
|
declare function createGrid(input: GridInput): GridElement;
|
|
602
634
|
declare function createText(input: TextInput): TextElement;
|
|
603
635
|
|
|
604
|
-
interface Rect {
|
|
605
|
-
x: number;
|
|
606
|
-
y: number;
|
|
607
|
-
w: number;
|
|
608
|
-
h: number;
|
|
609
|
-
}
|
|
610
636
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
611
637
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
612
638
|
declare function getBendFromPoint(from: Point, to: Point, dragPoint: Point): number;
|
|
613
639
|
declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: number): number;
|
|
614
640
|
declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
|
|
615
|
-
declare function getArrowBounds(from: Point, to: Point, bend: number):
|
|
641
|
+
declare function getArrowBounds(from: Point, to: Point, bend: number): Bounds;
|
|
616
642
|
|
|
617
643
|
declare function isBindable(element: CanvasElement): boolean;
|
|
618
644
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
619
|
-
declare function
|
|
620
|
-
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
645
|
+
declare function getEdgeIntersection(bounds: Bounds, outsidePoint: Point): Point;
|
|
621
646
|
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
622
647
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
623
648
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
624
649
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
625
650
|
declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
|
|
626
651
|
|
|
652
|
+
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
653
|
+
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
654
|
+
|
|
627
655
|
declare class AddElementCommand implements Command {
|
|
628
656
|
private readonly element;
|
|
629
657
|
constructor(element: CanvasElement);
|
|
@@ -666,6 +694,8 @@ interface PencilToolOptions {
|
|
|
666
694
|
color?: string;
|
|
667
695
|
width?: number;
|
|
668
696
|
smoothing?: number;
|
|
697
|
+
minPointDistance?: number;
|
|
698
|
+
progressiveSimplifyThreshold?: number;
|
|
669
699
|
}
|
|
670
700
|
declare class PencilTool implements Tool {
|
|
671
701
|
readonly name = "pencil";
|
|
@@ -674,6 +704,9 @@ declare class PencilTool implements Tool {
|
|
|
674
704
|
private color;
|
|
675
705
|
private width;
|
|
676
706
|
private smoothing;
|
|
707
|
+
private minPointDistance;
|
|
708
|
+
private progressiveThreshold;
|
|
709
|
+
private nextSimplifyAt;
|
|
677
710
|
private optionListeners;
|
|
678
711
|
constructor(options?: PencilToolOptions);
|
|
679
712
|
onActivate(ctx: ToolContext): void;
|
|
@@ -734,7 +767,6 @@ declare class SelectTool implements Tool {
|
|
|
734
767
|
private getMarqueeRect;
|
|
735
768
|
private findElementsInRect;
|
|
736
769
|
private rectsOverlap;
|
|
737
|
-
private getElementBounds;
|
|
738
770
|
private hitTest;
|
|
739
771
|
private isInsideBounds;
|
|
740
772
|
}
|
|
@@ -882,6 +914,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
882
914
|
undo(_store: ElementStore): void;
|
|
883
915
|
}
|
|
884
916
|
|
|
885
|
-
declare const VERSION = "0.8.
|
|
917
|
+
declare const VERSION = "0.8.7";
|
|
886
918
|
|
|
887
|
-
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,6 +167,8 @@ 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;
|
|
156
173
|
onChange(listener: () => void): () => void;
|
|
157
174
|
}
|
|
@@ -160,6 +177,10 @@ interface CameraOptions {
|
|
|
160
177
|
minZoom?: number;
|
|
161
178
|
maxZoom?: number;
|
|
162
179
|
}
|
|
180
|
+
interface CameraChangeInfo {
|
|
181
|
+
panned: boolean;
|
|
182
|
+
zoomed: boolean;
|
|
183
|
+
}
|
|
163
184
|
declare class Camera {
|
|
164
185
|
private x;
|
|
165
186
|
private y;
|
|
@@ -176,9 +197,12 @@ declare class Camera {
|
|
|
176
197
|
zoomAt(level: number, screenPoint: Point): void;
|
|
177
198
|
screenToWorld(screen: Point): Point;
|
|
178
199
|
worldToScreen(world: Point): Point;
|
|
200
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
179
201
|
toCSSTransform(): string;
|
|
180
|
-
onChange(listener: () => void): () => void;
|
|
181
|
-
private
|
|
202
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
203
|
+
private notifyPan;
|
|
204
|
+
private notifyZoom;
|
|
205
|
+
private notifyPanAndZoom;
|
|
182
206
|
}
|
|
183
207
|
|
|
184
208
|
declare class LayerManager {
|
|
@@ -487,6 +511,14 @@ declare class Viewport {
|
|
|
487
511
|
private observeResize;
|
|
488
512
|
}
|
|
489
513
|
|
|
514
|
+
interface RenderStatsSnapshot {
|
|
515
|
+
fps: number;
|
|
516
|
+
avgFrameMs: number;
|
|
517
|
+
p95FrameMs: number;
|
|
518
|
+
lastFrameMs: number;
|
|
519
|
+
frameCount: number;
|
|
520
|
+
}
|
|
521
|
+
|
|
490
522
|
declare class ElementRenderer {
|
|
491
523
|
private store;
|
|
492
524
|
private imageCache;
|
|
@@ -601,29 +633,25 @@ interface GridInput extends BaseDefaults {
|
|
|
601
633
|
declare function createGrid(input: GridInput): GridElement;
|
|
602
634
|
declare function createText(input: TextInput): TextElement;
|
|
603
635
|
|
|
604
|
-
interface Rect {
|
|
605
|
-
x: number;
|
|
606
|
-
y: number;
|
|
607
|
-
w: number;
|
|
608
|
-
h: number;
|
|
609
|
-
}
|
|
610
636
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
611
637
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
612
638
|
declare function getBendFromPoint(from: Point, to: Point, dragPoint: Point): number;
|
|
613
639
|
declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: number): number;
|
|
614
640
|
declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
|
|
615
|
-
declare function getArrowBounds(from: Point, to: Point, bend: number):
|
|
641
|
+
declare function getArrowBounds(from: Point, to: Point, bend: number): Bounds;
|
|
616
642
|
|
|
617
643
|
declare function isBindable(element: CanvasElement): boolean;
|
|
618
644
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
619
|
-
declare function
|
|
620
|
-
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
645
|
+
declare function getEdgeIntersection(bounds: Bounds, outsidePoint: Point): Point;
|
|
621
646
|
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
622
647
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
623
648
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
624
649
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
625
650
|
declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
|
|
626
651
|
|
|
652
|
+
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
653
|
+
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
654
|
+
|
|
627
655
|
declare class AddElementCommand implements Command {
|
|
628
656
|
private readonly element;
|
|
629
657
|
constructor(element: CanvasElement);
|
|
@@ -666,6 +694,8 @@ interface PencilToolOptions {
|
|
|
666
694
|
color?: string;
|
|
667
695
|
width?: number;
|
|
668
696
|
smoothing?: number;
|
|
697
|
+
minPointDistance?: number;
|
|
698
|
+
progressiveSimplifyThreshold?: number;
|
|
669
699
|
}
|
|
670
700
|
declare class PencilTool implements Tool {
|
|
671
701
|
readonly name = "pencil";
|
|
@@ -674,6 +704,9 @@ declare class PencilTool implements Tool {
|
|
|
674
704
|
private color;
|
|
675
705
|
private width;
|
|
676
706
|
private smoothing;
|
|
707
|
+
private minPointDistance;
|
|
708
|
+
private progressiveThreshold;
|
|
709
|
+
private nextSimplifyAt;
|
|
677
710
|
private optionListeners;
|
|
678
711
|
constructor(options?: PencilToolOptions);
|
|
679
712
|
onActivate(ctx: ToolContext): void;
|
|
@@ -734,7 +767,6 @@ declare class SelectTool implements Tool {
|
|
|
734
767
|
private getMarqueeRect;
|
|
735
768
|
private findElementsInRect;
|
|
736
769
|
private rectsOverlap;
|
|
737
|
-
private getElementBounds;
|
|
738
770
|
private hitTest;
|
|
739
771
|
private isInsideBounds;
|
|
740
772
|
}
|
|
@@ -882,6 +914,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
882
914
|
undo(_store: ElementStore): void;
|
|
883
915
|
}
|
|
884
916
|
|
|
885
|
-
declare const VERSION = "0.8.
|
|
917
|
+
declare const VERSION = "0.8.7";
|
|
886
918
|
|
|
887
|
-
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 };
|