@situm/react-native 3.0.10 → 3.1.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.
Files changed (77) hide show
  1. package/android/src/main/java/com/situm/plugin/PluginHelper.java +3 -2
  2. package/android/src/main/java/com/situm/plugin/SitumMapper.java +38 -59
  3. package/android/src/main/java/com/situm/plugin/SitumPlugin.java +1 -0
  4. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
  5. package/ios/SitumPlugin.m +8 -2
  6. package/lib/commonjs/sdk/index.js +509 -251
  7. package/lib/commonjs/sdk/index.js.map +1 -1
  8. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  9. package/lib/commonjs/sdk/types/constants.js +31 -4
  10. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  11. package/lib/commonjs/sdk/utils.js +103 -0
  12. package/lib/commonjs/sdk/utils.js.map +1 -0
  13. package/lib/commonjs/utils/requestPermission.js +9 -16
  14. package/lib/commonjs/utils/requestPermission.js.map +1 -1
  15. package/lib/commonjs/wayfinding/components/MapView.js +78 -134
  16. package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
  17. package/lib/commonjs/wayfinding/hooks/index.js +118 -278
  18. package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
  19. package/lib/commonjs/wayfinding/store/index.js +17 -6
  20. package/lib/commonjs/wayfinding/store/index.js.map +1 -1
  21. package/lib/commonjs/wayfinding/types/index.js +1 -3
  22. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  23. package/lib/commonjs/wayfinding/utils/mapper.js +128 -71
  24. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  25. package/lib/module/sdk/index.js +509 -249
  26. package/lib/module/sdk/index.js.map +1 -1
  27. package/lib/module/sdk/nativeInterface.js.map +1 -1
  28. package/lib/module/sdk/types/constants.js +27 -3
  29. package/lib/module/sdk/types/constants.js.map +1 -1
  30. package/lib/module/sdk/utils.js +94 -0
  31. package/lib/module/sdk/utils.js.map +1 -0
  32. package/lib/module/utils/requestPermission.js +9 -16
  33. package/lib/module/utils/requestPermission.js.map +1 -1
  34. package/lib/module/wayfinding/components/MapView.js +77 -133
  35. package/lib/module/wayfinding/components/MapView.js.map +1 -1
  36. package/lib/module/wayfinding/hooks/index.js +119 -278
  37. package/lib/module/wayfinding/hooks/index.js.map +1 -1
  38. package/lib/module/wayfinding/store/index.js +15 -6
  39. package/lib/module/wayfinding/store/index.js.map +1 -1
  40. package/lib/module/wayfinding/types/index.js +1 -1
  41. package/lib/module/wayfinding/types/index.js.map +1 -1
  42. package/lib/module/wayfinding/utils/mapper.js +123 -72
  43. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  44. package/lib/typescript/src/sdk/index.d.ts +183 -145
  45. package/lib/typescript/src/sdk/index.d.ts.map +1 -1
  46. package/lib/typescript/src/sdk/nativeInterface.d.ts +59 -0
  47. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -1
  48. package/lib/typescript/src/sdk/types/constants.d.ts +24 -3
  49. package/lib/typescript/src/sdk/types/constants.d.ts.map +1 -1
  50. package/lib/typescript/src/sdk/types/index.d.ts +91 -146
  51. package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
  52. package/lib/typescript/src/sdk/utils.d.ts +53 -0
  53. package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
  54. package/lib/typescript/src/utils/requestPermission.d.ts +1 -1
  55. package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -1
  56. package/lib/typescript/src/wayfinding/components/MapView.d.ts +16 -28
  57. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
  58. package/lib/typescript/src/wayfinding/hooks/index.d.ts +3 -34
  59. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
  60. package/lib/typescript/src/wayfinding/store/index.d.ts +8 -6
  61. package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -1
  62. package/lib/typescript/src/wayfinding/types/index.d.ts +36 -17
  63. package/lib/typescript/src/wayfinding/types/index.d.ts.map +1 -1
  64. package/lib/typescript/src/wayfinding/utils/mapper.d.ts +16 -11
  65. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -1
  66. package/package.json +2 -2
  67. package/src/sdk/index.ts +467 -476
  68. package/src/sdk/nativeInterface.ts +149 -1
  69. package/src/sdk/types/constants.ts +27 -3
  70. package/src/sdk/types/index.ts +98 -158
  71. package/src/sdk/utils.ts +129 -0
  72. package/src/utils/requestPermission.ts +18 -23
  73. package/src/wayfinding/components/MapView.tsx +145 -215
  74. package/src/wayfinding/hooks/index.ts +155 -385
  75. package/src/wayfinding/store/index.tsx +19 -9
  76. package/src/wayfinding/types/index.ts +49 -15
  77. package/src/wayfinding/utils/mapper.ts +145 -104
