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

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 (139) 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 +50 -51
  7. package/lib/commonjs/sdk/index.js.map +1 -1
  8. package/lib/commonjs/sdk/internaDelegatedState.js +48 -0
  9. package/lib/commonjs/sdk/internaDelegatedState.js.map +1 -0
  10. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  11. package/lib/commonjs/sdk/types/constants.js +5 -0
  12. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  13. package/lib/commonjs/sdk/types/index.js +9 -0
  14. package/lib/commonjs/sdk/types/index.js.map +1 -1
  15. package/lib/commonjs/sdk/utils.js +3 -3
  16. package/lib/commonjs/sdk/utils.js.map +1 -1
  17. package/lib/commonjs/utils/index.js.map +1 -1
  18. package/lib/commonjs/utils/logError.js.map +1 -1
  19. package/lib/commonjs/wayfinding/components/MapView.js +9 -9
  20. package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
  21. package/lib/commonjs/wayfinding/hooks/index.js +11 -7
  22. package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
  23. package/lib/commonjs/wayfinding/index.js.map +1 -1
  24. package/lib/commonjs/wayfinding/store/index.js +13 -8
  25. package/lib/commonjs/wayfinding/store/index.js.map +1 -1
  26. package/lib/commonjs/wayfinding/store/utils.js.map +1 -1
  27. package/lib/commonjs/wayfinding/types/constants.js.map +1 -1
  28. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  29. package/lib/commonjs/wayfinding/utils/index.js +1 -0
  30. package/lib/commonjs/wayfinding/utils/index.js.map +1 -1
  31. package/lib/commonjs/wayfinding/utils/mapper.js +7 -9
  32. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  33. package/lib/module/index.js +2 -0
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/package.json +1 -0
  36. package/lib/module/sdk/index.js +52 -51
  37. package/lib/module/sdk/index.js.map +1 -1
  38. package/lib/module/sdk/internaDelegatedState.js +43 -0
  39. package/lib/module/sdk/internaDelegatedState.js.map +1 -0
  40. package/lib/module/sdk/nativeInterface.js +2 -0
  41. package/lib/module/sdk/nativeInterface.js.map +1 -1
  42. package/lib/module/sdk/types/constants.js +7 -0
  43. package/lib/module/sdk/types/constants.js.map +1 -1
  44. package/lib/module/sdk/types/index.js +11 -0
  45. package/lib/module/sdk/types/index.js.map +1 -1
  46. package/lib/module/sdk/utils.js +5 -3
  47. package/lib/module/sdk/utils.js.map +1 -1
  48. package/lib/module/utils/index.js +2 -0
  49. package/lib/module/utils/index.js.map +1 -1
  50. package/lib/module/utils/logError.js +2 -0
  51. package/lib/module/utils/logError.js.map +1 -1
  52. package/lib/module/wayfinding/components/MapView.js +11 -9
  53. package/lib/module/wayfinding/components/MapView.js.map +1 -1
  54. package/lib/module/wayfinding/hooks/index.js +13 -7
  55. package/lib/module/wayfinding/hooks/index.js.map +1 -1
  56. package/lib/module/wayfinding/index.js +2 -0
  57. package/lib/module/wayfinding/index.js.map +1 -1
  58. package/lib/module/wayfinding/store/index.js +15 -8
  59. package/lib/module/wayfinding/store/index.js.map +1 -1
  60. package/lib/module/wayfinding/store/utils.js +2 -0
  61. package/lib/module/wayfinding/store/utils.js.map +1 -1
  62. package/lib/module/wayfinding/types/constants.js +2 -0
  63. package/lib/module/wayfinding/types/constants.js.map +1 -1
  64. package/lib/module/wayfinding/types/index.js +2 -0
  65. package/lib/module/wayfinding/types/index.js.map +1 -1
  66. package/lib/module/wayfinding/utils/index.js +3 -0
  67. package/lib/module/wayfinding/utils/index.js.map +1 -1
  68. package/lib/module/wayfinding/utils/mapper.js +9 -9
  69. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  70. package/lib/typescript/index.d.ts.map +1 -0
  71. package/lib/typescript/{src/sdk → sdk}/index.d.ts +25 -32
  72. package/lib/typescript/sdk/index.d.ts.map +1 -0
  73. package/lib/typescript/sdk/internaDelegatedState.d.ts +17 -0
  74. package/lib/typescript/sdk/internaDelegatedState.d.ts.map +1 -0
  75. package/lib/typescript/{src/sdk → sdk}/nativeInterface.d.ts +4 -2
  76. package/lib/typescript/sdk/nativeInterface.d.ts.map +1 -0
  77. package/lib/typescript/sdk/types/constants.d.ts.map +1 -0
  78. package/lib/typescript/{src/sdk → sdk}/types/index.d.ts +2 -1
  79. package/lib/typescript/sdk/types/index.d.ts.map +1 -0
  80. package/lib/typescript/{src/sdk → sdk}/utils.d.ts +1 -1
  81. package/lib/typescript/sdk/utils.d.ts.map +1 -0
  82. package/lib/typescript/utils/index.d.ts.map +1 -0
  83. package/lib/typescript/utils/logError.d.ts.map +1 -0
  84. package/lib/typescript/{src/wayfinding → wayfinding}/components/MapView.d.ts +1 -1
  85. package/lib/typescript/wayfinding/components/MapView.d.ts.map +1 -0
  86. package/lib/typescript/wayfinding/hooks/index.d.ts.map +1 -0
  87. package/lib/typescript/wayfinding/index.d.ts.map +1 -0
  88. package/lib/typescript/{src/wayfinding → wayfinding}/store/index.d.ts +13 -13
  89. package/lib/typescript/wayfinding/store/index.d.ts.map +1 -0
  90. package/lib/typescript/{src/wayfinding → wayfinding}/store/utils.d.ts +0 -1
  91. package/lib/typescript/wayfinding/store/utils.d.ts.map +1 -0
  92. package/lib/typescript/wayfinding/types/constants.d.ts.map +1 -0
  93. package/lib/typescript/{src/wayfinding → wayfinding}/types/index.d.ts +1 -1
  94. package/lib/typescript/wayfinding/types/index.d.ts.map +1 -0
  95. package/lib/typescript/wayfinding/utils/index.d.ts +3 -0
  96. package/lib/typescript/wayfinding/utils/index.d.ts.map +1 -0
  97. package/lib/typescript/wayfinding/utils/mapper.d.ts.map +1 -0
  98. package/package.json +25 -36
  99. package/src/sdk/index.ts +67 -52
  100. package/src/sdk/internaDelegatedState.ts +54 -0
  101. package/src/sdk/nativeInterface.ts +31 -27
  102. package/src/sdk/types/index.ts +7 -6
  103. package/src/sdk/utils.ts +12 -9
  104. package/src/utils/logError.ts +1 -1
  105. package/src/wayfinding/components/MapView.tsx +103 -104
  106. package/src/wayfinding/hooks/index.ts +94 -91
  107. package/src/wayfinding/store/index.tsx +4 -4
  108. package/src/wayfinding/types/index.ts +1 -1
  109. package/src/wayfinding/utils/index.ts +2 -1
  110. package/LICENSE +0 -21
  111. package/README.md +0 -200
  112. package/SECURITY-POLICY.md +0 -9
  113. package/lib/typescript/src/index.d.ts.map +0 -1
  114. package/lib/typescript/src/sdk/index.d.ts.map +0 -1
  115. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +0 -1
  116. package/lib/typescript/src/sdk/types/constants.d.ts.map +0 -1
  117. package/lib/typescript/src/sdk/types/index.d.ts.map +0 -1
  118. package/lib/typescript/src/sdk/utils.d.ts.map +0 -1
  119. package/lib/typescript/src/utils/index.d.ts.map +0 -1
  120. package/lib/typescript/src/utils/logError.d.ts.map +0 -1
  121. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +0 -1
  122. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +0 -1
  123. package/lib/typescript/src/wayfinding/index.d.ts.map +0 -1
  124. package/lib/typescript/src/wayfinding/store/index.d.ts.map +0 -1
  125. package/lib/typescript/src/wayfinding/store/utils.d.ts.map +0 -1
  126. package/lib/typescript/src/wayfinding/types/constants.d.ts.map +0 -1
  127. package/lib/typescript/src/wayfinding/types/index.d.ts.map +0 -1
  128. package/lib/typescript/src/wayfinding/utils/index.d.ts +0 -3
  129. package/lib/typescript/src/wayfinding/utils/index.d.ts.map +0 -1
  130. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +0 -1
  131. package/security.txt +0 -4
  132. /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
  133. /package/lib/typescript/{src/sdk → sdk}/types/constants.d.ts +0 -0
  134. /package/lib/typescript/{src/utils → utils}/index.d.ts +0 -0
  135. /package/lib/typescript/{src/utils → utils}/logError.d.ts +0 -0
  136. /package/lib/typescript/{src/wayfinding → wayfinding}/hooks/index.d.ts +0 -0
  137. /package/lib/typescript/{src/wayfinding → wayfinding}/index.d.ts +0 -0
  138. /package/lib/typescript/{src/wayfinding → wayfinding}/types/constants.d.ts +0 -0
  139. /package/lib/typescript/{src/wayfinding → wayfinding}/utils/mapper.d.ts +0 -0
