@fieldnotes/core 0.8.5 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -153,6 +153,7 @@ declare class ElementStore {
153
153
  snapshot(): CanvasElement[];
154
154
  loadSnapshot(elements: CanvasElement[]): void;
155
155
  on<K extends keyof ElementStoreEvents>(event: K, listener: (data: ElementStoreEvents[K]) => void): () => void;
156
+ onChange(listener: () => void): () => void;
156
157
  }
157
158
 
158
159
  interface CameraOptions {
@@ -198,6 +199,7 @@ declare class LayerManager {
198
199
  reorderLayer(id: string, newOrder: number): void;
199
200
  setLayerVisible(id: string, visible: boolean): boolean;
200
201
  setLayerLocked(id: string, locked: boolean): boolean;
202
+ setLayerOpacity(id: string, opacity: number): void;
201
203
  setActiveLayer(id: string): void;
202
204
  moveElementToLayer(elementId: string, layerId: string): void;
203
205
  snapshot(): Layer[];
@@ -281,6 +283,9 @@ interface Tool {
281
283
  onActivate?(ctx: ToolContext): void;
282
284
  onDeactivate?(ctx: ToolContext): void;
283
285
  renderOverlay?(ctx: CanvasRenderingContext2D): void;
286
+ getOptions?(): object;
287
+ setOptions?(options: object): void;
288
+ onOptionsChange?(listener: () => void): () => void;
284
289
  }
285
290
  type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
286
291
 
@@ -424,13 +429,11 @@ declare class Viewport {
424
429
  private readonly historyRecorder;
425
430
  readonly toolContext: ToolContext;
426
431
  private resizeObserver;
427
- private animFrameId;
428
432
  private _snapToGrid;
429
433
  private readonly _gridSize;
430
- private needsRender;
431
- private domNodes;
432
- private htmlContent;
433
- private interactingElementId;
434
+ private readonly renderLoop;
435
+ private readonly domNodeManager;
436
+ private readonly interactMode;
434
437
  constructor(container: HTMLElement, options?: ViewportOptions);
435
438
  get ctx(): CanvasRenderingContext2D | null;
436
439
  get snapToGrid(): boolean;
@@ -468,26 +471,14 @@ declare class Viewport {
468
471
  updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
469
472
  removeGrid(): void;
470
473
  destroy(): void;
471
- private startRenderLoop;
472
- private render;
473
474
  private startEditingElement;
474
475
  private onTextEditStop;
475
476
  private onDblClick;
476
477
  private hitTestWorld;
477
- private startInteracting;
478
478
  stopInteracting(): void;
479
- private onInteractNodePointerDown;
480
- private onInteractKeyDown;
481
- private onInteractPointerDown;
482
479
  private onDragOver;
483
480
  private onDrop;
484
- private syncDomNode;
485
- private renderDomContent;
486
481
  private unbindArrowsFrom;
487
- private hideDomNode;
488
- private removeDomNode;
489
- private clearDomNodes;
490
- private reattachHtmlContent;
491
482
  private createWrapper;
492
483
  private createCanvas;
493
484
  private createDomLayer;
@@ -683,13 +674,17 @@ declare class PencilTool implements Tool {
683
674
  private color;
684
675
  private width;
685
676
  private smoothing;
677
+ private optionListeners;
686
678
  constructor(options?: PencilToolOptions);
687
679
  onActivate(ctx: ToolContext): void;
688
680
  onDeactivate(ctx: ToolContext): void;
681
+ getOptions(): PencilToolOptions;
682
+ onOptionsChange(listener: () => void): () => void;
689
683
  setOptions(options: PencilToolOptions): void;
690
684
  onPointerDown(state: PointerState, ctx: ToolContext): void;
691
685
  onPointerMove(state: PointerState, ctx: ToolContext): void;
692
686
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
687
+ private notifyOptionsChange;
693
688
  renderOverlay(ctx: CanvasRenderingContext2D): void;
694
689
  }
695
690
 
@@ -702,6 +697,7 @@ declare class EraserTool implements Tool {
702
697
  private readonly radius;
703
698
  private readonly cursor;
704
699
  constructor(options?: EraserToolOptions);
700
+ getOptions(): EraserToolOptions;
705
701
  onActivate(ctx: ToolContext): void;
706
702
  onDeactivate(ctx: ToolContext): void;
707
703
  onPointerDown(state: PointerState, ctx: ToolContext): void;
@@ -757,8 +753,12 @@ declare class ArrowTool implements Tool {
757
753
  private fromBinding;
758
754
  private fromTarget;
759
755
  private toTarget;
756
+ private optionListeners;
760
757
  constructor(options?: ArrowToolOptions);
758
+ getOptions(): ArrowToolOptions;
759
+ onOptionsChange(listener: () => void): () => void;
761
760
  setOptions(options: ArrowToolOptions): void;
761
+ private notifyOptionsChange;
762
762
  private layerFilter;
763
763
  onPointerDown(state: PointerState, ctx: ToolContext): void;
764
764
  onPointerMove(state: PointerState, ctx: ToolContext): void;
@@ -776,8 +776,12 @@ declare class NoteTool implements Tool {
776
776
  private backgroundColor;
777
777
  private textColor;
778
778
  private size;
779
+ private optionListeners;
779
780
  constructor(options?: NoteToolOptions);
781
+ getOptions(): NoteToolOptions;
782
+ onOptionsChange(listener: () => void): () => void;
780
783
  setOptions(options: NoteToolOptions): void;
784
+ private notifyOptionsChange;
781
785
  onPointerDown(_state: PointerState, _ctx: ToolContext): void;
782
786
  onPointerMove(_state: PointerState, _ctx: ToolContext): void;
783
787
  onPointerUp(state: PointerState, ctx: ToolContext): void;
@@ -793,8 +797,12 @@ declare class TextTool implements Tool {
793
797
  private fontSize;
794
798
  private color;
795
799
  private textAlign;
800
+ private optionListeners;
796
801
  constructor(options?: TextToolOptions);
802
+ getOptions(): TextToolOptions;
803
+ onOptionsChange(listener: () => void): () => void;
797
804
  setOptions(options: TextToolOptions): void;
805
+ private notifyOptionsChange;
798
806
  onActivate(ctx: ToolContext): void;
799
807
  onDeactivate(ctx: ToolContext): void;
800
808
  onPointerDown(_state: PointerState, _ctx: ToolContext): void;
@@ -832,7 +840,10 @@ declare class ShapeTool implements Tool {
832
840
  private strokeColor;
833
841
  private strokeWidth;
834
842
  private fillColor;
843
+ private optionListeners;
835
844
  constructor(options?: ShapeToolOptions);
845
+ getOptions(): ShapeToolOptions;
846
+ onOptionsChange(listener: () => void): () => void;
836
847
  setOptions(options: ShapeToolOptions): void;
837
848
  onActivate(_ctx: ToolContext): void;
838
849
  onDeactivate(_ctx: ToolContext): void;
@@ -841,6 +852,7 @@ declare class ShapeTool implements Tool {
841
852
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
842
853
  renderOverlay(ctx: CanvasRenderingContext2D): void;
843
854
  private computeRect;
855
+ private notifyOptionsChange;
844
856
  private snap;
845
857
  private onKeyDown;
846
858
  private onKeyUp;
@@ -870,6 +882,6 @@ declare class UpdateLayerCommand implements Command {
870
882
  undo(_store: ElementStore): void;
871
883
  }
872
884
 
873
- declare const VERSION = "0.8.5";
885
+ declare const VERSION = "0.8.6";
874
886
 
875
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 };
package/dist/index.d.ts CHANGED
@@ -153,6 +153,7 @@ declare class ElementStore {
153
153
  snapshot(): CanvasElement[];
154
154
  loadSnapshot(elements: CanvasElement[]): void;
155
155
  on<K extends keyof ElementStoreEvents>(event: K, listener: (data: ElementStoreEvents[K]) => void): () => void;
156
+ onChange(listener: () => void): () => void;
156
157
  }
157
158
 
158
159
  interface CameraOptions {
@@ -198,6 +199,7 @@ declare class LayerManager {
198
199
  reorderLayer(id: string, newOrder: number): void;
199
200
  setLayerVisible(id: string, visible: boolean): boolean;
200
201
  setLayerLocked(id: string, locked: boolean): boolean;
202
+ setLayerOpacity(id: string, opacity: number): void;
201
203
  setActiveLayer(id: string): void;
202
204
  moveElementToLayer(elementId: string, layerId: string): void;
203
205
  snapshot(): Layer[];
@@ -281,6 +283,9 @@ interface Tool {
281
283
  onActivate?(ctx: ToolContext): void;
282
284
  onDeactivate?(ctx: ToolContext): void;
283
285
  renderOverlay?(ctx: CanvasRenderingContext2D): void;
286
+ getOptions?(): object;
287
+ setOptions?(options: object): void;
288
+ onOptionsChange?(listener: () => void): () => void;
284
289
  }
285
290
  type ToolName = 'hand' | 'select' | 'pencil' | 'eraser' | 'arrow' | 'note' | 'image' | 'text' | 'shape';
286
291
 
@@ -424,13 +429,11 @@ declare class Viewport {
424
429
  private readonly historyRecorder;
425
430
  readonly toolContext: ToolContext;
426
431
  private resizeObserver;
427
- private animFrameId;
428
432
  private _snapToGrid;
429
433
  private readonly _gridSize;
430
- private needsRender;
431
- private domNodes;
432
- private htmlContent;
433
- private interactingElementId;
434
+ private readonly renderLoop;
435
+ private readonly domNodeManager;
436
+ private readonly interactMode;
434
437
  constructor(container: HTMLElement, options?: ViewportOptions);
435
438
  get ctx(): CanvasRenderingContext2D | null;
436
439
  get snapToGrid(): boolean;
@@ -468,26 +471,14 @@ declare class Viewport {
468
471
  updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
469
472
  removeGrid(): void;
470
473
  destroy(): void;
471
- private startRenderLoop;
472
- private render;
473
474
  private startEditingElement;
474
475
  private onTextEditStop;
475
476
  private onDblClick;
476
477
  private hitTestWorld;
477
- private startInteracting;
478
478
  stopInteracting(): void;
479
- private onInteractNodePointerDown;
480
- private onInteractKeyDown;
481
- private onInteractPointerDown;
482
479
  private onDragOver;
483
480
  private onDrop;
484
- private syncDomNode;
485
- private renderDomContent;
486
481
  private unbindArrowsFrom;
487
- private hideDomNode;
488
- private removeDomNode;
489
- private clearDomNodes;
490
- private reattachHtmlContent;
491
482
  private createWrapper;
492
483
  private createCanvas;
493
484
  private createDomLayer;
@@ -683,13 +674,17 @@ declare class PencilTool implements Tool {
683
674
  private color;
684
675
  private width;
685
676
  private smoothing;
677
+ private optionListeners;
686
678
  constructor(options?: PencilToolOptions);
687
679
  onActivate(ctx: ToolContext): void;
688
680
  onDeactivate(ctx: ToolContext): void;
681
+ getOptions(): PencilToolOptions;
682
+ onOptionsChange(listener: () => void): () => void;
689
683
  setOptions(options: PencilToolOptions): void;
690
684
  onPointerDown(state: PointerState, ctx: ToolContext): void;
691
685
  onPointerMove(state: PointerState, ctx: ToolContext): void;
692
686
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
687
+ private notifyOptionsChange;
693
688
  renderOverlay(ctx: CanvasRenderingContext2D): void;
694
689
  }
695
690
 
@@ -702,6 +697,7 @@ declare class EraserTool implements Tool {
702
697
  private readonly radius;
703
698
  private readonly cursor;
704
699
  constructor(options?: EraserToolOptions);
700
+ getOptions(): EraserToolOptions;
705
701
  onActivate(ctx: ToolContext): void;
706
702
  onDeactivate(ctx: ToolContext): void;
707
703
  onPointerDown(state: PointerState, ctx: ToolContext): void;
@@ -757,8 +753,12 @@ declare class ArrowTool implements Tool {
757
753
  private fromBinding;
758
754
  private fromTarget;
759
755
  private toTarget;
756
+ private optionListeners;
760
757
  constructor(options?: ArrowToolOptions);
758
+ getOptions(): ArrowToolOptions;
759
+ onOptionsChange(listener: () => void): () => void;
761
760
  setOptions(options: ArrowToolOptions): void;
761
+ private notifyOptionsChange;
762
762
  private layerFilter;
763
763
  onPointerDown(state: PointerState, ctx: ToolContext): void;
764
764
  onPointerMove(state: PointerState, ctx: ToolContext): void;
@@ -776,8 +776,12 @@ declare class NoteTool implements Tool {
776
776
  private backgroundColor;
777
777
  private textColor;
778
778
  private size;
779
+ private optionListeners;
779
780
  constructor(options?: NoteToolOptions);
781
+ getOptions(): NoteToolOptions;
782
+ onOptionsChange(listener: () => void): () => void;
780
783
  setOptions(options: NoteToolOptions): void;
784
+ private notifyOptionsChange;
781
785
  onPointerDown(_state: PointerState, _ctx: ToolContext): void;
782
786
  onPointerMove(_state: PointerState, _ctx: ToolContext): void;
783
787
  onPointerUp(state: PointerState, ctx: ToolContext): void;
@@ -793,8 +797,12 @@ declare class TextTool implements Tool {
793
797
  private fontSize;
794
798
  private color;
795
799
  private textAlign;
800
+ private optionListeners;
796
801
  constructor(options?: TextToolOptions);
802
+ getOptions(): TextToolOptions;
803
+ onOptionsChange(listener: () => void): () => void;
797
804
  setOptions(options: TextToolOptions): void;
805
+ private notifyOptionsChange;
798
806
  onActivate(ctx: ToolContext): void;
799
807
  onDeactivate(ctx: ToolContext): void;
800
808
  onPointerDown(_state: PointerState, _ctx: ToolContext): void;
@@ -832,7 +840,10 @@ declare class ShapeTool implements Tool {
832
840
  private strokeColor;
833
841
  private strokeWidth;
834
842
  private fillColor;
843
+ private optionListeners;
835
844
  constructor(options?: ShapeToolOptions);
845
+ getOptions(): ShapeToolOptions;
846
+ onOptionsChange(listener: () => void): () => void;
836
847
  setOptions(options: ShapeToolOptions): void;
837
848
  onActivate(_ctx: ToolContext): void;
838
849
  onDeactivate(_ctx: ToolContext): void;
@@ -841,6 +852,7 @@ declare class ShapeTool implements Tool {
841
852
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
842
853
  renderOverlay(ctx: CanvasRenderingContext2D): void;
843
854
  private computeRect;
855
+ private notifyOptionsChange;
844
856
  private snap;
845
857
  private onKeyDown;
846
858
  private onKeyUp;
@@ -870,6 +882,6 @@ declare class UpdateLayerCommand implements Command {
870
882
  undo(_store: ElementStore): void;
871
883
  }
872
884
 
873
- declare const VERSION = "0.8.5";
885
+ declare const VERSION = "0.8.6";
874
886
 
875
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 };