@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.
Files changed (145) hide show
  1. package/android/src/main/java/com/situm/plugin/PluginHelper.java +1 -1
  2. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
  3. package/ios/SitumPlugin.m +18 -11
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/package.json +1 -0
  6. package/lib/commonjs/sdk/index.js.map +1 -1
  7. package/lib/commonjs/sdk/internaDelegatedState.js.map +1 -0
  8. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  9. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  10. package/lib/commonjs/sdk/types/index.js.map +1 -1
  11. package/lib/commonjs/sdk/utils.js.map +1 -1
  12. package/lib/commonjs/utils/index.js.map +1 -1
  13. package/lib/commonjs/utils/logError.js.map +1 -1
  14. package/lib/commonjs/wayfinding/index.js.map +1 -1
  15. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  16. package/lib/commonjs/wayfinding/utils/index.js.map +1 -1
  17. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/package.json +1 -0
  20. package/lib/module/sdk/index.js.map +0 -1
  21. package/lib/module/sdk/internaDelegatedState.js.map +1 -0
  22. package/lib/module/sdk/nativeInterface.js.map +1 -1
  23. package/lib/module/sdk/types/constants.js.map +1 -1
  24. package/lib/module/sdk/types/index.js.map +1 -1
  25. package/lib/module/sdk/utils.js.map +1 -1
  26. package/lib/module/utils/index.js.map +1 -1
  27. package/lib/module/utils/logError.js.map +0 -1
  28. package/lib/module/wayfinding/index.js.map +1 -1
  29. package/lib/module/wayfinding/types/constants.js.map +1 -1
  30. package/lib/module/wayfinding/types/index.js.map +0 -1
  31. package/lib/module/wayfinding/utils/index.js.map +1 -1
  32. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  33. package/lib/typescript/index.d.ts.map +1 -0
  34. package/lib/typescript/{src/sdk → sdk}/index.d.ts +25 -32
  35. package/lib/typescript/sdk/index.d.ts.map +1 -0
  36. package/lib/typescript/sdk/internaDelegatedState.d.ts +17 -0
  37. package/lib/typescript/sdk/internaDelegatedState.d.ts.map +1 -0
  38. package/lib/typescript/{src/sdk → sdk}/nativeInterface.d.ts +4 -2
  39. package/lib/typescript/sdk/nativeInterface.d.ts.map +1 -0
  40. package/lib/typescript/sdk/types/constants.d.ts.map +1 -0
  41. package/lib/typescript/{src/sdk → sdk}/types/index.d.ts +2 -1
  42. package/lib/typescript/sdk/types/index.d.ts.map +1 -0
  43. package/lib/typescript/{src/sdk → sdk}/utils.d.ts +1 -1
  44. package/lib/typescript/sdk/utils.d.ts.map +1 -0
  45. package/lib/typescript/utils/index.d.ts.map +1 -0
  46. package/lib/typescript/utils/logError.d.ts.map +1 -0
  47. package/lib/typescript/{src/wayfinding → wayfinding}/components/MapView.d.ts +1 -1
  48. package/lib/typescript/wayfinding/components/MapView.d.ts.map +1 -0
  49. package/lib/typescript/wayfinding/hooks/index.d.ts.map +1 -0
  50. package/lib/typescript/wayfinding/index.d.ts.map +1 -0
  51. package/lib/typescript/{src/wayfinding → wayfinding}/store/index.d.ts +13 -13
  52. package/lib/typescript/wayfinding/store/index.d.ts.map +1 -0
  53. package/lib/typescript/{src/wayfinding → wayfinding}/store/utils.d.ts +0 -1
  54. package/lib/typescript/wayfinding/store/utils.d.ts.map +1 -0
  55. package/lib/typescript/wayfinding/types/constants.d.ts.map +1 -0
  56. package/lib/typescript/{src/wayfinding → wayfinding}/types/index.d.ts +1 -1
  57. package/lib/typescript/wayfinding/types/index.d.ts.map +1 -0
  58. package/lib/typescript/wayfinding/utils/index.d.ts +3 -0
  59. package/lib/typescript/wayfinding/utils/index.d.ts.map +1 -0
  60. package/lib/typescript/wayfinding/utils/mapper.d.ts.map +1 -0
  61. package/package.json +24 -35
  62. package/src/sdk/index.ts +67 -52
  63. package/src/sdk/internaDelegatedState.ts +54 -0
  64. package/src/sdk/nativeInterface.ts +31 -27
  65. package/src/sdk/types/index.ts +7 -6
  66. package/src/sdk/utils.ts +12 -9
  67. package/src/utils/logError.ts +1 -1
  68. package/src/wayfinding/components/MapView.tsx +103 -104
  69. package/src/wayfinding/hooks/index.ts +94 -91
  70. package/src/wayfinding/store/index.tsx +4 -4
  71. package/src/wayfinding/types/index.ts +1 -1
  72. package/src/wayfinding/utils/index.ts +2 -1
  73. package/LICENSE +0 -21
  74. package/README.md +0 -200
  75. package/SECURITY-POLICY.md +0 -9
  76. package/lib/commonjs/index.js +0 -73
  77. package/lib/commonjs/sdk/index.js +0 -932
  78. package/lib/commonjs/sdk/nativeInterface.js +0 -20
  79. package/lib/commonjs/sdk/types/constants.js +0 -68
  80. package/lib/commonjs/sdk/types/index.js +0 -405
  81. package/lib/commonjs/sdk/utils.js +0 -156
  82. package/lib/commonjs/utils/index.js +0 -17
  83. package/lib/commonjs/utils/logError.js +0 -21
  84. package/lib/commonjs/wayfinding/components/MapView.js +0 -389
  85. package/lib/commonjs/wayfinding/components/MapView.js.map +0 -1
  86. package/lib/commonjs/wayfinding/hooks/index.js +0 -229
  87. package/lib/commonjs/wayfinding/hooks/index.js.map +0 -1
  88. package/lib/commonjs/wayfinding/index.js +0 -57
  89. package/lib/commonjs/wayfinding/store/index.js +0 -242
  90. package/lib/commonjs/wayfinding/store/index.js.map +0 -1
  91. package/lib/commonjs/wayfinding/store/utils.js +0 -49
  92. package/lib/commonjs/wayfinding/store/utils.js.map +0 -1
  93. package/lib/commonjs/wayfinding/types/constants.js +0 -13
  94. package/lib/commonjs/wayfinding/types/constants.js.map +0 -1
  95. package/lib/commonjs/wayfinding/types/index.js +0 -6
  96. package/lib/commonjs/wayfinding/utils/index.js +0 -11
  97. package/lib/commonjs/wayfinding/utils/mapper.js +0 -206
  98. package/lib/module/index.js +0 -12
  99. package/lib/module/sdk/index.js +0 -903
  100. package/lib/module/sdk/nativeInterface.js +0 -18
  101. package/lib/module/sdk/types/constants.js +0 -63
  102. package/lib/module/sdk/types/index.js +0 -434
  103. package/lib/module/sdk/utils.js +0 -144
  104. package/lib/module/utils/index.js +0 -2
  105. package/lib/module/utils/logError.js +0 -15
  106. package/lib/module/wayfinding/components/MapView.js +0 -379
  107. package/lib/module/wayfinding/components/MapView.js.map +0 -1
  108. package/lib/module/wayfinding/hooks/index.js +0 -220
  109. package/lib/module/wayfinding/hooks/index.js.map +0 -1
  110. package/lib/module/wayfinding/index.js +0 -13
  111. package/lib/module/wayfinding/store/index.js +0 -206
  112. package/lib/module/wayfinding/store/index.js.map +0 -1
  113. package/lib/module/wayfinding/store/utils.js +0 -38
  114. package/lib/module/wayfinding/store/utils.js.map +0 -1
  115. package/lib/module/wayfinding/types/constants.js +0 -7
  116. package/lib/module/wayfinding/types/index.js +0 -2
  117. package/lib/module/wayfinding/utils/index.js +0 -4
  118. package/lib/module/wayfinding/utils/mapper.js +0 -195
  119. package/lib/typescript/src/index.d.ts.map +0 -1
  120. package/lib/typescript/src/sdk/index.d.ts.map +0 -1
  121. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +0 -1
  122. package/lib/typescript/src/sdk/types/constants.d.ts.map +0 -1
  123. package/lib/typescript/src/sdk/types/index.d.ts.map +0 -1
  124. package/lib/typescript/src/sdk/utils.d.ts.map +0 -1
  125. package/lib/typescript/src/utils/index.d.ts.map +0 -1
  126. package/lib/typescript/src/utils/logError.d.ts.map +0 -1
  127. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +0 -1
  128. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +0 -1
  129. package/lib/typescript/src/wayfinding/index.d.ts.map +0 -1
  130. package/lib/typescript/src/wayfinding/store/index.d.ts.map +0 -1
  131. package/lib/typescript/src/wayfinding/store/utils.d.ts.map +0 -1
  132. package/lib/typescript/src/wayfinding/types/constants.d.ts.map +0 -1
  133. package/lib/typescript/src/wayfinding/types/index.d.ts.map +0 -1
  134. package/lib/typescript/src/wayfinding/utils/index.d.ts +0 -3
  135. package/lib/typescript/src/wayfinding/utils/index.d.ts.map +0 -1
  136. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +0 -1
  137. package/security.txt +0 -4
  138. /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
  139. /package/lib/typescript/{src/sdk → sdk}/types/constants.d.ts +0 -0
  140. /package/lib/typescript/{src/utils → utils}/index.d.ts +0 -0
  141. /package/lib/typescript/{src/utils → utils}/logError.d.ts +0 -0
  142. /package/lib/typescript/{src/wayfinding → wayfinding}/hooks/index.d.ts +0 -0
  143. /package/lib/typescript/{src/wayfinding → wayfinding}/index.d.ts +0 -0
  144. /package/lib/typescript/{src/wayfinding → wayfinding}/types/constants.d.ts +0 -0
  145. /package/lib/typescript/{src/wayfinding → wayfinding}/utils/mapper.d.ts +0 -0
@@ -1,932 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {};
7
- exports.default = void 0;
8
- var _reactNative = require("react-native");
9
- var _package = _interopRequireDefault(require("../../package.json"));
10
- var _logError = require("../utils/logError");
11
- var _types = require("./types");
12
- Object.keys(_types).forEach(function (key) {
13
- if (key === "default" || key === "__esModule") return;
14
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
- if (key in exports && exports[key] === _types[key]) return;
16
- Object.defineProperty(exports, key, {
17
- enumerable: true,
18
- get: function () {
19
- return _types[key];
20
- }
21
- });
22
- });
23
- var _constants = require("./types/constants");
24
- Object.keys(_constants).forEach(function (key) {
25
- if (key === "default" || key === "__esModule") return;
26
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
- if (key in exports && exports[key] === _constants[key]) return;
28
- Object.defineProperty(exports, key, {
29
- enumerable: true,
30
- get: function () {
31
- return _constants[key];
32
- }
33
- });
34
- });
35
- var _utils = require("./utils");
36
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
37
- /* eslint-disable @typescript-eslint/no-explicit-any */
38
- /* eslint-disable @typescript-eslint/ban-types */
39
-
40
- const LINKING_ERROR = `The package 'react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
41
- ios: "- You have run 'pod install'\n",
42
- default: ""
43
- }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo managed workflow\n";
44
- const RNCSitumPlugin = _reactNative.NativeModules.RNCSitumPlugin || new Proxy({}, {
45
- get() {
46
- throw new Error(LINKING_ERROR);
47
- }
48
- });
49
- const SitumPluginEventEmitter = new _reactNative.NativeEventEmitter(RNCSitumPlugin);
50
-
51
- // TODO: these do not act as state, not reliable
52
- let positioningRunning = false;
53
- let navigationRunning = false;
54
- let realtimeSubscriptions = [];
55
- let internalMethodCallMapDelegate = _ => {
56
- // internalMethodCallMapDelegate is an empty function by default.
57
- };
58
-
59
- // TODO: For now, I am keeping this behavior as it was, but it seems like a candidate for refactoring.
60
- const locationCallbackForNavigation = loc => {
61
- if (!SitumPlugin.navigationIsRunning()) return;
62
- SitumPlugin.updateNavigationWithLocation(loc);
63
- };
64
-
65
- // Client callbacks:
66
- /* eslint-disable @typescript-eslint/no-empty-function */
67
-
68
- let locationCallback = _ => {};
69
- let locationStatusCallback = _ => {};
70
- let locationStoppedCallback = () => {};
71
- let locationErrorCallback = _ => {};
72
- let navigationStartedCallback = _ => {};
73
- let navigationProgressCallback = _ => {};
74
- let navigationDestinationReachedCallback = _ => {};
75
- let navigationOutOfRouteCallback = () => {};
76
- let navigationFinishedCallback = () => {}; // Deprecated!
77
- let navigationCancellationCallback = () => {};
78
- let navigationErrorCallback = _ => {};
79
- let enterGeofencesCallback = _ => {};
80
- let exitGeofencesCallback = _ => {};
81
-
82
- /* eslint-enable @typescript-eslint/no-empty-function */
83
-
84
- // Internal callbacks:
85
- // These callback functions will be added as listeners to SitumPluginEventEmitter as soon as possible and will be
86
- // listening events for all the plugin lifecycle. They will forward calls to both client callbacks and the MapView
87
- // internal callback.
88
-
89
- const _internalLocationCallback = loc => {
90
- // MapView internal callback:
91
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.LOCATION, loc));
92
- // Navigation internal callback: TODO review this, seems to be different to other plugins and candidate for refactoring.
93
- locationCallbackForNavigation(loc);
94
- // Client callback:
95
- locationCallback(loc);
96
- };
97
- const _internalLocationStatusCallback = status => {
98
- var _locationStatusCallba;
99
- const mapViewStatusName = (0, _utils.locationStatusAdapter)(status.statusName);
100
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.LOCATION_STATUS, mapViewStatusName));
101
- // TODO: we are delegating different values to the internal and client callbacks. The viewer only understands
102
- // the states defined in LocationStatusName, but the integrator might be interested in any state from the SDK.
103
- (_locationStatusCallba = locationStatusCallback) === null || _locationStatusCallba === void 0 || _locationStatusCallba(status);
104
- };
105
- const _internalLocationStoppedCallback = () => {
106
- var _locationStoppedCallb;
107
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.LOCATION_STOPPED, undefined));
108
- // TODO: this callback is used only in RN, delete!
109
- (_locationStoppedCallb = locationStoppedCallback) === null || _locationStoppedCallb === void 0 || _locationStoppedCallb();
110
- };
111
- const _internalLocationErrorCallback = error => {
112
- var _locationErrorCallbac;
113
- const adaptedError = (0, _utils.locationErrorAdapter)(error);
114
- if (adaptedError.type === _types.ErrorType.CRITICAL) SitumPlugin.removeLocationUpdates();
115
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.LOCATION_ERROR, adaptedError));
116
- (_locationErrorCallbac = locationErrorCallback) === null || _locationErrorCallbac === void 0 || _locationErrorCallbac(adaptedError);
117
- };
118
- const _internalNavigationStartedCallback = route => {
119
- var _navigationStartedCal;
120
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_START, route));
121
- (_navigationStartedCal = navigationStartedCallback) === null || _navigationStartedCal === void 0 || _navigationStartedCal(route);
122
- };
123
- const _internalNavigationProgressCallback = progress => {
124
- var _navigationProgressCa;
125
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_PROGRESS, progress));
126
- (_navigationProgressCa = navigationProgressCallback) === null || _navigationProgressCa === void 0 || _navigationProgressCa(progress);
127
- };
128
- const _internalNavigationDestinationReachedCallback = route => {
129
- var _navigationDestinatio;
130
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_DESTINATION_REACHED, route));
131
- (_navigationDestinatio = navigationDestinationReachedCallback) === null || _navigationDestinatio === void 0 || _navigationDestinatio(route);
132
- };
133
- const _internalNavigationOutOfRouteCallback = () => {
134
- var _navigationOutOfRoute;
135
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_OUT_OF_ROUTE, undefined));
136
- (_navigationOutOfRoute = navigationOutOfRouteCallback) === null || _navigationOutOfRoute === void 0 || _navigationOutOfRoute();
137
- };
138
- const _internalNavigationFinishedCallback = () => {
139
- var _navigationFinishedCa;
140
- // Deprecated!
141
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_CANCELLATION, undefined));
142
- (_navigationFinishedCa = navigationFinishedCallback) === null || _navigationFinishedCa === void 0 || _navigationFinishedCa();
143
- };
144
- const _internalNavigationCancellationCallback = () => {
145
- var _navigationCancellati;
146
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_CANCELLATION, undefined));
147
- (_navigationCancellati = navigationCancellationCallback) === null || _navigationCancellati === void 0 || _navigationCancellati();
148
- };
149
- const _internalNavigationErrorCallback = error => {
150
- var _navigationErrorCallb;
151
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.NAVIGATION_ERROR, error));
152
- (_navigationErrorCallb = navigationErrorCallback) === null || _navigationErrorCallb === void 0 || _navigationErrorCallb(error);
153
- };
154
- const _internalEnterGeofencesCallback = data => {
155
- var _enterGeofencesCallba;
156
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.GEOFENCES_ENTER, data));
157
- (_enterGeofencesCallba = enterGeofencesCallback) === null || _enterGeofencesCallba === void 0 || _enterGeofencesCallba(data);
158
- };
159
- const _internalExitGeofencesCallback = data => {
160
- var _exitGeofencesCallbac;
161
- internalMethodCallMapDelegate(new _types.InternalCall(_constants.InternalCallType.GEOFENCES_EXIT, data));
162
- (_exitGeofencesCallbac = exitGeofencesCallback) === null || _exitGeofencesCallbac === void 0 || _exitGeofencesCallbac(data);
163
- };
164
- const _registerCallbacks = () => {
165
- const callbacksMap = {
166
- locationChanged: _internalLocationCallback,
167
- statusChanged: _internalLocationStatusCallback,
168
- locationStopped: _internalLocationStoppedCallback,
169
- locationError: _internalLocationErrorCallback,
170
- [_constants.SdkNavigationUpdateType.START]: _internalNavigationStartedCallback,
171
- [_constants.SdkNavigationUpdateType.PROGRESS]: _internalNavigationProgressCallback,
172
- [_constants.SdkNavigationUpdateType.DESTINATION_REACHED]: _internalNavigationDestinationReachedCallback,
173
- [_constants.SdkNavigationUpdateType.OUTSIDE_ROUTE]: _internalNavigationOutOfRouteCallback,
174
- [_constants.SdkNavigationUpdateType.FINISHED]: _internalNavigationFinishedCallback,
175
- [_constants.SdkNavigationUpdateType.CANCELLATION]: _internalNavigationCancellationCallback,
176
- [_constants.SdkNavigationUpdateType.ERROR]: _internalNavigationErrorCallback,
177
- onEnterGeofences: _internalEnterGeofencesCallback,
178
- onExitGeofences: _internalExitGeofencesCallback
179
- };
180
- Object.entries(callbacksMap).forEach(([eventName, callback]) => {
181
- SitumPluginEventEmitter.removeAllListeners(eventName);
182
- SitumPluginEventEmitter.addListener(eventName, callback);
183
- });
184
- };
185
-
186
- // End Internal callbacks --
187
-
188
- class SitumPlugin {
189
- /**
190
- * Whether the positioning is currently in execution.
191
- * @returns boolean
192
- */
193
- static positioningIsRunning = () => positioningRunning;
194
-
195
- /**
196
- * Whether the navigation is currently in execution.
197
- * @returns boolean
198
- */
199
- static navigationIsRunning = () => navigationRunning;
200
-
201
- /**
202
- * Initializes {@link SitumPlugin}.
203
- *
204
- * This method must be called before invoking any other methods.
205
- * This method can be safely called many times as it will only initialise the SDK
206
- * if it is not already initialised.
207
- *
208
- * @returns void
209
- * @throw Exception
210
- */
211
- static init = () => {
212
- _registerCallbacks();
213
- return (0, _utils.exceptionWrapper)(() => {
214
- RNCSitumPlugin.initSitumSDK();
215
- });
216
- };
217
-
218
- /**
219
- * Provides your API key to the Situm SDK.
220
- *
221
- * This key is generated for your application in the Dashboard.
222
- * Old credentials will be removed.
223
- *
224
- * @param apiKey user's apikey.
225
- *
226
- * @returns void
227
- * @throw Exception
228
- */
229
- static setApiKey = apiKey => {
230
- return (0, _utils.exceptionWrapper)(({
231
- onCallback
232
- }) => {
233
- RNCSitumPlugin.setApiKey("email@email.com", apiKey, response => {
234
- onCallback(response, "Failed to set API key.");
235
- });
236
- });
237
- };
238
-
239
- /**
240
- * Provides user's email and password. This credentials will be used to obtain a
241
- * valid user token to authenticate the server request, when necessary. Token
242
- * obtaining is not necessary done when this method is executed. Old credentials
243
- * will be removed.
244
- *
245
- * @param email user's email.
246
- * @param password user's password.
247
- *
248
- * @returns void
249
- * @throw Exception
250
- */
251
- static setUserPass = (email, password) => {
252
- return (0, _utils.exceptionWrapper)(({
253
- onCallback
254
- }) => {
255
- RNCSitumPlugin.setUserPass(email, password, response => {
256
- onCallback(response, "Failed to set user credentials.");
257
- });
258
- });
259
- };
260
-
261
- /**
262
- * Sets the API's base URL to retrieve the data.
263
- *
264
- * @param url user's email.
265
- *
266
- * @returns void
267
- * @throw Exception
268
- */
269
-
270
- static setDashboardURL = url => {
271
- return (0, _utils.exceptionWrapper)(({
272
- onCallback
273
- }) => {
274
- RNCSitumPlugin.setDashboardURL(url, response => {
275
- onCallback(response, "Failed to set dashboard URL.");
276
- });
277
- });
278
- };
279
-
280
- /**
281
- * Set to true if you want the SDK to download the configuration from the Situm API
282
- * and use it by default. Right now it only affects the {@link LocationRequest}.
283
- * Default value is true from SDK version 2.83.5
284
- *
285
- * @param useRemoteConfig
286
- *
287
- * @returns void
288
- * @throw Exception
289
- */
290
- static setUseRemoteConfig = useRemoteConfig => {
291
- return (0, _utils.exceptionWrapper)(({
292
- onCallback
293
- }) => {
294
- RNCSitumPlugin.setUseRemoteConfig(useRemoteConfig ? "true" : "false", response => {
295
- onCallback(response, "Failed to set remote config");
296
- });
297
- });
298
- };
299
-
300
- /**
301
- * Sets the max seconds the cache is valid
302
- *
303
- * @returns void
304
- * @throw Exception
305
- */
306
- static setMaxCacheAge = cacheAge => {
307
- return (0, _utils.exceptionWrapper)(({
308
- onCallback
309
- }) => {
310
- RNCSitumPlugin.setCacheMaxAge(cacheAge, response => {
311
- onCallback(response, "Failed to set cache max age");
312
- });
313
- });
314
- };
315
-
316
- /**
317
- * Sets the SDK {@link ConfigurationOptions}.
318
- *
319
- * @param options {@link ConfigurationOptions}
320
- *
321
- * @returns void
322
- * @throw Exception
323
- */
324
- static setConfiguration = options => {
325
- return (0, _utils.exceptionWrapper)(() => {
326
- if (options.useRemoteConfig !== undefined) {
327
- SitumPlugin.setUseRemoteConfig(options.useRemoteConfig);
328
- }
329
- if (options.cacheMaxAge !== undefined) {
330
- SitumPlugin.setMaxCacheAge(options.cacheMaxAge);
331
- }
332
-
333
- // Handle rest of configuration options
334
- });
335
- };
336
-
337
- /**
338
- * Invalidate all the resources in the cache
339
- *
340
- * @returns void
341
- * @throw Exception
342
- */
343
- static invalidateCache = () => {
344
- return (0, _utils.exceptionWrapper)(() => {
345
- RNCSitumPlugin.invalidateCache();
346
- });
347
- };
348
-
349
- /**
350
- * Gets the list of versions for the current plugin and environment
351
- *
352
- * @returns void
353
- * @throw Exception
354
- */
355
- static sdkVersion = () => {
356
- return (0, _utils.exceptionWrapper)(({
357
- onSuccess
358
- }) => {
359
- const versions = {
360
- react_native: _package.default.version
361
- };
362
- if (_reactNative.Platform.OS === "ios") {
363
- versions.ios = _package.default.sdkVersions.ios;
364
- } else {
365
- versions.android = _package.default.sdkVersions.android;
366
- }
367
- onSuccess(versions);
368
- });
369
- };
370
-
371
- /**
372
- * Returns the device identifier that has generated the location
373
- */
374
- static getDeviceId = () => {
375
- return (0, _utils.promiseWrapper)(({
376
- onSuccess,
377
- onError
378
- }) => {
379
- RNCSitumPlugin.getDeviceId(response => {
380
- //@ts-ignore
381
- if (response !== null && response !== void 0 && response.deviceId) {
382
- // Resolve with the actual deviceId
383
- //@ts-ignore
384
- onSuccess(response.deviceId);
385
- } else {
386
- // Reject if deviceId is not available in the response
387
- onError({
388
- code: _types.ErrorCode.UNKNOWN,
389
- message: "Couldn't get device ID",
390
- type: _types.ErrorType.CRITICAL
391
- });
392
- }
393
- });
394
- });
395
- };
396
-
397
- /**
398
- * Downloads all the {@link Building}s for the current user.
399
- */
400
- static fetchBuildings = () => {
401
- return (0, _utils.promiseWrapper)(({
402
- onSuccess,
403
- onError
404
- }) => {
405
- RNCSitumPlugin.fetchBuildings(onSuccess, onError);
406
- });
407
- };
408
-
409
- /**
410
- * Downloads all the building data for the selected building. This info includes
411
- * {@link Floor}, indoor and outdoor {@link Poi}s, events and paths. Also it download floor
412
- * maps and {@link PoiCategory} icons to local storage.
413
- *
414
- * @param building {@link Building}
415
- */
416
- static fetchBuildingInfo = building => {
417
- return (0, _utils.promiseWrapper)(({
418
- onSuccess,
419
- onError
420
- }) => {
421
- RNCSitumPlugin.fetchBuildingInfo(building, onSuccess, onError);
422
- });
423
- };
424
-
425
- /**
426
- * (Experimental) Downloads the tiled-map of a certain building
427
- *
428
- * @param building {@link Building} whose tiles will be downloaded
429
- */
430
- static fetchTilesFromBuilding = building => {
431
- return (0, _utils.promiseWrapper)(({
432
- onSuccess,
433
- onError
434
- }) => {
435
- RNCSitumPlugin.fetchTilesFromBuilding(building, onSuccess, onError);
436
- });
437
- };
438
-
439
- /**
440
- * Downloads all the floors of a building
441
- *
442
- * @param building {@link Building}
443
- */
444
- static fetchFloorsFromBuilding = building => {
445
- return (0, _utils.promiseWrapper)(({
446
- onSuccess,
447
- onError
448
- }) => {
449
- RNCSitumPlugin.fetchFloorsFromBuilding(building, onSuccess, onError);
450
- });
451
- };
452
-
453
- /**
454
- * Downloads the map image of a {@link Floor}
455
- *
456
- * @param floor {@link Floor}
457
- */
458
- static fetchMapFromFloor = floor => {
459
- return (0, _utils.promiseWrapper)(({
460
- onSuccess,
461
- onError
462
- }) => {
463
- RNCSitumPlugin.fetchMapFromFloor(floor, onSuccess, onError);
464
- });
465
- };
466
-
467
- /**
468
- * Get the geofences of a {@link Building}
469
- *
470
- * @param building {@link Building}
471
- */
472
- static fetchGeofencesFromBuilding = building => {
473
- return (0, _utils.promiseWrapper)(({
474
- onSuccess,
475
- onError
476
- }) => {
477
- RNCSitumPlugin.fetchGeofencesFromBuilding(building, onSuccess, onError);
478
- });
479
- };
480
-
481
- /**
482
- * Get all {@link PoiCategory}, download and cache their icons asynchronously.
483
- */
484
- static fetchPoiCategories = () => {
485
- return (0, _utils.promiseWrapper)(({
486
- onSuccess,
487
- onError
488
- }) => {
489
- RNCSitumPlugin.fetchPoiCategories(onSuccess, onError);
490
- });
491
- };
492
-
493
- /**
494
- * Get the normal {@link PoiIcon} for a category
495
- *
496
- * @param category {@link PoiCategory}. Not null.
497
- */
498
- static fetchPoiCategoryIconNormal = category => {
499
- return (0, _utils.promiseWrapper)(({
500
- onSuccess,
501
- onError
502
- }) => {
503
- RNCSitumPlugin.fetchPoiCategoryIconNormal(category, onSuccess, onError);
504
- });
505
- };
506
-
507
- /**
508
- * Get the selected {@link PoiIcon} for a {@link PoiCategory}
509
- *
510
- * @param category {@link PoiCategory}. Not null.
511
- */
512
- static fetchPoiCategoryIconSelected = category => {
513
- return (0, _utils.promiseWrapper)(({
514
- onSuccess,
515
- onError
516
- }) => {
517
- RNCSitumPlugin.fetchPoiCategoryIconSelected(category, onSuccess, onError);
518
- });
519
- };
520
-
521
- /**
522
- * Download the indoor {@link Poi}s of a {@link Building}
523
- *
524
- * @param building {@link Building}
525
- */
526
- static fetchIndoorPOIsFromBuilding = building => {
527
- return (0, _utils.promiseWrapper)(({
528
- onSuccess,
529
- onError
530
- }) => {
531
- RNCSitumPlugin.fetchIndoorPOIsFromBuilding(building, onSuccess, onError);
532
- });
533
- };
534
-
535
- /**
536
- * Download the outdoor {@link Poi}s of a {@link Building}
537
- *
538
- * @param building {@link Building}
539
- */
540
- static fetchOutdoorPOIsFromBuilding = building => {
541
- return (0, _utils.promiseWrapper)(({
542
- onSuccess,
543
- onError
544
- }) => {
545
- RNCSitumPlugin.fetchOutdoorPOIsFromBuilding(building, onSuccess, onError);
546
- });
547
- };
548
-
549
- /**
550
- * Starts positioning.
551
- *
552
- * @param {LocationRequest} locationRequest Positioning options to configure how positioning will behave
553
- */
554
- static requestLocationUpdates = locationRequest => {
555
- return (0, _utils.exceptionWrapper)(() => {
556
- if (SitumPlugin.positioningIsRunning()) return;
557
- RNCSitumPlugin.startPositioning(locationRequest || {});
558
- positioningRunning = true;
559
- });
560
- };
561
-
562
- /**
563
- * Stops positioning, removing all location updates
564
- */
565
- static removeLocationUpdates = () => {
566
- return (0, _utils.exceptionWrapper)(() => {
567
- if (!SitumPlugin.positioningIsRunning()) return;
568
- RNCSitumPlugin.stopPositioning(response => {
569
- if (response.success) {
570
- positioningRunning = false;
571
- } else {
572
- throw "Situm > hook > Could not stop positioning";
573
- }
574
- });
575
- });
576
- };
577
-
578
- /**
579
- * Calculates a route between two points. The result is provided
580
- * asynchronously using the callback.
581
- *
582
- * @param building {@link Building}
583
- * @param from {@link Point} route origin
584
- * @param to {@link Point} route destination
585
- * @param directionOptions {@link DirectionsOptions}
586
- */
587
- static requestDirections = (building, from, to, directionOptions) => {
588
- return (0, _utils.promiseWrapper)(({
589
- onSuccess,
590
- onError
591
- }) => {
592
- const params = [building, from, to, directionOptions || {}];
593
- RNCSitumPlugin.requestDirections(params, onSuccess, onError);
594
- });
595
- };
596
-
597
- /**
598
- * Set the navigation params, and the listener that receives the updated
599
- * navigation progress.
600
- *
601
- * Can only exist one navigation with one listener at a time. If this method was
602
- * previously invoked, but removeLocationUpdates() wasn't, removeLocationUpdates()
603
- * is called internally.
604
- *
605
- * @param options {@link NavigationRequest}
606
- */
607
- static requestNavigationUpdates = options => {
608
- return (0, _utils.exceptionWrapper)(() => {
609
- RNCSitumPlugin.requestNavigationUpdates(options || {});
610
- navigationRunning = true;
611
- });
612
- };
613
-
614
- /**
615
- * Informs NavigationManager object the change of the user's location
616
- *
617
- * @param location new {@link Location} of the user. If null, nothing is done
618
- */
619
- static updateNavigationWithLocation = location => {
620
- return (0, _utils.exceptionWrapper)(({
621
- onSuccess,
622
- onError
623
- }) => {
624
- if (!SitumPlugin.navigationIsRunning()) {
625
- throw "Situm > hook > No active navigation";
626
- }
627
- RNCSitumPlugin.updateNavigationWithLocation(location, onSuccess, onError);
628
- });
629
- };
630
-
631
- /**
632
- * Removes all location updates. This removes the internal state of the manager,
633
- * including the listener provided in requestNavigationUpdates(NavigationRequest,
634
- * NavigationListener), so it won't receive more progress updates.
635
- *
636
- */
637
- static removeNavigationUpdates = () => {
638
- return (0, _utils.promiseWrapper)(({
639
- onCallback
640
- }) => {
641
- if (!SitumPlugin.navigationIsRunning()) return;
642
- navigationRunning = false;
643
- RNCSitumPlugin.removeNavigationUpdates(response => {
644
- onCallback(response, "Failed to remove navigation updates");
645
- });
646
- });
647
- };
648
-
649
- /**
650
- * Requests a real time devices positions
651
- *
652
- * @param realtimeUpdates callback to use when new device positions are updated
653
- * @param error callback to use when an error on navigation udpates raises
654
- * @param options Represents the configuration for getting realtime devices positions in
655
- */
656
-
657
- static requestRealTimeUpdates = (realtimeUpdates, error, options) => {
658
- return (0, _utils.exceptionWrapper)(() => {
659
- RNCSitumPlugin.requestRealTimeUpdates(options || {});
660
- realtimeSubscriptions.push([SitumPluginEventEmitter.addListener("realtimeUpdated", realtimeUpdates), error ? SitumPluginEventEmitter.addListener("realtimeError", error || _logError.logError) : null]);
661
- });
662
- };
663
-
664
- /**
665
- * Removes all real time updates listners.
666
- *
667
- * @param _callback
668
- */
669
- static removeRealTimeUpdates = _callback => {
670
- return (0, _utils.exceptionWrapper)(() => {
671
- realtimeSubscriptions = [];
672
- RNCSitumPlugin.removeRealTimeUpdates();
673
- });
674
- };
675
-
676
- /**
677
- * Checks if a point is inside a {@link Geofence}
678
- *
679
- */
680
- static checkIfPointInsideGeofence = (request, callback) => {
681
- RNCSitumPlugin.checkIfPointInsideGeofence(request, callback);
682
- };
683
-
684
- /**
685
- * INTERNAL METHOD.
686
- *
687
- * Update SDK with the viewer navigation states.
688
- * Do not use this method as it is intended for internal use
689
- * by the map viewer module.
690
- *
691
- * @param externalNavigation
692
- */
693
- static updateNavigationState = externalNavigation => {
694
- return (0, _utils.exceptionWrapper)(() => {
695
- RNCSitumPlugin.updateNavigationState(externalNavigation);
696
- });
697
- };
698
-
699
- /**
700
- * Automatically assists users in resolving app-related permission and sensor issues.
701
- *
702
- * This method tells the native SDKs to present a user interface that explains detected
703
- * configuration issues and guides users through the required steps to resolve them,
704
- * following best practices for runtime permission requests.
705
- *
706
- * Issues addressed include:
707
- * - Missing permissions for Location or Bluetooth.
708
- * - Disabled Location or Bluetooth sensors.
709
- *
710
- * Use the <code>userHelperOptions</code> parameter to configure the available options.
711
- * Call {@link enableUserHelper} as a shortcut to enable the user helper with default configuration.
712
- * Call {@link disableUserHelper} as a shortcut to disable the user helper.
713
- *
714
- * @param {UserHelperOptions} userHelperOptions - Options for the user helper.
715
- * @param {function} cb - Cordova native callback to receive data.
716
- * @param {function} error - Cordova native callback to receive errors.
717
- */
718
- static configureUserHelper = userHelperOptions => {
719
- _registerCallbacks();
720
- return (0, _utils.exceptionWrapper)(({
721
- onSuccess,
722
- onError
723
- }) => {
724
- RNCSitumPlugin.configureUserHelper(userHelperOptions, onSuccess, onError);
725
- });
726
- };
727
-
728
- /**
729
- * Enables the user helper.
730
- *
731
- * Shortcut for {@link configureUserHelper} with <code>{enabled: true}</code>.
732
- *
733
- * @param {function} cb - Cordova native callback to receive data.
734
- * @param {function} error - Cordova native callback to receive errors.
735
- */
736
- static enableUserHelper = () => {
737
- SitumPlugin.configureUserHelper({
738
- enabled: true,
739
- colorScheme: undefined
740
- });
741
- };
742
-
743
- /**
744
- * Disables the user helper.
745
- *
746
- * Shortcut for {@link configureUserHelper} with <code>{enabled: false}</code>.
747
- *
748
- * @param {function} cb - Cordova native callback to receive data.
749
- * @param {function} error - Cordova native callback to receive errors.
750
- */
751
- static disableUserHelper = () => {
752
- SitumPlugin.configureUserHelper({
753
- enabled: false,
754
- colorScheme: undefined
755
- });
756
- };
757
-
758
- /**
759
- * INTERNAL METHOD.
760
- *
761
- * Validate if the mapView internal settings have been properly configured
762
- * Do not use this method as it is intended for internal use
763
- * by the map viewer module.
764
- *
765
- * @param validateMapViewProjectSettings
766
- */
767
- static validateMapViewProjectSettings = () => {
768
- if (_reactNative.Platform.OS === "ios") {
769
- return (0, _utils.exceptionWrapper)(() => {
770
- RNCSitumPlugin.validateMapViewProjectSettings();
771
- });
772
- }
773
- };
774
-
775
- /**
776
- * INTERNAL METHOD.
777
- *
778
- * Set a native MethodCall delegate. Do not use this method as it is intended for internal use by the map viewer module.
779
- * @param callback
780
- */
781
- static internalSetMethodCallMapDelegate = callback => {
782
- internalMethodCallMapDelegate = callback;
783
- };
784
-
785
- //-----------------------------------------------------------------------------//
786
- //-----------------------------GEOFENCES CALLBACKS-----------------------------//
787
- //-----------------------------------------------------------------------------//
788
-
789
- /**
790
- * Callback that notifies when the user enters a {@link Geofence}.
791
- *
792
- * In order to use correctly these callbacks you must know the following:
793
- * - Positioning geofences (with trainer_metadata custom field) won't be notified.
794
- * - These callbacks only work with indoor locations. Any outdoor location will
795
- * produce a call to onExitedGeofences with the last positioned geofences as argument.
796
- *
797
- * @param callback the function called when the user enters a {@link Geofence}
798
- */
799
- static onEnterGeofences = callback => {
800
- RNCSitumPlugin.onEnterGeofences();
801
- // Adopts SDK behavior (setter):
802
- enterGeofencesCallback = callback;
803
- };
804
-
805
- /**
806
- * Callback that notifies when the user exits a {@link Geofence}.
807
- *
808
- * In order to use correctly these callbacks you must know the following:
809
- * - Positioning geofences (with trainer_metadata custom field) won't be notified.
810
- * - These callbacks only work with indoor locations. Any outdoor location will
811
- * produce a call to onExitedGeofences with the last positioned geofences as argument.
812
- *
813
- * @param callback the function called when the user exits a {@link Geofence}
814
- */
815
- static onExitGeofences = callback => {
816
- RNCSitumPlugin.onExitGeofences();
817
- exitGeofencesCallback = callback;
818
- };
819
-
820
- //-----------------------------------------------------------------------------//
821
- //-----------------------------LOCATION CALLBACKS------------------------------//
822
- //-----------------------------------------------------------------------------//
823
-
824
- /**
825
- * Callback that notifies when the user {@link Location} changes.
826
- *
827
- * @param callback the function called when the user {@link Location} changes
828
- */
829
- static onLocationUpdate = callback => {
830
- locationCallback = callback;
831
- };
832
-
833
- /**
834
- * Callback that notifies when the user {@link LocationStatus} changes.
835
- *
836
- * @param callback the function called when the user {@link LocationStatus} changes
837
- */
838
- static onLocationStatus = callback => {
839
- locationStatusCallback = callback;
840
- };
841
-
842
- /**
843
- * Callback that notifies when there is an error while the user is positioining.
844
- *
845
- * @param callback the function called when there is an error
846
- */
847
- static onLocationError = callback => {
848
- locationErrorCallback = callback;
849
- };
850
-
851
- /**
852
- * Callback that notifies when the user stops positioning.
853
- *
854
- * @param callback the function called when the user stops positioning.
855
- */
856
- static onLocationStopped = callback => {
857
- locationStoppedCallback = callback;
858
- };
859
-
860
- //-----------------------------------------------------------------------------//
861
- //-----------------------------NAVIGATION CALLBACKS----------------------------//
862
- //-----------------------------------------------------------------------------//
863
-
864
- /**
865
- * Callback that notifies when navigation starts.
866
- *
867
- * @param callback a function that returns the initial {@link Route} by parameters.
868
- */
869
- static onNavigationStart = callback => {
870
- navigationStartedCallback = callback;
871
- };
872
-
873
- /**
874
- * Callback that notifies every progress the user makes while navigating.
875
- *
876
- * @param callback a function that returns the {@link NavigationProgress} by parameters.
877
- */
878
- static onNavigationProgress = callback => {
879
- navigationProgressCallback = callback;
880
- };
881
-
882
- /**
883
- * Callback that notifies when the user reaches the destination POI.
884
- *
885
- * @param callback a function that returns the completed {@link Route} by parameters.
886
- */
887
- static onNavigationDestinationReached = callback => {
888
- navigationDestinationReachedCallback = callback;
889
- };
890
-
891
- /**
892
- * Callback that notifies when the user gets out of the current route.
893
- *
894
- * @param callback the function called when the user gets out of the current route.
895
- */
896
- static onNavigationOutOfRoute = callback => {
897
- navigationOutOfRouteCallback = callback;
898
- };
899
-
900
- /**
901
- * @deprecated
902
- * DEPRECATED: Use instead onNavigationCancellation()
903
- * and onNavigationDestinationReached() to determine why did the navigation end.
904
- *
905
- * Callback that notifies when the user finishes the route.
906
- *
907
- * @param callback the function called when the user finishes the route.
908
- */
909
- static onNavigationFinished = callback => {
910
- navigationFinishedCallback = callback;
911
- };
912
-
913
- /**
914
- * Callback that notifies when the user does cancel the navigation.
915
- *
916
- * @param callback the function called when the user cancels the navigation.
917
- */
918
- static onNavigationCancellation = callback => {
919
- navigationCancellationCallback = callback;
920
- };
921
-
922
- /**
923
- * Callback that notifies when there is an error during navigation.
924
- *
925
- * @param callback the function called when there is an error during navigation.
926
- */
927
- static onNavigationError = callback => {
928
- navigationErrorCallback = callback;
929
- };
930
- }
931
- exports.default = SitumPlugin;
932
- //# sourceMappingURL=index.js.map