hypertrack-sdk-react-native 8.2.1 → 9.0.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.
- package/CHANGELOG.md +28 -1
- package/CONTRIBUTING.md +32 -110
- package/{LICENSE → LICENSE.md} +2 -0
- package/README.md +20 -40
- package/android/build.gradle +112 -113
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +209 -0
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +2 -4
- package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +88 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/Geotag.kt +9 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackError.kt +27 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +243 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/LocationError.kt +9 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/Result.kt +48 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/SdkInitParams.kt +46 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +20 -0
- package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +196 -0
- package/hypertrack-sdk-react-native.podspec +2 -2
- package/ios/HyperTrackReactNativePlugin.m +54 -0
- package/ios/HyperTrackReactNativePlugin.swift +253 -0
- package/ios/HyperTrackSdk-Bridging-Header.h +2 -0
- package/ios/HyperTrackSdk.xcodeproj/project.pbxproj +8 -11
- package/ios/common/DictionaryDecoder.swift +28 -0
- package/ios/common/HyperTrackError.swift +20 -0
- package/ios/common/HyperTrackSDKWrapper.swift +118 -0
- package/ios/common/SDKInitParams.swift +11 -0
- package/ios/common/SDKMethod.swift +14 -0
- package/ios/common/Serialization.swift +270 -0
- package/lib/commonjs/HyperTrack/HyperTrack.js +141 -142
- package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
- package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js +31 -0
- package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/Location.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/Location.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/LocationError.js +6 -0
- package/lib/commonjs/HyperTrack/data_types/LocationError.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/DeviceId.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/DeviceId.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/Geotag.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/Geotag.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/IsAvailable.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/IsAvailable.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/IsTracking.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/IsTracking.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/LocationErrorInternal.js +6 -0
- package/lib/commonjs/HyperTrack/data_types/internal/LocationErrorInternal.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/LocationResponse.js +6 -0
- package/lib/commonjs/HyperTrack/data_types/internal/LocationResponse.js.map +1 -0
- package/lib/commonjs/index.js +28 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/HyperTrack/HyperTrack.js +140 -134
- package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
- package/lib/module/HyperTrack/data_types/HyperTrackError.js +24 -0
- package/lib/module/HyperTrack/data_types/HyperTrackError.js.map +1 -0
- package/lib/module/HyperTrack/data_types/Location.js +2 -0
- package/lib/module/HyperTrack/data_types/Location.js.map +1 -0
- package/lib/module/HyperTrack/data_types/LocationError.js +2 -0
- package/lib/module/HyperTrack/data_types/LocationError.js.map +1 -0
- package/lib/module/HyperTrack/data_types/SdkInitParams.js +2 -0
- package/lib/module/HyperTrack/data_types/SdkInitParams.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/DeviceId.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/DeviceId.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/DeviceName.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/DeviceName.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/Geotag.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/Geotag.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/IsAvailable.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/IsAvailable.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/IsTracking.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/IsTracking.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/LocationErrorInternal.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/LocationErrorInternal.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/LocationResponse.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/LocationResponse.js.map +1 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/HyperTrack/HyperTrack.d.ts +66 -100
- package/lib/typescript/HyperTrack/data_types/HyperTrackError.d.ts +20 -0
- package/lib/typescript/HyperTrack/data_types/Location.d.ts +7 -0
- package/lib/typescript/HyperTrack/data_types/LocationError.d.ts +8 -0
- package/lib/typescript/HyperTrack/data_types/SdkInitParams.d.ts +5 -0
- package/lib/typescript/HyperTrack/data_types/internal/DeviceId.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/DeviceName.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/Geotag.d.ts +3 -0
- package/lib/typescript/HyperTrack/data_types/internal/HyperTrackErrorInternal.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/IsAvailable.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/IsTracking.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/LocationErrorInternal.d.ts +12 -0
- package/lib/typescript/HyperTrack/data_types/internal/LocationResponse.d.ts +11 -0
- package/lib/typescript/index.d.ts +4 -1
- package/package.json +156 -156
- package/src/HyperTrack/HyperTrack.ts +163 -163
- package/src/HyperTrack/data_types/HyperTrackError.ts +22 -0
- package/src/HyperTrack/data_types/Location.ts +7 -0
- package/src/HyperTrack/data_types/LocationError.ts +11 -0
- package/src/HyperTrack/data_types/SdkInitParams.ts +5 -0
- package/src/HyperTrack/data_types/internal/DeviceId.ts +4 -0
- package/src/HyperTrack/data_types/internal/DeviceName.ts +4 -0
- package/src/HyperTrack/data_types/internal/Geotag.ts +3 -0
- package/src/HyperTrack/data_types/internal/HyperTrackErrorInternal.ts +4 -0
- package/src/HyperTrack/data_types/internal/IsAvailable.ts +4 -0
- package/src/HyperTrack/data_types/internal/IsTracking.ts +4 -0
- package/src/HyperTrack/data_types/internal/LocationErrorInternal.ts +14 -0
- package/src/HyperTrack/data_types/internal/LocationResponse.ts +14 -0
- package/src/index.tsx +4 -7
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackModule.kt +0 -284
- package/ios/HyperTrack.h +0 -7
- package/ios/HyperTrack.m +0 -384
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HyperTrack"],"sources":["index.tsx"],"sourcesContent":["import HyperTrack from './HyperTrack/HyperTrack';\nexport default HyperTrack;\nexport { HyperTrack };\n\nexport {
|
|
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,148 @@
|
|
|
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.
|
|
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
|
-
|
|
63
|
-
|
|
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.
|
|
31
|
+
await HyperTrackSdk.initializeSdk({
|
|
32
|
+
publishableKey,
|
|
33
|
+
loggingEnabled: sdkInitParams.loggingEnabled ?? false,
|
|
34
|
+
allowMockLocations: sdkInitParams.allowMockLocations ?? false,
|
|
35
|
+
requireBackgroundTrackingPermission: sdkInitParams.requireBackgroundTrackingPermission ?? false
|
|
36
|
+
});
|
|
67
37
|
return new HyperTrack();
|
|
68
38
|
} catch (error) {
|
|
69
39
|
throw new Error(error.message);
|
|
70
40
|
}
|
|
71
41
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Enables debug log output. This is very verbose, so you shouldn't use this for
|
|
74
|
-
* production build.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
42
|
|
|
78
|
-
static enableDebugLogging(enable) {
|
|
79
|
-
HyperTrackSdk.enableDebugLogging(enable);
|
|
80
|
-
}
|
|
81
43
|
/**
|
|
82
|
-
* Returns a string
|
|
44
|
+
* Returns a string that is used to uniquely identify the device
|
|
83
45
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
async getDeviceID() {
|
|
87
|
-
return HyperTrackSdk.getDeviceID();
|
|
46
|
+
getDeviceId() {
|
|
47
|
+
return HyperTrackSdk.getDeviceId().then(deviceId => deviceId.value);
|
|
88
48
|
}
|
|
49
|
+
|
|
89
50
|
/**
|
|
90
|
-
*
|
|
51
|
+
* Reflects availability of the device for the Nearby search
|
|
91
52
|
*
|
|
92
53
|
* @returns true when is available or false when unavailable
|
|
93
54
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
55
|
isAvailable() {
|
|
97
|
-
return HyperTrackSdk.isAvailable();
|
|
56
|
+
return HyperTrackSdk.isAvailable().then(isAvailable => isAvailable.value);
|
|
98
57
|
}
|
|
58
|
+
|
|
99
59
|
/**
|
|
100
|
-
*
|
|
60
|
+
* Sets the availability of the device for the Nearby search
|
|
101
61
|
*
|
|
102
62
|
* @param availability true when is available or false when unavailable
|
|
103
63
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
64
|
+
setAvailability(isAvailable) {
|
|
65
|
+
HyperTrackSdk.setAvailability({
|
|
66
|
+
type: 'isAvailable',
|
|
67
|
+
value: isAvailable
|
|
68
|
+
});
|
|
108
69
|
}
|
|
70
|
+
|
|
109
71
|
/**
|
|
110
|
-
*
|
|
72
|
+
* Reflects the tracking intent for the device
|
|
73
|
+
*
|
|
111
74
|
* @return {boolean} Whether the user's movement data is getting tracked or not.
|
|
112
75
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
76
|
isTracking() {
|
|
116
|
-
return HyperTrackSdk.isTracking();
|
|
77
|
+
return HyperTrackSdk.isTracking().then(isTracking => isTracking.value);
|
|
117
78
|
}
|
|
79
|
+
|
|
118
80
|
/**
|
|
119
|
-
*
|
|
81
|
+
* Syncs the device state with the HyperTrack servers
|
|
120
82
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
syncDeviceSettings() {
|
|
124
|
-
HyperTrackSdk.syncDeviceSettings();
|
|
83
|
+
sync() {
|
|
84
|
+
HyperTrackSdk.sync();
|
|
125
85
|
}
|
|
86
|
+
|
|
126
87
|
/**
|
|
127
|
-
*
|
|
88
|
+
* Expresses an intent to start location tracking for the device
|
|
128
89
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
90
|
startTracking() {
|
|
132
91
|
HyperTrackSdk.startTracking();
|
|
133
92
|
}
|
|
93
|
+
|
|
134
94
|
/**
|
|
135
|
-
* Stops
|
|
95
|
+
* Stops location tracking immediately
|
|
136
96
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
97
|
stopTracking() {
|
|
140
98
|
HyperTrackSdk.stopTracking();
|
|
141
|
-
}
|
|
142
|
-
|
|
99
|
+
}
|
|
143
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Reflects the current location of the user or an outage reason
|
|
103
|
+
*/
|
|
144
104
|
getLocation() {
|
|
145
|
-
return HyperTrackSdk.getLocation()
|
|
105
|
+
return HyperTrackSdk.getLocation().then(locationResponse => {
|
|
106
|
+
return this.deserializeLocationResponse(locationResponse);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Sets the name for the device
|
|
112
|
+
* @param {string} name
|
|
113
|
+
*/
|
|
114
|
+
setName(name) {
|
|
115
|
+
HyperTrackSdk.setName({
|
|
116
|
+
type: 'deviceName',
|
|
117
|
+
value: name
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Sets the metadata for the device
|
|
123
|
+
* @param {Object} data - Metadata JSON
|
|
124
|
+
*/
|
|
125
|
+
setMetadata(data) {
|
|
126
|
+
HyperTrackSdk.setMetadata(data);
|
|
146
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Adds a new geotag
|
|
131
|
+
* @param {Object} data - Geotad data JSON
|
|
132
|
+
* @returns current location if success or LocationError if failure
|
|
133
|
+
*/
|
|
134
|
+
addGeotag(data) {
|
|
135
|
+
return HyperTrackSdk.addGeotag({
|
|
136
|
+
data
|
|
137
|
+
}).then(locationResponse => {
|
|
138
|
+
return this.deserializeLocationResponse(locationResponse);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
147
142
|
/**
|
|
148
|
-
*
|
|
143
|
+
* Subscribe to tracking errors
|
|
149
144
|
*
|
|
150
|
-
* @param listener
|
|
145
|
+
* @param listener
|
|
151
146
|
* @returns EmitterSubscription
|
|
152
147
|
* @example
|
|
153
148
|
* ```js
|
|
@@ -161,15 +156,16 @@ export default class HyperTrack {
|
|
|
161
156
|
* subscription.remove()
|
|
162
157
|
* ```
|
|
163
158
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
159
|
subscribeToErrors(listener) {
|
|
167
|
-
return EventEmitter.addListener(
|
|
160
|
+
return EventEmitter.addListener(EVENT_ERROR, rawErrors => {
|
|
161
|
+
listener(this.deserializeHyperTrackErrors(rawErrors));
|
|
162
|
+
});
|
|
168
163
|
}
|
|
164
|
+
|
|
169
165
|
/**
|
|
170
|
-
*
|
|
166
|
+
* Subscribe to tracking intent changes
|
|
171
167
|
*
|
|
172
|
-
* @param listener
|
|
168
|
+
* @param listener
|
|
173
169
|
* @returns EmitterSubscription
|
|
174
170
|
* @example
|
|
175
171
|
* ```js
|
|
@@ -183,48 +179,58 @@ export default class HyperTrack {
|
|
|
183
179
|
* subscription.remove()
|
|
184
180
|
* ```
|
|
185
181
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
182
|
subscribeToTracking(listener) {
|
|
189
|
-
return EventEmitter.addListener(
|
|
183
|
+
return EventEmitter.addListener(EVENT_TRACKING, isTracking => {
|
|
184
|
+
listener(isTracking.value);
|
|
185
|
+
});
|
|
190
186
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Send device name to HyperTrack
|
|
193
|
-
* @param {string} name - Device name you want to see in the Dashboard.
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
187
|
|
|
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
188
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* @param
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
*
|
|
221
|
-
*
|
|
189
|
+
* Subscribe to availability changes
|
|
190
|
+
*
|
|
191
|
+
* @param listener
|
|
192
|
+
* @returns EmitterSubscription
|
|
193
|
+
* @example
|
|
194
|
+
* ```js
|
|
195
|
+
* const subscription = HyperTrack.subscribeToAvailability(isAvailable => {
|
|
196
|
+
* if (isAvailable) {
|
|
197
|
+
* // ... ready to go
|
|
198
|
+
* }
|
|
199
|
+
* })
|
|
200
|
+
*
|
|
201
|
+
* // later, to stop listening
|
|
202
|
+
* subscription.remove()
|
|
203
|
+
* ```
|
|
222
204
|
*/
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
205
|
+
subscribeToAvailability(listener) {
|
|
206
|
+
return EventEmitter.addListener(EVENT_AVAILABILITY, isAvailable => {
|
|
207
|
+
listener(isAvailable.value);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** @ignore */
|
|
212
|
+
deserializeHyperTrackErrors(errors) {
|
|
213
|
+
return errors.map(error => HyperTrackError[error.value]);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** @ignore */
|
|
217
|
+
deserializeLocationResponse(response) {
|
|
218
|
+
switch (response.type) {
|
|
219
|
+
case "success":
|
|
220
|
+
return response.value;
|
|
221
|
+
case "failure":
|
|
222
|
+
switch (response.value.type) {
|
|
223
|
+
case "notRunning":
|
|
224
|
+
case "starting":
|
|
225
|
+
return response.value;
|
|
226
|
+
case "errors":
|
|
227
|
+
return {
|
|
228
|
+
type: "errors",
|
|
229
|
+
value: this.deserializeHyperTrackErrors(response.value.value)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
;
|
|
227
234
|
}
|
|
228
|
-
|
|
229
235
|
}
|
|
230
236
|
//# 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,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;AAWA,MAAMS,YAAY,GAAG,IAAIV,kBAAJ,CAAuBK,aAAvB,CAArB;AAEA,WAAYM,QAAZ;AAmBA;AACA;AACA;;WArBYA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AA2BZ;AACA;AACA;AACA,WAAYC,WAAZ;;WAAYA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,KAA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;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","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 });\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,aAAa,CAACY,2BAA2B,GACzC,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAEH,MAAMS,YAAY,GAAG,IAAId,kBAAkB,CAACS,aAAa,CAAC;AAE1D,eAAe,MAAMM,UAAU,CAAC;EACtBC,WAAW,GAAG;IACpB,OAAO,IAAI;EACb;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,UAAU,CACrBC,cAAsB,EAED;IAAA,IADrBC,aAA4B,uEAAG,CAAC,CAAC;IAEjC,IAAI;MACF,MAAMV,aAAa,CAACW,aAAa,CAAC;QAChCF,cAAc;QACdG,cAAc,EAAEF,aAAa,CAACE,cAAc,IAAI,KAAK;QACrDC,kBAAkB,EAAEH,aAAa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,IAAK;MAC5BgB,QAAQ,CAAChB,WAAW,CAACD,KAAK,CAAC;IAC7B,CAAC,CACF;EACH;;EAEA;EACQoB,2BAA2B,CAACG,MAAiC,EAAqB;IACxF,OAAOA,MAAM,CAACC,GAAG,CAAE7B,KAA8B,IAAKvB,eAAe,CAACuB,KAAK,CAACK,KAAK,CAAiC,CAAC;EACrH;;EAEA;EACQU,2BAA2B,CAACe,QAA0B,EAA4B;IACxF,QAAOA,QAAQ,CAACtB,IAAI;MAClB,KAAK,SAAS;QACZ,OAAOsB,QAAQ,CAACzB,KAAK;MACvB,KAAK,SAAS;QACZ,QAAOyB,QAAQ,CAACzB,KAAK,CAACG,IAAI;UACxB,KAAK,YAAY;UACjB,KAAK,UAAU;YACb,OAAOsB,QAAQ,CAACzB,KAAK;UACvB,KAAK,QAAQ;YACX,OAAO;cACLG,IAAI,EAAE,QAAQ;cACdH,KAAK,EAAE,IAAI,CAACoB,2BAA2B,CAACK,QAAQ,CAACzB,KAAK,CAACA,KAAK;YAC9D,CAAC;QAAA;IACJ;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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["SdkInitParams.ts"],"sourcesContent":["export type SdkInitParams = {\n loggingEnabled?: boolean;\n allowMockLocations?: boolean;\n requireBackgroundTrackingPermission?: boolean;\n};\n"],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["DeviceName.ts"],"sourcesContent":["export type DeviceName = {\n type: 'deviceName';\n value: string;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["Geotag.ts"],"sourcesContent":["export type Geotag = {\n data: Object\n}\n"],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["IsAvailable.ts"],"sourcesContent":["export type IsAvailable = {\n type: 'isAvailable';\n value: boolean;\n};\n"],"mappings":""}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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":""}
|
package/lib/module/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import HyperTrack from './HyperTrack/HyperTrack';
|
|
2
2
|
export default HyperTrack;
|
|
3
3
|
export { HyperTrack };
|
|
4
|
-
export {
|
|
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
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HyperTrack","
|
|
1
|
+
{"version":3,"names":["HyperTrack","HyperTrackError","LocationError","NotRunning","Starting","Errors","Location","SdkInitParams"],"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,OAAOA,UAAU,MAAM,yBAAyB;AAChD,eAAeA,UAAU;AACzB,SAASA,UAAU;AAEnB,SAASC,eAAe,QAAQ,yCAAyC;AACzE,SAASC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,uCAAuC;AACnG,SAASC,QAAQ,QAAQ,kCAAkC;AAC3D,SAASC,aAAa,QAAQ,uCAAuC"}
|