@orbat-mapper/tactical-draw 0.5.2 → 0.5.4

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 +26 -2
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1935,7 +1935,7 @@ const PREVIEW_CURSOR$1 = "crosshair";
1935
1935
  * kinds need no host UI.
1936
1936
  */
1937
1937
  function runFixedLengthDraw(options) {
1938
- const { adapter, kind, previewLayer, guideLayer, graphicsStyle, generateId, signal, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, onSession, snap } = options;
1938
+ const { adapter, kind, previewLayer, guideLayer, graphicsStyle, generateId, signal, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, onSession, seed, snap } = options;
1939
1939
  const metadata = getControlMeasureMetadata(kind);
1940
1940
  const rule = metadata.rule;
1941
1941
  const min = metadata.minCoordinates;
@@ -1947,7 +1947,26 @@ function runFixedLengthDraw(options) {
1947
1947
  const renderOpts = graphicsStyle ? { graphicsStyle } : void 0;
1948
1948
  const guideEnabled = (guideOpt ?? true) && !shouldSuppressGuide(metadata);
1949
1949
  const isAreaKind = metadata.geometry === "area";
1950
- const committed = [];
1950
+ const initialPoints = [];
1951
+ if (seed) {
1952
+ for (const pos of seed) {
1953
+ if (!isValidPosition$1(pos)) throw new TypeError(`td.draw: seed contains invalid coordinate ${JSON.stringify(pos)}`);
1954
+ initialPoints.push([...pos]);
1955
+ }
1956
+ if (typeof max === "number" && initialPoints.length > max) throw new RangeError(`td.draw: seed has ${initialPoints.length} points but kind "${kind}" allows at most ${max}`);
1957
+ if (initialPoints.length >= (min ?? required)) renderMeasureForAdapter(adapter, {
1958
+ id: PREVIEW_CM_ID$1,
1959
+ kind,
1960
+ controlPoints: initialPoints.map((p) => [...p]),
1961
+ ...measureOptions !== void 0 ? { options: measureOptions } : {},
1962
+ ...measureStyle !== void 0 ? { style: measureStyle } : {},
1963
+ ...measureTextAmplifiers !== void 0 ? { textAmplifiers: measureTextAmplifiers } : {}
1964
+ }, {
1965
+ ...renderOpts,
1966
+ validationMode: "throw"
1967
+ });
1968
+ }
1969
+ const committed = initialPoints;
1951
1970
  let rubberBand;
1952
1971
  let ctx;
1953
1972
  const savedCursor = "";
@@ -2122,6 +2141,7 @@ function runFixedLengthDraw(options) {
2122
2141
  adapter.setCursor(PREVIEW_CURSOR$1);
2123
2142
  adapter.on("click", handleClick);
2124
2143
  adapter.on("pointermove", handlePointerMove);
2144
+ if (committed.length > 0) renderPreview();
2125
2145
  if (onSession) onSession(session);
2126
2146
  }
2127
2147
  });
@@ -2133,6 +2153,9 @@ function positionsEqual$1(a, b) {
2133
2153
  if (az === void 0 && bz === void 0) return true;
2134
2154
  return az === bz;
2135
2155
  }
2156
+ function isValidPosition$1(value) {
2157
+ return Array.isArray(value) && value.length >= 2 && typeof value[0] === "number" && Number.isFinite(value[0]) && typeof value[1] === "number" && Number.isFinite(value[1]) && (value[2] === void 0 || typeof value[2] === "number" && Number.isFinite(value[2]));
2158
+ }
2136
2159
  /**
2137
2160
  * Produce preview features for the partial geometry. Tries the full renderer
2138
2161
  * first so the preview looks like the real symbol once enough points are in;
@@ -7590,6 +7613,7 @@ var TacticalDraw = class {
7590
7613
  sizeAnchor: options?.sizeAnchor,
7591
7614
  onSettled,
7592
7615
  onSession: this.trackSession(options?.onSession),
7616
+ seed: measureDraft.controlPoints,
7593
7617
  snap: this.resolveSnap
7594
7618
  }) : runVariableLengthDraw({
7595
7619
  adapter: this.adapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbat-mapper/tactical-draw",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
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.14.0"
42
+ "@orbat-mapper/control-measures": "^0.15.1"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": ">=4.0.0"