@situm/react-native 3.0.10 → 3.1.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.
Files changed (77) hide show
  1. package/android/src/main/java/com/situm/plugin/PluginHelper.java +3 -2
  2. package/android/src/main/java/com/situm/plugin/SitumMapper.java +38 -59
  3. package/android/src/main/java/com/situm/plugin/SitumPlugin.java +1 -0
  4. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
  5. package/ios/SitumPlugin.m +8 -2
  6. package/lib/commonjs/sdk/index.js +509 -251
  7. package/lib/commonjs/sdk/index.js.map +1 -1
  8. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  9. package/lib/commonjs/sdk/types/constants.js +31 -4
  10. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  11. package/lib/commonjs/sdk/utils.js +103 -0
  12. package/lib/commonjs/sdk/utils.js.map +1 -0
  13. package/lib/commonjs/utils/requestPermission.js +9 -16
  14. package/lib/commonjs/utils/requestPermission.js.map +1 -1
  15. package/lib/commonjs/wayfinding/components/MapView.js +78 -134
  16. package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
  17. package/lib/commonjs/wayfinding/hooks/index.js +118 -278
  18. package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
  19. package/lib/commonjs/wayfinding/store/index.js +17 -6
  20. package/lib/commonjs/wayfinding/store/index.js.map +1 -1
  21. package/lib/commonjs/wayfinding/types/index.js +1 -3
  22. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  23. package/lib/commonjs/wayfinding/utils/mapper.js +128 -71
  24. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  25. package/lib/module/sdk/index.js +509 -249
  26. package/lib/module/sdk/index.js.map +1 -1
  27. package/lib/module/sdk/nativeInterface.js.map +1 -1
  28. package/lib/module/sdk/types/constants.js +27 -3
  29. package/lib/module/sdk/types/constants.js.map +1 -1
  30. package/lib/module/sdk/utils.js +94 -0
  31. package/lib/module/sdk/utils.js.map +1 -0
  32. package/lib/module/utils/requestPermission.js +9 -16
  33. package/lib/module/utils/requestPermission.js.map +1 -1
  34. package/lib/module/wayfinding/components/MapView.js +77 -133
  35. package/lib/module/wayfinding/components/MapView.js.map +1 -1
  36. package/lib/module/wayfinding/hooks/index.js +119 -278
  37. package/lib/module/wayfinding/hooks/index.js.map +1 -1
  38. package/lib/module/wayfinding/store/index.js +15 -6
  39. package/lib/module/wayfinding/store/index.js.map +1 -1
  40. package/lib/module/wayfinding/types/index.js +1 -1
  41. package/lib/module/wayfinding/types/index.js.map +1 -1
  42. package/lib/module/wayfinding/utils/mapper.js +123 -72
  43. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  44. package/lib/typescript/src/sdk/index.d.ts +183 -145
  45. package/lib/typescript/src/sdk/index.d.ts.map +1 -1
  46. package/lib/typescript/src/sdk/nativeInterface.d.ts +59 -0
  47. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -1
  48. package/lib/typescript/src/sdk/types/constants.d.ts +24 -3
  49. package/lib/typescript/src/sdk/types/constants.d.ts.map +1 -1
  50. package/lib/typescript/src/sdk/types/index.d.ts +91 -146
  51. package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
  52. package/lib/typescript/src/sdk/utils.d.ts +53 -0
  53. package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
  54. package/lib/typescript/src/utils/requestPermission.d.ts +1 -1
  55. package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -1
  56. package/lib/typescript/src/wayfinding/components/MapView.d.ts +16 -28
  57. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
  58. package/lib/typescript/src/wayfinding/hooks/index.d.ts +3 -34
  59. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
  60. package/lib/typescript/src/wayfinding/store/index.d.ts +8 -6
  61. package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -1
  62. package/lib/typescript/src/wayfinding/types/index.d.ts +36 -17
  63. package/lib/typescript/src/wayfinding/types/index.d.ts.map +1 -1
  64. package/lib/typescript/src/wayfinding/utils/mapper.d.ts +16 -11
  65. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -1
  66. package/package.json +2 -2
  67. package/src/sdk/index.ts +467 -476
  68. package/src/sdk/nativeInterface.ts +149 -1
  69. package/src/sdk/types/constants.ts +27 -3
  70. package/src/sdk/types/index.ts +98 -158
  71. package/src/sdk/utils.ts +129 -0
  72. package/src/utils/requestPermission.ts +18 -23
  73. package/src/wayfinding/components/MapView.tsx +145 -215
  74. package/src/wayfinding/hooks/index.ts +155 -385
  75. package/src/wayfinding/store/index.tsx +19 -9
  76. package/src/wayfinding/types/index.ts +49 -15
  77. package/src/wayfinding/utils/mapper.ts +145 -104
