@fieldnotes/core 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +25 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +25 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -4288,6 +4288,7 @@ var Viewport = class {
|
|
|
4288
4288
|
renderLoop;
|
|
4289
4289
|
domNodeManager;
|
|
4290
4290
|
interactMode;
|
|
4291
|
+
gridChangeListeners = /* @__PURE__ */ new Set();
|
|
4291
4292
|
get ctx() {
|
|
4292
4293
|
return this.canvasEl.getContext("2d");
|
|
4293
4294
|
}
|
|
@@ -4392,6 +4393,22 @@ var Viewport = class {
|
|
|
4392
4393
|
this.historyRecorder.commit();
|
|
4393
4394
|
this.requestRender();
|
|
4394
4395
|
}
|
|
4396
|
+
getGridInfo() {
|
|
4397
|
+
const grid = this.store.getElementsByType("grid")[0];
|
|
4398
|
+
if (!grid) return null;
|
|
4399
|
+
return {
|
|
4400
|
+
gridType: grid.gridType,
|
|
4401
|
+
hexOrientation: grid.hexOrientation,
|
|
4402
|
+
cellSize: grid.cellSize,
|
|
4403
|
+
cellRadius: grid.gridType === "hex" ? grid.cellSize : grid.cellSize / 2
|
|
4404
|
+
};
|
|
4405
|
+
}
|
|
4406
|
+
onGridChange(listener) {
|
|
4407
|
+
this.gridChangeListeners.add(listener);
|
|
4408
|
+
return () => {
|
|
4409
|
+
this.gridChangeListeners.delete(listener);
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4395
4412
|
getRenderStats() {
|
|
4396
4413
|
return this.renderLoop.getStats();
|
|
4397
4414
|
}
|
|
@@ -4592,6 +4609,13 @@ var Viewport = class {
|
|
|
4592
4609
|
this.toolContext.gridType = void 0;
|
|
4593
4610
|
this.toolContext.hexOrientation = void 0;
|
|
4594
4611
|
}
|
|
4612
|
+
this.notifyGridChangeListeners();
|
|
4613
|
+
}
|
|
4614
|
+
notifyGridChangeListeners() {
|
|
4615
|
+
const info = this.getGridInfo();
|
|
4616
|
+
for (const listener of this.gridChangeListeners) {
|
|
4617
|
+
listener(info);
|
|
4618
|
+
}
|
|
4595
4619
|
}
|
|
4596
4620
|
observeResize() {
|
|
4597
4621
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -6283,7 +6307,7 @@ var UpdateLayerCommand = class {
|
|
|
6283
6307
|
};
|
|
6284
6308
|
|
|
6285
6309
|
// src/index.ts
|
|
6286
|
-
var VERSION = "0.
|
|
6310
|
+
var VERSION = "0.11.0";
|
|
6287
6311
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6288
6312
|
0 && (module.exports = {
|
|
6289
6313
|
AddElementCommand,
|
package/dist/index.d.cts
CHANGED
|
@@ -489,6 +489,12 @@ interface RenderStatsSnapshot {
|
|
|
489
489
|
frameCount: number;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
interface GridInfo {
|
|
493
|
+
gridType: 'square' | 'hex';
|
|
494
|
+
hexOrientation: 'pointy' | 'flat';
|
|
495
|
+
cellSize: number;
|
|
496
|
+
cellRadius: number;
|
|
497
|
+
}
|
|
492
498
|
interface ViewportOptions {
|
|
493
499
|
camera?: CameraOptions;
|
|
494
500
|
background?: BackgroundOptions;
|
|
@@ -519,6 +525,7 @@ declare class Viewport {
|
|
|
519
525
|
private readonly renderLoop;
|
|
520
526
|
private readonly domNodeManager;
|
|
521
527
|
private readonly interactMode;
|
|
528
|
+
private readonly gridChangeListeners;
|
|
522
529
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
523
530
|
get ctx(): CanvasRenderingContext2D | null;
|
|
524
531
|
get snapToGrid(): boolean;
|
|
@@ -555,6 +562,8 @@ declare class Viewport {
|
|
|
555
562
|
}): string;
|
|
556
563
|
updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
|
|
557
564
|
removeGrid(): void;
|
|
565
|
+
getGridInfo(): GridInfo | null;
|
|
566
|
+
onGridChange(listener: (info: GridInfo | null) => void): () => void;
|
|
558
567
|
getRenderStats(): RenderStatsSnapshot;
|
|
559
568
|
logPerformance(intervalMs?: number): () => void;
|
|
560
569
|
destroy(): void;
|
|
@@ -572,6 +581,7 @@ declare class Viewport {
|
|
|
572
581
|
private applyCameraTransform;
|
|
573
582
|
private syncCanvasSize;
|
|
574
583
|
private syncGridContext;
|
|
584
|
+
private notifyGridChangeListeners;
|
|
575
585
|
private observeResize;
|
|
576
586
|
}
|
|
577
587
|
|
|
@@ -1109,6 +1119,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
1109
1119
|
undo(_store: ElementStore): void;
|
|
1110
1120
|
}
|
|
1111
1121
|
|
|
1112
|
-
declare const VERSION = "0.
|
|
1122
|
+
declare const VERSION = "0.11.0";
|
|
1113
1123
|
|
|
1114
|
-
export { type ActiveFormats, 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, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, 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 NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, 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 StyledRun, 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, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|
|
1124
|
+
export { type ActiveFormats, 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, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, type GridElement, type GridInfo, 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 NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, 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 StyledRun, 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, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -489,6 +489,12 @@ interface RenderStatsSnapshot {
|
|
|
489
489
|
frameCount: number;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
interface GridInfo {
|
|
493
|
+
gridType: 'square' | 'hex';
|
|
494
|
+
hexOrientation: 'pointy' | 'flat';
|
|
495
|
+
cellSize: number;
|
|
496
|
+
cellRadius: number;
|
|
497
|
+
}
|
|
492
498
|
interface ViewportOptions {
|
|
493
499
|
camera?: CameraOptions;
|
|
494
500
|
background?: BackgroundOptions;
|
|
@@ -519,6 +525,7 @@ declare class Viewport {
|
|
|
519
525
|
private readonly renderLoop;
|
|
520
526
|
private readonly domNodeManager;
|
|
521
527
|
private readonly interactMode;
|
|
528
|
+
private readonly gridChangeListeners;
|
|
522
529
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
523
530
|
get ctx(): CanvasRenderingContext2D | null;
|
|
524
531
|
get snapToGrid(): boolean;
|
|
@@ -555,6 +562,8 @@ declare class Viewport {
|
|
|
555
562
|
}): string;
|
|
556
563
|
updateGrid(updates: Partial<Pick<GridElement, 'gridType' | 'hexOrientation' | 'cellSize' | 'strokeColor' | 'strokeWidth' | 'opacity'>>): void;
|
|
557
564
|
removeGrid(): void;
|
|
565
|
+
getGridInfo(): GridInfo | null;
|
|
566
|
+
onGridChange(listener: (info: GridInfo | null) => void): () => void;
|
|
558
567
|
getRenderStats(): RenderStatsSnapshot;
|
|
559
568
|
logPerformance(intervalMs?: number): () => void;
|
|
560
569
|
destroy(): void;
|
|
@@ -572,6 +581,7 @@ declare class Viewport {
|
|
|
572
581
|
private applyCameraTransform;
|
|
573
582
|
private syncCanvasSize;
|
|
574
583
|
private syncGridContext;
|
|
584
|
+
private notifyGridChangeListeners;
|
|
575
585
|
private observeResize;
|
|
576
586
|
}
|
|
577
587
|
|
|
@@ -1109,6 +1119,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
1109
1119
|
undo(_store: ElementStore): void;
|
|
1110
1120
|
}
|
|
1111
1121
|
|
|
1112
|
-
declare const VERSION = "0.
|
|
1122
|
+
declare const VERSION = "0.11.0";
|
|
1113
1123
|
|
|
1114
|
-
export { type ActiveFormats, 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, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, 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 NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, 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 StyledRun, 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, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|
|
1124
|
+
export { type ActiveFormats, 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, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, type GridElement, type GridInfo, 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 NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, 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 StyledRun, 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, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|
package/dist/index.js
CHANGED
|
@@ -4182,6 +4182,7 @@ var Viewport = class {
|
|
|
4182
4182
|
renderLoop;
|
|
4183
4183
|
domNodeManager;
|
|
4184
4184
|
interactMode;
|
|
4185
|
+
gridChangeListeners = /* @__PURE__ */ new Set();
|
|
4185
4186
|
get ctx() {
|
|
4186
4187
|
return this.canvasEl.getContext("2d");
|
|
4187
4188
|
}
|
|
@@ -4286,6 +4287,22 @@ var Viewport = class {
|
|
|
4286
4287
|
this.historyRecorder.commit();
|
|
4287
4288
|
this.requestRender();
|
|
4288
4289
|
}
|
|
4290
|
+
getGridInfo() {
|
|
4291
|
+
const grid = this.store.getElementsByType("grid")[0];
|
|
4292
|
+
if (!grid) return null;
|
|
4293
|
+
return {
|
|
4294
|
+
gridType: grid.gridType,
|
|
4295
|
+
hexOrientation: grid.hexOrientation,
|
|
4296
|
+
cellSize: grid.cellSize,
|
|
4297
|
+
cellRadius: grid.gridType === "hex" ? grid.cellSize : grid.cellSize / 2
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
onGridChange(listener) {
|
|
4301
|
+
this.gridChangeListeners.add(listener);
|
|
4302
|
+
return () => {
|
|
4303
|
+
this.gridChangeListeners.delete(listener);
|
|
4304
|
+
};
|
|
4305
|
+
}
|
|
4289
4306
|
getRenderStats() {
|
|
4290
4307
|
return this.renderLoop.getStats();
|
|
4291
4308
|
}
|
|
@@ -4486,6 +4503,13 @@ var Viewport = class {
|
|
|
4486
4503
|
this.toolContext.gridType = void 0;
|
|
4487
4504
|
this.toolContext.hexOrientation = void 0;
|
|
4488
4505
|
}
|
|
4506
|
+
this.notifyGridChangeListeners();
|
|
4507
|
+
}
|
|
4508
|
+
notifyGridChangeListeners() {
|
|
4509
|
+
const info = this.getGridInfo();
|
|
4510
|
+
for (const listener of this.gridChangeListeners) {
|
|
4511
|
+
listener(info);
|
|
4512
|
+
}
|
|
4489
4513
|
}
|
|
4490
4514
|
observeResize() {
|
|
4491
4515
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -6177,7 +6201,7 @@ var UpdateLayerCommand = class {
|
|
|
6177
6201
|
};
|
|
6178
6202
|
|
|
6179
6203
|
// src/index.ts
|
|
6180
|
-
var VERSION = "0.
|
|
6204
|
+
var VERSION = "0.11.0";
|
|
6181
6205
|
export {
|
|
6182
6206
|
AddElementCommand,
|
|
6183
6207
|
ArrowTool,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldnotes/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Vanilla TypeScript infinite canvas engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest"
|
|
28
|
+
},
|
|
24
29
|
"license": "MIT",
|
|
25
30
|
"repository": {
|
|
26
31
|
"type": "git",
|
|
@@ -44,10 +49,5 @@
|
|
|
44
49
|
"jsdom": "^29.0.0",
|
|
45
50
|
"tsup": "^8.5.1",
|
|
46
51
|
"vitest": "^4.1.0"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"build": "tsup",
|
|
50
|
-
"test": "vitest run",
|
|
51
|
-
"test:watch": "vitest"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|