@rnmapbox/maps 10.2.6 → 10.2.7
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/android/src/main/java/com/rnmapbox/rnmbx/modules/CustomHttpHeaders.kt +31 -9
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +15 -1
- package/ios/RNMBX/CustomHttpHeaders.swift +36 -7
- package/ios/RNMBX/RNMBXModule.m +1 -0
- package/ios/RNMBX/RNMBXModule.swift +16 -2
- package/ios/RNMBX/Utils/RNMBXViewResolver.mm +15 -2
- package/lib/commonjs/plugin/build/withMapbox.js +8 -8
- package/lib/commonjs/plugin/src/withMapbox.ts +8 -8
- package/lib/module/RNMBXModule.js +15 -1
- package/lib/module/RNMBXModule.js.map +1 -1
- package/lib/typescript/plugin/build/withMapbox.d.ts +1 -6
- package/lib/typescript/plugin/build/withMapbox.d.ts.map +1 -1
- package/lib/typescript/src/RNMBXModule.d.ts +11 -1
- package/lib/typescript/src/RNMBXModule.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/build/withMapbox.js +8 -8
- package/plugin/src/withMapbox.ts +8 -8
- package/src/RNMBXModule.ts +29 -3
|
@@ -1,36 +1,58 @@
|
|
|
1
1
|
package com.rnmapbox.rnmbx.modules
|
|
2
2
|
|
|
3
3
|
import com.mapbox.common.*
|
|
4
|
-
|
|
5
4
|
import com.rnmapbox.rnmbx.v11compat.httpinterceptor.*
|
|
6
5
|
|
|
6
|
+
data class CustomHttpHeadersOptions(val urlRegexp: Regex?)
|
|
7
|
+
|
|
8
|
+
data class CustomHttpHeadersMapValue(
|
|
9
|
+
val headerValue: String,
|
|
10
|
+
val options: CustomHttpHeadersOptions?
|
|
11
|
+
)
|
|
12
|
+
|
|
7
13
|
object CustomHttpHeaders : HttpServiceBase() {
|
|
14
|
+
const val LOG_TAG = "CustomHttpHeaders"
|
|
15
|
+
|
|
8
16
|
init {}
|
|
9
17
|
|
|
10
|
-
val map = mutableMapOf<String,
|
|
18
|
+
val map = mutableMapOf<String, CustomHttpHeadersMapValue>()
|
|
11
19
|
|
|
12
|
-
fun addCustomHeader(headerName: String, headerValue: String) {
|
|
20
|
+
fun addCustomHeader(headerName: String, headerValue: String, options: CustomHttpHeadersOptions? = null) {
|
|
13
21
|
HttpServiceFactory.getInstance().setInterceptor(
|
|
14
22
|
this
|
|
15
23
|
)
|
|
16
|
-
map.put(headerName, headerValue)
|
|
24
|
+
map.put(headerName, CustomHttpHeadersMapValue(headerValue = headerValue, options = options))
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
fun removeCustomHeader(headerName: String) {
|
|
20
28
|
map.remove(headerName)
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
fun getCustomRequestHeaders(customRequestHeaders: MutableMap<String, CustomHttpHeadersMapValue>, httpRequest: HttpRequest): HashMap<String, String> {
|
|
32
|
+
val headers = hashMapOf<String, String>()
|
|
24
33
|
for (entry in map.entries.iterator()) {
|
|
25
|
-
|
|
34
|
+
val urlRegexp = entry.value.options?.urlRegexp
|
|
35
|
+
if (urlRegexp != null) {
|
|
36
|
+
val destination = httpRequest.headers.getOrDefault("location", httpRequest.url)
|
|
37
|
+
if (urlRegexp.matches(destination)) {
|
|
38
|
+
headers[entry.key] = entry.value.headerValue
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
headers[entry.key] = entry.value.headerValue
|
|
43
|
+
}
|
|
26
44
|
}
|
|
45
|
+
return headers
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun onRequest(request: HttpRequest): HttpRequest {
|
|
49
|
+
request.headers.remove("Authorization")
|
|
50
|
+
request.headers.putAll(getCustomRequestHeaders(map, request))
|
|
27
51
|
return request
|
|
28
52
|
}
|
|
29
53
|
|
|
30
54
|
override fun onDownload(download: DownloadOptions): DownloadOptions {
|
|
31
|
-
|
|
32
|
-
download.request.headers[entry.key] = entry.value
|
|
33
|
-
}
|
|
55
|
+
download.request.headers.putAll(getCustomRequestHeaders(map, download.request))
|
|
34
56
|
return download
|
|
35
57
|
}
|
|
36
58
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.rnmapbox.rnmbx.modules
|
|
2
2
|
|
|
3
3
|
import android.os.Handler
|
|
4
|
+
import androidx.annotation.Nullable
|
|
4
5
|
import com.facebook.react.bridge.Promise
|
|
5
6
|
import com.mapbox.maps.extension.style.layers.properties.generated.LineJoin
|
|
6
7
|
import com.facebook.react.module.annotations.ReactModule
|
|
@@ -11,6 +12,8 @@ import com.rnmapbox.rnmbx.events.constants.EventTypes
|
|
|
11
12
|
import com.rnmapbox.rnmbx.modules.RNMBXOfflineModule
|
|
12
13
|
import com.rnmapbox.rnmbx.modules.RNMBXLocationModule
|
|
13
14
|
import com.facebook.react.bridge.ReactMethod
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap
|
|
16
|
+
import com.facebook.react.bridge.buildReadableMap
|
|
14
17
|
import com.facebook.react.common.MapBuilder
|
|
15
18
|
import com.mapbox.bindgen.None
|
|
16
19
|
import com.mapbox.common.*
|
|
@@ -24,6 +27,7 @@ import java.util.HashMap
|
|
|
24
27
|
|
|
25
28
|
import com.rnmapbox.rnmbx.v11compat.resourceoption.*
|
|
26
29
|
import com.rnmapbox.rnmbx.v11compat.mapboxmap.*
|
|
30
|
+
import java.util.regex.PatternSyntaxException
|
|
27
31
|
|
|
28
32
|
@ReactModule(name = RNMBXModule.REACT_CLASS)
|
|
29
33
|
class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
@@ -165,7 +169,17 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
|
|
|
165
169
|
|
|
166
170
|
@ReactMethod
|
|
167
171
|
fun addCustomHeader(headerName: String, headerValue: String) {
|
|
168
|
-
|
|
172
|
+
addCustomHeaderWithOptions(headerName, headerValue)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@ReactMethod
|
|
176
|
+
fun addCustomHeaderWithOptions(headerName: String, headerValue: String, options: ReadableMap? = buildReadableMap { }) {
|
|
177
|
+
try {
|
|
178
|
+
val urlRegexp = options?.getString("urlRegexp")?.toRegex()
|
|
179
|
+
CustomHttpHeaders.addCustomHeader(headerName, headerValue, CustomHttpHeadersOptions(urlRegexp = urlRegexp))
|
|
180
|
+
} catch (e: PatternSyntaxException) {
|
|
181
|
+
Logger.e(CustomHttpHeaders.LOG_TAG, e.localizedMessage ?: "Error converting ${options?.getString("urlRegexp")} to regex")
|
|
182
|
+
}
|
|
169
183
|
}
|
|
170
184
|
|
|
171
185
|
@ReactMethod
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import MapboxMaps
|
|
2
2
|
|
|
3
|
+
struct CustomHttpHeadersOptions {
|
|
4
|
+
var urlRegexp: NSRegularExpression?
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
struct CustomHttpHeadersMapValue {
|
|
8
|
+
var headerValue: String
|
|
9
|
+
var options: CustomHttpHeadersOptions
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
class CustomHttpHeaders : HttpServiceInterceptorInterface {
|
|
4
13
|
#if RNMBX_11
|
|
5
14
|
func onRequest(for request: HttpRequest, continuation: @escaping HttpServiceInterceptorRequestContinuation) {
|
|
@@ -18,7 +27,7 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
|
|
|
18
27
|
return headers
|
|
19
28
|
}()
|
|
20
29
|
|
|
21
|
-
var customHeaders : [String:
|
|
30
|
+
var customHeaders : [String:CustomHttpHeadersMapValue] = [:]
|
|
22
31
|
|
|
23
32
|
func install() {
|
|
24
33
|
#if RNMBX_11
|
|
@@ -38,19 +47,39 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
|
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
// MARK: - HttpServiceInterceptorInterface
|
|
50
|
+
|
|
51
|
+
func getCustomRequestHeaders(for request: HttpRequest, with customHeaders: [String: CustomHttpHeadersMapValue]) -> [String: String] {
|
|
52
|
+
var headers: [String: String] = [:]
|
|
53
|
+
let urlString = request.url
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
for (key, entry) in customHeaders {
|
|
56
|
+
let options = entry.options
|
|
57
|
+
|
|
58
|
+
if let pattern = options.urlRegexp {
|
|
59
|
+
do {
|
|
60
|
+
let range = NSRange(location: 0, length: urlString.utf16.count)
|
|
61
|
+
if pattern.firstMatch(in: urlString, options: [], range: range) != nil {
|
|
62
|
+
headers[key] = entry.headerValue
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
headers[key] = entry.headerValue
|
|
67
|
+
}
|
|
45
68
|
}
|
|
69
|
+
return headers
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
func onRequest(for request: HttpRequest) -> HttpRequest {
|
|
74
|
+
let customHeaders = getCustomRequestHeaders(for: request, with: customHeaders)
|
|
75
|
+
request.headers.merge(customHeaders) { (_, new) in new }
|
|
46
76
|
return request
|
|
47
77
|
}
|
|
48
78
|
|
|
49
79
|
#if !RNMBX_11
|
|
50
80
|
func onDownload(forDownload download: DownloadOptions) -> DownloadOptions {
|
|
51
|
-
customHeaders
|
|
52
|
-
|
|
53
|
-
}
|
|
81
|
+
let customHeaders = getCustomRequestHeaders(for: download.request, with: customHeaders)
|
|
82
|
+
download.request.headers.merge(customHeaders) { (_, new) in new }
|
|
54
83
|
return download
|
|
55
84
|
}
|
|
56
85
|
#endif
|
package/ios/RNMBX/RNMBXModule.m
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
RCT_EXTERN_METHOD(setAccessToken:(NSString *)accessToken resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
6
6
|
|
|
7
7
|
RCT_EXTERN_METHOD(addCustomHeader:(NSString *)headerName forHeaderValue:(NSString *) headerValue)
|
|
8
|
+
RCT_EXTERN_METHOD(addCustomHeaderWithOptions:(NSString *)headerName forHeaderValue:(NSString *) headerValue forOptions:(nullable NSDictionary *) options)
|
|
8
9
|
RCT_EXTERN_METHOD(removeCustomHeader:(NSString *)headerName)
|
|
9
10
|
|
|
10
11
|
RCT_EXTERN_METHOD(setTelemetryEnabled:(BOOL)telemetryEnabled)
|
|
@@ -98,9 +98,23 @@ class RNMBXModule : NSObject {
|
|
|
98
98
|
RNMBXModule.accessToken = token
|
|
99
99
|
resolver(token)
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
@objc func addCustomHeader(_ headerName: String, forHeaderValue headerValue: String) {
|
|
103
|
+
addCustomHeaderWithOptions(headerName, forHeaderValue: headerValue, forOptions: nil)
|
|
104
|
+
}
|
|
101
105
|
|
|
102
|
-
@objc func
|
|
103
|
-
|
|
106
|
+
@objc func addCustomHeaderWithOptions(_ headerName: String, forHeaderValue headerValue: String, forOptions options: NSDictionary?) {
|
|
107
|
+
var urlRegexp: NSRegularExpression? = nil
|
|
108
|
+
if let pattern = options?.value(forKey: "urlRegexp") as? String {
|
|
109
|
+
do {
|
|
110
|
+
urlRegexp = try NSRegularExpression(pattern: pattern)
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
Logger.log(level: .error, message: "Invalid regex pattern: \(error.localizedDescription)")
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
CustomHttpHeaders.shared.customHeaders[headerName] = CustomHttpHeadersMapValue(headerValue: headerValue, options: CustomHttpHeadersOptions(urlRegexp: urlRegexp))
|
|
104
118
|
}
|
|
105
119
|
|
|
106
120
|
@objc func removeCustomHeader(_ headerName: String) {
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
#import "RNMBXViewResolver.h"
|
|
8
8
|
|
|
9
|
+
// View resolution timeout and delay constants
|
|
10
|
+
static const NSTimeInterval MAX_TIMEOUT = 10.0; // 10 seconds
|
|
11
|
+
static const int64_t DELAY_ON_FIRST_ATTEMPT = (NSEC_PER_MSEC/5); // 0.2ms
|
|
12
|
+
static const int64_t DELAY_ON_NEXT_5_ATTEMPTS = 10 * NSEC_PER_MSEC; // 10ms
|
|
13
|
+
static const int64_t DELAY_ON_FURTHER_ATTEMPTS = 200 * NSEC_PER_MSEC; // 200ms
|
|
14
|
+
|
|
9
15
|
@implementation RNMBXViewResolver
|
|
10
16
|
|
|
11
17
|
+ (void)withViewRef:(NSNumber *)viewRef
|
|
@@ -84,7 +90,7 @@
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
NSTimeInterval elapsed = [[NSDate date] timeIntervalSinceDate:startTime];
|
|
87
|
-
if (elapsed >=
|
|
93
|
+
if (elapsed >= MAX_TIMEOUT) {
|
|
88
94
|
NSString *errorMsg = [NSString stringWithFormat:@"Could not find view with tag %@ in %@ after %d attempts over %.1fms",
|
|
89
95
|
viewRef, methodName, (int)attemptCount + 1, elapsed * 1000];
|
|
90
96
|
NSLog(@"%@", errorMsg);
|
|
@@ -92,7 +98,14 @@
|
|
|
92
98
|
return;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
int64_t delay
|
|
101
|
+
int64_t delay;
|
|
102
|
+
if (attemptCount == 0) {
|
|
103
|
+
delay = DELAY_ON_FIRST_ATTEMPT;
|
|
104
|
+
} else if (attemptCount <= 5) {
|
|
105
|
+
delay = DELAY_ON_NEXT_5_ATTEMPTS;
|
|
106
|
+
} else {
|
|
107
|
+
delay = DELAY_ON_FURTHER_ATTEMPTS;
|
|
108
|
+
}
|
|
96
109
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay), dispatch_get_main_queue(), ^{
|
|
97
110
|
[self resolveViewWithPolling:viewRef
|
|
98
111
|
delegate:delegate
|
|
@@ -117,7 +117,7 @@ exports.addMapboxInstallerBlock = addMapboxInstallerBlock;
|
|
|
117
117
|
*
|
|
118
118
|
* https://github.com/rnmapbox/maps/blob/main/ios/install.md#react-native--0600
|
|
119
119
|
*/
|
|
120
|
-
const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }) => (0, config_plugins_1.withDangerousMod)(config, [
|
|
120
|
+
const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, } = {}) => (0, config_plugins_1.withDangerousMod)(config, [
|
|
121
121
|
'ios',
|
|
122
122
|
async (exportedConfig) => {
|
|
123
123
|
const file = path_1.default.join(exportedConfig.modRequest.platformProjectRoot, 'Podfile');
|
|
@@ -131,7 +131,7 @@ const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVe
|
|
|
131
131
|
return exportedConfig;
|
|
132
132
|
},
|
|
133
133
|
]);
|
|
134
|
-
const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken }) => {
|
|
134
|
+
const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken } = {}) => {
|
|
135
135
|
const key = 'MAPBOX_DOWNLOADS_TOKEN';
|
|
136
136
|
if (RNMapboxMapsDownloadToken) {
|
|
137
137
|
console.warn('⚠️ WARNING: RNMapboxMapsDownloadToken is deprecated. Use RNMAPBOX_MAPS_DOWNLOAD_TOKEN environment variable instead.');
|
|
@@ -148,7 +148,7 @@ const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken
|
|
|
148
148
|
}
|
|
149
149
|
return config;
|
|
150
150
|
};
|
|
151
|
-
const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 }) => {
|
|
151
|
+
const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 } = {}) => {
|
|
152
152
|
const keyValues = {
|
|
153
153
|
expoRNMapboxMapsImpl: RNMapboxMapsImpl,
|
|
154
154
|
expoRNMapboxMapsVersion: RNMapboxMapsVersion,
|
|
@@ -174,7 +174,7 @@ const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVers
|
|
|
174
174
|
}
|
|
175
175
|
return config;
|
|
176
176
|
};
|
|
177
|
-
const withAndroidProperties = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, }) => {
|
|
177
|
+
const withAndroidProperties = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, } = {}) => {
|
|
178
178
|
config = withAndroidPropertiesDownloadToken(config, {
|
|
179
179
|
RNMapboxMapsDownloadToken,
|
|
180
180
|
});
|
|
@@ -256,7 +256,7 @@ const addMapboxMavenRepo = (src) => appendContents({
|
|
|
256
256
|
}).contents;
|
|
257
257
|
exports.addMapboxMavenRepo = addMapboxMavenRepo;
|
|
258
258
|
exports._addMapboxMavenRepo = exports.addMapboxMavenRepo;
|
|
259
|
-
const withAndroidAppGradle = (config) => (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
259
|
+
const withAndroidAppGradle = (config, _props = {}) => (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
260
260
|
if (modResults.language !== 'groovy') {
|
|
261
261
|
config_plugins_1.WarningAggregator.addWarningAndroid('withMapbox', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
262
262
|
return { modResults, ...exportedConfig };
|
|
@@ -264,7 +264,7 @@ const withAndroidAppGradle = (config) => (0, config_plugins_1.withAppBuildGradle
|
|
|
264
264
|
modResults.contents = addLibCppFilter(modResults.contents);
|
|
265
265
|
return { modResults, ...exportedConfig };
|
|
266
266
|
});
|
|
267
|
-
const withAndroidProjectGradle = (config) => (0, config_plugins_1.withProjectBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
267
|
+
const withAndroidProjectGradle = (config, _props = {}) => (0, config_plugins_1.withProjectBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
268
268
|
if (modResults.language !== 'groovy') {
|
|
269
269
|
config_plugins_1.WarningAggregator.addWarningAndroid('withMapbox', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
270
270
|
return { modResults, ...exportedConfig };
|
|
@@ -272,7 +272,7 @@ const withAndroidProjectGradle = (config) => (0, config_plugins_1.withProjectBui
|
|
|
272
272
|
modResults.contents = (0, exports.addMapboxMavenRepo)(modResults.contents);
|
|
273
273
|
return { modResults, ...exportedConfig };
|
|
274
274
|
});
|
|
275
|
-
const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, }) => {
|
|
275
|
+
const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, } = {}) => {
|
|
276
276
|
config = withAndroidProperties(config, {
|
|
277
277
|
RNMapboxMapsImpl,
|
|
278
278
|
RNMapboxMapsDownloadToken,
|
|
@@ -283,7 +283,7 @@ const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken
|
|
|
283
283
|
config = withAndroidAppGradle(config, { RNMapboxMapsImpl });
|
|
284
284
|
return config;
|
|
285
285
|
};
|
|
286
|
-
const withMapbox = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }) => {
|
|
286
|
+
const withMapbox = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, } = {}) => {
|
|
287
287
|
config = withMapboxAndroid(config, {
|
|
288
288
|
RNMapboxMapsImpl,
|
|
289
289
|
RNMapboxMapsVersion,
|
|
@@ -188,7 +188,7 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
|
|
|
188
188
|
RNMapboxMapsVersion,
|
|
189
189
|
RNMapboxMapsDownloadToken,
|
|
190
190
|
RNMapboxMapsUseV11,
|
|
191
|
-
},
|
|
191
|
+
}: MapboxPlugProps = {},
|
|
192
192
|
) =>
|
|
193
193
|
withDangerousMod(config, [
|
|
194
194
|
'ios',
|
|
@@ -216,7 +216,7 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
|
|
|
216
216
|
|
|
217
217
|
const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
|
|
218
218
|
config,
|
|
219
|
-
{ RNMapboxMapsDownloadToken },
|
|
219
|
+
{ RNMapboxMapsDownloadToken }: MapboxPlugProps = {},
|
|
220
220
|
) => {
|
|
221
221
|
const key = 'MAPBOX_DOWNLOADS_TOKEN';
|
|
222
222
|
|
|
@@ -247,7 +247,7 @@ const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
|
|
|
247
247
|
|
|
248
248
|
const withAndroidPropertiesImpl2: ConfigPlugin<MapboxPlugProps> = (
|
|
249
249
|
config,
|
|
250
|
-
{ RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 },
|
|
250
|
+
{ RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 }: MapboxPlugProps = {},
|
|
251
251
|
) => {
|
|
252
252
|
const keyValues = {
|
|
253
253
|
expoRNMapboxMapsImpl: RNMapboxMapsImpl,
|
|
@@ -289,7 +289,7 @@ const withAndroidProperties: ConfigPlugin<MapboxPlugProps> = (
|
|
|
289
289
|
RNMapboxMapsDownloadToken,
|
|
290
290
|
RNMapboxMapsVersion,
|
|
291
291
|
RNMapboxMapsUseV11,
|
|
292
|
-
},
|
|
292
|
+
}: MapboxPlugProps = {},
|
|
293
293
|
) => {
|
|
294
294
|
config = withAndroidPropertiesDownloadToken(config, {
|
|
295
295
|
RNMapboxMapsDownloadToken,
|
|
@@ -391,7 +391,7 @@ export const addMapboxMavenRepo = (src: string): string =>
|
|
|
391
391
|
comment: '//',
|
|
392
392
|
}).contents;
|
|
393
393
|
|
|
394
|
-
const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
394
|
+
const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config, _props: MapboxPlugProps = {}) =>
|
|
395
395
|
withAppBuildGradle(config, ({ modResults, ...exportedConfig }) => {
|
|
396
396
|
if (modResults.language !== 'groovy') {
|
|
397
397
|
WarningAggregator.addWarningAndroid(
|
|
@@ -407,7 +407,7 @@ const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
|
407
407
|
return { modResults, ...exportedConfig };
|
|
408
408
|
});
|
|
409
409
|
|
|
410
|
-
const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
410
|
+
const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config, _props: MapboxPlugProps = {}) =>
|
|
411
411
|
withProjectBuildGradle(config, ({ modResults, ...exportedConfig }) => {
|
|
412
412
|
if (modResults.language !== 'groovy') {
|
|
413
413
|
WarningAggregator.addWarningAndroid(
|
|
@@ -430,7 +430,7 @@ const withMapboxAndroid: ConfigPlugin<MapboxPlugProps> = (
|
|
|
430
430
|
RNMapboxMapsDownloadToken,
|
|
431
431
|
RNMapboxMapsVersion,
|
|
432
432
|
RNMapboxMapsUseV11,
|
|
433
|
-
},
|
|
433
|
+
}: MapboxPlugProps = {},
|
|
434
434
|
) => {
|
|
435
435
|
config = withAndroidProperties(config, {
|
|
436
436
|
RNMapboxMapsImpl,
|
|
@@ -451,7 +451,7 @@ const withMapbox: ConfigPlugin<MapboxPlugProps> = (
|
|
|
451
451
|
RNMapboxMapsVersion,
|
|
452
452
|
RNMapboxMapsDownloadToken,
|
|
453
453
|
RNMapboxMapsUseV11,
|
|
454
|
-
},
|
|
454
|
+
}: MapboxPlugProps = {},
|
|
455
455
|
) => {
|
|
456
456
|
config = withMapboxAndroid(config, {
|
|
457
457
|
RNMapboxMapsImpl,
|
|
@@ -10,6 +10,20 @@ if (NativeModules.RNMBXModule == null) {
|
|
|
10
10
|
throw new Error('@rnmapbox/maps native code not available. Make sure you have linked the library and rebuild your app. See https://rnmapbox.github.io/docs/install');
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Add a custom header to HTTP requests.
|
|
16
|
+
* @param headerName - The name of the header
|
|
17
|
+
* @param headerValue - The value of the header
|
|
18
|
+
* @param options - Optional configuration. If provided with urlRegexp, the header will only be added to URLs matching the regex
|
|
19
|
+
*/
|
|
20
|
+
function addCustomHeader(headerName, headerValue, options) {
|
|
21
|
+
if (options) {
|
|
22
|
+
RNMBXModule.addCustomHeaderWithOptions(headerName, headerValue, options);
|
|
23
|
+
} else {
|
|
24
|
+
RNMBXModule.addCustomHeader(headerName, headerValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
13
27
|
export const {
|
|
14
28
|
StyleURL,
|
|
15
29
|
OfflinePackDownloadState,
|
|
@@ -17,7 +31,6 @@ export const {
|
|
|
17
31
|
StyleSource,
|
|
18
32
|
TileServers,
|
|
19
33
|
removeCustomHeader,
|
|
20
|
-
addCustomHeader,
|
|
21
34
|
setAccessToken,
|
|
22
35
|
setWellKnownTileServer,
|
|
23
36
|
clearData,
|
|
@@ -25,4 +38,5 @@ export const {
|
|
|
25
38
|
setTelemetryEnabled,
|
|
26
39
|
setConnected
|
|
27
40
|
} = RNMBXModule;
|
|
41
|
+
export { addCustomHeader };
|
|
28
42
|
//# sourceMappingURL=RNMBXModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","RNMBXModule","global","expo","Error","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","
|
|
1
|
+
{"version":3,"names":["NativeModules","RNMBXModule","global","expo","Error","addCustomHeader","headerName","headerValue","options","addCustomHeaderWithOptions","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","setAccessToken","setWellKnownTileServer","clearData","getAccessToken","setTelemetryEnabled","setConnected"],"sourceRoot":"../../src","sources":["RNMBXModule.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AA8C5C,MAAMC,WAAwB,GAAGD,aAAa,CAACC,WAAW;AAC1D,IAAID,aAAa,CAACC,WAAW,IAAI,IAAI,EAAE;EACrC,IAAKC,MAAM,CAAwBC,IAAI,IAAI,IAAI,EAAE;IAC/C;IACA,MAAM,IAAIC,KAAK,CACb,wKACF,CAAC;EACH,CAAC,MAAM;IACL,MAAM,IAAIA,KAAK,CACb,mJACF,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CACtBC,UAAkB,EAClBC,WAAmB,EACnBC,OAAgC,EAC1B;EACN,IAAIA,OAAO,EAAE;IACXP,WAAW,CAACQ,0BAA0B,CAACH,UAAU,EAAEC,WAAW,EAAEC,OAAO,CAAC;EAC1E,CAAC,MAAM;IACLP,WAAW,CAACI,eAAe,CAACC,UAAU,EAAEC,WAAW,CAAC;EACtD;AACF;AAEA,OAAO,MAAM;EACXG,QAAQ;EACRC,wBAAwB;EACxBC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,cAAc;EACdC,sBAAsB;EACtBC,SAAS;EACTC,cAAc;EACdC,mBAAmB;EACnBC;AACF,CAAC,GAAGpB,WAAW;AAEf,SAASI,eAAe","ignoreList":[]}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export const __esModule: boolean;
|
|
2
|
-
declare const _default: config_plugins_1.ConfigPlugin<{
|
|
3
|
-
RNMapboxMapsImpl: any;
|
|
4
|
-
RNMapboxMapsVersion: any;
|
|
5
|
-
RNMapboxMapsDownloadToken: any;
|
|
6
|
-
RNMapboxMapsUseV11: any;
|
|
7
|
-
}>;
|
|
2
|
+
declare const _default: config_plugins_1.ConfigPlugin<{} | undefined>;
|
|
8
3
|
export default _default;
|
|
9
4
|
export function addInstallerBlock(src: any, blockName: any): any;
|
|
10
5
|
export function addConstantBlock(src: any, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMapbox.d.ts","sourceRoot":"","sources":["../../../../plugin/build/withMapbox.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withMapbox.d.ts","sourceRoot":"","sources":["../../../../plugin/build/withMapbox.js"],"names":[],"mappings":";;;AAmBA,iEA2BC;AAED;;;;;QAqCC;AAID;;;;;QAaC;AAED,0EAOW;AA2IX,kDAKW"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a custom header to HTTP requests.
|
|
3
|
+
* @param headerName - The name of the header
|
|
4
|
+
* @param headerValue - The value of the header
|
|
5
|
+
* @param options - Optional configuration. If provided with urlRegexp, the header will only be added to URLs matching the regex
|
|
6
|
+
*/
|
|
7
|
+
declare function addCustomHeader(headerName: string, headerValue: string, options?: {
|
|
8
|
+
urlRegexp?: string;
|
|
9
|
+
}): void;
|
|
1
10
|
export declare const StyleURL: {
|
|
2
11
|
Street: URL;
|
|
3
12
|
Outdoors: URL;
|
|
@@ -18,5 +27,6 @@ export declare const StyleURL: {
|
|
|
18
27
|
DefaultSourceID: string;
|
|
19
28
|
}, TileServers: {
|
|
20
29
|
Mapbox: string;
|
|
21
|
-
}, removeCustomHeader: (headerName: string) => void,
|
|
30
|
+
}, removeCustomHeader: (headerName: string) => void, setAccessToken: (accessToken: string | null) => Promise<string | null>, setWellKnownTileServer: (tileServer: string) => void, clearData: () => Promise<void>, getAccessToken: () => Promise<string>, setTelemetryEnabled: (telemetryEnabled: boolean) => void, setConnected: (connected: boolean) => void;
|
|
31
|
+
export { addCustomHeader };
|
|
22
32
|
//# sourceMappingURL=RNMBXModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNMBXModule.d.ts","sourceRoot":"","sources":["../../../src/RNMBXModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RNMBXModule.d.ts","sourceRoot":"","sources":["../../../src/RNMBXModule.ts"],"names":[],"mappings":"AA4DA;;;;;GAKG;AACH,iBAAS,eAAe,CACtB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,IAAI,CAMN;AAED,eAAO,MACL,QAAQ;YA3EE,GAAG;cACD,GAAG;WACN,GAAG;UACJ,GAAG;eACE,GAAG;qBACG,GAAG;GAuEtB,wBAAwB;cApEZ,MAAM,GAAG,MAAM;YACjB,MAAM,GAAG,MAAM;cACb,MAAM,GAAG,MAAM;cACf,MAAM,GAAG,MAAM;GAkE3B,QAAQ;WA/DC,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;GA8DxB,WAAW;qBA3DQ,MAAM;GA4DzB,WAAW;YAzDD,MAAM;GA0DhB,kBAAkB,eAxDa,MAAM,KAAG,IAAI,EAyD5C,cAAc,gBA/Cc,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAgDlE,sBAAsB,eA/Ca,MAAM,KAAG,IAAI,EAgDhD,SAAS,QA/CI,OAAO,CAAC,IAAI,CAAC,EAgD1B,cAAc,QA/CI,OAAO,CAAC,MAAM,CAAC,EAgDjC,mBAAmB,qBA/CmB,OAAO,KAAG,IAAI,EAgDpD,YAAY,cA/CY,OAAO,KAAG,IAgDrB,CAAC;AAEhB,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnmapbox/maps",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.7",
|
|
4
4
|
"description": "Community-supported, open-source React Native library for building maps using Mapbox native maps SDK for iOS and Android",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.native.d.ts",
|
|
@@ -117,7 +117,7 @@ exports.addMapboxInstallerBlock = addMapboxInstallerBlock;
|
|
|
117
117
|
*
|
|
118
118
|
* https://github.com/rnmapbox/maps/blob/main/ios/install.md#react-native--0600
|
|
119
119
|
*/
|
|
120
|
-
const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }) => (0, config_plugins_1.withDangerousMod)(config, [
|
|
120
|
+
const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, } = {}) => (0, config_plugins_1.withDangerousMod)(config, [
|
|
121
121
|
'ios',
|
|
122
122
|
async (exportedConfig) => {
|
|
123
123
|
const file = path_1.default.join(exportedConfig.modRequest.platformProjectRoot, 'Podfile');
|
|
@@ -131,7 +131,7 @@ const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVe
|
|
|
131
131
|
return exportedConfig;
|
|
132
132
|
},
|
|
133
133
|
]);
|
|
134
|
-
const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken }) => {
|
|
134
|
+
const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken } = {}) => {
|
|
135
135
|
const key = 'MAPBOX_DOWNLOADS_TOKEN';
|
|
136
136
|
if (RNMapboxMapsDownloadToken) {
|
|
137
137
|
console.warn('⚠️ WARNING: RNMapboxMapsDownloadToken is deprecated. Use RNMAPBOX_MAPS_DOWNLOAD_TOKEN environment variable instead.');
|
|
@@ -148,7 +148,7 @@ const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken
|
|
|
148
148
|
}
|
|
149
149
|
return config;
|
|
150
150
|
};
|
|
151
|
-
const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 }) => {
|
|
151
|
+
const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 } = {}) => {
|
|
152
152
|
const keyValues = {
|
|
153
153
|
expoRNMapboxMapsImpl: RNMapboxMapsImpl,
|
|
154
154
|
expoRNMapboxMapsVersion: RNMapboxMapsVersion,
|
|
@@ -174,7 +174,7 @@ const withAndroidPropertiesImpl2 = (config, { RNMapboxMapsImpl, RNMapboxMapsVers
|
|
|
174
174
|
}
|
|
175
175
|
return config;
|
|
176
176
|
};
|
|
177
|
-
const withAndroidProperties = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, }) => {
|
|
177
|
+
const withAndroidProperties = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, } = {}) => {
|
|
178
178
|
config = withAndroidPropertiesDownloadToken(config, {
|
|
179
179
|
RNMapboxMapsDownloadToken,
|
|
180
180
|
});
|
|
@@ -256,7 +256,7 @@ const addMapboxMavenRepo = (src) => appendContents({
|
|
|
256
256
|
}).contents;
|
|
257
257
|
exports.addMapboxMavenRepo = addMapboxMavenRepo;
|
|
258
258
|
exports._addMapboxMavenRepo = exports.addMapboxMavenRepo;
|
|
259
|
-
const withAndroidAppGradle = (config) => (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
259
|
+
const withAndroidAppGradle = (config, _props = {}) => (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
260
260
|
if (modResults.language !== 'groovy') {
|
|
261
261
|
config_plugins_1.WarningAggregator.addWarningAndroid('withMapbox', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
262
262
|
return { modResults, ...exportedConfig };
|
|
@@ -264,7 +264,7 @@ const withAndroidAppGradle = (config) => (0, config_plugins_1.withAppBuildGradle
|
|
|
264
264
|
modResults.contents = addLibCppFilter(modResults.contents);
|
|
265
265
|
return { modResults, ...exportedConfig };
|
|
266
266
|
});
|
|
267
|
-
const withAndroidProjectGradle = (config) => (0, config_plugins_1.withProjectBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
267
|
+
const withAndroidProjectGradle = (config, _props = {}) => (0, config_plugins_1.withProjectBuildGradle)(config, ({ modResults, ...exportedConfig }) => {
|
|
268
268
|
if (modResults.language !== 'groovy') {
|
|
269
269
|
config_plugins_1.WarningAggregator.addWarningAndroid('withMapbox', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
270
270
|
return { modResults, ...exportedConfig };
|
|
@@ -272,7 +272,7 @@ const withAndroidProjectGradle = (config) => (0, config_plugins_1.withProjectBui
|
|
|
272
272
|
modResults.contents = (0, exports.addMapboxMavenRepo)(modResults.contents);
|
|
273
273
|
return { modResults, ...exportedConfig };
|
|
274
274
|
});
|
|
275
|
-
const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, }) => {
|
|
275
|
+
const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken, RNMapboxMapsVersion, RNMapboxMapsUseV11, } = {}) => {
|
|
276
276
|
config = withAndroidProperties(config, {
|
|
277
277
|
RNMapboxMapsImpl,
|
|
278
278
|
RNMapboxMapsDownloadToken,
|
|
@@ -283,7 +283,7 @@ const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken
|
|
|
283
283
|
config = withAndroidAppGradle(config, { RNMapboxMapsImpl });
|
|
284
284
|
return config;
|
|
285
285
|
};
|
|
286
|
-
const withMapbox = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }) => {
|
|
286
|
+
const withMapbox = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, } = {}) => {
|
|
287
287
|
config = withMapboxAndroid(config, {
|
|
288
288
|
RNMapboxMapsImpl,
|
|
289
289
|
RNMapboxMapsVersion,
|
package/plugin/src/withMapbox.ts
CHANGED
|
@@ -188,7 +188,7 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
|
|
|
188
188
|
RNMapboxMapsVersion,
|
|
189
189
|
RNMapboxMapsDownloadToken,
|
|
190
190
|
RNMapboxMapsUseV11,
|
|
191
|
-
},
|
|
191
|
+
}: MapboxPlugProps = {},
|
|
192
192
|
) =>
|
|
193
193
|
withDangerousMod(config, [
|
|
194
194
|
'ios',
|
|
@@ -216,7 +216,7 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
|
|
|
216
216
|
|
|
217
217
|
const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
|
|
218
218
|
config,
|
|
219
|
-
{ RNMapboxMapsDownloadToken },
|
|
219
|
+
{ RNMapboxMapsDownloadToken }: MapboxPlugProps = {},
|
|
220
220
|
) => {
|
|
221
221
|
const key = 'MAPBOX_DOWNLOADS_TOKEN';
|
|
222
222
|
|
|
@@ -247,7 +247,7 @@ const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
|
|
|
247
247
|
|
|
248
248
|
const withAndroidPropertiesImpl2: ConfigPlugin<MapboxPlugProps> = (
|
|
249
249
|
config,
|
|
250
|
-
{ RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 },
|
|
250
|
+
{ RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsUseV11 }: MapboxPlugProps = {},
|
|
251
251
|
) => {
|
|
252
252
|
const keyValues = {
|
|
253
253
|
expoRNMapboxMapsImpl: RNMapboxMapsImpl,
|
|
@@ -289,7 +289,7 @@ const withAndroidProperties: ConfigPlugin<MapboxPlugProps> = (
|
|
|
289
289
|
RNMapboxMapsDownloadToken,
|
|
290
290
|
RNMapboxMapsVersion,
|
|
291
291
|
RNMapboxMapsUseV11,
|
|
292
|
-
},
|
|
292
|
+
}: MapboxPlugProps = {},
|
|
293
293
|
) => {
|
|
294
294
|
config = withAndroidPropertiesDownloadToken(config, {
|
|
295
295
|
RNMapboxMapsDownloadToken,
|
|
@@ -391,7 +391,7 @@ export const addMapboxMavenRepo = (src: string): string =>
|
|
|
391
391
|
comment: '//',
|
|
392
392
|
}).contents;
|
|
393
393
|
|
|
394
|
-
const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
394
|
+
const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config, _props: MapboxPlugProps = {}) =>
|
|
395
395
|
withAppBuildGradle(config, ({ modResults, ...exportedConfig }) => {
|
|
396
396
|
if (modResults.language !== 'groovy') {
|
|
397
397
|
WarningAggregator.addWarningAndroid(
|
|
@@ -407,7 +407,7 @@ const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
|
407
407
|
return { modResults, ...exportedConfig };
|
|
408
408
|
});
|
|
409
409
|
|
|
410
|
-
const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
|
|
410
|
+
const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config, _props: MapboxPlugProps = {}) =>
|
|
411
411
|
withProjectBuildGradle(config, ({ modResults, ...exportedConfig }) => {
|
|
412
412
|
if (modResults.language !== 'groovy') {
|
|
413
413
|
WarningAggregator.addWarningAndroid(
|
|
@@ -430,7 +430,7 @@ const withMapboxAndroid: ConfigPlugin<MapboxPlugProps> = (
|
|
|
430
430
|
RNMapboxMapsDownloadToken,
|
|
431
431
|
RNMapboxMapsVersion,
|
|
432
432
|
RNMapboxMapsUseV11,
|
|
433
|
-
},
|
|
433
|
+
}: MapboxPlugProps = {},
|
|
434
434
|
) => {
|
|
435
435
|
config = withAndroidProperties(config, {
|
|
436
436
|
RNMapboxMapsImpl,
|
|
@@ -451,7 +451,7 @@ const withMapbox: ConfigPlugin<MapboxPlugProps> = (
|
|
|
451
451
|
RNMapboxMapsVersion,
|
|
452
452
|
RNMapboxMapsDownloadToken,
|
|
453
453
|
RNMapboxMapsUseV11,
|
|
454
|
-
},
|
|
454
|
+
}: MapboxPlugProps = {},
|
|
455
455
|
) => {
|
|
456
456
|
config = withMapboxAndroid(config, {
|
|
457
457
|
RNMapboxMapsImpl,
|
package/src/RNMBXModule.ts
CHANGED
|
@@ -26,9 +26,16 @@ interface RNMBXModule {
|
|
|
26
26
|
TileServers: {
|
|
27
27
|
Mapbox: string;
|
|
28
28
|
};
|
|
29
|
-
|
|
30
29
|
removeCustomHeader(headerName: string): void;
|
|
31
|
-
addCustomHeader(
|
|
30
|
+
addCustomHeader(
|
|
31
|
+
headerName: string,
|
|
32
|
+
headerValue: string
|
|
33
|
+
): void;
|
|
34
|
+
addCustomHeaderWithOptions(
|
|
35
|
+
headerName: string,
|
|
36
|
+
headerValue: string,
|
|
37
|
+
options: { urlRegexp?: string },
|
|
38
|
+
): void;
|
|
32
39
|
setAccessToken(accessToken: string | null): Promise<string | null>;
|
|
33
40
|
setWellKnownTileServer(tileServer: string): void;
|
|
34
41
|
clearData(): Promise<void>;
|
|
@@ -51,6 +58,24 @@ if (NativeModules.RNMBXModule == null) {
|
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Add a custom header to HTTP requests.
|
|
63
|
+
* @param headerName - The name of the header
|
|
64
|
+
* @param headerValue - The value of the header
|
|
65
|
+
* @param options - Optional configuration. If provided with urlRegexp, the header will only be added to URLs matching the regex
|
|
66
|
+
*/
|
|
67
|
+
function addCustomHeader(
|
|
68
|
+
headerName: string,
|
|
69
|
+
headerValue: string,
|
|
70
|
+
options?: { urlRegexp?: string },
|
|
71
|
+
): void {
|
|
72
|
+
if (options) {
|
|
73
|
+
RNMBXModule.addCustomHeaderWithOptions(headerName, headerValue, options);
|
|
74
|
+
} else {
|
|
75
|
+
RNMBXModule.addCustomHeader(headerName, headerValue);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
54
79
|
export const {
|
|
55
80
|
StyleURL,
|
|
56
81
|
OfflinePackDownloadState,
|
|
@@ -58,7 +83,6 @@ export const {
|
|
|
58
83
|
StyleSource,
|
|
59
84
|
TileServers,
|
|
60
85
|
removeCustomHeader,
|
|
61
|
-
addCustomHeader,
|
|
62
86
|
setAccessToken,
|
|
63
87
|
setWellKnownTileServer,
|
|
64
88
|
clearData,
|
|
@@ -66,3 +90,5 @@ export const {
|
|
|
66
90
|
setTelemetryEnabled,
|
|
67
91
|
setConnected,
|
|
68
92
|
} = RNMBXModule;
|
|
93
|
+
|
|
94
|
+
export { addCustomHeader };
|