@situm/react-native 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +656 -0
- package/ReactNativeSitumPlugin.podspec +22 -0
- package/SECURITY-POLICY.md +9 -0
- package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.4/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/codeStyles/Project.xml +116 -0
- package/android/.idea/encodings.xml +6 -0
- package/android/.idea/misc.xml +31 -0
- package/android/.idea/sonarlint/issuestore/index.pb +15 -0
- package/android/.project +34 -0
- package/android/build.gradle +45 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/situm/plugin/PluginHelper.java +989 -0
- package/android/src/main/java/com/situm/plugin/SitumMapper.java +1206 -0
- package/android/src/main/java/com/situm/plugin/SitumPackage.java +29 -0
- package/android/src/main/java/com/situm/plugin/SitumPlugin.java +84 -0
- package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +344 -0
- package/android/src/main/java/com/situm/plugin/utils/ReactNativeJson.java +122 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +9 -0
- package/ios/Constants.h +14 -0
- package/ios/Constants.m +14 -0
- package/ios/RNSitumReactNativePlugin.xcodeproj/project.pbxproj +272 -0
- package/ios/SitumLocationWrapper.h +112 -0
- package/ios/SitumLocationWrapper.m +1132 -0
- package/ios/SitumPlugin.h +15 -0
- package/ios/SitumPlugin.m +911 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/sdk/index.js +399 -0
- package/lib/commonjs/sdk/index.js.map +1 -0
- package/lib/commonjs/sdk/nativeInterface.js +20 -0
- package/lib/commonjs/sdk/nativeInterface.js.map +1 -0
- package/lib/commonjs/sdk/types/index.d.js +6 -0
- package/lib/commonjs/sdk/types/index.d.js.map +1 -0
- package/lib/commonjs/sdk/utils.js +22 -0
- package/lib/commonjs/sdk/utils.js.map +1 -0
- package/lib/commonjs/utils/requestPermission.js +73 -0
- package/lib/commonjs/utils/requestPermission.js.map +1 -0
- package/lib/commonjs/wayfinding/components/MapView.js +220 -0
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -0
- package/lib/commonjs/wayfinding/hooks/index.js +401 -0
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -0
- package/lib/commonjs/wayfinding/index.js +45 -0
- package/lib/commonjs/wayfinding/index.js.map +1 -0
- package/lib/commonjs/wayfinding/store/index.js +237 -0
- package/lib/commonjs/wayfinding/store/index.js.map +1 -0
- package/lib/commonjs/wayfinding/store/utils.js +44 -0
- package/lib/commonjs/wayfinding/store/utils.js.map +1 -0
- package/lib/commonjs/wayfinding/styles/colors.js +18 -0
- package/lib/commonjs/wayfinding/styles/colors.js.map +1 -0
- package/lib/commonjs/wayfinding/types/index.d.js +6 -0
- package/lib/commonjs/wayfinding/types/index.d.js.map +1 -0
- package/lib/commonjs/wayfinding/utils/index.js +11 -0
- package/lib/commonjs/wayfinding/utils/index.js.map +1 -0
- package/lib/commonjs/wayfinding/utils/mapper.js +106 -0
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/sdk/index.js +390 -0
- package/lib/module/sdk/index.js.map +1 -0
- package/lib/module/sdk/nativeInterface.js +18 -0
- package/lib/module/sdk/nativeInterface.js.map +1 -0
- package/lib/module/sdk/types/index.d.js +2 -0
- package/lib/module/sdk/types/index.d.js.map +1 -0
- package/lib/module/sdk/utils.js +15 -0
- package/lib/module/sdk/utils.js.map +1 -0
- package/lib/module/utils/requestPermission.js +67 -0
- package/lib/module/utils/requestPermission.js.map +1 -0
- package/lib/module/wayfinding/components/MapView.js +207 -0
- package/lib/module/wayfinding/components/MapView.js.map +1 -0
- package/lib/module/wayfinding/hooks/index.js +392 -0
- package/lib/module/wayfinding/hooks/index.js.map +1 -0
- package/lib/module/wayfinding/index.js +12 -0
- package/lib/module/wayfinding/index.js.map +1 -0
- package/lib/module/wayfinding/store/index.js +202 -0
- package/lib/module/wayfinding/store/index.js.map +1 -0
- package/lib/module/wayfinding/store/utils.js +34 -0
- package/lib/module/wayfinding/store/utils.js.map +1 -0
- package/lib/module/wayfinding/styles/colors.js +11 -0
- package/lib/module/wayfinding/styles/colors.js.map +1 -0
- package/lib/module/wayfinding/types/index.d.js +2 -0
- package/lib/module/wayfinding/types/index.d.js.map +1 -0
- package/lib/module/wayfinding/utils/index.js +4 -0
- package/lib/module/wayfinding/utils/index.js.map +1 -0
- package/lib/module/wayfinding/utils/mapper.js +100 -0
- package/lib/module/wayfinding/utils/mapper.js.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/sdk/index.d.ts +269 -0
- package/lib/typescript/src/sdk/index.d.ts.map +1 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts +2 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -0
- package/lib/typescript/src/sdk/utils.d.ts +7 -0
- package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/requestPermission.d.ts +3 -0
- package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +36 -0
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/hooks/index.d.ts +53 -0
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/index.d.ts +5 -0
- package/lib/typescript/src/wayfinding/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/store/index.d.ts +103 -0
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/store/utils.d.ts +9 -0
- package/lib/typescript/src/wayfinding/store/utils.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/styles/colors.d.ts +8 -0
- package/lib/typescript/src/wayfinding/styles/colors.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/utils/index.d.ts +3 -0
- package/lib/typescript/src/wayfinding/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts +17 -0
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -0
- package/package.json +130 -0
- package/security.txt +4 -0
- package/src/index.ts +6 -0
- package/src/sdk/index.ts +656 -0
- package/src/sdk/nativeInterface.ts +18 -0
- package/src/sdk/types/index.d.ts +718 -0
- package/src/sdk/utils.ts +16 -0
- package/src/utils/requestPermission.ts +94 -0
- package/src/wayfinding/components/MapView.tsx +312 -0
- package/src/wayfinding/hooks/index.ts +539 -0
- package/src/wayfinding/index.tsx +11 -0
- package/src/wayfinding/store/index.tsx +254 -0
- package/src/wayfinding/store/utils.ts +40 -0
- package/src/wayfinding/styles/colors.tsx +6 -0
- package/src/wayfinding/types/index.d.ts +56 -0
- package/src/wayfinding/utils/index.ts +5 -0
- package/src/wayfinding/utils/mapper.ts +129 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Platform, StyleSheet } from "react-native";
|
|
5
|
+
import WebView from "react-native-webview";
|
|
6
|
+
//This icon should either be inside plugin or not be used rat all
|
|
7
|
+
import useSitum from "../hooks";
|
|
8
|
+
import { NavigationStatus, NavigationUpdateType, setWebViewRef } from "../store";
|
|
9
|
+
import { useDispatch } from "../store/utils";
|
|
10
|
+
import { sendMessageToViewer } from "../utils";
|
|
11
|
+
import Mapper from "../utils/mapper";
|
|
12
|
+
const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com";
|
|
13
|
+
|
|
14
|
+
// Define class that handles errors
|
|
15
|
+
export let ErrorName = /*#__PURE__*/function (ErrorName) {
|
|
16
|
+
ErrorName["ERR_INTERNET_DISCONNECTED"] = "ERR_INTERNET_DISCONNECTED";
|
|
17
|
+
ErrorName["ERR_INTERNAL_SERVER_ERROR"] = "ERR_INTERNAL_SERVER_ERROR";
|
|
18
|
+
return ErrorName;
|
|
19
|
+
}({});
|
|
20
|
+
const NETWORK_ERROR_CODE = {
|
|
21
|
+
android: -2,
|
|
22
|
+
ios: -1009,
|
|
23
|
+
// These platforms are unhandled
|
|
24
|
+
windows: 0,
|
|
25
|
+
macos: 0,
|
|
26
|
+
web: 0
|
|
27
|
+
};
|
|
28
|
+
const viewerStyles = StyleSheet.create({
|
|
29
|
+
webview: {
|
|
30
|
+
minHeight: "100%",
|
|
31
|
+
minWidth: "100%"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const MapView = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
domain,
|
|
37
|
+
// user,
|
|
38
|
+
// apikey,
|
|
39
|
+
configuration,
|
|
40
|
+
onLoad = () => {},
|
|
41
|
+
onLoadError = () => {},
|
|
42
|
+
onFloorChanged = () => {},
|
|
43
|
+
onPoiSelected = () => {},
|
|
44
|
+
onPoiDeselected = () => {},
|
|
45
|
+
onNavigationRequested = () => {},
|
|
46
|
+
onNavigationStarted = () => {},
|
|
47
|
+
onNavigationError = () => {},
|
|
48
|
+
onNavigationFinished = () => {},
|
|
49
|
+
style
|
|
50
|
+
//iOSMapViewIndex,
|
|
51
|
+
} = _ref;
|
|
52
|
+
const dispatch = useDispatch();
|
|
53
|
+
const webViewRef = useRef();
|
|
54
|
+
// Local states
|
|
55
|
+
const [mapLoaded, setMapLoaded] = useState(false);
|
|
56
|
+
const {
|
|
57
|
+
user: fullUser,
|
|
58
|
+
location,
|
|
59
|
+
directions,
|
|
60
|
+
navigation,
|
|
61
|
+
currentBuilding,
|
|
62
|
+
initializeBuildingById,
|
|
63
|
+
calculateRoute,
|
|
64
|
+
startNavigation,
|
|
65
|
+
stopNavigation,
|
|
66
|
+
error
|
|
67
|
+
} = useSitum();
|
|
68
|
+
const sendFollowUser = () => {
|
|
69
|
+
var _location$position;
|
|
70
|
+
if (webViewRef.current && mapLoaded && (location === null || location === void 0 ? void 0 : (_location$position = location.position) === null || _location$position === void 0 ? void 0 : _location$position.buildingIdentifier) === (configuration === null || configuration === void 0 ? void 0 : configuration.buildingIdentifier)) {
|
|
71
|
+
sendMessageToViewer(webViewRef.current, Mapper.followUser(true));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
configuration.buildingIdentifier && initializeBuildingById(configuration.buildingIdentifier);
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
}, [configuration.buildingIdentifier]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (error) {
|
|
80
|
+
console.error("Error code:", error.code ? error.code : " no code provided");
|
|
81
|
+
console.error("Error detected:", error.message);
|
|
82
|
+
}
|
|
83
|
+
}, [error]);
|
|
84
|
+
|
|
85
|
+
// Updated SDK location
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!webViewRef.current || !location) return;
|
|
88
|
+
//console.debug('location', location);
|
|
89
|
+
|
|
90
|
+
sendMessageToViewer(webViewRef.current, Mapper.location(location));
|
|
91
|
+
}, [location]);
|
|
92
|
+
|
|
93
|
+
// Updated SDK navigation
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!webViewRef.current || !navigation) return;
|
|
96
|
+
sendMessageToViewer(webViewRef.current, Mapper.navigation(navigation));
|
|
97
|
+
if (navigation.status === NavigationStatus.START) {
|
|
98
|
+
onNavigationStarted({
|
|
99
|
+
navigation: Mapper.routeToResult(navigation)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if ((navigation === null || navigation === void 0 ? void 0 : navigation.type) === NavigationUpdateType.destinationReached) {
|
|
103
|
+
onNavigationFinished({
|
|
104
|
+
navigation: Mapper.navigationToResult(navigation)
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
+
}, [navigation]);
|
|
109
|
+
|
|
110
|
+
// Updated SDK route
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!webViewRef.current || !directions) return;
|
|
113
|
+
sendMessageToViewer(webViewRef.current, Mapper.route(directions));
|
|
114
|
+
}, [directions]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (webViewRef.current && mapLoaded) {
|
|
117
|
+
sendMessageToViewer(webViewRef.current, Mapper.initialConfiguration(style, configuration.enablePoiClustering, configuration.showPoiNames, configuration.minZoom, configuration.maxZoom, configuration.initialZoom, configuration.useDashboardTheme));
|
|
118
|
+
}
|
|
119
|
+
}, [webViewRef, mapLoaded, style, configuration.enablePoiClustering, configuration.showPoiNames, configuration.minZoom, configuration.maxZoom, configuration.initialZoom, configuration.useDashboardTheme]);
|
|
120
|
+
const handleRequestFromViewer = event => {
|
|
121
|
+
const eventParsed = JSON.parse(event.nativeEvent.data);
|
|
122
|
+
switch (eventParsed.type) {
|
|
123
|
+
case "app.map_is_ready":
|
|
124
|
+
onLoad({
|
|
125
|
+
status: "SUCCESS",
|
|
126
|
+
message: "Map is ready!"
|
|
127
|
+
});
|
|
128
|
+
sendFollowUser();
|
|
129
|
+
break;
|
|
130
|
+
case "directions.requested":
|
|
131
|
+
calculateRoute({
|
|
132
|
+
originId: JSON.parse(event.nativeEvent.data).payload.originIdentifier,
|
|
133
|
+
destinationId: JSON.parse(event.nativeEvent.data).payload.destinationIdentifier,
|
|
134
|
+
directionsOptions: JSON.parse(event.nativeEvent.data).payload.directionsOptions
|
|
135
|
+
});
|
|
136
|
+
break;
|
|
137
|
+
case "navigation.requested":
|
|
138
|
+
startNavigation({
|
|
139
|
+
originId: JSON.parse(event.nativeEvent.data).payload.originIdentifier,
|
|
140
|
+
destinationId: JSON.parse(event.nativeEvent.data).payload.destinationIdentifier,
|
|
141
|
+
directionsOptions: JSON.parse(event.nativeEvent.data).payload.directionsOptions,
|
|
142
|
+
callback: (status, _navigation) => status === "success" && navigation ? onNavigationRequested({
|
|
143
|
+
navigation: Mapper.routeToResult(_navigation)
|
|
144
|
+
}) : status === "error" && onNavigationError({})
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
case "navigation.stopped":
|
|
148
|
+
stopNavigation();
|
|
149
|
+
break;
|
|
150
|
+
case "cartography.poi_selected":
|
|
151
|
+
onPoiSelected(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
152
|
+
break;
|
|
153
|
+
case "cartography.poi_deselected":
|
|
154
|
+
onPoiDeselected(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
155
|
+
break;
|
|
156
|
+
case "cartography.floor_changed":
|
|
157
|
+
onFloorChanged(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
158
|
+
break;
|
|
159
|
+
case "cartography.building_selected":
|
|
160
|
+
if (!eventParsed.payload.identifier || currentBuilding && eventParsed.payload.identifier.toString() === currentBuilding.buildingIdentifier) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
initializeBuildingById(eventParsed.payload.identifier.toString());
|
|
164
|
+
break;
|
|
165
|
+
default:
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return /*#__PURE__*/React.createElement(WebView, {
|
|
170
|
+
ref: webViewRef,
|
|
171
|
+
source: {
|
|
172
|
+
uri: `${domain || SITUM_BASE_DOMAIN}/?email=${fullUser === null || fullUser === void 0 ? void 0 : fullUser.email}&apikey=${fullUser === null || fullUser === void 0 ? void 0 : fullUser.apiKey}&wl=true&global=true&mode=embed${configuration.buildingIdentifier ? `&buildingid=${configuration.buildingIdentifier}` : ""}&show=rts`
|
|
173
|
+
},
|
|
174
|
+
style: viewerStyles.webview,
|
|
175
|
+
javaScriptEnabled: true,
|
|
176
|
+
domStorageEnabled: true,
|
|
177
|
+
startInLoadingState: true,
|
|
178
|
+
onMessage: handleRequestFromViewer
|
|
179
|
+
// This is called on a lot of interactions with the map because of url change probably
|
|
180
|
+
,
|
|
181
|
+
onLoadEnd: () => {
|
|
182
|
+
if (!webViewRef.current) return;
|
|
183
|
+
dispatch(setWebViewRef(webViewRef));
|
|
184
|
+
setMapLoaded(true);
|
|
185
|
+
},
|
|
186
|
+
onError: evt => {
|
|
187
|
+
const {
|
|
188
|
+
nativeEvent
|
|
189
|
+
} = evt;
|
|
190
|
+
// TODO: on render error should probably still try to render an html
|
|
191
|
+
if (nativeEvent.code === NETWORK_ERROR_CODE[Platform.OS]) {
|
|
192
|
+
onLoadError({
|
|
193
|
+
name: ErrorName.ERR_INTERNET_DISCONNECTED,
|
|
194
|
+
description: nativeEvent.description
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
// TODO: handle more errors
|
|
198
|
+
onLoadError({
|
|
199
|
+
name: ErrorName.ERR_INTERNAL_SERVER_ERROR,
|
|
200
|
+
description: nativeEvent.description
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
export default MapView;
|
|
207
|
+
//# sourceMappingURL=MapView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","Platform","StyleSheet","WebView","useSitum","NavigationStatus","NavigationUpdateType","setWebViewRef","useDispatch","sendMessageToViewer","Mapper","SITUM_BASE_DOMAIN","ErrorName","NETWORK_ERROR_CODE","android","ios","windows","macos","web","viewerStyles","create","webview","minHeight","minWidth","MapView","_ref","domain","configuration","onLoad","onLoadError","onFloorChanged","onPoiSelected","onPoiDeselected","onNavigationRequested","onNavigationStarted","onNavigationError","onNavigationFinished","style","dispatch","webViewRef","mapLoaded","setMapLoaded","user","fullUser","location","directions","navigation","currentBuilding","initializeBuildingById","calculateRoute","startNavigation","stopNavigation","error","sendFollowUser","_location$position","current","position","buildingIdentifier","followUser","console","code","message","status","START","routeToResult","type","destinationReached","navigationToResult","route","initialConfiguration","enablePoiClustering","showPoiNames","minZoom","maxZoom","initialZoom","useDashboardTheme","handleRequestFromViewer","event","eventParsed","JSON","parse","nativeEvent","data","originId","payload","originIdentifier","destinationId","destinationIdentifier","directionsOptions","callback","_navigation","identifier","toString","createElement","ref","source","uri","email","apiKey","javaScriptEnabled","domStorageEnabled","startInLoadingState","onMessage","onLoadEnd","onError","evt","OS","name","ERR_INTERNET_DISCONNECTED","description","ERR_INTERNAL_SERVER_ERROR"],"sourceRoot":"../../../../src","sources":["wayfinding/components/MapView.tsx"],"mappings":"AAAA;AACA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,OAAOC,OAAO,MAAM,sBAAsB;AAM1C;AACA,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SACEC,gBAAgB,EAChBC,oB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IAAIf,iBAAkB,WAAUgC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEsD,KAAM,WAC5DtD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEuD,MACX,kCACCvE,aAAa,CAAC8B,kBAAkB,GAC3B,eAAc9B,aAAa,CAAC8B,kBAAmB,EAAC,GACjD,EACL;IACH,CAAE;IACFpB,KAAK,EAAElB,YAAY,CAACE,OAAQ;IAC5B8E,iBAAiB,EAAE,IAAK;IACxBC,iBAAiB,EAAE,IAAK;IACxBC,mBAAmB,EAAE,IAAK;IAC1BC,SAAS,EAAE1B;IACX;IAAA;IACA2B,SAAS,EAAEA,CAAA,KAAM;MACf,IAAI,CAAChE,UAAU,CAACgB,OAAO,EAAE;MACzBjB,QAAQ,CAAC/B,aAAa,CAACgC,UAAU,CAAC,CAAC;MACnCE,YAAY,CAAC,IAAI,CAAC;IACpB,CAAE;IACF+D,OAAO,EAAGC,GAAsB,IAAK;MACnC,MAAM;QAAExB;MAAY,CAAC,GAAGwB,GAAG;MAC3B;MACA,IAAIxB,WAAW,CAACrB,IAAI,KAAK/C,kBAAkB,CAACZ,QAAQ,CAACyG,EAAE,CAAC,EAAE;QACxD7E,WAAW,CAAC;UACV8E,IAAI,EAAE/F,SAAS,CAACgG,yBAAyB;UACzCC,WAAW,EAAE5B,WAAW,CAAC4B;QAC3B,CAAC,CAAC;MACJ,CAAC,MAAM;QACL;QACAhF,WAAW,CAAC;UACV8E,IAAI,EAAE/F,SAAS,CAACkG,yBAAyB;UACzCD,WAAW,EAAE5B,WAAW,CAAC4B;QAC3B,CAAC,CAAC;MACJ;IACF;EAAE,CACH,CAAC;AAEN,CAAC;AAED,eAAerF,OAAO"}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import SitumPlugin from "../../sdk";
|
|
4
|
+
import requestPermission from "../../utils/requestPermission";
|
|
5
|
+
import { NavigationStatus, NavigationUpdateType, PositioningStatus, resetLocation, selectBuildings, selectCurrentBuilding, selectDestinationPoiID, selectDirections, selectError, selectIsSDKInitialized as selectIsSdkInitialized, selectLocation, selectLocationStatus, selectNavigation, selectPois, selectUser, selectWebViewRef, setAuth, setBuildings, setCurrentBuilding, setDestinationPoiID, setDirections, setError, setLocation, setLocationStatus, setNavigation, setPois, setSdkInitialized } from "../store/index";
|
|
6
|
+
import { useDispatch, useSelector } from "../store/utils";
|
|
7
|
+
import { sendMessageToViewer } from "../utils";
|
|
8
|
+
import Mapper from "../utils/mapper";
|
|
9
|
+
const defaultNavigationOptions = {
|
|
10
|
+
distanceToGoalThreshold: 4,
|
|
11
|
+
outsideRouteThreshold: 5
|
|
12
|
+
};
|
|
13
|
+
// Hook to define references that point to functions
|
|
14
|
+
// used on listeners. These references are updated whenever
|
|
15
|
+
// one of the dependencies on the array change
|
|
16
|
+
const useCallbackRef = (fn, deps) => {
|
|
17
|
+
const fnRef = useRef(fn);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
fnRef.current = fn;
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, deps);
|
|
22
|
+
return fnRef;
|
|
23
|
+
};
|
|
24
|
+
const useSitum = () => {
|
|
25
|
+
const dispatch = useDispatch();
|
|
26
|
+
const webViewRef = useSelector(selectWebViewRef);
|
|
27
|
+
const isSdkInitialized = useSelector(selectIsSdkInitialized);
|
|
28
|
+
const user = useSelector(selectUser);
|
|
29
|
+
const location = useSelector(selectLocation);
|
|
30
|
+
const locationStatus = useSelector(selectLocationStatus);
|
|
31
|
+
const buildings = useSelector(selectBuildings);
|
|
32
|
+
const currentBuilding = useSelector(selectCurrentBuilding);
|
|
33
|
+
const pois = useSelector(selectPois);
|
|
34
|
+
const directions = useSelector(selectDirections);
|
|
35
|
+
const navigation = useSelector(selectNavigation);
|
|
36
|
+
const error = useSelector(selectError);
|
|
37
|
+
const destinationPoiID = useSelector(selectDestinationPoiID);
|
|
38
|
+
const [lockDirections, setLockDirections] = useState(false);
|
|
39
|
+
const initSitumSdk = async _ref => {
|
|
40
|
+
let {
|
|
41
|
+
email,
|
|
42
|
+
apiKey,
|
|
43
|
+
startPositions = true,
|
|
44
|
+
fetchCartography = true,
|
|
45
|
+
useRemoteConfig = true
|
|
46
|
+
} = _ref;
|
|
47
|
+
return (
|
|
48
|
+
// TODO fix this async/await
|
|
49
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
50
|
+
new Promise(async (resolve, reject) => {
|
|
51
|
+
if (!isSdkInitialized) {
|
|
52
|
+
SitumPlugin.initSitumSDK();
|
|
53
|
+
setSdkInitialized(true);
|
|
54
|
+
}
|
|
55
|
+
if (email && apiKey) {
|
|
56
|
+
dispatch(setAuth({
|
|
57
|
+
email,
|
|
58
|
+
apiKey
|
|
59
|
+
}));
|
|
60
|
+
} else {
|
|
61
|
+
email = user.email;
|
|
62
|
+
apiKey = user.apiKey;
|
|
63
|
+
}
|
|
64
|
+
SitumPlugin.setApiKey(email, apiKey, response => {
|
|
65
|
+
if (response && Boolean(response.success) === true) {
|
|
66
|
+
console.debug("Situm > hook > Successful authentication.");
|
|
67
|
+
} else {
|
|
68
|
+
reject("Situm > hook > Failure while authenticating.");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
useRemoteConfig && SitumPlugin.setUseRemoteConfig(`${useRemoteConfig}`, () => {
|
|
72
|
+
console.debug("Situm > hook > Using remote config");
|
|
73
|
+
});
|
|
74
|
+
startPositions && (await requestPermission().then(() => {
|
|
75
|
+
startPositioning();
|
|
76
|
+
}).catch(e => {
|
|
77
|
+
console.error(e);
|
|
78
|
+
reject(e);
|
|
79
|
+
}));
|
|
80
|
+
fetchCartography && (await initializeBuildings().catch(e => {
|
|
81
|
+
console.error(e);
|
|
82
|
+
reject(e);
|
|
83
|
+
}));
|
|
84
|
+
resolve();
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Cartography
|
|
90
|
+
const initializeBuildings = async () => new Promise((resolve, reject) => {
|
|
91
|
+
console.debug("Retrieving buildings from Situm API");
|
|
92
|
+
SitumPlugin.fetchBuildings(buildingArray => {
|
|
93
|
+
dispatch(setBuildings(buildingArray));
|
|
94
|
+
console.debug("Situm > hook > Successfully retrieved buildings.");
|
|
95
|
+
resolve(buildingArray);
|
|
96
|
+
}, _error => {
|
|
97
|
+
console.error(`Situm > hook > Could not retrieve buildings: ${_error}`);
|
|
98
|
+
reject(`Could not retrieve buildings: ${_error}`);
|
|
99
|
+
dispatch(setError({
|
|
100
|
+
message: _error,
|
|
101
|
+
code: 3011
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
const initializeBuildingById = async buildingId => {
|
|
106
|
+
if (buildings.length === 0) return;
|
|
107
|
+
const newBuilding = buildings.find(b => b.buildingIdentifier === buildingId);
|
|
108
|
+
if (newBuilding) {
|
|
109
|
+
dispatch(setCurrentBuilding(newBuilding));
|
|
110
|
+
initializeBuildingPois(newBuilding);
|
|
111
|
+
} else {
|
|
112
|
+
console.warn(`Situm > hook > No building found for id ${buildingId}`);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const initializeBuilding = async b => {
|
|
116
|
+
dispatch(setCurrentBuilding(b));
|
|
117
|
+
initializeBuildingPois(b);
|
|
118
|
+
};
|
|
119
|
+
const initializeBuildingPois = b => {
|
|
120
|
+
SitumPlugin.fetchBuildingInfo(b, buildingInfo => {
|
|
121
|
+
console.debug("Situm > hook > Successfully retrieved pois of the selected building. ");
|
|
122
|
+
|
|
123
|
+
// Please, do not change the next line. iOS sends data as indoorPois and Android sends it as indoorPOIs
|
|
124
|
+
const buildingPois = (buildingInfo === null || buildingInfo === void 0 ? void 0 : buildingInfo.indoorPOIs) || (buildingInfo === null || buildingInfo === void 0 ? void 0 : buildingInfo.indoorPois) || [];
|
|
125
|
+
dispatch(setPois(buildingPois));
|
|
126
|
+
}, err => {
|
|
127
|
+
console.error(`Situm > hook > Could not initialize building pois: ${error}`);
|
|
128
|
+
dispatch(setError({
|
|
129
|
+
message: err,
|
|
130
|
+
code: 3021
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const startPositioning = () => {
|
|
135
|
+
console.debug("Situm > hook > Starting positioning...");
|
|
136
|
+
if (location.status !== PositioningStatus.STOPPED) {
|
|
137
|
+
console.debug("Situm > hook > Positioning has already started");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Declare the locationOptions (empty = default parameters)
|
|
142
|
+
const locationOptions = {
|
|
143
|
+
useDeadReckoning: false
|
|
144
|
+
};
|
|
145
|
+
// Start positioning
|
|
146
|
+
SitumPlugin.startPositioning(newLocation => {
|
|
147
|
+
dispatch(setLocation({
|
|
148
|
+
...newLocation
|
|
149
|
+
}));
|
|
150
|
+
}, status => {
|
|
151
|
+
if (status.statusName in PositioningStatus) {
|
|
152
|
+
console.debug(`Situm > hook > Positioning state updated ${status.statusName}`);
|
|
153
|
+
dispatch(setLocationStatus(status.statusName));
|
|
154
|
+
}
|
|
155
|
+
}, err => {
|
|
156
|
+
console.error(`Situm > hook > Error while positioning: ${err}}`);
|
|
157
|
+
//@ts-ignore
|
|
158
|
+
dispatch(setError({
|
|
159
|
+
message: err,
|
|
160
|
+
code: 3001
|
|
161
|
+
}));
|
|
162
|
+
}, locationOptions);
|
|
163
|
+
console.debug(`Successfully started positioning`);
|
|
164
|
+
};
|
|
165
|
+
const stopPositioning = async () => {
|
|
166
|
+
console.debug(`Stopping positioning ...`);
|
|
167
|
+
SitumPlugin.stopPositioning(success => {
|
|
168
|
+
if (success) {
|
|
169
|
+
dispatch(resetLocation());
|
|
170
|
+
console.debug("Situm > hook > Successfully stopped positioning");
|
|
171
|
+
} else {
|
|
172
|
+
console.error("Situm > hook > Could not stop positioning");
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Routes
|
|
178
|
+
const requestDirections = async (building, from, to, directionsOptions) => {
|
|
179
|
+
console.debug("Requesting directions");
|
|
180
|
+
const fromPoint = {
|
|
181
|
+
floorIdentifier: from.floorIdentifier,
|
|
182
|
+
buildingIdentifier: from.buildingIdentifier,
|
|
183
|
+
coordinate: from.coordinate
|
|
184
|
+
};
|
|
185
|
+
const toPoint = {
|
|
186
|
+
floorIdentifier: to.floorIdentifier,
|
|
187
|
+
buildingIdentifier: to.buildingIdentifier,
|
|
188
|
+
coordinate: to.coordinate
|
|
189
|
+
};
|
|
190
|
+
return new Promise((resolve, reject) => {
|
|
191
|
+
SitumPlugin.requestDirections([building, fromPoint, toPoint, directionsOptions], newDirections => {
|
|
192
|
+
console.debug("Situm > hook > Successfully computed route");
|
|
193
|
+
resolve(newDirections);
|
|
194
|
+
}, err => {
|
|
195
|
+
console.debug(`Situm > hook > Could not compute route: ${err}`);
|
|
196
|
+
dispatch(setError({
|
|
197
|
+
message: err,
|
|
198
|
+
code: 3041
|
|
199
|
+
}));
|
|
200
|
+
reject(err);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
const calculateRoute = async _ref2 => {
|
|
205
|
+
let {
|
|
206
|
+
originId,
|
|
207
|
+
destinationId,
|
|
208
|
+
directionsOptions,
|
|
209
|
+
updateRoute = true
|
|
210
|
+
} = _ref2;
|
|
211
|
+
const poiOrigin = pois.find(p => p.identifier === (originId === null || originId === void 0 ? void 0 : originId.toString()));
|
|
212
|
+
const poiDestination = pois.find(p => p.identifier === (destinationId === null || destinationId === void 0 ? void 0 : destinationId.toString()));
|
|
213
|
+
if (!poiDestination || !poiOrigin && originId !== -1 || lockDirections) {
|
|
214
|
+
console.debug(`Situm > hook >Could not compute route for origin: ${originId} or destination: ${destinationId} (lockDirections: ${lockDirections})`);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const from = originId === -1 && location ? location.position : {
|
|
218
|
+
buildingIdentifier: poiOrigin.buildingIdentifier,
|
|
219
|
+
floorIdentifier: poiOrigin.floorIdentifier,
|
|
220
|
+
cartesianCoordinate: poiOrigin.cartesianCoordinate,
|
|
221
|
+
coordinate: poiOrigin.coordinate
|
|
222
|
+
};
|
|
223
|
+
const to = {
|
|
224
|
+
buildingIdentifier: poiDestination.buildingIdentifier,
|
|
225
|
+
floorIdentifier: poiDestination.floorIdentifier,
|
|
226
|
+
cartesianCoordinate: poiDestination.cartesianCoordinate,
|
|
227
|
+
coordinate: poiDestination.coordinate
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// iOS workaround -> does not allow for several direction petitions
|
|
231
|
+
setLockDirections(true);
|
|
232
|
+
return requestDirections(currentBuilding, from, to, directionsOptions).then(newDirections => {
|
|
233
|
+
const extendedRoute = {
|
|
234
|
+
...newDirections,
|
|
235
|
+
originId,
|
|
236
|
+
destinationId,
|
|
237
|
+
type: directionsOptions === null || directionsOptions === void 0 ? void 0 : directionsOptions.accessibilityMode
|
|
238
|
+
};
|
|
239
|
+
updateRoute && dispatch(setDirections(extendedRoute));
|
|
240
|
+
return directions;
|
|
241
|
+
}).catch(e => {
|
|
242
|
+
dispatch(setDirections({
|
|
243
|
+
error: JSON.stringify(e)
|
|
244
|
+
}));
|
|
245
|
+
}).finally(() => setLockDirections(false));
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// Navigation
|
|
249
|
+
// TODO: this function is async and we use a callback, why not use a promise?
|
|
250
|
+
const startNavigation = async _ref3 => {
|
|
251
|
+
let {
|
|
252
|
+
callback,
|
|
253
|
+
destinationId,
|
|
254
|
+
directionsOptions,
|
|
255
|
+
navigationOptions,
|
|
256
|
+
originId
|
|
257
|
+
} = _ref3;
|
|
258
|
+
calculateRoute({
|
|
259
|
+
originId,
|
|
260
|
+
destinationId,
|
|
261
|
+
directionsOptions,
|
|
262
|
+
updateRoute: false
|
|
263
|
+
}).then(r => {
|
|
264
|
+
if (originId !== -1 || !location || !r) {
|
|
265
|
+
callback && callback("error");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
dispatch(setNavigation({
|
|
269
|
+
status: NavigationStatus.START,
|
|
270
|
+
...r
|
|
271
|
+
}));
|
|
272
|
+
callback && callback("success", r);
|
|
273
|
+
SitumPlugin.requestNavigationUpdates(update => {
|
|
274
|
+
const newNavType = update.type && update.type in NavigationUpdateType && NavigationUpdateType[update.type] || NavigationUpdateType.progress;
|
|
275
|
+
dispatch(setNavigation({
|
|
276
|
+
currentIndication: update === null || update === void 0 ? void 0 : update.currentIndication,
|
|
277
|
+
routeStep: update === null || update === void 0 ? void 0 : update.routeStep,
|
|
278
|
+
distanceToGoal: update === null || update === void 0 ? void 0 : update.distanceToGoal,
|
|
279
|
+
points: update === null || update === void 0 ? void 0 : update.points,
|
|
280
|
+
type: newNavType,
|
|
281
|
+
segments: update === null || update === void 0 ? void 0 : update.segments,
|
|
282
|
+
status: NavigationStatus.UPDATE
|
|
283
|
+
}));
|
|
284
|
+
}, err => {
|
|
285
|
+
console.error(`Situm > hook >Could not update navigation: ${err}`);
|
|
286
|
+
callback && callback("error");
|
|
287
|
+
dispatch(setError({
|
|
288
|
+
message: err,
|
|
289
|
+
code: 3051
|
|
290
|
+
}));
|
|
291
|
+
stopNavigationRef.current();
|
|
292
|
+
}, {
|
|
293
|
+
...defaultNavigationOptions,
|
|
294
|
+
...navigationOptions
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
const navigateToPoi = async _ref4 => {
|
|
299
|
+
let {
|
|
300
|
+
poi,
|
|
301
|
+
poiId
|
|
302
|
+
} = _ref4;
|
|
303
|
+
if (!poi && !poiId) return;
|
|
304
|
+
const validPoi = pois === null || pois === void 0 ? void 0 : pois.find(p => {
|
|
305
|
+
var _poi$id;
|
|
306
|
+
return (p === null || p === void 0 ? void 0 : p.identifier) === (poiId === null || poiId === void 0 ? void 0 : poiId.toString()) ||
|
|
307
|
+
// @ts-ignore
|
|
308
|
+
(p === null || p === void 0 ? void 0 : p.identifier) === (poi === null || poi === void 0 ? void 0 : (_poi$id = poi.id) === null || _poi$id === void 0 ? void 0 : _poi$id.toString());
|
|
309
|
+
});
|
|
310
|
+
if (!validPoi) {
|
|
311
|
+
console.error("Situm > hook > Invalid value as poi or poiId");
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
sendMessageToViewer(webViewRef.current, Mapper.navigateToPoi({
|
|
315
|
+
// @ts-ignore
|
|
316
|
+
navigationTo: (poi === null || poi === void 0 ? void 0 : poi.id) || poiId
|
|
317
|
+
}));
|
|
318
|
+
};
|
|
319
|
+
const stopNavigation = () => {
|
|
320
|
+
console.debug("Stopping navigation");
|
|
321
|
+
if (!navigation || navigation.status === NavigationStatus.STOP) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
SitumPlugin.removeNavigationUpdates(response => {
|
|
325
|
+
if (response && response.success) {
|
|
326
|
+
console.debug("Situm > hook > Successfully removed navigation updates");
|
|
327
|
+
} else {
|
|
328
|
+
console.error("Situm > hook > Could not remove navigation updates");
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
dispatch(setNavigation({
|
|
332
|
+
status: NavigationStatus.STOP
|
|
333
|
+
}));
|
|
334
|
+
dispatch(setDestinationPoiID(undefined));
|
|
335
|
+
};
|
|
336
|
+
const cancelNavigation = () => {
|
|
337
|
+
stopNavigation();
|
|
338
|
+
sendMessageToViewer(webViewRef.current, Mapper.cancelNavigation());
|
|
339
|
+
};
|
|
340
|
+
const selectPoi = poiId => {
|
|
341
|
+
const poi = pois === null || pois === void 0 ? void 0 : pois.find(p => (p === null || p === void 0 ? void 0 : p.identifier) === (poiId === null || poiId === void 0 ? void 0 : poiId.toString()));
|
|
342
|
+
if (!poi) {
|
|
343
|
+
console.error("Situm > hook > Invalid value as poiId");
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (navigation.status !== NavigationStatus.STOP) {
|
|
347
|
+
console.error("Situm > hook > Navigation on course, poi selection is unavailable");
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
sendMessageToViewer(webViewRef.current, Mapper.selectPoi(poiId));
|
|
351
|
+
};
|
|
352
|
+
const stopNavigationRef = useCallbackRef(stopNavigation, [navigation]);
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
if (!navigation || navigation.status === NavigationStatus.STOP || !location) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
SitumPlugin.updateNavigationWithLocation(location, info => {
|
|
358
|
+
console.debug(info);
|
|
359
|
+
}, e => {
|
|
360
|
+
console.error(`Situm > hook > Error on navigation update ${e}`);
|
|
361
|
+
});
|
|
362
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
363
|
+
}, [location]);
|
|
364
|
+
return {
|
|
365
|
+
// States
|
|
366
|
+
user,
|
|
367
|
+
location,
|
|
368
|
+
locationStatus,
|
|
369
|
+
currentBuilding,
|
|
370
|
+
buildings,
|
|
371
|
+
pois,
|
|
372
|
+
directions,
|
|
373
|
+
navigation,
|
|
374
|
+
error,
|
|
375
|
+
destinationPoiID,
|
|
376
|
+
// Functions
|
|
377
|
+
initSitumSdk,
|
|
378
|
+
initializeBuildings,
|
|
379
|
+
initializeBuilding,
|
|
380
|
+
initializeBuildingById,
|
|
381
|
+
startPositioning,
|
|
382
|
+
stopPositioning,
|
|
383
|
+
calculateRoute,
|
|
384
|
+
startNavigation,
|
|
385
|
+
stopNavigation,
|
|
386
|
+
cancelNavigation,
|
|
387
|
+
selectPoi,
|
|
388
|
+
navigateToPoi
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
export default useSitum;
|
|
392
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","SitumPlugin","requestPermission","NavigationStatus","NavigationUpdateType","PositioningStatus","resetLocation","selectBuildings","selectCurrentBuilding","selectDestinationPoiID","selectDirections","selectError","selectIsSDKInitialized","selectIsSdkInitialized","selectLocation","selectLocationStatus","selectNavigation","selectPois","selectUser","selectWebViewRef","setAuth","setBuildings","setCurrentBuilding","setDestinationPoiID","setDirections","setError","setLocation","setLocationStatus","setNavigation","setPois","setSdkInitialized","useDispatch","useSelector","sendMessageToViewer","Mapper","defaultNavigationOptions","distanceToGoalThreshold","outsideRouteThreshold","useCallbackRef","fn","deps","fnRef","current","useSitum","dispatch","webViewRef","isSdkInitialized","user","location","locationStatus","buildings","currentBuilding","pois","directions","navigation","error","destinationPoiID","lockDirections","setLockDirections","initSitumSdk","_ref","email","apiKey","startPositions","fetchCartography","useRemoteConfig","Promise","resolve","reject","initSitumSDK","setApiKey","response","Boolean","success","console","debug","setUseRemoteConfig","then","startPositioning","catch","e","initializeBuildings","fetchBuildings","buildingArray","_error","message","code","initializeBuildingById","buildingId","length","newBuilding","find","b","buildingIdentifier","initializeBuildingPois","warn","initializeBuilding","fetchBuildingInfo","buildingInfo","buildingPois","indoorPOIs","indoorPois","err","status","STOPPED","locationOptions","useDeadReckoning","newLocation","statusName","stopPositioning","requestDirections","building","from","to","directionsOptions","fromPoint","floorIdentifier","coordinate","toPoint","newDirections","calculateRoute","_ref2","originId","destinationId","updateRoute","poiOrigin","p","identifier","toString","poiDestination","position","cartesianCoordinate","extendedRoute","type","accessibilityMode","JSON","stringify","finally","startNavigation","_ref3","callback","navigationOptions","r","START","requestNavigationUpdates","update","newNavType","progress","currentIndication","routeStep","distanceToGoal","points","segments","UPDATE","stopNavigationRef","navigateToPoi","_ref4","poi","poiId","validPoi","_poi$id","id","navigationTo","stopNavigation","STOP","removeNavigationUpdates","undefined","cancelNavigation","selectPoi","updateNavigationWithLocation","info"],"sourceRoot":"../../../../src","sources":["wayfinding/hooks/index.ts"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAQnD,OAAOC,WAAW,MAAM,WAAW;AACnC,OAAOC,iBAAiB,MAAM,+BAA+B;AAC7D,SA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e;IACfD,SAAS;IACTE,IAAI;IACJC,UAAU;IACVC,UAAU;IACVC,KAAK;IACLC,gBAAgB;IAEhB;IACAG,YAAY;IACZsB,mBAAmB;IACnBe,kBAAkB;IAClBT,sBAAsB;IACtBT,gBAAgB;IAChB+B,eAAe;IACfW,cAAc;IACdkB,eAAe;IACfyB,cAAc;IACdI,gBAAgB;IAChBC,SAAS;IACTb;EACF,CAAC;AACH,CAAC;AAED,eAAehH,QAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Definitions
|
|
2
|
+
export * from "./types/index.d";
|
|
3
|
+
|
|
4
|
+
// Hook
|
|
5
|
+
export { default as useSitum } from "./hooks";
|
|
6
|
+
|
|
7
|
+
// State Provider
|
|
8
|
+
export { default as SitumProvider } from "./store";
|
|
9
|
+
|
|
10
|
+
// Component
|
|
11
|
+
export { default as MapView } from "./components/MapView";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","useSitum","SitumProvider","MapView"],"sourceRoot":"../../../src","sources":["wayfinding/index.tsx"],"mappings":"AAAA;AACA,cAAc,iBAAiB;;AAE/B;AACA,SAASA,OAAO,IAAIC,QAAQ,QAAQ,SAAS;;AAE7C;AACA,SAASD,OAAO,IAAIE,aAAa,QAAQ,SAAS;;AAElD;AACA,SAASF,OAAO,IAAIG,OAAO,QAAQ,sBAAsB"}
|