@@ -60,6 +60,7 @@ import es.situm.sdk.location.GeofenceListener;
60
60
  import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_CHANGED;
61
61
  import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_ERROR;
62
62
  import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_STATUS_CHANGED;
63
+ import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_STOPPED;
63
64
  import static com.situm.plugin.SitumPlugin.EVENT_NAVIGATION_ERROR;
64
65
  import static com.situm.plugin.SitumPlugin.EVENT_NAVIGATION_UPDATE;
65
66
  import static com.situm.plugin.SitumPlugin.EVENT_REALTIME_ERROR;
@@ -402,13 +403,14 @@ public class PluginHelper {
402
403
  }
403
404
  }
404
405
 
405
- public void stopPositioning(Callback callback) {
406
+ public void stopPositioning(Callback callback, DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter) {
406
407
  try {
407
408
  SitumSdk.locationManager().removeUpdates();
408
409
  WritableMap map = Arguments.createMap();
409
410
  map.putBoolean("success", true);
410
411
  map.putString("message", "Stopped Successfully");
411
412
  invokeCallback(callback, map);
413
+ eventEmitter.emit(EVENT_LOCATION_STOPPED, null);
412
414
  } catch (Exception e) {
413
415
  invokeCallback(callback, e.getMessage());
414
416
  }
@@ -427,7 +429,6 @@ public class PluginHelper {
427
429
 
428
430
  DirectionsRequest directionRequest = SitumMapper.jsonObjectToDirectionsRequest(jsonBuilding, jsonFrom,
429
431
  jsonTo, jsonOptions);
430
-
431
432
  SitumSdk.directionsManager().requestDirections(directionRequest, new Handler<Route>() {
432
433
  @Override
433
434
  public void onSuccess(Route route) {
@@ -7,12 +7,12 @@ import android.util.Log;
7
7
 
8
8
  import androidx.annotation.Nullable;
9
9
 
10
+ import com.facebook.react.bridge.Arguments;
10
11
  import com.facebook.react.bridge.ReadableArray;
11
12
  import com.facebook.react.bridge.ReadableMap;
12
13
  import com.facebook.react.bridge.WritableArray;
13
14
  import com.facebook.react.bridge.WritableMap;
14
15
  import com.facebook.react.bridge.WritableNativeArray;
15
- import com.facebook.react.bridge.WritableNativeMap;
16
16
 
17
17
  import org.json.JSONArray;
18
18
  import org.json.JSONException;
@@ -29,7 +29,6 @@ import java.util.Iterator;
29
29
  import java.util.List;
30
30
  import java.util.Locale;
31
31
  import java.util.Map;
32
- import java.util.Stack;
33
32
 
34
33
  import es.situm.sdk.directions.DirectionsRequest;
35
34
  import es.situm.sdk.location.LocationRequest;
@@ -1100,9 +1099,12 @@ class SitumMapper {
1100
1099
  DirectionsRequest.AccessibilityMode accessibilityMode = DirectionsRequest.AccessibilityMode.CHOOSE_SHORTEST;
1101
1100
  Boolean minimizeFloorChanges = false;
1102
1101
  double startingAngle = 0.0;
1103
-
1102
+
1104
1103
  if (joOptions != null) {
1104
+
1105
+
1105
1106
  if (joOptions.has(SitumMapper.ACCESSIBILITY_MODE)) {
1107
+
1106
1108
  String mode = joOptions.getString(SitumMapper.ACCESSIBILITY_MODE);
1107
1109
  if (mode.equals(DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE.name())) {
1108
1110
  accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE;
@@ -1127,6 +1129,7 @@ class SitumMapper {
1127
1129
  }
1128
1130
 
1129
1131
  static ReadableArray mapList(List<? extends MapperInterface> modelObjects) {
1132
+
1130
1133
  WritableArray mappedList = new WritableNativeArray();
1131
1134
  for (MapperInterface modelObject : modelObjects) {
1132
1135
  ReadableMap modelMap = convertMapToReadableMap(modelObject.toMap());
@@ -1136,37 +1139,25 @@ class SitumMapper {
1136
1139
  }
1137
1140
 
1138
1141
  public static ReadableMap convertMapToReadableMap(Map<String, Object> map) {
1139
- WritableMap response = new WritableNativeMap();
1140
- // Use a local stack to keep nested objects (avoids recursion).
1141
- // First item in the stack: the given object.
1142
- Stack<Map<String, Object>> sourcesStack = new Stack();
1143
- Stack<WritableMap> responseStack = new Stack<>();
1144
- sourcesStack.push(map);
1145
- responseStack.push(response);
1146
-
1147
- while (!sourcesStack.isEmpty()) {
1148
- Map<String, Object> currentSource = sourcesStack.pop();
1149
- WritableMap currentTarget = responseStack.pop();
1150
- for (Map.Entry<String, Object> entry : currentSource.entrySet()) {
1151
- String key = entry.getKey();
1152
- Object value = entry.getValue();
1153
- if (value instanceof String) {
1154
- currentTarget.putString(key, (String) value);
1155
- } else if (value instanceof Integer) {
1156
- currentTarget.putInt(key, (Integer) value);
1157
- } else if (value instanceof Double) {
1158
- currentTarget.putDouble(key, (Double) value);
1159
- } else if (value instanceof Boolean) {
1160
- currentTarget.putBoolean(key, (Boolean) value);
1161
- } else if (value instanceof List) {
1162
- // Warning: #convertMapToReadableMap maybe called here:
1163
- currentTarget.putArray(key, convertListToReadableArray((List<Object>) value));
1164
- } else if (value instanceof Map) {
1165
- sourcesStack.push((Map) value);
1166
- WritableMap nextMap = new WritableNativeMap();
1167
- responseStack.push(nextMap);
1168
- currentTarget.putMap(key, nextMap);
1169
- }
1142
+ WritableMap response = Arguments.createMap();
1143
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
1144
+ String key = entry.getKey();
1145
+ Object value = entry.getValue();
1146
+ if (value instanceof String) {
1147
+ response.putString(key, (String) value);
1148
+ } else if (value instanceof Integer) {
1149
+ response.putInt(key, (Integer) value);
1150
+ } else if (value instanceof Double) {
1151
+ response.putDouble(key, (Double) value);
1152
+ } else if (value instanceof Boolean) {
1153
+ response.putBoolean(key, (Boolean) value);
1154
+ } else if (value instanceof List) {
1155
+ // Warning: #convertMapToReadableMap maybe called here:
1156
+ response.putArray(key, convertListToReadableArray((List<Object>) value));
1157
+ } else if (value instanceof Map) {
1158
+ // TODO: avoid recursive calls using a stack throws ObjectAlreadyConsumedException while
1159
+ // processing nested WritableMaps. Is there a way to avoid recursion?
1160
+ response.putMap(key, convertMapToReadableMap((Map) value));
1170
1161
  }
1171
1162
  }
1172
1163
  return response;
@@ -1174,31 +1165,19 @@ class SitumMapper {
1174
1165
 
1175
1166
  public static ReadableArray convertListToReadableArray(List<Object> list) {
1176
1167
  WritableArray response = new WritableNativeArray();
1177
- Stack<List<Object>> sourcesStack = new Stack();
1178
- Stack<WritableArray> responseStack = new Stack<>();
1179
- sourcesStack.push(list);
1180
- responseStack.push(response);
1181
-
1182
- while (!sourcesStack.isEmpty()) {
1183
- List<Object> currentSource = sourcesStack.pop();
1184
- WritableArray currentTarget = responseStack.pop();
1185
- for (Object value : currentSource) {
1186
- if (value instanceof String) {
1187
- currentTarget.pushString((String) value);
1188
- } else if (value instanceof Integer) {
1189
- currentTarget.pushInt((Integer) value);
1190
- } else if (value instanceof Double) {
1191
- currentTarget.pushDouble((Double) value);
1192
- } else if (value instanceof Boolean) {
1193
- currentTarget.pushBoolean((Boolean) value);
1194
- } else if (value instanceof Map) {
1195
- currentTarget.pushMap(convertMapToReadableMap((Map) value));
1196
- } else if (value instanceof List) {
1197
- sourcesStack.push((List) value);
1198
- WritableArray nextList = new WritableNativeArray();
1199
- responseStack.push(nextList);
1200
- currentTarget.pushArray(nextList);
1201
- }
1168
+ for (Object value : list) {
1169
+ if (value instanceof String) {
1170
+ response.pushString((String) value);
1171
+ } else if (value instanceof Integer) {
1172
+ response.pushInt((Integer) value);
1173
+ } else if (value instanceof Double) {
1174
+ response.pushDouble((Double) value);
1175
+ } else if (value instanceof Boolean) {
1176
+ response.pushBoolean((Boolean) value);
1177
+ } else if (value instanceof Map) {
1178
+ response.pushMap(convertMapToReadableMap((Map) value));
1179
+ } else if (value instanceof List) {
1180
+ response.pushArray(convertListToReadableArray((List) value));
1202
1181
  }
1203
1182
  }
1204
1183
  return response;
@@ -8,6 +8,7 @@ public interface SitumPlugin {
8
8
  String EVENT_LOCATION_CHANGED = "locationChanged";
9
9
  String EVENT_LOCATION_ERROR = "locationError";
10
10
  String EVENT_LOCATION_STATUS_CHANGED = "statusChanged";
11
+ String EVENT_LOCATION_STOPPED = "locationStopped";
11
12
 
12
13
  String EVENT_NAVIGATION_UPDATE = "navigationUpdated";
13
14
  String EVENT_NAVIGATION_ERROR = "navigationError";
@@ -181,7 +181,7 @@ public class SitumPluginImpl extends ReactContextBaseJavaModule implements Situm
181
181
  @Override
182
182
  @ReactMethod
183
183
  public void stopPositioning(Callback callback) {
184
- getPluginInstance().stopPositioning(callback);
184
+ getPluginInstance().stopPositioning(callback, getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class));
185
185
  }
186
186
 
187
187
  @Override
package/ios/SitumPlugin.m CHANGED
@@ -84,7 +84,7 @@ RCT_EXPORT_MODULE(RNCSitumPlugin);
84
84
 
85
85
  - (NSArray<NSString *> *)supportedEvents
86
86
  {
87
- return @[@"locationChanged", @"statusChanged", @"locationError", @"navigationUpdated", @"navigationError", @"realtimeUpdated", @"realtimeError", @"onEnterGeofences", @"onExitGeofences"];
87
+ return @[@"locationChanged", @"statusChanged", @"locationError", @"locationStopped", @"navigationUpdated", @"navigationError", @"realtimeUpdated", @"realtimeError", @"onEnterGeofences", @"onExitGeofences"];
88
88
  }
89
89
 
90
90
  @synthesize computedRoute = _computedRoute;
@@ -359,6 +359,11 @@ RCT_EXPORT_METHOD(stopPositioning:(RCTResponseSenderBlock)callback)
359
359
  _positioningUpdates = NO;
360
360
  [[SITLocationManager sharedInstance] removeUpdates];
361
361
  [[SITLocationManager sharedInstance] removeDelegate:self];
362
+
363
+ NSDictionary *response = @{@"success": @YES, @"message": @"Stopped Successfully"};
364
+ callback(@[response]);
365
+
366
+ [self sendEventWithName:@"locationStopped" body:@{}];
362
367
  }
363
368
 
364
369
  RCT_EXPORT_METHOD(requestDirections: (NSArray *)requestArray withSuccessCallback:(RCTResponseSenderBlock)successBlock errorCallback:(RCTResponseSenderBlock)errorBlock)
@@ -897,13 +902,14 @@ destinationReachedOnRoute:(SITRoute *)route {
897
902
 
898
903
 
899
904
  - (void)didEnteredGeofences:(NSArray<SITGeofence *> *)geofences {
905
+
900
906
  NSArray *geofencesJO = [SitumLocationWrapper.shared geofencesToJsonArray:geofences];
901
907
 
902
908
  [self sendEventWithName:@"onEnterGeofences" body:geofencesJO];
903
909
  }
904
910
 
905
911
  - (void)didExitedGeofences:(NSArray<SITGeofence *> *)geofences {
906
-
912
+
907
913
  NSArray *geofencesJO = [SitumLocationWrapper.shared geofencesToJsonArray:geofences];
908
914
 
909
915
  [self sendEventWithName:@"onExitGeofences" body:geofencesJO];