@@ -41,7 +41,7 @@ import { ErrorName } from "../types/constants";
41
41
  import { sendMessageToViewer } from "../utils";
42
42
  import ViewerMapper from "../utils/mapper";
43
43
  import { setError, setLocationStatus } from "../store";
44
- const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com";
44
+ const SITUM_BASE_DOMAIN = "https://maps.situm.com";
45
45
 
46
46
  const NETWORK_ERROR_CODE = {
47
47
  android: -2,
@@ -59,7 +59,7 @@ export type MapViewConfiguration = {
59
59
  */
60
60
  apiDomain?: string;
61
61
  /**
62
- * A String parameter that allows you to specify which domain will be displayed inside our webview. Defaults to "https://map-viewer.situm.com/".
62
+ * A String parameter that allows you to specify which domain will be displayed inside our webview. Defaults to "https://maps.situm.com/".
63
63
  * In most cases this parameter shouldn't be changed.
64
64
  */
65
65
  viewerDomain?: string;
@@ -157,16 +157,16 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
157
157
  onExternalLinkClicked = undefined,
158
158
  onFavoritePoisUpdated = () => {},
159
159
  },
160
- ref
160
+ ref,
161
161
  ) => {
162
- const webViewRef = useRef<WebView>();
162
+ const webViewRef = useRef<WebView>(null);
163
163
  const [_onDirectionsRequestInterceptor, setInterceptor] =
164
164
  useState<OnDirectionsRequestInterceptor>();
165
165
 
166
166
  // Local states
167
167
  const [mapLoaded, setMapLoaded] = useState<boolean>(false);
168
168
  const [buildingIdentifier, setBuildingIdentifier] = useState<string>(
169
- configuration.buildingIdentifier
169
+ configuration.buildingIdentifier,
170
170
  );
171
171
  const {
172
172
  init,
@@ -198,7 +198,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
198
198
 
199
199
  sendMessageToViewer(
200
200
  webViewRef.current,
201
- ViewerMapper.navigateToPoi(payload)
201
+ ViewerMapper.navigateToPoi(payload),
202
202
  );
203
203
  }, []);