@@ -4,15 +4,12 @@ import React, { createContext, type MutableRefObject, useReducer } from "react";
4
4
  import {
5
5
  type Building,
6
6
  type Directions,
7
+ type Error,
7
8
  type Location,
9
+ type NavigationProgress,
8
10
  type Poi,
9
- type SDKError,
10
- type SDKNavigation,
11
11
  } from "../../sdk/types";
12
- import {
13
- LocationStatusName,
14
- NavigationStatus,
15
- } from "../../sdk/types/constants";
12
+ import { LocationStatusName } from "../../sdk/types/constants";
16
13
  import { useSitumInternal } from "../hooks";
17
14
  import { createStore } from "./utils";
18
15
 
@@ -30,9 +27,10 @@ export interface State {
30
27
  currentBuilding: Building;
31
28
  pois: Poi[];
32
29
  directions?: Directions;
33
- navigation?: SDKNavigation;
30
+ navigation?: NavigationProgress;
34
31
  destinationPoiID?: number;
35
- error?: SDKError;
32
+ error?: Error;
33
+ buildingIdentifier: string;
36
34
  }
37
35
 
38
36
  export const initialState: State = {
@@ -44,9 +42,10 @@ export const initialState: State = {
44
42
  currentBuilding: undefined,
45
43
  pois: [],
46
44
  directions: undefined,
47
- navigation: { status: NavigationStatus.STOP },
45
+ navigation: undefined,
48
46
  destinationPoiID: undefined,
49
47
  error: undefined,
48
+ buildingIdentifier: "-1",
50
49
  };
51
50
 
52
51
  export const SitumContext = createContext<
@@ -98,6 +97,12 @@ const store = createStore<State>({
98
97
  setError: (state: State, payload: State["error"]) => {
99
98
  return { ...state, error: payload };
100
99
  },
100
+ setBuildingIdentifier: (
101
+ state: State,
102
+ payload: State["buildingIdentifier"]
103
+ ) => {
104
+ return { ...state, buildingIdentifier: payload };
105
+ },
101
106
  },
102
107
  });
103
108
 
@@ -149,6 +154,10 @@ export const selectError = (state: State) => {
149
154
  return state.error;
150
155
  };
151
156
 
