@orbat-mapper/tactical-draw 0.6.2 → 0.8.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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as EditPointerDriver, S as makeFillPatternImage, T as PointerEventInfo, _ as HatchPattern, a as LayerId, b as fillPatternImageId, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, l as MapEventHandler, m as StyleOptions, n as HandleStyle, o as MapAdapter, p as PixelCoordinate, r as IconResource, s as MapCursor, t as FeatureGroup, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as PointerCallback, x as isMinePattern, y as fillPatternImageDimension } from "./map-adapter-BWvKku2P.mjs";
2
- import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, TextAmplifiers } from "@orbat-mapper/control-measures";
1
+ import { C as EditPointerDriver, S as makeFillPatternImage, T as PointerEventInfo, _ as HatchPattern, a as LayerId, b as fillPatternImageId, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, l as MapEventHandler, m as StyleOptions, n as HandleStyle, o as MapAdapter, p as PixelCoordinate, r as IconResource, s as MapCursor, t as FeatureGroup, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as PointerCallback, x as isMinePattern, y as fillPatternImageDimension } from "./map-adapter-CyVIAoPf.mjs";
2
+ import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
5
5
  //#region src/base-map-adapter.d.ts
@@ -354,11 +354,42 @@ interface PointSymbolStyle {
354
354
  colors?: PointSymbolColors;
355
355
  monoColor?: string;
356
356
  opacity?: number;
357
+ /** 0–1 multiplier applied to both body and connector opacity; defaults to 1. */
358
+ overallOpacity?: number;
357
359
  outlineWidth?: number;
358
360
  fill?: boolean;
359
361
  frame?: boolean;
360
362
  icon?: boolean;
361
363
  }
