@orbat-mapper/tactical-draw 0.18.0 → 0.20.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 { A as PinOverridePatch, B as isValidPinNumber, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PinPresentationStatus, H as pinZoomScale, I as PinPresentationStatusEvent, L as PinPresentationStore, M as PinPresentationCapability, N as PinPresentationPatch, O as DEFAULT_PIN_PRESENTATION, P as PinPresentationState, R as PinRender, S as isMinePattern, T as EditPointerDriver, U as resolvePinPresentation, V as pinDistanceScale, _ as HatchPattern, a as LayerId, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, j as PinPresentation, k as PinFootprint, 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 parseColor, x as fillPatternImageId, y as Rgba, z as combinePinScale } from "./map-adapter-Cos4xrCn.mjs";
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-D6pkU0iz.mjs";
2
2
  import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
@@ -357,141 +357,6 @@ declare class PointerCallbackHub {
357
357
  clear(): void;
358
358
  }
359
359
  //#endregion
360
- //#region src/point-symbol.d.ts
361
- type PointSymbolSize = {
362
- value: number;
363
- unit: "pixels";
364
- } | {
365
- value: number;
366
- unit: "meters"; /** Floor for the on-screen projection of the ground-based size; none when omitted. */
367
- minPixels?: number; /** Cap on the on-screen projection of the ground-based size — typically the pixel size the symbol had when anchored to ground; unclamped when omitted. */
368
- maxPixels?: number;
369
- };
370
- interface PointSymbolGraphicModifiers {
371
- /** Radians clockwise, relative to the point symbol's own orientation. */
372
- direction?: number;
373
- }
374
- interface PointSymbolColors {
375
- fill?: string;
376
- frame?: string;
377
- icon?: string;
378
- info?: string;
379
- outline?: string;
380
- }
381
- interface PointSymbolStyle {
382
- colors?: PointSymbolColors;
383
- monoColor?: string;
384
- opacity?: number;
385
- /** 0–1 multiplier applied to both body and connector opacity; defaults to 1. */
386
- overallOpacity?: number;
387
- outlineWidth?: number;
388
- fill?: boolean;
389
- frame?: boolean;
390
- icon?: boolean;
391
- }
392
- type PointSymbolPlacement = {
393
- mode: "screen-relative";
394
- offset: [number, number];
395
- } | {
396
- mode: "ground";
397
- position: Position;
398
- };
399
- /** Modifier that temporarily activates offset placement for a body drag. */
400
- type OffsetDragModifier = "alt" | "shift" | "ctrl" | "meta";
401
- type PointSymbolConnector = "auto" | "direct";
402
- /** Optional connector overrides; omitted properties inherit symbol styling. */
403
- interface PointSymbolOffsetStyle {
404
- strokeColor?: string;
405
- /** 0–1, independent of the body opacity. */
406
- opacity?: number;
407
- /** Fixed CSS-pixel width, independent of symbol size. */
408
- strokeWidth?: number;
409
- /** Alternating dash/gap lengths in CSS pixels; [] means solid. */
410
- strokeDash?: number[];
411
- }
412
- interface PointSymbolOffset {
413
- /** Gap at the symbol attachment end, measured along the line in CSS pixels; defaults to 0. */
414
- anchorPadding?: number;
415
- style?: PointSymbolOffsetStyle;
416
- placement: PointSymbolPlacement;
417
- connector: PointSymbolConnector;
418
- /** Authored indicator length as a multiple of the displayed octagon size. */
419
- indicatorLength?: number;
420
- }
421
- interface PointSymbol {
422
- id: string;
423
- kind: "point-symbol";
424
- sidc: string;
425
- position: Position;
426
- /** Normalized radians clockwise from geographic north. */
427
- rotation: number;
428
- /** Milsymbol's octagon-based L dimension. */
429
- size: PointSymbolSize;
430
- offset?: PointSymbolOffset;
431
- textAmplifiers?: TextAmplifiers;
432
- graphicModifiers?: PointSymbolGraphicModifiers;
433
- style?: PointSymbolStyle;
434
- rendererOptions?: {
435
- milsymbol?: Record<string, unknown>;
436
- };
437
- properties?: Record<string, unknown>;
438
- schemaVersion?: 1;
439
- }
440
- interface PointSymbolAnchor {
441
- x: number;
442
- y: number;
443
- }
444
- /** Canonical-size, renderer-neutral point-symbol output. */
445
- interface PointSymbolRender {
446
- /** Content-derived identity for adapter-wide native-resource reuse. */
447
- resourceId: string;
448
- svg: string;
449
- /** Renderer-space octagon size used to interpret persisted symbol size. */
450
- octagonSize: number;
451
- width: number;
452
- height: number;
453
- anchor: PointSymbolAnchor;
454
- octagonAnchor: PointSymbolAnchor;
455
- valid: boolean;
456
- validation?: unknown;
457
- /** Optional body/attachment capability. All coordinates are canonical SVG units. */
458
- offset?: {
459
- body: PointSymbolRender; /** Body registration in the ordinary image, preserving natural HQ placement. */
460
- ordinaryRegistration: PointSymbolAnchor;
461
- attachment: PointSymbolAnchor;
462
- indicator?: {
463
- direction: PointSymbolAnchor;
464
- length: number;
465
- minLength?: number;
466
- };
467
- strokeColor: string;
468
- strokeWidth: number;
469
- };
470
- }
471
- interface PointSymbolCapability {
472
- readonly defaultSize: PointSymbolSize;
473
- readonly defaultRotation: number;
474
- render(symbol: PointSymbol): PointSymbolRender;
475
- invalidate(): void;
476
- /**
477
- * Monotonic counter that increments on each `invalidate()` call. Consumers
478
- * (e.g. a render cache keyed on graphic snapshot identity) may read this to
479
- * detect that previously rendered point-symbol output is stale even though
480
- * the graphic snapshot itself is unchanged. Optional — when absent,
481
- * invalidation cannot be detected by cache layers, so they must not attempt
482
- * to key on it.
483
- */
484
- readonly generation?: number;
485
- }
486
- declare function isPointSymbol(graphic: unknown): graphic is PointSymbol;
487
- declare function clonePointSymbol(symbol: PointSymbol): PointSymbol;
488
- /**
489
- * Replace a point-symbol size value as a user-driven resize. Ground-size display
490
- * bounds scale with the value so they continue to constrain zoom changes rather
491
- * than preventing the resize itself.
492
- */
493
- declare function resizePointSymbolSize(size: PointSymbolSize, value: number): PointSymbolSize;
494
- //#endregion
495
360
  //#region src/image-graphic.d.ts
