@jacques_gordon/expo-mapbox-navigation 1.0.6 → 1.0.8

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 CHANGED
@@ -38,6 +38,12 @@ La version recommandée est `11.11.0`. **Important : définir explicitement `RNM
38
38
  npm install @jacques_gordon/expo-mapbox-navigation
39
39
  ```
40
40
 
41
+ Et additionnellement le package (parfois optionnelle)
42
+
43
+ ```bash
44
+ npm install metro-cache-key
45
+ ```
46
+
41
47
  ### 3. Configurer le plugin dans `app.json`
42
48
 
43
49
  ```json
@@ -1,2 +1,2 @@
1
- #Sat Jun 27 20:48:59 CEST 2026
1
+ #Sun Jun 28 09:52:58 CEST 2026
2
2
  gradle.version=8.9
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'ExpoMapboxNavigation'
3
- s.version = '1.0.6'
3
+ s.version = '1.0.0'
4
4
  s.summary = 'Expo module for Mapbox turn-by-turn navigation — iOS & Android'
5
5
  s.homepage = 'https://github.com/YOUR_GITHUB/expo-mapbox-navigation'
6
6
  s.license = { :type => 'MIT' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacques_gordon/expo-mapbox-navigation",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Expo module for Mapbox turn-by-turn navigation — iOS & Android, compatible with Expo SDK 53 Dev Client",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "license": "MIT",
35
35
  "repository": {
36
36
  "type": "git",
37
- "url": "https://github.com/jacquesngomeheffa/expo-mapbox-navigation.git"
37
+ "url": "git+https://github.com/jacquesngomeheffa/expo-mapbox-navigation.git"
38
38
  },
39
39
  "bugs": {
40
40
  "url": "https://github.com/jacquesngomeheffa/expo-mapbox-navigation/issues"
package/plugin/index.js CHANGED
@@ -3,53 +3,16 @@ const {
3
3
  withAppBuildGradle,
4
4
  withProjectBuildGradle,
5
5
  withAndroidManifest,
6
+ withDangerousMod,
6
7
  createRunOncePlugin,
7
- } = require("@expo/config-plugins");
8
+ } = require('@expo/config-plugins');
8
9
 
9
- const withExpoMapboxNavigation = (config, options) => {
10
- const {
11
- accessToken,
12
- mapboxMapsVersion = "11.11.0",
13
- androidColorOverrides = {},
14
- } = options || {};
15
-
16
- if (!accessToken) {
17
- throw new Error(
18
- "[expo-mapbox-navigation] accessToken est requis dans la configuration du plugin."
19
- );
20
- }
21
-
22
- // ── iOS ──
23
- config = withInfoPlist(config, (cfg) => {
24
- cfg.modResults["MBXAccessToken"] = accessToken;
10
+ const fs = require('fs');
11
+ const path = require('path');
25
12
 
26
- cfg.modResults["NSLocationWhenInUseUsageDescription"] =
27
- cfg.modResults["NSLocationWhenInUseUsageDescription"] ??
28
- "Cette application utilise votre position pour la navigation GPS.";
13
+ // ─── Mapbox Maven block ────────────────────────────────────────────────
29
14
 
30
- cfg.modResults["NSLocationAlwaysAndWhenInUseUsageDescription"] =
31
- cfg.modResults["NSLocationAlwaysAndWhenInUseUsageDescription"] ??
32
- "Cette application utilise votre position en arrière-plan pour la navigation GPS.";
33
-
34
- cfg.modResults["NSMotionUsageDescription"] =
35
- cfg.modResults["NSMotionUsageDescription"] ??
36
- "Cette application utilise le capteur de mouvement pour améliorer la navigation.";
37
-
38
- const uiBackgroundModes = cfg.modResults["UIBackgroundModes"] ?? [];
39
- if (!uiBackgroundModes.includes("audio")) uiBackgroundModes.push("audio");
40
- if (!uiBackgroundModes.includes("location"))
41
- uiBackgroundModes.push("location");
42
- cfg.modResults["UIBackgroundModes"] = uiBackgroundModes;
43
-
44
- return cfg;
45
- });
46
-
47
- // ── Android project build.gradle ──
48
- config = withProjectBuildGradle(config, (cfg) => {
49
- if (!cfg.modResults.contents.includes("api.mapbox.com/downloads")) {
50
- cfg.modResults.contents = cfg.modResults.contents.replace(
51
- /allprojects\s*\{([\s\S]*?)repositories\s*\{/,
52
- `allprojects {$1repositories {
15
+ const MAPBOX_MAVEN_BLOCK = `
53
16
  maven {
54
17
  url 'https://api.mapbox.com/downloads/v2/releases/maven'
55
18
  authentication { basic(BasicAuthentication) }
@@ -57,98 +20,135 @@ const withExpoMapboxNavigation = (config, options) => {
57
20
  username = "mapbox"
58
21
  password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: ""
59
22
  }
60
- }`
61
- );
62
23
  }
