@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
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.logError = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Small utility that can be used as an error handler. You cannot just pass
|
|
9
|
-
* `console.error` as a failure callback - it's not properly bound. If passes an
|
|
10
|
-
* `Error` object, it will print the message and stack.
|
|
11
|
-
*/
|
|
12
|
-
const logError = exports.logError = __DEV__ ? function (response) {
|
|
13
|
-
if (response instanceof String) {
|
|
14
|
-
console.log(response);
|
|
15
|
-
} else {
|
|
16
|
-
console.log(JSON.stringify(response));
|
|
17
|
-
}
|
|
18
|
-
} : function (_response) {
|
|
19
|
-
// do nothing
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=logError.js.map
|
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _reactNativeWebview = _interopRequireDefault(require("react-native-webview"));
|
|
10
|
-
var _sdk = _interopRequireDefault(require("../../sdk"));
|
|
11
|
-
var _hooks = _interopRequireDefault(require("../hooks"));
|
|
12
|
-
var _constants = require("../types/constants");
|
|
13
|
-
var _utils = require("../utils");
|
|
14
|
-
var _mapper = _interopRequireDefault(require("../utils/mapper"));
|
|
15
|
-
var _store = require("../store");
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
20
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
21
|
-
|
|
22
|
-
const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com";
|
|
23
|
-
const NETWORK_ERROR_CODE = {
|
|
24
|
-
android: -2,
|
|
25
|
-
ios: -1009,
|
|
26
|
-
// These platforms are unhandled
|
|
27
|
-
windows: 0,
|
|
28
|
-
macos: 0,
|
|
29
|
-
web: 0
|
|
30
|
-
};
|
|
31
|
-
const viewerStyles = _reactNative.StyleSheet.create({
|
|
32
|
-
webview: {
|
|
33
|
-
minHeight: "100%",
|
|
34
|
-
minWidth: "100%"
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const MapView = /*#__PURE__*/_react.default.forwardRef(({
|
|
38
|
-
configuration,
|
|
39
|
-
style,
|
|
40
|
-
onLoad = () => {},
|
|
41
|
-
onLoadError = () => {},
|
|
42
|
-
onPoiSelected = () => {},
|
|
43
|
-
onPoiDeselected = () => {},
|
|
44
|
-
onFloorChanged = () => {},
|
|
45
|
-
onExternalLinkClicked = undefined,
|
|
46
|
-
onFavoritePoisUpdated = () => {}
|
|
47
|
-
}, ref) => {
|
|
48
|
-
const webViewRef = (0, _react.useRef)();
|
|
49
|
-
const [_onDirectionsRequestInterceptor, setInterceptor] = (0, _react.useState)();
|
|
50
|
-
|
|
51
|
-
// Local states
|
|
52
|
-
const [mapLoaded, setMapLoaded] = (0, _react.useState)(false);
|
|
53
|
-
const [buildingIdentifier, setBuildingIdentifier] = (0, _react.useState)(configuration.buildingIdentifier);
|
|
54
|
-
const {
|
|
55
|
-
init,
|
|
56
|
-
location,
|
|
57
|
-
locationStatus,
|
|
58
|
-
directions,
|
|
59
|
-
navigation,
|
|
60
|
-
calculateRoute,
|
|
61
|
-
startNavigation,
|
|
62
|
-
stopNavigation,
|
|
63
|
-
error
|
|
64
|
-
} = (0, _hooks.default)();
|
|
65
|
-
const sendFollowUser = () => {
|
|
66
|
-
var _location$position;
|
|
67
|
-
if (webViewRef.current && mapLoaded && (location === null || location === void 0 || (_location$position = location.position) === null || _location$position === void 0 ? void 0 : _location$position.buildingIdentifier) === configuration.buildingIdentifier) {
|
|
68
|
-
_followUser(true);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Helper functions used on imperative handler
|
|
73
|
-
// Navigation
|
|
74
|
-
const _navigateToPoi = (0, _react.useCallback)(payload => {
|
|
75
|
-
if (!webViewRef.current || !payload || !payload.identifier) return;
|
|
76
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.navigateToPoi(payload));
|
|
77
|
-
}, []);
|
|
78
|
-
const _followUser = (0, _react.useCallback)(payload => {
|
|
79
|
-
if (!webViewRef.current) return;
|
|
80
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.followUser(payload));
|
|
81
|
-
}, []);
|
|
82
|
-
const _navigateToCar = (0, _react.useCallback)(payload => {
|
|
83
|
-
if (!webViewRef.current) return;
|
|
84
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.navigateToCar(payload));
|
|
85
|
-
}, []);
|
|
86
|
-
const _navigateToPoint = (0, _react.useCallback)(payload => {
|
|
87
|
-
if (!webViewRef.current || !(payload !== null && payload !== void 0 && payload.lat) && !(payload !== null && payload !== void 0 && payload.lng) && !(payload !== null && payload !== void 0 && payload.floorIdentifier)) return;
|
|
88
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.navigateToPoint(payload));
|
|
89
|
-
}, []);
|
|
90
|
-
|
|
91
|
-
// Cartography
|
|
92
|
-
const _selectPoi = (0, _react.useCallback)(poiId => {
|
|
93
|
-
if (!webViewRef.current) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.selectPoi(poiId));
|
|
97
|
-
}, []);
|
|
98
|
-
const _selectCar = (0, _react.useCallback)(() => {
|
|
99
|
-
if (!webViewRef.current) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.selectCar());
|
|
103
|
-
}, []);
|
|
104
|
-
const _selectPoiCategory = (0, _react.useCallback)(categoryId => {
|
|
105
|
-
if (!webViewRef.current) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (_sdk.default.navigationIsRunning()) {
|
|
109
|
-
console.error("Situm > hook > Navigation on course, poi category selection is unavailable");
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.selectPoiCategory(categoryId));
|
|
113
|
-
}, []);
|
|
114
|
-
const _selectFloor = (0, _react.useCallback)((floorId, options) => {
|
|
115
|
-
if (!webViewRef.current) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (_sdk.default.navigationIsRunning()) {
|
|
119
|
-
console.error("Situm > hook > Navigation on course, floor selection is unavailable");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.selectFloor(floorId, options));
|
|
123
|
-
}, []);
|
|
124
|
-
const _search = (0, _react.useCallback)(payload => {
|
|
125
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.search(payload));
|
|
126
|
-
}, []);
|
|
127
|
-
const _setDirectionsOptions = (0, _react.useCallback)(directionsOptions => {
|
|
128
|
-
if (!webViewRef.current) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.setDirectionsOptions(directionsOptions));
|
|
132
|
-
}, []);
|
|
133
|
-
const _setFavoritePois = (0, _react.useCallback)(poiIds => {
|
|
134
|
-
if (!webViewRef.current) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.setFavoritePois(poiIds));
|
|
138
|
-
}, []);
|
|
139
|
-
const _onMapIsReady = () => {
|
|
140
|
-
if (locationStatus) {
|
|
141
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.locationStatus(locationStatus));
|
|
142
|
-
}
|
|
143
|
-
if (error) {
|
|
144
|
-
// Right now, status and errors share message on the viewer:
|
|
145
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.locationError(error));
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* API exported to the outside world from the MapViewer
|
|
151
|
-
*
|
|
152
|
-
* These handler allows third party developers to send actions to the MapView.
|
|
153
|
-
* please check the MapViewRef type definitions to know the public API.
|
|
154
|
-
*
|
|
155
|
-
* <MapView
|
|
156
|
-
* ref={(ref: MapViewRef) => ref.selectPoi(122)}
|
|
157
|
-
* configuration={{
|
|
158
|
-
* buildingIdentifier: SITUM_BUILDING_ID,
|
|
159
|
-
* }}
|
|
160
|
-
* onLoad={onLoad} />
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
(0, _react.useImperativeHandle)(ref, () => {
|
|
164
|
-
return {
|
|
165
|
-
followUser() {
|
|
166
|
-
_followUser(true);
|
|
167
|
-
},
|
|
168
|
-
unfollowUser() {
|
|
169
|
-
_followUser(false);
|
|
170
|
-
},
|
|
171
|
-
selectPoi(poiId) {
|
|
172
|
-
_selectPoi(poiId);
|
|
173
|
-
},
|
|
174
|
-
selectCar() {
|
|
175
|
-
_selectCar();
|
|
176
|
-
},
|
|
177
|
-
selectPoiCategory(poiId) {
|
|
178
|
-
_selectPoiCategory(poiId);
|
|
179
|
-
},
|
|
180
|
-
selectFloor(poiId, options) {
|
|
181
|
-
_selectFloor(poiId, options);
|
|
182
|
-
},
|
|
183
|
-
setDirectionsOptions(directionsOptions) {
|
|
184
|
-
_setDirectionsOptions(directionsOptions);
|
|
185
|
-
},
|
|
186
|
-
setFavoritePois(poiIds) {
|
|
187
|
-
_setFavoritePois(poiIds);
|
|
188
|
-
},
|
|
189
|
-
deselectPoi() {
|
|
190
|
-
webViewRef.current && (0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.selectPoi(null));
|
|
191
|
-
},
|
|
192
|
-
navigateToPoi(payload) {
|
|
193
|
-
_navigateToPoi(payload);
|
|
194
|
-
},
|
|
195
|
-
navigateToCar(payload) {
|
|
196
|
-
_navigateToCar(payload);
|
|
197
|
-
},
|
|
198
|
-
navigateToPoint(payload) {
|
|
199
|
-
_navigateToPoint(payload);
|
|
200
|
-
},
|
|
201
|
-
setOnDirectionsRequestInterceptor(directionRequestInterceptor) {
|
|
202
|
-
setInterceptor(() => directionRequestInterceptor);
|
|
203
|
-
},
|
|
204
|
-
cancelNavigation() {
|
|
205
|
-
if (!webViewRef.current) return;
|
|
206
|
-
stopNavigation();
|
|
207
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.cancelNavigation());
|
|
208
|
-
},
|
|
209
|
-
search(payload) {
|
|
210
|
-
_search(payload);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
}, [stopNavigation, _navigateToPoi, _followUser, _navigateToCar, _navigateToPoint, _selectPoi, _selectCar, _selectPoiCategory, _selectFloor, _setDirectionsOptions, _setFavoritePois, _search]);
|
|
214
|
-
(0, _react.useEffect)(() => {
|
|
215
|
-
_sdk.default.validateMapViewProjectSettings();
|
|
216
|
-
return () => {};
|
|
217
|
-
}, []);
|
|
218
|
-
(0, _react.useEffect)(() => {
|
|
219
|
-
if (!error) return;
|
|
220
|
-
console.error("Error code:", error.code ? error.code : " no code provided");
|
|
221
|
-
console.error("Error detected:", error.message);
|
|
222
|
-
}, [error]);
|
|
223
|
-
|
|
224
|
-
// Updated SDK location
|
|
225
|
-
(0, _react.useEffect)(() => {
|
|
226
|
-
if (!webViewRef.current || !location || !mapLoaded) return;
|
|
227
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.location(location));
|
|
228
|
-
}, [location, mapLoaded]);
|
|
229
|
-
|
|
230
|
-
// locationStatus
|
|
231
|
-
(0, _react.useEffect)(() => {
|
|
232
|
-
if (!webViewRef.current || !locationStatus || !mapLoaded) return;
|
|
233
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.locationStatus(locationStatus));
|
|
234
|
-
// Callbacks used in `useEffect` won't be invoked if the value of locationStatus
|
|
235
|
-
// is set but hasn't changed. Set locationStatus to null always to avoid missing
|
|
236
|
-
// repeated messages.
|
|
237
|
-
(0, _store.setLocationStatus)(null);
|
|
238
|
-
}, [locationStatus, mapLoaded]);
|
|
239
|
-
|
|
240
|
-
// locationError
|
|
241
|
-
(0, _react.useEffect)(() => {
|
|
242
|
-
if (!webViewRef.current || !error || !mapLoaded) return;
|
|
243
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.locationError(error));
|
|
244
|
-
// Callbacks used in `useEffect` won't be invoked if the value of locationStatus
|
|
245
|
-
// is set but hasn't changed. Set locationStatus to null always to avoid missing
|
|
246
|
-
// repeated messages.
|
|
247
|
-
(0, _store.setError)(null);
|
|
248
|
-
}, [error, mapLoaded]);
|
|
249
|
-
|
|
250
|
-
// Updated SDK navigation
|
|
251
|
-
(0, _react.useEffect)(() => {
|
|
252
|
-
if (!webViewRef.current || !navigation || !mapLoaded) return;
|
|
253
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.navigation(navigation));
|
|
254
|
-
}, [navigation, mapLoaded]);
|
|
255
|
-
|
|
256
|
-
// Updated SDK route
|
|
257
|
-
(0, _react.useEffect)(() => {
|
|
258
|
-
if (!webViewRef.current || !directions || !mapLoaded) return;
|
|
259
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.route(directions));
|
|
260
|
-
}, [directions, mapLoaded]);
|
|
261
|
-
|
|
262
|
-
// Update language
|
|
263
|
-
(0, _react.useEffect)(() => {
|
|
264
|
-
if (!webViewRef.current || !configuration.language || !mapLoaded) return;
|
|
265
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.setLanguage(configuration.language));
|
|
266
|
-
}, [configuration.language, mapLoaded]);
|
|
267
|
-
|
|
268
|
-
// Update SDK configuration
|
|
269
|
-
(0, _react.useEffect)(() => {
|
|
270
|
-
if (webViewRef.current && mapLoaded) {
|
|
271
|
-
(0, _utils.sendMessageToViewer)(webViewRef.current, _mapper.default.initialConfiguration(style));
|
|
272
|
-
}
|
|
273
|
-
}, [webViewRef, mapLoaded, style]);
|
|
274
|
-
|
|
275
|
-
// Update follow user
|
|
276
|
-
(0, _react.useEffect)(() => {
|
|
277
|
-
mapLoaded && sendFollowUser();
|
|
278
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
279
|
-
}, [mapLoaded]);
|
|
280
|
-
const handleRequestFromViewer = event => {
|
|
281
|
-
const eventParsed = JSON.parse(event.nativeEvent.data);
|
|
282
|
-
switch (eventParsed.type) {
|
|
283
|
-
case "app.map_is_ready":
|
|
284
|
-
init();
|
|
285
|
-
setMapLoaded(true);
|
|
286
|
-
_onMapIsReady();
|
|
287
|
-
onLoad && onLoad("");
|
|
288
|
-
break;
|
|
289
|
-
case "directions.requested":
|
|
290
|
-
calculateRoute(eventParsed.payload, _onDirectionsRequestInterceptor);
|
|
291
|
-
break;
|
|
292
|
-
case "navigation.requested":
|
|
293
|
-
startNavigation(eventParsed.payload, _onDirectionsRequestInterceptor);
|
|
294
|
-
break;
|
|
295
|
-
case "navigation.stopped":
|
|
296
|
-
stopNavigation();
|
|
297
|
-
break;
|
|
298
|
-
case "cartography.poi_selected":
|
|
299
|
-
onPoiSelected(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
300
|
-
break;
|
|
301
|
-
case "cartography.poi_deselected":
|
|
302
|
-
onPoiDeselected(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
303
|
-
break;
|
|
304
|
-
case "ui.favorite_pois_updated":
|
|
305
|
-
{
|
|
306
|
-
const favoritePoisIds = {
|
|
307
|
-
currentPoisIdentifiers: eventParsed.payload.favoritePois ? [...eventParsed.payload.favoritePois] : []
|
|
308
|
-
};
|
|
309
|
-
onFavoritePoisUpdated(favoritePoisIds);
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
case "cartography.floor_selected":
|
|
313
|
-
onFloorChanged(eventParsed === null || eventParsed === void 0 ? void 0 : eventParsed.payload);
|
|
314
|
-
break;
|
|
315
|
-
case "cartography.building_selected":
|
|
316
|
-
if (!eventParsed.payload.identifier || eventParsed.payload.identifier.toString() === buildingIdentifier) {
|
|
317
|
-
return;
|
|
318
|
-
} else {
|
|
319
|
-
setBuildingIdentifier(eventParsed.payload.identifier.toString());
|
|
320
|
-
}
|
|
321
|
-
break;
|
|
322
|
-
case "viewer.navigation.started":
|
|
323
|
-
case "viewer.navigation.updated":
|
|
324
|
-
case "viewer.navigation.stopped":
|
|
325
|
-
_sdk.default.updateNavigationState(eventParsed.payload);
|
|
326
|
-
break;
|
|
327
|
-
default:
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
const _onShouldStartLoadWithRequest = request => {
|
|
332
|
-
if (request && request.url && !request.url.startsWith(configuration.viewerDomain || SITUM_BASE_DOMAIN)) {
|
|
333
|
-
if (onExternalLinkClicked && typeof onExternalLinkClicked === "function") {
|
|
334
|
-
onExternalLinkClicked({
|
|
335
|
-
url: request.url
|
|
336
|
-
});
|
|
337
|
-
} else {
|
|
338
|
-
_reactNative.Linking.openURL(request.url);
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
return true;
|
|
343
|
-
};
|
|
344
|
-
const _effectiveProfile = () => {
|
|
345
|
-
let effectiveProfile = configuration.profile;
|
|
346
|
-
if (configuration.remoteIdentifier && configuration.remoteIdentifier.length > 0) {
|
|
347
|
-
console.warn('Situm> MapView> [!] "remoteIdentifier" is deprecated. Use "profile" instead.');
|
|
348
|
-
if (!configuration.profile || configuration.profile.length == 0) {
|
|
349
|
-
effectiveProfile = configuration.remoteIdentifier;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return effectiveProfile;
|
|
353
|
-
};
|
|
354
|
-
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.default, {
|
|
355
|
-
ref: webViewRef,
|
|
356
|
-
source: {
|
|
357
|
-
uri: `${configuration.viewerDomain || SITUM_BASE_DOMAIN}/${_effectiveProfile() ? `id/${_effectiveProfile()}` : ""}?&apikey=${configuration.situmApiKey}&wl=true&global=true&mode=embed${configuration.buildingIdentifier ? `&buildingid=${configuration.buildingIdentifier}` : ""}&show=rts`
|
|
358
|
-
},
|
|
359
|
-
style: _reactNative.StyleSheet.flatten([viewerStyles.webview, style]),
|
|
360
|
-
limitsNavigationsToAppBoundDomains: true,
|
|
361
|
-
javaScriptEnabled: true,
|
|
362
|
-
domStorageEnabled: true,
|
|
363
|
-
startInLoadingState: true,
|
|
364
|
-
cacheEnabled: true,
|
|
365
|
-
onMessage: handleRequestFromViewer,
|
|
366
|
-
onShouldStartLoadWithRequest: _onShouldStartLoadWithRequest,
|
|
367
|
-
onError: evt => {
|
|
368
|
-
if (!onLoadError) return;
|
|
369
|
-
const {
|
|
370
|
-
nativeEvent
|
|
371
|
-
} = evt;
|
|
372
|
-
// TODO: on render error should probably still try to render an html
|
|
373
|
-
if (nativeEvent.code === NETWORK_ERROR_CODE[_reactNative.Platform.OS]) {
|
|
374
|
-
onLoadError({
|
|
375
|
-
name: _constants.ErrorName.ERR_INTERNET_DISCONNECTED,
|
|
376
|
-
description: nativeEvent.description
|
|
377
|
-
});
|
|
378
|
-
} else {
|
|
379
|
-
// TODO: handle more errors
|
|
380
|
-
onLoadError({
|
|
381
|
-
name: _constants.ErrorName.ERR_INTERNAL_SERVER_ERROR,
|
|
382
|
-
description: nativeEvent.description
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
var _default = exports.default = MapView;
|
|
389
|
-
//# sourceMappingURL=MapView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_interopRequireDefault","_sdk","_hooks","_constants","_utils","_mapper","_store","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SITUM_BASE_DOMAIN","NETWORK_ERROR_CODE","android","ios","windows","macos","web","viewerStyles","StyleSheet","create","webview","minHeight","minWidth","MapView","React","forwardRef","configuration","style","onLoad","onLoadError","onPoiSelected","onPoiDeselected","onFloorChanged","onExternalLinkClicked","undefined","onFavoritePoisUpdated","ref","webViewRef","useRef","_onDirectionsRequestInterceptor","setInterceptor","useState","mapLoaded","setMapLoaded","buildingIdentifier","setBuildingIdentifier","init","location","locationStatus","directions","navigation","calculateRoute","startNavigation","stopNavigation","error","useSitum","sendFollowUser","_location$position","current","position","_followUser","_navigateToPoi","useCallback","payload","identifier","sendMessageToViewer","ViewerMapper","navigateToPoi","followUser","_navigateToCar","navigateToCar","_navigateToPoint","lat","lng","floorIdentifier","navigateToPoint","_selectPoi","poiId","selectPoi","_selectCar","selectCar","_selectPoiCategory","categoryId","SitumPlugin","navigationIsRunning","console","selectPoiCategory","_selectFloor","floorId","options","selectFloor","_search","search","_setDirectionsOptions","directionsOptions","setDirectionsOptions","_setFavoritePois","poiIds","setFavoritePois","_onMapIsReady","locationError","useImperativeHandle","unfollowUser","deselectPoi","setOnDirectionsRequestInterceptor","directionRequestInterceptor","cancelNavigation","useEffect","validateMapViewProjectSettings","code","message","setLocationStatus","setError","route","language","setLanguage","initialConfiguration","handleRequestFromViewer","event","eventParsed","JSON","parse","nativeEvent","data","type","favoritePoisIds","currentPoisIdentifiers","favoritePois","toString","updateNavigationState","_onShouldStartLoadWithRequest","request","url","startsWith","viewerDomain","Linking","openURL","_effectiveProfile","effectiveProfile","profile","remoteIdentifier","length","warn","createElement","source","uri","situmApiKey","flatten","limitsNavigationsToAppBoundDomains","javaScriptEnabled","domStorageEnabled","startInLoadingState","cacheEnabled","onMessage","onShouldStartLoadWithRequest","onError","evt","Platform","OS","name","ErrorName","ERR_INTERNET_DISCONNECTED","description","ERR_INTERNAL_SERVER_ERROR","_default","exports"],"sourceRoot":"../../../../src","sources":["wayfinding/components/MapView.tsx"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,mBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA,IAAAI,IAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAF,sBAAA,CAAAH,OAAA;AAiBA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAuD,SAAAG,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAA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AClB,MAAM;QAAE6F;MAAY,CAAC,GAAGkC,GAAG;MAC3B;MACA,IAAIlC,WAAW,CAACb,IAAI,KAAKlG,kBAAkB,CAACkJ,qBAAQ,CAACC,EAAE,CAAC,EAAE;QACxDjI,WAAW,CAAC;UACVkI,IAAI,EAAEC,oBAAS,CAACC,yBAAyB;UACzCC,WAAW,EAAExC,WAAW,CAACwC;QAC3B,CAAC,CAAC;MACJ,CAAC,MAAM;QACL;QACArI,WAAW,CAAC;UACVkI,IAAI,EAAEC,oBAAS,CAACG,yBAAyB;UACzCD,WAAW,EAAExC,WAAW,CAACwC;QAC3B,CAAC,CAAC;MACJ;IACF;EAAE,CACH,CAAC;AAEN,CACF,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAA7K,OAAA,GAEa+B,OAAO","ignoreList":[]}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useSitumInternal = exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _sdk = _interopRequireDefault(require("../../sdk"));
|
|
9
|
-
var _types = require("../../sdk/types");
|
|
10
|
-
var _constants = require("../../sdk/types/constants");
|
|
11
|
-
var _index = require("../store/index");
|
|
12
|
-
var _utils = require("../store/utils");
|
|
13
|
-
var _mapper = require("../utils/mapper");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
-
|
|
17
|
-
const defaultNavigationRequest = {
|
|
18
|
-
distanceToGoalThreshold: 4,
|
|
19
|
-
outsideRouteThreshold: 5
|
|
20
|
-
};
|
|
21
|
-
const useSitumInternal = () => {
|
|
22
|
-
const dispatch = (0, _utils.useDispatch)();
|
|
23
|
-
const location = (0, _utils.useSelector)(_index.selectLocation);
|
|
24
|
-
const locationStatus = (0, _utils.useSelector)(_index.selectLocationStatus);
|
|
25
|
-
const directions = (0, _utils.useSelector)(_index.selectDirections);
|
|
26
|
-
const navigation = (0, _utils.useSelector)(_index.selectNavigation);
|
|
27
|
-
const error = (0, _utils.useSelector)(_index.selectError);
|
|
28
|
-
const [lockDirections, setLockDirections] = (0, _react.useState)(false);
|
|
29
|
-
const init = () => {
|
|
30
|
-
console.debug("Situm > hook > Initializing -> Registering callbacks");
|
|
31
|
-
registerCallbacks();
|
|
32
|
-
};
|
|
33
|
-
function registerCallbacks() {
|
|
34
|
-
_sdk.default.internalSetMethodCallMapDelegate(internalCall => {
|
|
35
|
-
switch (internalCall.type) {
|
|
36
|
-
case _constants.InternalCallType.LOCATION:
|
|
37
|
-
let location = internalCall.get();
|
|
38
|
-
dispatch((0, _index.setLocation)({
|
|
39
|
-
...location
|
|
40
|
-
}));
|
|
41
|
-
break;
|
|
42
|
-
case _constants.InternalCallType.LOCATION_STATUS:
|
|
43
|
-
let statusName = internalCall.get();
|
|
44
|
-
if (statusName in _constants.LocationStatusName) {
|
|
45
|
-
dispatch((0, _index.setLocationStatus)(statusName));
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
case _constants.InternalCallType.LOCATION_STOPPED:
|
|
49
|
-
// TODO: LOCATION_STOPPED exists only in RN, delete!
|
|
50
|
-
dispatch((0, _index.resetLocation)());
|
|
51
|
-
break;
|
|
52
|
-
case _constants.InternalCallType.LOCATION_ERROR:
|
|
53
|
-
let error = internalCall.get();
|
|
54
|
-
dispatch((0, _index.setError)(error));
|
|
55
|
-
break;
|
|
56
|
-
case _constants.InternalCallType.NAVIGATION_START:
|
|
57
|
-
dispatch((0, _index.setNavigation)({
|
|
58
|
-
type: _constants.NavigationUpdateType.PROGRESS,
|
|
59
|
-
status: _constants.NavigationStatus.START
|
|
60
|
-
}));
|
|
61
|
-
break;
|
|
62
|
-
case _constants.InternalCallType.NAVIGATION_DESTINATION_REACHED:
|
|
63
|
-
dispatch((0, _index.setNavigation)({
|
|
64
|
-
type: _constants.NavigationUpdateType.DESTINATION_REACHED,
|
|
65
|
-
status: _constants.NavigationStatus.UPDATE
|
|
66
|
-
}));
|
|
67
|
-
break;
|
|
68
|
-
case _constants.InternalCallType.NAVIGATION_PROGRESS:
|
|
69
|
-
let progress = internalCall.get();
|
|
70
|
-
dispatch((0, _index.setNavigation)({
|
|
71
|
-
currentIndication: progress === null || progress === void 0 ? void 0 : progress.currentIndication,
|
|
72
|
-
routeStep: progress === null || progress === void 0 ? void 0 : progress.routeStep,
|
|
73
|
-
distanceToGoal: progress === null || progress === void 0 ? void 0 : progress.distanceToGoal,
|
|
74
|
-
points: progress === null || progress === void 0 ? void 0 : progress.points,
|
|
75
|
-
type: _constants.NavigationUpdateType.PROGRESS,
|
|
76
|
-
segments: progress === null || progress === void 0 ? void 0 : progress.segments,
|
|
77
|
-
status: _constants.NavigationStatus.UPDATE
|
|
78
|
-
}));
|
|
79
|
-
break;
|
|
80
|
-
case _constants.InternalCallType.NAVIGATION_OUT_OF_ROUTE:
|
|
81
|
-
dispatch((0, _index.setNavigation)({
|
|
82
|
-
type: _constants.NavigationUpdateType.OUT_OF_ROUTE,
|
|
83
|
-
status: _constants.NavigationStatus.UPDATE
|
|
84
|
-
}));
|
|
85
|
-
break;
|
|
86
|
-
case _constants.InternalCallType.NAVIGATION_CANCELLATION:
|
|
87
|
-
dispatch((0, _index.setNavigation)({
|
|
88
|
-
type: _constants.NavigationUpdateType.CANCELLED,
|
|
89
|
-
status: _constants.NavigationStatus.STOP
|
|
90
|
-
}));
|
|
91
|
-
break;
|
|
92
|
-
case _constants.InternalCallType.NAVIGATION_ERROR:
|
|
93
|
-
case _constants.InternalCallType.GEOFENCES_ENTER:
|
|
94
|
-
case _constants.InternalCallType.GEOFENCES_EXIT:
|
|
95
|
-
// Do nothing.
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const calculateRoute = async (payload, interceptor, updateRoute = true) => {
|
|
101
|
-
console.debug("Situm > hook > calculating route");
|
|
102
|
-
const directionsRequest = (0, _mapper.createDirectionsRequest)(payload.directionsRequest);
|
|
103
|
-
interceptor && interceptor(directionsRequest);
|
|
104
|
-
const {
|
|
105
|
-
to,
|
|
106
|
-
from,
|
|
107
|
-
minimizeFloorChanges,
|
|
108
|
-
accessibilityMode,
|
|
109
|
-
bearingFrom,
|
|
110
|
-
includedTags,
|
|
111
|
-
excludedTags
|
|
112
|
-
} = directionsRequest;
|
|
113
|
-
const {
|
|
114
|
-
originIdentifier,
|
|
115
|
-
destinationIdentifier,
|
|
116
|
-
buildingIdentifier
|
|
117
|
-
} = (0, _mapper.createDirectionsMessage)(payload);
|
|
118
|
-
const _buildings = await _sdk.default.fetchBuildings();
|
|
119
|
-
const _building = _buildings.find(b => b.buildingIdentifier === buildingIdentifier);
|
|
120
|
-
if (!to || !from || lockDirections) {
|
|
121
|
-
console.debug(`Situm > hook > Could not compute route (to: ${to}, from: ${from}, lockDirections: ${lockDirections})`);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// iOS workaround -> does not allow for several direction petitions
|
|
126
|
-
setLockDirections(true);
|
|
127
|
-
return await _sdk.default.requestDirections(_building, from, to, {
|
|
128
|
-
minimizeFloorChanges,
|
|
129
|
-
accessibilityMode,
|
|
130
|
-
bearingFrom,
|
|
131
|
-
includedTags,
|
|
132
|
-
excludedTags
|
|
133
|
-
}).then(_directions => {
|
|
134
|
-
const newRoute = {
|
|
135
|
-
..._directions,
|
|
136
|
-
originIdentifier,
|
|
137
|
-
destinationIdentifier,
|
|
138
|
-
type: accessibilityMode
|
|
139
|
-
};
|
|
140
|
-
if (updateRoute) {
|
|
141
|
-
dispatch((0, _index.setDirections)(newRoute));
|
|
142
|
-
}
|
|
143
|
-
return newRoute;
|
|
144
|
-
}).catch(e => {
|
|
145
|
-
console.error(`Situm > hook > Could not compute route: ${e}`);
|
|
146
|
-
dispatch((0, _index.setDirections)({
|
|
147
|
-
error: JSON.stringify(e)
|
|
148
|
-
}));
|
|
149
|
-
}).finally(() => {
|
|
150
|
-
setLockDirections(false);
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// Navigation
|
|
155
|
-
const startNavigation = (payload, interceptor) => {
|
|
156
|
-
console.debug("Situm > hook > request to start navigation");
|
|
157
|
-
// TODO: we should delegate this to the sdk plugin
|
|
158
|
-
if (!navigation || (navigation === null || navigation === void 0 ? void 0 : navigation.status) !== _constants.NavigationStatus.STOP) {
|
|
159
|
-
stopNavigation();
|
|
160
|
-
}
|
|
161
|
-
calculateRoute(payload, interceptor, false).then(r => {
|
|
162
|
-
if (!r) {
|
|
163
|
-
console.debug(`Situm > hook > No route was computed`);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
dispatch((0, _index.setNavigation)({
|
|
167
|
-
status: _constants.NavigationStatus.START,
|
|
168
|
-
type: _constants.NavigationUpdateType.PROGRESS,
|
|
169
|
-
...r
|
|
170
|
-
}));
|
|
171
|
-
try {
|
|
172
|
-
const navigationRequest = (0, _mapper.createNavigationRequest)(payload.navigationRequest);
|
|
173
|
-
_sdk.default.requestNavigationUpdates({
|
|
174
|
-
...defaultNavigationRequest,
|
|
175
|
-
...navigationRequest
|
|
176
|
-
});
|
|
177
|
-
} catch (e) {
|
|
178
|
-
console.error(`Situm > hook > Could not update navigation ${e}`);
|
|
179
|
-
//TODO: Remove this and emit these errors in SitumPlugin.onNavigationError
|
|
180
|
-
dispatch((0, _index.setError)({
|
|
181
|
-
message: "Could not update navigation",
|
|
182
|
-
code: _types.ErrorCode.UNKNOWN,
|
|
183
|
-
type: _types.ErrorType.NON_CRITICAL
|
|
184
|
-
}));
|
|
185
|
-
stopNavigation();
|
|
186
|
-
}
|
|
187
|
-
}).catch(e => {
|
|
188
|
-
console.error(`Situm > hook > Could not compute route for navigation ${JSON.stringify(e)}`);
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
const stopNavigation = () => {
|
|
192
|
-
// TODO: we should delegate this to the sdk plugin
|
|
193
|
-
if (!navigation || (navigation === null || navigation === void 0 ? void 0 : navigation.status) === _constants.NavigationStatus.STOP) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
console.debug("Situm > hook > Stopping navigation");
|
|
197
|
-
_sdk.default.removeNavigationUpdates().then(() => {
|
|
198
|
-
console.debug("Situm > hook > Successfully removed navigation updates");
|
|
199
|
-
dispatch((0, _index.setNavigation)({
|
|
200
|
-
status: _constants.NavigationStatus.STOP
|
|
201
|
-
}));
|
|
202
|
-
}).catch(e => {
|
|
203
|
-
console.warn(`Situm > hook > Could not remove navigation updates ${JSON.stringify(e)}`);
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
return {
|
|
207
|
-
// States
|
|
208
|
-
location,
|
|
209
|
-
locationStatus,
|
|
210
|
-
directions,
|
|
211
|
-
navigation,
|
|
212
|
-
error,
|
|
213
|
-
// Functions
|
|
214
|
-
init,
|
|
215
|
-
calculateRoute,
|
|
216
|
-
startNavigation,
|
|
217
|
-
stopNavigation
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
exports.useSitumInternal = useSitumInternal;
|
|
221
|
-
const useSitum = () => {
|
|
222
|
-
const context = (0, _react.useContext)(_index.UseSitumContext);
|
|
223
|
-
if (!context) {
|
|
224
|
-
throw new Error("Situm > hook > No SitumProvider found.");
|
|
225
|
-
}
|
|
226
|
-
return context.useSitum;
|
|
227
|
-
};
|
|
228
|
-
var _default = exports.default = useSitum;
|
|
229
|
-
//# sourceMappingURL=index.js.map
|