@situm/react-native 3.0.0-beta.0 → 3.0.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/README.md +60 -506
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/android.iml +9 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +63 -0
- package/android/local.properties +8 -0
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sdk/types/index.d.js +349 -0
- package/lib/commonjs/sdk/types/index.d.js.map +1 -1
- package/lib/commonjs/utils/requestPermission.js +2 -2
- package/lib/commonjs/utils/requestPermission.js.map +1 -1
- package/lib/commonjs/wayfinding/components/MapView.js +97 -12
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
- package/lib/commonjs/wayfinding/hooks/index.js +40 -80
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
- package/lib/commonjs/wayfinding/store/index.js +8 -28
- package/lib/commonjs/wayfinding/store/index.js.map +1 -1
- package/lib/commonjs/wayfinding/utils/mapper.js +6 -4
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/types/index.d.js +373 -1
- package/lib/module/sdk/types/index.d.js.map +1 -1
- package/lib/module/utils/requestPermission.js +2 -2
- package/lib/module/utils/requestPermission.js.map +1 -1
- package/lib/module/wayfinding/components/MapView.js +97 -11
- package/lib/module/wayfinding/components/MapView.js.map +1 -1
- package/lib/module/wayfinding/hooks/index.js +8 -49
- package/lib/module/wayfinding/hooks/index.js.map +1 -1
- package/lib/module/wayfinding/store/index.js +3 -24
- package/lib/module/wayfinding/store/index.js.map +1 -1
- package/lib/module/wayfinding/utils/mapper.js +6 -4
- package/lib/module/wayfinding/utils/mapper.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +5 -2
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/hooks/index.d.ts +3 -12
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/store/index.d.ts +3 -62
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts +3 -2
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/index.ts +1 -0
- package/src/sdk/types/index.d.ts +80 -0
- package/src/utils/requestPermission.ts +2 -2
- package/src/wayfinding/components/MapView.tsx +329 -217
- package/src/wayfinding/hooks/index.ts +17 -78
- package/src/wayfinding/store/index.tsx +13 -80
- package/src/wayfinding/types/index.d.ts +10 -11
- package/src/wayfinding/utils/mapper.ts +16 -13
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
Building,
|
|
6
|
-
DirectionPoint,
|
|
7
|
-
LocationRequestOptions,
|
|
8
|
-
|
|
4
|
+
import {
|
|
5
|
+
type Building,
|
|
6
|
+
type DirectionPoint,
|
|
7
|
+
type LocationRequestOptions,
|
|
8
|
+
LocationStatus,
|
|
9
|
+
LocationStatusName,
|
|
10
|
+
NavigationStatus,
|
|
11
|
+
NavigationUpdateType,
|
|
12
|
+
type Poi,
|
|
13
|
+
type Position,
|
|
14
|
+
type SDKError,
|
|
15
|
+
type SDKNavigation,
|
|
9
16
|
} from "../../index";
|
|
10
17
|
import SitumPlugin from "../../sdk";
|
|
11
18
|
import requestPermission from "../../utils/requestPermission";
|
|
12
19
|
import {
|
|
13
|
-
NavigateToPoiType,
|
|
14
|
-
NavigationStatus,
|
|
15
|
-
NavigationUpdateType,
|
|
16
|
-
Position,
|
|
17
|
-
PositioningStatus,
|
|
18
20
|
resetLocation,
|
|
19
|
-
SDKError,
|
|
20
|
-
SDKNavigation,
|
|
21
21
|
selectBuildings,
|
|
22
22
|
selectCurrentBuilding,
|
|
23
23
|
selectDestinationPoiID,
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
selectNavigation,
|
|
30
30
|
selectPois,
|
|
31
31
|
selectUser,
|
|
32
|
-
selectWebViewRef,
|
|
33
32
|
setAuth,
|
|
34
33
|
setBuildings,
|
|
35
34
|
setCurrentBuilding,
|
|
@@ -44,23 +43,16 @@ import {
|
|
|
44
43
|
State,
|
|
45
44
|
} from "../store/index";
|
|
46
45
|
import { useDispatch, useSelector } from "../store/utils";
|
|
47
|
-
import { sendMessageToViewer } from "../utils";
|
|
48
|
-
import Mapper from "../utils/mapper";
|
|
49
46
|
|
|
50
47
|
const defaultNavigationOptions = {
|
|
51
48
|
distanceToGoalThreshold: 4,
|
|
52
49
|
outsideRouteThreshold: 5,
|
|
53
50
|
};
|
|
54
51
|
|
|
55
|
-
export interface LocationStatus {
|
|
56
|
-
statusName: string;
|
|
57
|
-
statusCode: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
52
|
// Hook to define references that point to functions
|
|
61
53
|
// used on listeners. These references are updated whenever
|
|
62
54
|
// one of the dependencies on the array change
|
|
63
|
-
const useCallbackRef = <T>(fn: T, deps: any[]) => {
|
|
55
|
+
export const useCallbackRef = <T>(fn: T, deps: any[]) => {
|
|
64
56
|
const fnRef = useRef(fn);
|
|
65
57
|
|
|
66
58
|
useEffect(() => {
|
|
@@ -73,7 +65,6 @@ const useCallbackRef = <T>(fn: T, deps: any[]) => {
|
|
|
73
65
|
|
|
74
66
|
const useSitum = () => {
|
|
75
67
|
const dispatch = useDispatch();
|
|
76
|
-
const webViewRef = useSelector(selectWebViewRef);
|
|
77
68
|
const isSdkInitialized = useSelector(selectIsSdkInitialized);
|
|
78
69
|
const user = useSelector(selectUser);
|
|
79
70
|
const location = useSelector(selectLocation);
|
|
@@ -170,7 +161,7 @@ const useSitum = () => {
|
|
|
170
161
|
});
|
|
171
162
|
|
|
172
163
|
const initializeBuildingById = async (buildingId: string) => {
|
|
173
|
-
if (buildings.length === 0) return;
|
|
164
|
+
if (!buildings || buildings.length === 0) return;
|
|
174
165
|
const newBuilding = buildings.find(
|
|
175
166
|
(b: Building) => b.buildingIdentifier === buildingId
|
|
176
167
|
);
|
|
@@ -212,7 +203,7 @@ const useSitum = () => {
|
|
|
212
203
|
const startPositioning = () => {
|
|
213
204
|
console.debug("Situm > hook > Starting positioning...");
|
|
214
205
|
|
|
215
|
-
if (location.status !==
|
|
206
|
+
if (location.status !== LocationStatusName.STOPPED) {
|
|
216
207
|
console.debug("Situm > hook > Positioning has already started");
|
|
217
208
|
return;
|
|
218
209
|
}
|
|
@@ -231,11 +222,11 @@ const useSitum = () => {
|
|
|
231
222
|
);
|
|
232
223
|
},
|
|
233
224
|
(status: LocationStatus) => {
|
|
234
|
-
if (status.statusName in
|
|
225
|
+
if (status.statusName in LocationStatusName) {
|
|
235
226
|
console.debug(
|
|
236
227
|
`Situm > hook > Positioning state updated ${status.statusName}`
|
|
237
228
|
);
|
|
238
|
-
dispatch(setLocationStatus(status.statusName as
|
|
229
|
+
dispatch(setLocationStatus(status.statusName as LocationStatusName));
|
|
239
230
|
}
|
|
240
231
|
},
|
|
241
232
|
(err: string) => {
|
|
@@ -421,34 +412,6 @@ const useSitum = () => {
|
|
|
421
412
|
});
|
|
422
413
|
};
|
|
423
414
|
|
|
424
|
-
const navigateToPoi = async ({
|
|
425
|
-
poi,
|
|
426
|
-
poiId,
|
|
427
|
-
}: {
|
|
428
|
-
poi?: Poi;
|
|
429
|
-
poiId?: number;
|
|
430
|
-
}) => {
|
|
431
|
-
if (!poi && !poiId) return;
|
|
432
|
-
const validPoi = pois?.find(
|
|
433
|
-
(p) =>
|
|
434
|
-
p?.identifier === poiId?.toString() ||
|
|
435
|
-
// @ts-ignore
|
|
436
|
-
p?.identifier === poi?.id?.toString()
|
|
437
|
-
);
|
|
438
|
-
if (!validPoi) {
|
|
439
|
-
console.error("Situm > hook > Invalid value as poi or poiId");
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
sendMessageToViewer(
|
|
444
|
-
webViewRef.current,
|
|
445
|
-
Mapper.navigateToPoi({
|
|
446
|
-
// @ts-ignore
|
|
447
|
-
navigationTo: poi?.id || poiId,
|
|
448
|
-
} as NavigateToPoiType)
|
|
449
|
-
);
|
|
450
|
-
};
|
|
451
|
-
|
|
452
415
|
const stopNavigation = (): void => {
|
|
453
416
|
console.debug("Stopping navigation");
|
|
454
417
|
if (!navigation || navigation.status === NavigationStatus.STOP) {
|
|
@@ -464,27 +427,6 @@ const useSitum = () => {
|
|
|
464
427
|
dispatch(setNavigation({ status: NavigationStatus.STOP }));
|
|
465
428
|
dispatch(setDestinationPoiID(undefined));
|
|
466
429
|
};
|
|
467
|
-
|
|
468
|
-
const cancelNavigation = (): void => {
|
|
469
|
-
stopNavigation();
|
|
470
|
-
sendMessageToViewer(webViewRef.current, Mapper.cancelNavigation());
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
const selectPoi = (poiId: number): void => {
|
|
474
|
-
const poi = pois?.find((p) => p?.identifier === poiId?.toString());
|
|
475
|
-
if (!poi) {
|
|
476
|
-
console.error("Situm > hook > Invalid value as poiId");
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
if (navigation.status !== NavigationStatus.STOP) {
|
|
480
|
-
console.error(
|
|
481
|
-
"Situm > hook > Navigation on course, poi selection is unavailable"
|
|
482
|
-
);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
sendMessageToViewer(webViewRef.current, Mapper.selectPoi(poiId));
|
|
486
|
-
};
|
|
487
|
-
|
|
488
430
|
const stopNavigationRef = useCallbackRef(stopNavigation, [navigation]);
|
|
489
431
|
|
|
490
432
|
useEffect(() => {
|
|
@@ -530,9 +472,6 @@ const useSitum = () => {
|
|
|
530
472
|
calculateRoute,
|
|
531
473
|
startNavigation,
|
|
532
474
|
stopNavigation,
|
|
533
|
-
cancelNavigation,
|
|
534
|
-
selectPoi,
|
|
535
|
-
navigateToPoi,
|
|
536
475
|
};
|
|
537
476
|
};
|
|
538
477
|
|
|
@@ -1,98 +1,31 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import React, { createContext, MutableRefObject, useReducer } from "react";
|
|
3
|
-
//@ts-ignore
|
|
4
|
-
import { Building, Poi } from "react-native-situm-plugin";
|
|
5
3
|
|
|
4
|
+
import {
|
|
5
|
+
Building,
|
|
6
|
+
Location,
|
|
7
|
+
LocationStatusName,
|
|
8
|
+
NavigationStatus,
|
|
9
|
+
Poi,
|
|
10
|
+
SDKError,
|
|
11
|
+
SDKNavigation,
|
|
12
|
+
} from "../../sdk/types/index.d";
|
|
6
13
|
import { createReducer } from "./utils";
|
|
7
14
|
|
|
8
|
-
export interface Location {
|
|
9
|
-
position?: Position;
|
|
10
|
-
accuracy?: number;
|
|
11
|
-
bearing?: {
|
|
12
|
-
degrees: number;
|
|
13
|
-
degreesClockwise: number;
|
|
14
|
-
};
|
|
15
|
-
hasBearing?: boolean;
|
|
16
|
-
status: PositioningStatus;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Position {
|
|
20
|
-
coordinate: {
|
|
21
|
-
latitude: number;
|
|
22
|
-
longitude: number;
|
|
23
|
-
};
|
|
24
|
-
cartesianCoordinate: {
|
|
25
|
-
x: number;
|
|
26
|
-
y: number;
|
|
27
|
-
};
|
|
28
|
-
isIndoor?: boolean;
|
|
29
|
-
isOutdoor?: boolean;
|
|
30
|
-
buildingIdentifier?: string;
|
|
31
|
-
floorIdentifier?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export enum PositioningStatus {
|
|
35
|
-
STARTING = "STARTING",
|
|
36
|
-
CALCULATING = "CALCULATING",
|
|
37
|
-
// This status will always be sent to mapviewer-web, in case we recieve
|
|
38
|
-
// a location from SDK.
|
|
39
|
-
POSITIONING = "POSITIONING",
|
|
40
|
-
USER_NOT_IN_BUILDING = "USER_NOT_IN_BUILDING",
|
|
41
|
-
STOPPED = "STOPPED",
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface SDKNavigation {
|
|
45
|
-
//closestPositionInRoute: any;
|
|
46
|
-
currentIndication?: any;
|
|
47
|
-
//currentStepIndex:number;
|
|
48
|
-
//distanceToEndStep: number;
|
|
49
|
-
distanceToGoal?: number;
|
|
50
|
-
//nextIndication: any;
|
|
51
|
-
points?: any;
|
|
52
|
-
routeStep?: any;
|
|
53
|
-
segments?: any;
|
|
54
|
-
route?: Directions;
|
|
55
|
-
//timeToEndStep: number;
|
|
56
|
-
//timeToGoal: number;
|
|
57
|
-
type?: NavigationUpdateType;
|
|
58
|
-
status: NavigationStatus;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export enum NavigationStatus {
|
|
62
|
-
START = "start",
|
|
63
|
-
STOP = "stop",
|
|
64
|
-
UPDATE = "update",
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export enum NavigationUpdateType {
|
|
68
|
-
progress = "PROGRESS",
|
|
69
|
-
userOutsideRoute = "OUT_OF_ROUTE",
|
|
70
|
-
destinationReached = "DESTINATION_REACHED",
|
|
71
|
-
}
|
|
72
|
-
|
|
73
15
|
// TODO: add types
|
|
74
16
|
export type Directions = any;
|
|
75
17
|
|
|
76
|
-
export type NavigateToPoiType = {
|
|
77
|
-
navigationTo: number;
|
|
78
|
-
type?: string;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
18
|
interface User {
|
|
82
19
|
email?: string;
|
|
83
20
|
apiKey?: string;
|
|
84
21
|
}
|
|
85
|
-
export interface SDKError {
|
|
86
|
-
code?: number;
|
|
87
|
-
message: string;
|
|
88
|
-
}
|
|
89
22
|
|
|
90
23
|
export interface State {
|
|
91
24
|
webViewRef: MutableRefObject<undefined>;
|
|
92
25
|
sdkInitialized: boolean;
|
|
93
26
|
user?: User;
|
|
94
27
|
location?: Location;
|
|
95
|
-
buildings: Building[];
|
|
28
|
+
buildings: Building[] | null;
|
|
96
29
|
currentBuilding: Building;
|
|
97
30
|
pois: Poi[];
|
|
98
31
|
directions?: Directions;
|
|
@@ -105,8 +38,8 @@ export const initialState: State = {
|
|
|
105
38
|
webViewRef: undefined,
|
|
106
39
|
sdkInitialized: false,
|
|
107
40
|
user: undefined,
|
|
108
|
-
location: { status:
|
|
109
|
-
buildings:
|
|
41
|
+
location: { status: LocationStatusName.STOPPED },
|
|
42
|
+
buildings: null,
|
|
110
43
|
currentBuilding: undefined,
|
|
111
44
|
pois: [],
|
|
112
45
|
directions: undefined,
|
|
@@ -132,7 +65,7 @@ const Reducer = createReducer<State>({
|
|
|
132
65
|
setLocation: (state: State, payload: State["location"]) => {
|
|
133
66
|
return { ...state, location: payload };
|
|
134
67
|
},
|
|
135
|
-
setLocationStatus: (state: State, payload:
|
|
68
|
+
setLocationStatus: (state: State, payload: LocationStatusName) => {
|
|
136
69
|
return { ...state, location: { ...state.location, status: payload } };
|
|
137
70
|
},
|
|
138
71
|
resetLocation: (state: State) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
//@ts-ignore
|
|
2
|
+
import { DirectionPoint } from "src/sdk/types";
|
|
3
|
+
|
|
2
4
|
import { ErrorName } from "../components/MapView";
|
|
3
5
|
|
|
4
6
|
interface MapViewError {
|
|
@@ -6,6 +8,12 @@ interface MapViewError {
|
|
|
6
8
|
description: string;
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
export interface MapViewRef {
|
|
12
|
+
selectPoi: (poiId: number) => void;
|
|
13
|
+
navigateToPoi: ({ poi, poiId }: { poi?: Poi; poiId?: number }) => void;
|
|
14
|
+
cancelNavigation: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
export interface WayfindingResult {
|
|
10
18
|
status: string;
|
|
11
19
|
message: string;
|
|
@@ -30,21 +38,12 @@ export interface OnFloorChangedResult {
|
|
|
30
38
|
fromFloorName: string;
|
|
31
39
|
toFloorName: string;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
buildingId: string;
|
|
35
|
-
floorId: string;
|
|
36
|
-
latitude: number;
|
|
37
|
-
longitude: number;
|
|
38
|
-
}
|
|
39
|
-
export interface Error {
|
|
40
|
-
code: number;
|
|
41
|
-
message: string;
|
|
42
|
-
}
|
|
41
|
+
|
|
43
42
|
export interface Destination {
|
|
44
43
|
category: string;
|
|
45
44
|
identifier?: string;
|
|
46
45
|
name?: string;
|
|
47
|
-
point:
|
|
46
|
+
point: DirectionPoint;
|
|
48
47
|
}
|
|
49
48
|
export interface Navigation {
|
|
50
49
|
status: string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Destination, Navigation, Point } from "..";
|
|
3
2
|
import {
|
|
4
|
-
|
|
3
|
+
DirectionPoint,
|
|
5
4
|
Location,
|
|
6
5
|
NavigateToPoiType,
|
|
7
6
|
SDKNavigation,
|
|
8
|
-
} from "
|
|
7
|
+
} from "../../sdk/types/index.d";
|
|
8
|
+
import { Destination, Navigation } from "..";
|
|
9
|
+
import { Directions } from "../store/index";
|
|
9
10
|
|
|
10
11
|
const mapperWrapper = (type: string, payload: unknown) =>
|
|
11
12
|
JSON.stringify({ type, payload });
|
|
@@ -42,7 +43,7 @@ const Mapper = {
|
|
|
42
43
|
|
|
43
44
|
cancelNavigation: () => mapperWrapper(`navigation.cancel`, {}),
|
|
44
45
|
|
|
45
|
-
selectPoi: (poiId: number) =>
|
|
46
|
+
selectPoi: (poiId: number | null) =>
|
|
46
47
|
mapperWrapper(`cartography.select_poi`, { identifier: poiId }),
|
|
47
48
|
|
|
48
49
|
followUser: (follow: boolean) => mapperWrapper("camera.follow_user", follow),
|
|
@@ -89,18 +90,20 @@ const Mapper = {
|
|
|
89
90
|
identifier: navigation?.destinationId,
|
|
90
91
|
//name:, //TODO
|
|
91
92
|
point: {
|
|
92
|
-
|
|
93
|
+
buildingIdentifier:
|
|
93
94
|
navigation.to.buildingIdentifier ||
|
|
94
95
|
navigation.TO.buildingIdentifier,
|
|
95
|
-
|
|
96
|
+
floorIdentifier:
|
|
96
97
|
navigation.to.floorIdentifier || navigation.TO.floorIdentifier,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
coordinate: {
|
|
99
|
+
latitude:
|
|
100
|
+
navigation.to.coordinate.latitude ||
|
|
101
|
+
navigation.TO.coordinate.latitude,
|
|
102
|
+
longitude:
|
|
103
|
+
navigation.to.coordinate.longitude ||
|
|
104
|
+
navigation.TO.coordinate.longitude,
|
|
105
|
+
},
|
|
106
|
+
} as DirectionPoint,
|
|
104
107
|
} as Destination,
|
|
105
108
|
} as Navigation;
|
|
106
109
|
},
|