364
+ type PointSymbolPlacement = {
365
+ mode: "screen-relative";
366
+ offset: [number, number];
367
+ } | {
368
+ mode: "ground";
369
+ position: Position;
370
+ };
371
+ /** Modifier that temporarily activates offset placement for a body drag. */
372
+ type OffsetDragModifier = "alt" | "shift" | "ctrl" | "meta";
373
+ type PointSymbolConnector = "auto" | "direct";
374
+ /** Optional connector overrides; omitted properties inherit symbol styling. */
375
+ interface PointSymbolOffsetStyle {
376
+ strokeColor?: string;
377
+ /** 0–1, independent of the body opacity. */
378
+ opacity?: number;
379
+ /** Fixed CSS-pixel width, independent of symbol size. */
380
+ strokeWidth?: number;
381
+ /** Alternating dash/gap lengths in CSS pixels; [] means solid. */
382
+ strokeDash?: number[];
383
+ }
384
+ interface PointSymbolOffset {
385
+ /** Gap at the symbol attachment end, measured along the line in CSS pixels; defaults to 0. */
386
+ anchorPadding?: number;
387
+ style?: PointSymbolOffsetStyle;
388
+ placement: PointSymbolPlacement;
389
+ connector: PointSymbolConnector;
390
+ /** Authored indicator length as a multiple of the displayed octagon size. */
391
+ indicatorLength?: number;
392
+ }
362
393
  interface PointSymbol {
363
394
  id: string;
364
395
  kind: "point-symbol";
@@ -368,6 +399,7 @@ interface PointSymbol {
368
399
  rotation: number;
369
400
  /** Milsymbol's octagon-based L dimension. */
370
401
  size: PointSymbolSize;
402
+ offset?: PointSymbolOffset;
371
403
  textAmplifiers?: TextAmplifiers;
372
404
  graphicModifiers?: PointSymbolGraphicModifiers;
373
405
  style?: PointSymbolStyle;
@@ -394,6 +426,19 @@ interface PointSymbolRender {
394
426
  octagonAnchor: PointSymbolAnchor;
395
427
  valid: boolean;
396
428
  validation?: unknown;
429
+ /** Optional body/attachment capability. All coordinates are canonical SVG units. */
430
+ offset?: {
431
+ body: PointSymbolRender; /** Body registration in the ordinary image, preserving natural HQ placement. */
432
+ ordinaryRegistration: PointSymbolAnchor;
433
+ attachment: PointSymbolAnchor;
434
+ indicator?: {
435
+ direction: PointSymbolAnchor;
436
+ length: number;
437
+ minLength?: number;
438
+ };
439
+ strokeColor: string;
440
+ strokeWidth: number;
441
+ };
397
442
  }
398
443
  interface PointSymbolCapability {
399
444
  readonly defaultSize: PointSymbolSize;
@@ -616,7 +661,7 @@ interface InteractionStyle {
616
661
  * remove) but no midpoints or box, and the edit controller deletes the tapped
617
662
  * vertex instead of dragging it.
618
663
  */
619
- type EditMode = "reshape" | "transform" | "labeldrag" | "delete";
664
+ type EditMode = "reshape" | "transform" | "labeldrag" | "delete" | "offset";
620
665
  //#endregion
621
666
  //#region src/tactical-draw/session-events.d.ts
622
667
  /** A gesture's phase within a stream of {@link TransientChangeEvent}s. */
@@ -895,7 +940,63 @@ interface EditChangeEvent {
895
940
  abort(): void;
896
941
  }
897
942
  //#endregion
943
+ //#region src/point-symbol-offset.d.ts
944
+ /** Read-only layout needs forward projection only. Coordinates are CSS pixels. */
945
+ type PointSymbolProjection = Pick<MapAdapter, "getPixelFromCoordinate" | "getBearing" | "getResolution">;
946
+ /** Editing may also require inverse projection (notably ground placement). */
947
+ type PointSymbolView = Pick<MapAdapter, "getPixelFromCoordinate" | "getCoordinateFromPixel" | "getBearing" | "getResolution">;
948
+ interface PointSymbolOffsetLayout {
949
+ /** Selected ordinary or detached body render, with canonical SVG dimensions. */
950
+ render: PointSymbolRender;
951
+ /** Selected body resource; dimensions and anchor remain in canonical SVG units. */
952
+ resource: IconResource;
953
+ /** Body opacity after applying the overall multiplier. */
954
+ bodyOpacity: number;
955
+ /** Clockwise radians in the projection plane. */
956
+ rotation: number;
957
+ actual: PixelCoordinate;
958
+ /** Body registration, including natural HQ displacement in ordinary placement. */
959
+ display: PixelCoordinate;
960
+ /** Coordinate at which the chosen image's resource anchor is painted. */
961
+ imageAnchor: PixelCoordinate;
962
+ ordinaryDisplay: PixelCoordinate;
963
+ attachment?: PixelCoordinate;
964
+ junction?: PixelCoordinate;
965
+ direction?: PixelCoordinate;
966
+ path: PixelCoordinate[];
967
+ kind: "ordinary" | "direct" | "indicator-only" | "with-extension";
968
+ status: "ok" | "unsupported-presentation";
969
+ scale: number;
970
+ /** Resolved connector styling in CSS pixels. */
971
+ connectorStyle: Required<PointSymbolOffsetStyle>;
972
+ }
973
+ /** Pure layout: projection input/output is in CSS pixels, including document contexts. */
974
+ declare function resolvePointSymbolOffset(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolProjection): PointSymbolOffsetLayout | null;
975
+ /** Set body placement without changing the authoritative coordinate. */
976
+ declare function placePointSymbol(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, display: PixelCoordinate, mode?: PointSymbolPlacement["mode"]): PointSymbol;
977
+ declare function convertPointSymbolPlacement(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, mode: PointSymbolPlacement["mode"]): PointSymbol;
978
+ /** Explicit alignment, also used with hysteresis by pointer editing. */
979
+ declare function alignPointSymbolIndicator(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView): PointSymbol;
980
+ declare function movePointSymbolLocation(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, position: Position): PointSymbol;
981
+ /** Canonical resource metadata shared by native adapters and external exporters. */
982
+ declare function pointSymbolResource(render: PointSymbolRender): IconResource;
983
+ /**
984
+ * Convert a resolved CSS-pixel layout to output units (e.g. 25.4 / 96 for mm).
985
+ * Scales positions, body scale, line width and dashes together, including the
986
+ * already-resolved offset and padding. Canonical resources, direction, rotation
987
+ * and opacity stay unchanged. Does not mutate the input or authored symbol.
988
+ */
989
+ declare function scalePointSymbolLayout(layout: PointSymbolOffsetLayout, factor: number): PointSymbolOffsetLayout;
990
+ //#endregion
898
991
  //#region src/tactical-draw/graphic-edit-session.d.ts
992
+ interface PointSymbolOffsetControls {
993
+ readonly layout: PointSymbolOffsetLayout | null;
994
+ readonly connectors: readonly PointSymbolConnector[];
995
+ setPlacement(mode: PointSymbolPlacement["mode"]): void;
996
+ setConnector(connector: PointSymbolConnector): void;
997
+ align(): void;
998
+ reset(): void;
999
+ }
899
1000
  interface GraphicEditChangeEvent<G extends Graphic = Graphic> {
900
1001
  readonly source: SessionChangeSource;
901
1002
  readonly graphic: GraphicSnapshot<G>;
@@ -908,6 +1009,8 @@ interface GraphicEditChangeEvent<G extends Graphic = Graphic> {
908
1009
  /** Common selection/editing contract shared by control measures and point symbols. */
909
1010
  interface GraphicEditSession<G extends Graphic = Graphic> {
910
1011
  readonly history: SessionHistory;
1012
+ /** Present on point-symbol sessions; all commands participate in session history. */
1013
+ readonly offset?: PointSymbolOffsetControls;
911
1014
  /** Immutable edit-start input. */
912
1015
  readonly graphic: G;
913
1016
  /** Live working graphic. Copy on read. */
@@ -1321,6 +1424,8 @@ interface InteractionHit {
1321
1424
  measureId?: string;
1322
1425
  }
1323
1426
  interface TacticalDrawOptions {
1427
+ /** Optional point-symbol body-drag shortcut; disabled when omitted or false. */
1428
+ offsetDragModifier?: OffsetDragModifier | false;
1324
1429
  layers?: TacticalDrawLayerOptions;
1325
1430
  /** Optional renderer capability for first-class point symbols (ADR-0029). */
1326
1431
  pointSymbols?: PointSymbolCapability;
@@ -1333,6 +1438,8 @@ interface TacticalDrawOptions {
1333
1438
  * appearance when neither the host nor the measure supplies a style.
1334
1439
  */
1335
1440
  graphicsStyle?: ControlMeasureStyle;
1441
+ /** Doctrinal defaults; explicit style colors take precedence. */
1442
+ symbolColors?: SymbolColors;
1336
1443
  /**
1337
1444
  * Façade-level default interaction-affordance style. Per-slot, per-property
1338
1445
  * merged with `DrawOptions.interactionStyle` / `EditOptions.interactionStyle`
@@ -1350,6 +1457,8 @@ interface TacticalDrawOptions {
1350
1457
  snapping?: SnappingOptions;
1351
1458
  }
1352
1459
  interface EditOptions {
1460
+ /** Override the point-symbol offset shortcut for this edit; false disables it. */
1461
+ offsetDragModifier?: OffsetDragModifier | false;
1353
1462
  signal?: AbortSignal;
1354
1463
  /**
1355
1464
  * Called synchronously once when the edit starts, before any pointer event
@@ -1498,8 +1607,10 @@ declare class TacticalDraw {
1498
1607
  private readonly handlesLayer;
1499
1608
  private readonly ownedLayers;
1500
1609
  private readonly graphicsStyle;
1610
+ private readonly symbolColors;
1501
1611
  private readonly defaultInteractionStyle;
1502
1612
  private readonly generateId;
1613
+ private offsetDragModifier;
1503
1614
  private readonly pointSymbols;
1504
1615
  private readonly images;
1505
1616
  private snappingOptions;
@@ -1550,6 +1661,8 @@ declare class TacticalDraw {
1550
1661
  private transformCounter;
1551
1662
  /** Snapshot of the host's latest authoritative Graphic membership and order. */
1552
1663
  private lastRenderedMeasures;
1664
+ /** Whether any last-rendered graphic reads the whole camera, not just scale. */
1665
+ private lastRenderedHasViewDependent;
1553
1666
  private snapGeometryFeatures;
1554
1667
  /**
1555
1668
  * Rendered graphics-layer groups, keyed on Graphic snapshot identity. Each
@@ -1587,6 +1700,8 @@ declare class TacticalDraw {
1587
1700
  */
1588
1701
  private hasHighlightOutlines;
1589
1702
  constructor(adapter: MapAdapter, options?: TacticalDrawOptions);
1703
+ /** Change the default shortcut for subsequent drags, including in an active edit. */
1704
+ setOffsetDragModifier(modifier: OffsetDragModifier | false): void;
1590
1705
  /** Replace snapping configuration without recreating the map adapter or façade. */
1591
1706
  setSnappingOptions(options?: SnappingOptions): void;
1592
1707
  /** Clear transient host affordances when snapping or its interaction ends. */
@@ -2031,14 +2146,18 @@ interface TransformBox {
2031
2146
  angle: number;
2032
2147
  }
2033
2148
  //#endregion
2149
+ //#region src/point-symbol-size.d.ts
2150
+ declare function effectivePointSymbolPixelSize(symbol: Pick<PointSymbol, "size">, resolution: number | undefined): number;
2151
+ //#endregion
2034
2152
  //#region src/tactical-draw/point-symbol-rendering.d.ts
2035
2153
  interface PointSymbolFootprint {
2036
2154
  box: TransformBox;
2037
2155
  corners: PixelCoordinate[];
2156
+ /** Connector path, separate from the body-only transform box. */
2157
+ connector: PixelCoordinate[];
2038
2158
  }
2039
- declare function effectivePointSymbolPixelSize(symbol: PointSymbol, resolution: number | undefined): number;
2040
2159
  /** Complete rotated logical footprint for selection and transform chrome. */
2041
- declare function pointSymbolFootprint(symbol: PointSymbol, render: PointSymbolRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): PointSymbolFootprint | null;
2160
+ declare function pointSymbolFootprint(symbol: PointSymbol, render: PointSymbolRender, adapter: PointSymbolProjection): PointSymbolFootprint | null;
2042
2161
  //#endregion
2043
2162
  //#region src/tactical-draw/image-rendering.d.ts
2044
2163
  interface ImageFootprint {
@@ -2061,4 +2180,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
2061
2180
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
2062
2181
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
2063
2182
  //#endregion
2064
- export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DrawImageDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, type HandleStyle, type HatchPattern, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type MergedPickFeature, type NativeEventEntry, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMinePattern, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };
2183
+ export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DrawImageDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, type HandleStyle, type HatchPattern, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type MergedPickFeature, type NativeEventEntry, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolConnector, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolOffset, type PointSymbolOffsetControls, type PointSymbolOffsetLayout, type PointSymbolOffsetStyle, type PointSymbolPlacement, type PointSymbolProjection, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMinePattern, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolvePointSymbolOffset, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic };