@yarrow-uz/rn-map-sdk 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # @yarrow-uz/rn-map-sdk
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dcb109b: Coded API errors end to end, plus the diagnostics to act on them:
8
+
9
+ - **`YarrowApiError`** (new export): every network client — routing, search, the
10
+ icon registry, place details and the style-URL builder — now throws a coded
11
+ error instead of a plain `Error`. Branch on `error.code`
12
+ (`'unauthorized' | 'payment-required' | 'forbidden' | 'rate-limited' |
13
+ 'not-found' | 'network' | 'invalid-response' | 'unknown'`); `status` and
14
+ `url` carry the HTTP status and request URL when one exists. The codes
15
+ follow the 2026-11 gateway contract: `402` is quota exhausted with overage
16
+ enabled but no billable balance, `403` is a missing subscription. Historic
17
+ `"Request failed: …"` messages are preserved verbatim, so message-based
18
+ handling keeps working. Client-side aborts are not wrapped — cancellation
19
+ still surfaces as a plain `AbortError`.
20
+ - **Missing-key clarity**: building a request with no configured API key now
21
+ throws a coded `unauthorized` error telling you to pass
22
+ `<YarrowMapView apiKey>` or call `setYarrowApiKey()` — previously the key was
23
+ silently omitted and the request failed opaquely on the server. `YarrowMapView`
24
+ and `YarrowOfflineManager` always seed the key, so normal map usage is
25
+ unaffected; only truly standalone clients without a key change behavior (they
26
+ were broken anyway).
27
+ - **Routing timeout**: `useYarrowRouting` aborts requests after 30 s by default
28
+ (previously `isLoading` could hang forever on a stalled network with no
29
+ caller signal) and rejects with a `network` error mentioning the timeout. The
30
+ new `timeoutMs` option tunes or disables it (`0` disables). Implemented with
31
+ a manual controller + timer — no `AbortSignal.any`/`AbortSignal.timeout`, so
32
+ it is safe on the full supported Hermes/RN range; caller `signal`
33
+ cancellation still applies immediately.
34
+ - **`onIconsError` prop** on `<YarrowMapView>`: fires with the failure when the
35
+ icon-registry fetch fails (still warns to the console; default without the
36
+ prop is unchanged warn-only). POI place-detail failures now warn with status
37
+ - URL in dev builds (`__DEV__`) instead of silently returning `null`.
38
+ - **Offline force-settle**: `downloadRegion({ force: true })` (and
39
+ `handle.delete()`) now settles every outstanding handle for the deleted
40
+ region — their `done` rejects with a `not-found` offline error explaining the
41
+ replacement — instead of hanging forever. Reattached listeners are released
42
+ with the pack.
43
+ - **Camera hardening**: `useYarrowCamera.fitBounds` no-ops with a dev warning on
44
+ empty/degenerate FeatureCollections instead of flying the camera to core's
45
+ inverted-world sentinel box.
46
+
47
+ README gains an "Errors" section documenting the codes and the timeout option.
48
+
49
+ ### Patch Changes
50
+
51
+ - 7251837: Fix routing against the updated Yarrow routing API (2026-11 contract): `profile` values are now mapped onto the API's wire enum — `driving` → `CAR`, `walking` → `FOOT`, `cycling` → `BICYCLE` (the API removed its old `DRIVING`-style values, so every route request failed validation with a 422). The wire values themselves are accepted case-insensitively, unknown values still pass through uppercased, and the public `profile` input/format is unchanged. The API's new no-route contract ("no route could be built" is now a 400 instead of a 200 with `success: false`) still resolves to an empty result, as documented. Non-OK responses now also surface the API error envelope's message when HTTP/2 leaves `statusText` empty (e.g. `Request failed: 422 Request validation failed` instead of a bare `Request failed: 422`).
52
+
53
+ ## 0.5.0
54
+
55
+ ### Minor Changes
56
+
57
+ - Drop the `@react-native-community/blur` peer dependency and ship the brand badge as a translucent tint pill on **both** platforms, superseding 0.4.0's iOS-only frosted glass. RN has no reliable backdrop-blur over the map's GPU surface (Android cannot sample GL content at all), and a native blur peer for one visual wasn't worth the install weight — the badge draws the tint directly (light `rgba(255,255,255,0.55)` / dark `rgba(15,23,42,0.55)`), same pill geometry, logo and corner as before. Apps no longer need blur installed or linked; nothing to migrate (installed copies are simply unused).
58
+
59
+ ### Patch Changes
60
+
61
+ - b673ced: Docs: both SDK READMEs now state the Yarrow branding policy — the Yarrow brand badge is the only visible badge on the map, and MapLibre's attribution/logo ornaments stay hidden by design (the web SDK hardcodes `attributionControl: false`; the RN SDK defaults `attribution`/`logo` to `false` with opt-in escape-hatch props).
62
+ - ca4ad66: `onLoadError` now reports the failing style URL (with the API key redacted to `api_key=***`), since MapLibre React Native's `onDidFailLoadingMap` carries no failure detail on either platform. Opening the URL in a browser shows the underlying response — 401/403 for a bad key, 404 for an unknown style, a network error otherwise.
63
+ - db91e9b: Dev builds now detect an unlinked MapLibre native module at SDK import and print the fix (`[YarrowMap] MapLibre native module is not linked...`) before MapLibre React Native's own import-time failure — its `TurboModuleRegistry` error names the missing module but not the remedy. Release builds are unaffected (`__DEV__`-gated, no-op on web).
64
+
65
+ The README installation section now includes Expo-first install commands (`npx expo install ...`), the MapLibre config-plugin snippet for `app.json`, an Expo Go caveat, and a bare-workflow pod-install line.
66
+
67
+ - ac0d1c6: `trackDau` exported from the RN SDK now defaults `sdk_type` to `"react-native"`. It previously re-exported the platform-agnostic core implementation whose default (`"javascript"`) misattributed direct calls from React Native apps. `<YarrowMapView>`'s built-in DAU ping already reported correctly.
68
+
3
69
  ## 0.4.0