63
- return cfg;
64
- });
24
+ `;
65
25
 
66
- // ── Android app build.gradle ──
67
- config = withAppBuildGradle(config, (cfg) => {
68
- if (!cfg.modResults.contents.includes("mapbox_access_token")) {
69
- cfg.modResults.contents = cfg.modResults.contents.replace(
70
- /defaultConfig\s*\{/,
71
- `defaultConfig {
72
- resValue "string", "mapbox_access_token", "${accessToken}"`
73
- );
74
- }
26
+ // ─── Inject into settings.gradle (SDK 53 FIX) ───────────────────────────
75
27
 
76
- if (
77
- mapboxMapsVersion &&
78
- !cfg.modResults.contents.includes("RNMapboxMapsVersion")
79
- ) {
80
- cfg.modResults.contents = cfg.modResults.contents.replace(
81
- /ext\s*\{/,
82
- `ext {
83
- RNMapboxMapsVersion = "${mapboxMapsVersion}"`
28
+ const withMapboxMavenInSettings = (config) => {
29
+ return withDangerousMod(config, [
30
+ 'android',
31
+ async (cfg) => {
32
+ const settingsPath = path.join(
33
+ cfg.modRequest.platformProjectRoot,
34
+ 'settings.gradle'
84
35
  );
85
36
 
86
- if (!cfg.modResults.contents.includes("RNMapboxMapsVersion")) {
87
- cfg.modResults.contents = cfg.modResults.contents.replace(
88
- /^(buildscript\s*\{)/m,
89
- `ext {
90
- RNMapboxMapsVersion = "${mapboxMapsVersion}"
91
- }
37
+ if (!fs.existsSync(settingsPath)) return cfg;
92
38
 
93
- $1`
94
- );
95
- }
96
- }
39
+ let contents = fs.readFileSync(settingsPath, 'utf8');
40
+
41
+ if (contents.includes('api.mapbox.com/downloads')) return cfg;
97
42
 
98
- if (Object.keys(androidColorOverrides).length > 0) {
99
- const colorResources = Object.entries(androidColorOverrides)
100
- .map(([name, value]) => ` resValue "color", "${name}", "${value}"`)
101
- .join("\n");
102
-
103
- if (!cfg.modResults.contents.includes("androidColorOverrides_injected")) {
104
- cfg.modResults.contents = cfg.modResults.contents.replace(
105
- /defaultConfig\s*\{/,
106
- `defaultConfig {
107
- ${colorResources}
108
- // androidColorOverrides_injected`
43
+ if (contents.includes('dependencyResolutionManagement')) {
44
+ contents = contents.replace(
45
+ /dependencyResolutionManagement\s*\{([\s\S]*?)repositories\s*\{/,
46
+ `dependencyResolutionManagement {$1repositories {${MAPBOX_MAVEN_BLOCK}`
109
47
  );
48
+ } else if (contents.includes('allprojects')) {
49
+ contents = contents.replace(
50
+ /allprojects\s*\{([\s\S]*?)repositories\s*\{/,
51
+ `allprojects {$1repositories {${MAPBOX_MAVEN_BLOCK}`
52
+ );
53
+ } else {
54
+ contents += `
55
+ allprojects {
56
+ repositories {${MAPBOX_MAVEN_BLOCK}
57
+ }
58
+ }`;
110
59
  }
111
- }
60
+
61
+ fs.writeFileSync(settingsPath, contents);
62
+ return cfg;
63
+ },
64
+ ]);
65
+ };
66
+
67
+ // ─── Plugin ─────────────────────────────────────────────────────────────
68
+
69
+ const withExpoMapboxNavigation = (config, options) => {
70
+ const {
71
+ accessToken,
72
+ mapboxMapsVersion = '11.11.0',
73
+ androidColorOverrides = {},
74
+ } = options;
75
+
76
+ if (!accessToken) {
77
+ throw new Error('[expo-mapbox-navigation] accessToken is required');
78
+ }
79
+
80
+ // ── iOS ───────────────────────────────────────────────────────────────
81
+ config = withInfoPlist(config, (cfg) => {
82
+ cfg.modResults.MBXAccessToken = accessToken;
83
+
84
+ cfg.modResults.NSLocationWhenInUseUsageDescription =
85
+ cfg.modResults.NSLocationWhenInUseUsageDescription ??
86
+ 'Navigation GPS requires location access.';
87
+
88
+ cfg.modResults.NSLocationAlwaysAndWhenInUseUsageDescription =
89
+ cfg.modResults.NSLocationAlwaysAndWhenInUseUsageDescription ??
90
+ 'Background navigation requires location access.';
91
+
92
+ cfg.modResults.NSMotionUsageDescription =
93
+ cfg.modResults.NSMotionUsageDescription ??
94
+ 'Motion is used to improve navigation experience.';
95
+
96
+ const modes = cfg.modResults.UIBackgroundModes || [];
97
+ if (!modes.includes('audio')) modes.push('audio');
98
+ if (!modes.includes('location')) modes.push('location');
99
+ cfg.modResults.UIBackgroundModes = modes;
112
100
 
113
101
  return cfg;
114
102
  });
115
103
 
116
- // ── Android Manifest ──
104
+ // ── Android settings.gradle FIX (IMPORTANT SDK 53) ────────────────────
105
+ config = withMapboxMavenInSettings(config);
106
+
107
+ // ── Android Manifest ──────────────────────────────────────────────────
117
108
  config = withAndroidManifest(config, (cfg) => {
118
109
  const manifest = cfg.modResults.manifest;
119
- const permissions = manifest["uses-permission"] ?? [];
110
+ const permissions = manifest['uses-permission'] || [];
120
111
 
121
- const addPermission = (name) => {
122
- if (!permissions.some((p) => p.$?.["android:name"] === name)) {
123
- permissions.push({ $: { "android:name": name } });
112
+ const add = (name) => {
113
+ if (!permissions.find((p) => p.$?.['android:name'] === name)) {
114
+ permissions.push({ $: { 'android:name': name } });
124
115
  }
125
116
  };
126
117
 
127
- addPermission("android.permission.ACCESS_FINE_LOCATION");
128
- addPermission("android.permission.ACCESS_COARSE_LOCATION");
129
- addPermission("android.permission.FOREGROUND_SERVICE");
130
- addPermission("android.permission.FOREGROUND_SERVICE_LOCATION");
118
+ add('android.permission.ACCESS_FINE_LOCATION');
119
+ add('android.permission.ACCESS_COARSE_LOCATION');
120
+ add('android.permission.FOREGROUND_SERVICE');
121
+ add('android.permission.FOREGROUND_SERVICE_LOCATION');
131
122
 
132
- manifest["uses-permission"] = permissions;
123
+ manifest['uses-permission'] = permissions;
133
124
 
134
- const application = manifest.application?.[0];
135
- if (application) {
136
- const metaData = application["meta-data"] ?? [];
125
+ const app = manifest.application?.[0];
126
+ if (app) {
127
+ const meta = app['meta-data'] || [];
137
128
 
138
- const existingToken = metaData.find(
139
- (m) => m.$?.["android:name"] === "com.mapbox.token"
140
- );
141
-
142
- if (!existingToken) {
143
- metaData.push({
129
+ if (!meta.find((m) => m.$?.['android:name'] === 'com.mapbox.token')) {
130
+ meta.push({
144
131
  $: {
145
- "android:name": "com.mapbox.token",
146
- "android:value": accessToken,
132
+ 'android:name': 'com.mapbox.token',
133
+ 'android:value': accessToken,
147
134
  },
148
135
  });
149
136
  }
150
137
 
151
- application["meta-data"] = metaData;
138
+ app['meta-data'] = meta;
139
+ }
140
+
141
+ return cfg;
142
+ });
143
+
144
+ // ── App build.gradle ──────────────────────────────────────────────────
145
+ config = withAppBuildGradle(config, (cfg) => {
146
+ if (!cfg.modResults.contents.includes('mapbox_access_token')) {
147
+ cfg.modResults.contents = cfg.modResults.contents.replace(
148
+ /defaultConfig\s*\{/,
149
+ `defaultConfig {
150
+ resValue "string", "mapbox_access_token", "${accessToken}"`
151
+ );
152
152
  }
153
153
 
154
154
  return cfg;
@@ -160,14 +160,7 @@ ${colorResources}
160
160
  const plugin = createRunOncePlugin(
161
161
  withExpoMapboxNavigation,
162
162
  "expo-mapbox-navigation",
163
- "1.0.4"
164
- );
165
-
166
- module.exports = plugin;
167
- module.exports.default = plugin;const plugin = createRunOncePlugin(
168
- withExpoMapboxNavigation,
169
- "expo-mapbox-navigation",
170
- "1.0.6"
163
+ "1.0.8"
171
164
  );
172
165
 
173
166
  module.exports = plugin;
package/plugin/index.ts DELETED
@@ -1,186 +0,0 @@
1
- import {
2
- ConfigPlugin,
3
- withInfoPlist,
4
- withAppBuildGradle,
5
- withProjectBuildGradle,
6
- withAndroidManifest,
7
- createRunOncePlugin,
8
- } from '@expo/config-plugins';
9
-
10
- export interface ExpoMapboxNavigationPluginOptions {
11
- /** Token public Mapbox (commence par pk.) */
12
- accessToken: string;
13
- /**
14
- * Version du SDK Mapbox Maps (doit correspondre à la version utilisée par @rnmapbox/maps).
15
- * Exemple: "11.11.0"
16
- */
17
- mapboxMapsVersion?: string;
18
- /**
19
- * Overrides de couleurs Android pour personnaliser l'UI Mapbox.
20
- * Exemple: { "mapbox_main_maneuver_background_color": "#FF0000" }
21
- */
22
- androidColorOverrides?: Record<string, string>;
23
- }
24
-
25
- const withExpoMapboxNavigation: ConfigPlugin<ExpoMapboxNavigationPluginOptions> = (
26
- config,
27
- options
28
- ) => {
29
- const { accessToken, mapboxMapsVersion = '11.11.0', androidColorOverrides = {} } = options;
30
-
31
- if (!accessToken) {
32
- throw new Error(
33
- '[expo-mapbox-navigation] accessToken est requis dans la configuration du plugin.'
34
- );
35
- }
36
-
37
- // ── iOS — Info.plist ──────────────────────────────────────────────────────
38
-
39
- config = withInfoPlist(config, (cfg) => {
40
- cfg.modResults['MBXAccessToken'] = accessToken;
41
-
42
- cfg.modResults['NSLocationWhenInUseUsageDescription'] =
43
- cfg.modResults['NSLocationWhenInUseUsageDescription'] ??
44
- 'Cette application utilise votre position pour la navigation GPS.';
45
-
46
- cfg.modResults['NSLocationAlwaysAndWhenInUseUsageDescription'] =
47
- cfg.modResults['NSLocationAlwaysAndWhenInUseUsageDescription'] ??
48
- "Cette application utilise votre position en arrière-plan pour la navigation GPS.";
49
-
50
- cfg.modResults['NSMotionUsageDescription'] =
51
- cfg.modResults['NSMotionUsageDescription'] ??
52
- "Cette application utilise le capteur de mouvement pour améliorer la navigation.";
53
-
54
- // Background modes: audio (voix) + location
55
- const uiBackgroundModes: string[] = cfg.modResults['UIBackgroundModes'] ?? [];
56
- if (!uiBackgroundModes.includes('audio')) uiBackgroundModes.push('audio');
57
- if (!uiBackgroundModes.includes('location')) uiBackgroundModes.push('location');
58
- cfg.modResults['UIBackgroundModes'] = uiBackgroundModes;
59
-
60
- return cfg;
61
- });
62
-
63
- // ── Android — project build.gradle (repo Maven Mapbox) ───────────────────
64
-
65
- config = withProjectBuildGradle(config, (cfg) => {
66
- if (!cfg.modResults.contents.includes('api.mapbox.com/downloads')) {
67
- // Ajouter le repo Mapbox dans allprojects > repositories
68
- cfg.modResults.contents = cfg.modResults.contents.replace(
69
- /allprojects\s*\{([\s\S]*?)repositories\s*\{/,
70
- `allprojects {$1repositories {
71
- maven {
72
- url 'https://api.mapbox.com/downloads/v2/releases/maven'
73
- authentication { basic(BasicAuthentication) }
74
- credentials {
75
- username = "mapbox"
76
- password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: ""
77
- }
78
- }`
79
- );
80
- }
81
- return cfg;
82
- });
83
-
84
- // ── Android — app build.gradle (token + version maps) ────────────────────
85
-
86
- config = withAppBuildGradle(config, (cfg) => {
87
- // Injecter le token Mapbox public comme ressource string
88
- if (!cfg.modResults.contents.includes('mapbox_access_token')) {
89
- cfg.modResults.contents = cfg.modResults.contents.replace(
90
- /defaultConfig\s*\{/,
91
- `defaultConfig {
92
- resValue "string", "mapbox_access_token", "${accessToken}"`
93
- );
94
- }
95
-
96
- // Injecter RNMapboxMapsVersion (requis par @rnmapbox/maps)
97
- if (
98
- mapboxMapsVersion &&
99
- !cfg.modResults.contents.includes('RNMapboxMapsVersion')
100
- ) {
101
- cfg.modResults.contents = cfg.modResults.contents.replace(
102
- /ext\s*\{/,
103
- `ext {
104
- RNMapboxMapsVersion = "${mapboxMapsVersion}"`
105
- );
106
-
107
- // Si pas de bloc ext, en créer un
108
- if (!cfg.modResults.contents.includes('RNMapboxMapsVersion')) {
109
- cfg.modResults.contents = cfg.modResults.contents.replace(
110
- /^(buildscript\s*\{)/m,
111
- `ext {
112
- RNMapboxMapsVersion = "${mapboxMapsVersion}"
113
- }
114
-
115
- $1`
116
- );
117
- }
118
- }
119
-
120
- // Générer les color overrides Android
121
- if (Object.keys(androidColorOverrides).length > 0) {
122
- const colorResources = Object.entries(androidColorOverrides)
123
- .map(([name, value]) => ` resValue "color", "${name}", "${value}"`)
124
- .join('\n');
125
-
126
- if (!cfg.modResults.contents.includes('androidColorOverrides_injected')) {
127
- cfg.modResults.contents = cfg.modResults.contents.replace(
128
- /defaultConfig\s*\{/,
129
- `defaultConfig {
130
- ${colorResources}
131
- // androidColorOverrides_injected`
132
- );
133
- }
134
- }
135
-
136
- return cfg;
137
- });
138
-
139
- // ── Android — Manifest (permissions) ─────────────────────────────────────
140
-
141
- config = withAndroidManifest(config, (cfg) => {
142
- const manifest = cfg.modResults.manifest;
143
- const permissions: any[] = manifest['uses-permission'] ?? [];
144
-
145
- const addPermission = (name: string) => {
146
- if (!permissions.some((p: any) => p.$?.['android:name'] === name)) {
147
- permissions.push({ $: { 'android:name': name } });
148
- }
149
- };
150
-
151
- addPermission('android.permission.ACCESS_FINE_LOCATION');
152
- addPermission('android.permission.ACCESS_COARSE_LOCATION');
153
- addPermission('android.permission.FOREGROUND_SERVICE');
154
- addPermission('android.permission.FOREGROUND_SERVICE_LOCATION');
155
-
156
- manifest['uses-permission'] = permissions;
157
-
158
- // Ajouter le token Mapbox dans les métadonnées de l'application
159
- const application = manifest.application?.[0];
160
- if (application) {
161
- const metaData: any[] = application['meta-data'] ?? [];
162
- const existingToken = metaData.find(
163
- (m: any) => m.$?.['android:name'] === 'com.mapbox.token'
164
- );
165
- if (!existingToken) {
166
- metaData.push({
167
- $: {
168
- 'android:name': 'com.mapbox.token',
169
- 'android:value': accessToken,
170
- },
171
- });
172
- }
173
- application['meta-data'] = metaData;
174
- }
175
-
176
- return cfg;
177
- });
178
-
179
- return config;
180
- };
181
-
182
- export default createRunOncePlugin(
183
- withExpoMapboxNavigation,
184
- 'expo-mapbox-navigation',
185
- '1.0.4'
186
- );