@maplibre/maplibre-react-native 10.0.0-beta.15 → 10.0.0-beta.17
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 +2 -2
- package/android/build.gradle +29 -6
- package/android/gradle.properties +11 -6
- package/android/src/main/java/org/maplibre/reactnative/location/LocationManager.java +7 -11
- package/android/src/main/java/org/maplibre/reactnative/location/engine/DefaultLocationEngineProvider.java +18 -0
- package/android/src/main/java/org/maplibre/reactnative/location/engine/LocationEngineProvidable.java +9 -0
- package/android/src/main/location-engine-default/org/maplibre/reactnative/location/engine/LocationEngineProvider.java +12 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/GoogleLocationEngineImpl.java +151 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/GoogleLocationEngineProvider.java +24 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/LocationEngineProvider.java +12 -0
- package/lib/commonjs/plugin/ios.js +97 -0
- package/lib/commonjs/plugin/ios.js.map +1 -0
- package/lib/commonjs/plugin/withMapLibre.js +7 -130
- package/lib/commonjs/plugin/withMapLibre.js.map +1 -1
- package/lib/module/plugin/ios.js +93 -0
- package/lib/module/plugin/ios.js.map +1 -0
- package/lib/module/plugin/withMapLibre.js +8 -126
- package/lib/module/plugin/withMapLibre.js.map +1 -1
- package/lib/typescript/commonjs/src/plugin/ios.d.ts +13 -0
- package/lib/typescript/commonjs/src/plugin/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/plugin/withMapLibre.d.ts +1 -10
- package/lib/typescript/commonjs/src/plugin/withMapLibre.d.ts.map +1 -1
- package/lib/typescript/module/src/plugin/ios.d.ts +13 -0
- package/lib/typescript/module/src/plugin/ios.d.ts.map +1 -0
- package/lib/typescript/module/src/plugin/withMapLibre.d.ts +1 -10
- package/lib/typescript/module/src/plugin/withMapLibre.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/plugin/ios.ts +112 -0
- package/src/plugin/withMapLibre.ts +10 -167
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ diverged, it has become necessary to separate the projects into specific wrapper
|
|
|
27
27
|
|
|
28
28
|
## Documentation
|
|
29
29
|
|
|
30
|
-
- [Getting Started](/docs/guides/setup/Getting-Started)
|
|
30
|
+
- [Getting Started](/docs/guides/setup/Getting-Started.md)
|
|
31
31
|
- Installation
|
|
32
32
|
- [Expo](/docs/guides/setup/Expo.md)
|
|
33
33
|
- [React Native](/docs/guides/setup/React-Native.md)
|
|
@@ -80,4 +80,4 @@ set up your local development environment.
|
|
|
80
80
|
|
|
81
81
|
## Community
|
|
82
82
|
|
|
83
|
-
Join the `#maplibre-react-native` or `#maplibre` [
|
|
83
|
+
Join the `#maplibre-react-native` or `#maplibre` [on the Open Street Map Slack](https://slack.openstreetmap.us/).
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["org.maplibre.reactnative.kotlinVersion"]
|
|
4
4
|
|
|
5
5
|
repositories {
|
|
6
6
|
google()
|
|
@@ -32,11 +32,15 @@ apply plugin: "kotlin-android"
|
|
|
32
32
|
// }
|
|
33
33
|
|
|
34
34
|
def getExtOrDefault(name) {
|
|
35
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["org.maplibre.reactnative." + name]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
def getConfigurableExtOrDefault(name) {
|
|
39
|
+
return rootProject.ext.has("org.maplibre.reactnative." + name) ? rootProject.ext.get("org.maplibre.reactnative." + name) : project.properties["org.maplibre.reactnative." + name]
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
def getExtOrIntegerDefault(name) {
|
|
39
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["
|
|
43
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["org.maplibre.reactnative." + name]).toInteger()
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
def supportsNamespace() {
|
|
@@ -68,6 +72,20 @@ android {
|
|
|
68
72
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
sourceSets {
|
|
76
|
+
main {
|
|
77
|
+
java.srcDirs = ['src/main/java']
|
|
78
|
+
|
|
79
|
+
if (getConfigurableExtOrDefault("locationEngine") == "default") {
|
|
80
|
+
java.srcDirs += 'src/main/location-engine-default'
|
|
81
|
+
} else if (getConfigurableExtOrDefault("locationEngine") == "google") {
|
|
82
|
+
java.srcDirs += 'src/main/location-engine-google'
|
|
83
|
+
} else {
|
|
84
|
+
throw new GradleException("org.maplibre.reactnative.locationEngine.locationEngine should be one of [\"default\", \"google\"]`. \"${getConfigurableExtOrDefault("locationEngine")}\" was provided.")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
71
89
|
buildTypes {
|
|
72
90
|
release {
|
|
73
91
|
minifyEnabled false
|
|
@@ -106,11 +124,16 @@ dependencies {
|
|
|
106
124
|
implementation "androidx.vectordrawable:vectordrawable:1.1.0"
|
|
107
125
|
implementation "androidx.annotation:annotation:1.7.0"
|
|
108
126
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
|
109
|
-
implementation "com.squareup.okhttp3:okhttp:${
|
|
110
|
-
implementation "com.squareup.okhttp3:okhttp-urlconnection:${
|
|
127
|
+
implementation "com.squareup.okhttp3:okhttp:${getConfigurableExtOrDefault('okhttpVersion')}"
|
|
128
|
+
implementation "com.squareup.okhttp3:okhttp-urlconnection:${getConfigurableExtOrDefault('okhttpVersion')}"
|
|
111
129
|
|
|
112
|
-
// MapLibre
|
|
130
|
+
// MapLibre Plugins
|
|
113
131
|
implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.1")
|
|
114
132
|
implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.1")
|
|
115
133
|
implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.1")
|
|
134
|
+
|
|
135
|
+
// Dependencies for Google Location Engine
|
|
136
|
+
if (getConfigurableExtOrDefault("locationEngine") == "google") {
|
|
137
|
+
implementation "com.google.android.gms:play-services-location:21.3.0"
|
|
138
|
+
}
|
|
116
139
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
org.maplibre.reactnative.kotlinVersion=1.7.0
|
|
2
|
+
org.maplibre.reactnative.minSdkVersion=21
|
|
3
|
+
org.maplibre.reactnative.targetSdkVersion=31
|
|
4
|
+
org.maplibre.reactnative.compileSdkVersion=31
|
|
5
|
+
org.maplibre.reactnative.ndkVersion=21.4.7075529
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# MapLibre React Native Customizations
|
|
8
|
+
|
|
9
|
+
org.maplibre.reactnative.okhttpVersion=4.9.0
|
|
10
|
+
|
|
11
|
+
# Available values: default, google
|
|
12
|
+
org.maplibre.reactnative.locationEngine=default
|
|
@@ -7,21 +7,14 @@ import android.util.Log;
|
|
|
7
7
|
|
|
8
8
|
import org.maplibre.android.location.engine.LocationEngine;
|
|
9
9
|
import org.maplibre.android.location.engine.LocationEngineCallback;
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
import com.mapbox.android.core.location.LocationEngineListener;
|
|
13
|
-
import com.mapbox.android.core.location.LocationEnginePriority;
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import org.maplibre.android.location.engine.LocationEngineDefault;
|
|
17
10
|
import org.maplibre.android.location.engine.LocationEngineRequest;
|
|
18
11
|
import org.maplibre.android.location.engine.LocationEngineResult;
|
|
19
12
|
import org.maplibre.android.location.permissions.PermissionsManager;
|
|
13
|
+
import org.maplibre.reactnative.location.engine.LocationEngineProvider;
|
|
20
14
|
|
|
21
15
|
import java.lang.ref.WeakReference;
|
|
22
16
|
import java.util.ArrayList;
|
|
23
17
|
import java.util.List;
|
|
24
|
-
import java.util.Locale;
|
|
25
18
|
|
|
26
19
|
@SuppressWarnings({"MissingPermission"})
|
|
27
20
|
public class LocationManager implements LocationEngineCallback<LocationEngineResult> {
|
|
@@ -58,8 +51,10 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
58
51
|
this.buildEngineRequest();
|
|
59
52
|
|
|
60
53
|
}
|
|
54
|
+
|
|
61
55
|
private void buildEngineRequest() {
|
|
62
|
-
locationEngine =
|
|
56
|
+
locationEngine = new LocationEngineProvider().getLocationEngine(context);
|
|
57
|
+
|
|
63
58
|
locationEngineRequest = new LocationEngineRequest.Builder(DEFAULT_INTERVAL_MILLIS)
|
|
64
59
|
.setFastestInterval(DEFAULT_FASTEST_INTERVAL_MILLIS)
|
|
65
60
|
.setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)
|
|
@@ -78,9 +73,11 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
78
73
|
listeners.remove(listener);
|
|
79
74
|
}
|
|
80
75
|
}
|
|
76
|
+
|
|
81
77
|
public void setMinDisplacement(float minDisplacement) {
|
|
82
78
|
mMinDisplacement = minDisplacement;
|
|
83
79
|
}
|
|
80
|
+
|
|
84
81
|
public void enable() {
|
|
85
82
|
if (!PermissionsManager.areLocationPermissionsGranted(context)) {
|
|
86
83
|
return;
|
|
@@ -134,8 +131,7 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
134
131
|
|
|
135
132
|
try {
|
|
136
133
|
locationEngine.getLastLocation(callback);
|
|
137
|
-
}
|
|
138
|
-
catch(Exception exception) {
|
|
134
|
+
} catch (Exception exception) {
|
|
139
135
|
Log.w(LOG_TAG, exception);
|
|
140
136
|
callback.onFailure(exception);
|
|
141
137
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
7
|
+
import org.maplibre.android.location.engine.LocationEngineDefault;
|
|
8
|
+
|
|
9
|
+
public class DefaultLocationEngineProvider implements LocationEngineProvidable {
|
|
10
|
+
private static final String LOG_TAG = "DefaultLocationEngineProvider";
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
14
|
+
LocationEngine locationEngine = LocationEngineDefault.INSTANCE.getDefaultLocationEngine(context.getApplicationContext());
|
|
15
|
+
Log.d(LOG_TAG, "DefaultLocationEngine will be used.");
|
|
16
|
+
return locationEngine;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
6
|
+
|
|
7
|
+
public class LocationEngineProvider implements LocationEngineProvidable {
|
|
8
|
+
@Override
|
|
9
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
10
|
+
return new DefaultLocationEngineProvider().getLocationEngine(context);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
4
|
+
import android.app.PendingIntent;
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.location.Location;
|
|
7
|
+
import android.os.Looper;
|
|
8
|
+
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
10
|
+
import androidx.annotation.Nullable;
|
|
11
|
+
import androidx.annotation.VisibleForTesting;
|
|
12
|
+
|
|
13
|
+
import com.google.android.gms.location.FusedLocationProviderClient;
|
|
14
|
+
import com.google.android.gms.location.LocationCallback;
|
|
15
|
+
import com.google.android.gms.location.LocationRequest;
|
|
16
|
+
import com.google.android.gms.location.LocationResult;
|
|
17
|
+
import com.google.android.gms.location.LocationServices;
|
|
18
|
+
import com.google.android.gms.location.Priority;
|
|
19
|
+
import com.google.android.gms.tasks.OnFailureListener;
|
|
20
|
+
import com.google.android.gms.tasks.OnSuccessListener;
|
|
21
|
+
|
|
22
|
+
import org.maplibre.android.location.engine.LocationEngineCallback;
|
|
23
|
+
import org.maplibre.android.location.engine.LocationEngineImpl;
|
|
24
|
+
import org.maplibre.android.location.engine.LocationEngineRequest;
|
|
25
|
+
import org.maplibre.android.location.engine.LocationEngineResult;
|
|
26
|
+
|
|
27
|
+
import java.util.Collections;
|
|
28
|
+
import java.util.List;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Wraps implementation of Fused Location Provider
|
|
32
|
+
*/
|
|
33
|
+
public class GoogleLocationEngineImpl implements LocationEngineImpl<LocationCallback> {
|
|
34
|
+
private final FusedLocationProviderClient fusedLocationProviderClient;
|
|
35
|
+
|
|
36
|
+
@VisibleForTesting
|
|
37
|
+
GoogleLocationEngineImpl(FusedLocationProviderClient fusedLocationProviderClient) {
|
|
38
|
+
this.fusedLocationProviderClient = fusedLocationProviderClient;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public GoogleLocationEngineImpl(@NonNull Context context) {
|
|
42
|
+
this.fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@NonNull
|
|
46
|
+
@Override
|
|
47
|
+
public LocationCallback createListener(LocationEngineCallback<LocationEngineResult> callback) {
|
|
48
|
+
return new GoogleLocationEngineCallbackTransport(callback);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@SuppressLint("MissingPermission")
|
|
52
|
+
@Override
|
|
53
|
+
public void getLastLocation(@NonNull LocationEngineCallback<LocationEngineResult> callback)
|
|
54
|
+
throws SecurityException {
|
|
55
|
+
GoogleLastLocationEngineCallbackTransport transport =
|
|
56
|
+
new GoogleLastLocationEngineCallbackTransport(callback);
|
|
57
|
+
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(transport).addOnFailureListener(transport);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@SuppressLint("MissingPermission")
|
|
61
|
+
@Override
|
|
62
|
+
public void requestLocationUpdates(@NonNull LocationEngineRequest request,
|
|
63
|
+
@NonNull LocationCallback listener,
|
|
64
|
+
@Nullable Looper looper) throws SecurityException {
|
|
65
|
+
fusedLocationProviderClient.requestLocationUpdates(toGMSLocationRequest(request), listener, looper);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@SuppressLint("MissingPermission")
|
|
69
|
+
@Override
|
|
70
|
+
public void requestLocationUpdates(@NonNull LocationEngineRequest request,
|
|
71
|
+
@NonNull PendingIntent pendingIntent) throws SecurityException {
|
|
72
|
+
fusedLocationProviderClient.requestLocationUpdates(toGMSLocationRequest(request), pendingIntent);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Override
|
|
76
|
+
public void removeLocationUpdates(@NonNull LocationCallback listener) {
|
|
77
|
+
if (listener != null) {
|
|
78
|
+
fusedLocationProviderClient.removeLocationUpdates(listener);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public void removeLocationUpdates(PendingIntent pendingIntent) {
|
|
84
|
+
if (pendingIntent != null) {
|
|
85
|
+
fusedLocationProviderClient.removeLocationUpdates(pendingIntent);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static LocationRequest toGMSLocationRequest(LocationEngineRequest request) {
|
|
90
|
+
LocationRequest.Builder builder = new LocationRequest.Builder(request.getInterval());
|
|
91
|
+
builder.setMinUpdateIntervalMillis(request.getFastestInterval());
|
|
92
|
+
builder.setMinUpdateDistanceMeters(request.getDisplacement());
|
|
93
|
+
builder.setMaxUpdateDelayMillis(request.getMaxWaitTime());
|
|
94
|
+
builder.setPriority(toGMSLocationPriority(request.getPriority()));
|
|
95
|
+
return builder.build();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private static int toGMSLocationPriority(int enginePriority) {
|
|
99
|
+
switch (enginePriority) {
|
|
100
|
+
case LocationEngineRequest.PRIORITY_HIGH_ACCURACY:
|
|
101
|
+
return Priority.PRIORITY_HIGH_ACCURACY;
|
|
102
|
+
case LocationEngineRequest.PRIORITY_BALANCED_POWER_ACCURACY:
|
|
103
|
+
return Priority.PRIORITY_BALANCED_POWER_ACCURACY;
|
|
104
|
+
case LocationEngineRequest.PRIORITY_LOW_POWER:
|
|
105
|
+
return Priority.PRIORITY_LOW_POWER;
|
|
106
|
+
case LocationEngineRequest.PRIORITY_NO_POWER:
|
|
107
|
+
default:
|
|
108
|
+
return Priority.PRIORITY_PASSIVE;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private static final class GoogleLocationEngineCallbackTransport extends LocationCallback {
|
|
113
|
+
private final LocationEngineCallback<LocationEngineResult> callback;
|
|
114
|
+
|
|
115
|
+
GoogleLocationEngineCallbackTransport(LocationEngineCallback<LocationEngineResult> callback) {
|
|
116
|
+
this.callback = callback;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Override
|
|
120
|
+
public void onLocationResult(LocationResult locationResult) {
|
|
121
|
+
super.onLocationResult(locationResult);
|
|
122
|
+
List<Location> locations = locationResult.getLocations();
|
|
123
|
+
if (!locations.isEmpty()) {
|
|
124
|
+
callback.onSuccess(LocationEngineResult.create(locations));
|
|
125
|
+
} else {
|
|
126
|
+
callback.onFailure(new Exception("Unavailable location"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@VisibleForTesting
|
|
132
|
+
static final class GoogleLastLocationEngineCallbackTransport
|
|
133
|
+
implements OnSuccessListener<Location>, OnFailureListener {
|
|
134
|
+
private final LocationEngineCallback<LocationEngineResult> callback;
|
|
135
|
+
|
|
136
|
+
GoogleLastLocationEngineCallbackTransport(LocationEngineCallback<LocationEngineResult> callback) {
|
|
137
|
+
this.callback = callback;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Override
|
|
141
|
+
public void onSuccess(Location location) {
|
|
142
|
+
callback.onSuccess(location != null ? LocationEngineResult.create(location) :
|
|
143
|
+
LocationEngineResult.create(Collections.<Location>emptyList()));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@Override
|
|
147
|
+
public void onFailure(@NonNull Exception e) {
|
|
148
|
+
callback.onFailure(e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.google.android.gms.common.ConnectionResult;
|
|
7
|
+
import com.google.android.gms.common.GoogleApiAvailability;
|
|
8
|
+
|
|
9
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
10
|
+
import org.maplibre.android.location.engine.LocationEngineProxy;
|
|
11
|
+
|
|
12
|
+
public class GoogleLocationEngineProvider implements LocationEngineProvidable {
|
|
13
|
+
private static final String LOG_TAG = "GoogleLocationEngineProvider";
|
|
14
|
+
|
|
15
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
16
|
+
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS) {
|
|
17
|
+
LocationEngine locationEngine = new LocationEngineProxy<>(new GoogleLocationEngineImpl(context.getApplicationContext()));
|
|
18
|
+
Log.d(LOG_TAG, "GoogleLocationEngine will be used.");
|
|
19
|
+
return locationEngine;
|
|
20
|
+
} else {
|
|
21
|
+
return new DefaultLocationEngineProvider().getLocationEngine(context);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
6
|
+
|
|
7
|
+
public class LocationEngineProvider implements LocationEngineProvidable {
|
|
8
|
+
@Override
|
|
9
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
10
|
+
return new GoogleLocationEngineProvider().getLocationEngine(context);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyPodfilePostInstall = applyPodfilePostInstall;
|
|
7
|
+
exports.ios = void 0;
|
|
8
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
9
|
+
var _generateCode = require("@expo/config-plugins/build/utils/generateCode");
|
|
10
|
+
/**
|
|
11
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
12
|
+
* doesn't currently support.
|
|
13
|
+
*/
|
|
14
|
+
function applyPodfilePostInstall(contents) {
|
|
15
|
+
const result = (0, _generateCode.mergeContents)({
|
|
16
|
+
tag: `@maplibre/maplibre-react-native-post_installer`,
|
|
17
|
+
src: contents,
|
|
18
|
+
newSrc: ` $MLRN.post_install(installer)`,
|
|
19
|
+
anchor: new RegExp(`post_install do \\|installer\\|`),
|
|
20
|
+
offset: 1,
|
|
21
|
+
comment: "#"
|
|
22
|
+
});
|
|
23
|
+
if (result.didMerge || result.didClear) {
|
|
24
|
+
return result.contents;
|
|
25
|
+
}
|
|
26
|
+
return contents;
|
|
27
|
+
}
|
|
28
|
+
const withPodfilePostInstall = config => {
|
|
29
|
+
return (0, _configPlugins.withPodfile)(config, c => {
|
|
30
|
+
c.modResults.contents = applyPodfilePostInstall(c.modResults.contents);
|
|
31
|
+
return c;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
37
|
+
* Without this, production builds targeting simulators will fail.
|
|
38
|
+
*/
|
|
39
|
+
function setExcludedArchitectures(project) {
|
|
40
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
for (const {
|
|
44
|
+
name,
|
|
45
|
+
buildSettings
|
|
46
|
+
} of Object.values(configurations || {})) {
|
|
47
|
+
// Guessing that this is the best way to emulate Xcode.
|
|
48
|
+
// Using `project.addToBuildSettings` modifies too many targets.
|
|
49
|
+
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
50
|
+
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return project;
|
|
54
|
+
}
|
|
55
|
+
const withoutSignatures = config => {
|
|
56
|
+
return (0, _configPlugins.withXcodeProject)(config, async c => {
|
|
57
|
+
c.modResults.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
58
|
+
shellPath: "/bin/sh",
|
|
59
|
+
shellScript: `
|
|
60
|
+
echo "Remove signature files (Xcode workaround)";
|
|
61
|
+
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
62
|
+
`
|
|
63
|
+
});
|
|
64
|
+
return c;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
70
|
+
* https://github.com/expo/eas-cli/issues/968
|
|
71
|
+
*
|
|
72
|
+
* Set `artifactPath` in `eas.json`:
|
|
73
|
+
* ```json
|
|
74
|
+
* "ios": {
|
|
75
|
+
* "artifactPath": "ios/build/*"
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
const withDwarfDsym = config => {
|
|
80
|
+
return (0, _configPlugins.withXcodeProject)(config, async c => {
|
|
81
|
+
c.modResults.debugInformationFormat = "dwarf-with-dsym";
|
|
82
|
+
return c;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const withExcludedSimulatorArchitectures = config => {
|
|
86
|
+
return (0, _configPlugins.withXcodeProject)(config, c => {
|
|
87
|
+
c.modResults = setExcludedArchitectures(c.modResults);
|
|
88
|
+
return c;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const ios = exports.ios = {
|
|
92
|
+
withPodfilePostInstall,
|
|
93
|
+
withoutSignatures,
|
|
94
|
+
withDwarfDsym,
|
|
95
|
+
withExcludedSimulatorArchitectures
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_generateCode","applyPodfilePostInstall","contents","result","mergeContents","tag","src","newSrc","anchor","RegExp","offset","comment","didMerge","didClear","withPodfilePostInstall","config","withPodfile","c","modResults","setExcludedArchitectures","project","configurations","pbxXCBuildConfigurationSection","name","buildSettings","Object","values","PRODUCT_NAME","withoutSignatures","withXcodeProject","addBuildPhase","shellPath","shellScript","withDwarfDsym","debugInformationFormat","withExcludedSimulatorArchitectures","ios","exports"],"sourceRoot":"../../../src","sources":["plugin/ios.ts"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,aAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASE,uBAAuBA,CAACC,QAAgB,EAAU;EAChE,MAAMC,MAAM,GAAG,IAAAC,2BAAa,EAAC;IAC3BC,GAAG,EAAE,gDAAgD;IACrDC,GAAG,EAAEJ,QAAQ;IACbK,MAAM,EAAE,mCAAmC;IAC3CC,MAAM,EAAE,IAAIC,MAAM,CAAC,iCAAiC,CAAC;IACrDC,MAAM,EAAE,CAAC;IACTC,OAAO,EAAE;EACX,CAAC,CAAC;EAEF,IAAIR,MAAM,CAACS,QAAQ,IAAIT,MAAM,CAACU,QAAQ,EAAE;IACtC,OAAOV,MAAM,CAACD,QAAQ;EACxB;EAEA,OAAOA,QAAQ;AACjB;AAEA,MAAMY,sBAAoC,GAAIC,MAAM,IAAK;EACvD,OAAO,IAAAC,0BAAW,EAACD,MAAM,EAAGE,CAAC,IAAK;IAChCA,CAAC,CAACC,UAAU,CAAChB,QAAQ,GAAGD,uBAAuB,CAACgB,CAAC,CAACC,UAAU,CAAChB,QAAQ,CAAC;IAEtE,OAAOe,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASE,wBAAwBA,CAACC,OAAqB,EAAgB;EACrE,MAAMC,cAAc,GAAGD,OAAO,CAACE,8BAA8B,CAAC,CAAC;EAC/D;EACA;EACA,KAAK,MAAM;IAAEC,IAAI;IAAEC;EAAc,CAAC,IAAIC,MAAM,CAACC,MAAM,CAACL,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE;IACzE;IACA;IACA,IACEE,IAAI,KAAK,SAAS,IAClB,OAAOC,aAAa,EAAEG,YAAY,KAAK,WAAW,EAClD;MACAH,aAAa,CAAC,wCAAwC,CAAC,GAAG,SAAS;IACrE;EACF;EAEA,OAAOJ,OAAO;AAChB;AAEA,MAAMQ,iBAA+B,GAAIb,MAAM,IAAK;EAClD,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAE,MAAOE,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACY,aAAa,CACxB,EAAE,EACF,0BAA0B,EAC1B,2CAA2C,EAC3C,IAAI,EACJ;MACEC,SAAS,EAAE,SAAS;MACpBC,WAAW,EAAE;AACrB;AACA;AACA;IACM,CACF,CAAC;IAED,OAAOf,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMgB,aAA2B,GAAIlB,MAAM,IAAK;EAC9C,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAE,MAAOE,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACgB,sBAAsB,GAAG,iBAAiB;IAEvD,OAAOjB,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAED,MAAMkB,kCAAgD,GAAIpB,MAAM,IAAK;EACnE,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAGE,CAAC,IAAK;IACrCA,CAAC,CAACC,UAAU,GAAGC,wBAAwB,CAACF,CAAC,CAACC,UAAU,CAAC;IAErD,OAAOD,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAEM,MAAMmB,GAAG,GAAAC,OAAA,CAAAD,GAAA,GAAG;EACjBtB,sBAAsB;EACtBc,iBAAiB;EACjBK,aAAa;EACbE;AACF,CAAC","ignoreList":[]}
|
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.addInstallerBlock = addInstallerBlock;
|
|
7
|
-
exports.addMapLibreInstallerBlock = addMapLibreInstallerBlock;
|
|
8
|
-
exports.applyCocoaPodsModifications = applyCocoaPodsModifications;
|
|
9
6
|
exports.default = void 0;
|
|
10
|
-
exports.setExcludedArchitectures = setExcludedArchitectures;
|
|
11
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
12
|
-
var
|
|
13
|
-
var _nodeFs = require("node:fs");
|
|
14
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
var _ios = require("./ios.js");
|
|
16
9
|
let pkg = {
|
|
17
10
|
name: "@maplibre/maplibre-react-native"
|
|
18
11
|
};
|
|
@@ -21,129 +14,13 @@ try {
|
|
|
21
14
|
} catch {
|
|
22
15
|
// empty catch block
|
|
23
16
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Dangerously adds the custom installer hooks to the Podfile.
|
|
26
|
-
* In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
|
|
27
|
-
*
|
|
28
|
-
* https://github.com/maplibre/maplibre-react-native/blob/main/docs/guides/setup/iOS.md
|
|
29
|
-
*/
|
|
30
|
-
const withCocoaPodsInstallerBlocks = c => {
|
|
31
|
-
return (0, _configPlugins.withDangerousMod)(c, ["ios",
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
33
|
-
async config => {
|
|
34
|
-
const file = _nodePath.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
|
35
|
-
const contents = await _nodeFs.promises.readFile(file, "utf8");
|
|
36
|
-
await _nodeFs.promises.writeFile(file, applyCocoaPodsModifications(contents), "utf-8");
|
|
37
|
-
return config;
|
|
38
|
-
}]);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Only the post-install block is required, the post installer block is
|
|
42
|
-
// used for spm (swift package manager) which Expo doesn't currently support.
|
|
43
|
-
function applyCocoaPodsModifications(contents) {
|
|
44
|
-
// Ensure installer blocks exist
|
|
45
|
-
let src = addInstallerBlock(contents, "post");
|
|
46
|
-
src = addMapLibreInstallerBlock(src, "post");
|
|
47
|
-
return src;
|
|
48
|
-
}
|
|
49
|
-
function addInstallerBlock(src, blockName) {
|
|
50
|
-
const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
|
|
51
|
-
const tag = `${blockName}_installer`;
|
|
52
|
-
for (const line of src.split("\n")) {
|
|
53
|
-
const contents = line.trim();
|
|
54
|
-
// Ignore comments
|
|
55
|
-
if (!contents.startsWith("#")) {
|
|
56
|
-
// Prevent adding the block if it exists outside of comments.
|
|
57
|
-
if (contents.match(matchBlock)) {
|
|
58
|
-
// This helps to still allow revisions, since we enabled the block previously.
|
|
59
|
-
// Only continue if the generated block exists...
|
|
60
|
-
const modified = (0, _generateCode.removeGeneratedContents)(src, tag);
|
|
61
|
-
if (!modified) {
|
|
62
|
-
return src;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return (0, _generateCode.mergeContents)({
|
|
68
|
-
tag,
|
|
69
|
-
src,
|
|
70
|
-
newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"),
|
|
71
|
-
anchor: /use_react_native/,
|
|
72
|
-
// We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
|
|
73
|
-
offset: 0,
|
|
74
|
-
comment: "#"
|
|
75
|
-
}).contents;
|
|
76
|
-
}
|
|
77
|
-
function addMapLibreInstallerBlock(src, blockName) {
|
|
78
|
-
return (0, _generateCode.mergeContents)({
|
|
79
|
-
tag: `@maplibre/maplibre-react-native-${blockName}_installer`,
|
|
80
|
-
src,
|
|
81
|
-
newSrc: ` $MLRN.${blockName}_install(installer)`,
|
|
82
|
-
anchor: new RegExp(`${blockName}_install do \\|installer\\|`),
|
|
83
|
-
offset: 1,
|
|
84
|
-
comment: "#"
|
|
85
|
-
}).contents;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
90
|
-
* Without this, production builds targeting simulators will fail.
|
|
91
|
-
*/
|
|
92
|
-
function setExcludedArchitectures(project) {
|
|
93
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
for (const {
|
|
97
|
-
name,
|
|
98
|
-
buildSettings
|
|
99
|
-
} of Object.values(configurations || {})) {
|
|
100
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
101
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
102
|
-
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
103
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return project;
|
|
107
|
-
}
|
|
108
|
-
const withoutSignatures = config => {
|
|
109
|
-
const shellScript = `
|
|
110
|
-
echo "Remove signature files (Xcode workaround)";
|
|
111
|
-
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
112
|
-
`;
|
|
113
|
-
return (0, _configPlugins.withXcodeProject)(config, async config => {
|
|
114
|
-
const xcodeProject = config.modResults;
|
|
115
|
-
xcodeProject.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
116
|
-
shellPath: "/bin/sh",
|
|
117
|
-
shellScript
|
|
118
|
-
});
|
|
119
|
-
return config;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
125
|
-
* https://github.com/expo/eas-cli/issues/968
|
|
126
|
-
* // Set artifactPath in eas.json
|
|
127
|
-
* "ios": {
|
|
128
|
-
* "artifactPath": "ios/build/*"
|
|
129
|
-
* }
|
|
130
|
-
*/
|
|
131
|
-
const withDwarfDsym = config => {
|
|
132
|
-
return (0, _configPlugins.withXcodeProject)(config, async config => {
|
|
133
|
-
const xcodeProject = config.modResults;
|
|
134
|
-
xcodeProject.debugInformationFormat = "dwarf-with-dsym";
|
|
135
|
-
return config;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
const withExcludedSimulatorArchitectures = c => {
|
|
139
|
-
return (0, _configPlugins.withXcodeProject)(c, config => {
|
|
140
|
-
config.modResults = setExcludedArchitectures(config.modResults);
|
|
141
|
-
return config;
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
17
|
const withMapLibre = config => {
|
|
145
|
-
|
|
146
|
-
|
|
18
|
+
// iOS
|
|
19
|
+
config = _ios.ios.withExcludedSimulatorArchitectures(config);
|
|
20
|
+
config = _ios.ios.withDwarfDsym(config);
|
|
21
|
+
config = _ios.ios.withoutSignatures(config);
|
|
22
|
+
config = _ios.ios.withPodfilePostInstall(config);
|
|
23
|
+
return config;
|
|
147
24
|
};
|
|
148
25
|
var _default = exports.default = (0, _configPlugins.createRunOncePlugin)(withMapLibre, pkg.name, pkg.version);
|
|
149
26
|
//# sourceMappingURL=withMapLibre.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_ios","pkg","name","withMapLibre","config","ios","withExcludedSimulatorArchitectures","withDwarfDsym","withoutSignatures","withPodfilePostInstall","_default","exports","default","createRunOncePlugin","version"],"sourceRoot":"../../../src","sources":["plugin/withMapLibre.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAIE,GAAuC,GAAG;EAC5CC,IAAI,EAAE;AACR,CAAC;AACD,IAAI;EACFD,GAAG,GAAGF,OAAO,CAAC,8CAA8C,CAAC;AAC/D,CAAC,CAAC,MAAM;EACN;AAAA;AAGF,MAAMI,YAA0B,GAAIC,MAAM,IAAK;EAC7C;EACAA,MAAM,GAAGC,QAAG,CAACC,kCAAkC,CAACF,MAAM,CAAC;EACvDA,MAAM,GAAGC,QAAG,CAACE,aAAa,CAACH,MAAM,CAAC;EAClCA,MAAM,GAAGC,QAAG,CAACG,iBAAiB,CAACJ,MAAM,CAAC;EACtCA,MAAM,GAAGC,QAAG,CAACI,sBAAsB,CAACL,MAAM,CAAC;EAE3C,OAAOA,MAAM;AACf,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,kCAAmB,EAACV,YAAY,EAAEF,GAAG,CAACC,IAAI,EAAED,GAAG,CAACa,OAAO,CAAC","ignoreList":[]}
|