4
70
 
5
71
  ### Minor Changes
package/README.md CHANGED
@@ -19,7 +19,12 @@ routing for iOS and Android.
19
19
  ## Installation
20
20
 
21
21
  ```bash
22
- npm install @yarrow-uz/rn-map-sdk @maplibre/maplibre-react-native @react-native-community/blur
22
+ # Expo — resolves peer versions compatible with your Expo SDK:
23
+ npx expo install @yarrow-uz/rn-map-sdk @maplibre/maplibre-react-native
24
+
25
+ # Bare React Native:
26
+ npm install @yarrow-uz/rn-map-sdk @maplibre/maplibre-react-native
27
+ cd ios && pod install && cd .. # iOS only
23
28
  ```
24
29
 
25
30
  > Get your API key from the [Yarrow Dashboard](https://dashboard.yarrow.uz).
@@ -31,10 +36,24 @@ npm install @yarrow-uz/rn-map-sdk @maplibre/maplibre-react-native @react-native-
31
36
  - `@maplibre/maplibre-react-native` **^11.5.1** installed in your app — it
32
37
  carries the native iOS/Android code. Follow its
33
38
  [installation guide](https://maplibre.org/maplibre-react-native/docs/install)
34
- (Expo config plugin or bare-workflow autolinking).
35
- - `@react-native-community/blur` **^4.4.1** installed in your app — the brand
36
- badge's frosted-glass blur (iOS) is a native effect, so it needs its native
37
- code linked too (autolinking covers both npm and Expo).
39
+ (Expo config plugin or bare-workflow autolinking). Expo apps must register
40
+ the plugin in `app.json` and **rebuild a native binary** afterwards (the
41
+ map cannot load in Expo Go):
42
+
43
+ ```json
44
+ {
45
+ "expo": {
46
+ "plugins": ["@maplibre/maplibre-react-native"]
47
+ }
48
+ }
49
+ ```
50
+
51
+ In dev builds the SDK detects a missing native module at startup and prints
52
+ the fix — if you see `[YarrowMap] MapLibre native module is not linked`,
53
+ the peers are installed but the app wasn't rebuilt natively.
54
+
55
+ That's the whole dependency list — `@yarrow-uz/rn-map-sdk` has no other
56
+ required peers.
38
57
 
39
58
  The platform-agnostic core is compiled **into** this package's dist, so
40
59
  `@yarrow-uz/rn-map-sdk` is the only Yarrow package you install.
@@ -64,10 +83,13 @@ export function MapScreen() {
64
83
 
65
84
  Props: `apiKey` and `center` are required; `zoom` (default 10), `minZoom` (0),
66
85
  `maxZoom` (19), `theme` (`light`), `styleType` (`default`), `attribution` and
67
- `logo` (`false` — the Yarrow brand badge replaces them), `compass` (`true`),
86
+ `logo` (`false` — Yarrow brand policy: the Yarrow badge is the only visible
87
+ badge, and MapLibre's attribution/logo ornaments stay hidden unless explicitly
88
+ restored), `compass` (`true`),
68
89
  `brandBadgePosition` (`bottom-left`), `brandBadgeScale` (`1` — exact web
69
90
  sizing; pass e.g. `1.4` for a bigger mark), `androidView` (MapLibre's
70
91
  default, `surface`), `dauTracking` (`true`), `onReady`, `onLoadError`,
92
+ `onIconsError` (icon-registry fetch failure — a coded `YarrowApiError`),
71
93
  `onPress`, `cameraRef`, `style` and `children` are optional.
72
94
 
73
95
  The component ref is the MapLibre `MapRef` (`getCenter`, `getBounds`,
@@ -93,7 +115,7 @@ import { YarrowMapView, RouteLayer, useYarrowRouting } from '@yarrow-uz/rn-map-s
93
115
 
94
116
  function Directions({ origin, destination }) {
95
117
  const { routes, isLoading, error, buildRoute, clearRoutes } = useYarrowRouting({
96
- profile: 'driving',
118
+ profile: 'driving', // mapped to the API's CAR; also accepted: walking→FOOT, cycling→BICYCLE
97
119
  language: 'uz',
98
120
  });
99
121
 
@@ -110,7 +132,9 @@ function Directions({ origin, destination }) {
110
132
 
111
133
  `buildRoute({ coordinates })` resolves to `{ features, directions, meta }`
112
134
  ("no route found" resolves to an empty result instead of rejecting; network
113
- failures reject and set `error`).
135
+ failures reject with a coded `YarrowApiError` and set `error`). Requests
136
+ abort after 30 s by default — see [Errors](#errors) for the `timeoutMs`
137
+ option.
114
138
 
115
139
  `<RouteLayer>` renders best-route-plus-alternatives (web `buildRoute()`
116
140
  styling). Pass `distinct` to render independent series in their own palette
@@ -402,6 +426,49 @@ offline.invalidateAmbientCache(); // recommended refresh
402
426
  destructive — MapLibre's JS layer only re-reads the database on app restart,
403
427
  so prefer per-region `invalidate()`/`delete()`.
404
428
 
429
+ ## Errors
430
+
431
+ All SDK network failures (routing, search, icon registry) throw a coded
432
+ `YarrowApiError` — catch it and branch on `error.code` instead of parsing
433
+ messages. Place-detail lookups (`PoiHighlightLayer`) never throw: they roll
434
+ the highlight back and warn in dev builds.
435
+
436
+ ```tsx
437
+ import { YarrowApiError, useYarrowRouting } from '@yarrow-uz/rn-map-sdk';
438
+
439
+ try {
440
+ await buildRoute({ coordinates: [[69.24, 41.29], [69.25, 41.3]] });
441
+ } catch (error) {
442
+ if (error instanceof YarrowApiError && error.code === 'unauthorized') {
443
+ // No key configured, or the server rejected it — `error.status` carries
444
+ // the HTTP status when one arrived (a missing-key error has none).
445
+ }
446
+ }
447
+ ```
448
+
449
+ | Code | Meaning |
450
+ | --- | --- |
451
+ | `unauthorized` | No API key configured, or the server rejected it (HTTP 401). Configure the key via `<YarrowMapView apiKey>` or `setYarrowApiKey()`. |
452
+ | `payment-required` | HTTP 402 — the quota is used up, overage is enabled, but the billing balance (or overage cap) could not cover the request. |
453
+ | `forbidden` | HTTP 403 — e.g. no active subscription for a metered service. |
454
+ | `rate-limited` | HTTP 429 — the quota for this period is used up and overage is off. |
455
+ | `not-found` | HTTP 404. |
456
+ | `network` | The request never produced a response — connection failure or a `buildRoute` timeout. |
457
+ | `invalid-response` | The Yarrow backend replied with an unexpected payload. |
458
+ | `unknown` | Any other HTTP status. |
459
+
460
+ Errors also carry `status` (HTTP status, when one arrived) and `url` (for
461
+ debugging). Client-side aborts are not wrapped — caller cancellation still
462
+ surfaces as a plain `AbortError`. Offline regions keep their own coded
463
+ `YarrowOfflineError` (see below). Deleting a region — including `force: true`
464
+ re-downloads — rejects any outstanding `region.done` with a `not-found`
465
+ offline error instead of hanging forever.
466
+
467
+ `useYarrowRouting` aborts requests after **30 s** by default and rejects with
468
+ a `network` error mentioning the timeout. Tune or disable it with the
469
+ `timeoutMs` option (`timeoutMs: 0` disables); caller `signal` cancellation
470
+ still applies immediately.
471
+
405
472
  ## Web-parity gaps
406
473
 
407
474
  The RN SDK mirrors the web SDK's interactive surface — search, routing, POI
@@ -420,17 +487,20 @@ like their web counterparts. Some web features have no native equivalent:
420
487
  - **Hover effects** — the web `hover` config and `setHoverEnabled()` are
421
488
  web-only; there is no hover on touch surfaces.
422
489
  - **Brand badge & Yarrow controls** — brand parity: `<YarrowMapView>` renders
423
- the same Yarrow brand badge as the web SDK (glass pill + logo, theme-aware,
490
+ the same Yarrow brand badge as the web SDK (tint pill + logo, theme-aware,
424
491
  `brandBadgePosition` prop, default `bottom-left`) as an overlay view, and
425
492
  MapLibre's native attribution/logo ornaments are hidden by default
426
493
  (`attribution`/`logo` props default `false` — pass `true` to restore them).
494
+ This is deliberate Yarrow brand policy, identical on the web: the Yarrow
495
+ badge is the only visible badge on the map (the web SDK hardcodes
496
+ `attributionControl: false`), and the `attribution`/`logo` props exist only
497
+ as escape hatches for apps that need them.
427
498
  Size it up with `brandBadgeScale` (e.g. `1.4`) if you want a bigger mark
428
- than the web's 106px logo. **Frosted glass is iOS-only**: iOS composites a
429
- live `BlurView` (`@react-native-community/blur`) over the map at the
430
- window level. Android has no backdrop-blur API over GPU content (blur
431
- libraries capture the root view into a software bitmap canvas, which the
432
- map's GL surface never appears in), so the Android pill runs a slightly
433
- more opaque tint instead of blur. The compass stays a native ornament
499
+ than the web's 106px logo. The pill is a **translucent tint on both
500
+ platforms**: RN has no reliable backdrop-blur over the map's GPU surface
501
+ (Android cannot sample GL content at all), so instead of shipping a native
502
+ blur peer for one visual, the badge draws the tint directly — the web SDK
503
+ keeps its `backdrop-filter: blur(4px)`. The compass stays a native ornament
434
504
  (`compass`, default `true`); the web SDK's DOM zoom/compass controls have
435
505
  no native counterpart.
436
506
  - **Feature state & background color** — MapLibre React Native's `MapRef`