hypertrack-sdk-react-native 13.5.0 → 13.5.1
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/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +40 -37
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +3 -6
- package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +2 -3
- package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +42 -65
- package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +69 -103
- package/android/src/main/java/com/reactnativehypertracksdk/common/WrapperResult.kt +14 -14
- package/lib/commonjs/HyperTrack/HyperTrack.js +5 -1
- package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
- package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
- package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
- package/lib/commonjs/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
- package/lib/module/HyperTrack/HyperTrack.js +5 -1
- package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
- package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
- package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
- package/lib/module/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
- package/lib/typescript/HyperTrack/data_types/internal/IsInsideGeofence.d.ts +4 -0
- package/lib/typescript/HyperTrack/data_types/internal/OrderInternal.d.ts +2 -1
- package/package.json +1 -1
- package/src/HyperTrack/HyperTrack.ts +7 -2
- package/src/HyperTrack/data_types/internal/IsInsideGeofence.ts +4 -0
- package/src/HyperTrack/data_types/internal/OrderInternal.ts +2 -1
|
@@ -20,14 +20,13 @@ import com.reactnativehypertracksdk.common.Serialization.serializeOrders
|
|
|
20
20
|
import com.reactnativehypertracksdk.common.Success
|
|
21
21
|
|
|
22
22
|
@ReactModule(name = HyperTrackReactNativePlugin.NAME)
|
|
23
|
-
class HyperTrackReactNativePlugin(
|
|
24
|
-
|
|
23
|
+
class HyperTrackReactNativePlugin(
|
|
24
|
+
reactContext: ReactApplicationContext?,
|
|
25
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
25
26
|
private var locateSubscription: HyperTrack.Cancellable? = null
|
|
26
27
|
private var subscriptions: List<HyperTrack.Cancellable>? = null
|
|
27
28
|
|
|
28
|
-
override fun getName(): String
|
|
29
|
-
return NAME
|
|
30
|
-
}
|
|
29
|
+
override fun getName(): String = NAME
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* ReactNative built-in methods
|
|
@@ -181,39 +180,43 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
|
|
|
181
180
|
HyperTrackSdkWrapper.setWorkerHandle(args.toHashMap())
|
|
182
181
|
}
|
|
183
182
|
|
|
184
|
-
private fun initListeners(): List<HyperTrack.Cancellable>
|
|
185
|
-
|
|
186
|
-
HyperTrack
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
183
|
+
private fun initListeners(): List<HyperTrack.Cancellable> =
|
|
184
|
+
mutableListOf<HyperTrack.Cancellable>().also { result ->
|
|
185
|
+
HyperTrack
|
|
186
|
+
.subscribeToErrors {
|
|
187
|
+
emitEvent(EVENT_ERRORS, serializeErrors(it).toWriteableArray())
|
|
188
|
+
}.also {
|
|
189
|
+
result.add(it)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
HyperTrack
|
|
193
|
+
.subscribeToIsAvailable {
|
|
194
|
+
emitEvent(EVENT_IS_AVAILABLE, serializeIsAvailable(it).toWritableMap())
|
|
195
|
+
}.also {
|
|
196
|
+
result.add(it)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
HyperTrack
|
|
200
|
+
.subscribeToIsTracking {
|
|
201
|
+
emitEvent(EVENT_IS_TRACKING, serializeIsTracking(it).toWritableMap())
|
|
202
|
+
}.also {
|
|
203
|
+
result.add(it)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
HyperTrack
|
|
207
|
+
.subscribeToLocation {
|
|
208
|
+
emitEvent(EVENT_LOCATION, serializeLocationResult(it).toWritableMap())
|
|
209
|
+
}.also {
|
|
210
|
+
result.add(it)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
HyperTrack
|
|
214
|
+
.subscribeToOrders {
|
|
215
|
+
emitEvent(EVENT_ORDERS, serializeOrders(it.values).toWritableMap())
|
|
216
|
+
}.also {
|
|
217
|
+
result.add(it)
|
|
218
|
+
}
|
|
215
219
|
}
|
|
216
|
-
}
|
|
217
220
|
|
|
218
221
|
private fun emitEvent(
|
|
219
222
|
event: String,
|
|
@@ -5,11 +5,8 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
5
5
|
import com.facebook.react.uimanager.ViewManager
|
|
6
6
|
|
|
7
7
|
class HyperTrackSdkPackage : ReactPackage {
|
|
8
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule>
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> =
|
|
9
|
+
listOf(HyperTrackReactNativePlugin(reactContext)).toMutableList()
|
|
11
10
|
|
|
12
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>>
|
|
13
|
-
return emptyList()
|
|
14
|
-
}
|
|
11
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> = emptyList()
|
|
15
12
|
}
|
|
@@ -60,8 +60,8 @@ internal fun <T> WrapperResult<T>.toPromise(promise: Promise) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
@Suppress("UNCHECKED_CAST")
|
|
63
|
-
internal fun List<Any>.toWriteableArray(): WritableArray
|
|
64
|
-
|
|
63
|
+
internal fun List<Any>.toWriteableArray(): WritableArray =
|
|
64
|
+
Arguments.createArray().also { writableArray ->
|
|
65
65
|
forEach {
|
|
66
66
|
when (it) {
|
|
67
67
|
is String -> {
|
|
@@ -78,7 +78,6 @@ internal fun List<Any>.toWriteableArray(): WritableArray {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
}
|
|
82
81
|
|
|
83
82
|
@Suppress("UNCHECKED_CAST")
|
|
84
83
|
internal fun Map<String, Any?>.toWritableMap(): WritableMap {
|
|
@@ -31,8 +31,8 @@ typealias Serialized = Map<String, Any?>
|
|
|
31
31
|
* It receives serialized params.
|
|
32
32
|
*/
|
|
33
33
|
internal object HyperTrackSdkWrapper {
|
|
34
|
-
fun addGeotag(args: Serialized): WrapperResult<Serialized>
|
|
35
|
-
|
|
34
|
+
fun addGeotag(args: Serialized): WrapperResult<Serialized> =
|
|
35
|
+
deserializeGeotagData(args)
|
|
36
36
|
.flatMapSuccess { geotag ->
|
|
37
37
|
// TODO: return proper error if JSON is wrong
|
|
38
38
|
val geotagMetadata = Json.fromMap(geotag.data)!!
|
|
@@ -60,18 +60,17 @@ internal object HyperTrackSdkWrapper {
|
|
|
60
60
|
)
|
|
61
61
|
} else {
|
|
62
62
|
HyperTrack.addGeotag(geotagMetadata, expectedLocation)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
serializeLocationWithDeviationSuccess(it.success)
|
|
72
|
-
}
|
|
63
|
+
}.let {
|
|
64
|
+
when (it) {
|
|
65
|
+
is Result.Failure -> {
|
|
66
|
+
serializeLocationErrorFailure(it.failure)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
is Result.Success -> {
|
|
70
|
+
serializeLocationWithDeviationSuccess(it.success)
|
|
73
71
|
}
|
|
74
72
|
}
|
|
73
|
+
}
|
|
75
74
|
} else {
|
|
76
75
|
if (orderHandle != null || orderStatus != null) {
|
|
77
76
|
if (orderHandle == null || orderStatus == null) {
|
|
@@ -84,116 +83,94 @@ internal object HyperTrackSdkWrapper {
|
|
|
84
83
|
)
|
|
85
84
|
} else {
|
|
86
85
|
HyperTrack.addGeotag(geotagMetadata)
|
|
87
|
-
}
|
|
88
|
-
.let { serializeLocationResult(it) }
|
|
86
|
+
}.let { serializeLocationResult(it) }
|
|
89
87
|
}.let {
|
|
90
88
|
Success(it)
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
}
|
|
94
91
|
|
|
95
|
-
fun getDeviceId(): WrapperResult<Serialized>
|
|
96
|
-
return Success(serializeDeviceId(HyperTrack.deviceID))
|
|
97
|
-
}
|
|
92
|
+
fun getDeviceId(): WrapperResult<Serialized> = Success(serializeDeviceId(HyperTrack.deviceID))
|
|
98
93
|
|
|
99
|
-
fun getDynamicPublishableKey(): WrapperResult<Serialized>
|
|
100
|
-
return Success(serializeDynamicPublishableKey(HyperTrack.dynamicPublishableKey))
|
|
101
|
-
}
|
|
94
|
+
fun getDynamicPublishableKey(): WrapperResult<Serialized> = Success(serializeDynamicPublishableKey(HyperTrack.dynamicPublishableKey))
|
|
102
95
|
|
|
103
|
-
fun getErrors(): WrapperResult<List<Serialized>>
|
|
104
|
-
return Success(serializeErrors(HyperTrack.errors))
|
|
105
|
-
}
|
|
96
|
+
fun getErrors(): WrapperResult<List<Serialized>> = Success(serializeErrors(HyperTrack.errors))
|
|
106
97
|
|
|
107
|
-
fun getIsAvailable(): WrapperResult<Serialized>
|
|
108
|
-
|
|
98
|
+
fun getIsAvailable(): WrapperResult<Serialized> =
|
|
99
|
+
Success(
|
|
109
100
|
serializeIsAvailable(HyperTrack.isAvailable),
|
|
110
101
|
)
|
|
111
|
-
}
|
|
112
102
|
|
|
113
|
-
fun getIsTracking(): WrapperResult<Serialized>
|
|
114
|
-
|
|
103
|
+
fun getIsTracking(): WrapperResult<Serialized> =
|
|
104
|
+
Success(
|
|
115
105
|
serializeIsTracking(HyperTrack.isTracking),
|
|
116
106
|
)
|
|
117
|
-
}
|
|
118
107
|
|
|
119
|
-
fun getLocation(): WrapperResult<Serialized>
|
|
120
|
-
|
|
108
|
+
fun getLocation(): WrapperResult<Serialized> =
|
|
109
|
+
HyperTrack
|
|
121
110
|
.location
|
|
122
111
|
.let {
|
|
123
112
|
when (it) {
|
|
124
113
|
is Result.Failure -> serializeLocationErrorFailure(it.failure)
|
|
125
114
|
is Result.Success -> serializeLocationSuccess(it.success)
|
|
126
115
|
}
|
|
127
|
-
}
|
|
128
|
-
.let { Success(it) }
|
|
129
|
-
}
|
|
116
|
+
}.let { Success(it) }
|
|
130
117
|
|
|
131
|
-
fun getMetadata(): WrapperResult<Serialized>
|
|
132
|
-
|
|
118
|
+
fun getMetadata(): WrapperResult<Serialized> =
|
|
119
|
+
Success(
|
|
133
120
|
serializeMetadata(HyperTrack.metadata.toMap()),
|
|
134
121
|
)
|
|
135
|
-
}
|
|
136
122
|
|
|
137
|
-
fun getName(): WrapperResult<Serialized>
|
|
138
|
-
|
|
123
|
+
fun getName(): WrapperResult<Serialized> =
|
|
124
|
+
Success(
|
|
139
125
|
serializeName(HyperTrack.name),
|
|
140
126
|
)
|
|
141
|
-
}
|
|
142
127
|
|
|
143
|
-
fun getOrders(): WrapperResult<Serialized>
|
|
144
|
-
|
|
128
|
+
fun getOrders(): WrapperResult<Serialized> =
|
|
129
|
+
Success(
|
|
145
130
|
serializeOrders(HyperTrack.orders.values),
|
|
146
131
|
)
|
|
147
|
-
}
|
|
148
132
|
|
|
149
|
-
fun getWorkerHandle(): WrapperResult<Serialized>
|
|
150
|
-
|
|
133
|
+
fun getWorkerHandle(): WrapperResult<Serialized> =
|
|
134
|
+
Success(
|
|
151
135
|
serializeWorkerHandle(HyperTrack.workerHandle),
|
|
152
136
|
)
|
|
153
|
-
}
|
|
154
137
|
|
|
155
|
-
fun setDynamicPublishableKey(args: Serialized): WrapperResult<Unit>
|
|
156
|
-
|
|
138
|
+
fun setDynamicPublishableKey(args: Serialized): WrapperResult<Unit> =
|
|
139
|
+
deserializeDynamicPublishableKey(args)
|
|
157
140
|
.mapSuccess { publishableKey ->
|
|
158
141
|
HyperTrack.dynamicPublishableKey = publishableKey
|
|
159
142
|
}
|
|
160
|
-
}
|
|
161
143
|
|
|
162
|
-
fun setIsAvailable(args: Serialized): WrapperResult<Unit>
|
|
163
|
-
|
|
144
|
+
fun setIsAvailable(args: Serialized): WrapperResult<Unit> =
|
|
145
|
+
deserializeIsAvailable(args)
|
|
164
146
|
.mapSuccess { isAvailable ->
|
|
165
147
|
HyperTrack.isAvailable = isAvailable
|
|
166
148
|
}
|
|
167
|
-
}
|
|
168
149
|
|
|
169
|
-
fun setIsTracking(args: Serialized): WrapperResult<Unit>
|
|
170
|
-
|
|
150
|
+
fun setIsTracking(args: Serialized): WrapperResult<Unit> =
|
|
151
|
+
deserializeIsTracking(args)
|
|
171
152
|
.mapSuccess { isTracking ->
|
|
172
153
|
HyperTrack.isTracking = isTracking
|
|
173
154
|
}
|
|
174
|
-
}
|
|
175
155
|
|
|
176
|
-
fun setMetadata(args: Serialized): WrapperResult<Unit>
|
|
177
|
-
|
|
156
|
+
fun setMetadata(args: Serialized): WrapperResult<Unit> =
|
|
157
|
+
deserializeMetadata(args)
|
|
178
158
|
.flatMapSuccess { metadata ->
|
|
179
159
|
WrapperResult.tryAsResult {
|
|
180
160
|
// TODO: return proper error if JSON is wrong
|
|
181
161
|
HyperTrack.metadata = Json.fromMap(metadata)!!
|
|
182
162
|
}
|
|
183
163
|
}
|
|
184
|
-
}
|
|
185
164
|
|
|
186
|
-
fun setName(args: Serialized): WrapperResult<Unit>
|
|
187
|
-
|
|
165
|
+
fun setName(args: Serialized): WrapperResult<Unit> =
|
|
166
|
+
deserializeName(args)
|
|
188
167
|
.mapSuccess { name ->
|
|
189
168
|
HyperTrack.name = name
|
|
190
169
|
}
|
|
191
|
-
}
|
|
192
170
|
|
|
193
|
-
fun setWorkerHandle(args: Serialized): WrapperResult<Unit>
|
|
194
|
-
|
|
171
|
+
fun setWorkerHandle(args: Serialized): WrapperResult<Unit> =
|
|
172
|
+
deserializeWorkerHandle(args)
|
|
195
173
|
.mapSuccess { workerHandle ->
|
|
196
174
|
HyperTrack.workerHandle = workerHandle
|
|
197
175
|
}
|
|
198
|
-
}
|
|
199
176
|
}
|