@situm/react-native 3.12.7 → 3.13.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 (41) hide show
  1. package/lib/commonjs/sdk/index.js +158 -24
  2. package/lib/commonjs/sdk/index.js.map +1 -1
  3. package/lib/commonjs/sdk/types/constants.js +16 -1
  4. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  5. package/lib/commonjs/sdk/types/index.js +11 -1
  6. package/lib/commonjs/sdk/types/index.js.map +1 -1
  7. package/lib/commonjs/sdk/utils.js +10 -0
  8. package/lib/commonjs/sdk/utils.js.map +1 -1
  9. package/lib/commonjs/wayfinding/components/MapView.js +10 -23
  10. package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
  11. package/lib/commonjs/wayfinding/hooks/index.js +64 -64
  12. package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
  13. package/lib/module/sdk/index.js +161 -27
  14. package/lib/module/sdk/index.js.map +1 -1
  15. package/lib/module/sdk/types/constants.js +15 -0
  16. package/lib/module/sdk/types/constants.js.map +1 -1
  17. package/lib/module/sdk/types/index.js +10 -0
  18. package/lib/module/sdk/types/index.js.map +1 -1
  19. package/lib/module/sdk/utils.js +10 -1
  20. package/lib/module/sdk/utils.js.map +1 -1
  21. package/lib/module/wayfinding/components/MapView.js +9 -22
  22. package/lib/module/wayfinding/components/MapView.js.map +1 -1
  23. package/lib/module/wayfinding/hooks/index.js +66 -66
  24. package/lib/module/wayfinding/hooks/index.js.map +1 -1
  25. package/lib/typescript/src/sdk/index.d.ts +8 -1
  26. package/lib/typescript/src/sdk/index.d.ts.map +1 -1
  27. package/lib/typescript/src/sdk/types/constants.d.ts +14 -0
  28. package/lib/typescript/src/sdk/types/constants.d.ts.map +1 -1
  29. package/lib/typescript/src/sdk/types/index.d.ts +7 -1
  30. package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
  31. package/lib/typescript/src/sdk/utils.d.ts +1 -0
  32. package/lib/typescript/src/sdk/utils.d.ts.map +1 -1
  33. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
  34. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/sdk/index.ts +201 -54
  37. package/src/sdk/types/constants.ts +15 -0
  38. package/src/sdk/types/index.ts +15 -0
  39. package/src/sdk/utils.ts +11 -1
  40. package/src/wayfinding/components/MapView.tsx +9 -28
  41. package/src/wayfinding/hooks/index.ts +84 -96
@@ -7,10 +7,13 @@ import {
7
7
  type Error,
8
8
  ErrorCode,
9
9
  ErrorType,
10
+ InternalCall,
10
11
  type Location,
11
12
  type NavigationProgress,
12
13
  } from "../../sdk/types";
13
14
  import {
15
+ InternalCallType,
16
+ LocationStatusName,
14
17
  NavigationStatus,
15
18
  NavigationUpdateType,
16
19
  } from "../../sdk/types/constants";
@@ -24,6 +27,7 @@ import {
24
27
  setDirections,
25
28
  setError,
26
29
  setLocation,
30
+ setLocationStatus,
27
31
  setNavigation,
28
32
  UseSitumContext,
29
33
  } from "../store/index";
@@ -58,102 +62,86 @@ export const useSitumInternal = () => {
58
62
  };
59
63
 
