@fieldnotes/core 0.50.2 → 0.50.3

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
@@ -1123,6 +1123,6 @@ declare class LaserTool implements Tool {
1123
1123
  private notifyOptionsChange;
1124
1124
  }
1125
1125
 
1126
- declare const VERSION = "0.50.2";
1126
+ declare const VERSION = "0.50.3";
1127
1127
 
1128
1128
  export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
package/dist/index.d.ts CHANGED
@@ -1123,6 +1123,6 @@ declare class LaserTool implements Tool {
1123
1123
  private notifyOptionsChange;
1124
1124
  }
1125
1125
 
1126
- declare const VERSION = "0.50.2";
1126
+ declare const VERSION = "0.50.3";
1127
1127
 
1128
1128
  export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
package/dist/index.js CHANGED
@@ -2233,6 +2233,9 @@ var MAX_DEPTH = 8;
2233
2233
  function intersects(a, b) {
2234
2234
  return a.x <= b.x + b.w && a.x + a.w >= b.x && a.y <= b.y + b.h && a.y + a.h >= b.y;
2235
2235
  }
2236
+ function contains(outer, inner) {
2237
+ return inner.x >= outer.x && inner.x + inner.w <= outer.x + outer.w && inner.y >= outer.y && inner.y + inner.h <= outer.y + outer.h;
2238
+ }
2236
2239
  var QuadNode = class _QuadNode {
2237
2240
  constructor(bounds, depth) {
2238
2241
  this.bounds = bounds;
@@ -2285,6 +2288,14 @@ var QuadNode = class _QuadNode {
2285
2288
  }
2286
2289
  }
2287
2290
  }
2291
+ collect(result) {
2292
+ result.push(...this.items);
2293
+ if (this.children) {
2294
+ for (const child of this.children) {
2295
+ child.collect(result);
2296
+ }
2297
+ }
2298
+ }
2288
2299
  getChildIndex(itemBounds) {
2289
2300
  const midX = this.bounds.x + this.bounds.w / 2;
2290
2301
  const midY = this.bounds.y + this.bounds.h / 2;
@@ -2348,6 +2359,7 @@ var Quadtree = class {
2348
2359
  return this._size;
2349
2360
  }
2350
2361
  insert(id, bounds) {
2362
+ this.expandToFit(bounds);
2351
2363
  this.root.insert({ id, bounds });
2352
2364
  this._size++;
2353
2365
  }
@@ -2372,6 +2384,24 @@ var Quadtree = class {
2372
2384
  this.root = new QuadNode(this.worldBounds, 0);
2373
2385
  this._size = 0;
2374
2386
  }
2387
+ expandToFit(bounds) {
2388
+ const current = this.root.bounds;
2389
+ if (contains(current, bounds)) return;
2390
+ const currentRight = current.x + current.w;
2391
+ const currentBottom = current.y + current.h;
2392
+ const requiredWidth = Math.max(currentRight, bounds.x + bounds.w) - Math.min(current.x, bounds.x);
2393
+ const requiredHeight = Math.max(currentBottom, bounds.y + bounds.h) - Math.min(current.y, bounds.y);
2394
+ const width = Math.max(current.w * 2, requiredWidth);
2395
+ const height = Math.max(current.h * 2, requiredHeight);
2396
+ const x = bounds.x < current.x ? currentRight - width : current.x;
2397
+ const y = bounds.y < current.y ? currentBottom - height : current.y;
2398
+ const entries = [];
2399
+ this.root.collect(entries);
2400
+ this.root = new QuadNode({ x, y, w: width, h: height }, 0);
2401
+ for (const entry of entries) {
2402
+ this.root.insert(entry);
2403
+ }
2404
+ }
2375
2405
  };
2376
2406
 
2377
2407
  // src/elements/stroke-smoothing.ts
@@ -10589,7 +10619,7 @@ var LaserTool = class {
10589
10619
  };
10590
10620
 
10591
10621
  // src/index.ts
10592
- var VERSION = "0.50.2";
10622
+ var VERSION = "0.50.3";
10593
10623
  export {
10594
10624
  ArrowTool,
10595
10625
  AutoSave,