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