@orbat-mapper/tactical-draw 0.24.0 → 0.25.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.mjs +17 -4
- package/package.json +2 -2
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, LABEL_FADE_END_RATIO, NON_SOLID_FILL_PATTERNS, applyBoxTransformOptions, canDeleteControlMeasureVertex, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureModifierDrag, getControlMeasureOptionHandles, getControlMeasurePartOf, getControlMeasureSegments, getDefaultOptions, labelSizeBandHideThreshold, 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, canDeleteControlMeasureVertex, canonicalTextAmplifierKey, cloneControlMeasure, controlMeasureIdFromFeature, dragControlMeasureOptionHandle, foldsBoxTransformOptions, freezeOrientationOptions, getControlMeasureMetadata, getControlMeasureModifierDrag, getControlMeasureOptionHandles, getControlMeasurePartOf, getControlMeasureSegments, getDefaultOptions, keepControlMeasureDrawnSize, 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";
|
|
@@ -3359,7 +3359,9 @@ function runVariableLengthDraw(options) {
|
|
|
3359
3359
|
if (!rule || ruleMin === void 0) return false;
|
|
3360
3360
|
return len >= trailingFixed + ruleMin;
|
|
3361
3361
|
}
|
|
3362
|
+
const insertAtStart = rule?.insertClicksAtStart ?? false;
|
|
3362
3363
|
function insertionIndex(len) {
|
|
3364
|
+
if (insertAtStart) return 0;
|
|
3363
3365
|
return canonicalFormed(len) ? len - trailingFixed : len;
|
|
3364
3366
|
}
|
|
3365
3367
|
const initialPoints = [];
|
|
@@ -3402,6 +3404,15 @@ function runVariableLengthDraw(options) {
|
|
|
3402
3404
|
if (rule && ruleMin !== void 0 && n - trailingFixed < ruleMin) return false;
|
|
3403
3405
|
return true;
|
|
3404
3406
|
}
|
|
3407
|
+
let sizeBaseline;
|
|
3408
|
+
function updateSizeBaseline() {
|
|
3409
|
+
if (!sizeBaseline && canCommitNow()) sizeBaseline = committed.map((p) => [...p]);
|
|
3410
|
+
}
|
|
3411
|
+
updateSizeBaseline();
|
|
3412
|
+
function drawnOptions(points) {
|
|
3413
|
+
if (!sizeBaseline) return measureOptions;
|
|
3414
|
+
return keepControlMeasureDrawnSize(kind, sizeBaseline, points, measureOptions);
|
|
3415
|
+
}
|
|
3405
3416
|
const session = {
|
|
3406
3417
|
get controlPoints() {
|
|
3407
3418
|
return committed.map((p) => [...p]);
|
|
@@ -3448,7 +3459,7 @@ function runVariableLengthDraw(options) {
|
|
|
3448
3459
|
const handleClick = (event) => {
|
|
3449
3460
|
if (ctx.settled) return;
|
|
3450
3461
|
const pos = roundControlPoint(snappedDrawPosition(snap, event));
|
|
3451
|
-
const lastSpineIdx = committed.length - 1 - trailingFixed;
|
|
3462
|
+
const lastSpineIdx = insertAtStart ? Math.min(0, committed.length - 1) : committed.length - 1 - trailingFixed;
|
|
3452
3463
|
const finishIndices = closedRing && lastSpineIdx > 0 ? [lastSpineIdx, 0] : [lastSpineIdx];
|
|
3453
3464
|
for (let i = 0; i < committed.length; i++) if (positionsEqual(pos, committed[i])) {
|
|
3454
3465
|
if (finishIndices.includes(i) && canCommitNow()) ctx.commit(buildSnapshot);
|
|
@@ -3473,6 +3484,7 @@ function runVariableLengthDraw(options) {
|
|
|
3473
3484
|
committed.splice(0, committed.length, ...derived);
|
|
3474
3485
|
}
|
|
3475
3486
|
committed.splice(0, committed.length, ...roundControlPoints(committed));
|
|
3487
|
+
updateSizeBaseline();
|
|
3476
3488
|
rubberBand = void 0;
|
|
3477
3489
|
renderPreview();
|
|
3478
3490
|
try {
|
|
@@ -3511,7 +3523,7 @@ function runVariableLengthDraw(options) {
|
|
|
3511
3523
|
points.splice(idx, 0, rubberBand);
|
|
3512
3524
|
} else points = [...committed];
|
|
3513
3525
|
if (rule) points = rule.derive(points);
|
|
3514
|
-
const previewFeatures = points.length === 0 ? [] : buildPreviewFeatures(adapter, kind, points,
|
|
3526
|
+
const previewFeatures = points.length === 0 ? [] : buildPreviewFeatures(adapter, kind, points, drawnOptions(points), measureStyle, measureTextAmplifiers, renderOpts);
|
|
3515
3527
|
ctx.writeLayer(previewLayer, [{
|
|
3516
3528
|
id: "__td_variable_draw_preview__",
|
|
3517
3529
|
features: previewFeatures,
|
|
@@ -3533,11 +3545,12 @@ function runVariableLengthDraw(options) {
|
|
|
3533
3545
|
renderPreview();
|
|
3534
3546
|
}
|
|
3535
3547
|
function buildSnapshot() {
|
|
3548
|
+
const committedOptions = drawnOptions(committed);
|
|
3536
3549
|
const sized = withDefaultAuthoringSize(withCommittedAdapterMeasureOptions({
|
|
3537
3550
|
id: generateId(),
|
|
3538
3551
|
kind,
|
|
3539
3552
|
controlPoints: committed.map((p) => [...p]),
|
|
3540
|
-
...
|
|
3553
|
+
...committedOptions !== void 0 ? { options: committedOptions } : {},
|
|
3541
3554
|
...measureStyle !== void 0 ? { style: measureStyle } : {},
|
|
3542
3555
|
...measureProperties !== void 0 ? { properties: measureProperties } : {},
|
|
3543
3556
|
...measureTextAmplifiers !== void 0 ? { textAmplifiers: measureTextAmplifiers } : {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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.41.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|