@yarrow-uz/rn-map-sdk 0.4.0 → 0.5.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.
@@ -0,0 +1,1336 @@
1
+ import { NativeSyntheticEvent, ViewProps } from "react-native";
2
+ import { CameraRef, CameraRef as CameraRef$1, MapProps, MapRef, MapRef as MapRef$1, MarkerProps, OfflinePackStatus, PressEventWithFeatures } from "@maplibre/maplibre-react-native";
3
+ import { ReactElement, ReactNode, Ref, RefObject } from "react";
4
+ declare const YARROW_MAP_URL: string;
5
+ declare const YARROW_SEARCH_API_URL: string;
6
+ declare function setYarrowApiKey(apiKey: string): void;
7
+ declare function getYarrowApiKey(): string;
8
+ /**
9
+ * Appends the configured API key as the `api_key` query parameter. Returns the
10
+ * url unchanged when no key is configured yet or the url cannot be parsed.
11
+ */
12
+ declare function addApiKeyToUrl(url: string): string;
13
+ type CacheConfig = {
14
+ enabled?: boolean;
15
+ lifespanDays?: number;
16
+ };
17
+ type NormalizedCacheConfig = {
18
+ enabled: boolean;
19
+ lifespanDays: number;
20
+ };
21
+ type CachedArrayBufferResponse = {
22
+ data: ArrayBuffer;
23
+ cacheControl: string | null;
24
+ expires: string | null;
25
+ contentType: string | null;
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
+ /** Style-API endpoint returning the icon registry (`IconListItem[]`). */
49
+ declare const ICONS_ENDPOINT = "/icons-image";
50
+ type SearchResult = {
51
+ id?: string | number;
52
+ latitude?: number;
53
+ longitude?: number;
54
+ icon_img?: string;
55
+ name?: string;
56
+ /** Backend category, e.g. `{ id: 789, name: "school" }`. The `name` field
57
+ * matches sprite names loaded into the map's icon registry at init, so
58
+ * it's used as a fallback icon source when `icon_img` is missing. */
59
+ category?: {
60
+ id?: number;
61
+ name?: string;
62
+ };
63
+ [key: string]: unknown;
64
+ };
65
+ declare const DEFAULT_CACHE_LIFESPAN_DAYS = 30;
66
+ declare const MILLISECONDS_PER_DAY: number;
67
+ declare const TILE_CACHE_NAME = "yarrow-cache-v1-tile";
68
+ declare const ICON_CACHE_NAME = "yarrow-cache-v1-icon";
69
+ declare const CACHE_PROTOCOL = "yarrowcache";
70
+ declare const CACHED_AT_HEADER = "x-yarrow-cached-at";
71
+ /** A geographic bounding box in degrees. */
72
+ type BoundingBox = {
73
+ xMin: number;
74
+ xMax: number;
75
+ yMin: number;
76
+ yMax: number;
77
+ };
78
+ /**
79
+ * Computes the geographic bounding box of a FeatureCollection whose features
80
+ * are Points, LineStrings or Polygons. Pure platform-agnostic math shared by
81
+ * the web and React Native SDKs' camera helpers.
82
+ */
83
+ declare function getBoundingBox(data: BoundsInput): BoundingBox;
84
+ /**
85
+ * Structural subset of maplibre-gl's `RequestParameters` covering the fields
86
+ * used for the network fetch. Any real maplibre `RequestParameters` object is
87
+ * assignable to this type.
88
+ */
89
+ type RequestParametersLike = {
90
+ method?: string;
91
+ headers?: {
92
+ [key: string]: string;
93
+ };
94
+ body?: BodyInit | null;
95
+ credentials?: 'omit' | 'same-origin' | 'include';
96
+ };
97
+ declare const hasCacheStorage: () => boolean;
98
+ declare const fetchArrayBufferWithCache: (url: string, cacheName: string, lifespanMs: number, abortController: AbortController, requestParameters?: RequestParametersLike) => Promise<CachedArrayBufferResponse>;
99
+ /** Routing API endpoint used by `fetchRoutes()`. */
100
+ declare const ROUTE_API_URL = "https://api.yarrow.uz/api/routing/route";
101
+ /**
102
+ * Turn modifier returned by the routing API for a direction step.
103
+ * Falls back to `string` for any value not enumerated here.
104
+ */
105
+ type RouteDirectionModifier = 'move' | 'left' | 'right' | 'slight left' | 'slight right' | 'sharp left' | 'sharp right' | 'straight' | 'uturn' | (string & {});
106
+ /**
107
+ * A single turn-by-turn step in a route's directions.
108
+ *
109
+ * `distance`/`duration` are omitted on terminal steps (e.g. the final
110
+ * "arrive" instruction), so they are optional. `to_street` is only present
111
+ * when the step transitions onto a named street.
112
+ */
113
+ type RouteDirection = {
114
+ instruction: string;
115
+ modifier?: RouteDirectionModifier;
116
+ modifier_key?: string;
117
+ to_street?: string;
118
+ distance?: number;
119
+ duration?: number;
120
+ [key: string]: unknown;
121
+ };
122
+ /** Platform-agnostic input for `fetchRoutes()` — the network half of
123
+ * `buildRoute()`. Rendering/callback options stay in the platform SDKs. */
124
+ type FetchRoutesInput = {
125
+ profile: string;
126
+ coordinates: [number, number][];
127
+ language?: string;
128
+ /** Cancels the routing request. */
129
+ signal?: AbortSignal;
130
+ };
131
+ interface RoutesMeta {
132
+ profile: string;
133
+ totalRoutes: number;
134
+ bestRouteIndex: number;
135
+ duration: number;
136
+ distance: number;
137
+ }
138
+ interface FetchRoutesResult {
139
+ features: RouteFeature[];
140
+ directions: RouteDirection[][];
141
+ meta: RoutesMeta;
142
+ }
143
+ /**
144
+ * Network half of the routing flow: POSTs the route request to the Yarrow
145
+ * routing API, parses and normalizes the response (coordinate order fix
146
+ * included). Rendering, events and camera work stay in the platform SDKs —
147
+ * they consume the returned features/directions/meta verbatim.
148
+ *
149
+ * Early "no route" outcomes resolve to an empty result (never throw), exactly
150
+ * like the web SDK's historic `buildRoute()` behavior.
151
+ */
152
+ declare function fetchRoutes(input: FetchRoutesInput): Promise<FetchRoutesResult>;
153
+ declare const transformRouteCoordinates: (features: RouteFeature[]) => RouteFeature[];
154
+ declare const haversineDistance: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
155
+ interface FetchSearchResultsInput {
156
+ lat: number;
157
+ lon: number;
158
+ page?: number;
159
+ pageSize?: number;
160
+ signal: AbortSignal;
161
+ }
162
+ /**
163
+ * Queries the Yarrow search API around a coordinate. Pure network + mapping —
164
+ * marker rendering stays in the platform SDKs.
165
+ */
166
+ declare function fetchSearchResults(query: string, input: FetchSearchResultsInput): Promise<SearchResult[]>;
167
+ type YarrowStyleType = 'default' | 'satellite' | 'hybrid';
168
+ /**
169
+ * Validates a user-supplied style type, warning (and falling back to
170
+ * `"default"`) on anything unrecognized. Verbatim behavior of the web SDK's
171
+ * `changeStyles()` guard.
172
+ */
173
+ declare function normalizeStyleType(styleType?: string): YarrowStyleType;
174
+ /**
175
+ * Style-fetch endpoint for a style type/theme combination, e.g.
176
+ * `/styles/satellite/?dark=true`. Verbatim behavior of the web SDK's
177
+ * `YarrowStylesManager.buildStyleEndpoint()`.
178
+ */
179
+ declare function buildStyleEndpoint(styleType: YarrowStyleType, theme: 'light' | 'dark'): string;
180
+ /**
181
+ * Public alias of `STORAGE_KEY` so platform SDKs can build storage adapters
182
+ * (e.g. React Native AsyncStorage bridges) without hard-coding the key.
183
+ */
184
+ declare const USER_TOKEN_STORAGE_KEY = "yarrow:user_token";
185
+ /**
186
+ * Minimal persistence contract for the anonymous user token. The default
187
+ * resolution uses `localStorage` when available (guarded — this is the only
188
+ * file in core allowed to touch it); shells without a DOM (e.g. React Native)
189
+ * can inject their own storage via `setTokenStorage`.
190
+ */
191
+ interface TokenStorage {
192
+ getItem(key: string): string | null;
193
+ setItem(key: string, value: string): void;
194
+ }
195
+ declare function setTokenStorage(storage: TokenStorage): void;
196
+ declare function getOrCreateUserToken(): string;
197
+ type ClusterBadgeProps = {
198
+ /** Cluster centroid as `[longitude, latitude]`. */
199
+ lngLat: [number, number];
200
+ /** Number of markers the badge stands in for. */
201
+ count: number;
202
+ /** Visual theme — picks the badge colors (web parity). */
203
+ theme: 'light' | 'dark';
204
+ onPress?: () => void;
205
+ };
206
+ /**
207
+ * The count badge that stands in for clustered highlight/search markers —
208
+ * the native counterpart of the web SDK's cluster DOM marker (blue circle,
209
+ * white border, bold count).
210
+ */
211
+ declare const ClusterBadge: import("react").MemoExoticComponent<({ lngLat, count, theme, onPress }: ClusterBadgeProps) => import("react/jsx-runtime").JSX.Element>;
212
+ /**
213
+ * Clustering configuration and normalization — the declarative counterpart of
214
+ * the web SDK's `setClustering`. Defaults match the web SDK exactly:
215
+ * 60 px merge radius, no clustering above zoom 16, clusters need ≥ 2 markers.
216
+ */
217
+ declare const DEFAULT_CLUSTER_RADIUS_PX = 60;
218
+ declare const DEFAULT_CLUSTER_MAX_ZOOM = 16;
219
+ declare const DEFAULT_CLUSTER_MIN_POINTS = 2;
220
+ /** A single marker that belongs to a pressed cluster. */
221
+ type ClusterChild = {
222
+ /**
223
+ * The marker id. Web parity uses numeric POI ids; the RN SDK also accepts
224
+ * string keys (search results without an `id` get index-based keys).
225
+ */
226
+ id: number | string;
227
+ lng: number;
228
+ lat: number;
229
+ };
230
+ /**
231
+ * Called when a cluster badge is pressed, with the POIs it represents. Return
232
+ * exactly `false` to suppress the default zoom-to-expand behaviour.
233
+ */
234
+ type ClusterClickHandler = (children: ClusterChild[]) => unknown;
235
+ /**
236
+ * Clustering config for highlight/search markers. Off by default; pass `true`
237
+ * to enable with defaults, or an object to tune it (passing an object also
238
+ * enables it).
239
+ */
240
+ type ClusteringConfig = boolean | {
241
+ /** Merge distance in screen points. Default 60. */
242
+ radius?: number;
243
+ /** Above this zoom, markers never cluster. Default 16. */
244
+ maxZoom?: number;
245
+ /** Minimum markers within `radius` to form a cluster. Min/default 2. */
246
+ minPoints?: number;
247
+ /** Overrides/augments the default zoom-to-expand on cluster press. */
248
+ onClusterClick?: ClusterClickHandler;
249
+ };
250
+ type NormalizedClusteringConfig = {
251
+ enabled: boolean;
252
+ radius: number;
253
+ maxZoom: number;
254
+ minPoints: number;
255
+ onClusterClick?: ClusterClickHandler;
256
+ };
257
+ /**
258
+ * Normalizes the public clustering option (`true` / config object / falsy)
259
+ * into a fully-resolved config. Passing an object enables clustering.
260
+ * `minPoints` is clamped to at least 2 — a "cluster" of one is just the
261
+ * marker itself.
262
+ */
263
+ declare function normalizeClusteringConfig(input: ClusteringConfig | undefined): NormalizedClusteringConfig;
264
+ /** A marker eligible for clustering: its id and coordinates. */
265
+ type ClusterPoint = {
266
+ id: number | string;
267
+ lng: number;
268
+ lat: number;
269
+ };
270
+ /** A computed cluster: badge position plus the members it stands in for. */
271
+ type PixelCluster = {
272
+ /**
273
+ * Key used to reuse a badge across recomputes (the first member's id —
274
+ * grouping is deterministic, so this is stable).
275
+ */
276
+ key: number | string;
277
+ lng: number;
278
+ lat: number;
279
+ members: ClusterChild[];
280
+ };
281
+ /**
282
+ * Groups projected points greedily by pixel distance: each unvisited point
283
+ * seeds a group and absorbs every remaining point within `radius`. O(n²), but
284
+ * the highlighted/search-marker count is small (dozens at most), so this
285
+ * stays cheap and deterministic. Ported from the web SDK's cluster engine.
286
+ */
287
+ declare function groupByPixelRadius<T extends {
288
+ x: number;
289
+ y: number;
290
+ }>(items: T[], radius: number): T[][];
291
+ /**
292
+ * Base-style layer targets — mirrors the web SDK's `ClickLayerTarget`. Unlike
293
+ * the web SDK (which resolves layer ids dynamically from the loaded style),
294
+ * native cannot enumerate style layers, so these are the canonical Yarrow
295
+ * style layer ids, verified against the served `/styles/` document (identical
296
+ * in light and dark). Apps can override per target via the options argument
297
+ * of `useYarrowLayerPress` if the style changes.
298
+ */
299
+ type ClickLayerTarget = 'pois' | 'buildings' | 'mahalla' | 'district' | 'region' | 'country';
300
+ declare const YARROW_CLICK_LAYER_IDS: Record<ClickLayerTarget, string[]>;
301
+ type LayerPressInfo = {
302
+ lat: number;
303
+ lng: number;
304
+ properties: Record<string, unknown>;
305
+ /** `true` when the pressed POI is currently highlighted (pois target only). */
306
+ selected?: boolean;
307
+ };
308
+ type UseYarrowLayerPressOptions = {
309
+ /** Per-target layer-id overrides (the base map's layer ids). */
310
+ layerIds?: Partial<Record<ClickLayerTarget, string[]>>;
311
+ };
312
+ /**
313
+ * Base-style-layer press handler — the native counterpart of the web SDK's
314
+ * `onIconClick('pois' | 'buildings')` and `onLayerClick(<admin label>)`. On
315
+ * every map press it queries the rendered features at the press point for the
316
+ * target layers and invokes `handler` with the topmost hit. Must be called
317
+ * inside `<YarrowMapView>` — extract a child component rendered as a map
318
+ * child (hooks outside the map can't see the runtime):
319
+ *
320
+ * ```tsx
321
+ * function PoiPressReporter() {
322
+ * useYarrowLayerPress('pois', ({ lat, lng, properties, selected }) => {
323
+ * console.log('POI pressed', properties.id, selected);
324
+ * });
325
+ * return null;
326
+ * }
327
+ *
328
+ * <YarrowMapView apiKey={KEY}>
329
+ * <PoiPressReporter />
330
+ * </YarrowMapView>
331
+ * ```
332
+ *
333
+ * Unlike the web SDK, targets resolve to the canonical Yarrow style layer
334
+ * ids (verified against the served `/styles/` document, identical in light
335
+ * and dark) instead of dynamic style inspection — override `layerIds` if
336
+ * your style variant names them differently.
337
+ */
338
+ declare function useYarrowLayerPress(target: ClickLayerTarget | ClickLayerTarget[], handler: (info: LayerPressInfo) => void, options?: UseYarrowLayerPressOptions): void;
339
+ type UseYarrowSearchOptions = {
340
+ /** Latitude the search ranks results around. */
341
+ lat: number;
342
+ /** Longitude the search ranks results around. */
343
+ lon: number;
344
+ /** Result page. Default `1`. */
345
+ page?: number;
346
+ /** Results per page. Default `15`. */
347
+ pageSize?: number;
348
+ /** Debounce before querying, ms. Default `300`. */
349
+ debounceMs?: number;
350
+ /** Set `false` to pause querying — pending results clear while paused.
351
+ * Default `true`. */
352
+ enabled?: boolean;
353
+ };
354
+ type UseYarrowSearchResult = {
355
+ results: SearchResult[];
356
+ isLoading: boolean;
357
+ error: Error | null;
358
+ };
359
+ /**
360
+ * Debounced, abortable search against the Yarrow search API.
361
+ *
362
+ * Requires the API key to be configured (`YarrowMapView` does this on mount;
363
+ * otherwise call `setYarrowApiKey()` first).
364
+ *
365
+ * ```tsx
366
+ * const { results, isLoading } = useYarrowSearch(query, {
367
+ * lat: position?.lat ?? 41.2995,
368
+ * lon: position?.lng ?? 69.2401,
369
+ * });
370
+ * ```
371
+ */
372
+ declare const useYarrowSearch: (query: string, options: UseYarrowSearchOptions) => UseYarrowSearchResult;
373
+ type UseYarrowMapSearchOptions = UseYarrowSearchOptions & {
374
+ /**
375
+ * Re-runs the search when the camera moves at least `thresholdMeters`
376
+ * (default 500, web parity) after a `debounceMs` settle delay (default 250,
377
+ * web parity). Pass `false` to disable; `true` uses both defaults.
378
+ */
379
+ refetchOnMove?: boolean | {
380
+ thresholdMeters?: number;
381
+ debounceMs?: number;
382
+ };
383
+ };
384
+ type UseYarrowMapSearchResult = UseYarrowSearchResult & {
385
+ /** The coordinate the current results were fetched around. */
386
+ center: {
387
+ lat: number;
388
+ lon: number;
389
+ };
390
+ };
391
+ /**
392
+ * `useYarrowSearch` plus web-parity re-query on camera movement: when the map
393
+ * moves ≥ 500 m from where the current results were fetched for, the search
394
+ * re-runs around the new center. Must be called inside `<YarrowMapView>` to
395
+ * observe camera moves (outside one it behaves exactly like `useYarrowSearch`).
396
+ *
397
+ * ```tsx
398
+ * const { results, isLoading, center } = useYarrowMapSearch(query, {
399
+ * lat: 41.2995,
400
+ * lon: 69.2401,
401
+ * refetchOnMove: true,
402
+ * });
403
+ * <SearchResultsLayer results={results} />
404
+ * ```
405
+ */
406
+ declare function useYarrowMapSearch(query: string, options: UseYarrowMapSearchOptions): UseYarrowMapSearchResult;
407
+ type UseYarrowRoutingOptions = {
408
+ /** Routing profile, e.g. `"driving"`, `"walking"`. Default `"driving"`. */
409
+ profile?: string;
410
+ /** Language for turn-by-turn directions. */
411
+ language?: string;
412
+ };
413
+ type BuildRouteInput = {
414
+ /** Waypoints as `[longitude, latitude][]` (minimum two). */
415
+ coordinates: [number, number][];
416
+ /** Overrides the hook-level profile for this request. */
417
+ profile?: string;
418
+ /** Overrides the hook-level language for this request. */
419
+ language?: string;
420
+ /** Cancels the request. */
421
+ signal?: AbortSignal;
422
+ };
423
+ type UseYarrowRoutingResult = {
424
+ /** Renderable route features — feed straight into `<RouteLayer routes={…}>`. */
425
+ routes: RouteFeature[];
426
+ /** Turn-by-turn directions per route. */
427
+ directions: RouteDirection[][];
428
+ /** Duration/distance/profile summary of the best route, when present. */
429
+ meta: RoutesMeta | null;
430
+ isLoading: boolean;
431
+ error: Error | null;
432
+ /** Fetches routes and stores them in state. Rejects on network failure —
433
+ * "no route found" resolves to an empty result instead. */
434
+ buildRoute: (input: BuildRouteInput) => Promise<FetchRoutesResult>;
435
+ /** Clears routes/directions/meta and any error. */
436
+ clearRoutes: () => void;
437
+ };
438
+ /**
439
+ * Headless routing state for the Yarrow routing API — pairs with
440
+ * `<RouteLayer>` for rendering.
441
+ *
442
+ * ```tsx
443
+ * const { routes, isLoading, buildRoute } = useYarrowRouting({ profile: 'driving' });
444
+ * <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
445
+ * <RouteLayer routes={routes} />
446
+ * </YarrowMapView>
447
+ * ```
448
+ */
449
+ declare const useYarrowRouting: (options?: UseYarrowRoutingOptions) => UseYarrowRoutingResult;
450
+ /** Icon registry: sprite name (e.g. `"school"`) → image URL. */
451
+ type YarrowIconsMap = Record<string, string>;
452
+ /**
453
+ * Fetches the Yarrow icon registry (`/icons-image`) and reduces it to a
454
+ * name → URL map. Native has no Cache Storage, so the result is not persisted
455
+ * — `<YarrowMapView>` fetches it once per mount when icons are enabled.
456
+ *
457
+ * Also seeds core's API-key module state (like every standalone client), so
458
+ * the key is current even if the hook runs before a map mounts.
459
+ */
460
+ declare function fetchYarrowIcons(apiKey?: string): Promise<YarrowIconsMap>;
461
+ /**
462
+ * Best-effort icon URL for a search-result `category.name` / tile
463
+ * `node_type`. The registry is keyed by sprite names, which usually match
464
+ * category names — the same fallback the web SDK applies via its icon
465
+ * expression.
466
+ */
467
+ declare function resolveCategoryIcon(iconsByName: YarrowIconsMap | undefined, name: string | undefined): string | undefined;
468
+ type YarrowImagesProps = {
469
+ /** Icon registry entries to add to the style: sprite name → image URL. */
470
+ iconsByName: YarrowIconsMap;
471
+ /**
472
+ * Fired when the style references an icon the registry doesn't cover —
473
+ * the map should re-fetch the registry (once) to recover.
474
+ */
475
+ onMissingIcon?: (name: string) => void;
476
+ };
477
+ /**
478
+ * Adds the Yarrow icon images to the native style so symbol layers can
479
+ * resolve their `icon-image` names — the native counterpart of the web SDK's
480
+ * `addIconsToMap` prefetch plus its missing-image resolver. `Images` accepts
481
+ * remote URLs and downloads them natively; `onImageMissing` covers icons
482
+ * referenced before the registry fetch lands or after a failed fetch.
483
+ */
484
+ declare const YarrowImages: import("react").MemoExoticComponent<({ iconsByName, onMissingIcon }: YarrowImagesProps) => import("react/jsx-runtime").JSX.Element>;
485
+ type BrandBadgePosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
486
+ declare const DEFAULT_BRAND_BADGE_SCALE = 1;
487
+ /**
488
+ * Configuration for the React Native map — the `container`-free counterpart
489
+ * of the web SDK's `YarrowMapConfigOptions`. The native view is sized by the
490
+ * consuming component's layout, so there is no container to name.
491
+ */
492
+ type YarrowMapConfigOptions = {
493
+ /** Yarrow API key from the dashboard. Required. */
494
+ apiKey: string;
495
+ /** Initial map center as `[longitude, latitude]`, e.g. Tashkent. */
496
+ center: [number, number];
497
+ /** Initial zoom level. Default `10`. */
498
+ zoom?: number;
499
+ /** Minimum zoom level. Default `0`. */
500
+ minZoom?: number;
501
+ /** Maximum zoom level. Default `19`. */
502
+ maxZoom?: number;
503
+ /** Style theme. Default `"light"`. */
504
+ theme?: 'light' | 'dark';
505
+ /** Base style. Default `"default"` (street map). */
506
+ styleType?: YarrowStyleType;
507
+ };
508
+ /**
509
+ * Validated, defaulted RN map configuration. Mirrors the web SDK's
510
+ * `YarrowMapConfig` minus the DOM container (the native view is sized by the
511
+ * consuming app's layout) and minus web-only rendering options (hover,
512
+ * clustering, controls, tile cache — none of which exist on native).
513
+ */
514
+ declare class YarrowMapConfig {
515
+ readonly center: [number, number];
516
+ readonly zoom: number;
517
+ readonly minZoom: number;
518
+ readonly maxZoom: number;
519
+ theme: 'light' | 'dark';
520
+ styleType: YarrowStyleType;
521
+ apiKey: string;
522
+ constructor(config: YarrowMapConfigOptions);
523
+ }
524
+ type RoutePressEvent = NativeSyntheticEvent<PressEventWithFeatures>;
525
+ /**
526
+ * Called when a rendered route is pressed, with the press event (carrying the
527
+ * GeoJSON feature) and the route's index in the `routes` array.
528
+ */
529
+ type RoutePressHandler = (event: RoutePressEvent, routeIndex: number) => void;
530
+ type RouteLayerProps = {
531
+ /** Route line features — feed with `useYarrowRouting().routes` or your own
532
+ * `fetchRoutes()` result. Best route renders bold; the rest as fainter,
533
+ * thinner alternatives. */
534
+ routes: RouteFeature[];
535
+ /** Index of the route to highlight. Default `0`. */
536
+ bestIndex?: number;
537
+ /** Best-route color. Default `#22c55e`. */
538
+ routeColor?: string;
539
+ /** Best-route line width. Default `5`. */
540
+ routeWidth?: number;
541
+ /** Best-route opacity. Default `1`. */
542
+ routeOpacity?: number;
543
+ /** Alternative-route color. Default `#aaaaaa` — every alternative shares
544
+ * it, matching the web SDK's `buildRoute()`. */
545
+ alternativeColor?: string;
546
+ /** Alternative-route line width. Default `2.5`. */
547
+ alternativeWidth?: number;
548
+ /** Alternative-route opacity. Default `0.5`. */
549
+ alternativeOpacity?: number;
550
+ /** Prefix for source/layer ids. Default `"yarrow-route"`. */
551
+ layerPrefix?: string;
552
+ /** Called when a rendered route line is pressed. */
553
+ onPressRoute?: RoutePressHandler;
554
+ /**
555
+ * Distinct-series mode — web `renderRoutes()` parity. Every route draws in
556
+ * its own color from the shared `ROUTE_COLORS` palette (cycled), width 4
557
+ * and opacity 0.8, with no best/alternative distinction; the
558
+ * `bestIndex`/route/alternative style props are ignored.
559
+ */
560
+ distinct?: boolean;
561
+ };
562
+ /**
563
+ * Declarative route rendering: one GeoJSON source + line layer per route.
564
+ * Compose inside `<YarrowMapView>` and drive it with `useYarrowRouting()`:
565
+ *
566
+ * ```tsx
567
+ * const { routes } = useYarrowRouting();
568
+ * <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
569
+ * <RouteLayer routes={routes} onPressRoute={…} />
570
+ * </YarrowMapView>
571
+ * ```
572
+ *
573
+ * Pass `distinct` to render independent series instead of best-route-plus-
574
+ * alternatives — the declarative counterpart of the web SDK's
575
+ * `renderRoutes()`.
576
+ */
577
+ declare const RouteLayer: import("react").MemoExoticComponent<({ routes, bestIndex, routeColor, routeWidth, routeOpacity, alternativeColor, alternativeWidth, alternativeOpacity, layerPrefix, onPressRoute, distinct }: RouteLayerProps) => import("react/jsx-runtime").JSX.Element[]>;
578
+ /**
579
+ * Full style URL for MapLibre React Native's `mapStyle` prop, built from the
580
+ * platform-agnostic style endpoint plus the configured API key. The key comes
581
+ * from core's module state (`setYarrowApiKey`) — `YarrowMapView` calls it for
582
+ * you; standalone callers must set it first.
583
+ */
584
+ declare function buildStyleUrl(styleType?: string, theme?: 'light' | 'dark'): string;
585
+ type YarrowMapViewProps = YarrowMapConfigOptions & {
586
+ /** Called once the native map finished loading its style. */
587
+ onReady?: (map: MapRef$1) => void;
588
+ /** Called when the style fails to load. */
589
+ onLoadError?: (error: Error) => void;
590
+ /** Called when the user presses the map (bubbles up from pressable
591
+ * sources unless they call `event.stopPropagation()`). */
592
+ onPress?: MapProps['onPress'];
593
+ /**
594
+ * Called when the camera finishes moving — web `onMoveEnd` parity:
595
+ * `(lat, lng, zoom)`.
596
+ */
597
+ onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
598
+ /** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
599
+ * The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
600
+ cameraRef?: Ref<CameraRef$1>;
601
+ /**
602
+ * MapLibre attribution button. Default `false` — the Yarrow brand badge
603
+ * covers attribution duties (web SDK parity). Pass `true` to restore the
604
+ * native ornament.
605
+ */
606
+ attribution?: boolean;
607
+ /**
608
+ * MapLibre logo. Default `false` — the Yarrow brand badge replaces it
609
+ * (web SDK parity). Pass `true` to restore the native ornament.
610
+ */
611
+ logo?: boolean;
612
+ /** Compass ornament. Default `true`. */
613
+ compass?: boolean;
614
+ /**
615
+ * Corner for the Yarrow brand badge overlay (web `brandBadgePosition`
616
+ * parity). Default `"bottom-left"`.
617
+ */
618
+ brandBadgePosition?: BrandBadgePosition;
619
+ /**
620
+ * Size multiplier over the web badge's 106px logo — `1` is exact web
621
+ * sizing (the default). Pass e.g. `1.4` for a bigger brand mark on
622
+ * phones.
623
+ */
624
+ brandBadgeScale?: number;
625
+ /**
626
+ * Android map render mode pass-through. MapLibre's own default is
627
+ * `"surface"`; `"texture"` renders the map into the view hierarchy
628
+ * (needed for view-hierarchy overlays/screenshots). The brand badge
629
+ * never requires it.
630
+ */
631
+ androidView?: MapProps['androidView'];
632
+ /** Fire-and-forget DAU ping when the style first loads. Default `true`. */
633
+ dauTracking?: boolean;
634
+ /**
635
+ * Fetch the Yarrow icon registry and add it to the style so POI symbols and
636
+ * category-icon fallbacks work (web icon-pipeline parity). Disable only if
637
+ * your style/labels don't need the Yarrow icons. Default `true`.
638
+ */
639
+ icons?: boolean;
640
+ /** Style for the wrapping native view. Default `{ flex: 1 }`. */
641
+ style?: ViewProps['style'];
642
+ /** Sources/layers/markers rendered inside the map. */
643
+ children?: ReactNode;
644
+ };
645
+ /**
646
+ * React Native Yarrow map. Renders MapLibre Native with a Yarrow style URL
647
+ * (theme + styleType aware, API key attached) and a default camera, and
648
+ * provides the runtime (refs, icon registry, camera/event subscriptions) to
649
+ * the SDK layers rendered inside it.
650
+ *
651
+ * ```tsx
652
+ * const mapRef = useRef<MapRef>(null);
653
+ * <YarrowMapView
654
+ * apiKey="YOUR_API_KEY"
655
+ * center={[69.2401, 41.2995]} // Tashkent
656
+ * zoom={12}
657
+ * theme="dark"
658
+ * onReady={(map) => map.getCenter().then(console.log)}
659
+ * />
660
+ * ```
661
+ *
662
+ * Camera props (`center`, `zoom`) apply only on mount — recenter through
663
+ * `cameraRef` (`flyTo`, `jumpTo`, `fitBounds`). Theme and styleType changes
664
+ * hot-swap the style URL natively.
665
+ */
666
+ declare const YarrowMapView: import("react").ForwardRefExoticComponent<YarrowMapConfigOptions & {
667
+ /** Called once the native map finished loading its style. */
668
+ onReady?: (map: MapRef$1) => void;
669
+ /** Called when the style fails to load. */
670
+ onLoadError?: (error: Error) => void;
671
+ /** Called when the user presses the map (bubbles up from pressable
672
+ * sources unless they call `event.stopPropagation()`). */
673
+ onPress?: MapProps['onPress'];
674
+ /**
675
+ * Called when the camera finishes moving — web `onMoveEnd` parity:
676
+ * `(lat, lng, zoom)`.
677
+ */
678
+ onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
679
+ /** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
680
+ * The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
681
+ cameraRef?: Ref<CameraRef$1>;
682
+ /**
683
+ * MapLibre attribution button. Default `false` — the Yarrow brand badge
684
+ * covers attribution duties (web SDK parity). Pass `true` to restore the
685
+ * native ornament.
686
+ */
687
+ attribution?: boolean;
688
+ /**
689
+ * MapLibre logo. Default `false` — the Yarrow brand badge replaces it
690
+ * (web SDK parity). Pass `true` to restore the native ornament.
691
+ */
692
+ logo?: boolean;
693
+ /** Compass ornament. Default `true`. */
694
+ compass?: boolean;
695
+ /**
696
+ * Corner for the Yarrow brand badge overlay (web `brandBadgePosition`
697
+ * parity). Default `"bottom-left"`.
698
+ */
699
+ brandBadgePosition?: BrandBadgePosition;
700
+ /**
701
+ * Size multiplier over the web badge's 106px logo — `1` is exact web
702
+ * sizing (the default). Pass e.g. `1.4` for a bigger brand mark on
703
+ * phones.
704
+ */
705
+ brandBadgeScale?: number;
706
+ /**
707
+ * Android map render mode pass-through. MapLibre's own default is
708
+ * `"surface"`; `"texture"` renders the map into the view hierarchy
709
+ * (needed for view-hierarchy overlays/screenshots). The brand badge
710
+ * never requires it.
711
+ */
712
+ androidView?: MapProps['androidView'];
713
+ /** Fire-and-forget DAU ping when the style first loads. Default `true`. */
714
+ dauTracking?: boolean;
715
+ /**
716
+ * Fetch the Yarrow icon registry and add it to the style so POI symbols and
717
+ * category-icon fallbacks work (web icon-pipeline parity). Disable only if
718
+ * your style/labels don't need the Yarrow icons. Default `true`.
719
+ */
720
+ icons?: boolean;
721
+ /** Style for the wrapping native view. Default `{ flex: 1 }`. */
722
+ style?: ViewProps['style'];
723
+ /** Sources/layers/markers rendered inside the map. */
724
+ children?: ReactNode;
725
+ } & import("react").RefAttributes<MapRef$1>>;
726
+ type HighlightMarkerViewProps = {
727
+ /** Coordinates as `[longitude, latitude]`. */
728
+ lngLat: [number, number];
729
+ /** Icon URL; when absent a blue dot is rendered (web parity). */
730
+ iconUrl?: string;
731
+ /** Label rendered under the icon. */
732
+ title?: string;
733
+ /** Icon size in points: a number (square) or `[width, height]`. Default 56. */
734
+ iconSize?: number | [number, number];
735
+ /** Plays the exit animation instead of the enter one. */
736
+ leaving?: boolean;
737
+ onPress?: () => void;
738
+ };
739
+ /**
740
+ * The animated icon+label marker shared by `<PoiHighlightLayer>` and
741
+ * `<SearchResultsLayer>` — the native counterpart of the web SDK's
742
+ * `createMarkerElement` + enter/exit CSS transitions. The scale/fade runs on
743
+ * an inner view (never on the `Marker` itself, which the map repositions
744
+ * every frame).
745
+ */
746
+ declare const HighlightMarkerView: import("react").MemoExoticComponent<({ lngLat, iconUrl, title, iconSize, leaving, onPress }: HighlightMarkerViewProps) => import("react/jsx-runtime").JSX.Element>;
747
+ type YarrowMarkerProps = {
748
+ /** Coordinates as `[longitude, latitude]`. */
749
+ lngLat: [number, number];
750
+ /** Which part of the marker sits on the coordinate. Default `'bottom'`. */
751
+ anchor?: MarkerProps['anchor'];
752
+ /** Pixel offset `[x, y]` applied relative to the anchor. */
753
+ offset?: [number, number];
754
+ /** Called when the marker is pressed. */
755
+ onPress?: () => void;
756
+ /** Marker content — a single view (icon, label, bubble, …). */
757
+ children: ReactElement;
758
+ };
759
+ /**
760
+ * Declarative counterpart of the web SDK's `addMarker()` / `removeMarker()`.
761
+ * Mounting places the marker, unmounting removes it; the React lifecycle
762
+ * replaces the imperative manager pair.
763
+ *
764
+ * ```tsx
765
+ * <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
766
+ * <YarrowMarker lngLat={[69.2401, 41.2995]} onPress={() => …}>
767
+ * <PinIcon />
768
+ * </YarrowMarker>
769
+ * </YarrowMapView>
770
+ * ```
771
+ */
772
+ declare const YarrowMarker: import("react").MemoExoticComponent<({ lngLat, anchor, offset, onPress, children }: YarrowMarkerProps) => import("react/jsx-runtime").JSX.Element>;
773
+ type ZoomToOptions = {
774
+ /** Animation duration in ms. Web's `speed` option has no native equivalent. */
775
+ duration?: number;
776
+ };
777
+ type FitBoundsOptions = {
778
+ /** Padding in points around the fitted bounds. Default `50`. */
779
+ padding?: number;
780
+ /** Animation duration in ms. Default `1000`. */
781
+ duration?: number;
782
+ };
783
+ type YarrowCamera = {
784
+ /** Flies the camera to a coordinate at `zoom`. */
785
+ zoomTo(lat: number, lng: number, zoom: number, options?: ZoomToOptions): void;
786
+ /**
787
+ * Fits the camera to the bounds of a GeoJSON FeatureCollection. Applies the
788
+ * web SDK's minimum-dimension expansion (0.003°) so single points don't
789
+ * over-zoom. Web's `maxZoom` cap is not supported natively.
790
+ */
791
+ fitBounds(data: BoundsInput, options?: FitBoundsOptions): void;
792
+ /** Computes the geographic bounding box of a FeatureCollection. */
793
+ getBoundingBox(data: BoundsInput): BoundingBox;
794
+ };
795
+ /**
796
+ * Web-parity camera helpers on top of a `CameraRef`. Reads the enclosing
797
+ * `<YarrowMapView>` camera when called inside the map; otherwise pass a ref:
798
+ *
799
+ * ```tsx
800
+ * const cameraRef = useRef<CameraRef>(null);
801
+ * <YarrowMapView apiKey={KEY} cameraRef={cameraRef}>…</YarrowMapView>
802
+ * const camera = useYarrowCamera(cameraRef);
803
+ * camera.zoomTo(41.2995, 69.2401, 14);
804
+ * ```
805
+ */
806
+ declare function useYarrowCamera(cameraRefInput?: RefObject<CameraRef$1 | null>): YarrowCamera;
807
+ /** Download progress of an offline region (normalized native pack status). */
808
+ type OfflineRegionProgress = Omit<OfflinePackStatus, 'id'>;
809
+ /**
810
+ * Geographic bounds as `[west, south, east, north]` — the flat corner order
811
+ * MapLibre React Native's `LngLatBounds` uses.
812
+ */
813
+ type OfflineBounds = [west: number, south: number, east: number, north: number];
814
+ type OfflineRegionDownloadOptions = {
815
+ /**
816
+ * Unique region name. Re-downloading an existing name returns the stored
817
+ * pack instead of creating a duplicate; a different name is required per
818
+ * style combination.
819
+ */
820
+ name: string;
821
+ /** Region bounds as `[west, south, east, north]`. */
822
+ bounds: OfflineBounds;
823
+ /** Lowest zoom level to pack. Default `8`. */
824
+ minZoom?: number;
825
+ /** Highest zoom level to pack. Default `15`. */
826
+ maxZoom?: number;
827
+ /** Style the pack pins. Default `"default"`. Offline style swaps only
828
+ * work for styles that were packed. */
829
+ styleType?: YarrowStyleType;
830
+ /** Theme the pack pins. Default `"light"`. */
831
+ theme?: 'light' | 'dark';
832
+ /**
833
+ * Days after which `listRegions()` flags the region `isStale`. Unlike the
834
+ * web cache there is no native TTL — staleness is informational; refresh
835
+ * with `handle.invalidate()`. Default `null` (never stale).
836
+ */
837
+ maxAgeDays?: number | null;
838
+ /** Delete and re-download an existing region with this name. Default `false`. */
839
+ force?: boolean;
840
+ /** Extra app-specific data stored alongside the region metadata, readable
841
+ * back via `listRegions()` → `userMetadata`. JSON-serializable only —
842
+ * native stores metadata as a JSON string. */
843
+ metadata?: Record<string, unknown>;
844
+ /** Progress while the region downloads. */
845
+ onProgress?: (progress: OfflineRegionProgress) => void;
846
+ /** Download failure. Fatal for the region — call `handle.resume()` to retry. */
847
+ onError?: (error: YarrowOfflineError) => void;
848
+ };
849
+ type OfflineRegionErrorCode =
850
+ /** The name exists with different parameters than the stored pack. */
851
+ 'params-mismatch' |
852
+ /** The region is too large for the native offline system. */
853
+ 'region-too-large' |
854
+ /** The native tile-count limit was hit (see `setTileCountLimit`). */
855
+ 'tile-count-limit-exceeded' | 'network' | 'disk' |
856
+ /** A handle referenced a region that no longer exists. */
857
+ 'not-found' | 'unknown';
858
+ type YarrowOfflineError = Error & {
859
+ code: OfflineRegionErrorCode;
860
+ /** Native pack id, when the error is tied to a region. */
861
+ regionId?: string;
862
+ };
863
+ type OfflineRegionSummary = {
864
+ id: string;
865
+ name: string;
866
+ styleType: YarrowStyleType;
867
+ theme: 'light' | 'dark';
868
+ bounds: OfflineBounds;
869
+ minZoom: number;
870
+ maxZoom: number;
871
+ status: OfflineRegionProgress['state'];
872
+ /** Download percentage, 0–100. */
873
+ percentage: number;
874
+ /** Bytes of tiles stored so far. */
875
+ completedTileSize: number;
876
+ /** True when `maxAgeDays` has elapsed since `createdAt`. */
877
+ isStale: boolean;
878
+ /** Epoch ms when the region was created. */
879
+ createdAt: number;
880
+ /** The `metadata` the app passed to `downloadRegion`, if any. */
881
+ userMetadata?: Record<string, unknown>;
882
+ };
883
+ type OfflineRegionHandle = {
884
+ /** Native pack id (UUID). */
885
+ id: string;
886
+ name: string;
887
+ /**
888
+ * Resolves with the final progress on completion, rejects with a
889
+ * `YarrowOfflineError` on the first download failure. It stays rejected
890
+ * after that — retry with `resume()` and track recovery through
891
+ * `onProgress` / `refreshStatus()` instead of awaiting `done` again.
892
+ */
893
+ done: Promise<OfflineRegionProgress>;
894
+ /** Current status snapshot from the native layer. */
895
+ refreshStatus: () => Promise<OfflineRegionProgress>;
896
+ pause: () => Promise<void>;
897
+ resume: () => Promise<void>;
898
+ /** Revalidates stored tiles against the server and re-fetches changed
899
+ * ones — the cheap refresh path. */
900
+ invalidate: () => Promise<void>;
901
+ delete: () => Promise<void>;
902
+ };
903
+ type OfflineRegionEstimate = {
904
+ /** Unique `z/x/y` tiles across `[minZoom, maxZoom]`. Each style downloads
905
+ * one tile per source (≈12 vector sources, satellite adds a raster one),
906
+ * so network/storage cost scales with the style's source count too. */
907
+ tileCount: number;
908
+ /** Rough storage estimate: `tileCount × avgTileBytes`. */
909
+ estSizeBytes: number;
910
+ tilesPerLevel: Array<{
911
+ zoom: number;
912
+ tiles: number;
913
+ }>;
914
+ };
915
+ /** Default minimum zoom for offline regions. */
916
+ declare const DEFAULT_OFFLINE_MIN_ZOOM = 8;
917
+ /** Default maximum zoom for offline regions. */
918
+ declare const DEFAULT_OFFLINE_MAX_ZOOM = 15;
919
+ /** Schema version of the pack metadata this SDK writes. */
920
+ declare const OFFLINE_METADATA_VERSION = 1;
921
+ /**
922
+ * Rough bytes per downloaded `z/x/y` tile, empirically measured from a
923
+ * Tashkent z14 tile: ≈64 KB × ~8 sources carrying data ≈ 0.5 MB. A region's
924
+ * true size depends on the style's source count and local data density —
925
+ * pass `avgTileBytes` for a tighter estimate.
926
+ */
927
+ declare const AVG_TILE_BYTES = 500000;
928
+ type EstimateRegionInput = {
929
+ bounds: OfflineBounds;
930
+ minZoom: number;
931
+ maxZoom: number;
932
+ /** Bytes per `z/x/y` tile used for the size estimate. Default `500_000`. */
933
+ avgTileBytes?: number;
934
+ };
935
+ /**
936
+ * Estimates the download/storage cost of an offline region — pure tile math,
937
+ * no native calls. Tile counts are exact for the XYZ scheme; byte estimates
938
+ * are rough (see `AVG_TILE_BYTES`).
939
+ *
940
+ * ```ts
941
+ * const { tileCount, estSizeBytes } = estimateRegion({
942
+ * bounds: [69.15, 41.2, 69.4, 41.4], // Tashkent
943
+ * minZoom: 8,
944
+ * maxZoom: 15,
945
+ * });
946
+ * ```
947
+ */
948
+ declare const estimateRegion: (input: EstimateRegionInput) => OfflineRegionEstimate;
949
+ type UseYarrowOfflineRegionsOptions = {
950
+ /** Yarrow API key from the dashboard. Required. */
951
+ apiKey: string;
952
+ /** Poll interval while any region is downloading, ms. Default `1000`. */
953
+ pollMs?: number;
954
+ };
955
+ type UseYarrowOfflineRegionsResult = {
956
+ /** All regions created through the SDK, newest first. */
957
+ regions: OfflineRegionSummary[];
958
+ /** True during the initial `listRegions()` load. */
959
+ isLoading: boolean;
960
+ error: Error | null;
961
+ /** Re-reads regions from the native layer. */
962
+ refresh: () => Promise<void>;
963
+ /** Starts a region download (idempotent by `name` — see
964
+ * `YarrowOfflineManager.downloadRegion`). */
965
+ download: (options: OfflineRegionDownloadOptions) => Promise<OfflineRegionHandle>;
966
+ pause: (name: string) => Promise<void>;
967
+ resume: (name: string) => Promise<void>;
968
+ /** Revalidates stored tiles against the server — the cheap refresh path. */
969
+ invalidate: (name: string) => Promise<void>;
970
+ remove: (name: string) => Promise<void>;
971
+ };
972
+ /**
973
+ * Offline region state for settings/offline screens — pairs with
974
+ * `YarrowOfflineManager`. Polls the native layer while downloads run, so
975
+ * `regions` (and progress bars) stay current.
976
+ *
977
+ * ```tsx
978
+ * const { regions, download, remove } = useYarrowOfflineRegions({ apiKey });
979
+ * await download({ name: 'tashkent', bounds: [69.15, 41.2, 69.4, 41.4] });
980
+ * ```
981
+ */
982
+ declare const useYarrowOfflineRegions: (options: UseYarrowOfflineRegionsOptions) => UseYarrowOfflineRegionsResult;
983
+ type YarrowOfflineManagerOptions = {
984
+ /** Yarrow API key from the dashboard. Required. */
985
+ apiKey: string;
986
+ };
987
+ /**
988
+ * Offline region manager for React Native — a Yarrow-flavoured wrapper around
989
+ * MapLibre React Native's `OfflineManager`.
990
+ *
991
+ * The web SDK's `yarrowcache` protocol cannot exist on native (no
992
+ * `addProtocol`), so offline support here is region packs: pick a bounding
993
+ * box and zoom range, download it once, and the map renders from the native
994
+ * offline database with no network.
995
+ *
996
+ * ```ts
997
+ * const offline = new YarrowOfflineManager({ apiKey: 'YOUR_API_KEY' });
998
+ * const { tileCount, estSizeBytes } = offline.estimateRegion({
999
+ * bounds: [69.15, 41.2, 69.4, 41.4], // Tashkent
1000
+ * minZoom: 8,
1001
+ * maxZoom: 15,
1002
+ * });
1003
+ * const region = await offline.downloadRegion({
1004
+ * name: 'tashkent-city',
1005
+ * bounds: [69.15, 41.2, 69.4, 41.4],
1006
+ * maxAgeDays: 30,
1007
+ * onProgress: (p) => console.log(`${p.percentage}%`),
1008
+ * });
1009
+ * await region.done;
1010
+ * ```
1011
+ */
1012
+ declare class YarrowOfflineManager {
1013
+ private readonly apiKey;
1014
+ /**
1015
+ * Downloads this session created, keyed by pack id. MLRN's listener maps
1016
+ * are last-write-wins, so re-attaching listeners over a live download
1017
+ * would strand the original handle — `reattachExisting` consults this map
1018
+ * and reuses the original `done` instead.
1019
+ */
1020
+ private readonly activeDownloads;
1021
+ constructor(options: YarrowOfflineManagerOptions);
1022
+ /**
1023
+ * Pure tile-math estimate of a region's download/storage cost — no native
1024
+ * calls. See `estimateRegion` for the math and caveats.
1025
+ */
1026
+ estimateRegion(input: Parameters<typeof estimateRegion>[0]): OfflineRegionEstimate;
1027
+ /**
1028
+ * Starts (or resumes) a region download. Resolves with a handle once the
1029
+ * pack is created and downloading — progress arrives via `options.onProgress`
1030
+ * and `handle.done` settles with the outcome.
1031
+ *
1032
+ * Idempotent by `name`: an existing matching region is returned as-is
1033
+ * (resumed when incomplete); a name reused with different parameters throws
1034
+ * a `params-mismatch` error. Pass `force: true` to delete and re-download.
1035
+ */
1036
+ downloadRegion(options: OfflineRegionDownloadOptions): Promise<OfflineRegionHandle>;
1037
+ /** Lists regions created through this SDK (native packs created directly
1038
+ * against `OfflineManager` are not included), newest first. */
1039
+ listRegions(): Promise<OfflineRegionSummary[]>;
1040
+ /** Returns the handle for a region by name, or `null`. */
1041
+ getRegion(name: string): Promise<OfflineRegionHandle | null>;
1042
+ /** Ambient cache (seen-tiles LRU) max size in bytes. May erase resources
1043
+ * when shrinking — call once at app startup. `0` disables the cache. */
1044
+ setAmbientCacheSize(size: number): Promise<void>;
1045
+ /** Revalidates ambient-cache tiles against the server — the recommended
1046
+ * way to refresh cached data. */
1047
+ invalidateAmbientCache(): Promise<void>;
1048
+ /** Erases ambient-cache resources. Computationally expensive. */
1049
+ clearAmbientCache(): Promise<void>;
1050
+ /** Maximum number of tiles offline packs may store. Raise it when large
1051
+ * regions fail with a `tile-count-limit-exceeded` error. */
1052
+ setTileCountLimit(limit: number): void;
1053
+ /** Download status event throttle in ms. Platform-defined default (300 ms
1054
+ * today on both iOS and Android). Note errors bypass the throttle. */
1055
+ setProgressEventThrottle(ms: number): void;
1056
+ /** Deletes the offline database (ambient cache + packs), then
1057
+ * reinitializes it. Destructive — and MLRN's JS pack cache only clears
1058
+ * on app restart, so subsequent reads may hit stale ids (guarded as
1059
+ * `not-found`). Prefer per-region `invalidate`/`delete`. */
1060
+ resetDatabase(): Promise<void>;
1061
+ private hydrate;
1062
+ private findRegionPacks;
1063
+ private findParamMismatches;
1064
+ /** Attaches listeners to a pack that may have outlived the JS layer
1065
+ * (created in a previous app session) and builds a fresh handle.
1066
+ *
1067
+ * Deliberately cautious: it never hijacks a download this session owns,
1068
+ * never attaches listeners to packs that don't need them, and — on
1069
+ * Android, where attaching an observer *activates* the region — never
1070
+ * wakes a paused pack unless the caller explicitly asked for a download. */
1071
+ private reattachExisting;
1072
+ private toHandle;
1073
+ private deletePack;
1074
+ }
1075
+ /** Coordinates the caller already holds (e.g. from a search result). */
1076
+ type PlaceLocation = {
1077
+ lat: number;
1078
+ lng: number;
1079
+ };
1080
+ /** Coordinates (+ optional icon URL and title) resolved before placing a marker. */
1081
+ type ResolvedPoiData = {
1082
+ lng: number;
1083
+ lat: number;
1084
+ iconUrl?: string;
1085
+ title?: string;
1086
+ };
1087
+ /** Payload passed to a highlight marker's press handler. */
1088
+ type PoiHighlightPressInfo = {
1089
+ /** The highlighted POI id. */
1090
+ id: number;
1091
+ lng: number;
1092
+ lat: number;
1093
+ /** Resolved title/icon of the marker, if any. */
1094
+ title?: string;
1095
+ iconUrl?: string;
1096
+ };
1097
+ /**
1098
+ * Per-id data the caller already holds. Anything provided here skips the
1099
+ * corresponding lookup (viewport query / place-detail API) — the cheapest
1100
+ * resolution wins, exactly like the web SDK's `HighlightPOIOptions`.
1101
+ */
1102
+ type HighlightPoiData = {
1103
+ location?: PlaceLocation;
1104
+ icon?: string;
1105
+ title?: string;
1106
+ };
1107
+ type PoiHighlightLayerProps = {
1108
+ /** POI id(s) to highlight — the declarative selection state. */
1109
+ ids: number | number[];
1110
+ /**
1111
+ * Per-id data the caller already holds (location/icon/title). Anything
1112
+ * provided skips the corresponding lookup.
1113
+ */
1114
+ dataById?: Record<number, HighlightPoiData>;
1115
+ /** Icon size in points: a number (square) or `[width, height]`. Default 56. */
1116
+ iconSize?: number | [number, number];
1117
+ /** Flies the camera to the highlighted POI(s) once resolved. Default `false`. */
1118
+ panTo?: boolean;
1119
+ /** Target zoom for `panTo` of a single POI. Default `13`. */
1120
+ zoom?: number;
1121
+ /** Clusters the highlight markers (`true` or a config object). */
1122
+ clustering?: ClusteringConfig;
1123
+ /** Called when a highlight marker is pressed. */
1124
+ onHighlightPress?: (info: PoiHighlightPressInfo) => void;
1125
+ /** Called when a POI could not be resolved (its highlight is rolled back). */
1126
+ onResolveError?: (id: number) => void;
1127
+ };
1128
+ /**
1129
+ * Declarative counterpart of the web SDK's `highlightPOI()`: renders an
1130
+ * animated icon+label marker for each highlighted POI id, resolving each id
1131
+ * cheapest-first (caller data → rendered tiles → place-detail API).
1132
+ * Highlight state is owned by the `ids` prop (or
1133
+ * `useYarrowPoiHighlight().highlightedIds`); removing an id plays the exit
1134
+ * animation and unmounts the marker.
1135
+ *
1136
+ * Known native limitation (documented in the README): the base style's own
1137
+ * POI icon is not hidden behind the highlight marker — native has no runtime
1138
+ * `setFilter`, so the marker simply draws on top of it.
1139
+ *
1140
+ * ```tsx
1141
+ * <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
1142
+ * <PoiHighlightLayer ids={[123]} dataById={{ 123: { location } }} panTo />
1143
+ * </YarrowMapView>
1144
+ * ```
1145
+ */
1146
+ declare function PoiHighlightLayer({ ids, dataById, iconSize, panTo, zoom, clustering, onHighlightPress, onResolveError }: PoiHighlightLayerProps): import("react/jsx-runtime").JSX.Element | null;
1147
+ /** Camera state snapshot delivered to region-change subscribers. */
1148
+ type YarrowRegionState = {
1149
+ /** Map center as `[lng, lat]`. */
1150
+ center: [number, number];
1151
+ zoom: number;
1152
+ };
1153
+ /** A raw map press, delivered to press subscribers before `onPress` props. */
1154
+ type YarrowMapPress = {
1155
+ /** Press location as `[lng, lat]`. */
1156
+ lngLat: [number, number];
1157
+ /** Press location in viewport pixels `[x, y]` (for `queryRenderedFeatures`). */
1158
+ point: [number, number];
1159
+ };
1160
+ /**
1161
+ * Shared runtime state that `<YarrowMapView>` provides to the layers and hooks
1162
+ * rendered inside it. Everything is optional at the type level so hooks can
1163
+ * also run outside a map (they no-op with a console warning where relevant).
1164
+ */
1165
+ type YarrowMapRuntime = {
1166
+ apiKey: string;
1167
+ /** Visual theme of the map, for theme-aware overlay styling. */
1168
+ theme: 'light' | 'dark';
1169
+ mapRef: RefObject<MapRef$1 | null>;
1170
+ cameraRef: RefObject<CameraRef$1 | null>;
1171
+ /** Icon registry: sprite name → image URL (empty until loaded / disabled). */
1172
+ iconsByName: Record<string, string>;
1173
+ /**
1174
+ * POI ids currently highlighted by `<PoiHighlightLayer>` — a mutable set
1175
+ * (no re-renders) so press handlers can report the web SDK's `selected`
1176
+ * flag. Updated by the layer; read by `useYarrowLayerPress`.
1177
+ */
1178
+ highlightedPoiIds: RefObject<Set<number>>;
1179
+ /**
1180
+ * Subscribes to region changes (the `moveend` parity point). Returns an
1181
+ * unsubscribe function.
1182
+ */
1183
+ subscribeRegionChange: (listener: (state: YarrowRegionState) => void) => () => void;
1184
+ /**
1185
+ * Subscribes to raw map presses. Returns an unsubscribe function.
1186
+ */
1187
+ subscribePress: (listener: (press: YarrowMapPress) => void) => () => void;
1188
+ };
1189
+ declare const YarrowMapContext: import("react").Context<YarrowMapRuntime | null>;
1190
+ /** Reads the enclosing `<YarrowMapView>` runtime, or `null` outside one. */
1191
+ declare function useYarrowMapRuntime(): YarrowMapRuntime | null;
1192
+ /** The base style's POI symbol layer (`node_tile` source). */
1193
+ declare const POI_BASE_LAYER = "pois_tile_layer";
1194
+ /**
1195
+ * Fetches a POI's coordinates and icon from the place-detail API — the
1196
+ * off-screen / below-zoom fallback of the resolution chain. Returns `null`
1197
+ * on any failure or missing coordinates (web parity).
1198
+ *
1199
+ * When the response carries no `icon_img`, the icon is derived from
1200
+ * `node_type` (falling back to `category.name`) — the web SDK resolves it
1201
+ * through its style `icon-image` expression; native approximates that with
1202
+ * an icon-registry lookup by the same name, since the detail endpoint
1203
+ * returns the node type rather than an icon URL.
1204
+ */
1205
+ declare function fetchPlaceLocation(id: number, iconsByName?: Record<string, string>): Promise<ResolvedPoiData | null>;
1206
+ /**
1207
+ * Reads a POI's point geometry from the style's POI layer within the current
1208
+ * viewport — the free, no-network resolution step. Native can only query
1209
+ * *rendered* features (no `querySourceFeatures` on undeclared sources), so
1210
+ * off-screen POIs fall through to the place-detail API. Icons are resolved
1211
+ * best-effort from the registry via the feature's `node_type`.
1212
+ */
1213
+ declare function lookupPoiInViewport(mapRef: MapRef$1, id: number, iconsByName?: Record<string, string>): Promise<ResolvedPoiData | null>;
1214
+ /**
1215
+ * Resolves a POI's coordinates, icon and title cheapest-first:
1216
+ * 1. caller-provided `location` / `icon` / `title`
1217
+ * 2. local lookup in the rendered POI layer (no network)
1218
+ * 3. the place-detail API (off-screen / below the POI zoom range, or when
1219
+ * anything is still missing — web parity: the API fills icon and title
1220
+ * too, not just coordinates)
1221
+ *
1222
+ * The web SDK additionally evaluates the style's `icon-image` expression for
1223
+ * both the tile and the place-detail steps; native approximates it with a
1224
+ * registry lookup by `node_type`. Coordinate resolution is the hard
1225
+ * requirement — if it fails, the highlight is rolled back by the caller.
1226
+ */
1227
+ declare function resolvePoiData(id: number, options: HighlightPoiData, runtime: YarrowMapRuntime): Promise<ResolvedPoiData | null>;
1228
+ /** Handle for one active highlight — mirrors the web SDK's `POIHighlight`. */
1229
+ type YarrowPoiHighlight = {
1230
+ readonly id: number;
1231
+ remove: () => void;
1232
+ };
1233
+ type UseYarrowPoiHighlightResult = {
1234
+ /** All currently highlighted ids — feed to `<PoiHighlightLayer ids={…}>`. */
1235
+ highlightedIds: number[];
1236
+ /**
1237
+ * Highlights one or more POIs. Additive by default (web parity); pass
1238
+ * `{ replace: true }` to reset the selection first. Returns one handle per
1239
+ * id whose `remove()` un-highlights it.
1240
+ */
1241
+ highlight: (input: number | number[], options?: {
1242
+ replace?: boolean;
1243
+ }) => YarrowPoiHighlight[];
1244
+ /** Un-highlights all POIs, or the given id(s). */
1245
+ reset: (input?: number | number[]) => void;
1246
+ /** Whether a POI id is currently highlighted. */
1247
+ isHighlighted: (id: number) => boolean;
1248
+ };
1249
+ /**
1250
+ * Headless highlight state — the declarative counterpart of the web SDK's
1251
+ * `highlightPOI` / `resetPOIHighlight` / `isPOIHighlighted` /
1252
+ * `getHighlightedPOIs` quartet. Rendering is owned by `<PoiHighlightLayer>`:
1253
+ *
1254
+ * ```tsx
1255
+ * const { highlightedIds, highlight } = useYarrowPoiHighlight();
1256
+ * <YarrowMapView apiKey={KEY}>
1257
+ * <PoiHighlightLayer ids={highlightedIds} panTo />
1258
+ * </YarrowMapView>
1259
+ * ```
1260
+ */
1261
+ declare function useYarrowPoiHighlight(): UseYarrowPoiHighlightResult;
1262
+ type SearchResultsLayerProps = {
1263
+ /** Results from `useYarrowSearch` (or your own fetch). */
1264
+ results: SearchResult[];
1265
+ /** Icon size in points: a number (square) or `[width, height]`. Default 56. */
1266
+ iconSize?: number | [number, number];
1267
+ /**
1268
+ * Fits the camera to the results the first time a non-empty page renders
1269
+ * (default `true`). The fit runs once per session — pass a `fitKey` to
1270
+ * start a new session (web parity: the web fits once per
1271
+ * `highlightSearchResults()` call, so a new query re-fits).
1272
+ */
1273
+ zoomToResults?: boolean;
1274
+ /**
1275
+ * Session identity for `zoomToResults`: changing it re-arms the initial
1276
+ * fit, e.g. `fitKey={query}` re-fits when the query changes (web parity).
1277
+ * Omitted (or unchanged) = fit once per mount.
1278
+ */
1279
+ fitKey?: string | number;
1280
+ /** Clusters the result markers (`true` or a config object). */
1281
+ clustering?: ClusteringConfig;
1282
+ /** Called when a result marker is pressed. */
1283
+ onResultPress?: (lat: number, lng: number, result: SearchResult) => void;
1284
+ };
1285
+ /**
1286
+ * Renders search results on the map — the declarative counterpart of the web
1287
+ * SDK's `highlightSearchResults()`. Icon precedence per result:
1288
+ * `icon_img` → registry icon by `category.name` → blue-dot fallback.
1289
+ *
1290
+ * ```tsx
1291
+ * const { results, isLoading } = useYarrowSearch(query, { lat, lon });
1292
+ * <YarrowMapView apiKey={KEY}>
1293
+ * <SearchResultsLayer results={results} onResultPress={…} />
1294
+ * </YarrowMapView>
1295
+ * ```
1296
+ */
1297
+ declare function SearchResultsLayer({ results, iconSize, zoomToResults, fitKey, clustering, onResultPress }: SearchResultsLayerProps): import("react/jsx-runtime").JSX.Element | null;
1298
+ /**
1299
+ * DAU tracking for the RN SDK — wraps the platform-agnostic core
1300
+ * implementation with the RN default `sdk_type: "react-native"`. Core's own
1301
+ * default (`'javascript'`) exists for the web SDK and would misattribute
1302
+ * direct calls from React Native apps, so this wrapper owns the RN default.
1303
+ * `<YarrowMapView>` passes the key from its own config (see `dauTracking`).
1304
+ */
1305
+ declare function trackDau(apiKey: string, sdkType?: string): void;
1306
+ /**
1307
+ * Minimal slice of `@react-native-async-storage/async-storage` the adapter
1308
+ * needs. Accepting a structural type (instead of importing the module) keeps
1309
+ * the async-storage peer dependency optional.
1310
+ */
1311
+ type AsyncStorageLike = {
1312
+ getItem(key: string): Promise<string | null>;
1313
+ setItem(key: string, value: string): Promise<void>;
1314
+ };
1315
+ /**
1316
+ * Bridges the async AsyncStorage API onto core's synchronous TokenStorage
1317
+ * contract: the existing token hydrates into memory once, reads are served
1318
+ * synchronously from that cache, and writes mirror in-memory before flushing
1319
+ * to AsyncStorage (fire-and-forget).
1320
+ *
1321
+ * If the initial read throws, the override is left unset entirely: core then
1322
+ * degrades to ephemeral tokens *without persisting anything*, so a transient
1323
+ * read failure can never overwrite the stored identity with a fresh token.
1324
+ *
1325
+ * Await this once during app startup, before the first map or tracking call
1326
+ * (tokens generated before this resolves are ephemeral by design):
1327
+ *
1328
+ * ```ts
1329
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
1330
+ * import { setAsyncStorageTokenStorage } from '@yarrow-uz/rn-map-sdk';
1331
+ *
1332
+ * await setAsyncStorageTokenStorage(AsyncStorage);
1333
+ * ```
1334
+ */
1335
+ declare function setAsyncStorageTokenStorage(storage: AsyncStorageLike): Promise<void>;
1336
+ export { YarrowMapViewProps as $, RouteDirection as $t, useYarrowOfflineRegions as A, ClusteringConfig as At, OfflineRegionHandle as B, BoundingBox as Bt, PlaceLocation as C, transformRouteCoordinates as Cn, LayerPressInfo as Ct, YarrowOfflineManagerOptions as D, ClusterChild as Dt, YarrowOfflineManager as E, useYarrowLayerPress as Et, OFFLINE_METADATA_VERSION as F, PixelCluster as Ft, YarrowCamera as G, DEFAULT_CACHE_LIFESPAN_DAYS as Gt, OfflineRegionSummary as H, CACHE_PROTOCOL as Ht, OfflineBounds as I, groupByPixelRadius as It, YarrowMarker as J, ICONS_ENDPOINT as Jt, ZoomToOptions as K, FetchRoutesInput as Kt, OfflineRegionDownloadOptions as L, normalizeClusteringConfig as Lt, estimateRegion as M, DEFAULT_CLUSTER_MIN_POINTS as Mt, DEFAULT_OFFLINE_MAX_ZOOM as N, DEFAULT_CLUSTER_RADIUS_PX as Nt, UseYarrowOfflineRegionsOptions as O, ClusterClickHandler as Ot, DEFAULT_OFFLINE_MIN_ZOOM as P, NormalizedClusteringConfig as Pt, YarrowMapView as Q, ROUTE_API_URL as Qt, OfflineRegionErrorCode as R, ClusterBadge as Rt, HighlightPoiData as S, setYarrowApiKey as Sn, ClickLayerTarget as St, ResolvedPoiData as T, YARROW_CLICK_LAYER_IDS as Tt, YarrowOfflineError as U, CacheConfig as Ut, OfflineRegionProgress as V, CACHED_AT_HEADER as Vt, FitBoundsOptions as W, CachedArrayBufferResponse as Wt, HighlightMarkerView as X, MILLISECONDS_PER_DAY as Xt, YarrowMarkerProps as Y, ICON_CACHE_NAME as Yt, HighlightMarkerViewProps as Z, NormalizedCacheConfig as Zt, YarrowMapRuntime as _, getYarrowApiKey as _n, UseYarrowMapSearchResult as _t, trackDau as a, TokenStorage as an, BrandBadgePosition as at, PoiHighlightLayer as b, normalizeStyleType as bn, UseYarrowSearchResult as bt, UseYarrowPoiHighlightResult as c, YARROW_SEARCH_API_URL as cn, YarrowImagesProps as ct, POI_BASE_LAYER as d, buildStyleEndpoint as dn, resolveCategoryIcon as dt, RouteDirectionModifier as en, buildStyleUrl as et, fetchPlaceLocation as f, fetchArrayBufferWithCache as fn, BuildRouteInput as ft, YarrowMapPress as g, getOrCreateUserToken as gn, UseYarrowMapSearchOptions as gt, YarrowMapContext as h, getBoundingBox as hn, useYarrowRouting as ht, setAsyncStorageTokenStorage as i, TILE_CACHE_NAME as in, YarrowMapConfigOptions as it, AVG_TILE_BYTES as j, DEFAULT_CLUSTER_MAX_ZOOM as jt, UseYarrowOfflineRegionsResult as k, ClusterPoint as kt, YarrowPoiHighlight as l, YarrowStyleType as ln, YarrowIconsMap as lt, resolvePoiData as m, fetchSearchResults as mn, UseYarrowRoutingResult as mt, MapRef as n, RoutesMeta as nn, RouteLayerProps as nt, SearchResultsLayer as o, USER_TOKEN_STORAGE_KEY as on, DEFAULT_BRAND_BADGE_SCALE as ot, lookupPoiInViewport as p, fetchRoutes as pn, UseYarrowRoutingOptions as pt, useYarrowCamera as q, FetchRoutesResult as qt, AsyncStorageLike as r, SearchResult as rn, YarrowMapConfig as rt, SearchResultsLayerProps as s, YARROW_MAP_URL as sn, YarrowImages as st, CameraRef as t, RouteFeature as tn, RouteLayer as tt, useYarrowPoiHighlight as u, addApiKeyToUrl as un, fetchYarrowIcons as ut, YarrowRegionState as v, hasCacheStorage as vn, useYarrowMapSearch as vt, PoiHighlightPressInfo as w, UseYarrowLayerPressOptions as wt, PoiHighlightLayerProps as x, setTokenStorage as xn, useYarrowSearch as xt, useYarrowMapRuntime as y, haversineDistance as yn, UseYarrowSearchOptions as yt, OfflineRegionEstimate as z, ClusterBadgeProps as zt };