@orbat-mapper/tactical-draw 0.5.7 → 0.6.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
@@ -544,7 +544,8 @@ declare const DEFAULT_LABEL_SIZE_PIXELS = 14;
544
544
  * on zoom. `screen` means a pixel size held constant on screen — re-rendered
545
545
  * against the live `metersPerPixel` on every view change. A draw/edit drawn in
546
546
  * pixels resolves (`bakes`) to a `ground` anchor on commit unless the caller
547
- * asks to stay `screen`.
547
+ * asks to stay `screen`. Edits of uniformly sized symbols retain their authored
548
+ * unit by default (ADR-0052).
548
549
  */
549
550
  type SizeAnchor = "ground" | "screen";
550
551
  /**
@@ -1394,7 +1395,7 @@ interface EditOptions {
1394
1395
  * `DrawOptions.sizeAnchor`: editing a screen-anchored graphic as `"ground"`
1395
1396
  * bakes/freezes it to meters; editing a ground graphic whose working options
1396
1397
  * have been switched to pixels as `"screen"` keeps the pixel size. Default
1397
- * `"ground"`. Applied to the resolved snapshot only — the in-flight preview
1398
+ * `"ground"`, except uniformly sized symbols retain their authored unit. Applied to the resolved snapshot only — the in-flight preview
1398
1399
  * stays screen-anchored throughout the edit.
1399
1400
  */
1400
1401
  sizeAnchor?: SizeAnchor;
@@ -1422,7 +1423,7 @@ interface EditManyOptions {
1422
1423
  closeOnClickAway?: boolean;
1423
1424
  /** Per-call interaction style override scoped to this transform. See ADR-0006. */
1424
1425
  interactionStyle?: InteractionStyle;
1425
- /** Size anchor for the committed measures (ADR-0020), applied group-wide. Default `"ground"`. */
1426
+ /** Size anchor for ordinary control measures in the group. Uniform symbols retain their own unit. Default `"ground"`. */
1426
1427
  sizeAnchor?: SizeAnchor;
1427
1428
  }
1428
1429
  /**
package/dist/index.mjs CHANGED
@@ -1102,6 +1102,22 @@ const PIXEL_SIZE_OPTIONS = {
1102
1102
  pixels: "toothHeightPixels",
1103
1103
  meters: "toothHeight"
1104
1104
  },
1105
+ destroy: {
1106
+ pixels: "sizePixels",
1107
+ meters: "sizeMeters"
1108
+ },
1109
+ defeat: {
1110
+ pixels: "sizePixels",
1111
+ meters: "sizeMeters"
1112
+ },
1113
+ neutralize: {
1114
+ pixels: "sizePixels",
1115
+ meters: "sizeMeters"
1116
+ },
1117
+ suppress: {
1118
+ pixels: "sizePixels",
1119
+ meters: "sizeMeters"
1120
+ },
1105
1121
  minefield: {
1106
1122
  pixels: "sizePixels",
1107
1123
  meters: "sizeMeters"
@@ -1233,6 +1249,10 @@ function measureRendersFromViewState(measure) {
1233
1249
  function getSizeAnchor(measure) {
1234
1250
  return measureUsesAdapterResolution(measure) ? "screen" : "ground";
1235
1251
  }
1252
+ /** Uniform symbols retain their authored unit unless a caller explicitly changes it. */
1253
+ function defaultSizeAnchor(measure) {
1254
+ return getControlMeasureMetadata(measure.kind).uniformSizing ? getSizeAnchor(measure) : "ground";
1255
+ }
1236
1256
  /**
1237
1257
  * Materialise a *pixel-authored* kind's default pixel size onto a measure that
1238
1258
  * carries neither size key, so the ADR-0020 ground bake has a pixel value to
@@ -3983,7 +4003,7 @@ const ALLOWED_EDIT_MODES = new Set([
3983
4003
  function runEdit(opts) {
3984
4004
  const { adapter, measure, graphicsLayer, previewLayer, guideLayer, handlesLayer, graphicsStyle, signal, closeOnClickAway = true, modes: initialModes, interactionStyle, onSession, handleIdPrefix, guide: guideOpt, settleToGraphics, publishWorkingGraphic, onSettled, onClickAwayGraphicsPick, snap } = opts;
3985
4005
  const renderOpts = graphicsStyle ? { graphicsStyle } : void 0;
3986
- let sizeAnchor = opts.sizeAnchor ?? "ground";
4006
+ let sizeAnchor = opts.sizeAnchor ?? defaultSizeAnchor(measure);
3987
4007
  const metadata = getControlMeasureMetadata(measure.kind);
3988
4008
  const rule = metadata.rule;
3989
4009
  const midpointHandlesEnabled = rule?.canonicalPointCount === void 0;
@@ -5489,6 +5509,17 @@ function scalePointSymbolStates(pre, scale, rotation) {
5489
5509
  } : null);
5490
5510
  }
5491
5511
  /**
5512
+ * Seed the group's single `sizeAnchor` scalar, which the session exposes and the
5513
+ * UI reflects. Only a lone control measure has an unambiguous authored unit to
5514
+ * honour (ADR-0052); a mixed or multi-member group falls back to `"ground"`.
5515
+ * Per-member commits consult `uniformSizing` directly, so this only decides the
5516
+ * starting state of the exposed toggle.
5517
+ */
5518
+ function defaultGroupSizeAnchor(graphics) {
5519
+ const only = graphics.length === 1 ? graphics[0] : void 0;
5520
+ return only && !isAnchoredGraphic(only) ? defaultSizeAnchor(only) : "ground";
5521
+ }
5522
+ /**
5492
5523
  * Drive an interactive group transform against a `MapAdapter` — the leaner,
5493
5524
  * multi-select sibling of `runEdit` (ADR-0017 "Multi-select" slice). No
5494
5525
  * reshape, no per-vertex handles, no guide layer, no per-measure
@@ -5515,7 +5546,7 @@ function runGroupTransform(opts) {
5515
5546
  assertCapabilityFor(graphics);
5516
5547
  validateImageResources(graphics);
5517
5548
  const renderOpts = graphicsStyle ? { graphicsStyle } : void 0;
5518
- let sizeAnchor = opts.sizeAnchor ?? "ground";
5549
+ let sizeAnchor = opts.sizeAnchor ?? defaultGroupSizeAnchor(graphics);
5519
5550
  /** Throw synchronously if any graphic in `list` is a point symbol and no capability was supplied. */
5520
5551
  function assertCapabilityFor(list) {
5521
5552
  if (!capability && list.some(isPointSymbol)) throw new PointSymbolCapabilityRequiredError();
@@ -5630,7 +5661,7 @@ function runGroupTransform(opts) {
5630
5661
  };
5631
5662
  }
5632
5663
  const working = buildWorkingMeasureWith(member, override);
5633
- const committed = sizeAnchor === "screen" ? working : bakePixelSizeToGround(working, adapter);
5664
+ const committed = getControlMeasureMetadata(working.kind).uniformSizing || sizeAnchor === "screen" ? working : bakePixelSizeToGround(working, adapter);
5634
5665
  return {
5635
5666
  graphic: cloneControlMeasure(committed),
5636
5667
  render: renderMeasureForAdapter(adapter, committed, renderOpts)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-draw",
3
- "version": "0.5.7",
3
+ "version": "0.6.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.18.0"
42
+ "@orbat-mapper/control-measures": "^0.20.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": ">=4.0.0"