@yarrow-uz/yarrow-map-web-sdk 1.0.40

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.
@@ -0,0 +1,23 @@
1
+ export type BrandBadgeTheme = 'light' | 'dark';
2
+ export type BrandBadgePosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
3
+ export declare const DEFAULT_BRAND_BADGE_POSITION: BrandBadgePosition;
4
+ export declare const normalizeBrandBadgePosition: (position?: BrandBadgePosition) => BrandBadgePosition;
5
+ type BrandBadgeState = {
6
+ theme: BrandBadgeTheme;
7
+ position: BrandBadgePosition;
8
+ };
9
+ export declare class BrandBadgeController {
10
+ private host?;
11
+ private container?;
12
+ private observer?;
13
+ private enforcerInterval?;
14
+ private state;
15
+ mount(container: HTMLElement, state: BrandBadgeState): void;
16
+ update(state: BrandBadgeState): void;
17
+ teardown(removeHost?: boolean): void;
18
+ private getHostInlineStyle;
19
+ private applyHostStyles;
20
+ private createHost;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=brandBadge.d.ts.map
@@ -0,0 +1,157 @@
1
+ import { type GeoJSONSourceSpecification, type LayerSpecification, Map as MaplibreMap, type StyleSpecification } from 'maplibre-gl';
2
+ import { type BrandBadgePosition } from './brandBadge';
3
+ import { type NormalizedYarrowControlsConfig, type YarrowControlsConfig, type YarrowControlsPosition } from './yarrowControls';
4
+ type CacheConfig = {
5
+ enabled?: boolean;
6
+ lifespanDays?: number;
7
+ };
8
+ type YarrowMapConfigOptions = {
9
+ container: HTMLElement | string;
10
+ center: [number, number];
11
+ zoom?: number;
12
+ minZoom?: number;
13
+ maxZoom?: number;
14
+ theme?: 'light' | 'dark';
15
+ cache?: CacheConfig;
16
+ brandBadgePosition?: BrandBadgePosition;
17
+ controls?: YarrowControlsConfig;
18
+ };
19
+ type NormalizedCacheConfig = {
20
+ enabled: boolean;
21
+ lifespanDays: number;
22
+ };
23
+ type LayerDescriptor = {
24
+ type: string;
25
+ name: string;
26
+ };
27
+ type BoundsInput = {
28
+ type?: string;
29
+ features: Array<{
30
+ geometry?: {
31
+ type?: string;
32
+ coordinates?: unknown;
33
+ };
34
+ }>;
35
+ };
36
+ type RouteFeature = {
37
+ type: 'Feature';
38
+ geometry: {
39
+ type: 'LineString';
40
+ coordinates: [number, number][];
41
+ };
42
+ properties: {
43
+ duration: number;
44
+ distance: number;
45
+ [key: string]: unknown;
46
+ };
47
+ };
48
+ type RouteBuildResult = {
49
+ features: RouteFeature[];
50
+ directions: unknown[];
51
+ };
52
+ type MultiRouteBuildResult = {
53
+ features: RouteFeature[];
54
+ directions: unknown[][];
55
+ };
56
+ type SearchResult = {
57
+ id?: string | number;
58
+ latitude?: number;
59
+ longitude?: number;
60
+ icon_img?: string;
61
+ name?: string;
62
+ [key: string]: unknown;
63
+ };
64
+ declare class YarrowMapConfig {
65
+ container: HTMLElement | string;
66
+ center: [number, number];
67
+ zoom: number;
68
+ minZoom: number;
69
+ maxZoom: number;
70
+ theme: 'light' | 'dark';
71
+ cache: NormalizedCacheConfig;
72
+ brandBadgePosition: BrandBadgePosition;
73
+ controls: NormalizedYarrowControlsConfig;
74
+ constructor(config: YarrowMapConfigOptions);
75
+ constructor(container: HTMLElement | string, center: [number, number], zoom?: number, minZoom?: number, maxZoom?: number, theme?: 'light' | 'dark', cache?: CacheConfig, brandBadgePosition?: BrandBadgePosition, controls?: YarrowControlsConfig);
76
+ }
77
+ declare class YarrowMap {
78
+ private static isCacheProtocolRegistered;
79
+ config: YarrowMapConfig;
80
+ map?: MaplibreMap;
81
+ layers: LayerDescriptor[];
82
+ private brandBadgeController;
83
+ private yarrowControlsController;
84
+ constructor(config: YarrowMapConfig);
85
+ private ensureCacheProtocol;
86
+ private get cacheLifespanMs();
87
+ private isCacheEnabled;
88
+ private transformRequestForCache;
89
+ private fetchJson;
90
+ private loadImageFromSrc;
91
+ private loadIconImage;
92
+ private getIconsMap;
93
+ private addIconsToMap;
94
+ private patchMapRemoveForBadgeCleanup;
95
+ clearCache(): Promise<void>;
96
+ fixStyle(style: StyleSpecification | null | undefined): void;
97
+ init(): Promise<void>;
98
+ changeStyles(styleType: string | undefined): Promise<StyleSpecification>;
99
+ changeTheme(theme: 'light' | 'dark'): Promise<StyleSpecification>;
100
+ zoomTo(lat: number, lng: number, zoom: number): void;
101
+ fitBounds(data: BoundsInput): void;
102
+ getBoundingBox(data: BoundsInput): {
103
+ xMin: number;
104
+ yMin: number;
105
+ xMax: number;
106
+ yMax: number;
107
+ };
108
+ onMoveEnd(callback: (lat: number, lng: number, zoom: number) => void): void;
109
+ onMapClick(callback: (lat: number, lng: number) => void): void;
110
+ onIconClick(layerGroup: 'pois' | 'buildings', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
111
+ onLayerClick(layerName: 'buildings' | 'pois', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
112
+ changeBackgroundColor(color: string): void;
113
+ addLayer(layerName: string, layerType: LayerSpecification['type'], featureCollection: GeoJSONSourceSpecification['data'], paint?: Record<string, unknown>, layout?: Record<string, unknown>, iconSettings?: {
114
+ width?: number;
115
+ height?: number;
116
+ }): void;
117
+ addMarker(coordinates: [number, number], options?: {
118
+ element?: HTMLElement;
119
+ color?: string;
120
+ draggable?: boolean;
121
+ anchor?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
122
+ onClick?: () => void;
123
+ }): maplibregl.Marker | null;
124
+ removeMarker(marker: maplibregl.Marker | null): void;
125
+ removeLayer(layerName: string): void;
126
+ renderRoutes(routes: RouteFeature[], baseLayerName?: string): void;
127
+ buildRouteWithLabels(startCoordinates: [number, number], endCoordinates: [number, number], profile: string): Promise<RouteBuildResult>;
128
+ buildMultiSegmentRouteWithLabels(coordinates: [number, number][], profile: string, language?: string): Promise<MultiRouteBuildResult>;
129
+ clearAllRoutes(): void;
130
+ highlightSearchResults(query: string, highlightOptions?: {
131
+ layerName?: string;
132
+ iconImage?: string;
133
+ highlightColor?: string;
134
+ pulseAnimation?: boolean;
135
+ zoomToResults?: boolean;
136
+ onIconClick?: (lat: number, lng: number, properties: Record<string, unknown>) => void;
137
+ onResultsUpdate?: (results: SearchResult[]) => void;
138
+ onLoadingStateChange?: (state: 'firstRender' | 'rerender' | false) => void;
139
+ }): () => void;
140
+ private currentBusRouteInterval?;
141
+ private currentBusMarkers;
142
+ private currentRouteLayers;
143
+ private readonly MAX_BUSES;
144
+ private svgCache;
145
+ private mapMoveTimeout?;
146
+ private busPositions;
147
+ private animationFrameId?;
148
+ private animateBusMarkers;
149
+ private startBusAnimation;
150
+ private stopBusAnimation;
151
+ showBusRoute(route_id?: string): Promise<() => void>;
152
+ }
153
+ export { YarrowMap, YarrowMapConfig };
154
+ export type { BrandBadgePosition };
155
+ export type { YarrowControlsConfig, YarrowControlsPosition };
156
+ export type { YarrowMapConfigOptions };
157
+ //# sourceMappingURL=yarrow.d.ts.map
@@ -0,0 +1,44 @@
1
+ import type { Map as MaplibreMap } from 'maplibre-gl';
2
+ export type YarrowControlsPosition = 'left' | 'right';
3
+ export type YarrowControlsConfig = {
4
+ enabled?: boolean;
5
+ position?: YarrowControlsPosition;
6
+ zoom?: boolean;
7
+ compass?: boolean;
8
+ };
9
+ export type NormalizedYarrowControlsConfig = {
10
+ enabled: boolean;
11
+ position: YarrowControlsPosition;
12
+ zoom: boolean;
13
+ compass: boolean;
14
+ };
15
+ export declare const DEFAULT_YARROW_CONTROLS_CONFIG: NormalizedYarrowControlsConfig;
16
+ export declare const normalizeYarrowControlsConfig: (controls?: YarrowControlsConfig) => NormalizedYarrowControlsConfig;
17
+ type YarrowControlsState = {
18
+ theme: 'light' | 'dark';
19
+ controls: NormalizedYarrowControlsConfig;
20
+ };
21
+ export declare class YarrowControlsController {
22
+ private map?;
23
+ private host?;
24
+ private container?;
25
+ private zoomInButton?;
26
+ private zoomOutButton?;
27
+ private compassButton?;
28
+ private compassNeedle?;
29
+ private onRotate?;
30
+ private onZoomInClick?;
31
+ private onZoomOutClick?;
32
+ private onCompassClick?;
33
+ private state;
34
+ mount(map: MaplibreMap, state: YarrowControlsState): void;
35
+ update(state: YarrowControlsState): void;
36
+ teardown(removeHost?: boolean): void;
37
+ private createDom;
38
+ private applyHostPosition;
39
+ private renderVisibleButtons;
40
+ private attachMapListeners;
41
+ private updateCompassNeedle;
42
+ }
43
+ export {};
44
+ //# sourceMappingURL=yarrowControls.d.ts.map