@orbat-mapper/tactical-draw 0.22.1 → 0.23.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.
Files changed (2) hide show
  1. package/dist/index.mjs +34 -10
  2. package/package.json +4 -3
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_HIGHLIGHT_WIDTH, DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_SYMBOL_COLOR, FILL_PATTERN_DEFINITIONS, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureOptionHandles, getDefaultOptions, normalizeTextAmplifiers, remapVertexAlignedOptions, renderControlMeasure, resetControlMeasureOptionHandle, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, resolveSymbolColor, roundToFixed, switchSizePairUnit } from "@orbat-mapper/control-measures";
1
+ import { DEFAULT_HIGHLIGHT_WIDTH, DEFAULT_LABEL_HEIGHT_CSS_PIXELS, DEFAULT_SYMBOL_COLOR, FILL_PATTERN_DEFINITIONS, LABEL_FADE_END_RATIO, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureOptionHandles, getDefaultOptions, labelSizeBandHideThreshold, normalizeTextAmplifiers, remapVertexAlignedOptions, renderControlMeasure, resetControlMeasureOptionHandle, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, resolveSymbolColor, roundToFixed, switchSizePairUnit } from "@orbat-mapper/control-measures";
2
2
  function pickPointerType(originalEvent) {
3
3
  if (typeof PointerEvent !== "undefined" && originalEvent instanceof PointerEvent) {
4
4
  if (originalEvent.pointerType === "touch") return "touch";
@@ -776,7 +776,7 @@ const DEFAULT_TEXT_SIZE_MAX_PIXELS = 24;
776
776
  * Share of the band minimum at which a fading ground label reaches zero
777
777
  * opacity and hides (ADR-0060): 4 px fades out to nothing at 3.2 px.
778
778
  */
779
- const TEXT_FADE_END_RATIO = .8;
779
+ const TEXT_FADE_END_RATIO = LABEL_FADE_END_RATIO;
780
780
  /**
781
781
  * Ground label size `textSizeMeters / resolution`, pinned to both edges of
782
782
  * the band. The fixed-scale rule behind [[resolveTextAppearance]]'s
@@ -789,6 +789,19 @@ function resolveGroundTextSizePixels(textSizeMeters, resolution, text) {
789
789
  return Math.min(max, Math.max(min, textSizeMeters / resolution));
790
790
  }
791
791
  /**
792
+ * `band` as the render context's label size band (ADR-0064): how an
793
+ * interactive map draws ground labels, pinned at the maximum and hiding below
794
+ * the minimum. Generators then size knockouts to the text on screen and drop
795
+ * them once the text hides.
796
+ */
797
+ function interactiveLabelSizeBand(band) {
798
+ return {
799
+ min: band?.textSizeMinPixels ?? 4,
800
+ max: band?.textSizeMaxPixels ?? 24,
801
+ belowMin: "hide"
802
+ };
803
+ }
804
+ /**
792
805
  * Resolve how a label renders on an interactive map at `resolution`, or
793
806
  * `null` when it should render nothing this frame:
794
807
  *
@@ -828,7 +841,7 @@ function resolveTextAppearance(props, resolution, policy) {
828
841
  sizePixels: Math.min(max, px),
829
842
  opacity: 1
830
843
  };
831
- const fadeEnd = min * TEXT_FADE_END_RATIO;
844
+ const fadeEnd = labelSizeBandHideThreshold(interactiveLabelSizeBand(props));
832
845
  if (px <= fadeEnd) return null;
833
846
  return {
834
847
  sizePixels: px,
@@ -2084,7 +2097,8 @@ function canResetGroundSizes(measure, adapter) {
2084
2097
  * Return the complete option record produced by resetting every known size
2085
2098
  * pair to its default on-screen appearance at the adapter's current
2086
2099
  * resolution. Pixel keys are removed and meter keys are written, so the
2087
- * result remains ground-anchored. Unrelated options are preserved.
2100
+ * result remains ground-anchored. A pair that inherits another pair's size is
2101
+ * cleared so it follows again. Unrelated options are preserved.
2088
2102
  *
2089
2103
  * Returns `undefined` when the kind has no resettable sizes or the adapter has
2090
2104
  * no usable resolution.
@@ -2096,6 +2110,11 @@ function resetGroundSizeOptions(measure, adapter) {
2096
2110
  const defaults = getDefaultOptions(measure.kind);
2097
2111
  const next = { ...measure.options ?? {} };
2098
2112
  for (const spec of specs) {
2113
+ if (spec.inheritsFrom !== void 0) {
2114
+ delete next[spec.pixels];
2115
+ delete next[spec.meters];
2116
+ continue;
2117
+ }
2099
2118
  const defaultPixels = spec.defaultUnit === "px" && spec.defaultValue !== void 0 ? spec.defaultValue : defaults[spec.pixels];
2100
2119
  if (typeof defaultPixels !== "number") continue;
2101
2120
  const result = switchSizePairUnit({
@@ -2129,7 +2148,7 @@ function measureUsesAdapterResolution(measure) {
2129
2148
  return sizeOptionSpecs(measure.kind).some((spec) => {
2130
2149
  if (options?.[spec.pixels] !== void 0) return true;
2131
2150
  if (options?.[spec.meters] !== void 0) return false;
2132
- return !spec.captureOnDraw && spec.defaultUnit === "px";
2151
+ return !spec.captureOnDraw && spec.inheritsFrom === void 0 && spec.defaultUnit === "px";
2133
2152
  });
2134
2153
  }
2135
2154
  /**
@@ -2175,14 +2194,15 @@ function defaultSizeAnchor(measure) {
2175
2194
  }
2176
2195
  /**
2177
2196
  * Materialize uncaptured pixel authoring defaults before commit, so the ground
2178
- * bake sees an explicit value. Meter-default dimensions and authored values
2179
- * remain unchanged; captured labels have their separate render/commit seam.
2197
+ * bake sees an explicit value. Meter-default dimensions, pairs that inherit
2198
+ * another pair's size, and authored values remain unchanged; captured labels
2199
+ * have their separate render/commit seam.
2180
2200
  */
2181
2201
  function withDefaultAuthoringSize(measure) {
2182
2202
  let options = measure.options ?? {};
2183
2203
  let changed = false;
2184
2204
  for (const spec of sizeOptionSpecs(measure.kind)) {
2185
- if (spec.captureOnDraw || spec.defaultUnit !== "px") continue;
2205
+ if (spec.captureOnDraw || spec.inheritsFrom !== void 0 || spec.defaultUnit !== "px") continue;
2186
2206
  if (options[spec.pixels] !== void 0 || options[spec.meters] !== void 0) continue;
2187
2207
  const resolved = resolveSizePair({
2188
2208
  kind: measure.kind,
@@ -8903,7 +8923,8 @@ var TacticalDraw = class {
8903
8923
  this.sessionRenderOptions = {
8904
8924
  graphicsStyle: this.graphicsStyle,
8905
8925
  symbolColors: this.symbolColors,
8906
- highlightAppearance: { ...options?.highlightAppearance }
8926
+ highlightAppearance: { ...options?.highlightAppearance },
8927
+ context: { labelSizeBand: interactiveLabelSizeBand(this.labelSizeBand) }
8907
8928
  };
8908
8929
  this.defaultInteractionStyle = options?.interactionStyle;
8909
8930
  this.generateId = options?.generateId ?? (() => `td-${++this.idCounter}`);
@@ -9150,7 +9171,10 @@ var TacticalDraw = class {
9150
9171
  }
9151
9172
  const render = renderMeasureForAdapter(this.adapter, graphic, {
9152
9173
  ...this.sessionRenderOptions,
9153
- context: { labelFit: this.labelFit }
9174
+ context: {
9175
+ ...this.sessionRenderOptions.context,
9176
+ labelFit: this.labelFit
9177
+ }
9154
9178
  });
9155
9179
  return {
9156
9180
  id: graphic.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-draw",
3
- "version": "0.22.1",
3
+ "version": "0.23.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.38.0"
42
+ "@orbat-mapper/control-measures": "^0.39.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": ">=4.0.0"
@@ -62,6 +62,7 @@
62
62
  "scripts": {
63
63
  "build": "tsdown",
64
64
  "test": "vitest run",
65
- "lint": "eslint . --fix"
65
+ "lint": "eslint . --fix",
66
+ "typecheck": "tsc --noEmit"
66
67
  }
67
68
  }