@situm/react-native 3.15.0-beta.3 → 3.15.0-beta.4

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