@orbat-mapper/tactical-draw-adapter-maplibre 0.3.22 → 0.4.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,8 +1,115 @@
1
- import { BaseMapAdapter, EditPointerDriver, FeatureGroup, IconResource, LayerId, MapCursor, NativeEventEntry, PickHandler, PickOptions, PixelCoordinate, StyleOptions } from "@orbat-mapper/tactical-draw";
2
1
  import * as maplibregl from "maplibre-gl";
3
- import { DataDrivenPropertyValueSpecification } from "maplibre-gl";
2
+ import { CustomLayerInterface, CustomRenderMethodInput, DataDrivenPropertyValueSpecification, Map as Map$1 } from "maplibre-gl";
3
+ import { BaseMapAdapter, EditPointerDriver, FeatureGroup, IconResource, LayerId, MapCursor, NativeEventEntry, PickHandler, PickOptions, PinFootprint, PinPresentationCapability, PinPresentationStatusEvent, PinRender, PixelCoordinate, StyleOptions } from "@orbat-mapper/tactical-draw";
4
4
  import { Feature, Position } from "geojson";
5
5
 
6
+ //#region src/pin-atlas.d.ts
7
+ interface AtlasEntry {
8
+ page: number;
9
+ uv: [number, number, number, number];
10
+ }
11
+ /** Paged shelves avoid one texture per symbol and do not reorder draw instances. */
12
+ declare class PinAtlas {
13
+ readonly size: number;
14
+ readonly entries: Map<string, AtlasEntry>;
15
+ readonly pages: HTMLCanvasElement[];
16
+ private x;
17
+ private y;
18
+ private rowHeight;
19
+ constructor(size?: number);
20
+ add(resource: IconResource, scale: number, image: CanvasImageSource): void;
21
+ }
22
+ //#endregion
23
+ //#region src/pin-resources.d.ts
24
+ interface PinResourceSnapshot {
25
+ atlas: PinAtlas;
26
+ textures: WebGLTexture[];
27
+ }
28
+ /** One atlas roster per logical layer, shared across ordinary-graphic barriers. */
29
+ declare class PinResources {
30
+ private map;
31
+ revision: number;
32
+ private key;
33
+ private resources;
34
+ private pending?;
35
+ private textures;
36
+ private context?;
37
+ private disposed;
38
+ private needsDepth;
39
+ private invalidateDepth;
40
+ private restore;
41
+ constructor(map: Map$1);
42
+ setRoster(pins: readonly PinRender[]): void;
43
+ load(gl: WebGL2RenderingContext): Promise<PinResourceSnapshot | undefined>;
44
+ dispose(): void;
45
+ }
46
+ //#endregion
47
+ //#region src/pin-layer.d.ts
48
+ /** Batched GPU pin rendering. Adjacent groups only; instance order is paint order. */
49
+ declare class PinLayer implements CustomLayerInterface {
50
+ readonly id: string;
51
+ private readonly resources;
52
+ private readonly onStatus?;
53
+ readonly type = "custom";
54
+ readonly renderingMode = "2d";
55
+ private map;
56
+ private gl;
57
+ private program?;
58
+ private uniforms?;
59
+ private buffer?;
60
+ private vao?;
61
+ private textures;
62
+ private atlas;
63
+ private pins;
64
+ private ranges;
65
+ private version;
66
+ private resourceRevision;
67
+ private needsDepth;
68
+ private elevationCache;
69
+ private pendingElevation;
70
+ private removed;
71
+ private ready;
72
+ private dirty;
73
+ private changedPins;
74
+ private slices;
75
+ private origin;
76
+ private elevations;
77
+ private projection;
78
+ private matrix;
79
+ private frame?;
80
+ private pickFramebuffer?;
81
+ private pickTexture?;
82
+ private pickSize;
83
+ private status;
84
+ private refreshTerrain;
85
+ private elevation;
86
+ has(id: string): boolean;
87
+ constructor(id: string, resources: PinResources, onStatus?: ((event: PinPresentationStatusEvent) => void) | undefined);
88
+ private restoreContext;
89
+ private onRemoveListeners;
90
+ onAdd(map: Map$1, context: WebGLRenderingContext | WebGL2RenderingContext): void;
91
+ /** Uniform locations are fixed once a program is linked; resolved here, not per draw. */
92
+ private resolveUniforms;
93
+ private setStatus;
94
+ getStatus(id?: string): PinPresentationCapability;
95
+ setPins(pins: readonly PinRender[], changedIndices?: readonly number[]): Promise<void>;
96
+ private buildPin;
97
+ private rebuild;
98
+ render(context: WebGLRenderingContext | WebGL2RenderingContext, input: CustomRenderMethodInput): void;
99
+ private draw;
100
+ /** On-demand GPU pick shares the visual shader including alpha and terrain mask. */
101
+ pick(pixel: PixelCoordinate, tolerance?: number): string | null;
102
+ /**
103
+ * Shared Mercator/globe clip-space projection converted to container pixels. Callers
104
+ * differ in elevation source and in whether/where a screen-mode lift offset applies
105
+ * — those stay at the call site, as they aren't part of the shared matrix math.
106
+ */
107
+ private projectToPixel;
108
+ footprint(id: string): PinFootprint | null;
109
+ moveFromPixel(id: string, attachment: PixelCoordinate): number[] | null;
110
+ onRemove(_map: Map$1, context: WebGLRenderingContext | WebGL2RenderingContext): void;
111
+ }
112
+ //#endregion
6
113
  //#region src/text-sizing.d.ts
