@orbat-mapper/tactical-draw 0.18.0 → 0.19.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 { A as PinOverridePatch, B as isValidPinNumber, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PinPresentationStatus, H as pinZoomScale, I as PinPresentationStatusEvent, L as PinPresentationStore, M as PinPresentationCapability, N as PinPresentationPatch, O as DEFAULT_PIN_PRESENTATION, P as PinPresentationState, R as PinRender, S as isMinePattern, T as EditPointerDriver, U as resolvePinPresentation, V as pinDistanceScale, _ as HatchPattern, a as LayerId, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, j as PinPresentation, k as PinFootprint, 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 parseColor, x as fillPatternImageId, y as Rgba, z as combinePinScale } from "./map-adapter-
|
|
1
|
+
import { A as PinOverridePatch, B as isValidPinNumber, C as makeFillPatternImage, D as PointerEventInfo, E as PointerCallback, F as PinPresentationStatus, H as pinZoomScale, I as PinPresentationStatusEvent, L as PinPresentationStore, M as PinPresentationCapability, N as PinPresentationPatch, O as DEFAULT_PIN_PRESENTATION, P as PinPresentationState, R as PinRender, S as isMinePattern, T as EditPointerDriver, U as resolvePinPresentation, V as pinDistanceScale, _ as HatchPattern, a as LayerId, b as fillPatternImageDimension, c as MapEvent, d as PickHandler, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, j as PinPresentation, k as PinFootprint, 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 parseColor, x as fillPatternImageId, y as Rgba, z as combinePinScale } from "./map-adapter-DFqXaRgp.mjs";
|
|
2
2
|
import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
|
|
3
3
|
import { Feature, Position } from "geojson";
|
|
4
4
|
|
|
@@ -1902,6 +1902,12 @@ declare class TacticalDraw {
|
|
|
1902
1902
|
setPinPresentation(defaults: PinPresentationPatch): void;
|
|
1903
1903
|
setPinOverride(id: string, patch: PinOverridePatch): void;
|
|
1904
1904
|
resetPinOverride(id: string): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Set several pin overrides, and with `null` reset them, in one change and
|
|
1907
|
+
* one re-render. Prefer it over a loop of {@link setPinOverride} calls when
|
|
1908
|
+
* many pins change at once.
|
|
1909
|
+
*/
|
|
1910
|
+
setPinOverrides(patches: Readonly<Record<string, PinOverridePatch | null>>): void;
|
|
1905
1911
|
getPinPresentationCapability(id?: string): PinPresentationCapability;
|
|
1906
1912
|
onPinPresentationStatusChange(listener: (event: PinPresentationStatusEvent) => void): () => void;
|
|
1907
1913
|
getPinPresentationState(): PinPresentationState;
|
package/dist/index.mjs
CHANGED
|
@@ -1313,6 +1313,10 @@ var PinPresentationStore = class {
|
|
|
1313
1313
|
defaults: {},
|
|
1314
1314
|
overrides: {}
|
|
1315
1315
|
};
|
|
1316
|
+
/** Monotonic stamp source for {@link revision}. */
|
|
1317
|
+
revisions = 0;
|
|
1318
|
+
defaultsRevision = 0;
|
|
1319
|
+
overrideRevisions = /* @__PURE__ */ new Map();
|
|
1316
1320
|
emitter = createCommitEmitter("PinPresentationStore.onChange listener errors");
|
|
1317
1321
|
getState() {
|
|
1318
1322
|
return structuredClone(this.state);
|
|
@@ -1320,18 +1324,34 @@ var PinPresentationStore = class {
|
|
|
1320
1324
|
resolve(id) {
|
|
1321
1325
|
return resolvePinPresentation(this.state.defaults, Object.hasOwn(this.state.overrides, id) ? this.state.overrides[id] : {});
|
|
1322
1326
|
}
|
|
1327
|
+
/**
|
|
1328
|
+
* @internal A stamp that changes whenever {@link resolve} may return a
|
|
1329
|
+
* different presentation for `id`, so a renderer can keep reusing the pins
|
|
1330
|
+
* whose presentation a change left alone.
|
|
1331
|
+
*/
|
|
1332
|
+
revision(id) {
|
|
1333
|
+
return Math.max(this.defaultsRevision, this.overrideRevisions.get(id) ?? 0);
|
|
1334
|
+
}
|
|
1323
1335
|
replace(state) {
|
|
1324
1336
|
if (!state || !state.overrides || typeof state.overrides !== "object" || Array.isArray(state.overrides)) throw new TypeError("Invalid pin state");
|
|
1325
|
-
|
|
1337
|
+
const defaultsChanged = !Object.is(state.defaults, this.state.defaults);
|
|
1338
|
+
const changed = [];
|
|
1339
|
+
if (defaultsChanged) {
|
|
1326
1340
|
resolvePinPresentation(state.defaults);
|
|
1327
1341
|
for (const patch of Object.values(state.overrides)) {
|
|
1328
1342
|
validateOverride(patch);
|
|
1329
1343
|
resolvePinPresentation(state.defaults, patch);
|
|
1330
1344
|
}
|
|
1331
|
-
} else
|
|
1332
|
-
|
|
1333
|
-
|
|
1345
|
+
} else {
|
|
1346
|
+
for (const [id, patch] of Object.entries(state.overrides)) if (!Object.is(patch, this.state.overrides[id])) {
|
|
1347
|
+
validateOverride(patch);
|
|
1348
|
+
resolvePinPresentation(state.defaults, patch);
|
|
1349
|
+
changed.push(id);
|
|
1350
|
+
}
|
|
1351
|
+
for (const id of Object.keys(this.state.overrides)) if (!Object.hasOwn(state.overrides, id)) changed.push(id);
|
|
1334
1352
|
}
|
|
1353
|
+
if (defaultsChanged) this.defaultsRevision = ++this.revisions;
|
|
1354
|
+
for (const id of changed) this.overrideRevisions.set(id, ++this.revisions);
|
|
1335
1355
|
this.state = structuredClone(state);
|
|
1336
1356
|
this.emitter.emit(this.getState());
|
|
1337
1357
|
}
|
|
@@ -1342,20 +1362,27 @@ var PinPresentationStore = class {
|
|
|
1342
1362
|
});
|
|
1343
1363
|
}
|
|
1344
1364
|
setOverride(id, patch) {
|
|
1345
|
-
this.
|
|
1346
|
-
...this.state,
|
|
1347
|
-
overrides: {
|
|
1348
|
-
...this.state.overrides,
|
|
1349
|
-
[id]: patch
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1365
|
+
this.setOverrides({ [id]: patch });
|
|
1352
1366
|
}
|
|
1353
1367
|
resetOverride(id) {
|
|
1354
|
-
|
|
1355
|
-
|
|
1368
|
+
this.setOverrides({ [id]: null });
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Set several overrides, and with `null` reset them, as one validated change
|
|
1372
|
+
* and one `onChange` emit. Each patch replaces that id's previous patch, as
|
|
1373
|
+
* {@link setOverride} does; ids not named keep theirs. An invalid patch
|
|
1374
|
+
* throws and leaves every override unchanged.
|
|
1375
|
+
*/
|
|
1376
|
+
setOverrides(patches) {
|
|
1377
|
+
if (!patches || typeof patches !== "object" || Array.isArray(patches)) throw new TypeError("Invalid pin overrides");
|
|
1378
|
+
const entries = Object.entries(patches);
|
|
1379
|
+
if (entries.length === 0) return;
|
|
1380
|
+
const overrides = new Map(Object.entries(this.state.overrides));
|
|
1381
|
+
for (const [id, patch] of entries) if (patch === null) overrides.delete(id);
|
|
1382
|
+
else overrides.set(id, patch);
|
|
1356
1383
|
this.replace({
|
|
1357
1384
|
...this.state,
|
|
1358
|
-
overrides
|
|
1385
|
+
overrides: Object.fromEntries(overrides)
|
|
1359
1386
|
});
|
|
1360
1387
|
}
|
|
1361
1388
|
onChange(listener) {
|
|
@@ -8740,7 +8767,6 @@ var TacticalDraw = class {
|
|
|
8740
8767
|
this.adapter.setLayerStyle(this.highlightLayer, guideToStyleOptions(this.baseHighlightStyle()));
|
|
8741
8768
|
this.adapter.onViewChange(this.handleViewChange);
|
|
8742
8769
|
this.unsubscribePins = this.pins.onChange(() => {
|
|
8743
|
-
this.invalidateGraphicGroupCache(false);
|
|
8744
8770
|
this.refreshActiveEditPresentation();
|
|
8745
8771
|
this.reconcileGraphicsStack();
|
|
8746
8772
|
this.flushHighlights();
|
|
@@ -8758,6 +8784,15 @@ var TacticalDraw = class {
|
|
|
8758
8784
|
this.assertAlive();
|
|
8759
8785
|
this.pins.resetOverride(id);
|
|
8760
8786
|
}
|
|
8787
|
+
/**
|
|
8788
|
+
* Set several pin overrides, and with `null` reset them, in one change and
|
|
8789
|
+
* one re-render. Prefer it over a loop of {@link setPinOverride} calls when
|
|
8790
|
+
* many pins change at once.
|
|
8791
|
+
*/
|
|
8792
|
+
setPinOverrides(patches) {
|
|
8793
|
+
this.assertAlive();
|
|
8794
|
+
this.pins.setOverrides(patches);
|
|
8795
|
+
}
|
|
8761
8796
|
getPinPresentationCapability(id) {
|
|
8762
8797
|
return this.adapter.getPinPresentationCapability?.(id) ?? {
|
|
8763
8798
|
status: "unsupported",
|
|
@@ -8842,19 +8877,22 @@ var TacticalDraw = class {
|
|
|
8842
8877
|
* per-frame reconcile cost becomes O(selection) rather than O(document).
|
|
8843
8878
|
*/
|
|
8844
8879
|
renderGraphicGroup(graphic) {
|
|
8880
|
+
const pinnable = isPinnableGraphic(graphic);
|
|
8881
|
+
const pinRevision = pinnable ? this.pins.revision(graphic.id) : void 0;
|
|
8845
8882
|
const cached = this.graphicGroupCache.get(graphic);
|
|
8846
|
-
if (cached) {
|
|
8883
|
+
if (cached && cached.pinRevision === pinRevision) {
|
|
8847
8884
|
if (cached.dependence === "none") return cached.group;
|
|
8848
8885
|
if (cached.dependence === "resolution" && Object.is(cached.resolution, this.adapter.getResolution())) return cached.group;
|
|
8849
8886
|
}
|
|
8850
|
-
const presentation =
|
|
8887
|
+
const presentation = pinnable ? this.pins.resolve(graphic.id) : void 0;
|
|
8851
8888
|
const dependence = presentation && this.graphicUsesPinPresentation(graphic, presentation) ? "none" : graphicViewDependence(graphic, this.adapter.scalesGroundPointSymbolsNatively === true);
|
|
8852
8889
|
const resolution = dependence === "none" ? void 0 : this.adapter.getResolution();
|
|
8853
8890
|
const group = this.buildGraphicGroup(graphic, presentation);
|
|
8854
8891
|
this.graphicGroupCache.set(graphic, {
|
|
8855
8892
|
group,
|
|
8856
8893
|
dependence,
|
|
8857
|
-
resolution
|
|
8894
|
+
resolution,
|
|
8895
|
+
pinRevision
|
|
8858
8896
|
});
|
|
8859
8897
|
return group;
|
|
8860
8898
|
}
|
|
@@ -139,13 +139,30 @@ declare function resolvePinPresentation(...patches: readonly PinPresentationPatc
|
|
|
139
139
|
/** Replacing patches makes omitted override properties inherit again. */
|
|
140
140
|
declare class PinPresentationStore {
|
|
141
141
|
private state;
|
|
142
|
+
/** Monotonic stamp source for {@link revision}. */
|
|
143
|
+
private revisions;
|
|
144
|
+
private defaultsRevision;
|
|
145
|
+
private readonly overrideRevisions;
|
|
142
146
|
private readonly emitter;
|
|
143
147
|
getState(): PinPresentationState;
|
|
144
148
|
resolve(id: string): PinPresentation;
|
|
149
|
+
/**
|
|
150
|
+
* @internal A stamp that changes whenever {@link resolve} may return a
|
|
151
|
+
* different presentation for `id`, so a renderer can keep reusing the pins
|
|
152
|
+
* whose presentation a change left alone.
|
|
153
|
+
*/
|
|
154
|
+
revision(id: string): number;
|
|
145
155
|
replace(state: PinPresentationState): void;
|
|
146
156
|
setDefaults(patch: PinPresentationPatch): void;
|
|
147
157
|
setOverride(id: string, patch: PinOverridePatch): void;
|
|
148
158
|
resetOverride(id: string): void;
|
|
159
|
+
/**
|
|
160
|
+
* Set several overrides, and with `null` reset them, as one validated change
|
|
161
|
+
* and one `onChange` emit. Each patch replaces that id's previous patch, as
|
|
162
|
+
* {@link setOverride} does; ids not named keep theirs. An invalid patch
|
|
163
|
+
* throws and leaves every override unchanged.
|
|
164
|
+
*/
|
|
165
|
+
setOverrides(patches: Readonly<Record<string, PinOverridePatch | null>>): void;
|
|
149
166
|
onChange(listener: (state: PinPresentationState) => void): () => void;
|
|
150
167
|
}
|
|
151
168
|
//#endregion
|
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-DFqXaRgp.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.19.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.36.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|