@fieldnotes/core 0.8.11 → 0.9.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/README.md +63 -9
- package/dist/index.cjs +973 -13
- package/dist/index.d.cts +183 -65
- package/dist/index.d.ts +183 -65
- package/dist/index.js +962 -13
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -112,7 +112,20 @@ interface GridElement extends BaseElement {
|
|
|
112
112
|
strokeWidth: number;
|
|
113
113
|
opacity: number;
|
|
114
114
|
}
|
|
115
|
-
type
|
|
115
|
+
type TemplateShape = 'circle' | 'cone' | 'line' | 'square';
|
|
116
|
+
interface TemplateElement extends BaseElement {
|
|
117
|
+
type: 'template';
|
|
118
|
+
templateShape: TemplateShape;
|
|
119
|
+
radius: number;
|
|
120
|
+
angle: number;
|
|
121
|
+
fillColor: string;
|
|
122
|
+
strokeColor: string;
|
|
123
|
+
strokeWidth: number;
|
|
124
|
+
opacity: number;
|
|
125
|
+
feetPerCell?: number;
|
|
126
|
+
radiusFeet?: number;
|
|
127
|
+
}
|
|
128
|
+
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement | GridElement | TemplateElement;
|
|
116
129
|
type ElementType = CanvasElement['type'];
|
|
117
130
|
|
|
118
131
|
interface Layer {
|
|
@@ -139,7 +152,37 @@ declare function exportState(elements: CanvasElement[], camera: {
|
|
|
139
152
|
}, layers?: Layer[]): CanvasState;
|
|
140
153
|
declare function parseState(json: string): CanvasState;
|
|
141
154
|
|
|
142
|
-
|
|
155
|
+
interface CameraOptions {
|
|
156
|
+
minZoom?: number;
|
|
157
|
+
maxZoom?: number;
|
|
158
|
+
}
|
|
159
|
+
interface CameraChangeInfo {
|
|
160
|
+
panned: boolean;
|
|
161
|
+
zoomed: boolean;
|
|
162
|
+
}
|
|
163
|
+
declare class Camera {
|
|
164
|
+
private x;
|
|
165
|
+
private y;
|
|
166
|
+
private z;
|
|
167
|
+
private readonly minZoom;
|
|
168
|
+
private readonly maxZoom;
|
|
169
|
+
private changeListeners;
|
|
170
|
+
constructor(options?: CameraOptions);
|
|
171
|
+
get position(): Point;
|
|
172
|
+
get zoom(): number;
|
|
173
|
+
pan(dx: number, dy: number): void;
|
|
174
|
+
moveTo(x: number, y: number): void;
|
|
175
|
+
setZoom(level: number): void;
|
|
176
|
+
zoomAt(level: number, screenPoint: Point): void;
|
|
177
|
+
screenToWorld(screen: Point): Point;
|
|
178
|
+
worldToScreen(world: Point): Point;
|
|
179
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
180
|
+
toCSSTransform(): string;
|
|
181
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
182
|
+
private notifyPan;
|
|
183
|
+
private notifyZoom;
|
|
184
|
+
private notifyPanAndZoom;
|
|
185
|
+
}
|
|
143
186
|
|
|
144
187
|
interface ElementUpdateEvent {
|
|
145
188
|
previous: CanvasElement;
|
|
@@ -175,37 +218,44 @@ declare class ElementStore {
|
|
|
175
218
|
onChange(listener: () => void): () => void;
|
|
176
219
|
}
|
|
177
220
|
|
|
178
|
-
interface
|
|
179
|
-
|
|
180
|
-
|
|
221
|
+
interface ToolContext {
|
|
222
|
+
camera: Camera;
|
|
223
|
+
store: ElementStore;
|
|
224
|
+
requestRender: () => void;
|
|
225
|
+
switchTool?: (name: string) => void;
|
|
226
|
+
editElement?: (id: string) => void;
|
|
227
|
+
setCursor?: (cursor: string) => void;
|
|
228
|
+
snapToGrid?: boolean;
|
|
229
|
+
gridSize?: number;
|
|
230
|
+
gridType?: 'square' | 'hex';
|
|
231
|
+
hexOrientation?: HexOrientation;
|
|
232
|
+
activeLayerId?: string;
|
|
233
|
+
isLayerVisible?: (layerId: string) => boolean;
|
|
234
|
+
isLayerLocked?: (layerId: string) => boolean;
|
|
181
235
|
}
|
|
182
|
-
interface
|
|
183
|
-
|
|
184
|
-
|
|
236
|
+
interface PointerState {
|
|
237
|
+
x: number;
|
|
238
|
+
y: number;
|
|
239
|
+
pressure: number;
|
|
185
240
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
setZoom(level: number): void;
|
|
199
|
-
zoomAt(level: number, screenPoint: Point): void;
|
|
200
|
-
screenToWorld(screen: Point): Point;
|
|
201
|
-
worldToScreen(world: Point): Point;
|
|
202
|
-
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
203
|
-
toCSSTransform(): string;
|
|
204
|
-
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
205
|
-
private notifyPan;
|
|
206
|
-
private notifyZoom;
|
|
207
|
-
private notifyPanAndZoom;
|
|
241
|
+
interface Tool {
|
|
242
|
+
readonly name: string;
|
|
243
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
244
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
245
|
+
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
246
|
+
onHover?(state: PointerState, ctx: ToolContext): void;
|
|
247
|
+
onActivate?(ctx: ToolContext): void;
|
|
248
|
+
onDeactivate?(ctx: ToolContext): void;
|
|
249
|
+
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
250
|
+
getOptions?(): object;
|
|
251
|
+
setOptions?(options: object): void;
|
|
252
|
+
onOptionsChange?(listener: () => void): () => void;
|
|
208
253
|
}
|
|
254
|
+
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape' | 'measure' | 'template';
|
|
255
|
+
|
|
256
|
+
declare function snapPoint(point: Point, gridSize: number): Point;
|
|
257
|
+
declare function snapToHexCenter(point: Point, cellSize: number, orientation: HexOrientation): Point;
|
|
258
|
+
declare function smartSnap(point: Point, ctx: ToolContext): Point;
|
|
209
259
|
|
|
210
260
|
declare class LayerManager {
|
|
211
261
|
private readonly store;
|
|
@@ -290,39 +340,6 @@ declare class Background {
|
|
|
290
340
|
private renderGrid;
|
|
291
341
|
}
|
|
292
342
|
|
|
293
|
-
interface ToolContext {
|
|
294
|
-
camera: Camera;
|
|
295
|
-
store: ElementStore;
|
|
296
|
-
requestRender: () => void;
|
|
297
|
-
switchTool?: (name: string) => void;
|
|
298
|
-
editElement?: (id: string) => void;
|
|
299
|
-
setCursor?: (cursor: string) => void;
|
|
300
|
-
snapToGrid?: boolean;
|
|
301
|
-
gridSize?: number;
|
|
302
|
-
activeLayerId?: string;
|
|
303
|
-
isLayerVisible?: (layerId: string) => boolean;
|
|
304
|
-
isLayerLocked?: (layerId: string) => boolean;
|
|
305
|
-
}
|
|
306
|
-
interface PointerState {
|
|
307
|
-
x: number;
|
|
308
|
-
y: number;
|
|
309
|
-
pressure: number;
|
|
310
|
-
}
|
|
311
|
-
interface Tool {
|
|
312
|
-
readonly name: string;
|
|
313
|
-
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
314
|
-
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
315
|
-
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
316
|
-
onHover?(state: PointerState, ctx: ToolContext): void;
|
|
317
|
-
onActivate?(ctx: ToolContext): void;
|
|
318
|
-
onDeactivate?(ctx: ToolContext): void;
|
|
319
|
-
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
320
|
-
getOptions?(): object;
|
|
321
|
-
setOptions?(options: object): void;
|
|
322
|
-
onOptionsChange?(listener: () => void): () => void;
|
|
323
|
-
}
|
|
324
|
-
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
|
|
325
|
-
|
|
326
343
|
declare class ToolManager {
|
|
327
344
|
private tools;
|
|
328
345
|
private current;
|
|
@@ -529,6 +546,7 @@ declare class Viewport {
|
|
|
529
546
|
private createDomLayer;
|
|
530
547
|
private applyCameraTransform;
|
|
531
548
|
private syncCanvasSize;
|
|
549
|
+
private syncGridContext;
|
|
532
550
|
private observeResize;
|
|
533
551
|
}
|
|
534
552
|
|
|
@@ -554,6 +572,10 @@ declare class ElementRenderer {
|
|
|
554
572
|
private fillShapePath;
|
|
555
573
|
private strokeShapePath;
|
|
556
574
|
private renderGrid;
|
|
575
|
+
private renderTemplate;
|
|
576
|
+
private renderGeometricTemplate;
|
|
577
|
+
private renderHexTemplate;
|
|
578
|
+
private renderRadiusMarker;
|
|
557
579
|
private renderImage;
|
|
558
580
|
private getHexTile;
|
|
559
581
|
private getImage;
|
|
@@ -648,6 +670,19 @@ interface GridInput extends BaseDefaults {
|
|
|
648
670
|
}
|
|
649
671
|
declare function createGrid(input: GridInput): GridElement;
|
|
650
672
|
declare function createText(input: TextInput): TextElement;
|
|
673
|
+
interface TemplateInput extends BaseDefaults {
|
|
674
|
+
position: Point;
|
|
675
|
+
templateShape: TemplateShape;
|
|
676
|
+
radius: number;
|
|
677
|
+
angle?: number;
|
|
678
|
+
fillColor?: string;
|
|
679
|
+
strokeColor?: string;
|
|
680
|
+
strokeWidth?: number;
|
|
681
|
+
opacity?: number;
|
|
682
|
+
feetPerCell?: number;
|
|
683
|
+
radiusFeet?: number;
|
|
684
|
+
}
|
|
685
|
+
declare function createTemplate(input: TemplateInput): TemplateElement;
|
|
651
686
|
|
|
652
687
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
653
688
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
@@ -668,6 +703,13 @@ declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<
|
|
|
668
703
|
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
669
704
|
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
670
705
|
|
|
706
|
+
declare function getHexDistance(a: Point, b: Point, cellSize: number, orientation: HexOrientation): number;
|
|
707
|
+
declare function getHexCellsInRadius(center: Point, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
708
|
+
declare function getHexCellsInCone(center: Point, angle: number, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
709
|
+
declare function getHexCellsInLine(center: Point, angle: number, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
710
|
+
declare function getHexCellsInSquare(center: Point, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
711
|
+
declare function drawHexPath(ctx: CanvasRenderingContext2D, cx: number, cy: number, cellSize: number, orientation: HexOrientation): void;
|
|
712
|
+
|
|
671
713
|
declare class AddElementCommand implements Command {
|
|
672
714
|
private readonly element;
|
|
673
715
|
constructor(element: CanvasElement);
|
|
@@ -780,6 +822,8 @@ declare class SelectTool implements Tool {
|
|
|
780
822
|
private renderMarquee;
|
|
781
823
|
private renderSelectionBoxes;
|
|
782
824
|
private renderBindingHighlights;
|
|
825
|
+
private hitTestTemplateResizeHandle;
|
|
826
|
+
private handleTemplateResize;
|
|
783
827
|
private getMarqueeRect;
|
|
784
828
|
private findElementsInRect;
|
|
785
829
|
private rectsOverlap;
|
|
@@ -906,6 +950,80 @@ declare class ShapeTool implements Tool {
|
|
|
906
950
|
private onKeyUp;
|
|
907
951
|
}
|
|
908
952
|
|
|
953
|
+
interface MeasureToolOptions {
|
|
954
|
+
feetPerCell?: number;
|
|
955
|
+
}
|
|
956
|
+
interface Measurement {
|
|
957
|
+
start: Point;
|
|
958
|
+
end: Point;
|
|
959
|
+
worldDistance: number;
|
|
960
|
+
cells: number;
|
|
961
|
+
feet: number;
|
|
962
|
+
}
|
|
963
|
+
declare class MeasureTool implements Tool {
|
|
964
|
+
readonly name = "measure";
|
|
965
|
+
private start;
|
|
966
|
+
private end;
|
|
967
|
+
private gridSize;
|
|
968
|
+
private gridType;
|
|
969
|
+
private hexOrientation;
|
|
970
|
+
private feetPerCell;
|
|
971
|
+
private optionListeners;
|
|
972
|
+
constructor(options?: MeasureToolOptions);
|
|
973
|
+
getOptions(): MeasureToolOptions;
|
|
974
|
+
setOptions(options: MeasureToolOptions): void;
|
|
975
|
+
onOptionsChange(listener: () => void): () => void;
|
|
976
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
977
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
978
|
+
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
979
|
+
onDeactivate(_ctx: ToolContext): void;
|
|
980
|
+
getMeasurement(): Measurement | null;
|
|
981
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
982
|
+
private snapToGrid;
|
|
983
|
+
private notifyOptionsChange;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
interface TemplateToolOptions {
|
|
987
|
+
templateShape?: TemplateShape;
|
|
988
|
+
fillColor?: string;
|
|
989
|
+
strokeColor?: string;
|
|
990
|
+
strokeWidth?: number;
|
|
991
|
+
opacity?: number;
|
|
992
|
+
feetPerCell?: number;
|
|
993
|
+
}
|
|
994
|
+
declare class TemplateTool implements Tool {
|
|
995
|
+
readonly name = "template";
|
|
996
|
+
private drawing;
|
|
997
|
+
private origin;
|
|
998
|
+
private current;
|
|
999
|
+
private gridSize;
|
|
1000
|
+
private gridType;
|
|
1001
|
+
private hexOrientation;
|
|
1002
|
+
private snapEnabled;
|
|
1003
|
+
private templateShape;
|
|
1004
|
+
private fillColor;
|
|
1005
|
+
private strokeColor;
|
|
1006
|
+
private strokeWidth;
|
|
1007
|
+
private opacity;
|
|
1008
|
+
private feetPerCell;
|
|
1009
|
+
private optionListeners;
|
|
1010
|
+
constructor(options?: TemplateToolOptions);
|
|
1011
|
+
getOptions(): TemplateToolOptions;
|
|
1012
|
+
setOptions(options: TemplateToolOptions): void;
|
|
1013
|
+
onOptionsChange(listener: () => void): () => void;
|
|
1014
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
1015
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
1016
|
+
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
1017
|
+
onDeactivate(_ctx: ToolContext): void;
|
|
1018
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
1019
|
+
private renderGeometricOverlay;
|
|
1020
|
+
private renderHexOverlay;
|
|
1021
|
+
private computeRadius;
|
|
1022
|
+
private computeAngle;
|
|
1023
|
+
private snapToGrid;
|
|
1024
|
+
private notifyOptionsChange;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
909
1027
|
declare class CreateLayerCommand implements Command {
|
|
910
1028
|
private readonly manager;
|
|
911
1029
|
private readonly layer;
|
|
@@ -930,6 +1048,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
930
1048
|
undo(_store: ElementStore): void;
|
|
931
1049
|
}
|
|
932
1050
|
|
|
933
|
-
declare const VERSION = "0.
|
|
1051
|
+
declare const VERSION = "0.9.0";
|
|
934
1052
|
|
|
935
|
-
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 };
|
|
1053
|
+
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, MeasureTool, type MeasureToolOptions, type Measurement, 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 TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, 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, createTemplate, createText, drawHexPath, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, smartSnap, snapPoint, snapToHexCenter, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -112,7 +112,20 @@ interface GridElement extends BaseElement {
|
|
|
112
112
|
strokeWidth: number;
|
|
113
113
|
opacity: number;
|
|
114
114
|
}
|
|
115
|
-
type
|
|
115
|
+
type TemplateShape = 'circle' | 'cone' | 'line' | 'square';
|
|
116
|
+
interface TemplateElement extends BaseElement {
|
|
117
|
+
type: 'template';
|
|
118
|
+
templateShape: TemplateShape;
|
|
119
|
+
radius: number;
|
|
120
|
+
angle: number;
|
|
121
|
+
fillColor: string;
|
|
122
|
+
strokeColor: string;
|
|
123
|
+
strokeWidth: number;
|
|
124
|
+
opacity: number;
|
|
125
|
+
feetPerCell?: number;
|
|
126
|
+
radiusFeet?: number;
|
|
127
|
+
}
|
|
128
|
+
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement | GridElement | TemplateElement;
|
|
116
129
|
type ElementType = CanvasElement['type'];
|
|
117
130
|
|
|
118
131
|
interface Layer {
|
|
@@ -139,7 +152,37 @@ declare function exportState(elements: CanvasElement[], camera: {
|
|
|
139
152
|
}, layers?: Layer[]): CanvasState;
|
|
140
153
|
declare function parseState(json: string): CanvasState;
|
|
141
154
|
|
|
142
|
-
|
|
155
|
+
interface CameraOptions {
|
|
156
|
+
minZoom?: number;
|
|
157
|
+
maxZoom?: number;
|
|
158
|
+
}
|
|
159
|
+
interface CameraChangeInfo {
|
|
160
|
+
panned: boolean;
|
|
161
|
+
zoomed: boolean;
|
|
162
|
+
}
|
|
163
|
+
declare class Camera {
|
|
164
|
+
private x;
|
|
165
|
+
private y;
|
|
166
|
+
private z;
|
|
167
|
+
private readonly minZoom;
|
|
168
|
+
private readonly maxZoom;
|
|
169
|
+
private changeListeners;
|
|
170
|
+
constructor(options?: CameraOptions);
|
|
171
|
+
get position(): Point;
|
|
172
|
+
get zoom(): number;
|
|
173
|
+
pan(dx: number, dy: number): void;
|
|
174
|
+
moveTo(x: number, y: number): void;
|
|
175
|
+
setZoom(level: number): void;
|
|
176
|
+
zoomAt(level: number, screenPoint: Point): void;
|
|
177
|
+
screenToWorld(screen: Point): Point;
|
|
178
|
+
worldToScreen(world: Point): Point;
|
|
179
|
+
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
180
|
+
toCSSTransform(): string;
|
|
181
|
+
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
182
|
+
private notifyPan;
|
|
183
|
+
private notifyZoom;
|
|
184
|
+
private notifyPanAndZoom;
|
|
185
|
+
}
|
|
143
186
|
|
|
144
187
|
interface ElementUpdateEvent {
|
|
145
188
|
previous: CanvasElement;
|
|
@@ -175,37 +218,44 @@ declare class ElementStore {
|
|
|
175
218
|
onChange(listener: () => void): () => void;
|
|
176
219
|
}
|
|
177
220
|
|
|
178
|
-
interface
|
|
179
|
-
|
|
180
|
-
|
|
221
|
+
interface ToolContext {
|
|
222
|
+
camera: Camera;
|
|
223
|
+
store: ElementStore;
|
|
224
|
+
requestRender: () => void;
|
|
225
|
+
switchTool?: (name: string) => void;
|
|
226
|
+
editElement?: (id: string) => void;
|
|
227
|
+
setCursor?: (cursor: string) => void;
|
|
228
|
+
snapToGrid?: boolean;
|
|
229
|
+
gridSize?: number;
|
|
230
|
+
gridType?: 'square' | 'hex';
|
|
231
|
+
hexOrientation?: HexOrientation;
|
|
232
|
+
activeLayerId?: string;
|
|
233
|
+
isLayerVisible?: (layerId: string) => boolean;
|
|
234
|
+
isLayerLocked?: (layerId: string) => boolean;
|
|
181
235
|
}
|
|
182
|
-
interface
|
|
183
|
-
|
|
184
|
-
|
|
236
|
+
interface PointerState {
|
|
237
|
+
x: number;
|
|
238
|
+
y: number;
|
|
239
|
+
pressure: number;
|
|
185
240
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
setZoom(level: number): void;
|
|
199
|
-
zoomAt(level: number, screenPoint: Point): void;
|
|
200
|
-
screenToWorld(screen: Point): Point;
|
|
201
|
-
worldToScreen(world: Point): Point;
|
|
202
|
-
getVisibleRect(canvasWidth: number, canvasHeight: number): Bounds;
|
|
203
|
-
toCSSTransform(): string;
|
|
204
|
-
onChange(listener: (info: CameraChangeInfo) => void): () => void;
|
|
205
|
-
private notifyPan;
|
|
206
|
-
private notifyZoom;
|
|
207
|
-
private notifyPanAndZoom;
|
|
241
|
+
interface Tool {
|
|
242
|
+
readonly name: string;
|
|
243
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
244
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
245
|
+
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
246
|
+
onHover?(state: PointerState, ctx: ToolContext): void;
|
|
247
|
+
onActivate?(ctx: ToolContext): void;
|
|
248
|
+
onDeactivate?(ctx: ToolContext): void;
|
|
249
|
+
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
250
|
+
getOptions?(): object;
|
|
251
|
+
setOptions?(options: object): void;
|
|
252
|
+
onOptionsChange?(listener: () => void): () => void;
|
|
208
253
|
}
|
|
254
|
+
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape' | 'measure' | 'template';
|
|
255
|
+
|
|
256
|
+
declare function snapPoint(point: Point, gridSize: number): Point;
|
|
257
|
+
declare function snapToHexCenter(point: Point, cellSize: number, orientation: HexOrientation): Point;
|
|
258
|
+
declare function smartSnap(point: Point, ctx: ToolContext): Point;
|
|
209
259
|
|
|
210
260
|
declare class LayerManager {
|
|
211
261
|
private readonly store;
|
|
@@ -290,39 +340,6 @@ declare class Background {
|
|
|
290
340
|
private renderGrid;
|
|
291
341
|
}
|
|
292
342
|
|
|
293
|
-
interface ToolContext {
|
|
294
|
-
camera: Camera;
|
|
295
|
-
store: ElementStore;
|
|
296
|
-
requestRender: () => void;
|
|
297
|
-
switchTool?: (name: string) => void;
|
|
298
|
-
editElement?: (id: string) => void;
|
|
299
|
-
setCursor?: (cursor: string) => void;
|
|
300
|
-
snapToGrid?: boolean;
|
|
301
|
-
gridSize?: number;
|
|
302
|
-
activeLayerId?: string;
|
|
303
|
-
isLayerVisible?: (layerId: string) => boolean;
|
|
304
|
-
isLayerLocked?: (layerId: string) => boolean;
|
|
305
|
-
}
|
|
306
|
-
interface PointerState {
|
|
307
|
-
x: number;
|
|
308
|
-
y: number;
|
|
309
|
-
pressure: number;
|
|
310
|
-
}
|
|
311
|
-
interface Tool {
|
|
312
|
-
readonly name: string;
|
|
313
|
-
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
314
|
-
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
315
|
-
onPointerUp(state: PointerState, ctx: ToolContext): void;
|
|
316
|
-
onHover?(state: PointerState, ctx: ToolContext): void;
|
|
317
|
-
onActivate?(ctx: ToolContext): void;
|
|
318
|
-
onDeactivate?(ctx: ToolContext): void;
|
|
319
|
-
renderOverlay?(ctx: CanvasRenderingContext2D): void;
|
|
320
|
-
getOptions?(): object;
|
|
321
|
-
setOptions?(options: object): void;
|
|
322
|
-
onOptionsChange?(listener: () => void): () => void;
|
|
323
|
-
}
|
|
324
|
-
type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
|
|
325
|
-
|
|
326
343
|
declare class ToolManager {
|
|
327
344
|
private tools;
|
|
328
345
|
private current;
|
|
@@ -529,6 +546,7 @@ declare class Viewport {
|
|
|
529
546
|
private createDomLayer;
|
|
530
547
|
private applyCameraTransform;
|
|
531
548
|
private syncCanvasSize;
|
|
549
|
+
private syncGridContext;
|
|
532
550
|
private observeResize;
|
|
533
551
|
}
|
|
534
552
|
|
|
@@ -554,6 +572,10 @@ declare class ElementRenderer {
|
|
|
554
572
|
private fillShapePath;
|
|
555
573
|
private strokeShapePath;
|
|
556
574
|
private renderGrid;
|
|
575
|
+
private renderTemplate;
|
|
576
|
+
private renderGeometricTemplate;
|
|
577
|
+
private renderHexTemplate;
|
|
578
|
+
private renderRadiusMarker;
|
|
557
579
|
private renderImage;
|
|
558
580
|
private getHexTile;
|
|
559
581
|
private getImage;
|
|
@@ -648,6 +670,19 @@ interface GridInput extends BaseDefaults {
|
|
|
648
670
|
}
|
|
649
671
|
declare function createGrid(input: GridInput): GridElement;
|
|
650
672
|
declare function createText(input: TextInput): TextElement;
|
|
673
|
+
interface TemplateInput extends BaseDefaults {
|
|
674
|
+
position: Point;
|
|
675
|
+
templateShape: TemplateShape;
|
|
676
|
+
radius: number;
|
|
677
|
+
angle?: number;
|
|
678
|
+
fillColor?: string;
|
|
679
|
+
strokeColor?: string;
|
|
680
|
+
strokeWidth?: number;
|
|
681
|
+
opacity?: number;
|
|
682
|
+
feetPerCell?: number;
|
|
683
|
+
radiusFeet?: number;
|
|
684
|
+
}
|
|
685
|
+
declare function createTemplate(input: TemplateInput): TemplateElement;
|
|
651
686
|
|
|
652
687
|
declare function getArrowControlPoint(from: Point, to: Point, bend: number): Point;
|
|
653
688
|
declare function getArrowMidpoint(from: Point, to: Point, bend: number): Point;
|
|
@@ -668,6 +703,13 @@ declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<
|
|
|
668
703
|
declare function getElementBounds(element: CanvasElement): Bounds | null;
|
|
669
704
|
declare function boundsIntersect(a: Bounds, b: Bounds): boolean;
|
|
670
705
|
|
|
706
|
+
declare function getHexDistance(a: Point, b: Point, cellSize: number, orientation: HexOrientation): number;
|
|
707
|
+
declare function getHexCellsInRadius(center: Point, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
708
|
+
declare function getHexCellsInCone(center: Point, angle: number, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
709
|
+
declare function getHexCellsInLine(center: Point, angle: number, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
710
|
+
declare function getHexCellsInSquare(center: Point, radiusCells: number, cellSize: number, orientation: HexOrientation): Point[];
|
|
711
|
+
declare function drawHexPath(ctx: CanvasRenderingContext2D, cx: number, cy: number, cellSize: number, orientation: HexOrientation): void;
|
|
712
|
+
|
|
671
713
|
declare class AddElementCommand implements Command {
|
|
672
714
|
private readonly element;
|
|
673
715
|
constructor(element: CanvasElement);
|
|
@@ -780,6 +822,8 @@ declare class SelectTool implements Tool {
|
|
|
780
822
|
private renderMarquee;
|
|
781
823
|
private renderSelectionBoxes;
|
|
782
824
|
private renderBindingHighlights;
|
|
825
|
+
private hitTestTemplateResizeHandle;
|
|
826
|
+
private handleTemplateResize;
|
|
783
827
|
private getMarqueeRect;
|
|
784
828
|
private findElementsInRect;
|
|
785
829
|
private rectsOverlap;
|
|
@@ -906,6 +950,80 @@ declare class ShapeTool implements Tool {
|
|
|
906
950
|
private onKeyUp;
|
|
907
951
|
}
|
|
908
952
|
|
|
953
|
+
interface MeasureToolOptions {
|
|
954
|
+
feetPerCell?: number;
|
|
955
|
+
}
|
|
956
|
+
interface Measurement {
|
|
957
|
+
start: Point;
|
|
958
|
+
end: Point;
|
|
959
|
+
worldDistance: number;
|
|
960
|
+
cells: number;
|
|
961
|
+
feet: number;
|
|
962
|
+
}
|
|
963
|
+
declare class MeasureTool implements Tool {
|
|
964
|
+
readonly name = "measure";
|
|
965
|
+
private start;
|
|
966
|
+
private end;
|
|
967
|
+
private gridSize;
|
|
968
|
+
private gridType;
|
|
969
|
+
private hexOrientation;
|
|
970
|
+
private feetPerCell;
|
|
971
|
+
private optionListeners;
|
|
972
|
+
constructor(options?: MeasureToolOptions);
|
|
973
|
+
getOptions(): MeasureToolOptions;
|
|
974
|
+
setOptions(options: MeasureToolOptions): void;
|
|
975
|
+
onOptionsChange(listener: () => void): () => void;
|
|
976
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
977
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
978
|
+
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
979
|
+
onDeactivate(_ctx: ToolContext): void;
|
|
980
|
+
getMeasurement(): Measurement | null;
|
|
981
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
982
|
+
private snapToGrid;
|
|
983
|
+
private notifyOptionsChange;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
interface TemplateToolOptions {
|
|
987
|
+
templateShape?: TemplateShape;
|
|
988
|
+
fillColor?: string;
|
|
989
|
+
strokeColor?: string;
|
|
990
|
+
strokeWidth?: number;
|
|
991
|
+
opacity?: number;
|
|
992
|
+
feetPerCell?: number;
|
|
993
|
+
}
|
|
994
|
+
declare class TemplateTool implements Tool {
|
|
995
|
+
readonly name = "template";
|
|
996
|
+
private drawing;
|
|
997
|
+
private origin;
|
|
998
|
+
private current;
|
|
999
|
+
private gridSize;
|
|
1000
|
+
private gridType;
|
|
1001
|
+
private hexOrientation;
|
|
1002
|
+
private snapEnabled;
|
|
1003
|
+
private templateShape;
|
|
1004
|
+
private fillColor;
|
|
1005
|
+
private strokeColor;
|
|
1006
|
+
private strokeWidth;
|
|
1007
|
+
private opacity;
|
|
1008
|
+
private feetPerCell;
|
|
1009
|
+
private optionListeners;
|
|
1010
|
+
constructor(options?: TemplateToolOptions);
|
|
1011
|
+
getOptions(): TemplateToolOptions;
|
|
1012
|
+
setOptions(options: TemplateToolOptions): void;
|
|
1013
|
+
onOptionsChange(listener: () => void): () => void;
|
|
1014
|
+
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
1015
|
+
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
1016
|
+
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
1017
|
+
onDeactivate(_ctx: ToolContext): void;
|
|
1018
|
+
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
1019
|
+
private renderGeometricOverlay;
|
|
1020
|
+
private renderHexOverlay;
|
|
1021
|
+
private computeRadius;
|
|
1022
|
+
private computeAngle;
|
|
1023
|
+
private snapToGrid;
|
|
1024
|
+
private notifyOptionsChange;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
909
1027
|
declare class CreateLayerCommand implements Command {
|
|
910
1028
|
private readonly manager;
|
|
911
1029
|
private readonly layer;
|
|
@@ -930,6 +1048,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
930
1048
|
undo(_store: ElementStore): void;
|
|
931
1049
|
}
|
|
932
1050
|
|
|
933
|
-
declare const VERSION = "0.
|
|
1051
|
+
declare const VERSION = "0.9.0";
|
|
934
1052
|
|
|
935
|
-
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 };
|
|
1053
|
+
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, MeasureTool, type MeasureToolOptions, type Measurement, 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 TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, 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, createTemplate, createText, drawHexPath, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, smartSnap, snapPoint, snapToHexCenter, unbindArrow, updateBoundArrow };
|