@hot-updater/react-native 0.27.1 → 0.29.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 (87) hide show
  1. package/android/build.gradle +12 -0
  2. package/android/src/main/AndroidManifest.xml +3 -0
  3. package/android/src/main/AndroidManifestNew.xml +3 -0
  4. package/android/src/main/cpp/CMakeLists.txt +9 -0
  5. package/android/src/main/cpp/HotUpdaterRecovery.cpp +143 -0
  6. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +325 -210
  7. package/android/src/main/java/com/hotupdater/BundleMetadata.kt +73 -16
  8. package/android/src/main/java/com/hotupdater/CohortService.kt +73 -0
  9. package/android/src/main/java/com/hotupdater/DecompressService.kt +28 -22
  10. package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +1 -1
  11. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +51 -13
  12. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +533 -0
  13. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryReceiver.kt +14 -0
  14. package/android/src/main/java/com/hotupdater/ReactNativeValueConverters.kt +55 -0
  15. package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +19 -7
  16. package/android/src/newarch/HotUpdaterModule.kt +16 -25
  17. package/android/src/oldarch/HotUpdaterModule.kt +20 -26
  18. package/android/src/oldarch/HotUpdaterSpec.kt +12 -2
  19. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +340 -232
  20. package/ios/HotUpdater/Internal/BundleMetadata.swift +61 -8
  21. package/ios/HotUpdater/Internal/CohortService.swift +63 -0
  22. package/ios/HotUpdater/Internal/DecompressService.swift +53 -30
  23. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +9 -1
  24. package/ios/HotUpdater/Internal/HotUpdater.mm +376 -70
  25. package/ios/HotUpdater/Internal/HotUpdaterCrashHandler.h +7 -0
  26. package/ios/HotUpdater/Internal/HotUpdaterCrashHandler.mm +4 -0
  27. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +321 -9
  28. package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +24 -8
  29. package/lib/commonjs/DefaultResolver.js +3 -5
  30. package/lib/commonjs/DefaultResolver.js.map +1 -1
  31. package/lib/commonjs/checkForUpdate.js +2 -0
  32. package/lib/commonjs/checkForUpdate.js.map +1 -1
  33. package/lib/commonjs/index.js +13 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/native.js +211 -39
  36. package/lib/commonjs/native.js.map +1 -1
  37. package/lib/commonjs/native.spec.js +443 -0
  38. package/lib/commonjs/native.spec.js.map +1 -0
  39. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  40. package/lib/commonjs/types.js.map +1 -1
  41. package/lib/commonjs/wrap.js +4 -5
  42. package/lib/commonjs/wrap.js.map +1 -1
  43. package/lib/module/DefaultResolver.js +3 -5
  44. package/lib/module/DefaultResolver.js.map +1 -1
  45. package/lib/module/checkForUpdate.js +3 -1
  46. package/lib/module/checkForUpdate.js.map +1 -1
  47. package/lib/module/index.js +14 -1
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/module/native.js +204 -34
  50. package/lib/module/native.js.map +1 -1
  51. package/lib/module/native.spec.js +442 -0
  52. package/lib/module/native.spec.js.map +1 -0
  53. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  54. package/lib/module/types.js.map +1 -1
  55. package/lib/module/wrap.js +5 -6
  56. package/lib/module/wrap.js.map +1 -1
  57. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/index.d.ts +14 -1
  59. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/native.d.ts +43 -23
  61. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +32 -8
  63. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/types.d.ts +6 -3
  65. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/wrap.d.ts +3 -6
  67. package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
  68. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  69. package/lib/typescript/module/index.d.ts +14 -1
  70. package/lib/typescript/module/index.d.ts.map +1 -1
  71. package/lib/typescript/module/native.d.ts +43 -23
  72. package/lib/typescript/module/native.d.ts.map +1 -1
  73. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +32 -8
  74. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  75. package/lib/typescript/module/types.d.ts +6 -3
  76. package/lib/typescript/module/types.d.ts.map +1 -1
  77. package/lib/typescript/module/wrap.d.ts +3 -6
  78. package/lib/typescript/module/wrap.d.ts.map +1 -1
  79. package/package.json +6 -6
  80. package/src/DefaultResolver.ts +4 -4
  81. package/src/checkForUpdate.ts +4 -0
  82. package/src/index.ts +21 -0
  83. package/src/native.spec.ts +480 -0
  84. package/src/native.ts +285 -39
  85. package/src/specs/NativeHotUpdater.ts +36 -6
  86. package/src/types.ts +7 -3
  87. package/src/wrap.tsx +8 -12
@@ -7,6 +7,7 @@ import com.facebook.react.bridge.Promise
7
7
  import com.facebook.react.bridge.ReactApplicationContext
8
8
  import com.facebook.react.bridge.ReactMethod
9
9
  import com.facebook.react.bridge.ReadableMap
