hypertrack-sdk-react-native 8.2.2 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/CONTRIBUTING.md +30 -110
  3. package/LICENSE +2 -0
  4. package/README.md +20 -40
  5. package/android/build.gradle +112 -113
  6. package/android/gradle.properties +1 -1
  7. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +209 -0
  8. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +2 -4
  9. package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +88 -0
  10. package/android/src/main/java/com/reactnativehypertracksdk/common/Geotag.kt +9 -0
  11. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackError.kt +28 -0
  12. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +251 -0
  13. package/android/src/main/java/com/reactnativehypertracksdk/common/LocationError.kt +9 -0
  14. package/android/src/main/java/com/reactnativehypertracksdk/common/Result.kt +50 -0
  15. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkInitParams.kt +44 -0
  16. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +21 -0
  17. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +203 -0
  18. package/hypertrack-sdk-react-native.podspec +1 -1
  19. package/ios/HyperTrackReactNativePlugin.m +54 -0
  20. package/ios/HyperTrackReactNativePlugin.swift +253 -0
  21. package/ios/HyperTrackSdk-Bridging-Header.h +2 -0
  22. package/ios/HyperTrackSdk.xcodeproj/project.pbxproj +8 -11
  23. package/ios/common/DictionaryDecoder.swift +28 -0
  24. package/ios/common/HyperTrackError.swift +20 -0
  25. package/ios/common/HyperTrackSDKWrapper.swift +120 -0
  26. package/ios/common/SDKInitParams.swift +13 -0
  27. package/ios/common/SDKMethod.swift +14 -0
  28. package/ios/common/Serialization.swift +268 -0
  29. package/lib/commonjs/HyperTrack/HyperTrack.js +142 -142
  30. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  31. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js +31 -0
  32. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js.map +1 -0
  33. package/lib/commonjs/HyperTrack/data_types/Location.js +2 -0
  34. package/lib/commonjs/HyperTrack/data_types/Location.js.map +1 -0
  35. package/lib/commonjs/HyperTrack/data_types/LocationError.js +6 -0
  36. package/lib/commonjs/HyperTrack/data_types/LocationError.js.map +1 -0
  37. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js +2 -0
  38. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js.map +1 -0
  39. package/lib/commonjs/HyperTrack/data_types/internal/DeviceId.js +2 -0
  40. package/lib/commonjs/HyperTrack/data_types/internal/DeviceId.js.map +1 -0
  41. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js +2 -0
  42. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js.map +1 -0
  43. package/lib/commonjs/HyperTrack/data_types/internal/Geotag.js +2 -0
  44. package/lib/commonjs/HyperTrack/data_types/internal/Geotag.js.map +1 -0
  45. package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js +2 -0
  46. package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -0
  47. package/lib/commonjs/HyperTrack/data_types/internal/IsAvailable.js +2 -0
  48. package/lib/commonjs/HyperTrack/data_types/internal/IsAvailable.js.map +1 -0
  49. package/lib/commonjs/HyperTrack/data_types/internal/IsTracking.js +2 -0
  50. package/lib/commonjs/HyperTrack/data_types/internal/IsTracking.js.map +1 -0
  51. package/lib/commonjs/HyperTrack/data_types/internal/LocationErrorInternal.js +6 -0
  52. package/lib/commonjs/HyperTrack/data_types/internal/LocationErrorInternal.js.map +1 -0
  53. package/lib/commonjs/HyperTrack/data_types/internal/LocationResponse.js +6 -0
  54. package/lib/commonjs/HyperTrack/data_types/internal/LocationResponse.js.map +1 -0
  55. package/lib/commonjs/index.js +28 -17
  56. package/lib/commonjs/index.js.map +1 -1
  57. package/lib/module/HyperTrack/HyperTrack.js +141 -134
  58. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  59. package/lib/module/HyperTrack/data_types/HyperTrackError.js +24 -0
  60. package/lib/module/HyperTrack/data_types/HyperTrackError.js.map +1 -0
  61. package/lib/module/HyperTrack/data_types/Location.js +2 -0
  62. package/lib/module/HyperTrack/data_types/Location.js.map +1 -0
  63. package/lib/module/HyperTrack/data_types/LocationError.js +2 -0
  64. package/lib/module/HyperTrack/data_types/LocationError.js.map +1 -0
  65. package/lib/module/HyperTrack/data_types/SdkInitParams.js +2 -0
  66. package/lib/module/HyperTrack/data_types/SdkInitParams.js.map +1 -0
  67. package/lib/module/HyperTrack/data_types/internal/DeviceId.js +2 -0
  68. package/lib/module/HyperTrack/data_types/internal/DeviceId.js.map +1 -0
  69. package/lib/module/HyperTrack/data_types/internal/DeviceName.js +2 -0
  70. package/lib/module/HyperTrack/data_types/internal/DeviceName.js.map +1 -0
  71. package/lib/module/HyperTrack/data_types/internal/Geotag.js +2 -0
  72. package/lib/module/HyperTrack/data_types/internal/Geotag.js.map +1 -0
  73. package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js +2 -0
  74. package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -0
  75. package/lib/module/HyperTrack/data_types/internal/IsAvailable.js +2 -0
  76. package/lib/module/HyperTrack/data_types/internal/IsAvailable.js.map +1 -0
  77. package/lib/module/HyperTrack/data_types/internal/IsTracking.js +2 -0
  78. package/lib/module/HyperTrack/data_types/internal/IsTracking.js.map +1 -0
  79. package/lib/module/HyperTrack/data_types/internal/LocationErrorInternal.js +2 -0
  80. package/lib/module/HyperTrack/data_types/internal/LocationErrorInternal.js.map +1 -0
  81. package/lib/module/HyperTrack/data_types/internal/LocationResponse.js +2 -0
  82. package/lib/module/HyperTrack/data_types/internal/LocationResponse.js.map +1 -0
  83. package/lib/module/index.js +4 -1
  84. package/lib/module/index.js.map +1 -1
  85. package/lib/typescript/HyperTrack/HyperTrack.d.ts +66 -100
  86. package/lib/typescript/HyperTrack/data_types/HyperTrackError.d.ts +20 -0
  87. package/lib/typescript/HyperTrack/data_types/Location.d.ts +7 -0
  88. package/lib/typescript/HyperTrack/data_types/LocationError.d.ts +8 -0
  89. package/lib/typescript/HyperTrack/data_types/SdkInitParams.d.ts +25 -0
  90. package/lib/typescript/HyperTrack/data_types/internal/DeviceId.d.ts +4 -0
  91. package/lib/typescript/HyperTrack/data_types/internal/DeviceName.d.ts +4 -0
  92. package/lib/typescript/HyperTrack/data_types/internal/Geotag.d.ts +3 -0
  93. package/lib/typescript/HyperTrack/data_types/internal/HyperTrackErrorInternal.d.ts +4 -0
  94. package/lib/typescript/HyperTrack/data_types/internal/IsAvailable.d.ts +4 -0
  95. package/lib/typescript/HyperTrack/data_types/internal/IsTracking.d.ts +4 -0
  96. package/lib/typescript/HyperTrack/data_types/internal/LocationErrorInternal.d.ts +12 -0
  97. package/lib/typescript/HyperTrack/data_types/internal/LocationResponse.d.ts +11 -0
  98. package/lib/typescript/index.d.ts +4 -1
  99. package/package.json +156 -156
  100. package/src/HyperTrack/HyperTrack.ts +164 -163
  101. package/src/HyperTrack/data_types/HyperTrackError.ts +22 -0
  102. package/src/HyperTrack/data_types/Location.ts +7 -0
  103. package/src/HyperTrack/data_types/LocationError.ts +11 -0
  104. package/src/HyperTrack/data_types/SdkInitParams.ts +28 -0
  105. package/src/HyperTrack/data_types/internal/DeviceId.ts +4 -0
  106. package/src/HyperTrack/data_types/internal/DeviceName.ts +4 -0
  107. package/src/HyperTrack/data_types/internal/Geotag.ts +3 -0
  108. package/src/HyperTrack/data_types/internal/HyperTrackErrorInternal.ts +4 -0
  109. package/src/HyperTrack/data_types/internal/IsAvailable.ts +4 -0
  110. package/src/HyperTrack/data_types/internal/IsTracking.ts +4 -0
  111. package/src/HyperTrack/data_types/internal/LocationErrorInternal.ts +14 -0
  112. package/src/HyperTrack/data_types/internal/LocationResponse.ts +14 -0
  113. package/src/index.tsx +4 -7
  114. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackModule.kt +0 -284
  115. package/ios/HyperTrack.h +0 -7
  116. package/ios/HyperTrack.m +0 -384
