@orbat-mapper/tactical-draw 0.23.0 → 0.25.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,4 +1,4 @@
1
- import { $ as PinPresentationStatusEvent, A as PointSymbolAnchor, B as PointSymbolSize, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PointSymbolOffset, G as DEFAULT_PIN_PRESENTATION, H as clonePointSymbol, I as PointSymbolOffsetStyle, J as PinPresentation, K as PinFootprint, L as PointSymbolPlacement, M as PointSymbolColors, N as PointSymbolConnector, O as OffsetDragModifier, P as PointSymbolGraphicModifiers, Q as PinPresentationStatus, R as PointSymbolRect, S as isMinePattern, T as EditPointerDriver, U as isPointSymbol, V as PointSymbolStyle, W as resizePointSymbolSize, X as PinPresentationPatch, Y as PinPresentationCapability, Z as PinPresentationState, _ as HatchPattern, a as LayerId, at as pinZoomScale, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, et as PinPresentationStore, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as pinDistanceScale, j as PointSymbolCapability, k as PointSymbol, l as MapEventHandler, m as StyleOptions, n as HandleStyle, nt as combinePinScale, o as MapAdapter, ot as resolvePinPresentation, p as PixelCoordinate, q as PinOverridePatch, r as IconResource, rt as isValidPinNumber, s as MapCursor, t as FeatureGroup, tt as PinRender, u as PickEvent, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as PointSymbolRender } from "./map-adapter-Btuz2FLI.mjs";
1
+ import { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-DoB8tiCc.mjs";
2
2
  import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, HighlightAppearance, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
@@ -629,6 +629,36 @@ declare const DEFAULT_LABEL_SIZE_PIXELS = 14;
629
629
  * unit by default (ADR-0052).
630
630
  */
631
631
  type SizeAnchor = "ground" | "screen";
632
+ /**
633
+ * Whether `kind` has at least one size that can be restored to its normal
634
+ * pixel-authored appearance at the given resolution. Kept inside
635
+ * tactical-draw using the core metadata catalog so hosts never need to
636
+ * infer option names or special-case captured labels.
637
+ *
638
+ * `scale` only needs `getResolution()` (Web Mercator meters per CSS pixel), so
639
+ * a host without a live map can pass a fixed one:
640
+ * `canResetGroundSizes(measure, { getResolution: () => resolution })`.
641
+ */
642
+ declare function canResetGroundSizes(measure: Pick<ControlMeasure, "kind">, scale: Pick<MapAdapter, "getResolution">): boolean;
643
+ /**
644
+ * Return the complete option record produced by resetting every known size
645
+ * pair to its default on-screen appearance at the given resolution. Pixel
646
+ * keys are removed and meter keys are written, so the result remains
647
+ * ground-anchored. A pair that inherits another pair's size is cleared so it
648
+ * follows again. Unrelated options are preserved. This is the rule
649
+ * `EditSession.resetGroundSizes()` applies; hosts resetting graphics outside
650
+ * an edit session call it directly, passing a fixed resolution such as
651
+ * `{ getResolution: () => resolution }`.
652
+ *
653
+ * A pair's default is its own `defaultValue` when its `defaultUnit` is `"px"`,
654
+ * else the kind's default pixel option.
655
+ *
656
+ * Returns options for any kind with size pairs, even when nothing changes;
657
+ * compare with the input (e.g. structurally) to detect a no-op. Returns
658
+ * `undefined` when the kind has no resettable sizes or the resolution is not
659
+ * usable.
660
+ */
661
+ declare function resetGroundSizeOptions(measure: Pick<ControlMeasure, "kind" | "options">, scale: Pick<MapAdapter, "getResolution">): ControlMeasure["options"] | undefined;
632
662
  /**
633
663
  * The [[SizeAnchor]] a measure currently encodes (ADR-0020): `screen` when it
634
664
  * carries its kind's pixel-denominated size option, `ground` otherwise. Keys off
@@ -673,6 +703,13 @@ interface InteractionStyle {
673
703
  geometryHandle?: HandleStyle;
674
704
  /** Visible grab target for a draggable rendered text label. */
675
705
  labelHandle?: HandleStyle;
706
+ /**
707
+ * A point a Ctrl/⌘ + drag may snap onto, e.g. a vertex a Flow Arrow's new
708
+ * flow can merge into (ADR-0065). Shown only during that drag.
709
+ */
710
+ snapTargetHandle?: HandleStyle;
711
+ /** The snap target the drag is on now. Falls back to `snapTargetHandle` when unset. */
712
+ activeSnapTargetHandle?: HandleStyle;
676
713
  scaleHandle?: HandleStyle;
677
714
  rotateHandle?: HandleStyle;
678
715
  boxOutline?: GuideStyle;
@@ -812,6 +849,16 @@ interface EditSession {
812
849
  * [[setDetailHandles]].
813
850
  */
814
851
  readonly detailHandles: boolean;
852
+ /**
853
+ * The sub-selected part of a graphic whose definition divides it into parts
854
+ * (`ControlMeasureTopology.partOf`), e.g. the index of the Flow Arrow's
855
+ * selected flow (ADR-0065). Reshape mode shows only that part's option grips,
856
+ * and hosts read it to edit the part's own settings. Starts at `0`; pressing
857
+ * a point or midpoint, or clicking the graphic's body, selects the part under
858
+ * the pointer, and an edit or undo that removes the selected part falls back
859
+ * to `0`. `undefined` for graphics without parts.
860
+ */
861
+ readonly selectedPart: number | undefined;
815
862
  /**
816
863
  * Live size anchor for the measure under edit (ADR-0020). `"ground"` bakes a
817
864
  * pixel size to meters on commit; `"screen"` keeps it zoom-aware. Initialised
@@ -845,6 +892,18 @@ interface EditSession {
845
892
  * no change event, no history entry. A silent no-op after settlement.
846
893
  */
847
894
  setDetailHandles(visible: boolean): void;
895
+ /**
896
+ * Select a part (see [[selectedPart]]). View state only: no change event, no
897
+ * history entry. A no-op for a part the working graphic doesn't have, for
898
+ * graphics without parts, and after settlement.
899
+ */
900
+ selectPart(part: number): void;
901
+ /**
902
+ * Subscribe to [[selectedPart]] changes, from the pointer, [[selectPart]] or
903
+ * the fallback after the selected part goes away. Returns an unsubscribe
904
+ * function; registering after settlement is a no-op.
905
+ */
906
+ onPartSelect(listener: (part: number | undefined) => void): () => void;
848
907
  /** Atomically replace the live working graphic while preserving id and kind. */
849
908
  updateGraphic(updater: (graphic: ControlMeasure) => ControlMeasure): void;
850
909
  /** Shallow-merge per-measure generator options into the live working copy. */
@@ -1515,6 +1574,15 @@ interface InteractionHit {
1515
1574
  interface TacticalDrawOptions {
1516
1575
  /** Optional point-symbol body-drag shortcut; disabled when omitted or false. */
1517
1576
  offsetDragModifier?: OffsetDragModifier | false;
1577
+ /**
1578
+ * Which modifier keys the draw and edit gestures listen for: the vertex
1579
+ * modifier drag (Ctrl or ⌘), delete a vertex / reset an option handle (Alt)
1580
+ * and the angle and rotation constraint (Shift). Omitted roles keep those
1581
+ * defaults; `false` turns a gesture off. Throws a `RangeError` when
1582
+ * `deleteOrReset` shares a key with `modifierDrag`. Change it later with
1583
+ * {@link TacticalDraw.setEditModifiers}.
1584
+ */
1585
+ editModifiers?: EditModifiers;
1518
1586
  layers?: TacticalDrawLayerOptions;
1519
1587
  /** Optional renderer capability for first-class point symbols (ADR-0029). */
1520
1588
  pointSymbols?: PointSymbolCapability;
@@ -1742,6 +1810,9 @@ declare class TacticalDraw {
1742
1810
  private readonly defaultInteractionStyle;
1743
1811
  private readonly generateId;
1744
1812
  private offsetDragModifier;
1813
+ private editModifiers;
1814
+ /** Live read of the editor's modifier keys, so a change applies mid-edit. */
1815
+ private readonly currentEditModifiers;
1745
1816
  private readonly pointSymbols;
1746
1817
  private readonly images;
1747
1818
  private readonly markers;
@@ -1881,6 +1952,15 @@ declare class TacticalDraw {
1881
1952
  * `presentation` to skip re-resolving it when a caller has one in hand.
1882
1953
  */
1883
1954
  private graphicUsesPinPresentation;
1955
+ /**
1956
+ * Change the editor's modifier keys (see {@link TacticalDrawOptions.editModifiers}).
1957
+ * Roles the patch omits keep their current key. Applies from the next
1958
+ * pointer event, including in an active draw or edit. Throws a `RangeError`,
1959
+ * leaving the keys unchanged, when the result would be invalid.
1960
+ */
1961
+ setEditModifiers(modifiers: EditModifiers): void;
1962
+ /** The editor's current modifier keys, every role filled in (e.g. for hint text). */
1963
+ getEditModifiers(): ResolvedEditModifiers;
1884
1964
  /** Change the default shortcut for subsequent drags, including in an active edit. */
1885
1965
  setOffsetDragModifier(modifier: OffsetDragModifier | false): void;
1886
1966
  /**
@@ -2212,10 +2292,13 @@ declare class TacticalDraw {
2212
2292
  * This matters most for the active preview, since a click can land
2213
2293
  * anywhere across a rotated/offset label during an edit.
2214
2294
  *
2215
- * `tolerance` defaults to `pickHitTolerance(options?.originalEvent)` —
2216
- * pass the host's raw click event as `originalEvent` to get the same
2217
- * pointer-type-aware tolerance (4px mouse/pen, 12px touch) `onPick` uses;
2218
- * pass an explicit `tolerance` to override it outright.
2295
+ * `tolerance` defaults per layer and by pointer type — pass the host's raw
2296
+ * click event as `originalEvent` to get the right one: edit handles take
2297
+ * the edit session's own handle tolerance (12px mouse/pen, 22px touch), so
2298
+ * a pixel the edit would press as a handle is owned by `handles`; preview
2299
+ * and graphics take `pickHitTolerance` (4px mouse/pen, 12px touch), as
2300
+ * `onPick` does. Pass an explicit `tolerance` to override it for every
2301
+ * layer.
2219
2302
  *
2220
2303
  * `measureId` is set when the hit feature resolves to a control-measure id
2221
2304
  * via `tryControlMeasureIdFromFeature` — present for graphics/preview
@@ -2398,4 +2481,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
2398
2481
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
2399
2482
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
2400
2483
  //#endregion
2401
- export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type FeatureHighlightBand, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, type HandleStyle, type HatchPattern, type HighlightBand, type HighlightBandSlot, type HighlightCasing, 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 LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type NativeEventEntry, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, 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 PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedPickPresentation, type Rgba, 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_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
2484
+ export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_EDIT_MODIFIERS, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, type DrawMeasureDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditModifiers, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type FeatureHighlightBand, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, type HandleStyle, type HatchPattern, type HighlightBand, type HighlightBandSlot, type HighlightCasing, 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 LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type ModifierKey, type NativeEventEntry, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, 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 PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedEditModifiers, type ResolvedPickPresentation, type Rgba, 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_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, canResetGroundSizes, cloneImageGraphic, cloneMarker, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderOrderToVisualOrder, resetGroundSizeOptions, resizePointSymbolSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };