@situm/react-native 3.15.0-beta.1 → 3.15.0-beta.2

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 (145) hide show
  1. package/android/src/main/java/com/situm/plugin/PluginHelper.java +1 -1
  2. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
  3. package/ios/SitumPlugin.m +14 -7
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/package.json +1 -0
  6. package/lib/commonjs/sdk/index.js.map +1 -1
  7. package/lib/commonjs/sdk/internaDelegatedState.js.map +1 -0
  8. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  9. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  10. package/lib/commonjs/sdk/types/index.js.map +1 -1
  11. package/lib/commonjs/sdk/utils.js.map +1 -1
  12. package/lib/commonjs/utils/index.js.map +1 -1
  13. package/lib/commonjs/utils/logError.js.map +1 -1
  14. package/lib/commonjs/wayfinding/index.js.map +1 -1
  15. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  16. package/lib/commonjs/wayfinding/utils/index.js.map +1 -1
  17. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/package.json +1 -0
  20. package/lib/module/sdk/index.js.map +0 -1
  21. package/lib/module/sdk/internaDelegatedState.js.map +1 -0
  22. package/lib/module/sdk/nativeInterface.js.map +1 -1
  23. package/lib/module/sdk/types/constants.js.map +1 -1
  24. package/lib/module/sdk/types/index.js.map +1 -1
  25. package/lib/module/sdk/utils.js.map +1 -1
  26. package/lib/module/utils/index.js.map +1 -1
  27. package/lib/module/utils/logError.js.map +0 -1
  28. package/lib/module/wayfinding/index.js.map +1 -1
  29. package/lib/module/wayfinding/types/constants.js.map +1 -1
  30. package/lib/module/wayfinding/types/index.js.map +0 -1
  31. package/lib/module/wayfinding/utils/index.js.map +1 -1
  32. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  33. package/lib/typescript/index.d.ts.map +1 -0
  34. package/lib/typescript/{src/sdk → sdk}/index.d.ts +25 -32
  35. package/lib/typescript/sdk/index.d.ts.map +1 -0
  36. package/lib/typescript/sdk/internaDelegatedState.d.ts +17 -0
  37. package/lib/typescript/sdk/internaDelegatedState.d.ts.map +1 -0
  38. package/lib/typescript/{src/sdk → sdk}/nativeInterface.d.ts +4 -2
  39. package/lib/typescript/sdk/nativeInterface.d.ts.map +1 -0
  40. package/lib/typescript/sdk/types/constants.d.ts.map +1 -0
  41. package/lib/typescript/{src/sdk → sdk}/types/index.d.ts +2 -1
  42. package/lib/typescript/sdk/types/index.d.ts.map +1 -0
  43. package/lib/typescript/{src/sdk → sdk}/utils.d.ts +1 -1
  44. package/lib/typescript/sdk/utils.d.ts.map +1 -0
  45. package/lib/typescript/utils/index.d.ts.map +1 -0
  46. package/lib/typescript/utils/logError.d.ts.map +1 -0
  47. package/lib/typescript/{src/wayfinding → wayfinding}/components/MapView.d.ts +1 -1
  48. package/lib/typescript/wayfinding/components/MapView.d.ts.map +1 -0
  49. package/lib/typescript/wayfinding/hooks/index.d.ts.map +1 -0
  50. package/lib/typescript/wayfinding/index.d.ts.map +1 -0
  51. package/lib/typescript/{src/wayfinding → wayfinding}/store/index.d.ts +13 -13
  52. package/lib/typescript/wayfinding/store/index.d.ts.map +1 -0
  53. package/lib/typescript/{src/wayfinding → wayfinding}/store/utils.d.ts +0 -1
  54. package/lib/typescript/wayfinding/store/utils.d.ts.map +1 -0
  55. package/lib/typescript/wayfinding/types/constants.d.ts.map +1 -0
  56. package/lib/typescript/{src/wayfinding → wayfinding}/types/index.d.ts +1 -1
  57. package/lib/typescript/wayfinding/types/index.d.ts.map +1 -0
  58. package/lib/typescript/wayfinding/utils/index.d.ts +3 -0
  59. package/lib/typescript/wayfinding/utils/index.d.ts.map +1 -0
  60. package/lib/typescript/wayfinding/utils/mapper.d.ts.map +1 -0
  61. package/package.json +24 -35
  62. package/src/sdk/index.ts +67 -52
  63. package/src/sdk/internaDelegatedState.ts +54 -0
  64. package/src/sdk/nativeInterface.ts +31 -27
  65. package/src/sdk/types/index.ts +7 -6
  66. package/src/sdk/utils.ts +12 -9
  67. package/src/utils/logError.ts +1 -1
  68. package/src/wayfinding/components/MapView.tsx +103 -104
  69. package/src/wayfinding/hooks/index.ts +94 -91
  70. package/src/wayfinding/store/index.tsx +4 -4
  71. package/src/wayfinding/types/index.ts +1 -1
  72. package/src/wayfinding/utils/index.ts +2 -1
  73. package/LICENSE +0 -21
  74. package/README.md +0 -200
  75. package/SECURITY-POLICY.md +0 -9
  76. package/lib/commonjs/index.js +0 -73
  77. package/lib/commonjs/sdk/index.js +0 -932
  78. package/lib/commonjs/sdk/nativeInterface.js +0 -20
  79. package/lib/commonjs/sdk/types/constants.js +0 -68
  80. package/lib/commonjs/sdk/types/index.js +0 -405
  81. package/lib/commonjs/sdk/utils.js +0 -156
  82. package/lib/commonjs/utils/index.js +0 -17
  83. package/lib/commonjs/utils/logError.js +0 -21
  84. package/lib/commonjs/wayfinding/components/MapView.js +0 -389
  85. package/lib/commonjs/wayfinding/components/MapView.js.map +0 -1
  86. package/lib/commonjs/wayfinding/hooks/index.js +0 -229
  87. package/lib/commonjs/wayfinding/hooks/index.js.map +0 -1
  88. package/lib/commonjs/wayfinding/index.js +0 -57
  89. package/lib/commonjs/wayfinding/store/index.js +0 -242
  90. package/lib/commonjs/wayfinding/store/index.js.map +0 -1
  91. package/lib/commonjs/wayfinding/store/utils.js +0 -49
  92. package/lib/commonjs/wayfinding/store/utils.js.map +0 -1
  93. package/lib/commonjs/wayfinding/types/constants.js +0 -13
  94. package/lib/commonjs/wayfinding/types/constants.js.map +0 -1
  95. package/lib/commonjs/wayfinding/types/index.js +0 -6
  96. package/lib/commonjs/wayfinding/utils/index.js +0 -11
  97. package/lib/commonjs/wayfinding/utils/mapper.js +0 -206
  98. package/lib/module/index.js +0 -12
  99. package/lib/module/sdk/index.js +0 -903
  100. package/lib/module/sdk/nativeInterface.js +0 -18
  101. package/lib/module/sdk/types/constants.js +0 -63
  102. package/lib/module/sdk/types/index.js +0 -434
  103. package/lib/module/sdk/utils.js +0 -144
  104. package/lib/module/utils/index.js +0 -2
  105. package/lib/module/utils/logError.js +0 -15
  106. package/lib/module/wayfinding/components/MapView.js +0 -379
  107. package/lib/module/wayfinding/components/MapView.js.map +0 -1
  108. package/lib/module/wayfinding/hooks/index.js +0 -220
  109. package/lib/module/wayfinding/hooks/index.js.map +0 -1
  110. package/lib/module/wayfinding/index.js +0 -13
  111. package/lib/module/wayfinding/store/index.js +0 -206
  112. package/lib/module/wayfinding/store/index.js.map +0 -1
  113. package/lib/module/wayfinding/store/utils.js +0 -38
  114. package/lib/module/wayfinding/store/utils.js.map +0 -1
  115. package/lib/module/wayfinding/types/constants.js +0 -7
  116. package/lib/module/wayfinding/types/index.js +0 -2
  117. package/lib/module/wayfinding/utils/index.js +0 -4
  118. package/lib/module/wayfinding/utils/mapper.js +0 -195
  119. package/lib/typescript/src/index.d.ts.map +0 -1
  120. package/lib/typescript/src/sdk/index.d.ts.map +0 -1
  121. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +0 -1
  122. package/lib/typescript/src/sdk/types/constants.d.ts.map +0 -1
  123. package/lib/typescript/src/sdk/types/index.d.ts.map +0 -1
  124. package/lib/typescript/src/sdk/utils.d.ts.map +0 -1
  125. package/lib/typescript/src/utils/index.d.ts.map +0 -1
  126. package/lib/typescript/src/utils/logError.d.ts.map +0 -1
  127. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +0 -1
  128. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +0 -1
  129. package/lib/typescript/src/wayfinding/index.d.ts.map +0 -1
  130. package/lib/typescript/src/wayfinding/store/index.d.ts.map +0 -1
  131. package/lib/typescript/src/wayfinding/store/utils.d.ts.map +0 -1
  132. package/lib/typescript/src/wayfinding/types/constants.d.ts.map +0 -1
  133. package/lib/typescript/src/wayfinding/types/index.d.ts.map +0 -1
  134. package/lib/typescript/src/wayfinding/utils/index.d.ts +0 -3
  135. package/lib/typescript/src/wayfinding/utils/index.d.ts.map +0 -1
  136. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +0 -1
  137. package/security.txt +0 -4
  138. /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
  139. /package/lib/typescript/{src/sdk → sdk}/types/constants.d.ts +0 -0
  140. /package/lib/typescript/{src/utils → utils}/index.d.ts +0 -0
  141. /package/lib/typescript/{src/utils → utils}/logError.d.ts +0 -0
  142. /package/lib/typescript/{src/wayfinding → wayfinding}/hooks/index.d.ts +0 -0
  143. /package/lib/typescript/{src/wayfinding → wayfinding}/index.d.ts +0 -0
  144. /package/lib/typescript/{src/wayfinding → wayfinding}/types/constants.d.ts +0 -0
  145. /package/lib/typescript/{src/wayfinding → wayfinding}/utils/mapper.d.ts +0 -0
package/src/sdk/index.ts CHANGED
@@ -38,6 +38,7 @@ import {
38
38
  locationStatusAdapter,
39
39
  promiseWrapper,
40
40
  } from "./utils";
41
+ import { DelegatedStateManager } from "./internaDelegatedState";
41
42
 
42
43
  export * from "./types";
43
44
  export * from "./types/constants";
@@ -56,7 +57,7 @@ const RNCSitumPlugin =
56
57
  get() {
57
58
  throw new Error(LINKING_ERROR);
58
59
  },
59
- }
60
+ },
60
61
  ) as SitumPluginInterface);
61
62
 
62
63
  const SitumPluginEventEmitter = new NativeEventEmitter(RNCSitumPlugin);
@@ -66,6 +67,7 @@ let positioningRunning = false;
66
67
  let navigationRunning = false;
67
68
  let realtimeSubscriptions = [];
68
69
 
70
+ // Internal method call (MapView) delegate:
69
71
  let internalMethodCallMapDelegate = (_: InternalCall) => {
70
72
  // internalMethodCallMapDelegate is an empty function by default.
71
73
  };
@@ -101,9 +103,10 @@ let exitGeofencesCallback = (_: any) => {};
101
103
  // internal callback.
102
104
 
103
105
  const _internalLocationCallback = (loc: Location) => {
106
+ DelegatedStateManager.getInstance().updateLocation(loc);
104
107
  // MapView internal callback:
105
108
  internalMethodCallMapDelegate(
106
- new InternalCall(InternalCallType.LOCATION, loc)
109
+ new InternalCall(InternalCallType.LOCATION, loc),
107
110
  );
108
111
  // Navigation internal callback: TODO review this, seems to be different to other plugins and candidate for refactoring.
109
112
  locationCallbackForNavigation(loc);
@@ -113,8 +116,9 @@ const _internalLocationCallback = (loc: Location) => {
113
116
 
114
117
  const _internalLocationStatusCallback = (status: LocationStatus) => {
115
118
  const mapViewStatusName = locationStatusAdapter(status.statusName);
119
+ DelegatedStateManager.getInstance().updateStatus(mapViewStatusName);
116
120
  internalMethodCallMapDelegate(
117
- new InternalCall(InternalCallType.LOCATION_STATUS, mapViewStatusName)
121
+ new InternalCall(InternalCallType.LOCATION_STATUS, mapViewStatusName),
118
122
  );
119
123
  // TODO: we are delegating different values to the internal and client callbacks. The viewer only understands
120
124
  // the states defined in LocationStatusName, but the integrator might be interested in any state from the SDK.
@@ -123,7 +127,7 @@ const _internalLocationStatusCallback = (status: LocationStatus) => {
123
127
 
124
128
  const _internalLocationStoppedCallback = () => {
125
129
  internalMethodCallMapDelegate(
126
- new InternalCall(InternalCallType.LOCATION_STOPPED, undefined)
130
+ new InternalCall(InternalCallType.LOCATION_STOPPED, undefined),
127
131
  );
128
132
  // TODO: this callback is used only in RN, delete!
129
133
  locationStoppedCallback?.();
@@ -131,38 +135,37 @@ const _internalLocationStoppedCallback = () => {
131
135
 
132
136
  const _internalLocationErrorCallback = (error: Error) => {
133
137
  const adaptedError = locationErrorAdapter(error);
134
- if (adaptedError.type === ErrorType.CRITICAL)
135
- SitumPlugin.removeLocationUpdates();
138
+ DelegatedStateManager.getInstance().updateError(adaptedError);
136
139
  internalMethodCallMapDelegate(
137
- new InternalCall(InternalCallType.LOCATION_ERROR, adaptedError)
140
+ new InternalCall(InternalCallType.LOCATION_ERROR, adaptedError),
138
141
  );
139
142
  locationErrorCallback?.(adaptedError);
140
143
  };
141
144
 
142
145
  const _internalNavigationStartedCallback = (route: Route) => {
143
146
  internalMethodCallMapDelegate(
144
- new InternalCall(InternalCallType.NAVIGATION_START, route)
147
+ new InternalCall(InternalCallType.NAVIGATION_START, route),
145
148
  );
146
149
  navigationStartedCallback?.(route);
147
150
  };
148
151
 
149
152
  const _internalNavigationProgressCallback = (progress: NavigationProgress) => {
150
153
  internalMethodCallMapDelegate(
151
- new InternalCall(InternalCallType.NAVIGATION_PROGRESS, progress)
154
+ new InternalCall(InternalCallType.NAVIGATION_PROGRESS, progress),
152
155
  );
153
156
  navigationProgressCallback?.(progress);
154
157
  };
155
158
 
156
159
  const _internalNavigationDestinationReachedCallback = (route: Route) => {
157
160
  internalMethodCallMapDelegate(
158
- new InternalCall(InternalCallType.NAVIGATION_DESTINATION_REACHED, route)
161
+ new InternalCall(InternalCallType.NAVIGATION_DESTINATION_REACHED, route),
159
162
  );
160
163
  navigationDestinationReachedCallback?.(route);
161
164
  };
162
165
 
163
166
  const _internalNavigationOutOfRouteCallback = () => {
164
167
  internalMethodCallMapDelegate(
165
- new InternalCall(InternalCallType.NAVIGATION_OUT_OF_ROUTE, undefined)
168
+ new InternalCall(InternalCallType.NAVIGATION_OUT_OF_ROUTE, undefined),
166
169
  );
167
170
  navigationOutOfRouteCallback?.();
168
171
  };
@@ -170,35 +173,35 @@ const _internalNavigationOutOfRouteCallback = () => {
170
173
  const _internalNavigationFinishedCallback = () => {
171
174
  // Deprecated!
172
175
  internalMethodCallMapDelegate(
173
- new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined)
176
+ new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined),
174
177
  );
175
178
  navigationFinishedCallback?.();
176
179
  };
177
180
 
178
181
  const _internalNavigationCancellationCallback = () => {
179
182
  internalMethodCallMapDelegate(
180
- new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined)
183
+ new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined),
181
184
  );
182
185
  navigationCancellationCallback?.();
183
186
  };
184
187
 
185
188
  const _internalNavigationErrorCallback = (error: any) => {
186
189
  internalMethodCallMapDelegate(
187
- new InternalCall(InternalCallType.NAVIGATION_ERROR, error)
190
+ new InternalCall(InternalCallType.NAVIGATION_ERROR, error),
188
191
  );
189
192
  navigationErrorCallback?.(error);
190
193
  };
191
194
 
192
195
  const _internalEnterGeofencesCallback = (data: any) => {
193
196
  internalMethodCallMapDelegate(
194
- new InternalCall(InternalCallType.GEOFENCES_ENTER, data)
197
+ new InternalCall(InternalCallType.GEOFENCES_ENTER, data),
195
198
  );
196
199
  enterGeofencesCallback?.(data);
197
200
  };
198
201
 
199
202
  const _internalExitGeofencesCallback = (data: any) => {
200
203
  internalMethodCallMapDelegate(
201
- new InternalCall(InternalCallType.GEOFENCES_EXIT, data)
204
+ new InternalCall(InternalCallType.GEOFENCES_EXIT, data),
202
205
  );
203
206
  exitGeofencesCallback?.(data);
204
207
  };
@@ -224,8 +227,10 @@ const _registerCallbacks = () => {
224
227
  };
225
228
 
226
229
  Object.entries(callbacksMap).forEach(([eventName, callback]) => {
230
+ console.log("Event emitter add listener: ", eventName);
227
231
  SitumPluginEventEmitter.removeAllListeners(eventName);
228
232
  SitumPluginEventEmitter.addListener(eventName, callback);
233
+ console.log("Event emitter add listener finished: ", eventName);
229
234
  });
230
235
  };
231
236
 
@@ -333,7 +338,7 @@ export default class SitumPlugin {
333
338
  useRemoteConfig ? "true" : "false",
334
339
  (response) => {
335
340
  onCallback(response, "Failed to set remote config");
336
- }
341
+ },
337
342
  );
338
343
  });
339
344
  };
@@ -594,7 +599,7 @@ export default class SitumPlugin {
594
599
  building: Building,
595
600
  from: Point | Location,
596
601
  to: Point | Poi,
597
- directionOptions?: DirectionsOptions
602
+ directionOptions?: DirectionsOptions,
598
603
  ) => {
599
604
  return promiseWrapper<Directions>(({ onSuccess, onError }) => {
600
605
  const params = [building, from, to, directionOptions || {}];
@@ -662,7 +667,7 @@ export default class SitumPlugin {
662
667
  static requestRealTimeUpdates = (
663
668
  realtimeUpdates: (event: any) => void,
664
669
  error?: (event: any) => void,
665
- options?: any
670
+ options?: any,
666
671
  ) => {
667
672
  return exceptionWrapper<void>(() => {
668
673
  RNCSitumPlugin.requestRealTimeUpdates(options || {});
@@ -671,7 +676,7 @@ export default class SitumPlugin {
671
676
  error
672
677
  ? SitumPluginEventEmitter.addListener(
673
678
  "realtimeError",
674
- error || logError
679
+ error || logError,
675
680
  )
676
681
  : null,
677
682
  ]);
@@ -696,31 +701,16 @@ export default class SitumPlugin {
696
701
  */
697
702
  static checkIfPointInsideGeofence = (
698
703
  request: any,
699
- callback?: (response: { isInsideGeofence: boolean; geofence: any }) => void
704
+ callback?: (response: { isInsideGeofence: boolean; geofence: any }) => void,
700
705
  ) => {
701
- RNCSitumPlugin.checkIfPointInsideGeofence(request, callback);
702
- };
703
-
704
- /**
705
- * INTERNAL METHOD.
706
- *
707
- * Update SDK with the viewer navigation states.
708
- * Do not use this method as it is intended for internal use
709
- * by the map viewer module.
710
- *
711
- * @param externalNavigation
712
- */
713
- static updateNavigationState = (externalNavigation: Map<string, any>) => {
714
- return exceptionWrapper<void>(() => {
715
- RNCSitumPlugin.updateNavigationState(externalNavigation);
716
- });
706
+ RNCSitumPlugin.checkIfPointInsideGeofence(request, callback || (() => {}));
717
707
  };
718
708
 
719
709
  /**
720
710
  * Automatically assists users in resolving app-related permission and sensor issues.
721
711
  *
722
- * This method tells the native SDKs to present a user interface that explains detected
723
- * configuration issues and guides users through the required steps to resolve them,
712
+ * This method tells the native SDKs to present a user interface that explains detected
713
+ * configuration issues and guides users through the required steps to resolve them,
724
714
  * following best practices for runtime permission requests.
725
715
  *
726
716
  * Issues addressed include:
@@ -732,12 +722,10 @@ export default class SitumPlugin {
732
722
  * Call {@link disableUserHelper} as a shortcut to disable the user helper.
733
723
  *
734
724
  * @param {UserHelperOptions} userHelperOptions - Options for the user helper.
735
- * @param {function} cb - Cordova native callback to receive data.
736
- * @param {function} error - Cordova native callback to receive errors.
737
725
  */
738
726
  static configureUserHelper = (userHelperOptions: UserHelperOptions) => {
739
727
  _registerCallbacks();
740
- return exceptionWrapper<void>(({onSuccess, onError}) => {
728
+ return exceptionWrapper<void>(({ onSuccess, onError }) => {
741
729
  RNCSitumPlugin.configureUserHelper(userHelperOptions, onSuccess, onError);
742
730
  });
743
731
  };
@@ -746,12 +734,9 @@ export default class SitumPlugin {
746
734
  * Enables the user helper.
747
735
  *
748
736
  * Shortcut for {@link configureUserHelper} with <code>{enabled: true}</code>.
749
- *
750
- * @param {function} cb - Cordova native callback to receive data.
751
- * @param {function} error - Cordova native callback to receive errors.
752
737
  */
753
738
  static enableUserHelper = () => {
754
- SitumPlugin.configureUserHelper({enabled: true, colorScheme: undefined});
739
+ SitumPlugin.configureUserHelper({ enabled: true, colorScheme: undefined });
755
740
  };
756
741
 
757
742
  /**
@@ -759,11 +744,24 @@ export default class SitumPlugin {
759
744
  *
760
745
  * Shortcut for {@link configureUserHelper} with <code>{enabled: false}</code>.
761
746
  *
762
- * @param {function} cb - Cordova native callback to receive data.
763
- * @param {function} error - Cordova native callback to receive errors.
764
747
  */
765
748
  static disableUserHelper = () => {
766
- SitumPlugin.configureUserHelper({enabled: false, colorScheme: undefined});
749
+ SitumPlugin.configureUserHelper({ enabled: false, colorScheme: undefined });
750
+ };
751
+
752
+ /**
753
+ * INTERNAL METHOD.
754
+ *
755
+ * Update SDK with the viewer navigation states.
756
+ * Do not use this method as it is intended for internal use
757
+ * by the map viewer module.
758
+ *
759
+ * @param externalNavigation
760
+ */
761
+ static updateNavigationState = (externalNavigation: Map<string, any>) => {
762
+ return exceptionWrapper<void>(() => {
763
+ RNCSitumPlugin.updateNavigationState(externalNavigation);
764
+ });
767
765
  };
768
766
 
769
767
  /**
@@ -790,9 +788,26 @@ export default class SitumPlugin {
790
788
  * @param callback
791
789
  */
792
790
  static internalSetMethodCallMapDelegate = (
793
- callback: (internalCall: InternalCall) => void
791
+ callback: (internalCall: InternalCall) => void,
794
792
  ) => {
795
793
  internalMethodCallMapDelegate = callback;
794
+ const lastValues = DelegatedStateManager.getInstance().getValues();
795
+ // Forward last received values as soon as possible:
796
+ if (lastValues.location) {
797
+ internalMethodCallMapDelegate(
798
+ new InternalCall(InternalCallType.LOCATION, lastValues.location),
799
+ );
800
+ }
801
+ if (lastValues.status) {
802
+ internalMethodCallMapDelegate(
803
+ new InternalCall(InternalCallType.LOCATION_STATUS, lastValues.status),
804
+ );
805
+ }
806
+ if (lastValues.error) {
807
+ internalMethodCallMapDelegate(
808
+ new InternalCall(InternalCallType.LOCATION_ERROR, lastValues.error),
809
+ );
810
+ }
796
811
  };
797
812
 
798
813
  //-----------------------------------------------------------------------------//
@@ -889,7 +904,7 @@ export default class SitumPlugin {
889
904
  * @param callback a function that returns the {@link NavigationProgress} by parameters.
890
905
  */
891
906
  static onNavigationProgress = (
892
- callback: (progress: NavigationProgress) => void
907
+ callback: (progress: NavigationProgress) => void,
893
908
  ) => {
894
909
  navigationProgressCallback = callback;
895
910
  };
@@ -900,7 +915,7 @@ export default class SitumPlugin {
900
915
  * @param callback a function that returns the completed {@link Route} by parameters.
901
916
  */
902
917
  static onNavigationDestinationReached = (
903
- callback: (route: Route) => void
918
+ callback: (route: Route) => void,
904
919
  ) => {
905
920
  navigationDestinationReachedCallback = callback;
906
921
  };
@@ -0,0 +1,54 @@
1
+ import { Location, Error } from "./types";
2
+
3
+ // Internal state forwarded to the MapView as soon as possible.
4
+ export type DelegatedState = {
5
+ location: Location | null;
6
+ status: string | null;
7
+ error: Error | null;
8
+ };
9
+
10
+ export class DelegatedStateManager {
11
+ private static instance: DelegatedStateManager;
12
+ private state: DelegatedState = {
13
+ location: null,
14
+ status: null,
15
+ error: null,
16
+ };
17
+
18
+ private constructor() {}
19
+
20
+ static getInstance(): DelegatedStateManager {
21
+ if (!DelegatedStateManager.instance) {
22
+ DelegatedStateManager.instance = new DelegatedStateManager();
23
+ }
24
+ return DelegatedStateManager.instance;
25
+ }
26
+
27
+ updateLocation(location: Location): void {
28
+ this.state = {
29
+ location,
30
+ status: null,
31
+ error: null,
32
+ };
33
+ }
34
+
35
+ updateStatus(status: string): void {
36
+ this.state = {
37
+ location: null,
38
+ status,
39
+ error: null,
40
+ };
41
+ }
42
+
43
+ updateError(error: Error): void {
44
+ this.state = {
45
+ location: null,
46
+ status: null,
47
+ error,
48
+ };
49
+ }
50
+
51
+ getValues(): Readonly<DelegatedState> {
52
+ return this.state;
53
+ }
54
+ }
@@ -25,60 +25,60 @@ import type {
25
25
  interface CartographyAPI {
26
26
  fetchBuildings: (
27
27
  onSuccess: (response: Building[]) => void,
28
- onError: (error: Error) => void
28
+ onError: (error: Error) => void,
29
29
  ) => void;
30
30
  fetchBuildingInfo: (
31
31
  bluilding: Building,
32
32
  onSuccess: (response: BuildingInfo) => void,
33
- onError: (error: Error) => void
33
+ onError: (error: Error) => void,
34
34
  ) => void;
35
35
  fetchTilesFromBuilding: (
36
36
  building: Building,
37
37
  onSuccess: (response: string) => void,
38
- onError: (error: Error) => void
38
+ onError: (error: Error) => void,
39
39
  ) => void;
40
40
  fetchFloorsFromBuilding: (
41
41
  building: Building,
42
42
  onSuccess: (response: Floor[]) => void,
43
- onError: (error: Error) => void
43
+ onError: (error: Error) => void,
44
44
  ) => void;
45
45
  fetchMapFromFloor: (
46
46
  floor: Floor,
47
47
  onSuccess: (response: string) => void,
48
- onError: (error: Error) => void
48
+ onError: (error: Error) => void,
49
49
  ) => void;
50
50
  fetchGeofencesFromBuilding: (
51
51
  building: Building,
52
52
  onSuccess: (response: Geofence[]) => void,
53
- onError: (error: Error) => void
53
+ onError: (error: Error) => void,
54
54
  ) => void;
55
55
  fetchPoiCategories: (
56
56
  onSuccess: (response: PoiCategory[]) => void,
57
- onError: (error: Error) => void
57
+ onError: (error: Error) => void,
58
58
  ) => void;
59
59
  fetchPoiCategoryIconNormal: (
60
60
  category: PoiCategory,
61
61
  onSuccess: (response: PoiIcon) => void,
62
- onError: (error: Error) => void
62
+ onError: (error: Error) => void,
63
63
  ) => void;
64
64
  fetchPoiCategoryIconSelected: (
65
65
  category: PoiCategory,
66
66
  onSuccess: (response: PoiIcon) => void,
67
- onError: (error: Error) => void
67
+ onError: (error: Error) => void,
68
68
  ) => void;
69
69
  fetchIndoorPOIsFromBuilding: (
70
70
  building: Building,
71
71
  onSuccess: (response: Poi[]) => void,
72
- onError: (error: Error) => void
72
+ onError: (error: Error) => void,
73
73
  ) => void;
74
74
  fetchOutdoorPOIsFromBuilding: (
75
75
  building: Building,
76
76
  onSuccess: (response: Poi[]) => void,
77
- onError: (error: Error) => void
77
+ onError: (error: Error) => void,
78
78
  ) => void;
79
79
  checkIfPointInsideGeofence: (
80
80
  request: any,
81
- callback: (response: { isInsideGeofence: boolean; geofence: any }) => void
81
+ callback: (response: { isInsideGeofence: boolean; geofence: any }) => void,
82
82
  ) => void;
83
83
  onEnterGeofences: () => void;
84
84
  onExitGeofences: () => void;
@@ -93,7 +93,7 @@ interface NavigationAPI {
93
93
  updateNavigationWithLocation: (
94
94
  location: Location,
95
95
  onSuccess: (response: void) => void,
96
- onError: (error: Error) => void
96
+ onError: (error: Error) => void,
97
97
  ) => void;
98
98
  updateNavigationState: (externalNavigation: Map<string, any>) => void;
99
99
  }
@@ -106,11 +106,19 @@ interface DirectionsAPI {
106
106
  | DirectionsOptions
107
107
  )[],
108
108
  onSuccess: (response: Directions) => void,
109
- onError: (error: Error) => void
109
+ onError: (error: Error) => void,
110
110
  ) => void;
111
111
  requestNavigationUpdates: (navigationOptions: NavigationRequest) => void;
112
112
  removeNavigationUpdates: (
113
- callback: (response: { success: boolean }) => void
113
+ callback: (response: { success: boolean }) => void,
114
+ ) => void;
115
+ }
116
+
117
+ interface UserHelperManagerAPI {
118
+ configureUserHelper: (
119
+ userHelperOptions: UserHelperOptions,
120
+ success: (response: any) => void,
121
+ error: (response: any) => void,
114
122
  ) => void;
115
123
  }
116
124
 
@@ -119,40 +127,36 @@ export interface SitumPluginInterface
119
127
  CartographyAPI,
120
128
  LocationAPI,
121
129
  NavigationAPI,
122
- DirectionsAPI {
130
+ DirectionsAPI,
131
+ UserHelperManagerAPI {
123
132
  initSitumSDK: () => void;
124
133
  setApiKey: (
125
134
  email: string,
126
135
  apiKey: string,
127
- callback: (response: { success: boolean }) => void
136
+ callback: (response: { success: boolean }) => void,
128
137
  ) => void;
129
138
  setUserPass: (
130
139
  email: string,
131
140
  password: string,
132
- callback: (response: { success: boolean }) => void
141
+ callback: (response: { success: boolean }) => void,
133
142
  ) => void;
134
143
  setDashboardURL: (
135
144
  url: string,
136
- callback: (response: { success: boolean }) => void
145
+ callback: (response: { success: boolean }) => void,
137
146
  ) => void;
138
147
  setUseRemoteConfig: (
139
148
  useRemoteConfig: string,
140
- callback: (response: { success: boolean }) => void
149
+ callback: (response: { success: boolean }) => void,
141
150
  ) => void;
142
151
  setCacheMaxAge: (
143
152
  cacheAge: number,
144
- callback: (response: { success: boolean }) => void
153
+ callback: (response: { success: boolean }) => void,
145
154
  ) => void;
146
155
  invalidateCache: () => void;
147
156
  getDeviceId: (callback: (response: string) => void) => void;
148
157
  requestRealTimeUpdates: (options: any) => void;
149
158
  removeRealTimeUpdates: () => void;
150
159
  validateMapViewProjectSettings: () => void;
151
- configureUserHelper: (
152
- userHelperOptions: UserHelperOptions,
153
- success: (response: any) => void,
154
- error: (response: any) => void
155
- ) => void;
156
160
  }
157
161
 
158
162
  const { RNCSitumPlugin } = NativeModules;
@@ -161,7 +165,7 @@ if (!RNCSitumPlugin) {
161
165
  throw new Error("react-native-situm-plugin: NativeModule is null");
162
166
  }
163
167
 
164
- let nativeEventEmitter = null;
168
+ let nativeEventEmitter: NativeEventEmitter | null = null;
165
169
 
166
170
  module.exports = {
167
171
  RNCSitumPlugin,
@@ -5,7 +5,7 @@ import type {
5
5
  InternalCallType,
6
6
  LocationStatusName,
7
7
  SdkNavigationUpdateType,
8
- } from "src/sdk";
8
+ } from "./constants";
9
9
 
10
10
  /**
11
11
  * @name Building
@@ -183,6 +183,7 @@ export type Geofence = {
183
183
  infoHtml: string;
184
184
  polygonPoints: Point[];
185
185
  customFields: object;
186
+ name: string;
186
187
  };
187
188
 
188
189
  /**
@@ -694,8 +695,8 @@ export class InternalCall<T = any> {
694
695
  */
695
696
 
696
697
  export type UserHelperColorScheme = {
697
- primaryColor: string,
698
- secondaryColor: string,
698
+ primaryColor: string;
699
+ secondaryColor: string;
699
700
  };
700
701
 
701
702
  /**
@@ -708,6 +709,6 @@ export type UserHelperColorScheme = {
708
709
  */
709
710
 
710
711
  export type UserHelperOptions = {
711
- enabled: boolean,
712
- colorScheme: UserHelperColorScheme | undefined,
713
- };
712
+ enabled: boolean;
713
+ colorScheme: UserHelperColorScheme | undefined;
714
+ };
package/src/sdk/utils.ts CHANGED
@@ -18,7 +18,7 @@ export const handleAsyncCallback = (
18
18
  response: { success: boolean },
19
19
  resolve: PromiseResolve<void>,
20
20
  reject: PromiseReject,
21
- errorMessage: string
21
+ errorMessage: string,
22
22
  ) => {
23
23
  if (response?.success) {
24
24
  resolve();
@@ -40,7 +40,7 @@ export const handleAsyncCallback = (
40
40
 
41
41
  export const handleSyncCallback = (
42
42
  r: { success: boolean },
43
- errorMessage: string
43
+ errorMessage: string,
44
44
  ) => {
45
45
  if (r?.success) {
46
46
  return;
@@ -65,9 +65,9 @@ export const exceptionWrapper = <T>(
65
65
  onCallback: (r: { success: boolean }, errorMessage: string) => void;
66
66
  onSuccess: PromiseResolve<T>;
67
67
  onError: PromiseReject;
68
- }) => void
69
- ): T => {
70
- let returnValue: T;
68
+ }) => void,
69
+ ) => {
70
+ let returnValue: T | undefined;
71
71
  try {
72
72
  fn({
73
73
  onCallback: handleSyncCallback,
@@ -105,7 +105,7 @@ export const promiseWrapper = <T>(
105
105
  onCallback: (r: { success: boolean }, errorMessage: string) => void;
106
106
  onSuccess: PromiseResolve<T>;
107
107
  onError: PromiseReject;
108
- }) => void
108
+ }) => void,
109
109
  ) => {
110
110
  return new Promise<T>((resolve, reject) => {
111
111
  try {
@@ -124,14 +124,17 @@ export const promiseWrapper = <T>(
124
124
  logError(error);
125
125
  reject({
126
126
  code: ErrorCode.UNKNOWN,
127
- message: error?.message || "Unknown error.",
127
+ message:
128
+ typeof error === "object" && error !== null && "message" in error
129
+ ? error?.message
130
+ : "Unknown error.",
128
131
  type: ErrorType.NON_CRITICAL,
129
132
  });
130
133
  }
131
134
  });
132
135
  };
133
136
 
134
- export function locationStatusAdapter(statusName): string {
137
+ export function locationStatusAdapter(statusName: any): string {
135
138
  // The MapView will only understand status names declared at LocationStatusName and CALCULATING
136
139
  // is not one of them.
137
140
  // TODO: implement status & error adapter on native SDKs.
@@ -141,7 +144,7 @@ export function locationStatusAdapter(statusName): string {
141
144
  return statusName;
142
145
  }
143
146
 
144
- export function locationErrorAdapter(error): Error {
147
+ export function locationErrorAdapter(error: any): Error {
145
148
  let adaptedCode = ErrorCode.UNKNOWN;
146
149
  const adaptedMessage = error.message;
147
150
  const adaptedType = ErrorType.CRITICAL;
@@ -11,6 +11,6 @@ export const logError = __DEV__
11
11
  console.log(JSON.stringify(response));
12
12
  }
13
13
  }
14
- : function (_response) {
14
+ : function (_response: any) {
15
15
  // do nothing
16
16
  };