@orbat-mapper/tactical-draw 0.2.1 → 0.3.1

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 { S as PointerEventInfo, _ as fillPatternImageDimension, a as MapAdapter, b as EditPointerDriver, c as MapEventHandler, d as PickOptions, f as PixelCoordinate, g as HatchPattern, h as HATCH_PATTERNS, i as LayerId, l as PickEvent, m as TextStyleOptions, n as HandleStyle, o as MapCursor, p as StyleOptions, r as IconResource, s as MapEvent, t as FeatureGroup, u as PickHandler, v as fillPatternImageId, x as PointerCallback, y as makeFillPatternImage } from "./map-adapter-84irgVJR.mjs";
1
+ import { C as PointerEventInfo, S as PointerCallback, _ as HatchPattern, a as LayerId, b as makeFillPatternImage, 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 fillPatternImageDimension, x as EditPointerDriver, y as fillPatternImageId } from "./map-adapter-DfIb57kQ.mjs";
2
2
  import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
@@ -419,13 +419,73 @@ declare function clonePointSymbol(symbol: PointSymbol): PointSymbol;
419
419
  */
420
420
  declare function resizePointSymbolSize(size: PointSymbolSize, value: number): PointSymbolSize;
421
421
  //#endregion
422
+ //#region src/image-graphic.d.ts
423
+ type ImageSize = {
424
+ value: number;
425
+ unit: "meters";
426
+ };
427
+ interface ImageIntrinsicSize {
428
+ width: number;
429
+ height: number;
430
+ }
431
+ interface ImageGraphicStyle {
432
+ opacity?: number;
433
+ }
434
+ /** Persisted, host-resource-backed Image graphic. */
435
+ interface ImageGraphic {
436
+ id: string;
437
+ kind: "image";
438
+ resourceId: string;
439
+ intrinsicSize: ImageIntrinsicSize;
440
+ position: Position;
441
+ /** Normalized radians clockwise from geographic north. */
442
+ rotation: number;
443
+ /** Displayed width; height is derived from `intrinsicSize`. */
444
+ size: ImageSize;
445
+ name?: string;
446
+ style?: ImageGraphicStyle;
447
+ properties?: Record<string, unknown>;
448
+ schemaVersion: 1;
449
+ }
450
+ /** Prepared, synchronous display resource supplied and owned by the host. */
451
+ interface ImageResource {
452
+ id: string;
453
+ /** Self-contained raster URL prepared by the host for native image overlays. */
454
+ overlayUrl: string;
455
+ width: number;
456
+ height: number;
457
+ }
458
+ interface ImageCapability {
459
+ resolve(resourceId: string): ImageResource | undefined;
460
+ /** Monotonic host-owned revision for resource availability changes. */
461
+ readonly generation?: number;
462
+ }
463
+ interface ImageRender {
464
+ resourceId: string;
465
+ width: number;
466
+ height: number;
467
+ overlayUrl?: string;
468
+ available: boolean;
469
+ }
470
+ declare function isImageGraphic(graphic: unknown): graphic is ImageGraphic;
471
+ declare function cloneImageGraphic(image: ImageGraphic): ImageGraphic;
472
+ declare function normalizeImageGraphic(image: ImageGraphic): ImageGraphic;
473
+ declare function imageOpacity(image: ImageGraphic): number;
474
+ declare function validateImageGraphic(image: ImageGraphic): void;
475
+ //#endregion
422
476
  //#region src/graphic.d.ts
423
- type Graphic = ControlMeasure | PointSymbol;
424
- type GraphicRender = ControlMeasureRender | PointSymbolRender;
477
+ type Graphic = ControlMeasure | PointSymbol | ImageGraphic;
478
+ type GraphicRender = ControlMeasureRender | PointSymbolRender | ImageRender;
425
479
  interface GraphicSnapshot<G extends Graphic = Graphic> {
426
480
  graphic: G;
427
- render: G extends PointSymbol ? PointSymbolRender : ControlMeasureRender;
481
+ render: G extends PointSymbol ? PointSymbolRender : G extends ImageGraphic ? ImageRender : ControlMeasureRender;
428
482
  }