@@ -3,50 +3,61 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Error", {
6
+ Object.defineProperty(exports, "Errors", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _HyperTrack.Error;
9
+ return _LocationError.Errors;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "GeotagError", {
12
+ Object.defineProperty(exports, "HyperTrack", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _HyperTrack.GeotagError;
15
+ return _HyperTrack.default;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "HyperTrack", {
18
+ Object.defineProperty(exports, "HyperTrackError", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _HyperTrack.default;
21
+ return _HyperTrackError.HyperTrackError;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "Location", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _HyperTrack.Location;
27
+ return _Location.Location;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "LocationError", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _HyperTrack.LocationError;
33
+ return _LocationError.LocationError;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "NotRunning", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _LocationError.NotRunning;
34
40
  }
35
41
  });
36
- Object.defineProperty(exports, "SDKError", {
42
+ Object.defineProperty(exports, "SdkInitParams", {
37
43
  enumerable: true,
38
44
  get: function () {
39
- return _HyperTrack.SDKError;
45
+ return _SdkInitParams.SdkInitParams;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "Starting", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _LocationError.Starting;
40
52
  }
41
53
  });
42
54
  exports.default = void 0;
43
-
44
- var _HyperTrack = _interopRequireWildcard(require("./HyperTrack/HyperTrack"));
45
-
46
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
47
-
48
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
-
55
+ var _HyperTrack = _interopRequireDefault(require("./HyperTrack/HyperTrack"));
56
+ var _HyperTrackError = require("./HyperTrack/data_types/HyperTrackError");
57
+ var _LocationError = require("./HyperTrack/data_types/LocationError");
58
+ var _Location = require("./HyperTrack/data_types/Location");
59
+ var _SdkInitParams = require("./HyperTrack/data_types/SdkInitParams");
60
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
61
  var _default = _HyperTrack.default;
51
62
  exports.default = _default;
52
63
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HyperTrack"],"sources":["index.tsx"],"sourcesContent":["import HyperTrack from './HyperTrack/HyperTrack';\nexport default HyperTrack;\nexport { HyperTrack };\n\nexport {\n Location,\n Error,\n SDKError,\n GeotagError,\n LocationError,\n} from './HyperTrack/HyperTrack';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;eACeA,mB"}
1
+ {"version":3,"names":["HyperTrack"],"sources":["index.tsx"],"sourcesContent":["import HyperTrack from './HyperTrack/HyperTrack';\nexport default HyperTrack;\nexport { HyperTrack };\n\nexport { HyperTrackError } from './HyperTrack/data_types/HyperTrackError';\nexport { LocationError, NotRunning, Starting, Errors } from './HyperTrack/data_types/LocationError';\nexport { Location } from './HyperTrack/data_types/Location';\nexport { SdkInitParams } from './HyperTrack/data_types/SdkInitParams'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAIA;AACA;AACA;AACA;AAAqE;AAAA,eANtDA,mBAAU;AAAA"}
@@ -1,153 +1,149 @@
1
1
  import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
2
+ import { HyperTrackError } from './data_types/HyperTrackError';
3
+ const EVENT_TRACKING = 'onTrackingChanged';
4
+ const EVENT_AVAILABILITY = 'onAvailabilityChanged';
5
+ const EVENT_ERROR = 'onError';
2
6
  const LINKING_ERROR = `The package 'hypertrack-sdk-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
7
  ios: "- You have run 'pod install'\n",
4
8
  default: ''
5
9
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
- const HyperTrackSdk = NativeModules.HyperTrack ? NativeModules.HyperTrack : new Proxy({}, {
10
+ const HyperTrackSdk = NativeModules.HyperTrackReactNativePlugin ? NativeModules.HyperTrackReactNativePlugin : new Proxy({}, {
7
11
  get() {
8
12
  throw new Error(LINKING_ERROR);
9
13
  }
10
-
11
14
  });
12
15
  const EventEmitter = new NativeEventEmitter(HyperTrackSdk);
13
- export let SDKError;
14
- /**
15
- * A base interface for errors in SDK.
16
- */
17
-
18
- (function (SDKError) {
19
- SDKError[SDKError["GENERAL"] = 0] = "GENERAL";
20
- SDKError[SDKError["INVALID_PUBLISHABLE_KEY"] = 1] = "INVALID_PUBLISHABLE_KEY";
21
- SDKError[SDKError["AUTHORIZATION_FAILED"] = 2] = "AUTHORIZATION_FAILED";
22
- SDKError[SDKError["PERMISSION_DENIED"] = 3] = "PERMISSION_DENIED";
23
- })(SDKError || (SDKError = {}));
24
-
25
- /**
26
- * Interface for accessing adding geotag result.
27
- */
28
- export let GeotagError;
29
-
30
- (function (GeotagError) {
31
- GeotagError[GeotagError["PLATFORM_NOT_SUPPORTED"] = 0] = "PLATFORM_NOT_SUPPORTED";
32
- GeotagError[GeotagError["LOCATION_MISMATCH"] = 1] = "LOCATION_MISMATCH";
33
- GeotagError[GeotagError["LOCATION_NOT_AVAILABLE"] = 2] = "LOCATION_NOT_AVAILABLE";
34
- GeotagError[GeotagError["INVALID_ARGUMENTS"] = 3] = "INVALID_ARGUMENTS";
35
- })(GeotagError || (GeotagError = {}));
36
-
37
- export let LocationError;
38
-
39
- (function (LocationError) {
40
- LocationError["LOCATION_PERMISSIONS_NOT_DETERMINED"] = "location_permissions_not_determined";
41
- LocationError["LOCATION_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND"] = "location_permissions_cant_be_asked_in_background";
42
- LocationError["LOCATION_PERMISSIONS_INSUFFICIENT_FOR_BACKGROUND"] = "location_permissions_insufficient_for_background";
43
- LocationError["LOCATION_PERMISSIONS_RESTRICTED"] = "location_permissions_restricted";
44
- LocationError["LOCATION_PERMISSIONS_REDUCED_ACCURACY"] = "location_permissions_reduced_accuracy";
45
- LocationError["LOCATION_PERMISSIONS_DENIED"] = "location_permissions_denied";
46
- LocationError["LOCATION_SERVICES_DISABLED"] = "location_services_disabled";
47
- LocationError["MOTION_ACTIVITY_PERMISSIONS_NOT_DETERMINED"] = "motion_activity_permissions_not_determined";
48
- LocationError["MOTION_ACTIVITY_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND"] = "motion_activity_permissions_cant_be_asked_in_background";
49
- LocationError["MOTION_ACTIVITY_PERMISSIONS_DENIED"] = "motion_activity_permissions_denied";
50
- LocationError["MOTION_ACTIVITY_SERVICES_DISABLED"] = "motion_activity_services_disabled";
51
- LocationError["NOT_RUNNING"] = "not_running";
52
- LocationError["GPS_SIGNAL_LOST"] = "gps_signal_lost";
53
- LocationError["STARTING"] = "starting";
54
- LocationError["LOCATION_MOCKED"] = "location_mocked";
55
- })(LocationError || (LocationError = {}));
56
-
57
16
  export default class HyperTrack {
58
17
  constructor() {
59
18
  return this;
60
19
  }
61
20
 
62
- static async createInstance(publishableKey) {
63
- let automaticallyRequestPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
64
-
21
+ /**
22
+ * Creates an SDK instance
23
+ *
24
+ * @param publishableKey publishable key provided in HyperTrack’s dashboard setup page
25
+ * @param sdkInitParams
26
+ * @returns HyperTrack instance
27
+ */
28
+ static async initialize(publishableKey) {
29
+ let sdkInitParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
65
30
  try {
66
- await HyperTrackSdk.initialize(publishableKey, false, automaticallyRequestPermissions);
31
+ await HyperTrackSdk.initializeSdk({
32
+ publishableKey,
33
+ loggingEnabled: sdkInitParams.loggingEnabled ?? false,
34
+ allowMockLocations: sdkInitParams.allowMockLocations ?? false,
35
+ requireBackgroundTrackingPermission: sdkInitParams.requireBackgroundTrackingPermission ?? false,
36
+ automaticallyRequestPermissions: sdkInitParams.automaticallyRequestPermissions ?? true
37
+ });
67
38
  return new HyperTrack();
68
39
  } catch (error) {
69
40
  throw new Error(error.message);
70
41
  }
71
42
  }
72
- /**
73
- * Enables debug log output. This is very verbose, so you shouldn't use this for
74
- * production build.
75
- */
76
-
77
43
 
78
- static enableDebugLogging(enable) {
79
- HyperTrackSdk.enableDebugLogging(enable);
80
- }
81
44
  /**
82
- * Returns a string which is used by HyperTrack to uniquely identify the user.
45
+ * Returns a string that is used to uniquely identify the device
83
46
  */
84
-
85
-
86
- async getDeviceID() {
87
- return HyperTrackSdk.getDeviceID();
47
+ getDeviceId() {
48
+ return HyperTrackSdk.getDeviceId().then(deviceId => deviceId.value);
88
49
  }
50
+
89
51
  /**
90
- * Device's availability for nearby search
52
+ * Reflects availability of the device for the Nearby search
91
53
  *
92
54
  * @returns true when is available or false when unavailable
93
55
  */
94
-
95
-
96
56
  isAvailable() {
97
- return HyperTrackSdk.isAvailable();
57
+ return HyperTrackSdk.isAvailable().then(isAvailable => isAvailable.value);
98
58
  }
59
+
99
60
  /**
100
- * Allows you to set device availability for nearby search
61
+ * Sets the availability of the device for the Nearby search
101
62
  *
102
63
  * @param availability true when is available or false when unavailable
103
64
  */
104
-
105
-
106
- async setAvailability(availability) {
107
- return HyperTrackSdk.setAvailability(availability);
65
+ setAvailability(isAvailable) {
66
+ HyperTrackSdk.setAvailability({
67
+ type: 'isAvailable',
68
+ value: isAvailable
69
+ });
108
70
  }
71
+
109
72
  /**
110
- * Determine whether the SDK is tracking the movement of the user.
73
+ * Reflects the tracking intent for the device
74
+ *
111
75
  * @return {boolean} Whether the user's movement data is getting tracked or not.
112
76
  */
113
-
114
-
115
77
  isTracking() {
116
- return HyperTrackSdk.isTracking();
78
+ return HyperTrackSdk.isTracking().then(isTracking => isTracking.value);
117
79
  }
80
+
118
81
  /**
119
- * Update device state from server.
82
+ * Syncs the device state with the HyperTrack servers
120
83
  */
121
-
122
-
123
- syncDeviceSettings() {
124
- HyperTrackSdk.syncDeviceSettings();
84
+ sync() {
85
+ HyperTrackSdk.sync();
125
86
  }
87
+
126
88
  /**
127
- * Start or resume tracking location and activity events.
89
+ * Expresses an intent to start location tracking for the device
128
90
  */
129
-
130
-
131
91
  startTracking() {
132
92
  HyperTrackSdk.startTracking();
133
93
  }
94
+
134
95
  /**
135
- * Stops the SDK from listening to the user's movement updates and recording any data.
96
+ * Stops location tracking immediately
136
97
  */
137
-
138
-
139
98
  stopTracking() {
140
99
  HyperTrackSdk.stopTracking();
141
- } /// The current location of the user or an outage reason.
142
-
100
+ }
143
101
 
102
+ /**
103
+ * Reflects the current location of the user or an outage reason
104
+ */
144
105
  getLocation() {
145
- return HyperTrackSdk.getLocation();
106
+ return HyperTrackSdk.getLocation().then(locationResponse => {
107
+ return this.deserializeLocationResponse(locationResponse);
108
+ });
109
+ }
110
+
111
+ /**
112
+ * Sets the name for the device
113
+ * @param {string} name
114
+ */
115
+ setName(name) {
116
+ HyperTrackSdk.setName({
117
+ type: 'deviceName',
118
+ value: name
119
+ });
120
+ }
121
+
122
+ /**
123
+ * Sets the metadata for the device
124
+ * @param {Object} data - Metadata JSON
125
+ */
126
+ setMetadata(data) {
127
+ HyperTrackSdk.setMetadata(data);
146
128
  }
129
+
130
+ /**
131
+ * Adds a new geotag
132
+ * @param {Object} data - Geotad data JSON
133
+ * @returns current location if success or LocationError if failure
134
+ */
135
+ addGeotag(data) {
136
+ return HyperTrackSdk.addGeotag({
137
+ data
138
+ }).then(locationResponse => {
139
+ return this.deserializeLocationResponse(locationResponse);
140
+ });
141
+ }
142
+
147
143
  /**
148
- * Listen for errors.
144
+ * Subscribe to tracking errors
149
145
  *
150
- * @param listener (errors: {code, message}) => void
146
+ * @param listener
151
147
  * @returns EmitterSubscription
152
148
  * @example
153
149
  * ```js
@@ -161,15 +157,16 @@ export default class HyperTrack {
161
157
  * subscription.remove()
162
158
  * ```
163
159
  */
164
-
165
-
166
160
  subscribeToErrors(listener) {
167
- return EventEmitter.addListener('onTrackingErrorHyperTrack', listener);
161
+ return EventEmitter.addListener(EVENT_ERROR, rawErrors => {
162
+ listener(this.deserializeHyperTrackErrors(rawErrors));
163
+ });
168
164
  }
165
+
169
166
  /**
170
- * Listen for tracking changes.
167
+ * Subscribe to tracking intent changes
171
168
  *
172
- * @param listener (isTracking: boolean) => void
169
+ * @param listener
173
170
  * @returns EmitterSubscription
174
171
  * @example
175
172
  * ```js
@@ -183,48 +180,58 @@ export default class HyperTrack {
183
180
  * subscription.remove()
184
181
  * ```
185
182
  */
186
-
187
-
188
183
  subscribeToTracking(listener) {
189
- return EventEmitter.addListener('onTrackingStateChanged', listener);
184
+ return EventEmitter.addListener(EVENT_TRACKING, isTracking => {
185
+ listener(isTracking.value);
186
+ });
190
187
  }
191
- /**
192
- * Send device name to HyperTrack
193
- * @param {string} name - Device name you want to see in the Dashboard.
194
- */
195
-
196
188
 
197
- setDeviceName(name) {
198
- HyperTrackSdk.setDeviceName(name);
199
- }
200
- /**
201
- * Send metadata details to HyperTrack
202
- * @param {Object} data - Send extra device information.
203
- */
204
-
205
-
206
- setMetadata(data) {
207
- HyperTrackSdk.setMetadata(data);
208
- }
209
189
  /**
210
- * @deprecated
211
- * Set a trip marker
212
- * @param {Object} _data - Include anything that can be parsed into JSON.
213
- */
214
-
215
-
216
- setTripMarker(_data) {
217
- throw new Error('Deprecated');
218
- }
219
- /**
220
- * Add geotag
221
- * @param {Object} data - Include anything that can be parsed into JSON.
190
+ * Subscribe to availability changes
191
+ *
192
+ * @param listener
193
+ * @returns EmitterSubscription
194
+ * @example
195
+ * ```js
196
+ * const subscription = HyperTrack.subscribeToAvailability(isAvailable => {
197
+ * if (isAvailable) {
198
+ * // ... ready to go
199
+ * }
200
+ * })
201
+ *
202
+ * // later, to stop listening
203
+ * subscription.remove()
204
+ * ```
222
205
  */
223
-
224
-
225
- addGeotag(data) {
226
- return HyperTrackSdk.addGeotag(data);
206
+ subscribeToAvailability(listener) {
207
+ return EventEmitter.addListener(EVENT_AVAILABILITY, isAvailable => {
208
+ listener(isAvailable.value);
209
+ });
210
+ }
211
+
212
+ /** @ignore */
213
+ deserializeHyperTrackErrors(errors) {
214
+ return errors.map(error => HyperTrackError[error.value]);
215
+ }
216
+
217
+ /** @ignore */
218
+ deserializeLocationResponse(response) {
219
+ switch (response.type) {
220
+ case "success":
221
+ return response.value;
222
+ case "failure":
223
+ switch (response.value.type) {
224
+ case "notRunning":
225
+ case "starting":
226
+ return response.value;
227
+ case "errors":
228
+ return {
229
+ type: "errors",
230
+ value: this.deserializeHyperTrackErrors(response.value.value)
231
+ };
232
+ }
233
+ }
234
+ ;
227
235
  }
228
-
229
236
  }
230
237
  //# sourceMappingURL=HyperTrack.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","HyperTrackSdk","HyperTrack","Proxy","get","Error","EventEmitter","SDKError","GeotagError","LocationError","constructor","createInstance","publishableKey","automaticallyRequestPermissions","initialize","error","message","enableDebugLogging","enable","getDeviceID","isAvailable","setAvailability","availability","isTracking","syncDeviceSettings","startTracking","stopTracking","getLocation","subscribeToErrors","listener","addListener","subscribeToTracking","setDeviceName","name","setMetadata","data","setTripMarker","_data","addGeotag"],"sources":["HyperTrack.ts"],"sourcesContent":["import { NativeModules, Platform, NativeEventEmitter } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'hypertrack-sdk-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst HyperTrackSdk = NativeModules.HyperTrack\n ? NativeModules.HyperTrack\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nconst EventEmitter = new NativeEventEmitter(HyperTrackSdk);\n\nexport enum SDKError {\n /**\n * An error that we couldn't recognize.\n */\n GENERAL = 0,\n /**\n * Publishable key is invalid. Check your key on hypertrack dashboard setup.\n */\n INVALID_PUBLISHABLE_KEY = 1,\n /**\n * Your free trial ended or account was not renewed. Check your account on hypertrack dashboard.\n */\n AUTHORIZATION_FAILED = 2,\n /**\n * Tracking won't start due to denied (or absent) permission.\n */\n PERMISSION_DENIED = 3,\n}\n\n/**\n * A base interface for errors in SDK.\n */\nexport type Error = {\n code: SDKError;\n message?: string;\n};\n\n/**\n * Interface for accessing adding geotag result.\n */\nexport enum GeotagError {\n /** Expected location is not supported on this platform */\n PLATFORM_NOT_SUPPORTED = 0,\n /** Expected vs actual location difference is greater then required */\n LOCATION_MISMATCH = 1,\n /** SDK can't get actual location from OS sensors */\n LOCATION_NOT_AVAILABLE = 2,\n /** Invalid arguments */\n INVALID_ARGUMENTS = 3,\n}\n\nexport interface Location {\n location: {\n latitude: number;\n longitude: number;\n };\n}\n\nexport enum LocationError {\n // The user has not chosen whether the app can use location services.\n // SDK automatically asked for permissions.\n LOCATION_PERMISSIONS_NOT_DETERMINED = 'location_permissions_not_determined',\n // The user has not chosen whether the app can use location services.\n // SDK can't ask for permissions in background.\n LOCATION_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = 'location_permissions_cant_be_asked_in_background',\n // Can't start tracking in background with When In Use location\n // permissions. SDK will automatically start tracking when app will return\n // to foreground.\n LOCATION_PERMISSIONS_INSUFFICIENT_FOR_BACKGROUND = 'location_permissions_insufficient_for_background',\n // The app is not authorized to use location services.\n LOCATION_PERMISSIONS_RESTRICTED = 'location_permissions_restricted',\n // The user didn't grant precise location permissions or downgraded permissions to imprecise.\n LOCATION_PERMISSIONS_REDUCED_ACCURACY = 'location_permissions_reduced_accuracy',\n // The user denied location permissions.\n LOCATION_PERMISSIONS_DENIED = 'location_permissions_denied',\n // The user disabled location services systemwide.\n LOCATION_SERVICES_DISABLED = 'location_services_disabled',\n // The user has not chosen whether the app can use motion activity\n // services. SDK automatically asked for permissions.\n MOTION_ACTIVITY_PERMISSIONS_NOT_DETERMINED = 'motion_activity_permissions_not_determined',\n // The user has not chosen whether the app can use motion activity\n // services. SDK can't ask for permissions in background.\n MOTION_ACTIVITY_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = 'motion_activity_permissions_cant_be_asked_in_background',\n // Motion activity permissions denied after SDK's initialization. Granting\n // them will restart the app, so in effect, they are denied during this app's\n // session.\n MOTION_ACTIVITY_PERMISSIONS_DENIED = 'motion_activity_permissions_denied',\n // The user disabled motion services systemwide.\n MOTION_ACTIVITY_SERVICES_DISABLED = 'motion_activity_services_disabled',\n // The SDK is not collecting locations because it's either not tracking or is unavailable.\n NOT_RUNNING = 'not_running',\n // GPS satellites are not in view.\n GPS_SIGNAL_LOST = 'gps_signal_lost',\n // The SDK started collecting locations and is waiting for OS location services to respond.\n STARTING = 'starting',\n // The user enabled mock location app while mocking locations is prohibited.\n LOCATION_MOCKED = 'location_mocked',\n}\n\nexport default class HyperTrack {\n constructor() {\n return this;\n }\n\n static async createInstance(\n publishableKey: string,\n automaticallyRequestPermissions = true\n ) {\n try {\n await HyperTrackSdk.initialize(\n publishableKey,\n false,\n automaticallyRequestPermissions\n );\n return new HyperTrack();\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n\n /**\n * Enables debug log output. This is very verbose, so you shouldn't use this for\n * production build.\n */\n static enableDebugLogging(enable: boolean) {\n HyperTrackSdk.enableDebugLogging(enable);\n }\n\n /**\n * Returns a string which is used by HyperTrack to uniquely identify the user.\n */\n async getDeviceID(): Promise<string> {\n return HyperTrackSdk.getDeviceID();\n }\n\n /**\n * Device's availability for nearby search\n *\n * @returns true when is available or false when unavailable\n */\n isAvailable(): Promise<boolean> {\n return HyperTrackSdk.isAvailable();\n }\n\n /**\n * Allows you to set device availability for nearby search\n *\n * @param availability true when is available or false when unavailable\n */\n async setAvailability(availability: Boolean): Promise<void> {\n return HyperTrackSdk.setAvailability(availability);\n }\n\n /**\n * Determine whether the SDK is tracking the movement of the user.\n * @return {boolean} Whether the user's movement data is getting tracked or not.\n */\n isTracking(): Promise<boolean> {\n return HyperTrackSdk.isTracking();\n }\n\n /**\n * Update device state from server.\n */\n syncDeviceSettings() {\n HyperTrackSdk.syncDeviceSettings();\n }\n\n /**\n * Start or resume tracking location and activity events.\n */\n startTracking() {\n HyperTrackSdk.startTracking();\n }\n\n /**\n * Stops the SDK from listening to the user's movement updates and recording any data.\n */\n stopTracking() {\n HyperTrackSdk.stopTracking();\n }\n\n /// The current location of the user or an outage reason.\n getLocation(): Promise<LocationError | Location> {\n return HyperTrackSdk.getLocation();\n }\n\n /**\n * Listen for errors.\n *\n * @param listener (errors: {code, message}) => void\n * @returns EmitterSubscription\n * @example\n * ```js\n * const subscription = HyperTrack.subscribeToErrors(errors => {\n * errors.forEach(error => {\n * // ... error\n * })\n * })\n *\n * // later, to stop listening\n * subscription.remove()\n * ```\n */\n subscribeToErrors(listener: (errors: Error) => void) {\n return EventEmitter.addListener('onTrackingErrorHyperTrack', listener);\n }\n\n /**\n * Listen for tracking changes.\n *\n * @param listener (isTracking: boolean) => void\n * @returns EmitterSubscription\n * @example\n * ```js\n * const subscription = HyperTrack.subscribeToTracking(isTracking => {\n * if (isTracking) {\n * // ... ready to go\n * }\n * })\n *\n * // later, to stop listening\n * subscription.remove()\n * ```\n */\n subscribeToTracking(listener: (isTracking: boolean) => void) {\n return EventEmitter.addListener('onTrackingStateChanged', listener);\n }\n\n /**\n * Send device name to HyperTrack\n * @param {string} name - Device name you want to see in the Dashboard.\n */\n setDeviceName(name: string) {\n HyperTrackSdk.setDeviceName(name);\n }\n\n /**\n * Send metadata details to HyperTrack\n * @param {Object} data - Send extra device information.\n */\n setMetadata(data: Object) {\n HyperTrackSdk.setMetadata(data);\n }\n\n /**\n * @deprecated\n * Set a trip marker\n * @param {Object} _data - Include anything that can be parsed into JSON.\n */\n setTripMarker(_data: Object) {\n throw new Error('Deprecated');\n }\n\n /**\n * Add geotag\n * @param {Object} data - Include anything that can be parsed into JSON.\n */\n addGeotag(data: Object): Promise<LocationError | Location> {\n return HyperTrackSdk.addGeotag(data);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,EAAkCC,kBAAlC,QAA4D,cAA5D;AAEA,MAAMC,aAAa,GAChB,sFAAD,GACAF,QAAQ,CAACG,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,aAAa,GAAGP,aAAa,CAACQ,UAAd,GAClBR,aAAa,CAACQ,UADI,GAElB,IAAIC,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a,CAACkB,WAAd,EAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEC,WAAW,GAAqB;IAC9B,OAAOnB,aAAa,CAACmB,WAAd,EAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACuB,MAAfC,eAAe,CAACC,YAAD,EAAuC;IAC1D,OAAOrB,aAAa,CAACoB,eAAd,CAA8BC,YAA9B,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACEC,UAAU,GAAqB;IAC7B,OAAOtB,aAAa,CAACsB,UAAd,EAAP;EACD;EAED;AACF;AACA;;;EACEC,kBAAkB,GAAG;IACnBvB,aAAa,CAACuB,kBAAd;EACD;EAED;AACF;AACA;;;EACEC,aAAa,GAAG;IACdxB,aAAa,CAACwB,aAAd;EACD;EAED;AACF;AACA;;;EACEC,YAAY,GAAG;IACbzB,aAAa,CAACyB,YAAd;EACD,CAjF6B,CAmF9B;;;EACAC,WAAW,GAAsC;IAC/C,OAAO1B,aAAa,CAAC0B,WAAd,EAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACEC,iBAAiB,CAACC,QAAD,EAAoC;IACnD,OAAOvB,YAAY,CAACwB,WAAb,CAAyB,2BAAzB,EAAsDD,QAAtD,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACEE,mBAAmB,CAACF,QAAD,EAA0C;IAC3D,OAAOvB,YAAY,CAACwB,WAAb,CAAyB,wBAAzB,EAAmDD,QAAnD,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACEG,aAAa,CAACC,IAAD,EAAe;IAC1BhC,aAAa,CAAC+B,aAAd,CAA4BC,IAA5B;EACD;EAED;AACF;AACA;AACA;;;EACEC,WAAW,CAACC,IAAD,EAAe;IACxBlC,aAAa,CAACiC,WAAd,CAA0BC,IAA1B;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEC,aAAa,CAACC,KAAD,EAAgB;IAC3B,MAAM,IAAIhC,KAAJ,CAAU,YAAV,CAAN;EACD;EAED;AACF;AACA;AACA;;;EACEiC,SAAS,CAACH,IAAD,EAAkD;IACzD,OAAOlC,aAAa,CAACqC,SAAd,CAAwBH,IAAxB,CAAP;EACD;;AAjK6B"}
1
+ {"version":3,"names":["NativeModules","Platform","NativeEventEmitter","HyperTrackError","EVENT_TRACKING","EVENT_AVAILABILITY","EVENT_ERROR","LINKING_ERROR","select","ios","default","HyperTrackSdk","HyperTrackReactNativePlugin","Proxy","get","Error","EventEmitter","HyperTrack","constructor","initialize","publishableKey","sdkInitParams","initializeSdk","loggingEnabled","allowMockLocations","requireBackgroundTrackingPermission","automaticallyRequestPermissions","error","message","getDeviceId","then","deviceId","value","isAvailable","setAvailability","type","isTracking","sync","startTracking","stopTracking","getLocation","locationResponse","deserializeLocationResponse","setName","name","setMetadata","data","addGeotag","subscribeToErrors","listener","addListener","rawErrors","deserializeHyperTrackErrors","subscribeToTracking","subscribeToAvailability","errors","map","response"],"sources":["HyperTrack.ts"],"sourcesContent":["import { NativeModules, Platform, NativeEventEmitter } from 'react-native';\nimport { HyperTrackError } from './data_types/HyperTrackError';\nimport type { IsAvailable } from './data_types/internal/IsAvailable';\nimport type { IsTracking } from './data_types/internal/IsTracking';\nimport type { LocationResponse } from './data_types/internal/LocationResponse';\nimport type { Location } from './data_types/Location';\nimport type { LocationError } from './data_types/LocationError';\nimport type { SdkInitParams } from './data_types/SdkInitParams';\nimport type { DeviceId } from './data_types/internal/DeviceId';\nimport type { Geotag } from './data_types/internal/Geotag';\nimport type { DeviceName } from './data_types/internal/DeviceName';\nimport type { HyperTrackErrorInternal } from './data_types/internal/HyperTrackErrorInternal';\n\nconst EVENT_TRACKING = 'onTrackingChanged';\nconst EVENT_AVAILABILITY = 'onAvailabilityChanged';\nconst EVENT_ERROR = 'onError';\n\nconst LINKING_ERROR =\n `The package 'hypertrack-sdk-react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst HyperTrackSdk = NativeModules.HyperTrackReactNativePlugin\n ? NativeModules.HyperTrackReactNativePlugin\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nconst EventEmitter = new NativeEventEmitter(HyperTrackSdk);\n\nexport default class HyperTrack {\n private constructor() {\n return this;\n }\n\n /**\n * Creates an SDK instance\n * \n * @param publishableKey publishable key provided in HyperTrack’s dashboard setup page\n * @param sdkInitParams\n * @returns HyperTrack instance\n */\n static async initialize(\n publishableKey: string,\n sdkInitParams: SdkInitParams = {}\n ): Promise<HyperTrack> {\n try {\n await HyperTrackSdk.initializeSdk({\n publishableKey,\n loggingEnabled: sdkInitParams.loggingEnabled ?? false,\n allowMockLocations: sdkInitParams.allowMockLocations ?? false,\n requireBackgroundTrackingPermission: sdkInitParams.requireBackgroundTrackingPermission ?? false,\n automaticallyRequestPermissions: sdkInitParams.automaticallyRequestPermissions ?? true,\n });\n return new HyperTrack();\n } catch (error: any) {\n throw new Error(error.message);\n }\n }\n\n /**\n * Returns a string that is used to uniquely identify the device\n */\n getDeviceId(): Promise<string> {\n return HyperTrackSdk.getDeviceId().then(\n (deviceId: DeviceId) => deviceId.value\n );\n }\n\n /**\n * Reflects availability of the device for the Nearby search\n *\n * @returns true when is available or false when unavailable\n */\n isAvailable(): Promise<boolean> {\n return HyperTrackSdk.isAvailable().then(\n (isAvailable: IsAvailable) => isAvailable.value\n );\n }\n\n /**\n * Sets the availability of the device for the Nearby search\n *\n * @param availability true when is available or false when unavailable\n */\n setAvailability(isAvailable: boolean) {\n HyperTrackSdk.setAvailability({\n type: 'isAvailable',\n value: isAvailable\n } as IsAvailable);\n }\n\n /**\n * Reflects the tracking intent for the device\n * \n * @return {boolean} Whether the user's movement data is getting tracked or not.\n */\n isTracking(): Promise<boolean> {\n return HyperTrackSdk.isTracking().then(\n (isTracking: IsTracking) => isTracking.value\n );\n }\n\n /**\n * Syncs the device state with the HyperTrack servers\n */\n sync() {\n HyperTrackSdk.sync();\n }\n\n /**\n * Expresses an intent to start location tracking for the device\n */\n startTracking() {\n HyperTrackSdk.startTracking();\n }\n\n /**\n * Stops location tracking immediately\n */\n stopTracking() {\n HyperTrackSdk.stopTracking();\n }\n\n /**\n * Reflects the current location of the user or an outage reason\n */\n getLocation(): Promise<LocationError | Location> {\n return HyperTrackSdk.getLocation().then(\n (locationResponse: LocationResponse) => {\n return this.deserializeLocationResponse(locationResponse);\n }\n );\n }\n\n /**\n * Sets the name for the device\n * @param {string} name\n */\n setName(name: string) {\n HyperTrackSdk.setName({\n type: 'deviceName',\n value: name\n } as DeviceName)\n }\n\n /**\n * Sets the metadata for the device\n * @param {Object} data - Metadata JSON\n */\n setMetadata(data: Object) {\n HyperTrackSdk.setMetadata(data);\n }\n\n /**\n * Adds a new geotag\n * @param {Object} data - Geotad data JSON\n * @returns current location if success or LocationError if failure\n */\n addGeotag(data: Object): Promise<LocationError | Location> {\n return HyperTrackSdk.addGeotag({\n data\n } as Geotag).then(\n (locationResponse: LocationResponse) => {\n return this.deserializeLocationResponse(locationResponse);\n }\n );\n }\n\n /**\n * Subscribe to tracking errors\n *\n * @param listener\n * @returns EmitterSubscription\n * @example\n * ```js\n * const subscription = HyperTrack.subscribeToErrors(errors => {\n * errors.forEach(error => {\n * // ... error\n * })\n * })\n *\n * // later, to stop listening\n * subscription.remove()\n * ```\n */\n subscribeToErrors(listener: (errors: HyperTrackError[]) => void) {\n return EventEmitter.addListener(EVENT_ERROR, (rawErrors: HyperTrackErrorInternal[]) => {\n listener(this.deserializeHyperTrackErrors(rawErrors))\n });\n }\n\n /**\n * Subscribe to tracking intent changes\n *\n * @param listener\n * @returns EmitterSubscription\n * @example\n * ```js\n * const subscription = HyperTrack.subscribeToTracking(isTracking => {\n * if (isTracking) {\n * // ... ready to go\n * }\n * })\n *\n * // later, to stop listening\n * subscription.remove()\n * ```\n */\n subscribeToTracking(listener: (isTracking: boolean) => void) {\n return EventEmitter.addListener(\n EVENT_TRACKING,\n (isTracking: IsTracking) => {\n listener(isTracking.value);\n }\n );\n }\n\n /**\n * Subscribe to availability changes\n *\n * @param listener\n * @returns EmitterSubscription\n * @example\n * ```js\n * const subscription = HyperTrack.subscribeToAvailability(isAvailable => {\n * if (isAvailable) {\n * // ... ready to go\n * }\n * })\n *\n * // later, to stop listening\n * subscription.remove()\n * ```\n */\n subscribeToAvailability(listener: (isAvailable: boolean) => void) {\n return EventEmitter.addListener(\n EVENT_AVAILABILITY,\n (isAvailable: IsAvailable) => {\n listener(isAvailable.value);\n }\n );\n }\n\n /** @ignore */\n private deserializeHyperTrackErrors(errors: HyperTrackErrorInternal[]): HyperTrackError[] {\n return errors.map((error: HyperTrackErrorInternal) => HyperTrackError[error.value as keyof typeof HyperTrackError])\n }\n\n /** @ignore */\n private deserializeLocationResponse(response: LocationResponse): Location | LocationError {\n switch(response.type) {\n case \"success\":\n return response.value\n case \"failure\":\n switch(response.value.type) {\n case \"notRunning\":\n case \"starting\":\n return response.value\n case \"errors\":\n return {\n type: \"errors\",\n value: this.deserializeHyperTrackErrors(response.value.value)\n }\n }\n };\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;AAC1E,SAASC,eAAe,QAAQ,8BAA8B;AAY9D,MAAMC,cAAc,GAAG,mBAAmB;AAC1C,MAAMC,kBAAkB,GAAG,uBAAuB;AAClD,MAAMC,WAAW,GAAG,SAAS;AAE7B,MAAMC,aAAa,GAChB,sFAAqF,GACtFN,QAAQ,CAACO,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,aAAa,GAAGX,aAAa,CAACY,2BAA2B,GAC3DZ,a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;IACJ;EACH;AACF"}
@@ -0,0 +1,24 @@
1
+ // enum naming convention is ignored to make datatype sync
2
+ // across platforms easier
3
+ export let HyperTrackError;
4
+ (function (HyperTrackError) {
5
+ HyperTrackError["gpsSignalLost"] = "gpsSignalLost";
6
+ HyperTrackError["locationMocked"] = "locationMocked";
7
+ HyperTrackError["locationPermissionsDenied"] = "locationPermissionsDenied";
8
+ HyperTrackError["locationPermissionsInsufficientForBackground"] = "locationPermissionsInsufficientForBackground";
9
+ HyperTrackError["locationPermissionsNotDetermined"] = "locationPermissionsNotDetermined";
10
+ HyperTrackError["locationPermissionsReducedAccuracy"] = "locationPermissionsReducedAccuracy";
11
+ HyperTrackError["locationPermissionsProvisional"] = "locationPermissionsProvisional";
12
+ HyperTrackError["locationPermissionsRestricted"] = "locationPermissionsRestricted";
13
+ HyperTrackError["locationServicesDisabled"] = "locationServicesDisabled";
14
+ HyperTrackError["locationServicesUnavailable"] = "locationServicesUnavailable";
15
+ HyperTrackError["motionActivityPermissionsNotDetermined"] = "motionActivityPermissionsNotDetermined";
16
+ HyperTrackError["motionActivityPermissionsDenied"] = "motionActivityPermissionsDenied";
17
+ HyperTrackError["motionActivityServicesDisabled"] = "motionActivityServicesDisabled";
18
+ HyperTrackError["motionActivityServicesUnavailable"] = "motionActivityServicesUnavailable";
19
+ HyperTrackError["motionActivityPermissionsRestricted"] = "motionActivityPermissionsRestricted";
20
+ HyperTrackError["networkConnectionUnavailable"] = "networkConnectionUnavailable";
21
+ HyperTrackError["invalidPublishableKey"] = "invalidPublishableKey";
22
+ HyperTrackError["blockedFromRunning"] = "blockedFromRunning";
23
+ })(HyperTrackError || (HyperTrackError = {}));
24
+ //# sourceMappingURL=HyperTrackError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HyperTrackError"],"sources":["HyperTrackError.ts"],"sourcesContent":["// enum naming convention is ignored to make datatype sync\n// across platforms easier\nexport enum HyperTrackError {\n gpsSignalLost = \"gpsSignalLost\",\n locationMocked = \"locationMocked\",\n locationPermissionsDenied = \"locationPermissionsDenied\",\n locationPermissionsInsufficientForBackground = \"locationPermissionsInsufficientForBackground\",\n locationPermissionsNotDetermined = \"locationPermissionsNotDetermined\",\n locationPermissionsReducedAccuracy = \"locationPermissionsReducedAccuracy\",\n locationPermissionsProvisional = \"locationPermissionsProvisional\",\n locationPermissionsRestricted = \"locationPermissionsRestricted\",\n locationServicesDisabled = \"locationServicesDisabled\",\n locationServicesUnavailable = \"locationServicesUnavailable\",\n motionActivityPermissionsNotDetermined = \"motionActivityPermissionsNotDetermined\",\n motionActivityPermissionsDenied = \"motionActivityPermissionsDenied\",\n motionActivityServicesDisabled = \"motionActivityServicesDisabled\",\n motionActivityServicesUnavailable = \"motionActivityServicesUnavailable\",\n motionActivityPermissionsRestricted = \"motionActivityPermissionsRestricted\",\n networkConnectionUnavailable = \"networkConnectionUnavailable\",\n invalidPublishableKey = \"invalidPublishableKey\",\n blockedFromRunning = \"blockedFromRunning\"\n}\n"],"mappings":"AAAA;AACA;AACA,WAAYA,eAAe;AAmB1B,WAnBWA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,KAAfA,eAAe"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["Location.ts"],"sourcesContent":["export type Location = {\n type: 'location';\n value: {\n latitude: number;\n longitude: number;\n };\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LocationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["LocationError.ts"],"sourcesContent":["import type { HyperTrackError } from './HyperTrackError';\nimport type { NotRunning, Starting } from './internal/LocationErrorInternal';\n\nexport { NotRunning, Starting }\n\nexport type Errors = {\n type: 'errors';\n value: HyperTrackError[];\n};\n\nexport type LocationError = NotRunning | Starting | Errors;\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=SdkInitParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["SdkInitParams.ts"],"sourcesContent":["/**\n * Parameters for initializing the SDK.\n */\nexport type SdkInitParams = {\n /**\n * Enable debug logging.\n * @default false\n */\n loggingEnabled?: boolean;\n\n /**\n * Allow mock locations to pass through and don’t send mock location outage.\n * @default false\n */\n allowMockLocations?: boolean;\n\n /**\n * Require Background location permissions while requiring permissions on Android.\n * @default false\n */\n requireBackgroundTrackingPermission?: boolean;\n\n /**\n * Automatically request permissions on starting tracking on iOS.\n * @default true\n */\n automaticallyRequestPermissions?: boolean;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=DeviceId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["DeviceId.ts"],"sourcesContent":["export type DeviceId = {\n type: 'deviceID';\n value: string;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=DeviceName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["DeviceName.ts"],"sourcesContent":["export type DeviceName = {\n type: 'deviceName';\n value: string;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Geotag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["Geotag.ts"],"sourcesContent":["export type Geotag = {\n data: Object\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=HyperTrackErrorInternal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["HyperTrackErrorInternal.ts"],"sourcesContent":["export type HyperTrackErrorInternal = {\n type: \"hyperTrackError\",\n value: string\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=IsAvailable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["IsAvailable.ts"],"sourcesContent":["export type IsAvailable = {\n type: 'isAvailable';\n value: boolean;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=IsTracking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["IsTracking.ts"],"sourcesContent":["export type IsTracking = {\n type: 'isTracking';\n value: boolean;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LocationErrorInternal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["LocationErrorInternal.ts"],"sourcesContent":["import type { HyperTrackErrorInternal } from './HyperTrackErrorInternal';\n\nexport type NotRunning = {\n type: 'notRunning';\n};\nexport type Starting = {\n type: 'starting';\n};\nexport type ErrorsInternal = {\n type: 'errors';\n value: HyperTrackErrorInternal[];\n};\n\nexport type LocationErrorInternal = NotRunning | Starting | ErrorsInternal;\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LocationResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["LocationResponse.ts"],"sourcesContent":["import type { Location } from '../Location';\nimport type { LocationErrorInternal } from './LocationErrorInternal';\n\nexport type LocationSuccess = {\n type: 'success';\n value: Location;\n};\n\nexport type LocationFailure = {\n type: 'failure';\n value: LocationErrorInternal;\n};\n\nexport type LocationResponse = LocationSuccess | LocationFailure;\n"],"mappings":""}
@@ -1,5 +1,8 @@
1
1
  import HyperTrack from './HyperTrack/HyperTrack';
2
2
  export default HyperTrack;
3
3
  export { HyperTrack };
4
- export { Location, Error, SDKError, GeotagError, LocationError } from './HyperTrack/HyperTrack';
4
+ export { HyperTrackError } from './HyperTrack/data_types/HyperTrackError';
5
+ export { LocationError, NotRunning, Starting, Errors } from './HyperTrack/data_types/LocationError';
6
+ export { Location } from './HyperTrack/data_types/Location';
7
+ export { SdkInitParams } from './HyperTrack/data_types/SdkInitParams';
5
8
  //# sourceMappingURL=index.js.map