hypertrack-sdk-react-native 13.5.0 → 13.6.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 (37) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +40 -37
  3. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +3 -6
  4. package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +2 -3
  5. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +42 -65
  6. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +69 -103
  7. package/android/src/main/java/com/reactnativehypertracksdk/common/WrapperResult.kt +14 -14
  8. package/hypertrack-sdk-react-native.podspec +1 -1
  9. package/lib/commonjs/HyperTrack/HyperTrack.js +5 -1
  10. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  11. package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
  12. package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
  13. package/lib/commonjs/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
  14. package/lib/module/HyperTrack/HyperTrack.js +5 -1
  15. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  16. package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
  17. package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
  18. package/lib/module/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
  19. package/lib/typescript/HyperTrack/data_types/internal/IsInsideGeofence.d.ts +4 -0
  20. package/lib/typescript/HyperTrack/data_types/internal/OrderInternal.d.ts +2 -1
  21. package/package.json +1 -1
  22. package/src/HyperTrack/HyperTrack.ts +7 -2
  23. package/src/HyperTrack/data_types/internal/IsInsideGeofence.ts +4 -0
  24. package/src/HyperTrack/data_types/internal/OrderInternal.ts +2 -1
  25. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  26. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  27. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  28. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  29. package/android/.gradle/7.2/gc.properties +0 -0
  30. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  31. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  32. package/android/.gradle/checksums/checksums.lock +0 -0
  33. package/android/.gradle/vcs-1/gc.properties +0 -0
  34. package/android/.idea/gradle.xml +0 -15
  35. package/android/.idea/misc.xml +0 -9
  36. package/android/.idea/vcs.xml +0 -6
  37. package/android/local.properties +0 -8
@@ -1,3 +1,3 @@
1
1
  HyperTrackSdk_kotlinVersion=1.6.21
2
- HyperTrackSdk_HyperTrackSDKVersion=7.7.0
2
+ HyperTrackSdk_HyperTrackSDKVersion=7.8.0
3
3
  android.useAndroidX=true
@@ -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(reactContext: ReactApplicationContext?) :
24
- ReactContextBaseJavaModule(reactContext) {
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
- return mutableListOf<HyperTrack.Cancellable>().also { result ->
186
- HyperTrack.subscribeToErrors {
187
- emitEvent(EVENT_ERRORS, serializeErrors(it).toWriteableArray())
188
- }.also {
189
- result.add(it)
190
- }
191
-
192
- HyperTrack.subscribeToIsAvailable {
193
- emitEvent(EVENT_IS_AVAILABLE, serializeIsAvailable(it).toWritableMap())
194
- }.also {
195
- result.add(it)
196
- }
197
-
198
- HyperTrack.subscribeToIsTracking {
199
- emitEvent(EVENT_IS_TRACKING, serializeIsTracking(it).toWritableMap())
200
- }.also {
201
- result.add(it)
202
- }
203
-
204
- HyperTrack.subscribeToLocation {
205
- emitEvent(EVENT_LOCATION, serializeLocationResult(it).toWritableMap())
206
- }.also {
207
- result.add(it)
208
- }
209
-
210
- HyperTrack.subscribeToOrders {
211
- emitEvent(EVENT_ORDERS, serializeOrders(it.values).toWritableMap())
212
- }.also {
213
- result.add(it)
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
- return listOf(HyperTrackReactNativePlugin(reactContext)).toMutableList()
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
- return Arguments.createArray().also { writableArray ->
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
- return deserializeGeotagData(args)
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
- .let {
65
- when (it) {
66
- is Result.Failure -> {
67
- serializeLocationErrorFailure(it.failure)
68
- }
69
-
70
- is Result.Success -> {
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
- return Success(
98
+ fun getIsAvailable(): WrapperResult<Serialized> =
99
+ Success(
109
100
  serializeIsAvailable(HyperTrack.isAvailable),
110
101
  )
111
- }
112
102
 
113
- fun getIsTracking(): WrapperResult<Serialized> {
114
- return Success(
103
+ fun getIsTracking(): WrapperResult<Serialized> =
104
+ Success(
115
105
  serializeIsTracking(HyperTrack.isTracking),
116
106
  )
117
- }
118
107
 
119
- fun getLocation(): WrapperResult<Serialized> {
120
- return HyperTrack
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
- return Success(
118
+ fun getMetadata(): WrapperResult<Serialized> =
119
+ Success(
133
120
  serializeMetadata(HyperTrack.metadata.toMap()),
134
121
  )
135
- }
136
122
 
137
- fun getName(): WrapperResult<Serialized> {
138
- return Success(
123
+ fun getName(): WrapperResult<Serialized> =
124
+ Success(
139
125
  serializeName(HyperTrack.name),
140
126
  )
141
- }
142
127
 
143
- fun getOrders(): WrapperResult<Serialized> {
144
- return Success(
128
+ fun getOrders(): WrapperResult<Serialized> =
129
+ Success(
145
130
  serializeOrders(HyperTrack.orders.values),
146
131
  )
147
- }
148
132
 
149
- fun getWorkerHandle(): WrapperResult<Serialized> {
150
- return Success(
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
- return deserializeDynamicPublishableKey(args)
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
- return deserializeIsAvailable(args)
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
- return deserializeIsTracking(args)
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
- return deserializeMetadata(args)
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
- return deserializeName(args)
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
- return deserializeWorkerHandle(args)
171
+ fun setWorkerHandle(args: Serialized): WrapperResult<Unit> =
172
+ deserializeWorkerHandle(args)
195
173
  .mapSuccess { workerHandle ->
196
174
  HyperTrack.workerHandle = workerHandle
197
175
  }
198
- }
199
176
  }