483
+ /**
484
+ * A graphic whose identity is one geographic anchor + size + rotation,
485
+ * rather than a control-point geometry: `PointSymbol` or `ImageGraphic`.
486
+ */
487
+ type AnchoredGraphic = PointSymbol | ImageGraphic;
488
+ declare function isAnchoredGraphic(graphic: Graphic): graphic is AnchoredGraphic;
429
489
  //#endregion
430
490
  //#region src/tactical-draw/abort.d.ts
431
491
  /**
@@ -1213,6 +1273,9 @@ interface SnappingOptions {
1213
1273
  //#region src/tactical-draw/point-symbol-draw-controller.d.ts
1214
1274
  type DrawPointSymbolDraft = Pick<PointSymbol, "kind" | "sidc"> & Partial<Omit<PointSymbol, "kind" | "sidc">>;
1215
1275
  //#endregion
1276
+ //#region src/tactical-draw/image-draw-controller.d.ts
1277
+ type DrawImageDraft = Pick<ImageGraphic, "kind" | "resourceId" | "intrinsicSize"> & Partial<Omit<ImageGraphic, "kind" | "resourceId" | "intrinsicSize">>;
1278
+ //#endregion
1216
1279
  //#region src/tactical-draw/tactical-draw.d.ts
1217
1280
  /**
1218
1281
  * Host-supplied layer slot ids. Any omitted slot is allocated by the façade and
@@ -1246,6 +1309,8 @@ interface TacticalDrawOptions {
1246
1309
  layers?: TacticalDrawLayerOptions;
1247
1310
  /** Optional renderer capability for first-class point symbols (ADR-0029). */
1248
1311
  pointSymbols?: PointSymbolCapability;
1312
+ /** Synchronous host-supplied resolver for first-class Image resources. */
1313
+ images?: ImageCapability;
1249
1314
  /**
1250
1315
  * Façade-level default style passed through to `renderControlMeasure` as the
1251
1316
  * third (lowest priority) style layer per StyleResolver (#44). Shallow-merged
@@ -1275,7 +1340,7 @@ interface EditOptions {
1275
1340
  * Called synchronously once when the edit starts, before any pointer event
1276
1341
  * is processed. Lets a host wire commit / cancel buttons to the active edit.
1277
1342
  */
1278
- onSession?: (session: EditSession | GraphicEditSession<PointSymbol>) => void;
1343
+ onSession?: (session: EditSession | GraphicEditSession<PointSymbol> | GraphicEditSession<ImageGraphic>) => void;
1279
1344
  /**
1280
1345
  * Default `true`. When `true`, a click on empty map (or on another graphics
1281
1346
  * layer measure) closes the active edit. Clicks on preview / handle
@@ -1421,6 +1486,7 @@ declare class TacticalDraw {
1421
1486
  private readonly defaultInteractionStyle;
1422
1487
  private readonly generateId;
1423
1488
  private readonly pointSymbols;
1489
+ private readonly images;
1424
1490
  private snappingOptions;
1425
1491
  private readonly resolveSnap;
1426
1492
  private readonly graphicStack;
@@ -1487,6 +1553,7 @@ declare class TacticalDraw {
1487
1553
  * there is no capability, or the capability doesn't expose `generation`.
1488
1554
  */
1489
1555
  private lastSeenPointSymbolGeneration;
1556
+ private lastSeenImageGeneration;
1490
1557
  /**
1491
1558
  * Ids of graphics currently carrying a passive selection-highlight outline
1492
1559
  * ({@link setHighlightedGraphics}). Declarative set-replace, no session —
@@ -1534,6 +1601,8 @@ declare class TacticalDraw {
1534
1601
  * the point-symbol capability's `generation`.
1535
1602
  */
1536
1603
  private invalidateGraphicGroupCache;
1604
+ /** Refresh capability-dependent renders before any caller-visible state is mutated. */
1605
+ private refreshCapabilityGenerations;
1537
1606
  /** Submit one complete grouped desired state for the host stack plus overrides. */
1538
1607
  private reconcileGraphicsStack;
1539
1608
  /** Atomically publish several live renders into their host-owned Graphic slots. */
