@orbat-mapper/tactical-draw 0.6.2 → 0.7.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 +4 -1
- package/dist/index.mjs +37 -16
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as EditPointerDriver, S as makeFillPatternImage, T as PointerEventInfo, _ as HatchPattern, a as LayerId, b as fillPatternImageId, 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 MINE_PATTERN_TILE_SIZE, w as PointerCallback, x as isMinePattern, y as fillPatternImageDimension } from "./map-adapter-BWvKku2P.mjs";
|
|
2
|
-
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
2
|
+
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
|
5
5
|
//#region src/base-map-adapter.d.ts
|
|
@@ -1333,6 +1333,8 @@ interface TacticalDrawOptions {
|
|
|
1333
1333
|
* appearance when neither the host nor the measure supplies a style.
|
|
1334
1334
|
*/
|
|
1335
1335
|
graphicsStyle?: ControlMeasureStyle;
|
|
1336
|
+
/** Doctrinal defaults; explicit style colors take precedence. */
|
|
1337
|
+
symbolColors?: SymbolColors;
|
|
1336
1338
|
/**
|
|
1337
1339
|
* Façade-level default interaction-affordance style. Per-slot, per-property
|
|
1338
1340
|
* merged with `DrawOptions.interactionStyle` / `EditOptions.interactionStyle`
|
|
@@ -1498,6 +1500,7 @@ declare class TacticalDraw {
|
|
|
1498
1500
|
private readonly handlesLayer;
|
|
1499
1501
|
private readonly ownedLayers;
|
|
1500
1502
|
private readonly graphicsStyle;
|
|
1503
|
+
private readonly symbolColors;
|
|
1501
1504
|
private readonly defaultInteractionStyle;
|
|
1502
1505
|
private readonly generateId;
|
|
1503
1506
|
private readonly pointSymbols;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_LABEL_HEIGHT_CSS_PIXELS, FILL_PATTERN_DEFINITIONS, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureOptionHandles, getDefaultOptions, normalizeTextAmplifiers, renderControlMeasure, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, roundToFixed, switchSizePairUnit } from "@orbat-mapper/control-measures";
|
|
1
|
+
import { 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, renderControlMeasure, resolveAmplifierPlacement, resolveSizePair, resolveStyleHints, 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";
|
|
@@ -1878,7 +1878,7 @@ const PREVIEW_CURSOR$1 = "crosshair";
|
|
|
1878
1878
|
* kinds need no host UI.
|
|
1879
1879
|
*/
|
|
1880
1880
|
function runFixedLengthDraw(options) {
|
|
1881
|
-
const { adapter, kind, previewLayer, guideLayer, graphicsStyle, generateId, signal, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, onSession, seed, snap } = options;
|
|
1881
|
+
const { adapter, kind, previewLayer, guideLayer, graphicsStyle, symbolColors, generateId, signal, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, onSession, seed, snap } = options;
|
|
1882
1882
|
const metadata = getControlMeasureMetadata(kind);
|
|
1883
1883
|
const rule = metadata.rule;
|
|
1884
1884
|
const min = metadata.minCoordinates;
|
|
@@ -1887,7 +1887,10 @@ function runFixedLengthDraw(options) {
|
|
|
1887
1887
|
if (rule) required = rule.minimumUserPoints;
|
|
1888
1888
|
else if (typeof min === "number" && typeof max === "number" && min === max) required = min;
|
|
1889
1889
|
else throw new Error(`runFixedLengthDraw: kind "${kind}" is not fixed-length (min=${min}, max=${max})`);
|
|
1890
|
-
const renderOpts =
|
|
1890
|
+
const renderOpts = {
|
|
1891
|
+
graphicsStyle,
|
|
1892
|
+
symbolColors
|
|
1893
|
+
};
|
|
1891
1894
|
const guideEnabled = (guideOpt ?? true) && !shouldSuppressGuide(metadata);
|
|
1892
1895
|
const isAreaKind = metadata.geometry === "area";
|
|
1893
1896
|
const initialPoints = [];
|
|
@@ -2155,7 +2158,7 @@ const PREVIEW_CURSOR = "crosshair";
|
|
|
2155
2158
|
* added point again" as additional gesture-level commit triggers.
|
|
2156
2159
|
*/
|
|
2157
2160
|
function runVariableLengthDraw(options) {
|
|
2158
|
-
const { adapter, kind, previewLayer, guideLayer, graphicsStyle, generateId, signal, onSession, seed, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, snap } = options;
|
|
2161
|
+
const { adapter, kind, previewLayer, guideLayer, graphicsStyle, symbolColors, generateId, signal, onSession, seed, measureOptions, measureStyle, measureProperties, measureTextAmplifiers, guide: guideOpt, sizeAnchor, onSettled, snap } = options;
|
|
2159
2162
|
const metadata = getControlMeasureMetadata(kind);
|
|
2160
2163
|
if (typeof metadata.minCoordinates !== "number") throw new Error(`runVariableLengthDraw: kind "${kind}" has no minCoordinates metadata`);
|
|
2161
2164
|
const min = metadata.minCoordinates;
|
|
@@ -2173,7 +2176,10 @@ function runVariableLengthDraw(options) {
|
|
|
2173
2176
|
function insertionIndex(len) {
|
|
2174
2177
|
return canonicalFormed(len) ? len - trailingFixed : len;
|
|
2175
2178
|
}
|
|
2176
|
-
const renderOpts =
|
|
2179
|
+
const renderOpts = {
|
|
2180
|
+
graphicsStyle,
|
|
2181
|
+
symbolColors
|
|
2182
|
+
};
|
|
2177
2183
|
const initialPoints = [];
|
|
2178
2184
|
if (seed) {
|
|
2179
2185
|
for (const pos of seed) {
|
|
@@ -3914,8 +3920,11 @@ const ALLOWED_EDIT_MODES = new Set([
|
|
|
3914
3920
|
* - close / abort / signal / preempt / destroy paths
|
|
3915
3921
|
*/
|
|
3916
3922
|
function runEdit(opts) {
|
|
3917
|
-
const { adapter, measure, graphicsLayer, previewLayer, guideLayer, handlesLayer, graphicsStyle, signal, closeOnClickAway = true, modes: initialModes, interactionStyle, onSession, handleIdPrefix, guide: guideOpt, settleToGraphics, publishWorkingGraphic, onSettled, onClickAwayGraphicsPick, snap } = opts;
|
|
3918
|
-
const renderOpts =
|
|
3923
|
+
const { adapter, measure, graphicsLayer, previewLayer, guideLayer, handlesLayer, graphicsStyle, symbolColors, signal, closeOnClickAway = true, modes: initialModes, interactionStyle, onSession, handleIdPrefix, guide: guideOpt, settleToGraphics, publishWorkingGraphic, onSettled, onClickAwayGraphicsPick, snap } = opts;
|
|
3924
|
+
const renderOpts = {
|
|
3925
|
+
graphicsStyle,
|
|
3926
|
+
symbolColors
|
|
3927
|
+
};
|
|
3919
3928
|
let sizeAnchor = opts.sizeAnchor ?? defaultSizeAnchor(measure);
|
|
3920
3929
|
const metadata = getControlMeasureMetadata(measure.kind);
|
|
3921
3930
|
const rule = metadata.rule;
|
|
@@ -5455,10 +5464,13 @@ function defaultGroupSizeAnchor(graphics) {
|
|
|
5455
5464
|
* a live session without a session boundary
|
|
5456
5465
|
*/
|
|
5457
5466
|
function runGroupTransform(opts) {
|
|
5458
|
-
const { adapter, capability, imageCapability, graphics, graphicsLayer, previewLayer, handlesLayer, graphicsStyle, signal, closeOnClickAway = true, interactionStyle, onSession, handleIdPrefix, publishWorkingGraphics, settleWorkingGraphics, isOnGraphicsLayer, onSettled, onClickAwayGraphicsPick } = opts;
|
|
5467
|
+
const { adapter, capability, imageCapability, graphics, graphicsLayer, previewLayer, handlesLayer, graphicsStyle, symbolColors, signal, closeOnClickAway = true, interactionStyle, onSession, handleIdPrefix, publishWorkingGraphics, settleWorkingGraphics, isOnGraphicsLayer, onSettled, onClickAwayGraphicsPick } = opts;
|
|
5459
5468
|
assertCapabilityFor(graphics);
|
|
5460
5469
|
validateImageResources(graphics);
|
|
5461
|
-
const renderOpts =
|
|
5470
|
+
const renderOpts = {
|
|
5471
|
+
graphicsStyle,
|
|
5472
|
+
symbolColors
|
|
5473
|
+
};
|
|
5462
5474
|
let sizeAnchor = opts.sizeAnchor ?? defaultGroupSizeAnchor(graphics);
|
|
5463
5475
|
/** Throw synchronously if any graphic in `list` is a point symbol and no capability was supplied. */
|
|
5464
5476
|
function assertCapabilityFor(list) {
|
|
@@ -6982,6 +6994,7 @@ var TacticalDraw = class {
|
|
|
6982
6994
|
handlesLayer;
|
|
6983
6995
|
ownedLayers;
|
|
6984
6996
|
graphicsStyle;
|
|
6997
|
+
symbolColors;
|
|
6985
6998
|
defaultInteractionStyle;
|
|
6986
6999
|
generateId;
|
|
6987
7000
|
pointSymbols;
|
|
@@ -7072,6 +7085,7 @@ var TacticalDraw = class {
|
|
|
7072
7085
|
hasHighlightOutlines = false;
|
|
7073
7086
|
constructor(adapter, options) {
|
|
7074
7087
|
this.adapter = adapter;
|
|
7088
|
+
this.symbolColors = options?.symbolColors ? { ...options.symbolColors } : void 0;
|
|
7075
7089
|
this.lastViewResolution = adapter.getResolution();
|
|
7076
7090
|
this.graphicsStyle = resolveStyleHints(BUILT_IN_GRAPHICS_STYLE, options?.graphicsStyle, void 0);
|
|
7077
7091
|
this.defaultInteractionStyle = options?.interactionStyle;
|
|
@@ -7168,7 +7182,10 @@ var TacticalDraw = class {
|
|
|
7168
7182
|
revision
|
|
7169
7183
|
};
|
|
7170
7184
|
}
|
|
7171
|
-
const render = renderMeasureForAdapter(this.adapter, graphic, {
|
|
7185
|
+
const render = renderMeasureForAdapter(this.adapter, graphic, {
|
|
7186
|
+
graphicsStyle: this.graphicsStyle,
|
|
7187
|
+
symbolColors: this.symbolColors
|
|
7188
|
+
});
|
|
7172
7189
|
return {
|
|
7173
7190
|
id: graphic.id,
|
|
7174
7191
|
features: render.features,
|
|
@@ -7412,7 +7429,10 @@ var TacticalDraw = class {
|
|
|
7412
7429
|
if (!this.images) return null;
|
|
7413
7430
|
return imageFootprint(graphic, renderImageForAdapter(this.adapter, this.images, graphic).render, this.adapter)?.box ?? null;
|
|
7414
7431
|
}
|
|
7415
|
-
const render = renderMeasureForAdapter(this.adapter, graphic, {
|
|
7432
|
+
const render = renderMeasureForAdapter(this.adapter, graphic, {
|
|
7433
|
+
graphicsStyle: this.graphicsStyle,
|
|
7434
|
+
symbolColors: this.symbolColors
|
|
7435
|
+
});
|
|
7416
7436
|
if (graphic.kind === "text") return fitTextFootprintFromFeatures(render.features, (lonLat) => this.adapter.getPixelFromCoordinate(lonLat), {
|
|
7417
7437
|
resolution: this.adapter.getResolution(),
|
|
7418
7438
|
bearing
|
|
@@ -7576,6 +7596,7 @@ var TacticalDraw = class {
|
|
|
7576
7596
|
previewLayer: this.previewLayer,
|
|
7577
7597
|
guideLayer: this.guideLayer,
|
|
7578
7598
|
graphicsStyle: this.graphicsStyle,
|
|
7599
|
+
symbolColors: this.symbolColors,
|
|
7579
7600
|
generateId: () => measureDraft.id ?? this.generateId(),
|
|
7580
7601
|
signal: options?.signal,
|
|
7581
7602
|
measureOptions: measureDraft.options,
|
|
@@ -7594,6 +7615,7 @@ var TacticalDraw = class {
|
|
|
7594
7615
|
previewLayer: this.previewLayer,
|
|
7595
7616
|
guideLayer: this.guideLayer,
|
|
7596
7617
|
graphicsStyle: this.graphicsStyle,
|
|
7618
|
+
symbolColors: this.symbolColors,
|
|
7597
7619
|
generateId: () => measureDraft.id ?? this.generateId(),
|
|
7598
7620
|
signal: options?.signal,
|
|
7599
7621
|
onSession: this.trackSession(options?.onSession),
|
|
@@ -7710,6 +7732,7 @@ var TacticalDraw = class {
|
|
|
7710
7732
|
guideLayer: this.guideLayer,
|
|
7711
7733
|
handlesLayer: this.handlesLayer,
|
|
7712
7734
|
graphicsStyle: this.graphicsStyle,
|
|
7735
|
+
symbolColors: this.symbolColors,
|
|
7713
7736
|
signal: options?.signal,
|
|
7714
7737
|
closeOnClickAway: options?.closeOnClickAway,
|
|
7715
7738
|
modes: options?.modes,
|
|
@@ -7764,6 +7787,7 @@ var TacticalDraw = class {
|
|
|
7764
7787
|
previewLayer: this.previewLayer,
|
|
7765
7788
|
handlesLayer: this.handlesLayer,
|
|
7766
7789
|
graphicsStyle: this.graphicsStyle,
|
|
7790
|
+
symbolColors: this.symbolColors,
|
|
7767
7791
|
signal: options?.signal,
|
|
7768
7792
|
closeOnClickAway: options?.closeOnClickAway,
|
|
7769
7793
|
interactionStyle: mergedInteractionStyle,
|
|
@@ -8146,10 +8170,7 @@ function normalisePointEditModes(modes) {
|
|
|
8146
8170
|
* identically when neither host nor measure supplies a style — without it,
|
|
8147
8171
|
* each engine falls through to its own native (and different) vector default.
|
|
8148
8172
|
*/
|
|
8149
|
-
const BUILT_IN_GRAPHICS_STYLE = {
|
|
8150
|
-
color: "#000000",
|
|
8151
|
-
strokeWidth: 2
|
|
8152
|
-
};
|
|
8173
|
+
const BUILT_IN_GRAPHICS_STYLE = { strokeWidth: 2 };
|
|
8153
8174
|
/**
|
|
8154
8175
|
* Built-in defaults for the interaction-affordance slots (ADR-0006, extended
|
|
8155
8176
|
* for the ADR-0017 transform box). The scale (corner) grips and the rotate
|
|
@@ -8237,7 +8258,7 @@ function mergeSlot(base, override) {
|
|
|
8237
8258
|
}
|
|
8238
8259
|
function styleToStyleOptions(style) {
|
|
8239
8260
|
const out = {};
|
|
8240
|
-
const strokeColor = style.strokeColor ?? style.color;
|
|
8261
|
+
const strokeColor = style.strokeColor ?? style.color ?? DEFAULT_SYMBOL_COLOR;
|
|
8241
8262
|
if (strokeColor !== void 0) out.strokeColor = strokeColor;
|
|
8242
8263
|
if (style.strokeWidth !== void 0) out.strokeWidth = style.strokeWidth;
|
|
8243
8264
|
if (style.strokeDash !== void 0) out.strokeDash = [...style.strokeDash];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.23.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|