10
+ import com.facebook.react.bridge.WritableNativeArray
10
11
  import com.facebook.react.bridge.WritableNativeMap
11
12
  import com.facebook.react.modules.core.DeviceEventManagerModule
12
13
  import kotlinx.coroutines.CoroutineScope
@@ -14,13 +15,12 @@ import kotlinx.coroutines.Dispatchers
14
15
  import kotlinx.coroutines.SupervisorJob
15
16
  import kotlinx.coroutines.cancel
16
17
  import kotlinx.coroutines.launch
17
- import org.json.JSONArray
18
- import org.json.JSONObject
19
18
 
20
19
  class HotUpdaterModule internal constructor(
21
20
  context: ReactApplicationContext,
22
21
  ) : HotUpdaterSpec(context) {
23
22
  private val mReactApplicationContext: ReactApplicationContext = context
23
+ private val cohortService = CohortService(context)
24
24
 
25
25
  // Managed coroutine scope for the module lifecycle
26
26
  private val moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
@@ -153,32 +153,10 @@ class HotUpdaterModule internal constructor(
153
153
  }
154
154
 
155
155
  @ReactMethod(isBlockingSynchronousMethod = true)
156
- override fun notifyAppReady(params: ReadableMap): String {
157
- val bundleId = params.getString("bundleId")
158
- val result = JSONObject()
159
-
160
- if (bundleId == null) {
161
- result.put("status", "STABLE")
162
- return result.toString()
163
- }
164
-
165
- val impl = getInstance()
166
- val statusMap = impl.notifyAppReady(bundleId)
167
-
168
- result.put("status", statusMap["status"] as? String ?: "STABLE")
169
- statusMap["crashedBundleId"]?.let {
170
- result.put("crashedBundleId", it as String)
171
- }
172
-
173
- return result.toString()
174
- }
156
+ override fun notifyAppReady(): WritableNativeMap = getInstance().notifyAppReady().toWritableNativeMap()
175
157
 
176
158
  @ReactMethod(isBlockingSynchronousMethod = true)
177
- override fun getCrashHistory(): String {
178
- val impl = getInstance()
179
- val crashHistory = impl.getCrashHistory()
180
- return JSONArray(crashHistory).toString()
181
- }
159
+ override fun getCrashHistory(): WritableNativeArray = getInstance().getCrashHistory().toWritableNativeArray()
182
160
 
183
161
  @ReactMethod(isBlockingSynchronousMethod = true)
184
162
  override fun clearCrashHistory(): Boolean {
@@ -192,7 +170,23 @@ class HotUpdaterModule internal constructor(
192
170
  return impl.getBaseURL()
193
171
  }
194
172
 
173
+ @ReactMethod(isBlockingSynchronousMethod = true)
174
+ override fun getBundleId(): String? {
175
+ val impl = getInstance()
176
+ return impl.getBundleId()
177
+ }
178
+
179
+ @ReactMethod(isBlockingSynchronousMethod = true)
180
+ override fun getManifest(): WritableNativeMap = getInstance().getManifest().toWritableNativeMap()
181
+
195
182
  @ReactMethod
183
+ override fun setCohort(cohort: String) {
184
+ cohortService.setCohort(cohort)
185
+ }
186
+
187
+ @ReactMethod(isBlockingSynchronousMethod = true)
188
+ override fun getCohort(): String = cohortService.getCohort()
189
+
196
190
  override fun resetChannel(promise: Promise) {
197
191
  moduleScope.launch {
198
192
  try {
@@ -4,6 +4,8 @@ import com.facebook.react.bridge.Promise
4
4
  import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.bridge.ReactContextBaseJavaModule
6
6
  import com.facebook.react.bridge.ReadableMap
7
+ import com.facebook.react.bridge.WritableArray
8
+ import com.facebook.react.bridge.WritableMap
7
9
 
8
10
  abstract class HotUpdaterSpec internal constructor(
9
11
  context: ReactApplicationContext,
@@ -17,13 +19,21 @@ abstract class HotUpdaterSpec internal constructor(
17
19
 
18
20
  abstract fun reloadProcess(promise: Promise)
19
21
 
20
- abstract fun notifyAppReady(params: ReadableMap): String
22
+ abstract fun notifyAppReady(): WritableMap
21
23
 
22
- abstract fun getCrashHistory(): String
24
+ abstract fun getCrashHistory(): WritableArray
23
25
 
24
26
  abstract fun clearCrashHistory(): Boolean
25
27
 
26
28
  abstract fun getBaseURL(): String
27
29
 
30
+ abstract fun setCohort(customId: String)
31
+
32
+ abstract fun getCohort(): String
33
+
34
+ abstract fun getBundleId(): String?
35
+
36
+ abstract fun getManifest(): WritableMap
37
+
28
38
  abstract fun resetChannel(promise: Promise)
29
39
  }