@@ -1668,6 +1737,7 @@ declare class TacticalDraw {
1668
1737
  * kinds of session.
1669
1738
  */
1670
1739
  draw(draft: DrawPointSymbolDraft, options?: DrawOptions): Promise<GraphicSnapshot<PointSymbol>>;
1740
+ draw(draft: DrawImageDraft, options?: DrawOptions): Promise<GraphicSnapshot<ImageGraphic>>;
1671
1741
  draw<K extends ControlMeasureKind>(draft: DrawMeasureDraft<K>, options?: DrawOptions): Promise<GraphicSnapshot<ControlMeasure<K>>>;
1672
1742
  /**
1673
1743
  * Start an interactive edit on a single control measure. Returns a Promise
@@ -1685,6 +1755,7 @@ declare class TacticalDraw {
1685
1755
  * non-load-bearing for hosts that adopt them.
1686
1756
  */
1687
1757
  edit(graphic: PointSymbol, options?: EditOptions): Promise<GraphicSnapshot<PointSymbol>>;
1758
+ edit(graphic: ImageGraphic, options?: EditOptions): Promise<GraphicSnapshot<ImageGraphic>>;
1688
1759
  edit(measure: ControlMeasure, options?: EditOptions): Promise<GraphicSnapshot<ControlMeasure>>;
1689
1760
  /**
1690
1761
  * Start an interactive group transform (multi-select) over `measures`
@@ -1828,7 +1899,7 @@ declare class TacticalDraw {
1828
1899
  * The live variable-draw or edit session, or `null` while idle and during
1829
1900
  * fixed-length draws. Safe to read after `destroy()`.
1830
1901
  */
1831
- get activeSession(): DrawSession | EditSession | GraphicEditSession<PointSymbol> | null;
1902
+ get activeSession(): DrawSession | EditSession | GraphicEditSession | null;
1832
1903
  /**
1833
1904
  * The live `editMany` group-transform session, or `null` while idle (and
1834
1905
  * during any other interaction). Separate from `activeSession` because
@@ -1902,6 +1973,9 @@ declare class TacticalDrawDestroyedError extends Error {
1902
1973
  declare class PointSymbolCapabilityRequiredError extends Error {
1903
1974
  constructor();
1904
1975
  }
1976
+ declare class ImageCapabilityRequiredError extends Error {
1977
+ constructor();
1978
+ }
1905
1979
  //#endregion
1906
1980
  //#region src/tactical-draw/transform-box.d.ts
1907
1981
  /**
@@ -1946,6 +2020,13 @@ declare function effectivePointSymbolPixelSize(symbol: PointSymbol, resolution:
1946
2020
  /** Complete rotated logical footprint for selection and transform chrome. */
1947
2021
  declare function pointSymbolFootprint(symbol: PointSymbol, render: PointSymbolRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): PointSymbolFootprint | null;
1948
2022
  //#endregion
2023
+ //#region src/tactical-draw/image-rendering.d.ts
2024
+ interface ImageFootprint {
2025
+ box: TransformBox;
2026
+ corners: PixelCoordinate[];
2027
+ }
2028
+ declare function imageFootprint(image: ImageGraphic, render: ImageRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): ImageFootprint | null;
2029
+ //#endregion
1949
2030
  //#region src/world-wrap.d.ts
1950
2031
  /**
1951
2032
  * Shift `lng` by whole world widths (360°) onto the copy nearest `refLng`.
@@ -1960,4 +2041,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
1960
2041
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
1961
2042
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
1962
2043
  //#endregion
1963
- export { BaseMapAdapter, type CombinedAbort, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, 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 InteractionHit, type InteractionStyle, type LabelExtent, type LayerId, 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, clonePointSymbol, coerceHandleStyle, combineWithHostSignal, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hitTestFeature, hitTestIconFeature, ignoreAbort, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature };
2044
+ 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, 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, isPointSymbol, isTacticalDrawAbortError, makeFillPatternImage, mergeNativeAndCachedPickFeatures, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, pickHitTolerance, pickPointerType, pointSymbolFootprint, renderOrderToVisualOrder, resizePointSymbolSize, resolveGroundTextSizePixels, resolvePickPresentation, resolveTextHaloWidth, resolveTextSizePixels, tryControlMeasureIdFromFeature, validateImageGraphic };