204
204
 
@@ -213,7 +213,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
213
213
 
214
214
  sendMessageToViewer(
215
215
  webViewRef.current,
216
- ViewerMapper.navigateToCar(payload)
216
+ ViewerMapper.navigateToCar(payload),
217
217
  );
218
218
  }, []);
219
219
 
@@ -226,7 +226,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
226
226
 
227
227
  sendMessageToViewer(
228
228
  webViewRef.current,
229
- ViewerMapper.navigateToPoint(payload)
229
+ ViewerMapper.navigateToPoint(payload),
230
230
  );
231
231
  }, []);
232
232
 
@@ -253,13 +253,13 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
253
253
  }
254
254
  if (SitumPlugin.navigationIsRunning()) {
255
255
  console.error(
256
- "Situm > hook > Navigation on course, poi category selection is unavailable"
256
+ "Situm > hook > Navigation on course, poi category selection is unavailable",
257
257
  );
258
258
  return;
259
259
  }
260
260
  sendMessageToViewer(
261
261
  webViewRef.current,
262
- ViewerMapper.selectPoiCategory(categoryId)
262
+ ViewerMapper.selectPoiCategory(categoryId),
263
263
  );
264
264
  }, []);
265
265
 
@@ -270,16 +270,16 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
270
270
  }
271
271
  if (SitumPlugin.navigationIsRunning()) {
272
272
  console.error(
273
- "Situm > hook > Navigation on course, floor selection is unavailable"
273
+ "Situm > hook > Navigation on course, floor selection is unavailable",
274
274
  );
275
275
  return;
276
276
  }
