@yarrow-uz/yarrow-map-web-sdk 1.0.46 → 1.0.48

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.
@@ -1,4 +1,342 @@
1
- import 'maplibre-gl/dist/maplibre-gl.css';
2
- export * from './useYarrowMap';
3
- export * from './YarrowMapView';
4
- //# sourceMappingURL=index.d.ts.map
1
+ import * as React from "react";
2
+ import { FeatureIdentifier, GeoJSONSourceSpecification, LayerSpecification, Map as Map$1, MapMouseEvent, Marker, MarkerOptions, PointLike, QueryRenderedFeaturesOptions, StyleSpecification } from "maplibre-gl";
3
+
4
+ //#region src/maps/brandBadge.d.ts
5
+ type BrandBadgePosition$1 = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
6
+ //#endregion
7
+ //#region src/maps/yarrowControls.d.ts
8
+ type YarrowControlsPosition$1 = 'left' | 'left-top' | 'left-bottom' | 'right' | 'right-top' | 'right-bottom';
9
+ type YarrowControlsConfig$1 = {
10
+ enabled?: boolean;
11
+ position?: YarrowControlsPosition$1;
12
+ zoom?: boolean;
13
+ compass?: boolean;
14
+ };
15
+ type NormalizedYarrowControlsConfig = {
16
+ enabled: boolean;
17
+ position: YarrowControlsPosition$1;
18
+ zoom: boolean;
19
+ compass: boolean;
20
+ };
21
+ declare const normalizeYarrowControlsConfig: (controls?: YarrowControlsConfig$1) => NormalizedYarrowControlsConfig;
22
+ //#endregion
23
+ //#region node_modules/@maplibre/maplibre-gl-style-spec/dist/index.d.ts
24
+ type ColorSpecification = string;
25
+ type ProjectionDefinitionT = [string, string, number];
26
+ type ProjectionDefinitionSpecification = string | ProjectionDefinitionT | PropertyValueSpecification<ProjectionDefinitionT>;
27
+ type ExpressionInputType = string | number | boolean;
28
+ type VariableExpressionSpecification = ["var", string];
29
+ type CollatorExpressionSpecification = ["collator", {
30
+ "case-sensitive"?: boolean | ExpressionSpecification;
31
+ "diacritic-sensitive"?: boolean | ExpressionSpecification;
32
+ locale?: string | ExpressionSpecification;
33
+ }];
34
+ type InterpolationSpecification = ["linear"] | ["exponential", number] | ["cubic-bezier", number, number, number, number];
35
+ type ExpressionSpecification = ["array", ExpressionSpecification] | ["array", "string" | "number" | "boolean", ExpressionSpecification] | ["array", "string" | "number" | "boolean", number, ExpressionSpecification] | ["boolean", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | CollatorExpressionSpecification | ["format", ...(string | ["image", ExpressionSpecification] | ExpressionSpecification | {
36
+ "font-scale"?: number | ExpressionSpecification;
37
+ "text-font"?: ExpressionSpecification;
38
+ "text-color"?: ColorSpecification | ExpressionSpecification;
39
+ "vertical-align"?: "bottom" | "center" | "top";
40
+ })[]] | ["image", string | ExpressionSpecification] | ["literal", unknown] | ["number", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | ["number-format", number | ExpressionSpecification, {
41
+ "locale"?: string | ExpressionSpecification;
42
+ "currency"?: string | ExpressionSpecification;
43
+ "min-fraction-digits"?: number | ExpressionSpecification;
44
+ "max-fraction-digits"?: number | ExpressionSpecification;
45
+ }] | ["number-format", number | ExpressionSpecification, {
46
+ "locale"?: string | ExpressionSpecification;
47
+ "unit"?: string | ExpressionSpecification;
48
+ "min-fraction-digits"?: number | ExpressionSpecification;
49
+ "max-fraction-digits"?: number | ExpressionSpecification;
50
+ }] | ["object", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | ["string", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | ["to-boolean", unknown | ExpressionSpecification] | ["to-color", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | ["to-number", unknown | ExpressionSpecification, ...(unknown | ExpressionSpecification)[]] | ["to-string", unknown | ExpressionSpecification] | ["typeof", unknown | ExpressionSpecification] | ["accumulated"] | ["feature-state", string | ExpressionSpecification] | ["geometry-type"] | ["id"] | ["line-progress"] | ["properties"] | ["at", number | ExpressionSpecification, ExpressionSpecification] | ["get", string | ExpressionSpecification, ExpressionSpecification?] | ["global-state", string] | ["has", string | ExpressionSpecification, ExpressionSpecification?] | ["in", null | ExpressionInputType | ExpressionSpecification, string | ExpressionSpecification] | ["index-of", null | ExpressionInputType | ExpressionSpecification, string | ExpressionSpecification, (number | ExpressionSpecification)?] | ["length", string | ExpressionSpecification] | ["slice", string | ExpressionSpecification, number | ExpressionSpecification, (number | ExpressionSpecification)?] | ["!", boolean | ExpressionSpecification] | ["!=", null | ExpressionInputType | ExpressionSpecification, null | ExpressionInputType | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | ["<", string | number | ExpressionSpecification, string | number | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | ["<=", string | number | ExpressionSpecification, string | number | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | ["==", null | ExpressionInputType | ExpressionSpecification, null | ExpressionInputType | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | [">", string | number | ExpressionSpecification, string | number | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | [">=", string | number | ExpressionSpecification, string | number | ExpressionSpecification, (CollatorExpressionSpecification | VariableExpressionSpecification)?] | ["all", ...(boolean | ExpressionSpecification)[]] | ["any", ...(boolean | ExpressionSpecification)[]] | ["case", boolean | ExpressionSpecification, null | ExpressionInputType | ExpressionSpecification, ...(boolean | null | ExpressionInputType | ExpressionSpecification)[], null | ExpressionInputType | ExpressionSpecification] | ["coalesce", ...(ExpressionInputType | ExpressionSpecification)[]] | ["match", string | number | ExpressionSpecification, string | number | string[] | number[], null | ExpressionInputType | ExpressionSpecification, ...(string | number | string[] | number[] | null | ExpressionInputType | ExpressionSpecification)[], // repeated as above
51
+ null | ExpressionInputType | ExpressionSpecification] | ["within", GeoJSON.GeoJSON] | ["interpolate", InterpolationSpecification, number | ExpressionSpecification, ...(number | ColorSpecification | ExpressionSpecification | ProjectionDefinitionSpecification)[]] | ["interpolate-hcl", InterpolationSpecification, number | ExpressionSpecification, ...(number | ColorSpecification | ExpressionSpecification)[]] | ["interpolate-lab", InterpolationSpecification, number | ExpressionSpecification, ...(number | ColorSpecification | ExpressionSpecification)[]] | ["step", number | ExpressionSpecification, ExpressionInputType | ExpressionSpecification, ...(number | ExpressionInputType | ExpressionSpecification)[]] | ["let", string, ExpressionInputType | ExpressionSpecification, ...(string | ExpressionInputType | ExpressionSpecification)[]] | VariableExpressionSpecification | ["concat", ...(ExpressionInputType | ExpressionSpecification)[]] | ["downcase", string | ExpressionSpecification] | ["is-supported-script", string | ExpressionSpecification] | ["join", string[] | ExpressionSpecification, string | ExpressionSpecification] | ["resolved-locale", CollatorExpressionSpecification] | ["split", string | ExpressionSpecification, string | ExpressionSpecification] | ["upcase", string | ExpressionSpecification] | ["rgb", number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification] | ["rgba", number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification, number | ExpressionSpecification] | ["to-rgba", ColorSpecification | ExpressionSpecification] | ["-", number | ExpressionSpecification, (number | ExpressionSpecification)?] | ["*", number | ExpressionSpecification, number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] | ["/", number | ExpressionSpecification, number | ExpressionSpecification] | ["%", number | ExpressionSpecification, number | ExpressionSpecification] | ["^", number | ExpressionSpecification, number | ExpressionSpecification] | ["+", ...(number | ExpressionSpecification)[]] | ["abs", number | ExpressionSpecification] | ["acos", number | ExpressionSpecification] | ["asin", number | ExpressionSpecification] | ["atan", number | ExpressionSpecification] | ["ceil", number | ExpressionSpecification] | ["cos", number | ExpressionSpecification] | ["distance", GeoJSON.GeoJSON] | ["e"] | ["floor", number | ExpressionSpecification] | ["ln", number | ExpressionSpecification] | ["ln2"] | ["log10", number | ExpressionSpecification] | ["log2", number | ExpressionSpecification] | ["max", number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] | ["min", number | ExpressionSpecification, ...(number | ExpressionSpecification)[]] | ["pi"] | ["round", number | ExpressionSpecification] | ["sin", number | ExpressionSpecification] | ["sqrt", number | ExpressionSpecification] | ["tan", number | ExpressionSpecification] | ["zoom"] | ["heatmap-density"] | ["elevation"] | ["global-state", string];
52
+ type ExpressionFilterSpecification = boolean | ExpressionSpecification;
53
+ type LegacyFilterSpecification = ["has", string] | ["!has", string] | ["==", string, string | number | boolean] | ["!=", string, string | number | boolean] | [">", string, string | number | boolean] | [">=", string, string | number | boolean] | ["<", string, string | number | boolean] | ["<=", string, string | number | boolean] | ["in", string, ...(string | number | boolean)[]] | ["!in", string, ...(string | number | boolean)[]] | ["all", ...LegacyFilterSpecification[]] | ["any", ...LegacyFilterSpecification[]] | ["none", ...LegacyFilterSpecification[]];
54
+ type FilterSpecification = ExpressionFilterSpecification | LegacyFilterSpecification;
55
+ type CameraFunctionSpecification<T> = {
56
+ type: "exponential";
57
+ stops: Array<[number, T]>;
58
+ } | {
59
+ type: "interval";
60
+ stops: Array<[number, T]>;
61
+ };
62
+ type PropertyValueSpecification<T> = T | CameraFunctionSpecification<T> | ExpressionSpecification;
63
+ //#endregion
64
+ //#region src/maps/types.d.ts
65
+ type CacheConfig$1 = {
66
+ enabled?: boolean;
67
+ lifespanDays?: number;
68
+ };
69
+ type NormalizedCacheConfig = {
70
+ enabled: boolean;
71
+ lifespanDays: number;
72
+ };
73
+ type LayerDescriptor = {
74
+ type: string;
75
+ name: string;
76
+ };
77
+ type AddLayerOptions = {
78
+ sourceId?: string;
79
+ filter?: FilterSpecification;
80
+ };
81
+ type BoundsInput = {
82
+ type?: string;
83
+ features: Array<{
84
+ geometry?: {
85
+ type?: string;
86
+ coordinates?: unknown;
87
+ };
88
+ }>;
89
+ };
90
+ type RouteFeature = {
91
+ type: 'Feature';
92
+ geometry: {
93
+ type: 'LineString';
94
+ coordinates: [number, number][];
95
+ };
96
+ properties: {
97
+ duration: number;
98
+ distance: number;
99
+ [key: string]: unknown;
100
+ };
101
+ };
102
+ type SearchResult = {
103
+ id?: string | number;
104
+ latitude?: number;
105
+ longitude?: number;
106
+ icon_img?: string;
107
+ name?: string;
108
+ [key: string]: unknown;
109
+ };
110
+ type YarrowMapConfigOptions = {
111
+ container: HTMLElement | string;
112
+ center: [number, number];
113
+ zoom?: number;
114
+ minZoom?: number;
115
+ maxZoom?: number;
116
+ theme?: 'light' | 'dark';
117
+ cache?: CacheConfig$1;
118
+ brandBadgePosition?: BrandBadgePosition$1;
119
+ controls?: YarrowControlsConfig$1;
120
+ excludePoiLayer?: boolean;
121
+ apiKey: string;
122
+ };
123
+ type SearchOptions = {
124
+ layerName?: string;
125
+ iconImage?: string;
126
+ highlightColor?: string;
127
+ pulseAnimation?: boolean;
128
+ zoomToResults?: boolean;
129
+ onIconClick?: (lat: number, lng: number, properties: Record<string, unknown>) => void;
130
+ onResultsUpdate?: (results: SearchResult[]) => void;
131
+ onLoadingStateChange?: (state: 'firstRender' | 'rerender' | false) => void;
132
+ };
133
+ //#endregion
134
+ //#region src/maps/config.d.ts
135
+ declare class YarrowMapConfig {
136
+ readonly container: HTMLElement | string;
137
+ readonly center: [number, number];
138
+ readonly zoom: number;
139
+ readonly minZoom: number;
140
+ readonly maxZoom: number;
141
+ theme: 'light' | 'dark';
142
+ cache: NormalizedCacheConfig;
143
+ brandBadgePosition: BrandBadgePosition$1;
144
+ controls: ReturnType<typeof normalizeYarrowControlsConfig>;
145
+ excludePoiLayer: boolean;
146
+ apiKey: string;
147
+ constructor(config: YarrowMapConfigOptions);
148
+ }
149
+ //#endregion
150
+ //#region src/maps/routing/types.d.ts
151
+ type RouteLineCap = 'butt' | 'round' | 'square';
152
+ type RouteLineJoin = 'bevel' | 'round' | 'miter';
153
+ interface RouteEventContext {
154
+ feature: RouteFeature;
155
+ index: number;
156
+ isBest: boolean;
157
+ layerId: string;
158
+ lngLat: {
159
+ lng: number;
160
+ lat: number;
161
+ };
162
+ originalEvent: MapMouseEvent;
163
+ }
164
+ interface BuildRouteOptions {
165
+ profile: string;
166
+ coordinates: [number, number][];
167
+ routeColor?: string;
168
+ routeWidth?: number;
169
+ routeOpacity?: number;
170
+ alternativeColor?: string;
171
+ alternativeWidth?: number;
172
+ alternativeOpacity?: number;
173
+ routeLineCap?: RouteLineCap;
174
+ routeLineJoin?: RouteLineJoin;
175
+ fitBounds?: boolean;
176
+ clearOldRoutes?: boolean;
177
+ language?: string;
178
+ layerPrefix?: string;
179
+ onRouteClick?: (ctx: RouteEventContext) => void;
180
+ onRouteHover?: (ctx: RouteEventContext | null) => void;
181
+ }
182
+ interface BuildRouteResult {
183
+ features: RouteFeature[];
184
+ directions: RouteDirection[][];
185
+ meta: {
186
+ profile: string;
187
+ totalRoutes: number;
188
+ bestRouteIndex: number;
189
+ duration: number;
190
+ distance: number;
191
+ };
192
+ }
193
+ type RouteDirection = {
194
+ distance: number;
195
+ duration: number;
196
+ instruction: string;
197
+ [key: string]: unknown;
198
+ };
199
+ //#endregion
200
+ //#region src/maps/yarrow.d.ts
201
+ declare class YarrowMap {
202
+ private static isCacheProtocolRegistered;
203
+ config: YarrowMapConfig;
204
+ map?: Map$1;
205
+ layers: LayerDescriptor[];
206
+ private layerManager;
207
+ private markerManager;
208
+ private routingBuilder;
209
+ private routingRenderer;
210
+ private searchManager;
211
+ private stylesManager;
212
+ private navigationManager;
213
+ private eventManager;
214
+ private badgeController;
215
+ private controlsController;
216
+ private badgeResizeObserver?;
217
+ private poiLayerConfig?;
218
+ private poiSourceConfig?;
219
+ constructor(config: YarrowMapConfig);
220
+ private ensureCacheProtocol;
221
+ private get cacheLifespanMs();
222
+ private isCacheEnabled;
223
+ private transformRequestForCache;
224
+ private fetchJson;
225
+ private addApiKeyToUrl;
226
+ private loadImageFromSrc;
227
+ private loadIconImage;
228
+ private getIconsMap;
229
+ private addIconsToMap;
230
+ private patchMapRemoveForBadgeCleanup;
231
+ private getControlsInsetForCollision;
232
+ private syncOverlayCollisionInset;
233
+ private stopBadgeCollisionObserver;
234
+ private startBadgeCollisionObserver;
235
+ fixStyle(style: StyleSpecification | null | undefined): void;
236
+ private updateLayersArray;
237
+ private storePoiLayerConfig;
238
+ private removePoiLayerFromStyle;
239
+ init(): Promise<void>;
240
+ clearCache(): Promise<void>;
241
+ changeStyles(styleType?: string): Promise<StyleSpecification>;
242
+ changeTheme(theme: 'light' | 'dark'): Promise<StyleSpecification>;
243
+ changeBrandBadgePosition(position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'): BrandBadgePosition$1;
244
+ enablePoiLayer(): void;
245
+ disablePoiLayer(): void;
246
+ zoomTo(lat: number, lng: number, zoom: number): void;
247
+ fitBounds(data: BoundsInput): void;
248
+ getBoundingBox(data: BoundsInput): {
249
+ xMin: number;
250
+ xMax: number;
251
+ yMin: number;
252
+ yMax: number;
253
+ };
254
+ onMoveEnd(callback: (lat: number, lng: number, zoom: number) => void): void;
255
+ onMapClick(callback: (lat: number, lng: number) => void): void;
256
+ onIconClick(layerGroup: 'pois' | 'buildings', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
257
+ onLayerClick(layerName: 'buildings' | 'pois', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
258
+ changeBackgroundColor(color: string): void;
259
+ addSource(sourceId: string, data: GeoJSONSourceSpecification['data']): void;
260
+ updateSourceData(sourceId: string, data: GeoJSONSourceSpecification['data']): void;
261
+ addLayer(layerName: string, layerType: LayerSpecification['type'], featureCollection: GeoJSONSourceSpecification['data'], paint?: LayerSpecification['paint'], layout?: LayerSpecification['layout'], iconSettings?: {
262
+ width?: number;
263
+ height?: number;
264
+ }, options?: AddLayerOptions): void;
265
+ removeLayer(layerName: string): void;
266
+ setFeatureState(feature: FeatureIdentifier, state: Record<string, unknown>): void;
267
+ queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): import("maplibre-gl").MapGeoJSONFeature[];
268
+ addMarker(coordinates: [number, number], options?: MarkerOptions): Marker | null;
269
+ removeMarker(marker: Marker | null): void;
270
+ renderRoutes(routes: RouteFeature[], baseLayerName?: string): void;
271
+ buildRoute(options: BuildRouteOptions): Promise<BuildRouteResult>;
272
+ buildRouteWithLabels(startCoordinates: [number, number], endCoordinates: [number, number], profile: string): Promise<{
273
+ features: RouteFeature[];
274
+ directions: unknown[];
275
+ }>;
276
+ buildMultiSegmentRouteWithLabels(coordinates: [number, number][], profile: string, language?: string): Promise<{
277
+ features: RouteFeature[];
278
+ directions: unknown[][];
279
+ }>;
280
+ clearAllRoutes(): void;
281
+ highlightSearchResults(query: string, options?: SearchOptions): () => void;
282
+ }
283
+ //#endregion
284
+ //#region src/react/useYarrowMap.d.ts
285
+ type CacheConfig = {
286
+ enabled?: boolean;
287
+ lifespanDays?: number;
288
+ };
289
+ type BrandBadgePosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
290
+ type YarrowControlsPosition = 'left' | 'left-top' | 'left-bottom' | 'right' | 'right-top' | 'right-bottom';
291
+ type YarrowControlsConfig = {
292
+ enabled?: boolean;
293
+ position?: YarrowControlsPosition;
294
+ zoom?: boolean;
295
+ compass?: boolean;
296
+ };
297
+ type YarrowMapReactConfig = {
298
+ center: [number, number];
299
+ zoom?: number;
300
+ minZoom?: number;
301
+ maxZoom?: number;
302
+ theme?: 'light' | 'dark';
303
+ cache?: CacheConfig;
304
+ brandBadgePosition?: BrandBadgePosition;
305
+ controls?: YarrowControlsConfig;
306
+ excludePoiLayer?: boolean;
307
+ apiKey: string;
308
+ };
309
+ type UseYarrowMapOptions = {
310
+ config: YarrowMapReactConfig;
311
+ configKey?: string | number;
312
+ onReady?: (map: YarrowMap) => void;
313
+ };
314
+ type UseYarrowMapResult = {
315
+ containerRef: React.RefObject<HTMLDivElement | null>;
316
+ map: YarrowMap | null;
317
+ isReady: boolean;
318
+ error: Error | null;
319
+ };
320
+ declare const useYarrowMap: ({
321
+ config,
322
+ configKey,
323
+ onReady
324
+ }: UseYarrowMapOptions) => UseYarrowMapResult;
325
+ //#endregion
326
+ //#region src/react/YarrowMapView.d.ts
327
+ type YarrowMapViewProps = {
328
+ config: YarrowMapReactConfig;
329
+ configKey?: string | number;
330
+ onReady?: Parameters<typeof useYarrowMap>[0]['onReady'];
331
+ className?: string;
332
+ style?: React.CSSProperties;
333
+ };
334
+ declare const YarrowMapView: ({
335
+ config,
336
+ configKey,
337
+ onReady,
338
+ className,
339
+ style
340
+ }: YarrowMapViewProps) => import("react/jsx-runtime").JSX.Element;
341
+ //#endregion
342
+ export { UseYarrowMapOptions, UseYarrowMapResult, YarrowMapReactConfig, YarrowMapView, useYarrowMap };