@mapsindoors/react-native-maps-indoors-mapbox 2.9.0 → 2.10.0
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 +81 -21
- package/android/build.gradle +2 -14
- package/android/src/main/java/com/mapsindoorsrn/MapboxMapView.java +4 -0
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +10 -1
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsViewManager.java +28 -2
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +10 -2
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +1 -0
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +335 -99
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +17 -1
- package/android/src/main/java/com/mapsindoorsrn/core/RouteStore.java +59 -0
- package/app.plugin.js +8 -86
- package/ios/core/DirectionsRendererBridge.m +1 -0
- package/ios/core/DirectionsRendererModule.swift +292 -308
- package/ios/core/DirectionsServiceModule.swift +7 -1
- package/ios/core/MapControlModule.swift +330 -244
- package/ios/core/MapsIndoorsBridge.m +1 -0
- package/ios/core/MapsIndoorsModule.swift +48 -14
- package/ios/core/ReactPositionProvider.swift +6 -7
- package/ios/core/Sources/MainThread/CallGeneration.swift +38 -0
- package/ios/core/Sources/MainThread/MainThread.swift +25 -0
- package/ios/core/Sources/RouteStore/RouteStore.swift +62 -0
- package/package.json +10 -2
- package/react-native-maps-indoors-mapbox.podspec +6 -2
- package/specs/NativeDirectionsRendererModule.ts +1 -1
- package/specs/NativeMapsIndoorsModule.ts +1 -1
- package/src/core/MPCameraPosition.ts +1 -1
- package/src/core/MPDirectionsRenderer.ts +19 -3
- package/src/core/MPDirectionsService.ts +4 -1
- package/src/core/MPRouteStopIconConfig.ts +5 -3
- package/src/core/MapsIndoors.ts +36 -3
- package/src/core/RouteHandles.ts +76 -0
- package/src/core/RouteStopIconConfig.ts +5 -1
- package/src/core/__tests__/MPBounds.test.ts +0 -109
- package/src/core/__tests__/MPFilter.test.ts +0 -76
- package/src/core/__tests__/MPLanguageTag.test.ts +0 -168
- package/src/core/__tests__/MPPoint.test.ts +0 -82
- package/src/core/__tests__/MPSolution.test.ts +0 -107
- package/src/core/__tests__/MapsIndoors.language.test.ts +0 -180
|
@@ -25,6 +25,7 @@ import com.mapsindoors.core.MPDataSetManagerStatus;
|
|
|
25
25
|
import com.mapsindoors.core.MPDisplayRule;
|
|
26
26
|
import com.mapsindoors.core.MPFilter;
|
|
27
27
|
import com.mapsindoors.core.MPLocation;
|
|
28
|
+
import com.mapsindoors.core.MPLogger;
|
|
28
29
|
import com.mapsindoors.core.MPPoint;
|
|
29
30
|
import com.mapsindoors.core.MPQuery;
|
|
30
31
|
import com.mapsindoors.core.MPSolution;
|
|
@@ -98,9 +99,23 @@ public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
|
98
99
|
promise.reject("MapsIndoorsError", errorString);
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Names this wrapper as the component behind the MapsIndoors Insights session, so React Native
|
|
104
|
+
* apps are told apart from native ones in the rollups.
|
|
105
|
+
*
|
|
106
|
+
* The SDK snapshots the component into the session when the session starts, inside
|
|
107
|
+
* {@code MapsIndoors.load}, so this has to run on the same call, right before it. The version
|
|
108
|
+
* comes from JS, which reads it from the map package's own package.json.
|
|
109
|
+
*/
|
|
110
|
+
private void setReactNativeComponent(@Nullable String sdkVersion) {
|
|
111
|
+
MPLogger.setCustomComponent("React Native/android SDK", sdkVersion != null ? sdkVersion : "unknown");
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
@ReactMethod
|
|
102
|
-
public void loadMapsIndoors(String apiKey, ReadableArray optionalStrings, Promise promise) {
|
|
115
|
+
public void loadMapsIndoors(String apiKey, ReadableArray optionalStrings, @Nullable String sdkVersion, Promise promise) {
|
|
103
116
|
try {
|
|
117
|
+
setReactNativeComponent(sdkVersion);
|
|
118
|
+
RouteStore.clear();
|
|
104
119
|
if (optionalStrings != null) {
|
|
105
120
|
List<String> venueList = new ArrayList<>();
|
|
106
121
|
for (int i = 0; i < optionalStrings.size(); i++) {
|
|
@@ -352,6 +367,7 @@ public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
|
352
367
|
|
|
353
368
|
@ReactMethod
|
|
354
369
|
public void destroy(final Promise promise) {
|
|
370
|
+
RouteStore.clear();
|
|
355
371
|
MapsIndoors.destroy();
|
|
356
372
|
promise.resolve(null);
|
|
357
373
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.mapsindoors.core.MPRoute;
|
|
7
|
+
|
|
8
|
+
import java.util.LinkedHashMap;
|
|
9
|
+
import java.util.Map;
|
|
10
|
+
import java.util.UUID;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Keeps the routes {@link DirectionsServiceModule#getRoute} returned, so
|
|
14
|
+
* {@link DirectionsRendererModule#setRoute} can render the very instance instead of parsing the copy
|
|
15
|
+
* that comes back from JavaScript (SPEX-2782).
|
|
16
|
+
*
|
|
17
|
+
* Only that instance carries the endpoints the SDK reports with the directions Insights events, and
|
|
18
|
+
* the SDK keeps them out of Gson, so a parsed copy reports none.
|
|
19
|
+
*
|
|
20
|
+
* Shared by the two modules, since neither can reach the other's instance. Holds at most
|
|
21
|
+
* {@link #CAPACITY} routes and forgets the least recently used, since JavaScript never says when it is
|
|
22
|
+
* done with one. A forgotten route still renders, from its JSON, just without endpoints. Rendering
|
|
23
|
+
* a kept route again is safe: the SDK resolves its endpoints once and reads them on every event.
|
|
24
|
+
*/
|
|
25
|
+
final class RouteStore {
|
|
26
|
+
static final int CAPACITY = 10;
|
|
27
|
+
|
|
28
|
+
// Access order, so a lookup counts as use and a route the app keeps setting stays.
|
|
29
|
+
private static final Map<String, MPRoute> sRoutes = new LinkedHashMap<String, MPRoute>(CAPACITY + 1, 1f, true) {
|
|
30
|
+
@Override
|
|
31
|
+
protected boolean removeEldestEntry(Map.Entry<String, MPRoute> eldest) {
|
|
32
|
+
return size() > CAPACITY;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
private RouteStore() {}
|
|
37
|
+
|
|
38
|
+
/** Keeps {@code route} and returns the key to look it up by. */
|
|
39
|
+
@NonNull
|
|
40
|
+
static synchronized String keep(@NonNull MPRoute route) {
|
|
41
|
+
String key = UUID.randomUUID().toString();
|
|
42
|
+
sRoutes.put(key, route);
|
|
43
|
+
return key;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The route kept under {@code key}, if it is still kept. */
|
|
47
|
+
@Nullable
|
|
48
|
+
static synchronized MPRoute get(@Nullable String key) {
|
|
49
|
+
return key == null ? null : sRoutes.get(key);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Forgets every route, when MapsIndoors loads or is destroyed: a route belongs to the solution
|
|
54
|
+
* that was loaded when it was requested.
|
|
55
|
+
*/
|
|
56
|
+
static synchronized void clear() {
|
|
57
|
+
sRoutes.clear();
|
|
58
|
+
}
|
|
59
|
+
}
|
package/app.plugin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const {
|
|
2
2
|
withProjectBuildGradle,
|
|
3
|
-
withGradleProperties,
|
|
4
3
|
withPlugins,
|
|
5
4
|
withDangerousMod,
|
|
6
5
|
withInfoPlist,
|
|
@@ -46,24 +45,6 @@ const {
|
|
|
46
45
|
]);
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
/**
|
|
50
|
-
* Plugin to add mapbox private token to gradle properties
|
|
51
|
-
* @param {*} config expo project config
|
|
52
|
-
* @param {*} token private token to set
|
|
53
|
-
* @returns modified config
|
|
54
|
-
*/
|
|
55
|
-
const withGradleProps = (token) => (config) => {
|
|
56
|
-
return withGradleProperties(config, (modConf) => {
|
|
57
|
-
modConf.modResults.push({
|
|
58
|
-
type: "property",
|
|
59
|
-
key: "MAPBOX_DOWNLOADS_TOKEN",
|
|
60
|
-
value: token,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return modConf;
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
48
|
/**
|
|
68
49
|
* Plugin to add mapsindoors maven repository
|
|
69
50
|
* @param {*} config expo project config
|
|
@@ -76,19 +57,7 @@ const {
|
|
|
76
57
|
|
|
77
58
|
`maven { url 'https://www.jitpack.io' }
|
|
78
59
|
maven { url 'https://maven.mapsindoors.com/' }
|
|
79
|
-
maven {
|
|
80
|
-
url 'https://api.mapbox.com/downloads/v2/releases/maven'
|
|
81
|
-
authentication {
|
|
82
|
-
basic(BasicAuthentication)
|
|
83
|
-
}
|
|
84
|
-
credentials {
|
|
85
|
-
// Do not change the username below.
|
|
86
|
-
// This should always be 'mapbox' (not your username).
|
|
87
|
-
username = "mapbox"
|
|
88
|
-
// Use the secret token you stored in gradle.properties as the password
|
|
89
|
-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
|
|
90
|
-
}
|
|
91
|
-
}`
|
|
60
|
+
maven { url 'https://api.mapbox.com/downloads/v2/releases/maven' }`
|
|
92
61
|
);
|
|
93
62
|
|
|
94
63
|
modConf.modResults.contents = content;
|
|
@@ -109,57 +78,6 @@ const {
|
|
|
109
78
|
});
|
|
110
79
|
};
|
|
111
80
|
|
|
112
|
-
/**
|
|
113
|
-
* Plugin to add mapsindoors user system setup
|
|
114
|
-
* @param {*} token private token to set
|
|
115
|
-
* @param {*} config expo project config
|
|
116
|
-
*/
|
|
117
|
-
const withiOSSecret = (token) => (config) => {
|
|
118
|
-
return withDangerousMod(config, [
|
|
119
|
-
"ios",
|
|
120
|
-
async (modConf) => {
|
|
121
|
-
const home = path.resolve(process.env.HOME);
|
|
122
|
-
const netrc = path.resolve(home, ".netrc");
|
|
123
|
-
|
|
124
|
-
// conf to add
|
|
125
|
-
const conf = `machine api.mapbox.com
|
|
126
|
-
login mapbox
|
|
127
|
-
password ${token}
|
|
128
|
-
`;
|
|
129
|
-
|
|
130
|
-
const exists = fs.existsSync(netrc);
|
|
131
|
-
|
|
132
|
-
if (!exists) {
|
|
133
|
-
// no previous conf, write new one
|
|
134
|
-
fs.writeFileSync(netrc, conf, { flag: "w" });
|
|
135
|
-
fs.chmodSync(netrc, 0o600);
|
|
136
|
-
} else {
|
|
137
|
-
// get content
|
|
138
|
-
let content = fs.readFileSync(netrc, "utf-8");
|
|
139
|
-
const lines = content.split("\n");
|
|
140
|
-
|
|
141
|
-
// check if mapbox conf exist
|
|
142
|
-
const found = lines.findIndex((line) =>
|
|
143
|
-
line.includes("machine api.mapbox.com")
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
if (found >= 0) {
|
|
147
|
-
// remove previous mapbox conf
|
|
148
|
-
content = lines
|
|
149
|
-
.filter((_, idx) => ![found, found + 1, found + 2].includes(idx))
|
|
150
|
-
.join("\n");
|
|
151
|
-
fs.writeFileSync(netrc, content, { flag: "w" });
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// write new conf
|
|
155
|
-
fs.writeFileSync(netrc, conf, { flag: "a+" });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return modConf;
|
|
159
|
-
},
|
|
160
|
-
]);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
81
|
/**
|
|
164
82
|
* Plugin to add podfile script
|
|
165
83
|
* @param {*} config expo project config
|
|
@@ -255,7 +173,7 @@ const {
|
|
|
255
173
|
/**
|
|
256
174
|
* Combine Expo configuration and properties
|
|
257
175
|
* @param {*} config expo project config
|
|
258
|
-
* @param {*} {downloadToken} Mapbox
|
|
176
|
+
* @param {*} {downloadToken} deprecated and ignored: Mapbox SDK downloads need no token
|
|
259
177
|
* @param {*} {publicToken} Mapbox public token
|
|
260
178
|
* @returns modified config
|
|
261
179
|
*/
|
|
@@ -263,12 +181,16 @@ const {
|
|
|
263
181
|
config,
|
|
264
182
|
{ downloadToken, publicToken, staticPods }
|
|
265
183
|
) => {
|
|
184
|
+
if (downloadToken !== undefined) {
|
|
185
|
+
console.warn(
|
|
186
|
+
"@mapsindoors/react-native-maps-indoors-mapbox: `downloadToken` is deprecated and ignored. Mapbox SDK downloads need no token; remove it from your plugin config."
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
266
190
|
const plugins = [
|
|
267
|
-
withGradleProps(downloadToken),
|
|
268
191
|
withAPIKeys(publicToken),
|
|
269
192
|
withMavenRepo,
|
|
270
193
|
withTokenInfoPlist(publicToken),
|
|
271
|
-
withiOSSecret(downloadToken),
|
|
272
194
|
withPodfile,
|
|
273
195
|
withStaticLinkage(staticPods),
|
|
274
196
|
];
|