@orbat-mapper/tactical-draw 0.25.0 → 0.27.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 { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-
|
|
1
|
+
import { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-mmWf_Jig.mjs";
|
|
2
2
|
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, HighlightAppearance, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
|
@@ -2307,12 +2307,36 @@ declare class TacticalDraw {
|
|
|
2307
2307
|
* This is a pure synchronous query over adapter-cached state: it does not
|
|
2308
2308
|
* depend on `onPick`/`"click"` dispatch having run first, so it is safe to
|
|
2309
2309
|
* call from any host click handler regardless of ordering relative to
|
|
2310
|
-
* TacticalDraw's own pick/click pipeline.
|
|
2310
|
+
* TacticalDraw's own pick/click pipeline. A press that changes what is under
|
|
2311
|
+
* the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
|
|
2312
|
+
* for the click that ends it; pair this with {@link consumedPointerCycle}.
|
|
2311
2313
|
*/
|
|
2312
2314
|
ownsInteractionAt(pixel: PixelCoordinate, options?: {
|
|
2313
2315
|
tolerance?: number;
|
|
2314
2316
|
originalEvent?: unknown;
|
|
2315
2317
|
}): InteractionHit | null;
|
|
2318
|
+
/**
|
|
2319
|
+
* Whether the active edit consumed the current pointer cycle's click — for
|
|
2320
|
+
* hosts composing their own click-away / deselection logic alongside
|
|
2321
|
+
* {@link ownsInteractionAt} (issue #668).
|
|
2322
|
+
*
|
|
2323
|
+
* Some presses change what is under the pointer, for example: Alt+click
|
|
2324
|
+
* (or a tap in `delete` mode) deletes the vertex handle that was pressed,
|
|
2325
|
+
* Alt+click on an option handle moves its grip to the reset position, and a
|
|
2326
|
+
* label or point-symbol drag moves what was pressed. The edit swallows the
|
|
2327
|
+
* click that ends such a press, but
|
|
2328
|
+
* a pixel query made from that click can find nothing there any more. Call
|
|
2329
|
+
* this from the host's own map `click` handler and treat `true` like an
|
|
2330
|
+
* owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
|
|
2331
|
+
*
|
|
2332
|
+
* `true` from the press that consumed the click until the next pointerdown,
|
|
2333
|
+
* so the answer doesn't depend on whether the host's `click` handler runs
|
|
2334
|
+
* before or after TacticalDraw's own. Only meaningful inside a `click`
|
|
2335
|
+
* handler: after a drag that no click follows, it stays `true` until the
|
|
2336
|
+
* next press. `false` while idle, during draws, and once the edit has
|
|
2337
|
+
* settled.
|
|
2338
|
+
*/
|
|
2339
|
+
consumedPointerCycle(): boolean;
|
|
2316
2340
|
private toInteractionHit;
|
|
2317
2341
|
/**
|
|
2318
2342
|
* Abort the in-flight draw or edit. The default `"session"` reason matches
|
package/dist/index.mjs
CHANGED
|
@@ -2151,11 +2151,18 @@ function runEditInteraction(spec) {
|
|
|
2151
2151
|
* edit takes two clicks instead of one.
|
|
2152
2152
|
*/
|
|
2153
2153
|
let suppressClickAway = false;
|
|
2154
|
+
/**
|
|
2155
|
+
* This pointer cycle armed {@link suppressClickAway}. Survives the trailing
|
|
2156
|
+
* `click` (which consumes the suppression) and is cleared only on the next
|
|
2157
|
+
* `pointerdown`, so hosts can ask about the click in any handler order.
|
|
2158
|
+
*/
|
|
2159
|
+
let consumedThisCycle = false;
|
|
2154
2160
|
/** A zero-movement body drag released this pointer cycle — set through `shell.noteBodyClick()`. */
|
|
2155
2161
|
let bodyClickPending = false;
|
|
2156
2162
|
const shell = {
|
|
2157
2163
|
suppressNextClickAway() {
|
|
2158
2164
|
suppressClickAway = true;
|
|
2165
|
+
consumedThisCycle = true;
|
|
2159
2166
|
},
|
|
2160
2167
|
noteBodyClick() {
|
|
2161
2168
|
bodyClickPending = true;
|
|
@@ -2202,7 +2209,7 @@ function runEditInteraction(spec) {
|
|
|
2202
2209
|
if (wasBodyClick) return;
|
|
2203
2210
|
spec.close();
|
|
2204
2211
|
};
|
|
2205
|
-
|
|
2212
|
+
const core = runInteraction({
|
|
2206
2213
|
adapter,
|
|
2207
2214
|
signal,
|
|
2208
2215
|
layers,
|
|
@@ -2252,6 +2259,7 @@ function runEditInteraction(spec) {
|
|
|
2252
2259
|
};
|
|
2253
2260
|
const onDown = (pixel, info) => {
|
|
2254
2261
|
suppressClickAway = false;
|
|
2262
|
+
consumedThisCycle = false;
|
|
2255
2263
|
spec.onDown(pixel, info);
|
|
2256
2264
|
};
|
|
2257
2265
|
const unsubDown = driver.onPointerDown(onDown);
|
|
@@ -2279,6 +2287,16 @@ function runEditInteraction(spec) {
|
|
|
2279
2287
|
spec.attach(controllerContext, driver, shell);
|
|
2280
2288
|
}
|
|
2281
2289
|
});
|
|
2290
|
+
return {
|
|
2291
|
+
promise: core.promise,
|
|
2292
|
+
get settled() {
|
|
2293
|
+
return core.settled;
|
|
2294
|
+
},
|
|
2295
|
+
get pointerCycleConsumed() {
|
|
2296
|
+
return consumedThisCycle && !core.settled;
|
|
2297
|
+
},
|
|
2298
|
+
abort: core.abort
|
|
2299
|
+
};
|
|
2282
2300
|
}
|
|
2283
2301
|
//#endregion
|
|
2284
2302
|
//#region src/tactical-draw/active-interaction.ts
|
|
@@ -2338,6 +2356,10 @@ var ActiveInteractionTracker = class {
|
|
|
2338
2356
|
get session() {
|
|
2339
2357
|
return this.currentSession;
|
|
2340
2358
|
}
|
|
2359
|
+
/** Whether the active interaction consumed the current pointer cycle's click. */
|
|
2360
|
+
get pointerCycleConsumed() {
|
|
2361
|
+
return this.handle?.pointerCycleConsumed === true;
|
|
2362
|
+
}
|
|
2341
2363
|
/** True while an interaction is mid-construction (between `begin` and `set`). */
|
|
2342
2364
|
get isStarting() {
|
|
2343
2365
|
return this.starting;
|
|
@@ -5312,9 +5334,13 @@ function runEdit(opts) {
|
|
|
5312
5334
|
}]);
|
|
5313
5335
|
}
|
|
5314
5336
|
/** Live view scale for option handles behind pixel-authored sizes. */
|
|
5315
|
-
|
|
5337
|
+
/** The live view state for option handles; `modifier` adds the press's modifier-drag key. */
|
|
5338
|
+
function optionHandleContext(modifier = false) {
|
|
5316
5339
|
const resolution = adapter.getResolution();
|
|
5317
|
-
return
|
|
5340
|
+
return {
|
|
5341
|
+
...hasUsableResolution(resolution) ? { constructionMetersPerCssPixel: resolution } : {},
|
|
5342
|
+
...modifier ? { modifier: true } : {}
|
|
5343
|
+
};
|
|
5318
5344
|
}
|
|
5319
5345
|
function buildCurrentHandleSet() {
|
|
5320
5346
|
const handles = buildHandleSet(workingPoints, modes, {
|
|
@@ -5909,7 +5935,7 @@ function runEdit(opts) {
|
|
|
5909
5935
|
if (frame.part !== void 0) parts.select(frame.part);
|
|
5910
5936
|
}
|
|
5911
5937
|
function optionsForOptionHandle(position, drag) {
|
|
5912
|
-
const patch = dragControlMeasureOptionHandle(measure.kind, workingPoints, drag.preDragOptions, drag.handleId, position, optionHandleContext());
|
|
5938
|
+
const patch = dragControlMeasureOptionHandle(measure.kind, workingPoints, drag.preDragOptions, drag.handleId, position, optionHandleContext(drag.modifier));
|
|
5913
5939
|
return patch ? {
|
|
5914
5940
|
...drag.preDragOptions ?? {},
|
|
5915
5941
|
...patch
|
|
@@ -6086,8 +6112,9 @@ function runEdit(opts) {
|
|
|
6086
6112
|
if (hit.kind === "vertex") parts.select(topology.partOf(hit.index));
|
|
6087
6113
|
else if (hit.kind === "midpoint") parts.select(hit.segment?.part);
|
|
6088
6114
|
if (hit.kind === "vertex" && modifierHeld(info, keys().modifierDrag) && startModifierDrag(hit.index, pixel, tol)) return;
|
|
6115
|
+
const optionModifier = hit.kind === "option" && modifierHeld(info, keys().modifierDrag);
|
|
6089
6116
|
if (hit.kind === "option" && hit.optionId && deleteOrReset) {
|
|
6090
|
-
const patch = resetControlMeasureOptionHandle(measure.kind, workingPoints, workingOptions, hit.optionId, optionHandleContext());
|
|
6117
|
+
const patch = resetControlMeasureOptionHandle(measure.kind, workingPoints, workingOptions, hit.optionId, optionHandleContext(optionModifier));
|
|
6091
6118
|
if (patch) {
|
|
6092
6119
|
setOptions(patch, "gesture", "Reset option handle");
|
|
6093
6120
|
shell.suppressNextClickAway();
|
|
@@ -6098,7 +6125,8 @@ function runEdit(opts) {
|
|
|
6098
6125
|
activeOptionDrag = {
|
|
6099
6126
|
handleId: hit.optionId,
|
|
6100
6127
|
preDragOptions: workingOptions,
|
|
6101
|
-
preDragNonGeometryDirty: nonGeometryDirty
|
|
6128
|
+
preDragNonGeometryDirty: nonGeometryDirty,
|
|
6129
|
+
modifier: optionModifier
|
|
6102
6130
|
};
|
|
6103
6131
|
transient.emit("start", workingPoints, null);
|
|
6104
6132
|
dragInFlight = true;
|
|
@@ -6456,6 +6484,9 @@ function runEdit(opts) {
|
|
|
6456
6484
|
get settled() {
|
|
6457
6485
|
return core.settled;
|
|
6458
6486
|
},
|
|
6487
|
+
get pointerCycleConsumed() {
|
|
6488
|
+
return core.pointerCycleConsumed;
|
|
6489
|
+
},
|
|
6459
6490
|
usesGraphicStack: true,
|
|
6460
6491
|
measureId: measure.id,
|
|
6461
6492
|
abort(reason, cause) {
|
|
@@ -7879,6 +7910,9 @@ function runGroupTransform(opts) {
|
|
|
7879
7910
|
get settled() {
|
|
7880
7911
|
return core.settled;
|
|
7881
7912
|
},
|
|
7913
|
+
get pointerCycleConsumed() {
|
|
7914
|
+
return core.pointerCycleConsumed;
|
|
7915
|
+
},
|
|
7882
7916
|
get graphicIds() {
|
|
7883
7917
|
return members.map((m) => m.graphic.id);
|
|
7884
7918
|
},
|
|
@@ -8390,6 +8424,9 @@ function runPointSymbolEdit(opts) {
|
|
|
8390
8424
|
get settled() {
|
|
8391
8425
|
return handle.settled;
|
|
8392
8426
|
},
|
|
8427
|
+
get pointerCycleConsumed() {
|
|
8428
|
+
return handle.pointerCycleConsumed;
|
|
8429
|
+
},
|
|
8393
8430
|
get usesGraphicStack() {
|
|
8394
8431
|
return usesGraphicStack;
|
|
8395
8432
|
},
|
|
@@ -8722,6 +8759,9 @@ function runImageEdit(opts) {
|
|
|
8722
8759
|
get settled() {
|
|
8723
8760
|
return handle.settled;
|
|
8724
8761
|
},
|
|
8762
|
+
get pointerCycleConsumed() {
|
|
8763
|
+
return handle.pointerCycleConsumed;
|
|
8764
|
+
},
|
|
8725
8765
|
get usesGraphicStack() {
|
|
8726
8766
|
return usesGraphicStack;
|
|
8727
8767
|
},
|
|
@@ -9099,6 +9139,9 @@ function runMarkerEdit(opts) {
|
|
|
9099
9139
|
get settled() {
|
|
9100
9140
|
return handle.settled;
|
|
9101
9141
|
},
|
|
9142
|
+
get pointerCycleConsumed() {
|
|
9143
|
+
return handle.pointerCycleConsumed;
|
|
9144
|
+
},
|
|
9102
9145
|
get usesGraphicStack() {
|
|
9103
9146
|
return usesGraphicStack;
|
|
9104
9147
|
},
|
|
@@ -10452,7 +10495,9 @@ var TacticalDraw = class {
|
|
|
10452
10495
|
* This is a pure synchronous query over adapter-cached state: it does not
|
|
10453
10496
|
* depend on `onPick`/`"click"` dispatch having run first, so it is safe to
|
|
10454
10497
|
* call from any host click handler regardless of ordering relative to
|
|
10455
|
-
* TacticalDraw's own pick/click pipeline.
|
|
10498
|
+
* TacticalDraw's own pick/click pipeline. A press that changes what is under
|
|
10499
|
+
* the pointer (e.g. an Alt+click vertex delete) can leave the pixel empty
|
|
10500
|
+
* for the click that ends it; pair this with {@link consumedPointerCycle}.
|
|
10456
10501
|
*/
|
|
10457
10502
|
ownsInteractionAt(pixel, options) {
|
|
10458
10503
|
this.assertAlive();
|
|
@@ -10528,6 +10573,31 @@ var TacticalDraw = class {
|
|
|
10528
10573
|
}
|
|
10529
10574
|
return null;
|
|
10530
10575
|
}
|
|
10576
|
+
/**
|
|
10577
|
+
* Whether the active edit consumed the current pointer cycle's click — for
|
|
10578
|
+
* hosts composing their own click-away / deselection logic alongside
|
|
10579
|
+
* {@link ownsInteractionAt} (issue #668).
|
|
10580
|
+
*
|
|
10581
|
+
* Some presses change what is under the pointer, for example: Alt+click
|
|
10582
|
+
* (or a tap in `delete` mode) deletes the vertex handle that was pressed,
|
|
10583
|
+
* Alt+click on an option handle moves its grip to the reset position, and a
|
|
10584
|
+
* label or point-symbol drag moves what was pressed. The edit swallows the
|
|
10585
|
+
* click that ends such a press, but
|
|
10586
|
+
* a pixel query made from that click can find nothing there any more. Call
|
|
10587
|
+
* this from the host's own map `click` handler and treat `true` like an
|
|
10588
|
+
* owned hit, e.g. `td.ownsInteractionAt(pixel) || td.consumedPointerCycle()`.
|
|
10589
|
+
*
|
|
10590
|
+
* `true` from the press that consumed the click until the next pointerdown,
|
|
10591
|
+
* so the answer doesn't depend on whether the host's `click` handler runs
|
|
10592
|
+
* before or after TacticalDraw's own. Only meaningful inside a `click`
|
|
10593
|
+
* handler: after a drag that no click follows, it stays `true` until the
|
|
10594
|
+
* next press. `false` while idle, during draws, and once the edit has
|
|
10595
|
+
* settled.
|
|
10596
|
+
*/
|
|
10597
|
+
consumedPointerCycle() {
|
|
10598
|
+
this.assertAlive();
|
|
10599
|
+
return this.activeInteraction.pointerCycleConsumed;
|
|
10600
|
+
}
|
|
10531
10601
|
toInteractionHit(layer, feature) {
|
|
10532
10602
|
const measureId = tryControlMeasureIdFromFeature(feature);
|
|
10533
10603
|
return measureId != null ? {
|
|
@@ -227,7 +227,8 @@ interface EditModifiers {
|
|
|
227
227
|
/**
|
|
228
228
|
* Drag a vertex with this key held to hand the gesture to the definition's
|
|
229
229
|
* `modifierDrag` hook (e.g. a Flow Arrow split or merge). Any key in a list
|
|
230
|
-
* starts it.
|
|
230
|
+
* starts it. Held while pressing an option handle, it lets the definition
|
|
231
|
+
* widen that drag or reset (e.g. sizing every Split Arrow head at once).
|
|
231
232
|
* @default ["ctrl", "meta"]
|
|
232
233
|
*/
|
|
233
234
|
modifierDrag?: ModifierKey | readonly ModifierKey[] | false;
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-
|
|
1
|
+
import { a as LayerId, o as MapAdapter, p as PixelCoordinate } from "./map-adapter-mmWf_Jig.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.
|
|
3
|
+
"version": "0.27.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.42.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|