277
277
  sendMessageToViewer(
278
278
  webViewRef.current,
279
- ViewerMapper.selectFloor(floorId, options)
279
+ ViewerMapper.selectFloor(floorId, options),
280
280
  );
281
281
  },
282
- []
282
+ [],
283
283
  );
284
284
 
285
285
  const _search = useCallback((payload: SearchFilter) => {
@@ -293,10 +293,10 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
293
293
  }
294
294
  sendMessageToViewer(
295
295
  webViewRef.current,
296
- ViewerMapper.setDirectionsOptions(directionsOptions)
296
+ ViewerMapper.setDirectionsOptions(directionsOptions),
297
297
  );
298
298
  },
299
- []
299
+ [],
300
300
  );
301
301
 
302
302
  const _setFavoritePois = useCallback((poiIds: number[]) => {
@@ -305,7 +305,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
305
305
  }
306
306
  sendMessageToViewer(
307
307
  webViewRef.current,
308
- ViewerMapper.setFavoritePois(poiIds)
308
+ ViewerMapper.setFavoritePois(poiIds),
309
309
  );
310
310
  }, []);
311
311
 
@@ -313,14 +313,14 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
313
313
  if (locationStatus) {
314
314
  sendMessageToViewer(
315
315
  webViewRef.current,
316
- ViewerMapper.locationStatus(locationStatus)
316
+ ViewerMapper.locationStatus(locationStatus),
317
317
  );
318
318
  }
319
319
  if (error) {
320
320
  // Right now, status and errors share message on the viewer:
321
321
  sendMessageToViewer(
322
322
  webViewRef.current,
323
- ViewerMapper.locationError(error)
323
+ ViewerMapper.locationError(error),
324
324
  );
325
325
  }
326
326
  };
@@ -339,81 +339,77 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
339
339
  * onLoad={onLoad} />
340
340
  */
341
341
 
342
- useImperativeHandle(
343
- ref,
344
- () => {
345
- return {
346
- followUser() {
347
- _followUser(true);
348
- },
349
- unfollowUser() {
350
- _followUser(false);
351
- },
352
- selectPoi(poiId: number) {
353
- _selectPoi(poiId);
354
- },
355
- selectCar() {
356
- _selectCar();
357
- },
358
- selectPoiCategory(poiId: number) {
359
- _selectPoiCategory(poiId);
360
- },
361
- selectFloor(poiId: number, options?: CartographySelectionOptions) {
362
- _selectFloor(poiId, options);
363
- },
364
- setDirectionsOptions(directionsOptions: MapViewDirectionsOptions) {
365
- _setDirectionsOptions(directionsOptions);
366
- },
367
- setFavoritePois(poiIds: number[]) {
368
- _setFavoritePois(poiIds);
369
- },
370
- deselectPoi() {
371
- webViewRef.current &&
372
- sendMessageToViewer(
373
- webViewRef.current,
374
- ViewerMapper.selectPoi(null)
375
- );
376
- },
377
- navigateToPoi(payload): void {
378
- _navigateToPoi(payload);
379
- },
380
- navigateToCar(payload): void {
381
- _navigateToCar(payload);
382
- },
383
- navigateToPoint(payload: NavigateToPointPayload): void {
384
- _navigateToPoint(payload);
385
- },
386
- setOnDirectionsRequestInterceptor(directionRequestInterceptor): void {
387
- setInterceptor(() => directionRequestInterceptor);
388
- },
389
- cancelNavigation(): void {
390
- if (!webViewRef.current) return;
391
- stopNavigation();
342
+ useImperativeHandle(ref, () => {
343
+ return {
344
+ followUser() {
345
+ _followUser(true);
346
+ },
347
+ unfollowUser() {
348
+ _followUser(false);
349
+ },
350
+ selectPoi(poiId: number) {
351
+ _selectPoi(poiId);
352
+ },
353
+ selectCar() {
354
+ _selectCar();
355
+ },
356
+ selectPoiCategory(poiId: number) {
357
+ _selectPoiCategory(poiId);
358
+ },
359
+ selectFloor(poiId: number, options?: CartographySelectionOptions) {
360
+ _selectFloor(poiId, options);
361
+ },
362
+ setDirectionsOptions(directionsOptions: MapViewDirectionsOptions) {
363
+ _setDirectionsOptions(directionsOptions);
364
+ },
365
+ setFavoritePois(poiIds: number[]) {
366
+ _setFavoritePois(poiIds);
367
+ },
368
+ deselectPoi() {
369
+ webViewRef.current &&
392
370
  sendMessageToViewer(
393
371
  webViewRef.current,
394
- ViewerMapper.cancelNavigation()
372
+ ViewerMapper.selectPoi(null),
395
373
  );
396
- },
397
- search(payload): void {
398
- _search(payload);
399
- },
400
- };
401
- },
402
- [
403
- stopNavigation,
404
- _navigateToPoi,
405
- _followUser,
406
- _navigateToCar,
407
- _navigateToPoint,
408
- _selectPoi,
409
- _selectCar,
410
- _selectPoiCategory,
411
- _selectFloor,
412
- _setDirectionsOptions,
413
- _setFavoritePois,
414
- _search,
415
- ]
416
- );
374
+ },
375
+ navigateToPoi(payload): void {
376
+ _navigateToPoi(payload);
377
+ },
378
+ navigateToCar(payload): void {
379
+ _navigateToCar(payload);
380
+ },
381
+ navigateToPoint(payload: NavigateToPointPayload): void {
382
+ _navigateToPoint(payload);
383
+ },
384
+ setOnDirectionsRequestInterceptor(directionRequestInterceptor): void {
385
+ setInterceptor(() => directionRequestInterceptor);
386
+ },
387
+ cancelNavigation(): void {
388
+ if (!webViewRef.current) return;
389
+ stopNavigation();
390
+ sendMessageToViewer(
391
+ webViewRef.current,
392
+ ViewerMapper.cancelNavigation(),
393
+ );
394
+ },
395
+ search(payload): void {
396
+ _search(payload);
397
+ },
398
+ };
399
+ }, [
400
+ stopNavigation,
401
+ _navigateToPoi,
402
+ _followUser,
403
+ _navigateToCar,
404
+ _navigateToPoint,
405
+ _selectPoi,
406
+ _selectCar,
407
+ _selectPoiCategory,
408
+ _selectFloor,
409
+ _setDirectionsOptions,
410
+ _setFavoritePois,
411
+ _search,
412
+ ]);
417
413
 