60
64
  function registerCallbacks() {
61
- SitumPlugin.onLocationUpdate((loc: Location) => {
62
- dispatch(
63
- setLocation({
64
- ...loc,
65
- })
66
- );
67
- });
68
-
69
- // TODO: not working, using local state at MapView.tsx.
70
- // SitumPlugin.onLocationStatus((status: LocationStatus) => {
71
- // if (status.statusName in LocationStatusName) {
72
- // console.debug(
73
- // `Situm > hook > Positioning state updated ${status.statusName}`
74
- // );
75
- // dispatch(setLocationStatus(status.statusName as LocationStatusName));
76
- // }
77
- // });
78
-
79
- SitumPlugin.onLocationStopped(() => {
80
- console.debug("Situm > hook > Stopped positioning");
81
- dispatch(resetLocation());
82
- });
83
-
84
- SitumPlugin.onNavigationStart((route) => {
85
- console.debug(
86
- `Situm > hook > navigation started to ${route.poiTo?.poiName}`
87
- );
88
-
89
- dispatch(
90
- setNavigation({
91
- type: NavigationUpdateType.PROGRESS,
92
- status: NavigationStatus.START,
93
- })
94
- );
95
- });
96
-
97
- SitumPlugin.onNavigationProgress((progress: NavigationProgress) => {
98
- console.debug(
99
- `Situm > hook > navigation progress, remanining distance to goal ${progress.distanceToGoal.toFixed(
100
- 2
101
- )} m.`
102
- );
103
-
104
- dispatch(
105
- setNavigation({
106
- currentIndication: progress?.currentIndication,
107
- routeStep: progress?.routeStep,
108
- distanceToGoal: progress?.distanceToGoal,
109
- points: progress?.points,
110
- type: NavigationUpdateType.PROGRESS,
111
- segments: progress?.segments,
112
- status: NavigationStatus.UPDATE,
113
- })
114
- );
115
- });
116
-
117
- SitumPlugin.onNavigationOutOfRoute(() => {
118
- console.debug("Situm > hook > user went out of route, recalculating ...");
119
-
120
- dispatch(
121
- setNavigation({
122
- type: NavigationUpdateType.OUT_OF_ROUTE,
123
- status: NavigationStatus.UPDATE,
124
- })
125
- );
126
- });
127
-
128
- SitumPlugin.onNavigationDestinationReached((route) => {
129
- console.debug(
130
- `Situm > hook > destination ${route.poiTo?.poiName} was reached.`
131
- );
132
-
133
- dispatch(
134
- setNavigation({
135
- type: NavigationUpdateType.DESTINATION_REACHED,
136
- status: NavigationStatus.UPDATE,
137
- })
138
- );
139
- });
140
-
141
- SitumPlugin.onNavigationCancellation(() => {
142
- console.debug("Situm > hook > navigation was cancelled by the user.");
143
-
144
- dispatch(
145
- setNavigation({
146
- type: NavigationUpdateType.CANCELLED,
147
- status: NavigationStatus.STOP,
148
- })
149
- );
150
- });
151
-
152
- SitumPlugin.onNavigationError((navigationError: any) => {
153
- console.error(
154
- "Situm > hook > ERROR while navigating: ",
155
- JSON.stringify(navigationError)
156
- );
65
+ SitumPlugin.internalSetMethodCallMapDelegate((internalCall: InternalCall) => {
66
+ switch(internalCall.type) {
67
+ case InternalCallType.LOCATION:
68
+ let location = internalCall.get<Location>();
69
+ dispatch(
70
+ setLocation({
71
+ ...location,
72
+ })
73
+ );
74
+ break;
75
+ case InternalCallType.LOCATION_STATUS:
76
+ let statusName = internalCall.get<string>();
77
+ if (statusName in LocationStatusName) {
78
+ dispatch(
79
+ setLocationStatus(statusName)
80
+ );
81
+ }
82
+ break;
83
+ case InternalCallType.LOCATION_STOPPED:
84
+ // TODO: LOCATION_STOPPED exists only in RN, delete!
85
+ dispatch(resetLocation());
86
+ break;
87
+ case InternalCallType.LOCATION_ERROR:
88
+ let error = internalCall.get<Error>();
89
+ dispatch(
90
+ setError(error)
91
+ );
92
+ break;
93
+ case InternalCallType.NAVIGATION_START:
94
+ dispatch(
95
+ setNavigation({
96
+ type: NavigationUpdateType.PROGRESS,
97
+ status: NavigationStatus.START,
98
+ })
99
+ );
100
+ break;
101
+ case InternalCallType.NAVIGATION_DESTINATION_REACHED:
102
+ dispatch(
103
+ setNavigation({
104
+ type: NavigationUpdateType.DESTINATION_REACHED,
105
+ status: NavigationStatus.UPDATE,
106
+ })
107
+ );
108
+ break;
109
+ case InternalCallType.NAVIGATION_PROGRESS:
110
+ let progress = internalCall.get<NavigationProgress>();
111
+ dispatch(
112
+ setNavigation({
113
+ currentIndication: progress?.currentIndication,
114
+ routeStep: progress?.routeStep,
115
+ distanceToGoal: progress?.distanceToGoal,
116
+ points: progress?.points,
117
+ type: NavigationUpdateType.PROGRESS,
118
+ segments: progress?.segments,
119
+ status: NavigationStatus.UPDATE,
120
+ })
121
+ );
122
+ break;
123
+ case InternalCallType.NAVIGATION_OUT_OF_ROUTE:
124
+ dispatch(
125
+ setNavigation({
126
+ type: NavigationUpdateType.OUT_OF_ROUTE,
127
+ status: NavigationStatus.UPDATE,
128
+ })
129
+ );
130
+ break;
131
+ case InternalCallType.NAVIGATION_CANCELLATION:
132
+ dispatch(
133
+ setNavigation({
134
+ type: NavigationUpdateType.CANCELLED,
135
+ status: NavigationStatus.STOP,
136
+ })
137
+ );
138
+ break;
139
+ case InternalCallType.NAVIGATION_ERROR:
140
+ case InternalCallType.GEOFENCES_ENTER:
141
+ case InternalCallType.GEOFENCES_EXIT:
142
+ // Do nothing.
143
+ break;
144
+ }
157
145
  });
158
146
  }
159
147