@rnmapbox/maps 10.0.11 → 10.0.12-rc.1
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.
|
@@ -42,6 +42,126 @@ protocol LocationProviderRCTMGLDelegate : AnyObject {
|
|
|
42
42
|
func locationManager(_ locationManager: LocationProviderRCTMGL, didUpdateLocation: RCTMGLLocation)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
class RCTMGLAppleLocationProvider: NSObject {
|
|
46
|
+
private var locationProvider: CLLocationManager
|
|
47
|
+
private var privateLocationProviderOptions: LocationOptions {
|
|
48
|
+
didSet {
|
|
49
|
+
locationProvider.distanceFilter = privateLocationProviderOptions.distanceFilter
|
|
50
|
+
locationProvider.desiredAccuracy = privateLocationProviderOptions.desiredAccuracy
|
|
51
|
+
locationProvider.activityType = privateLocationProviderOptions.activityType
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
private weak var delegate: LocationProviderDelegate?
|
|
55
|
+
|
|
56
|
+
public var headingOrientation: CLDeviceOrientation {
|
|
57
|
+
didSet { locationProvider.headingOrientation = headingOrientation }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public override init() {
|
|
61
|
+
locationProvider = CLLocationManager()
|
|
62
|
+
privateLocationProviderOptions = LocationOptions()
|
|
63
|
+
headingOrientation = locationProvider.headingOrientation
|
|
64
|
+
super.init()
|
|
65
|
+
locationProvider.delegate = self
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
extension RCTMGLAppleLocationProvider: LocationProvider {
|
|
70
|
+
|
|
71
|
+
public var locationProviderOptions: LocationOptions {
|
|
72
|
+
get { privateLocationProviderOptions }
|
|
73
|
+
set { privateLocationProviderOptions = newValue }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public var authorizationStatus: CLAuthorizationStatus {
|
|
77
|
+
if #available(iOS 14.0, *) {
|
|
78
|
+
return locationProvider.authorizationStatus
|
|
79
|
+
} else {
|
|
80
|
+
return CLLocationManager.authorizationStatus()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public var accuracyAuthorization: CLAccuracyAuthorization {
|
|
85
|
+
if #available(iOS 14.0, *) {
|
|
86
|
+
return locationProvider.accuracyAuthorization
|
|
87
|
+
} else {
|
|
88
|
+
return .fullAccuracy
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public var heading: CLHeading? {
|
|
93
|
+
return locationProvider.heading
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public func setDelegate(_ delegate: LocationProviderDelegate) {
|
|
97
|
+
self.delegate = delegate
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public func requestAlwaysAuthorization() {
|
|
101
|
+
locationProvider.requestAlwaysAuthorization()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public func requestWhenInUseAuthorization() {
|
|
105
|
+
locationProvider.requestWhenInUseAuthorization()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@available(iOS 14.0, *)
|
|
109
|
+
public func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String) {
|
|
110
|
+
locationProvider.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public func startUpdatingLocation() {
|
|
114
|
+
locationProvider.startUpdatingLocation()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public func stopUpdatingLocation() {
|
|
118
|
+
locationProvider.stopUpdatingLocation()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public func startUpdatingHeading() {
|
|
122
|
+
locationProvider.startUpdatingHeading()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public func stopUpdatingHeading() {
|
|
126
|
+
locationProvider.stopUpdatingHeading()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public func dismissHeadingCalibrationDisplay() {
|
|
130
|
+
locationProvider.dismissHeadingCalibrationDisplay()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
extension RCTMGLAppleLocationProvider: CLLocationManagerDelegate {
|
|
135
|
+
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
|
136
|
+
delegate?.locationProvider(self, didUpdateLocations: locations)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public func locationManager(_ manager: CLLocationManager, didUpdateHeading heading: CLHeading) {
|
|
140
|
+
delegate?.locationProvider(self, didUpdateHeading: heading)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
|
|
144
|
+
delegate?.locationProvider(self, didFailWithError: error)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@available(iOS 14.0, *)
|
|
148
|
+
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
|
|
149
|
+
delegate?.locationProviderDidChangeAuthorization(self)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool {
|
|
153
|
+
guard let calibratingDelegate = delegate as? CalibratingLocationProviderDelegate else {
|
|
154
|
+
return false
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return calibratingDelegate.locationProviderShouldDisplayHeadingCalibration(self)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
internal protocol CalibratingLocationProviderDelegate: LocationProviderDelegate {
|
|
162
|
+
func locationProviderShouldDisplayHeadingCalibration(_ locationProvider: LocationProvider) -> Bool
|
|
163
|
+
}
|
|
164
|
+
|
|
45
165
|
/// LocationProviderRCTMGL listens to updates from a locationProvider and implements the LocationProvider interface itself
|
|
46
166
|
/// So it can be source of Mapbox locationProduces (which updates location pluck and viewport if configured) as well as source to updates
|
|
47
167
|
/// to RCTMGLLocationModules.
|
|
@@ -84,7 +204,7 @@ class LocationProviderRCTMGL : LocationProviderDelegate {
|
|
|
84
204
|
}
|
|
85
205
|
|
|
86
206
|
init() {
|
|
87
|
-
provider =
|
|
207
|
+
provider = RCTMGLAppleLocationProvider()
|
|
88
208
|
provider.setDelegate(self)
|
|
89
209
|
}
|
|
90
210
|
|
|
@@ -222,6 +342,17 @@ extension LocationProviderRCTMGL: LocationProvider {
|
|
|
222
342
|
func setDelegate(_ delegate: LocationProviderDelegate) {
|
|
223
343
|
provider.setDelegate(self)
|
|
224
344
|
locationProviderDelage = delegate
|
|
345
|
+
|
|
346
|
+
if let lastLocation = lastKnownLocation {
|
|
347
|
+
DispatchQueue.main.async {
|
|
348
|
+
self.locationProviderDelage?.locationProvider(self, didUpdateLocations: [lastLocation])
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if let lastHeading = lastKnownHeading {
|
|
352
|
+
DispatchQueue.main.async { [self] in
|
|
353
|
+
self.locationProviderDelage?.locationProvider(self, didUpdateHeading: lastHeading)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
225
356
|
}
|
|
226
357
|
|
|
227
358
|
func requestAlwaysAuthorization() {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigPlugin
|
|
1
|
+
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
declare type InstallerBlockName = 'pre' | 'post';
|
|
3
3
|
export declare type MapboxPlugProps = {
|
|
4
4
|
RNMapboxMapsImpl?: string;
|
|
@@ -12,11 +12,6 @@ export declare const addInstallerBlock: (src: string, blockName: InstallerBlockN
|
|
|
12
12
|
export declare const addConstantBlock: (src: string, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, }: MapboxPlugProps) => string;
|
|
13
13
|
export declare const applyCocoaPodsModifications: (contents: string, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, }: MapboxPlugProps) => string;
|
|
14
14
|
export declare const addMapboxInstallerBlock: (src: string, blockName: InstallerBlockName) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
17
|
-
* Without this, production builds targeting simulators will fail.
|
|
18
|
-
*/
|
|
19
|
-
export declare const setExcludedArchitectures: (project: XcodeProject) => XcodeProject;
|
|
20
15
|
export declare const addMapboxMavenRepo: (src: string) => string;
|
|
21
16
|
declare const _default: ConfigPlugin<MapboxPlugProps>;
|
|
22
17
|
export default _default;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._addMapboxMavenRepo = exports.addMapboxMavenRepo = exports.
|
|
6
|
+
exports._addMapboxMavenRepo = exports.addMapboxMavenRepo = exports.addMapboxInstallerBlock = exports.applyCocoaPodsModifications = exports.addConstantBlock = exports.addInstallerBlock = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const config_plugins_1 = require("expo/config-plugins");
|
|
@@ -119,26 +119,6 @@ const withCocoaPodsInstallerBlocks = (config, { RNMapboxMapsImpl, RNMapboxMapsVe
|
|
|
119
119
|
return exportedConfig;
|
|
120
120
|
},
|
|
121
121
|
]);
|
|
122
|
-
/**
|
|
123
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
124
|
-
* Without this, production builds targeting simulators will fail.
|
|
125
|
-
*/
|
|
126
|
-
const setExcludedArchitectures = (project) => {
|
|
127
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
128
|
-
for (const { buildSettings } of Object.values(configurations || {})) {
|
|
129
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
130
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
131
|
-
if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {
|
|
132
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return project;
|
|
136
|
-
};
|
|
137
|
-
exports.setExcludedArchitectures = setExcludedArchitectures;
|
|
138
|
-
const withExcludedSimulatorArchitectures = (config) => (0, config_plugins_1.withXcodeProject)(config, (exportedConfig) => {
|
|
139
|
-
exportedConfig.modResults = (0, exports.setExcludedArchitectures)(exportedConfig.modResults);
|
|
140
|
-
return exportedConfig;
|
|
141
|
-
});
|
|
142
122
|
const withAndroidPropertiesDownloadToken = (config, { RNMapboxMapsDownloadToken }) => {
|
|
143
123
|
const key = 'MAPBOX_DOWNLOADS_TOKEN';
|
|
144
124
|
if (RNMapboxMapsDownloadToken) {
|
|
@@ -269,7 +249,6 @@ const withMapboxAndroid = (config, { RNMapboxMapsImpl, RNMapboxMapsDownloadToken
|
|
|
269
249
|
return config;
|
|
270
250
|
};
|
|
271
251
|
const withMapbox = (config, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken }) => {
|
|
272
|
-
config = withExcludedSimulatorArchitectures(config);
|
|
273
252
|
config = withMapboxAndroid(config, {
|
|
274
253
|
RNMapboxMapsImpl,
|
|
275
254
|
RNMapboxMapsVersion,
|
package/plugin/src/withMapbox.ts
CHANGED
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
ConfigPlugin,
|
|
6
6
|
createRunOncePlugin,
|
|
7
7
|
withDangerousMod,
|
|
8
|
-
withXcodeProject,
|
|
9
|
-
XcodeProject,
|
|
10
8
|
withGradleProperties,
|
|
11
9
|
WarningAggregator,
|
|
12
10
|
withProjectBuildGradle,
|
|
@@ -185,35 +183,6 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
|
|
|
185
183
|
},
|
|
186
184
|
]);
|
|
187
185
|
|
|
188
|
-
/**
|
|
189
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
190
|
-
* Without this, production builds targeting simulators will fail.
|
|
191
|
-
*/
|
|
192
|
-
export const setExcludedArchitectures: (
|
|
193
|
-
project: XcodeProject,
|
|
194
|
-
) => XcodeProject = (project: XcodeProject): XcodeProject => {
|
|
195
|
-
const configurations: { buildSettings: Record<string, string> }[] =
|
|
196
|
-
project.pbxXCBuildConfigurationSection();
|
|
197
|
-
for (const { buildSettings } of Object.values(configurations || {})) {
|
|
198
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
199
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
200
|
-
if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {
|
|
201
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return project;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const withExcludedSimulatorArchitectures: ConfigPlugin = (config) =>
|
|
209
|
-
withXcodeProject(config, (exportedConfig) => {
|
|
210
|
-
exportedConfig.modResults = setExcludedArchitectures(
|
|
211
|
-
exportedConfig.modResults,
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
return exportedConfig;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
186
|
const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
|
|
218
187
|
config,
|
|
219
188
|
{ RNMapboxMapsDownloadToken },
|
|
@@ -408,7 +377,6 @@ const withMapbox: ConfigPlugin<MapboxPlugProps> = (
|
|
|
408
377
|
config,
|
|
409
378
|
{ RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken },
|
|
410
379
|
) => {
|
|
411
|
-
config = withExcludedSimulatorArchitectures(config);
|
|
412
380
|
config = withMapboxAndroid(config, {
|
|
413
381
|
RNMapboxMapsImpl,
|
|
414
382
|
RNMapboxMapsVersion,
|