496
361
  type ImageSize = {
497
362
  value: number;
@@ -1902,6 +1767,12 @@ declare class TacticalDraw {
1902
1767
  setPinPresentation(defaults: PinPresentationPatch): void;
1903
1768
  setPinOverride(id: string, patch: PinOverridePatch): void;
1904
1769
  resetPinOverride(id: string): void;
1770
+ /**
1771
+ * Set several pin overrides, and with `null` reset them, in one change and
1772
+ * one re-render. Prefer it over a loop of {@link setPinOverride} calls when
1773
+ * many pins change at once.
1774
+ */
1775
+ setPinOverrides(patches: Readonly<Record<string, PinOverridePatch | null>>): void;
1905
1776
  getPinPresentationCapability(id?: string): PinPresentationCapability;
1906
1777
  onPinPresentationStatusChange(listener: (event: PinPresentationStatusEvent) => void): () => void;
1907
1778
  getPinPresentationState(): PinPresentationState;
@@ -2427,4 +2298,4 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
2427
2298
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
2428
2299
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
2429
2300
  //#endregion
2430
- 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 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 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 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, 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, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
2301
+ 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 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 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, 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, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker };
package/dist/index.mjs CHANGED
@@ -258,10 +258,16 @@ function evaluateIcon(feature, resource, context) {
258
258
  const angle = (typeof rawRotation === "number" && Number.isFinite(rawRotation) ? rawRotation : 0) - (context.bearing ?? 0);
259
259
  const cos = Math.cos(angle);
260
260
  const sin = Math.sin(angle);
261
- const minX = -resource.anchor[0] * scale;
262
- const maxX = (resource.width - resource.anchor[0]) * scale;
263
- const minY = -resource.anchor[1] * scale;
264
- const maxY = (resource.height - resource.anchor[1]) * scale;
261
+ const contentRect = resource.contentRect ?? {
262
+ x: 0,
263
+ y: 0,
264
+ width: resource.width,
265
+ height: resource.height
266
+ };
267
+ const minX = (contentRect.x - resource.anchor[0]) * scale;
268
+ const maxX = (contentRect.x + contentRect.width - resource.anchor[0]) * scale;
269
+ const minY = (contentRect.y - resource.anchor[1]) * scale;
270
+ const maxY = (contentRect.y + contentRect.height - resource.anchor[1]) * scale;
265
271
  const dx = context.pixel[0] - anchor[0];
266
272
  const dy = context.pixel[1] - anchor[1];
267
273
  const localX = dx * cos + dy * sin;
@@ -269,12 +275,7 @@ function evaluateIcon(feature, resource, context) {
269
275
  const outsideX = Math.max(minX - localX, 0, localX - maxX);
270
276
  const outsideY = Math.max(minY - localY, 0, localY - maxY);
271
277
  if (outsideX > context.tolerance || outsideY > context.tolerance) return null;
272
- const coreRect = resource.coreRect ?? {
273
- x: 0,
274
- y: 0,
275
- width: resource.width,
276
- height: resource.height
277
- };
278
+ const coreRect = resource.coreRect ?? contentRect;
278
279
  const coreMinX = (coreRect.x - resource.anchor[0]) * scale;
279
280
  const coreMaxX = (coreRect.x + coreRect.width - resource.anchor[0]) * scale;
280
281
  const coreMinY = (coreRect.y - resource.anchor[1]) * scale;
@@ -1313,6 +1314,10 @@ var PinPresentationStore = class {
1313
1314
  defaults: {},
1314
1315
  overrides: {}
1315
1316
  };
1317
+ /** Monotonic stamp source for {@link revision}. */
1318
+ revisions = 0;
1319
+ defaultsRevision = 0;
1320
+ overrideRevisions = /* @__PURE__ */ new Map();
1316
1321
  emitter = createCommitEmitter("PinPresentationStore.onChange listener errors");
1317
1322
  getState() {
1318
1323
  return structuredClone(this.state);
@@ -1320,18 +1325,34 @@ var PinPresentationStore = class {
1320
1325
  resolve(id) {
1321
1326
  return resolvePinPresentation(this.state.defaults, Object.hasOwn(this.state.overrides, id) ? this.state.overrides[id] : {});
1322
1327
  }
1328
+ /**
1329
+ * @internal A stamp that changes whenever {@link resolve} may return a
1330
+ * different presentation for `id`, so a renderer can keep reusing the pins
1331
+ * whose presentation a change left alone.
1332
+ */
1333
+ revision(id) {
1334
+ return Math.max(this.defaultsRevision, this.overrideRevisions.get(id) ?? 0);
1335
+ }
1323
1336
  replace(state) {
1324
1337
  if (!state || !state.overrides || typeof state.overrides !== "object" || Array.isArray(state.overrides)) throw new TypeError("Invalid pin state");
1325
- if (!Object.is(state.defaults, this.state.defaults)) {
1338
+ const defaultsChanged = !Object.is(state.defaults, this.state.defaults);
1339
+ const changed = [];
1340
+ if (defaultsChanged) {
1326
1341
  resolvePinPresentation(state.defaults);
1327
1342
  for (const patch of Object.values(state.overrides)) {
1328
1343
  validateOverride(patch);
1329
1344
  resolvePinPresentation(state.defaults, patch);
1330
1345
  }
1331
- } else for (const [id, patch] of Object.entries(state.overrides)) if (!Object.is(patch, this.state.overrides[id])) {
1332
- validateOverride(patch);
1333
- resolvePinPresentation(state.defaults, patch);
1346
+ } else {
1347
+ for (const [id, patch] of Object.entries(state.overrides)) if (!Object.is(patch, this.state.overrides[id])) {
1348
+ validateOverride(patch);
1349
+ resolvePinPresentation(state.defaults, patch);
1350
+ changed.push(id);
1351
+ }
1352
+ for (const id of Object.keys(this.state.overrides)) if (!Object.hasOwn(state.overrides, id)) changed.push(id);
1334
1353
  }
1354
+ if (defaultsChanged) this.defaultsRevision = ++this.revisions;
1355
+ for (const id of changed) this.overrideRevisions.set(id, ++this.revisions);
1335
1356
  this.state = structuredClone(state);
1336
1357
  this.emitter.emit(this.getState());
1337
1358
  }
@@ -1342,20 +1363,27 @@ var PinPresentationStore = class {
1342
1363
  });
1343
1364
  }
1344
1365
  setOverride(id, patch) {
1345
- this.replace({
1346
- ...this.state,
1347
- overrides: {
1348
- ...this.state.overrides,
1349
- [id]: patch
1350
- }
1351
- });
1366
+ this.setOverrides({ [id]: patch });
1352
1367
  }
1353
1368
  resetOverride(id) {
1354
- const overrides = { ...this.state.overrides };
1355
- delete overrides[id];
1369
+ this.setOverrides({ [id]: null });
1370
+ }
1371
+ /**
1372
+ * Set several overrides, and with `null` reset them, as one validated change
1373
+ * and one `onChange` emit. Each patch replaces that id's previous patch, as
1374
+ * {@link setOverride} does; ids not named keep theirs. An invalid patch
1375
+ * throws and leaves every override unchanged.
1376
+ */
1377
+ setOverrides(patches) {
1378
+ if (!patches || typeof patches !== "object" || Array.isArray(patches)) throw new TypeError("Invalid pin overrides");
1379
+ const entries = Object.entries(patches);
1380
+ if (entries.length === 0) return;
1381
+ const overrides = new Map(Object.entries(this.state.overrides));
1382
+ for (const [id, patch] of entries) if (patch === null) overrides.delete(id);
1383
+ else overrides.set(id, patch);
1356
1384
  this.replace({
1357
1385
  ...this.state,
1358
- overrides
1386
+ overrides: Object.fromEntries(overrides)
1359
1387
  });
1360
1388
  }
1361
1389
  onChange(listener) {
@@ -1723,6 +1751,7 @@ function pointSymbolResource(render) {
1723
1751
  width: render.width,
1724
1752
  height: render.height,
1725
1753
  anchor: [render.anchor.x, render.anchor.y],
1754
+ ...render.contentBounds ? { contentRect: render.contentBounds } : {},
1726
1755
  coreRect: {
1727
1756
  x: render.octagonAnchor.x - render.octagonSize / 2,
1728
1757
  y: render.octagonAnchor.y - render.octagonSize / 2,
@@ -5971,14 +6000,20 @@ function pointSymbolFootprint(symbol, render, adapter) {
5971
6000
  render = layout.render;
5972
6001
  const scale = pointSymbolPixelScale(symbol, render, adapter.getResolution());
5973
6002
  const angle = symbol.rotation - adapter.getBearing();
5974
- const centerOffsetX = (render.width / 2 - render.anchor.x) * scale;
5975
- const centerOffsetY = (render.height / 2 - render.anchor.y) * scale;
6003
+ const content = render.contentBounds ?? {
6004
+ x: 0,
6005
+ y: 0,
6006
+ width: render.width,
6007
+ height: render.height
6008
+ };
6009
+ const centerOffsetX = (content.x + content.width / 2 - render.anchor.x) * scale;
6010
+ const centerOffsetY = (content.y + content.height / 2 - render.anchor.y) * scale;
5976
6011
  const cos = Math.cos(angle);
5977
6012
  const sin = Math.sin(angle);
5978
6013
  const box = {
5979
6014
  center: [anchor[0] + centerOffsetX * cos - centerOffsetY * sin, anchor[1] + centerOffsetX * sin + centerOffsetY * cos],
5980
- halfWidth: render.width * scale / 2,
5981
- halfHeight: render.height * scale / 2,
6015
+ halfWidth: content.width * scale / 2,
6016
+ halfHeight: content.height * scale / 2,
5982
6017
  angle
5983
6018
  };
5984
6019
  return {
@@ -8740,7 +8775,6 @@ var TacticalDraw = class {
8740
8775
  this.adapter.setLayerStyle(this.highlightLayer, guideToStyleOptions(this.baseHighlightStyle()));
8741
8776
  this.adapter.onViewChange(this.handleViewChange);
8742
8777
  this.unsubscribePins = this.pins.onChange(() => {
8743
- this.invalidateGraphicGroupCache(false);
8744
8778
  this.refreshActiveEditPresentation();
8745
8779
  this.reconcileGraphicsStack();
8746
8780
  this.flushHighlights();
@@ -8758,6 +8792,15 @@ var TacticalDraw = class {
8758
8792
  this.assertAlive();
8759
8793
  this.pins.resetOverride(id);
8760
8794
  }
8795
+ /**
8796
+ * Set several pin overrides, and with `null` reset them, in one change and
8797
+ * one re-render. Prefer it over a loop of {@link setPinOverride} calls when
8798
+ * many pins change at once.
8799
+ */
8800
+ setPinOverrides(patches) {
8801
+ this.assertAlive();
8802
+ this.pins.setOverrides(patches);
8803
+ }
8761
8804
  getPinPresentationCapability(id) {
8762
8805
  return this.adapter.getPinPresentationCapability?.(id) ?? {
8763
8806
  status: "unsupported",
@@ -8842,19 +8885,22 @@ var TacticalDraw = class {
8842
8885
  * per-frame reconcile cost becomes O(selection) rather than O(document).
8843
8886
  */
8844
8887
  renderGraphicGroup(graphic) {
8888
+ const pinnable = isPinnableGraphic(graphic);
8889
+ const pinRevision = pinnable ? this.pins.revision(graphic.id) : void 0;
8845
8890
  const cached = this.graphicGroupCache.get(graphic);
8846
- if (cached) {
8891
+ if (cached && cached.pinRevision === pinRevision) {
8847
8892
  if (cached.dependence === "none") return cached.group;
8848
8893
  if (cached.dependence === "resolution" && Object.is(cached.resolution, this.adapter.getResolution())) return cached.group;
8849
8894
  }
8850
- const presentation = isPinnableGraphic(graphic) ? this.pins.resolve(graphic.id) : void 0;
8895
+ const presentation = pinnable ? this.pins.resolve(graphic.id) : void 0;
8851
8896
  const dependence = presentation && this.graphicUsesPinPresentation(graphic, presentation) ? "none" : graphicViewDependence(graphic, this.adapter.scalesGroundPointSymbolsNatively === true);
8852
8897
  const resolution = dependence === "none" ? void 0 : this.adapter.getResolution();
8853
8898
  const group = this.buildGraphicGroup(graphic, presentation);
8854
8899
  this.graphicGroupCache.set(graphic, {
8855
8900
  group,
8856
8901
  dependence,
8857
- resolution
8902
+ resolution,
8903
+ pinRevision
8858
8904
  });
8859
8905
  return group;
8860
8906
  }
@@ -1,4 +1,4 @@
1
- import { PatternId } from "@orbat-mapper/control-measures";
1
+ import { PatternId, TextAmplifiers } from "@orbat-mapper/control-measures";
2
2
  import { Feature, Position } from "geojson";
3
3
 
4
4
  //#region src/pin-presentation.d.ts
@@ -139,16 +139,181 @@ declare function resolvePinPresentation(...patches: readonly PinPresentationPatc
139
139
  /** Replacing patches makes omitted override properties inherit again. */
140
140
  declare class PinPresentationStore {
141
141
  private state;
142
+ /** Monotonic stamp source for {@link revision}. */
143
+ private revisions;
144
+ private defaultsRevision;
145
+ private readonly overrideRevisions;
142
146
  private readonly emitter;
143
147
  getState(): PinPresentationState;
144
148
  resolve(id: string): PinPresentation;
149
+ /**
150
+ * @internal A stamp that changes whenever {@link resolve} may return a
151
+ * different presentation for `id`, so a renderer can keep reusing the pins
152
+ * whose presentation a change left alone.
153
+ */
154
+ revision(id: string): number;
145
155
  replace(state: PinPresentationState): void;
146
156
  setDefaults(patch: PinPresentationPatch): void;
147
157
  setOverride(id: string, patch: PinOverridePatch): void;
148
158
  resetOverride(id: string): void;
159
+ /**
160
+ * Set several overrides, and with `null` reset them, as one validated change
161
+ * and one `onChange` emit. Each patch replaces that id's previous patch, as
162
+ * {@link setOverride} does; ids not named keep theirs. An invalid patch
163
+ * throws and leaves every override unchanged.
164
+ */
165
+ setOverrides(patches: Readonly<Record<string, PinOverridePatch | null>>): void;
149
166
  onChange(listener: (state: PinPresentationState) => void): () => void;
150
167
  }
151
168
  //#endregion
169
+ //#region src/point-symbol.d.ts
170
+ type PointSymbolSize = {
171
+ value: number;
172
+ unit: "pixels";
173
+ } | {
174
+ value: number;
175
+ unit: "meters"; /** Floor for the on-screen projection of the ground-based size; none when omitted. */
176
+ minPixels?: number; /** Cap on the on-screen projection of the ground-based size — typically the pixel size the symbol had when anchored to ground; unclamped when omitted. */
177
+ maxPixels?: number;
178
+ };
179
+ interface PointSymbolGraphicModifiers {
180
+ /** Radians clockwise, relative to the point symbol's own orientation. */
181
+ direction?: number;
182
+ }
183
+ interface PointSymbolColors {
184
+ fill?: string;
185
+ frame?: string;
186
+ icon?: string;
187
+ info?: string;
188
+ outline?: string;
189
+ }
190
+ interface PointSymbolStyle {
191
+ colors?: PointSymbolColors;
192
+ monoColor?: string;
193
+ opacity?: number;
194
+ /** 0–1 multiplier applied to both body and connector opacity; defaults to 1. */
195
+ overallOpacity?: number;
196
+ outlineWidth?: number;
197
+ fill?: boolean;
198
+ frame?: boolean;
199
+ icon?: boolean;
200
+ }
201
+ type PointSymbolPlacement = {
202
+ mode: "screen-relative";
203
+ offset: [number, number];
204
+ } | {
205
+ mode: "ground";
206
+ position: Position;
207
+ };
208
+ /** Modifier that temporarily activates offset placement for a body drag. */
209
+ type OffsetDragModifier = "alt" | "shift" | "ctrl" | "meta";
210
+ type PointSymbolConnector = "auto" | "direct";
211
+ /** Optional connector overrides; omitted properties inherit symbol styling. */
212
+ interface PointSymbolOffsetStyle {
213
+ strokeColor?: string;
214
+ /** 0–1, independent of the body opacity. */
215
+ opacity?: number;
216
+ /** Fixed CSS-pixel width, independent of symbol size. */
217
+ strokeWidth?: number;
218
+ /** Alternating dash/gap lengths in CSS pixels; [] means solid. */
219
+ strokeDash?: number[];
220
+ }
221
+ interface PointSymbolOffset {
222
+ /** Gap at the symbol attachment end, measured along the line in CSS pixels; defaults to 0. */
223
+ anchorPadding?: number;
224
+ style?: PointSymbolOffsetStyle;
225
+ placement: PointSymbolPlacement;
226
+ connector: PointSymbolConnector;
227
+ /** Authored indicator length as a multiple of the displayed octagon size. */
228
+ indicatorLength?: number;
229
+ }
230
+ interface PointSymbol {
231
+ id: string;
232
+ kind: "point-symbol";
233
+ sidc: string;
234
+ position: Position;
235
+ /** Normalized radians clockwise from geographic north. */
236
+ rotation: number;
237
+ /** Milsymbol's octagon-based L dimension. */
238
+ size: PointSymbolSize;
239
+ offset?: PointSymbolOffset;
240
+ textAmplifiers?: TextAmplifiers;
241
+ graphicModifiers?: PointSymbolGraphicModifiers;
242
+ style?: PointSymbolStyle;
243
+ rendererOptions?: {
244
+ milsymbol?: Record<string, unknown>;
245
+ };
246
+ properties?: Record<string, unknown>;
247
+ schemaVersion?: 1;
248
+ }
249
+ interface PointSymbolAnchor {
250
+ x: number;
251
+ y: number;
252
+ }
253
+ interface PointSymbolRect {
254
+ x: number;
255
+ y: number;
256
+ width: number;
257
+ height: number;
258
+ }
259
+ /** Canonical-size, renderer-neutral point-symbol output. */
260
+ interface PointSymbolRender {
261
+ /** Content-derived identity for adapter-wide native-resource reuse. */
262
+ resourceId: string;
263
+ svg: string;
264
+ /** Renderer-space octagon size used to interpret persisted symbol size. */
265
+ octagonSize: number;
266
+ width: number;
267
+ height: number;
268
+ /**
269
+ * Visible content box in canonical SVG units, relative to the image's
270
+ * top-left. Footprints, hit tests and edit boxes use it, so transparent
271
+ * padding (e.g. room for a soft halo) is not clickable; the image itself is
272
+ * still drawn at `width × height`. Defaults to the full image.
273
+ */
274
+ contentBounds?: PointSymbolRect;
275
+ anchor: PointSymbolAnchor;
276
+ octagonAnchor: PointSymbolAnchor;
277
+ valid: boolean;
278
+ validation?: unknown;
279
+ /** Optional body/attachment capability. All coordinates are canonical SVG units. */
280
+ offset?: {
281
+ body: PointSymbolRender; /** Body registration in the ordinary image, preserving natural HQ placement. */
282
+ ordinaryRegistration: PointSymbolAnchor;
283
+ attachment: PointSymbolAnchor;
284
+ indicator?: {
285
+ direction: PointSymbolAnchor;
286
+ length: number;
287
+ minLength?: number;
288
+ };
289
+ strokeColor: string;
290
+ strokeWidth: number;
291
+ };
292
+ }
293
+ interface PointSymbolCapability {
294
+ readonly defaultSize: PointSymbolSize;
295
+ readonly defaultRotation: number;
296
+ render(symbol: PointSymbol): PointSymbolRender;
297
+ invalidate(): void;
298
+ /**
299
+ * Monotonic counter that increments on each `invalidate()` call. Consumers
300
+ * (e.g. a render cache keyed on graphic snapshot identity) may read this to
301
+ * detect that previously rendered point-symbol output is stale even though
302
+ * the graphic snapshot itself is unchanged. Optional — when absent,
303
+ * invalidation cannot be detected by cache layers, so they must not attempt
304
+ * to key on it.
305
+ */
306
+ readonly generation?: number;
307
+ }
308
+ declare function isPointSymbol(graphic: unknown): graphic is PointSymbol;
309
+ declare function clonePointSymbol(symbol: PointSymbol): PointSymbol;
310
+ /**
311
+ * Replace a point-symbol size value as a user-driven resize. Ground-size display
312
+ * bounds scale with the value so they continue to constrain zoom changes rather
313
+ * than preventing the resize itself.
314
+ */
315
+ declare function resizePointSymbolSize(size: PointSymbolSize, value: number): PointSymbolSize;
316
+ //#endregion
152
317
  //#region src/gestures/types.d.ts
153
318
  interface PointerEventInfo {
154
319
  /** Per-event hit-tolerance override (e.g. larger for touch). */
@@ -340,17 +505,19 @@ interface IconResource {
340
505
  width: number;
341
506
  height: number;
342
507
  anchor: [number, number];
508
+ /**
509
+ * Visible content box in unscaled canvas coordinates. Icon picks and their
510
+ * footprints use it instead of the full canvas, so transparent padding is not
511
+ * hit area; the icon is still drawn at `width × height`. Defaults to the full
512
+ * canvas.
513
+ */
514
+ contentRect?: PointSymbolRect;
343
515
  /**
344
516
  * Direct visible mark used to rank icon picks, in unscaled canvas coordinates.
345
517
  * Hits elsewhere in the full canvas measure their distance from this rectangle;
346
518
  * omit it to preserve whole-canvas distance-zero behavior.
347
519
  */
348
- coreRect?: {
349
- x: number;
350
- y: number;
351
- width: number;
352
- height: number;
353
- };
520
+ coreRect?: PointSymbolRect;
354
521
  }
355
522
  /** A self-contained image fixed to four geographic corners, ordered TL/TR/BR/BL. */
356
523
  interface ImageOverlayResource {
@@ -562,4 +729,4 @@ interface MapAdapter {
562
729
  getLayerFeatures(layerId: LayerId): readonly Feature[];
563
730
  }
564
731
  //#endregion
565
- export { PinOverridePatch as A, isValidPinNumber as B, makeFillPatternImage as C, PointerEventInfo as D, PointerCallback as E, PinPresentationStatus as F, pinZoomScale as H, PinPresentationStatusEvent as I, PinPresentationStore as L, PinPresentationCapability as M, PinPresentationPatch as N, DEFAULT_PIN_PRESENTATION as O, PinPresentationState as P, PinRender as R, isMinePattern as S, EditPointerDriver as T, resolvePinPresentation as U, pinDistanceScale as V, HatchPattern as _, LayerId as a, fillPatternImageDimension as b, MapEvent as c, PickHandler as d, PickOptions as f, HATCH_PATTERNS as g, TextStyleOptions as h, ImageOverlayResource as i, PinPresentation as j, PinFootprint as k, MapEventHandler as l, StyleOptions as m, HandleStyle as n, MapAdapter as o, PixelCoordinate as p, IconResource as r, MapCursor as s, FeatureGroup as t, PickEvent as u, MINE_PATTERN_TILE_SIZE as v, parseColor as w, fillPatternImageId as x, Rgba as y, combinePinScale as z };
732
+ export { PinPresentationStatusEvent as $, PointSymbolAnchor as A, PointSymbolSize as B, makeFillPatternImage as C, PointerEventInfo as D, PointerCallback as E, PointSymbolOffset as F, DEFAULT_PIN_PRESENTATION as G, clonePointSymbol as H, PointSymbolOffsetStyle as I, PinPresentation as J, PinFootprint as K, PointSymbolPlacement as L, PointSymbolColors as M, PointSymbolConnector as N, OffsetDragModifier as O, PointSymbolGraphicModifiers as P, PinPresentationStatus as Q, PointSymbolRect as R, isMinePattern as S, EditPointerDriver as T, isPointSymbol as U, PointSymbolStyle as V, resizePointSymbolSize as W, PinPresentationPatch as X, PinPresentationCapability as Y, PinPresentationState as Z, HatchPattern as _, LayerId as a, pinZoomScale as at, fillPatternImageDimension as b, MapEvent as c, PickHandler as d, PinPresentationStore as et, PickOptions as f, HATCH_PATTERNS as g, TextStyleOptions as h, ImageOverlayResource as i, pinDistanceScale as it, PointSymbolCapability as j, PointSymbol as k, MapEventHandler as l, StyleOptions as m, HandleStyle as n, combinePinScale as nt, MapAdapter as o, resolvePinPresentation as ot, PixelCoordinate as p, PinOverridePatch as q, IconResource as r, isValidPinNumber as rt, MapCursor as s, FeatureGroup as t, PinRender as tt, PickEvent as u, MINE_PATTERN_TILE_SIZE as v, parseColor as w, fillPatternImageId as x, Rgba as y, PointSymbolRender as z };
@@ -1,4 +1,4 @@
1
- import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-Cos4xrCn.mjs";
1
+ import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-D6pkU0iz.mjs";
2
2
  import { Feature } from "geojson";
3
3
 
4
4
  //#region src/testing/feature-group-conformance.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-draw",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
5
5
  "license": "MIT",
6
6
  "author": "Orbat Mapper",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@orbat-mapper/control-measures": "^0.35.0"
42
+ "@orbat-mapper/control-measures": "^0.36.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": ">=4.0.0"