@baeckerherz/expo-mapbox-navigation 1.0.2 → 1.0.4
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/README.md +38 -14
- package/android/build.gradle +9 -2
- package/package.json +9 -3
- package/plugin/build/index.js +3 -1
- package/plugin/build/withMapboxNavSettingsGradle.d.ts +9 -0
- package/plugin/build/withMapboxNavSettingsGradle.js +39 -0
- package/plugin/src/index.ts +3 -1
- package/plugin/src/withMapboxNavSettingsGradle.ts +45 -0
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# @baeckerherz/expo-mapbox-navigation
|
|
2
2
|
|
|
3
|
-
[](./LICENSE)
|
|
3
|
+
[](./README.md#status) [](./LICENSE)
|
|
4
4
|
|
|
5
|
-
Expo module
|
|
5
|
+
**Expo module for turn-by-turn navigation on iOS and Android** using [Mapbox Navigation SDK v3](https://docs.mapbox.com/ios/navigation/guides/) (iOS) / [Android](https://docs.mapbox.com/android/navigation/guides/). Single `MapboxNavigation` component, Expo config plugin for credentials, no vendored binaries. Minimal alternative to existing community wrappers.
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **Alpha** — iOS is working in our builds; Android is not yet working (dependency resolution / Mapbox Maven). We need help to get Android over the line. APIs may change. **Contributions welcome.** Open an issue or reach out.
|
|
8
|
+
|
|
9
|
+
**Package summary:** Expo config plugin + native module; Mapbox Navigation SDK v3; iOS (SPM) and Android (Maven, drop-in NavigationView); turn-by-turn driving/walking/cycling; requires Expo ≥51, React Native ≥0.74, Mapbox public + secret tokens; alpha stage; TypeScript API via `MapboxNavigation` component.
|
|
8
10
|
|
|
9
11
|
## Table of contents
|
|
10
12
|
|
|
@@ -23,8 +25,17 @@ Expo module wrapping [Mapbox Navigation SDK v3](https://docs.mapbox.com/ios/navi
|
|
|
23
25
|
## Prerequisites
|
|
24
26
|
|
|
25
27
|
- [Mapbox account](https://account.mapbox.com/) with Navigation SDK access
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
Mapbox requires **two tokens** (create both in your [Mapbox tokens page](https://account.mapbox.com/access-tokens/)):
|
|
30
|
+
|
|
31
|
+
| Token | Prefix | Purpose |
|
|
32
|
+
|-------|--------|---------|
|
|
33
|
+
| **Public (access) token** | `pk.xxx` | Used by the app at runtime: map tiles, Directions API, voice, etc. Set as `mapboxAccessToken` in the plugin. |
|
|
34
|
+
| **Secret (downloads) token** | `sk.xxx` | Used only at **build time**: Gradle (Android) and SPM (iOS) use it to download the Navigation SDK from Mapbox. Must have **Downloads:Read** scope. Not used by the app at runtime. |
|
|
35
|
+
|
|
36
|
+
The same **secret token** is used for both platforms. For EAS Build, one EAS secret (e.g. `MAPBOX_DOWNLOADS_TOKEN` or `MAPBOX_SECRET_TOKEN`) can back both: iOS needs it in `~/.netrc` for SPM; Android needs it in `gradle.properties` (the plugin writes it from `mapboxSecretToken`) and, when using centralized repo resolution, as env var `MAPBOX_DOWNLOADS_TOKEN`.
|
|
37
|
+
|
|
38
|
+
- **iOS:** Add the secret token to `~/.netrc` so SPM can download the SDK (local dev and EAS Build):
|
|
28
39
|
|
|
29
40
|
```plaintext
|
|
30
41
|
machine api.mapbox.com
|
|
@@ -32,7 +43,7 @@ Expo module wrapping [Mapbox Navigation SDK v3](https://docs.mapbox.com/ios/navi
|
|
|
32
43
|
password YOUR_SECRET_TOKEN
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
- **Android:** The plugin writes `mapboxSecretToken` to `android/gradle.properties` as `MAPBOX_DOWNLOADS_TOKEN` so Maven can download the SDK.
|
|
46
|
+
- **Android:** The plugin writes `mapboxSecretToken` to `android/gradle.properties` as `MAPBOX_DOWNLOADS_TOKEN` so Maven can download the SDK. For EAS Build, also set `MAPBOX_DOWNLOADS_TOKEN` as an EAS secret so the build can authenticate.
|
|
36
47
|
|
|
37
48
|
## Installation
|
|
38
49
|
|
|
@@ -153,20 +164,25 @@ Existing wrappers have major drawbacks:
|
|
|
153
164
|
|
|
154
165
|
## Status
|
|
155
166
|
|
|
156
|
-
**
|
|
167
|
+
**Alpha.** Platform status:
|
|
168
|
+
|
|
169
|
+
| Platform | Status | Notes |
|
|
170
|
+
|----------|--------|-------|
|
|
171
|
+
| **iOS** | Working (Alpha) | SPM via config plugin; tested in our project builds. |
|
|
172
|
+
| **Android** | Not yet working | Mapbox Maven / dependency resolution issues; help wanted to fix. |
|
|
173
|
+
|
|
174
|
+
Goals: reliable SPM injection (iOS), drop-in NavigationView/NavigationViewController, event bridging. We want more feedback and testing. For prerelease we may publish under the `alpha` npm tag.
|
|
157
175
|
|
|
158
|
-
|
|
159
|
-
2. Sufficient drop-in NavigationView/NavigationViewController integration
|
|
160
|
-
3. Event bridging for required use cases
|
|
176
|
+
**Help wanted** — especially to get Android builds working (Gradle, Mapbox repo auth, or switching to `ui-components` if the drop-in artifact is unavailable).
|
|
161
177
|
|
|
162
178
|
**Known risks**
|
|
163
179
|
|
|
164
|
-
- **Android:**
|
|
180
|
+
- **Android:** Build and dependency resolution need community input.
|
|
165
181
|
- **Licensing:** Mapbox Navigation SDK requires a commercial Mapbox license; this wrapper does not change that.
|
|
166
182
|
|
|
167
183
|
## Contributing
|
|
168
184
|
|
|
169
|
-
We welcome contributors and maintainers. If you work on Expo native modules, Mapbox SDKs, or React Native tooling, we’d love your help.
|
|
185
|
+
We welcome contributors and maintainers. If you work on Expo native modules, Mapbox SDKs, or React Native tooling, we’d love your help. **If you or your company use this package,** we’d love to hear from you (issues, discussions, or [partner@baeckerherz.at](mailto:partner@baeckerherz.at)) — it helps us prioritize and justify ongoing work.
|
|
170
186
|
|
|
171
187
|
**Project layout:** `src/` (TypeScript API), `ios/` (Swift + podspec), `android/` (Kotlin + build.gradle), `plugin/` (Expo config plugins), `example/` (test app).
|
|
172
188
|
|
|
@@ -188,10 +204,18 @@ Open an [issue](https://github.com/baeckerherz/expo-mapbox-navigation/issues) or
|
|
|
188
204
|
|
|
189
205
|
[MIT](./LICENSE)
|
|
190
206
|
|
|
191
|
-
##
|
|
207
|
+
## Who uses this
|
|
208
|
+
|
|
209
|
+
We’d like to list teams and projects using this package (with your permission). If you’re using it, open an issue or email [partner@baeckerherz.at](mailto:partner@baeckerherz.at).
|
|
192
210
|
|
|
193
|
-
|
|
211
|
+
## Sponsors
|
|
194
212
|
|
|
195
213
|
<a href="https://github.com/baeckerherz"><img src="https://avatars.githubusercontent.com/u/261656164?s=80&v=4" width="48" alt="Bäckerherz" /></a> **[Bäckerherz](https://github.com/baeckerherz)** — Founding sponsor. They build and use this module; the project exists thanks to their investment in open-source Expo tooling.
|
|
196
214
|
|
|
215
|
+
<a href="https://www.tourenflow.com/"><img src="https://www.tourenflow.com/logo.svg" width="48" alt="TourenFlow" /></a> **[TourenFlow](https://www.tourenflow.com/)** — Intelligent tour planning and route optimization.
|
|
216
|
+
|
|
197
217
|
To support the project or work with us: [partner@baeckerherz.at](mailto:partner@baeckerherz.at).
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
<!-- For AI/LLM context: This package is @baeckerherz/expo-mapbox-navigation. It provides turn-by-turn navigation in Expo/React Native apps using Mapbox Navigation SDK v3. Install with npx expo install @baeckerherz/expo-mapbox-navigation. Configure the Expo plugin with mapboxAccessToken and mapboxSecretToken; iOS needs ~/.netrc for SPM, Android uses MAPBOX_DOWNLOADS_TOKEN in gradle.properties. Component: MapboxNavigation with coordinates, locale, mapStyle, themeMode, and events (onRouteProgressChanged, onCancelNavigation, onFinalDestinationArrival, etc.). Alpha stage; iOS and Android supported in maintainer builds. -->
|
package/android/build.gradle
CHANGED
|
@@ -63,11 +63,18 @@ repositories {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
def kotlinVersion = "2.1.20"
|
|
67
|
+
if (rootProject.hasProperty("kotlinVersion")) {
|
|
68
|
+
kotlinVersion = rootProject.kotlinVersion
|
|
69
|
+
} else if (rootProject.ext.has("kotlinVersion")) {
|
|
70
|
+
kotlinVersion = rootProject.ext.get("kotlinVersion")
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
dependencies {
|
|
67
74
|
implementation project(':expo-modules-core')
|
|
68
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${
|
|
75
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinVersion}"
|
|
69
76
|
|
|
70
|
-
// Mapbox Navigation SDK v3 - drop-in UI
|
|
77
|
+
// Mapbox Navigation SDK v3 - core, drop-in UI, and maps
|
|
71
78
|
implementation "com.mapbox.navigationcore:android:3.5.0"
|
|
72
79
|
implementation "com.mapbox.navigationcore:dropin:3.5.0"
|
|
73
80
|
implementation "com.mapbox.navigationcore:ui-maps:3.5.0"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeckerherz/expo-mapbox-navigation",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Expo module
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Expo module for turn-by-turn navigation (Mapbox Navigation SDK v3) on iOS and Android. Alpha. Single MapboxNavigation component, Expo config plugin.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
7
7
|
"expo": {
|
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
"turn-by-turn",
|
|
23
23
|
"driving",
|
|
24
24
|
"mapbox-navigation-sdk",
|
|
25
|
-
"mapbox-navigation-v3"
|
|
25
|
+
"mapbox-navigation-v3",
|
|
26
|
+
"expo-module",
|
|
27
|
+
"alpha",
|
|
28
|
+
"mapbox-navigation",
|
|
29
|
+
"react-native-navigation",
|
|
30
|
+
"directions",
|
|
31
|
+
"routing"
|
|
26
32
|
],
|
|
27
33
|
"license": "MIT",
|
|
28
34
|
"repository": {
|
package/plugin/build/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
4
|
const withMapboxNavPodfile_1 = require("./withMapboxNavPodfile");
|
|
5
5
|
const withMapboxNavGradle_1 = require("./withMapboxNavGradle");
|
|
6
|
+
const withMapboxNavSettingsGradle_1 = require("./withMapboxNavSettingsGradle");
|
|
6
7
|
const withMapboxNavGradleProperties_1 = require("./withMapboxNavGradleProperties");
|
|
7
8
|
const withMapboxNavigation = (config, { mapboxAccessToken, mapboxSecretToken, navigationSdkVersion = "3.5.0", }) => {
|
|
8
9
|
if (!mapboxAccessToken) {
|
|
@@ -27,8 +28,9 @@ const withMapboxNavigation = (config, { mapboxAccessToken, mapboxSecretToken, na
|
|
|
27
28
|
// iOS: Adds Mapbox Navigation SPM to the Pods project, sets search paths,
|
|
28
29
|
// and adds a script phase to strip duplicate xcframework signatures.
|
|
29
30
|
config = (0, withMapboxNavPodfile_1.withMapboxNavPodfile)(config, { navigationSdkVersion });
|
|
30
|
-
// Android: Mapbox Maven repository and optional token
|
|
31
|
+
// Android: Mapbox Maven repository (build.gradle and settings.gradle) and optional token
|
|
31
32
|
config = (0, withMapboxNavGradle_1.withMapboxNavGradle)(config);
|
|
33
|
+
config = (0, withMapboxNavSettingsGradle_1.withMapboxNavSettingsGradle)(config);
|
|
32
34
|
config = (0, withMapboxNavGradleProperties_1.withMapboxNavGradleProperties)(config, { mapboxSecretToken });
|
|
33
35
|
return config;
|
|
34
36
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Adds the Mapbox Maven repository to settings.gradle when the project uses
|
|
4
|
+
* dependencyResolutionManagement (e.g. FAIL_ON_PROJECT_REPOS). In that mode
|
|
5
|
+
* project-level repositories are ignored, so the root build.gradle injection
|
|
6
|
+
* is not enough and we must add the repo here.
|
|
7
|
+
* Uses env MAPBOX_DOWNLOADS_TOKEN so EAS Build and local builds can supply the secret.
|
|
8
|
+
*/
|
|
9
|
+
export declare const withMapboxNavSettingsGradle: ConfigPlugin;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withMapboxNavSettingsGradle = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
/**
|
|
6
|
+
* Adds the Mapbox Maven repository to settings.gradle when the project uses
|
|
7
|
+
* dependencyResolutionManagement (e.g. FAIL_ON_PROJECT_REPOS). In that mode
|
|
8
|
+
* project-level repositories are ignored, so the root build.gradle injection
|
|
9
|
+
* is not enough and we must add the repo here.
|
|
10
|
+
* Uses env MAPBOX_DOWNLOADS_TOKEN so EAS Build and local builds can supply the secret.
|
|
11
|
+
*/
|
|
12
|
+
const withMapboxNavSettingsGradle = (config) => {
|
|
13
|
+
return (0, config_plugins_1.withSettingsGradle)(config, (config) => {
|
|
14
|
+
let contents = config.modResults.contents;
|
|
15
|
+
if (contents.includes("api.mapbox.com/downloads/v2/releases/maven")) {
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
if (!contents.includes("dependencyResolutionManagement") ||
|
|
19
|
+
!contents.includes("repositories {")) {
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
const mapboxMaven = `
|
|
23
|
+
// @baeckerherz/expo-mapbox-navigation: Mapbox Navigation SDK Maven repository
|
|
24
|
+
maven {
|
|
25
|
+
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
|
|
26
|
+
authentication {
|
|
27
|
+
basic(BasicAuthentication)
|
|
28
|
+
}
|
|
29
|
+
credentials {
|
|
30
|
+
username = "mapbox"
|
|
31
|
+
password = (System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: "")
|
|
32
|
+
}
|
|
33
|
+
}`;
|
|
34
|
+
contents = contents.replace(/(repositories\s*\{)/, `$1${mapboxMaven}`);
|
|
35
|
+
config.modResults.contents = contents;
|
|
36
|
+
return config;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.withMapboxNavSettingsGradle = withMapboxNavSettingsGradle;
|
package/plugin/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigPlugin, createRunOncePlugin } from "@expo/config-plugins";
|
|
2
2
|
import { withMapboxNavPodfile } from "./withMapboxNavPodfile";
|
|
3
3
|
import { withMapboxNavGradle } from "./withMapboxNavGradle";
|
|
4
|
+
import { withMapboxNavSettingsGradle } from "./withMapboxNavSettingsGradle";
|
|
4
5
|
import { withMapboxNavGradleProperties } from "./withMapboxNavGradleProperties";
|
|
5
6
|
|
|
6
7
|
interface PluginConfig {
|
|
@@ -47,8 +48,9 @@ const withMapboxNavigation: ConfigPlugin<PluginConfig> = (
|
|
|
47
48
|
// and adds a script phase to strip duplicate xcframework signatures.
|
|
48
49
|
config = withMapboxNavPodfile(config, { navigationSdkVersion });
|
|
49
50
|
|
|
50
|
-
// Android: Mapbox Maven repository and optional token
|
|
51
|
+
// Android: Mapbox Maven repository (build.gradle and settings.gradle) and optional token
|
|
51
52
|
config = withMapboxNavGradle(config);
|
|
53
|
+
config = withMapboxNavSettingsGradle(config);
|
|
52
54
|
config = withMapboxNavGradleProperties(config, { mapboxSecretToken });
|
|
53
55
|
|
|
54
56
|
return config;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { withSettingsGradle, ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Mapbox Maven repository to settings.gradle when the project uses
|
|
5
|
+
* dependencyResolutionManagement (e.g. FAIL_ON_PROJECT_REPOS). In that mode
|
|
6
|
+
* project-level repositories are ignored, so the root build.gradle injection
|
|
7
|
+
* is not enough and we must add the repo here.
|
|
8
|
+
* Uses env MAPBOX_DOWNLOADS_TOKEN so EAS Build and local builds can supply the secret.
|
|
9
|
+
*/
|
|
10
|
+
export const withMapboxNavSettingsGradle: ConfigPlugin = (config) => {
|
|
11
|
+
return withSettingsGradle(config, (config) => {
|
|
12
|
+
let contents = config.modResults.contents;
|
|
13
|
+
|
|
14
|
+
if (contents.includes("api.mapbox.com/downloads/v2/releases/maven")) {
|
|
15
|
+
return config;
|
|
16
|
+
}
|
|
17
|
+
if (
|
|
18
|
+
!contents.includes("dependencyResolutionManagement") ||
|
|
19
|
+
!contents.includes("repositories {")
|
|
20
|
+
) {
|
|
21
|
+
return config;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mapboxMaven = `
|
|
25
|
+
// @baeckerherz/expo-mapbox-navigation: Mapbox Navigation SDK Maven repository
|
|
26
|
+
maven {
|
|
27
|
+
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
|
|
28
|
+
authentication {
|
|
29
|
+
basic(BasicAuthentication)
|
|
30
|
+
}
|
|
31
|
+
credentials {
|
|
32
|
+
username = "mapbox"
|
|
33
|
+
password = (System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: "")
|
|
34
|
+
}
|
|
35
|
+
}`;
|
|
36
|
+
|
|
37
|
+
contents = contents.replace(
|
|
38
|
+
/(repositories\s*\{)/,
|
|
39
|
+
`$1${mapboxMaven}`
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
config.modResults.contents = contents;
|
|
43
|
+
return config;
|
|
44
|
+
});
|
|
45
|
+
};
|