7
114
  type SizeExpression = DataDrivenPropertyValueSpecification<number>;
8
115
  interface TextSizing {
@@ -14,6 +121,7 @@ interface TextSizing {
14
121
  //#endregion
15
122
  //#region src/ml-adapter.d.ts
16
123
  interface MapLibreLayerHandle {
124
+ pinResources?: PinResources;
17
125
  sourceId: string;
18
126
  /** MapLibre layer ids created for this logical layer (fill, line, circle, symbol) */
19
127
  mlLayerIds: string[];
@@ -21,9 +129,20 @@ interface MapLibreLayerHandle {
21
129
  groupOrder: string[];
22
130
  nextGroupBundleId: number;
23
131
  style?: StyleOptions;
132
+ /**
133
+ * The flattened pin batch last passed to `pinResources.setRoster`. Producers
134
+ * memoize `PinRender` identity when nothing changed (mirrored by the
135
+ * per-bundle `pinSignature` diff below), so an identical batch by reference
136
+ * means `setRoster`'s own Map-rebuild/sort/stringify would be a no-op —
137
+ * skip calling it at all rather than pay for that every drag frame.
138
+ */
139
+ lastPinBatch?: readonly PinRender[];
24
140
  }
25
141
  type PaintChannel = "fill" | "fill-pattern" | "line" | "circle" | "icon" | "text";
26
142
  interface MapLibreGroupBundle {
143
+ pinLayer?: PinLayer;
144
+ pinSignature?: readonly PinRender[];
145
+ pinResourceRevision?: number;
27
146
  readonly sourceId: string;
28
147
  readonly paintSurfaces: Map<string, MapLibrePaintSurface>;
29
148
  paintOrder: string[];
@@ -87,7 +206,7 @@ declare class MapLibreAdapter extends BaseMapAdapter<MapLibreLayerHandle, MapLib
87
206
  private toContinuousLng;
88
207
  protected createLayer(layerId: LayerId, style?: StyleOptions): MapLibreLayerHandle;
89
208
  protected destroyLayer(handle: MapLibreLayerHandle): void;
90
- protected applyFeatureGroups(layerId: LayerId, groups: readonly FeatureGroup[]): void;
209
+ protected applyFeatureGroups(layerId: LayerId, input: readonly FeatureGroup[]): void;
91
210
  private createGroupBundle;
92
211
  private destroyGroupBundle;
93
212
  private reconcileGroupImageOverlays;
@@ -144,6 +263,25 @@ declare class MapLibreAdapter extends BaseMapAdapter<MapLibreLayerHandle, MapLib
144
263
  getZoom(): number | undefined;
145
264
  getBearing(): number;
146
265
  onPick(layerId: LayerId, handler: PickHandler, opts?: PickOptions): () => void;
266
+ private readonly pinStatusListeners;
267
+ private readonly emitPinStatus;
268
+ onPinPresentationStatusChange(handler: (event: PinPresentationStatusEvent) => void): () => void;
269
+ /**
270
+ * Pin layers across this adapter's group bundles.
271
+ * - With no `handle`: every layer's bundles, in bundle-map (creation)
272
+ * order — fine for id-based lookups where only "does one match" matters.
273
+ * - With `handle`: only that layer's bundles, walked topmost-first (reverse
274
+ * paint order) — required for hit-testing, where the first hit must be
275
+ * the visually topmost pin.
276
+ */
277
+ private pinLayers;
278
+ /** First non-null/undefined result of `fn` across all pin layers, else null. */
279
+ private findPinLayer;
280
+ getPinPresentationCapability(graphicId?: string): PinPresentationCapability;
281
+ getPinFootprint(id: string): PinFootprint | null;
282
+ movePinFromPixel(id: string, attachment: PixelCoordinate): Position | null;
283
+ private pinHit;
284
+ pickPin(id: string, pixel: PixelCoordinate, tolerance: number): boolean;
147
285
  setGlobeMode(enabled: boolean): void;
148
286
  }
149
287
  //#endregion