157
+ export const selectBuildingIdentifier = (state: State) => {
158
+ return state.buildingIdentifier;
159
+ };
160
+
152
161
  export const {
153
162
  setWebViewRef,
154
163
  setSdkInitialized,
@@ -163,6 +172,7 @@ export const {
163
172
  setNavigation,
164
173
  setDestinationPoiID,
165
174
  setError,
175
+ setBuildingIdentifier,
166
176
  } = store.actions;
167
177
 
168
178
  /**
@@ -1,4 +1,6 @@
1
- import type { DirectionPoint, Poi } from "../../sdk/types";
1
+ import { AccessibilityMode } from "src/sdk";
2
+
3
+ import type { Point } from "../../sdk/types";
2
4
  import { ErrorName } from "./constants";
3
5
 
4
6
  export interface MapViewError {
@@ -8,7 +10,26 @@ export interface MapViewError {
8
10
 
9
11
  export interface MapViewRef {
10
12
  selectPoi: (poiId: number) => void;
11
- navigateToPoi: ({ poi, poiId }: { poi?: Poi; poiId?: number }) => void;
13
+ navigateToPoi: ({
14
+ identifier,
15
+ accessibilityMode = AccessibilityMode.CHOOSE_SHORTEST,
16
+ }: {
17
+ identifier: number;
18
+ accessibilityMode?: AccessibilityMode;
19
+ }) => void;
20
+ navigateToPoint: ({
21
+ lat,
22
+ lng,
23
+ floorIdentifier,
24
+ navigationName,
25
+ accessibilityMode = AccessibilityMode.CHOOSE_SHORTEST,
26
+ }: {
27
+ lat: number;
28
+ lng: number;
29
+ floorIdentifier: string;
30
+ navigationName?: string;
31
+ accessibilityMode?: AccessibilityMode;
32
+ }) => void;
12
33
  cancelNavigation: () => void;
13
34
  }
14
35
 
@@ -18,17 +39,13 @@ export interface WayfindingResult {
18
39
  }
19
40
 
20
41
  export interface OnPoiSelectedResult {
21
- buildingId: string;
22
- buildingName: string;
23
- floorId: string;
24
- floorName: string;
25
- poiId: string;
26
- poiName: string;
42
+ identifier: string;
43
+ buildingIdentifier: string;
27
44
  }
28
45
 
29
46
  export interface OnPoiDeselectedResult {
30
- buildingId: string;
31
- buildingName: string;
47
+ identifier: string;
48
+ buildingIdentifier: string;
32
49
  }
33
50
 
34
51
  export interface OnFloorChangedResult {
@@ -44,7 +61,7 @@ export interface Destination {
44
61
  category: string;
45
62
  identifier?: string;
46
63
  name?: string;
47
- point: DirectionPoint;
64
+ point: Point;
48
65
  }
49
66
 
50
67
  export interface Navigation {
@@ -53,11 +70,28 @@ export interface Navigation {
53
70
  }
54
71
 
55
72
  export interface OnNavigationResult {
56
- navigation: Navigation;
73
+ navigation?: Navigation;
57
74
  error?: Error;
58
75
  }
59
76
 
60
- export type NavigateToPoiType = {
61
- navigationTo: number;
62
- type?: string;
77
+ export type NavigateToPoiPayload = {
78
+ identifier: number;
79
+ accessibilityMode?: AccessibilityMode;
80
+ };
81
+
82
+ export type NavigateToPointPayload = {
83
+ lat: number;
84
+ lng: number;
85
+ floorIdentifier: string;
86
+ navigationName?: string;
87
+ accessibilityMode?: AccessibilityMode;
88
+ };
89
+
90
+ export type DirectionsMessage = {
91
+ buildingIdentifier: string;
92
+ originIdentifier: string;
93
+ originCategory: string;
94
+ destinationIdentifier: string;
95
+ destinationCategory: string;
96
+ identifier: string;
63
97
  };
@@ -1,18 +1,102 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { AccessibilityMode } from "../../sdk";
2
3
  import type {
3
- DirectionPoint,
4
4
  Directions,
5
+ DirectionsRequest,
5
6
  Location,
6
- SDKNavigation,
7
+ NavigationProgress,
8
+ NavigationRequest,
9
+ Point,
7
10
  } from "../../sdk/types";
8
- import type { Destination, NavigateToPoiType, Navigation } from "../types";
11
+ import type {
12
+ DirectionsMessage,
13
+ NavigateToPointPayload,
14
+ NavigateToPoiPayload,
15
+ Navigation,
16
+ OnNavigationResult,
17
+ } from "../types";
18
+
19
+ export const createPoint = (payload: any): Point => {
20
+ return {
21
+ buildingIdentifier: payload.buildingIdentifier,
22
+ floorIdentifier: payload.floorIdentifier,
23
+ cartesianCoordinate: payload.cartesianCoordinate,
24
+ coordinate: payload.coordinate,
25
+ };
26
+ };
9
27
 
10
- const mapperWrapper = (type: string, payload: unknown) =>
11
- JSON.stringify({ type, payload });
28
+ export const createDirectionsMessage = (payload: any): DirectionsMessage => {
29
+ return {
30
+ buildingIdentifier: payload.buildingIdentifier,
31
+ originIdentifier: (payload.originIdentifier || -1).toString(),
32
+ originCategory: payload.originCategory,
33
+ destinationIdentifier: (payload.destinationIdentifier || -1).toString(),
34
+ destinationCategory: payload.destinationCategory,
35
+ identifier: (payload.identifier || "").toString(),
36
+ };
37
+ };
38
+
39
+ export const createDirectionsRequest = (payload: any): DirectionsRequest => {
40
+ return {
41
+ buildingIdentifier: payload.from.buildingIdentifier,
42
+ to: createPoint(payload.to),
43
+ from: createPoint(payload.from),
44
+ bearingFrom: payload.bearingFrom || 0,
45
+ accessibilityMode:
46
+ payload.accessibilityMode || AccessibilityMode.CHOOSE_SHORTEST,
47
+ minimizeFloorChanges: payload.minimizeFloorChanges || false,
48
+ };
49
+ };
50
+
51
+ export const createNavigationRequest = (payload: any): NavigationRequest => {
52
+ const navigationRequest = {
53
+ distanceToGoalThreshold: payload.distanceToGoalThreshold,
54
+ outsideRouteThreshold: payload.outsideRouteThreshold,
55
+ distanceToIgnoreFirstIndication: payload.distanceToIgnoreFirstIndication,
56
+ distanceToFloorChangeThreshold: payload.distanceToFloorChangeThreshold,
57
+ distanceToChangeIndicationThreshold:
58
+ payload.distanceToChangeIndicationThreshold,
59
+ indicationsInterval: payload.indicationsInterval,
60
+ timeToFirstIndication: payload.timeToFirstIndication,
61
+ roundIndicationsStep: payload.roundIndicationsStep,
62
+ timeToIgnoreUnexpectedFloorChanges:
63
+ payload.timeToIgnoreUnexpectedFloorChanges,
64
+ ignoreLowQualityLocations: payload.ignoreLowQualityLocations,
65
+ };
66
+
67
+ return Object.fromEntries(
68
+ Object.entries(navigationRequest || {}).filter(
69
+ ([_, value]) => value !== undefined
70
+ )
71
+ );
72
+ };
73
+
74
+ const mapperWrapper = (type: string, payload: unknown) => {
75
+ return JSON.stringify({ type, payload });
76
+ };
12
77
 
13
- const Mapper = {
14
- location: (location: Location) =>
15
- mapperWrapper("location.update", {
78
+ const ViewerMapper = {
79
+ // Configuration
80
+ followUser: (follow: boolean) => {
81
+ return mapperWrapper("camera.follow_user", follow);
82
+ },
83
+ setLanguage: (lang: string) => {
84
+ return mapperWrapper("ui.set_language", lang);
85
+ },
86
+ initialConfiguration: (style: any) => {
87
+ return mapperWrapper("ui.initial_configuration", {
88
+ ...(style && {
89
+ style: style,
90
+ }),
91
+ });
92
+ },
93
+ // Cartography
94
+ selectPoi: (poiId: number | null) => {
95
+ return mapperWrapper(`cartography.select_poi`, { identifier: poiId });
96
+ },
97
+ // Location
98
+ location: (location: Location) => {
99
+ return mapperWrapper("location.update", {
16
100
  ...(location.position && {
17
101
  latitude: location.position.coordinate.latitude,
18
102
  longitude: location.position.coordinate.longitude,
@@ -27,106 +111,63 @@ const Mapper = {
27
111
  hasBearing: location.hasBearing,
28
112
  }),
29
113
  status: location.status,
30
- }),
31
- locationStatus: (locationStatus: Location["status"]) =>
32
- mapperWrapper("location_status.update", locationStatus),
33
-
34
- route: (directions: Directions) =>
35
- mapperWrapper("directions.update", directions),
36
-
37
- navigation: (navigation: Navigation) =>
38
- mapperWrapper(`navigation.${navigation.status}`, navigation),
39
-
40
- navigateToPoi: (navigate: NavigateToPoiType) =>
41
- mapperWrapper(`navigation.start`, { navigationTo: navigate?.navigationTo }),
42
-
43
- cancelNavigation: () => mapperWrapper(`navigation.cancel`, {}),
44
-
45
- selectPoi: (poiId: number | null) =>
46
- mapperWrapper(`cartography.select_poi`, { identifier: poiId }),
47
-
48
- followUser: (follow: boolean) => mapperWrapper("camera.follow_user", follow),
49
- setLanguage: (lang: string) => mapperWrapper("ui.set_language", lang),
50
-
51
- initialConfiguration: (
52
- style: any,
53
- enablePoiClustering: any,
54
- showPoiNames: any,
55
- minZoom: any,
56
- maxZoom: any,
57
- initialZoom: any,
58
- useDashboardTheme: any
59
- ) =>
60
- mapperWrapper("ui.initial_configuration", {
61
- ...(style && {
62
- style: style,
63
- }),
64
- ...(enablePoiClustering && {
65
- enablePoiClustering: enablePoiClustering,
66
- }),
67
- ...(showPoiNames && {
68
- showPoiNames: showPoiNames,
69
- }),
70
- ...(minZoom && {
71
- minZoom: minZoom,
72
- }),
73
- ...(maxZoom && {
74
- maxZoom: maxZoom,
75
- }),
76
- ...(initialZoom && {
77
- initialZoom: initialZoom,
78
- }),
79
- ...(useDashboardTheme && {
80
- useDashboardTheme: useDashboardTheme,
81
- }),
82
- }),
83
-
84
- routeToResult: (navigation: any): Navigation => {
85
- //console.log('navigation/route to be mapped:', navigation);
114
+ });
115
+ },
116
+ locationStatus: (locationStatus: Location["status"]) => {
117
+ return mapperWrapper("location_status.update", locationStatus);
118
+ },
119
+ // Directions
120
+ route: (directions: Directions) => {
121
+ return mapperWrapper("directions.update", directions);
122
+ },
123
+ routeToResult: (route: any): OnNavigationResult => {
86
124
  return {
87
- status: navigation.status,
88
- destination: {
89
- category: navigation?.destinationId ? "POI" : "COORDINATE",
90
- identifier: navigation?.destinationId,
91
- //name:, //TODO
92
- point: {
93
- buildingIdentifier:
94
- navigation.to.buildingIdentifier ||
95
- navigation.TO.buildingIdentifier,
96
- floorIdentifier:
97
- navigation.to.floorIdentifier || navigation.TO.floorIdentifier,
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,
107
- } as Destination,
108
- } as Navigation;
125
+ navigation: {
126
+ status: route.status,
127
+ destination: {
128
+ category: route?.destinationId ? "POI" : "COORDINATE",
129
+ identifier: route?.destinationId,
130
+ //name:, //TODO
131
+ point: route.to ? createPoint(route.to) : createPoint(route.TO),
132
+ },
133
+ },
134
+ };
109
135
  },
110
-
111
- navigationToResult: (navigation: SDKNavigation): Navigation => {
136
+ // Navigation
137
+ navigation: (navigation: Navigation) => {
138
+ return mapperWrapper(`navigation.${navigation.status}`, navigation);
139
+ },
140
+ navigateToPoi: (navigate: NavigateToPoiPayload) => {
141
+ return mapperWrapper(`navigation.start`, {
142
+ navigationTo: navigate?.identifier,
143
+ type: navigate.accessibilityMode,
144
+ });
145
+ },
146
+ navigateToPoint: ({
147
+ lat,
148
+ lng,
149
+ floorIdentifier,
150
+ navigationName,
151
+ accessibilityMode,
152
+ }: NavigateToPointPayload) => {
153
+ return mapperWrapper(`navigation.start`, {
154
+ lat,
155
+ lng,
156
+ floorIdentifier,
157
+ navigationName,
158
+ type: accessibilityMode,
159
+ });
160
+ },
161
+ cancelNavigation: () => {
162
+ return mapperWrapper(`navigation.cancel`, {});
163
+ },
164
+ navigationToResult: (navigation: NavigationProgress): OnNavigationResult => {
112
165
  return {
113
- status: navigation?.type,
166
+ navigation: {
167
+ status: navigation?.type,
168
+ },
114
169
  };
115
- // return {
116
- // status: navigation.status,
117
- // destination: {
118
- // category: navigation.routeStep.TO.destinationId ? 'POI' : 'COORDINATE',
119
- // identifier: navigation.routeStep.TO.destinationId,
120
- // //name:, //TODO
121
- // point: {
122
- // buildingId: navigation.routeStep.TO.buildingIdentifier,
123
- // floorId: navigation.routeStep.TO.floorIdentifier,
124
- // latitude: navigation.routeStep.TO.coordinate.latitude,
125
- // longitude: navigation.routeStep.TO.coordinate.longitude,
126
- // } as Point,
127
- // } as Destination,
128
- // } as Navigation;
129
170
  },
130
171
  };
131
172
 
132
- export default Mapper;
173
+ export default ViewerMapper;