418
414
  useEffect(() => {
419
415
  SitumPlugin.validateMapViewProjectSettings();
@@ -426,7 +422,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
426
422
 
427
423
  console.error(
428
424
  "Error code:",
429
- error.code ? error.code : " no code provided"
425
+ error.code ? error.code : " no code provided",
430
426
  );
431
427
  console.error("Error detected:", error.message);
432
428
  }, [error]);
@@ -444,7 +440,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
444
440
 
445
441
  sendMessageToViewer(
446
442
  webViewRef.current,
447
- ViewerMapper.locationStatus(locationStatus)
443
+ ViewerMapper.locationStatus(locationStatus),
448
444
  );
449
445
  // Callbacks used in `useEffect` won't be invoked if the value of locationStatus
450
446
  // is set but hasn't changed. Set locationStatus to null always to avoid missing
@@ -458,7 +454,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
458
454
 
459
455
  sendMessageToViewer(
460
456
  webViewRef.current,
461
- ViewerMapper.locationError(error)
457
+ ViewerMapper.locationError(error),
462
458
  );
463
459
  // Callbacks used in `useEffect` won't be invoked if the value of locationStatus
464
460
  // is set but hasn't changed. Set locationStatus to null always to avoid missing
@@ -472,7 +468,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
472
468
 
473
469
  sendMessageToViewer(
474
470
  webViewRef.current,
475
- ViewerMapper.navigation(navigation)
471
+ ViewerMapper.navigation(navigation),
476
472
  );
477
473
  }, [navigation, mapLoaded]);
478
474
 
@@ -489,7 +485,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
489
485
 
490
486
  sendMessageToViewer(
491
487
  webViewRef.current,
492
- ViewerMapper.setLanguage(configuration.language)
488
+ ViewerMapper.setLanguage(configuration.language),
493
489
  );
494
490
  }, [configuration.language, mapLoaded]);
495
491
 
@@ -498,7 +494,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
498
494
  if (webViewRef.current && mapLoaded) {
499
495
  sendMessageToViewer(
500
496
  webViewRef.current,
501
- ViewerMapper.initialConfiguration(style)
497
+ ViewerMapper.initialConfiguration(style),
502
498
  );
503
499
  }
504
500
  }, [webViewRef, mapLoaded, style]);
@@ -565,7 +561,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
565
561
  }
