@situm/react-native 3.15.0-beta.0 → 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.
- package/android/src/main/java/com/situm/plugin/PluginHelper.java +1 -1
- package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
- package/ios/SitumPlugin.m +18 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/sdk/index.js.map +1 -1
- package/lib/commonjs/sdk/internaDelegatedState.js.map +1 -0
- package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
- package/lib/commonjs/sdk/types/constants.js.map +1 -1
- package/lib/commonjs/sdk/types/index.js.map +1 -1
- package/lib/commonjs/sdk/utils.js.map +1 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/logError.js.map +1 -1
- package/lib/commonjs/wayfinding/index.js.map +1 -1
- package/lib/commonjs/wayfinding/types/index.js.map +1 -1
- package/lib/commonjs/wayfinding/utils/index.js.map +1 -1
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/sdk/index.js.map +0 -1
- package/lib/module/sdk/internaDelegatedState.js.map +1 -0
- package/lib/module/sdk/nativeInterface.js.map +1 -1
- package/lib/module/sdk/types/constants.js.map +1 -1
- package/lib/module/sdk/types/index.js.map +1 -1
- package/lib/module/sdk/utils.js.map +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/logError.js.map +0 -1
- package/lib/module/wayfinding/index.js.map +1 -1
- package/lib/module/wayfinding/types/constants.js.map +1 -1
- package/lib/module/wayfinding/types/index.js.map +0 -1
- package/lib/module/wayfinding/utils/index.js.map +1 -1
- package/lib/module/wayfinding/utils/mapper.js.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/{src/sdk → sdk}/index.d.ts +25 -32
- package/lib/typescript/sdk/index.d.ts.map +1 -0
- package/lib/typescript/sdk/internaDelegatedState.d.ts +17 -0
- package/lib/typescript/sdk/internaDelegatedState.d.ts.map +1 -0
- package/lib/typescript/{src/sdk → sdk}/nativeInterface.d.ts +4 -2
- package/lib/typescript/sdk/nativeInterface.d.ts.map +1 -0
- package/lib/typescript/sdk/types/constants.d.ts.map +1 -0
- package/lib/typescript/{src/sdk → sdk}/types/index.d.ts +2 -1
- package/lib/typescript/sdk/types/index.d.ts.map +1 -0
- package/lib/typescript/{src/sdk → sdk}/utils.d.ts +1 -1
- package/lib/typescript/sdk/utils.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/logError.d.ts.map +1 -0
- package/lib/typescript/{src/wayfinding → wayfinding}/components/MapView.d.ts +1 -1
- package/lib/typescript/wayfinding/components/MapView.d.ts.map +1 -0
- package/lib/typescript/wayfinding/hooks/index.d.ts.map +1 -0
- package/lib/typescript/wayfinding/index.d.ts.map +1 -0
- package/lib/typescript/{src/wayfinding → wayfinding}/store/index.d.ts +13 -13
- package/lib/typescript/wayfinding/store/index.d.ts.map +1 -0
- package/lib/typescript/{src/wayfinding → wayfinding}/store/utils.d.ts +0 -1
- package/lib/typescript/wayfinding/store/utils.d.ts.map +1 -0
- package/lib/typescript/wayfinding/types/constants.d.ts.map +1 -0
- package/lib/typescript/{src/wayfinding → wayfinding}/types/index.d.ts +1 -1
- package/lib/typescript/wayfinding/types/index.d.ts.map +1 -0
- package/lib/typescript/wayfinding/utils/index.d.ts +3 -0
- package/lib/typescript/wayfinding/utils/index.d.ts.map +1 -0
- package/lib/typescript/wayfinding/utils/mapper.d.ts.map +1 -0
- package/package.json +24 -35
- package/src/sdk/index.ts +67 -52
- package/src/sdk/internaDelegatedState.ts +54 -0
- package/src/sdk/nativeInterface.ts +31 -27
- package/src/sdk/types/index.ts +7 -6
- package/src/sdk/utils.ts +12 -9
- package/src/utils/logError.ts +1 -1
- package/src/wayfinding/components/MapView.tsx +103 -104
- package/src/wayfinding/hooks/index.ts +94 -91
- package/src/wayfinding/store/index.tsx +4 -4
- package/src/wayfinding/types/index.ts +1 -1
- package/src/wayfinding/utils/index.ts +2 -1
- package/LICENSE +0 -21
- package/README.md +0 -200
- package/SECURITY-POLICY.md +0 -9
- package/lib/commonjs/index.js +0 -73
- package/lib/commonjs/sdk/index.js +0 -932
- package/lib/commonjs/sdk/nativeInterface.js +0 -20
- package/lib/commonjs/sdk/types/constants.js +0 -68
- package/lib/commonjs/sdk/types/index.js +0 -405
- package/lib/commonjs/sdk/utils.js +0 -156
- package/lib/commonjs/utils/index.js +0 -17
- package/lib/commonjs/utils/logError.js +0 -21
- package/lib/commonjs/wayfinding/components/MapView.js +0 -389
- package/lib/commonjs/wayfinding/components/MapView.js.map +0 -1
- package/lib/commonjs/wayfinding/hooks/index.js +0 -229
- package/lib/commonjs/wayfinding/hooks/index.js.map +0 -1
- package/lib/commonjs/wayfinding/index.js +0 -57
- package/lib/commonjs/wayfinding/store/index.js +0 -242
- package/lib/commonjs/wayfinding/store/index.js.map +0 -1
- package/lib/commonjs/wayfinding/store/utils.js +0 -49
- package/lib/commonjs/wayfinding/store/utils.js.map +0 -1
- package/lib/commonjs/wayfinding/types/constants.js +0 -13
- package/lib/commonjs/wayfinding/types/constants.js.map +0 -1
- package/lib/commonjs/wayfinding/types/index.js +0 -6
- package/lib/commonjs/wayfinding/utils/index.js +0 -11
- package/lib/commonjs/wayfinding/utils/mapper.js +0 -206
- package/lib/module/index.js +0 -12
- package/lib/module/sdk/index.js +0 -903
- package/lib/module/sdk/nativeInterface.js +0 -18
- package/lib/module/sdk/types/constants.js +0 -63
- package/lib/module/sdk/types/index.js +0 -434
- package/lib/module/sdk/utils.js +0 -144
- package/lib/module/utils/index.js +0 -2
- package/lib/module/utils/logError.js +0 -15
- package/lib/module/wayfinding/components/MapView.js +0 -379
- package/lib/module/wayfinding/components/MapView.js.map +0 -1
- package/lib/module/wayfinding/hooks/index.js +0 -220
- package/lib/module/wayfinding/hooks/index.js.map +0 -1
- package/lib/module/wayfinding/index.js +0 -13
- package/lib/module/wayfinding/store/index.js +0 -206
- package/lib/module/wayfinding/store/index.js.map +0 -1
- package/lib/module/wayfinding/store/utils.js +0 -38
- package/lib/module/wayfinding/store/utils.js.map +0 -1
- package/lib/module/wayfinding/types/constants.js +0 -7
- package/lib/module/wayfinding/types/index.js +0 -2
- package/lib/module/wayfinding/utils/index.js +0 -4
- package/lib/module/wayfinding/utils/mapper.js +0 -195
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/sdk/index.d.ts.map +0 -1
- package/lib/typescript/src/sdk/nativeInterface.d.ts.map +0 -1
- package/lib/typescript/src/sdk/types/constants.d.ts.map +0 -1
- package/lib/typescript/src/sdk/types/index.d.ts.map +0 -1
- package/lib/typescript/src/sdk/utils.d.ts.map +0 -1
- package/lib/typescript/src/utils/index.d.ts.map +0 -1
- package/lib/typescript/src/utils/logError.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/index.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/store/utils.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/types/constants.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/types/index.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/utils/index.d.ts +0 -3
- package/lib/typescript/src/wayfinding/utils/index.d.ts.map +0 -1
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +0 -1
- package/security.txt +0 -4
- /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/typescript/{src/sdk → sdk}/types/constants.d.ts +0 -0
- /package/lib/typescript/{src/utils → utils}/index.d.ts +0 -0
- /package/lib/typescript/{src/utils → utils}/logError.d.ts +0 -0
- /package/lib/typescript/{src/wayfinding → wayfinding}/hooks/index.d.ts +0 -0
- /package/lib/typescript/{src/wayfinding → wayfinding}/index.d.ts +0 -0
- /package/lib/typescript/{src/wayfinding → wayfinding}/types/constants.d.ts +0 -0
- /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://
|
|
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://
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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.
|
|
372
|
+
ViewerMapper.selectPoi(null),
|
|
395
373
|
);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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 (
|
|
590
|
-
|
|
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(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
71
|
+
setLocation({
|
|
72
|
+
...location,
|
|
73
|
+
}),
|
|
80
74
|
);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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:
|
|
42
|
-
locationStatus:
|
|
41
|
+
location: undefined,
|
|
42
|
+
locationStatus: undefined,
|
|
43
43
|
buildings: null,
|
|
44
44
|
currentBuilding: undefined,
|
|
45
45
|
pois: [],
|
|
@@ -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
|
};
|