566
562
  };
567
563
 
568
- const _onShouldStartLoadWithRequest = (request) => {
564
+ const _onShouldStartLoadWithRequest = (request: any) => {
569
565
  if (
570
566
  request &&
571
567
  request.url &&
@@ -586,23 +582,26 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
586
582
 
587
583
  const _effectiveProfile = () => {
588
584
  let effectiveProfile = configuration.profile;
589
- if (configuration.remoteIdentifier && configuration.remoteIdentifier.length > 0) {
590
- console.warn('Situm> MapView> [!] "remoteIdentifier" is deprecated. Use "profile" instead.');
585
+ if (
586
+ configuration.remoteIdentifier &&
587
+ configuration.remoteIdentifier.length > 0
588
+ ) {
589
+ console.warn(
590
+ 'Situm> MapView> [!] "remoteIdentifier" is deprecated. Use "profile" instead.',
591
+ );
591
592
  if (!configuration.profile || configuration.profile.length == 0) {
592
593
  effectiveProfile = configuration.remoteIdentifier;
593
594
  }
594
595
  }
595
596
  return effectiveProfile;
596
- }
597
+ };
597
598
 
598
599
  return (
599
600
  <WebView
600
601
  ref={webViewRef}
601
602
  source={{
602
603
  uri: `${configuration.viewerDomain || SITUM_BASE_DOMAIN}/${
603
- _effectiveProfile()
604
- ? `id/${_effectiveProfile()}`
605
- : ""
604
+ _effectiveProfile() ? `id/${_effectiveProfile()}` : ""
606
605
  }?&apikey=${
607
606
  configuration.situmApiKey
608
607
  }&wl=true&global=true&mode=embed${
@@ -638,7 +637,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
638
637
  }}
639
638
  />
640
639
  );
641
- }
640
+ },
642
641
  );
643
642
 
644
643
  export default MapView;
@@ -62,98 +62,96 @@ export const useSitumInternal = () => {
62
62
  };
63
63
 
64
64
  function registerCallbacks() {
65
- SitumPlugin.internalSetMethodCallMapDelegate((internalCall: InternalCall) => {
66
- switch(internalCall.type) {
67
- case InternalCallType.LOCATION:
68
- let location = internalCall.get<Location>();
69
- dispatch(
70
- setLocation({
71
- ...location,
72
- })
73
- );
74
- break;
75
- case InternalCallType.LOCATION_STATUS:
76
- let statusName = internalCall.get<string>();
77
- if (statusName in LocationStatusName) {
65
+ SitumPlugin.internalSetMethodCallMapDelegate(
66
+ (internalCall: InternalCall) => {
67
+ switch (internalCall.type) {
68
+ case InternalCallType.LOCATION:
69
+ let location = internalCall.get<Location>();
78
70
  dispatch(
79
- setLocationStatus(statusName)
71
+ setLocation({
72
+ ...location,
73
+ }),
80
74
  );
81
- }
82
- break;
83
- case InternalCallType.LOCATION_STOPPED:
84
- // TODO: LOCATION_STOPPED exists only in RN, delete!
85
- dispatch(resetLocation());
86
- break;
87
- case InternalCallType.LOCATION_ERROR:
88
- let error = internalCall.get<Error>();
89
- dispatch(
90
- setError(error)
91
- );
92
- break;
93
- case InternalCallType.NAVIGATION_START:
94
- dispatch(
95
- setNavigation({
96
- type: NavigationUpdateType.PROGRESS,
97
- status: NavigationStatus.START,
98
- })
99
- );
100
- break;
101
- case InternalCallType.NAVIGATION_DESTINATION_REACHED:
102
- dispatch(
103
- setNavigation({
104
- type: NavigationUpdateType.DESTINATION_REACHED,
105
- status: NavigationStatus.UPDATE,
106
- })
107
- );
108
- break;
109
- case InternalCallType.NAVIGATION_PROGRESS:
110
- let progress = internalCall.get<NavigationProgress>();
111
- dispatch(
112
- setNavigation({
113
- currentIndication: progress?.currentIndication,
114
- routeStep: progress?.routeStep,
115
- distanceToGoal: progress?.distanceToGoal,
116
- points: progress?.points,
117
- type: NavigationUpdateType.PROGRESS,
118
- segments: progress?.segments,
119
- status: NavigationStatus.UPDATE,
120
- })
121
- );
122
- break;
123
- case InternalCallType.NAVIGATION_OUT_OF_ROUTE:
124
- dispatch(
125
- setNavigation({
126
- type: NavigationUpdateType.OUT_OF_ROUTE,
127
- status: NavigationStatus.UPDATE,
128
- })
129
- );
130
- break;
131
- case InternalCallType.NAVIGATION_CANCELLATION:
132
- dispatch(
133
- setNavigation({
134
- type: NavigationUpdateType.CANCELLED,
135
- status: NavigationStatus.STOP,
136
- })
137
- );
138
- break;
139
- case InternalCallType.NAVIGATION_ERROR:
140
- case InternalCallType.GEOFENCES_ENTER:
141
- case InternalCallType.GEOFENCES_EXIT:
142
- // Do nothing.
143
- break;
144
- }
145
- });
75
+ break;
76
+ case InternalCallType.LOCATION_STATUS:
77
+ let statusName = internalCall.get<string>();
78
+ if (statusName in LocationStatusName) {
79
+ dispatch(setLocationStatus(statusName));
80
+ }
81
+ break;
82
+ case InternalCallType.LOCATION_STOPPED:
83
+ // TODO: LOCATION_STOPPED exists only in RN, delete!
84
+ dispatch(resetLocation());
85
+ break;
86
+ case InternalCallType.LOCATION_ERROR:
87
+ let error = internalCall.get<Error>();
88
+ dispatch(setError(error));
89
+ break;
90
+ case InternalCallType.NAVIGATION_START:
91
+ dispatch(
92
+ setNavigation({
93
+ type: NavigationUpdateType.PROGRESS,
94
+ status: NavigationStatus.START,
95
+ }),
96
+ );
97
+ break;
98
+ case InternalCallType.NAVIGATION_DESTINATION_REACHED:
99
+ dispatch(
100
+ setNavigation({
101
+ type: NavigationUpdateType.DESTINATION_REACHED,
102
+ status: NavigationStatus.UPDATE,
103
+ }),
104
+ );
105
+ break;
106
+ case InternalCallType.NAVIGATION_PROGRESS:
107
+ let progress = internalCall.get<NavigationProgress>();
108
+ dispatch(
109
+ setNavigation({
110
+ currentIndication: progress?.currentIndication,
111
+ routeStep: progress?.routeStep,
112
+ distanceToGoal: progress?.distanceToGoal,
113
+ points: progress?.points,
114
+ type: NavigationUpdateType.PROGRESS,
115
+ segments: progress?.segments,
116
+ status: NavigationStatus.UPDATE,
117
+ }),
118
+ );
119
+ break;
120
+ case InternalCallType.NAVIGATION_OUT_OF_ROUTE:
121
+ dispatch(
122
+ setNavigation({
123
+ type: NavigationUpdateType.OUT_OF_ROUTE,
124
+ status: NavigationStatus.UPDATE,
125
+ }),
126
+ );
127
+ break;
128
+ case InternalCallType.NAVIGATION_CANCELLATION:
129
+ dispatch(
130
+ setNavigation({
131
+ type: NavigationUpdateType.CANCELLED,
132
+ status: NavigationStatus.STOP,
133
+ }),
134
+ );
135
+ break;
136
+ case InternalCallType.NAVIGATION_ERROR:
137
+ case InternalCallType.GEOFENCES_ENTER:
138
+ case InternalCallType.GEOFENCES_EXIT:
139
+ // Do nothing.
140
+ break;
141
+ }
142
+ },
143
+ );
146
144
  }
147
145
 
148
146
  const calculateRoute = async (
149
147
  payload: any,
150
148
  interceptor?: OnDirectionsRequestInterceptor,
151
- updateRoute = true
149
+ updateRoute = true,
152
150
  ) => {
153
151
  console.debug("Situm > hook > calculating route");
154
152
 
155
153
  const directionsRequest = createDirectionsRequest(
156
- payload.directionsRequest
154
+ payload.directionsRequest,
157
155
  );
158
156
  interceptor && interceptor(directionsRequest);
159
157
  const {
@@ -170,12 +168,17 @@ export const useSitumInternal = () => {
170
168
 
171
169
  const _buildings = await SitumPlugin.fetchBuildings();
172
170
  const _building = _buildings.find(
173
- (b: Building) => b.buildingIdentifier === buildingIdentifier
171
+ (b: Building) => b.buildingIdentifier === buildingIdentifier,
174
172
  );
175
173
 
174
+ if (!_building) {
175
+ console.debug(`Situm > hook > Could not compute route: missing building`);
176
+ return;
177
+ }
178
+
176
179
  if (!to || !from || lockDirections) {
177
180
  console.debug(
178
- `Situm > hook > Could not compute route (to: ${to}, from: ${from}, lockDirections: ${lockDirections})`
181
+ `Situm > hook > Could not compute route (to: ${to}, from: ${from}, lockDirections: ${lockDirections})`,
179
182
  );
180
183
  return;
181
184
  }
@@ -213,7 +216,7 @@ export const useSitumInternal = () => {
213
216
  // Navigation
214
217
  const startNavigation = (
215
218
  payload: any,
216
- interceptor?: OnDirectionsRequestInterceptor
219
+ interceptor?: OnDirectionsRequestInterceptor,
217
220
  ) => {
218
221
  console.debug("Situm > hook > request to start navigation");
219
222
  // TODO: we should delegate this to the sdk plugin
@@ -232,11 +235,11 @@ export const useSitumInternal = () => {
232
235
  status: NavigationStatus.START,
233
236
  type: NavigationUpdateType.PROGRESS,
234
237
  ...r,
235
- })
238
+ }),
236
239
  );
237
240
  try {
238
241
  const navigationRequest = createNavigationRequest(
239
- payload.navigationRequest
242
+ payload.navigationRequest,
240
243
  );
241
244
  SitumPlugin.requestNavigationUpdates({
242
245
  ...defaultNavigationRequest,
@@ -250,7 +253,7 @@ export const useSitumInternal = () => {
250
253
  message: "Could not update navigation",
251
254
  code: ErrorCode.UNKNOWN,
252
255
  type: ErrorType.NON_CRITICAL,
253
- } as Error)
256
+ } as Error),
254
257
  );
255
258
  stopNavigation();
256
259
  }
@@ -258,8 +261,8 @@ export const useSitumInternal = () => {
258
261
  .catch((e) => {
259
262
  console.error(
260
263
  `Situm > hook > Could not compute route for navigation ${JSON.stringify(
261
- e
262
- )}`
264
+ e,
265
+ )}`,
263
266
  );
264
267
  });
265
268
  };
@@ -279,8 +282,8 @@ export const useSitumInternal = () => {
279
282
  .catch((e) => {
280
283
  console.warn(
281
284
  `Situm > hook > Could not remove navigation updates ${JSON.stringify(
282
- e
283
- )}`
285
+ e,
286
+ )}`,
284
287
  );
285
288
  });
286
289
  };
@@ -19,13 +19,13 @@ interface User {
19
19
  }
20
20
 
21
21
  export interface State {
22
- webViewRef: MutableRefObject<undefined>;
22
+ webViewRef: MutableRefObject<undefined> | undefined;
23
23
  sdkInitialized: boolean;
24
24
  user?: User;
25
25
  location?: Location;
26
26
  locationStatus?: LocationStatusName;
27
27
  buildings: Building[] | null;
28
- currentBuilding: Building;
28
+ currentBuilding: Building | undefined;
29
29
  pois: Poi[];
30
30
  directions?: Directions;
31
31
  navigation?: NavigationProgress;
@@ -38,8 +38,8 @@ export const initialState: State = {
38
38
  webViewRef: undefined,
39
39
  sdkInitialized: false,
40
40
  user: undefined,
41
- location: null,
42
- locationStatus: null,
41
+ location: undefined,
42
+ locationStatus: undefined,
43
43
  buildings: null,
44
44
  currentBuilding: undefined,
45
45
  pois: [],
@@ -1,4 +1,4 @@
1
- import { AccessibilityMode } from "src/sdk";
1
+ import { AccessibilityMode } from "../../sdk/types/constants";
2
2
 
3
3
  import type { DirectionsRequest, Point } from "../../sdk/types";
4
4
  export type { MapViewConfiguration, MapViewProps } from "../components/MapView";
@@ -1,5 +1,6 @@
1
1
  import WebView from "react-native-webview";
2
2
 
3
- export const sendMessageToViewer = (viewer: WebView, message: string) => {
3
+ export const sendMessageToViewer = (viewer: WebView | null, message: string) => {
4
+ if (!viewer) return;
4
5
  viewer.injectJavaScript(`window.postMessage(${message})`);
5
6
  };