@hot-updater/react-native 1.0.0-rc.4 → 1.0.0-rc.41

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 (317) hide show
  1. package/android/build.gradle +13 -2
  2. package/android/proguard-rules.pro +8 -2
  3. package/android/src/bridge/BridgeReactInstance.kt +38 -0
  4. package/android/src/bridgeless/BridgeReactInstance.kt +24 -0
  5. package/android/src/main/java/com/hotupdater/ActivityStartGate.kt +94 -0
  6. package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
  7. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +1064 -844
  8. package/android/src/main/java/com/hotupdater/BundleMetadata.kt +50 -11
  9. package/android/src/main/java/com/hotupdater/FileManagerService.kt +45 -0
  10. package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +287 -22
  11. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +46 -30
  12. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +75 -192
  13. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryState.kt +64 -0
  14. package/android/src/main/java/com/hotupdater/InstallIdentityService.kt +37 -0
  15. package/android/src/main/java/com/hotupdater/KeyValueStorageService.kt +86 -0
  16. package/android/src/main/java/com/hotupdater/NetworkState.kt +31 -0
  17. package/android/src/main/java/com/hotupdater/NoBackupStorage.kt +17 -0
  18. package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +127 -50
  19. package/android/src/main/java/com/hotupdater/ReactNativeValueConverters.kt +34 -0
  20. package/android/src/main/java/com/hotupdater/TarArchiveInputStream.kt +214 -375
  21. package/android/src/main/java/com/hotupdater/TarBrArchiveExtractor.kt +119 -0
  22. package/android/src/newarch/HotUpdater.kt +7 -9
  23. package/android/src/newarch/HotUpdaterModule.kt +109 -84
  24. package/android/src/newarch/JavaScriptExceptionHooks.kt +48 -0
  25. package/android/src/newarch/ReactIntegrationManager.kt +6 -32
  26. package/android/src/oldarch/HotUpdater.kt +7 -9
  27. package/android/src/oldarch/HotUpdaterModule.kt +98 -74
  28. package/android/src/oldarch/HotUpdaterSpec.kt +4 -6
  29. package/android/src/oldarch/JavaScriptExceptionHooks.kt +71 -0
  30. package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
  31. package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
  32. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +1032 -1116
  33. package/ios/HotUpdater/Internal/BundleMetadata.swift +61 -54
  34. package/ios/HotUpdater/Internal/FileManagerService.swift +48 -0
  35. package/ios/HotUpdater/Internal/FileUtilities.swift +64 -0
  36. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +0 -1
  37. package/ios/HotUpdater/Internal/HotUpdater.mm +32 -67
  38. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +229 -73
  39. package/ios/HotUpdater/Internal/KeyValueStorageService.swift +71 -0
  40. package/ios/HotUpdater/Internal/NotificationExtension.swift +0 -2
  41. package/ios/HotUpdater/Internal/TarArchiveExtractor.swift +182 -311
  42. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +119 -71
  43. package/ios/HotUpdater/Internal/UpdateFailure.swift +390 -0
  44. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.h +16 -0
  45. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.mm +83 -0
  46. package/ios/HotUpdater/Recovery/HotUpdaterRecoveryHooks.mm +49 -0
  47. package/lib/commonjs/appReady.js +96 -0
  48. package/lib/commonjs/appReady.js.map +1 -0
  49. package/lib/commonjs/checkForUpdate.js +121 -69
  50. package/lib/commonjs/checkForUpdate.js.map +1 -1
  51. package/lib/commonjs/clientPlugin.js +13 -0
  52. package/lib/commonjs/clientPlugin.js.map +1 -0
  53. package/lib/commonjs/error.js +5 -14
  54. package/lib/commonjs/error.js.map +1 -1
  55. package/lib/commonjs/fetchJSON.js +16 -27
  56. package/lib/commonjs/fetchJSON.js.map +1 -1
  57. package/lib/commonjs/fetchUpdateResponse.js +60 -0
  58. package/lib/commonjs/fetchUpdateResponse.js.map +1 -0
  59. package/lib/commonjs/httpClient.js +64 -95
  60. package/lib/commonjs/httpClient.js.map +1 -1
  61. package/lib/commonjs/index.js +355 -324
  62. package/lib/commonjs/index.js.map +1 -1
  63. package/lib/commonjs/init.types.js +6 -0
  64. package/lib/commonjs/init.types.js.map +1 -0
  65. package/lib/commonjs/native.js +77 -63
  66. package/lib/commonjs/native.js.map +1 -1
  67. package/lib/commonjs/pluginHost.js +41 -0
  68. package/lib/commonjs/pluginHost.js.map +1 -0
  69. package/lib/commonjs/releaseCatalogCache.js +36 -87
  70. package/lib/commonjs/releaseCatalogCache.js.map +1 -1
  71. package/lib/commonjs/sdkVersion.js +1 -1
  72. package/lib/commonjs/sdkVersion.js.map +1 -1
  73. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  74. package/lib/commonjs/store.js +3 -10
  75. package/lib/commonjs/store.js.map +1 -1
  76. package/lib/commonjs/updateError.js +145 -0
  77. package/lib/commonjs/updateError.js.map +1 -0
  78. package/lib/commonjs/wrap.js +46 -38
  79. package/lib/commonjs/wrap.js.map +1 -1
  80. package/lib/module/appReady.js +90 -0
  81. package/lib/module/appReady.js.map +1 -0
  82. package/lib/module/checkForUpdate.js +114 -64
  83. package/lib/module/checkForUpdate.js.map +1 -1
  84. package/lib/module/clientPlugin.js +4 -0
  85. package/lib/module/clientPlugin.js.map +1 -0
  86. package/lib/module/error.js +5 -14
  87. package/lib/module/error.js.map +1 -1
  88. package/lib/module/fetchJSON.js +14 -26
  89. package/lib/module/fetchJSON.js.map +1 -1
  90. package/lib/module/fetchUpdateResponse.js +55 -0
  91. package/lib/module/fetchUpdateResponse.js.map +1 -0
  92. package/lib/module/httpClient.js +63 -94
  93. package/lib/module/httpClient.js.map +1 -1
  94. package/lib/module/index.js +335 -327
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/init.types.js +4 -0
  97. package/lib/module/init.types.js.map +1 -0
  98. package/lib/module/native.js +70 -56
  99. package/lib/module/native.js.map +1 -1
  100. package/lib/module/pluginHost.js +36 -0
  101. package/lib/module/pluginHost.js.map +1 -0
  102. package/lib/module/releaseCatalogCache.js +32 -82
  103. package/lib/module/releaseCatalogCache.js.map +1 -1
  104. package/lib/module/sdkVersion.js +1 -1
  105. package/lib/module/sdkVersion.js.map +1 -1
  106. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  107. package/lib/module/store.js +3 -10
  108. package/lib/module/store.js.map +1 -1
  109. package/lib/module/updateError.js +139 -0
  110. package/lib/module/updateError.js.map +1 -0
  111. package/lib/module/wrap.js +47 -38
  112. package/lib/module/wrap.js.map +1 -1
  113. package/lib/typescript/commonjs/appReady.d.ts +30 -0
  114. package/lib/typescript/commonjs/appReady.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/checkForUpdate.d.ts +20 -6
  116. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/clientPlugin.d.ts +2 -0
  118. package/lib/typescript/commonjs/clientPlugin.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/error.d.ts +5 -14
  120. package/lib/typescript/commonjs/error.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/fetchJSON.d.ts +5 -5
  122. package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/fetchUpdateResponse.d.ts +14 -0
  124. package/lib/typescript/commonjs/fetchUpdateResponse.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/httpClient.d.ts +5 -34
  126. package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/index.d.ts +124 -116
  128. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/init.types.d.ts +21 -0
  130. package/lib/typescript/commonjs/init.types.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/native.d.ts +32 -25
  132. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/pluginHost.d.ts +8 -0
  134. package/lib/typescript/commonjs/pluginHost.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/releaseCatalogCache.d.ts +8 -14
  136. package/lib/typescript/commonjs/releaseCatalogCache.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
  138. package/lib/typescript/commonjs/sdkVersion.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +35 -47
  140. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/store.d.ts +1 -3
  142. package/lib/typescript/commonjs/store.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/types.d.ts +1 -1
  144. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/updateError.d.ts +26 -0
  146. package/lib/typescript/commonjs/updateError.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/wrap.d.ts +2 -3
  148. package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/wrap.types.d.ts +13 -41
  150. package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
  151. package/lib/typescript/module/appReady.d.ts +30 -0
  152. package/lib/typescript/module/appReady.d.ts.map +1 -0
  153. package/lib/typescript/module/checkForUpdate.d.ts +20 -6
  154. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  155. package/lib/typescript/module/clientPlugin.d.ts +2 -0
  156. package/lib/typescript/module/clientPlugin.d.ts.map +1 -0
  157. package/lib/typescript/module/error.d.ts +5 -14
  158. package/lib/typescript/module/error.d.ts.map +1 -1
  159. package/lib/typescript/module/fetchJSON.d.ts +5 -5
  160. package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
  161. package/lib/typescript/module/fetchUpdateResponse.d.ts +14 -0
  162. package/lib/typescript/module/fetchUpdateResponse.d.ts.map +1 -0
  163. package/lib/typescript/module/httpClient.d.ts +5 -34
  164. package/lib/typescript/module/httpClient.d.ts.map +1 -1
  165. package/lib/typescript/module/index.d.ts +124 -116
  166. package/lib/typescript/module/index.d.ts.map +1 -1
  167. package/lib/typescript/module/init.types.d.ts +21 -0
  168. package/lib/typescript/module/init.types.d.ts.map +1 -0
  169. package/lib/typescript/module/native.d.ts +32 -25
  170. package/lib/typescript/module/native.d.ts.map +1 -1
  171. package/lib/typescript/module/pluginHost.d.ts +8 -0
  172. package/lib/typescript/module/pluginHost.d.ts.map +1 -0
  173. package/lib/typescript/module/releaseCatalogCache.d.ts +8 -14
  174. package/lib/typescript/module/releaseCatalogCache.d.ts.map +1 -1
  175. package/lib/typescript/module/sdkVersion.d.ts +1 -1
  176. package/lib/typescript/module/sdkVersion.d.ts.map +1 -1
  177. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +35 -47
  178. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  179. package/lib/typescript/module/store.d.ts +1 -3
  180. package/lib/typescript/module/store.d.ts.map +1 -1
  181. package/lib/typescript/module/types.d.ts +1 -1
  182. package/lib/typescript/module/types.d.ts.map +1 -1
  183. package/lib/typescript/module/updateError.d.ts +26 -0
  184. package/lib/typescript/module/updateError.d.ts.map +1 -0
  185. package/lib/typescript/module/wrap.d.ts +2 -3
  186. package/lib/typescript/module/wrap.d.ts.map +1 -1
  187. package/lib/typescript/module/wrap.types.d.ts +13 -41
  188. package/lib/typescript/module/wrap.types.d.ts.map +1 -1
  189. package/package.json +8 -4
  190. package/src/appReady.ts +147 -0
  191. package/src/checkForUpdate.ts +156 -89
  192. package/src/clientPlugin.ts +21 -0
  193. package/src/error.ts +5 -15
  194. package/src/fetchJSON.ts +14 -30
  195. package/src/fetchUpdateResponse.ts +60 -0
  196. package/src/httpClient.ts +89 -160
  197. package/src/index.ts +413 -425
  198. package/src/init.types.ts +24 -0
  199. package/src/native.ts +101 -105
  200. package/src/pluginHost.ts +52 -0
  201. package/src/releaseCatalogCache.ts +43 -172
  202. package/src/sdkVersion.ts +1 -1
  203. package/src/specs/NativeHotUpdater.ts +34 -48
  204. package/src/store.ts +2 -23
  205. package/src/types.ts +1 -1
  206. package/src/updateError.ts +167 -0
  207. package/src/wrap.tsx +60 -43
  208. package/src/wrap.types.ts +18 -46
  209. package/android/src/main/java/com/hotupdater/DecompressService.kt +0 -89
  210. package/android/src/main/java/com/hotupdater/DecompressionStrategy.kt +0 -26
  211. package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +0 -117
  212. package/android/src/main/java/com/hotupdater/TarGzDecompressionStrategy.kt +0 -117
  213. package/android/src/main/java/com/hotupdater/ZipDecompressionStrategy.kt +0 -192
  214. package/android/src/test/java/com/hotupdater/BsdiffPatchTest.kt +0 -46
  215. package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +0 -799
  216. package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +0 -273
  217. package/android/src/test/java/com/hotupdater/NativeConfigUtilsTest.kt +0 -20
  218. package/android/src/test/java/com/hotupdater/OkHttpDownloadServiceTest.kt +0 -111
  219. package/android/src/test/java/com/hotupdater/RelativePathResolverTest.kt +0 -41
  220. package/android/src/test/java/com/hotupdater/ReleaseCatalogCacheServiceTest.kt +0 -118
  221. package/android/src/test/java/com/hotupdater/TarArchiveInputStreamTest.kt +0 -68
  222. package/ios/HotUpdater/Internal/ArchiveExtractionUtilities.swift +0 -178
  223. package/ios/HotUpdater/Internal/DecompressService.swift +0 -112
  224. package/ios/HotUpdater/Internal/DecompressionStrategy.swift +0 -22
  225. package/ios/HotUpdater/Internal/StreamingTarArchiveExtractor.swift +0 -370
  226. package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +0 -39
  227. package/ios/HotUpdater/Internal/TarGzDecompressionStrategy.swift +0 -59
  228. package/ios/HotUpdater/Internal/ZipArchiveExtractor.swift +0 -482
  229. package/ios/HotUpdater/Internal/ZipDecompressionStrategy.swift +0 -56
  230. package/lib/commonjs/catalogCacheNative.spec.js +0 -31
  231. package/lib/commonjs/catalogCacheNative.spec.js.map +0 -1
  232. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +0 -616
  233. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +0 -1
  234. package/lib/commonjs/httpClient.spec.js +0 -102
  235. package/lib/commonjs/httpClient.spec.js.map +0 -1
  236. package/lib/commonjs/index.spec.js +0 -302
  237. package/lib/commonjs/index.spec.js.map +0 -1
  238. package/lib/commonjs/iosInterop.spec.js +0 -18
  239. package/lib/commonjs/iosInterop.spec.js.map +0 -1
  240. package/lib/commonjs/native.spec.js +0 -883
  241. package/lib/commonjs/native.spec.js.map +0 -1
  242. package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js +0 -218
  243. package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +0 -1
  244. package/lib/commonjs/notifyAppReadyInsights.js +0 -133
  245. package/lib/commonjs/notifyAppReadyInsights.js.map +0 -1
  246. package/lib/commonjs/notifyAppReadyInsights.spec.js +0 -246
  247. package/lib/commonjs/notifyAppReadyInsights.spec.js.map +0 -1
  248. package/lib/commonjs/notifyAppReadyInsights.test-utils.js +0 -24
  249. package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +0 -1
  250. package/lib/commonjs/notifyAppReadyInsights.transport.spec.js +0 -117
  251. package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +0 -1
  252. package/lib/commonjs/releaseCatalogCache.spec.js +0 -195
  253. package/lib/commonjs/releaseCatalogCache.spec.js.map +0 -1
  254. package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js +0 -64
  255. package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js.map +0 -1
  256. package/lib/commonjs/store.notification.spec.js +0 -76
  257. package/lib/commonjs/store.notification.spec.js.map +0 -1
  258. package/lib/commonjs/store.spec.js +0 -316
  259. package/lib/commonjs/store.spec.js.map +0 -1
  260. package/lib/commonjs/wrap.spec.js +0 -329
  261. package/lib/commonjs/wrap.spec.js.map +0 -1
  262. package/lib/module/catalogCacheNative.spec.js +0 -31
  263. package/lib/module/catalogCacheNative.spec.js.map +0 -1
  264. package/lib/module/checkForUpdate.releaseCatalog.spec.js +0 -615
  265. package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +0 -1
  266. package/lib/module/httpClient.spec.js +0 -102
  267. package/lib/module/httpClient.spec.js.map +0 -1
  268. package/lib/module/index.spec.js +0 -301
  269. package/lib/module/index.spec.js.map +0 -1
  270. package/lib/module/iosInterop.spec.js +0 -18
  271. package/lib/module/iosInterop.spec.js.map +0 -1
  272. package/lib/module/native.spec.js +0 -882
  273. package/lib/module/native.spec.js.map +0 -1
  274. package/lib/module/notifyAppReadyInsights.boundary.spec.js +0 -217
  275. package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +0 -1
  276. package/lib/module/notifyAppReadyInsights.js +0 -128
  277. package/lib/module/notifyAppReadyInsights.js.map +0 -1
  278. package/lib/module/notifyAppReadyInsights.spec.js +0 -245
  279. package/lib/module/notifyAppReadyInsights.spec.js.map +0 -1
  280. package/lib/module/notifyAppReadyInsights.test-utils.js +0 -18
  281. package/lib/module/notifyAppReadyInsights.test-utils.js.map +0 -1
  282. package/lib/module/notifyAppReadyInsights.transport.spec.js +0 -116
  283. package/lib/module/notifyAppReadyInsights.transport.spec.js.map +0 -1
  284. package/lib/module/releaseCatalogCache.spec.js +0 -195
  285. package/lib/module/releaseCatalogCache.spec.js.map +0 -1
  286. package/lib/module/releaseCatalogCacheNativeContract.spec.js +0 -64
  287. package/lib/module/releaseCatalogCacheNativeContract.spec.js.map +0 -1
  288. package/lib/module/store.notification.spec.js +0 -77
  289. package/lib/module/store.notification.spec.js.map +0 -1
  290. package/lib/module/store.spec.js +0 -315
  291. package/lib/module/store.spec.js.map +0 -1
  292. package/lib/module/wrap.spec.js +0 -330
  293. package/lib/module/wrap.spec.js.map +0 -1
  294. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +0 -13
  295. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +0 -1
  296. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +0 -8
  297. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
  298. package/lib/typescript/module/notifyAppReadyInsights.d.ts +0 -13
  299. package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +0 -1
  300. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +0 -8
  301. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
  302. package/src/catalogCacheNative.spec.ts +0 -63
  303. package/src/checkForUpdate.releaseCatalog.spec.ts +0 -612
  304. package/src/httpClient.spec.ts +0 -132
  305. package/src/index.spec.ts +0 -337
  306. package/src/iosInterop.spec.ts +0 -30
  307. package/src/native.spec.ts +0 -945
  308. package/src/notifyAppReadyInsights.boundary.spec.ts +0 -234
  309. package/src/notifyAppReadyInsights.spec.ts +0 -243
  310. package/src/notifyAppReadyInsights.test-utils.ts +0 -31
  311. package/src/notifyAppReadyInsights.transport.spec.ts +0 -130
  312. package/src/notifyAppReadyInsights.ts +0 -194
  313. package/src/releaseCatalogCache.spec.ts +0 -282
  314. package/src/releaseCatalogCacheNativeContract.spec.ts +0 -80
  315. package/src/store.notification.spec.ts +0 -92
  316. package/src/store.spec.ts +0 -372
  317. package/src/wrap.spec.ts +0 -406
@@ -5,25 +5,48 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  HotUpdater: true,
8
+ defineClientPlugin: true,
9
+ insights: true,
10
+ remoteConfig: true,
8
11
  extractSignatureFailure: true,
9
12
  isSignatureVerificationError: true
10
13
  };
11
14
  exports.HotUpdater = void 0;
15
+ Object.defineProperty(exports, "defineClientPlugin", {
16
+ enumerable: true,
17
+ get: function () {
18
+ return _clientPlugin.defineClientPlugin;
19
+ }
20
+ });
12
21
  Object.defineProperty(exports, "extractSignatureFailure", {
13
22
  enumerable: true,
14
23
  get: function () {
15
24
  return _types.extractSignatureFailure;
16
25
  }
17
26
  });
27
+ Object.defineProperty(exports, "insights", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _client.insights;
31
+ }
32
+ });
18
33
  Object.defineProperty(exports, "isSignatureVerificationError", {
19
34
  enumerable: true,
20
35
  get: function () {
21
36
  return _types.isSignatureVerificationError;
22
37
  }
23
38
  });
39
+ Object.defineProperty(exports, "remoteConfig", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _client2.remoteConfig;
43
+ }
44
+ });
45
+ var _appReady = require("./appReady.js");
24
46
  var _checkForUpdate = require("./checkForUpdate.js");
25
47
  var _httpClient = require("./httpClient.js");
26
48
  var _native = require("./native.js");
49
+ var _pluginHost = require("./pluginHost.js");
27
50
  var _store = require("./store.js");
28
51
  Object.keys(_store).forEach(function (key) {
29
52
  if (key === "default" || key === "__esModule") return;
@@ -37,7 +60,14 @@ Object.keys(_store).forEach(function (key) {
37
60
  });
38
61
  });
39
62
  var _wrap = require("./wrap.js");
63
+ var _clientPlugin = require("./clientPlugin.js");
64
+ var _client = require("@hot-updater/plugin-insights/client");
65
+ var _client2 = require("@hot-updater/plugin-remote-config/client");
40
66
  var _types = require("./types.js");
67
+ // The built-in Insights client plugin, for HotUpdater.init({ plugins }).
68
+
69
+ // The built-in Remote Config client plugin, for HotUpdater.init({ plugins }).
70
+
41
71
  /**
42
72
  * Register getBaseURL to global objects for use without imports.
43
73
  * This is needed for Expo DOM components and Babel plugin generated code.
@@ -55,246 +85,204 @@ const registerGlobalGetBaseURL = () => {
55
85
 
56
86
  // Call registration immediately on module load
57
87
  registerGlobalGetBaseURL();
58
- /**
59
- * Creates a HotUpdater client instance with all update management methods.
60
- * This function is called once on module initialization to create a singleton instance.
61
- */
62
- function createHotUpdaterClient() {
63
- let configurationAPI = null;
64
- let mixedConfigurationReported = false;
88
+ const createMissingNetworkConfigError = () => new Error(`[HotUpdater] baseURL must be provided.\n\n` + `Configure HotUpdater with the standard baseURL setup:\n\n` + ` export const hotUpdater = HotUpdater.init({\n` + ` baseURL: "<your-update-server-url>",\n` + ` });\n\n` + `See https://hot-updater.dev/docs/react-native-api/init`);
65
89
 
66
- // Global configuration stored from wrap
67
- const globalConfig = {
68
- insights: true,
69
- client: null
70
- };
71
- const createMissingNetworkConfigError = apiName => {
72
- if (apiName === "init") {
73
- return new Error(`[HotUpdater] baseURL must be provided.\n\n` + `Configure HotUpdater before calling update APIs with the standard baseURL setup:\n\n` + ` HotUpdater.init({\n` + ` baseURL: "<your-update-server-url>",\n` + ` });\n\n` + `For manual update flows, visit: https://hot-updater.dev/docs/guides/custom-update`);
74
- }
75
- const baseURLExample = ` export default HotUpdater.wrap({\n` + ` baseURL: "<your-update-server-url>",\n` + ` updateStrategy: "appVersion"\n` + ` })(App);\n\n`;
76
- return new Error(`[HotUpdater] baseURL must be provided.\n\n` + `Configure HotUpdater.wrap with the standard baseURL setup:\n\n` + baseURLExample + `For manual update flows, use HotUpdater.init() and visit: ` + `https://hot-updater.dev/docs/guides/custom-update`);
77
- };
78
- const normalizeOptions = options => {
79
- const incoming = options;
80
- if (incoming.updateMode === "manual") {
81
- throw new Error('[HotUpdater] HotUpdater.wrap({ updateMode: "manual" }) was removed. ' + "Call HotUpdater.init({ ... }) instead, export your root component " + "directly, and use HotUpdater.checkForUpdate(...) for the manual " + "update flow. See https://hot-updater.dev/docs/guides/custom-update");
82
- }
83
- const autoOptions = incoming;
84
- if (autoOptions.baseURL) {
85
- const {
86
- baseURL,
87
- ...rest
88
- } = autoOptions;
89
- return {
90
- ...rest,
91
- insights: rest.insights ?? true,
92
- client: (0, _httpClient.createHttpClient)(baseURL)
93
- };
90
+ /** The methods that read or change native state, the same on every instance. */
91
+ const nativeMethods = {
92
+ /**
93
+ * Reloads the app.
94
+ */
95
+ reload: _native.reload,
96
+ /**
97
+ * Configures how `hotUpdater.reload()` behaves.
98
+ *
99
+ * This can be called unconditionally on both platforms.
100
+ * The default is `processRestart`.
101
+ *
102
+ * - `reload`: built-in React Native reload on both platforms
103
+ * - `processRestart`: Android process restart, iOS behaves like normal reload
104
+ * - `custom`: run a custom JS handler on both platforms
105
+ */
106
+ setReloadBehavior: _native.setReloadBehavior,
107
+ /**
108
+ * Returns whether an update has finished downloading in this app session.
109
+ *
110
+ * When it returns true, calling `hotUpdater.reload()` (or restarting the app)
111
+ * will apply the downloaded update bundle.
112
+ *
113
+ * - Derived from `progress` reaching 1.0
114
+ * - Resets to false when a new download starts (progress < 1)
115
+ *
116
+ * @returns {boolean} True if a downloaded update is ready to apply
117
+ * @example
118
+ * ```ts
119
+ * if (hotUpdater.isUpdateDownloaded()) {
120
+ * await hotUpdater.reload();
121
+ * }
122
+ * ```
123
+ */
124
+ isUpdateDownloaded: () => _store.hotUpdaterStore.getSnapshot().isUpdateDownloaded,
125
+ /**
126
+ * Fetches the current app version.
127
+ */
128
+ getAppVersion: _native.getAppVersion,
129
+ /** Reads the active and stable Release/Bundle state. */
130
+ getActiveUpdateState: async () => (0, _native.getPublicActiveUpdateState)(),
131
+ /**
132
+ * Returns the selected update ID, matching the ID shown in the console.
133
+ * A staged update can change this ID before the app reloads.
134
+ */
135
+ getBundleId: _native.getUpdateId,
136
+ /** Returns the minimum bundle ID based on the native app build time. */
137
+ getMinBundleId: _native.getMinBundleId,
138
+ /**
139
+ * Fetches the current manifest for the active bundle.
140
+ */
141
+ getManifest: _native.getManifest,
142
+ /**
143
+ * Fetches the current channel of the app.
144
+ *
145
+ * If no channel is specified, the app is assigned to the 'production' channel.
146
+ *
147
+ * @returns {string} The current release channel of the app
148
+ * @default "production"
149
+ * @example
150
+ * ```ts
151
+ * const channel = hotUpdater.getChannel();
152
+ * console.log(`Current channel: ${channel}`);
153
+ * ```
154
+ */
155
+ getChannel: _native.getChannel,
156
+ /**
157
+ * Fetches the build-time default channel of the app.
158
+ *
159
+ * This value does not change when a runtime channel override is active.
160
+ *
161
+ * @returns {string} The default release channel embedded in the app
162
+ * @example
163
+ * ```ts
164
+ * const defaultChannel = hotUpdater.getDefaultChannel();
165
+ * console.log(`Default channel: ${defaultChannel}`);
166
+ * ```
167
+ */
168
+ getDefaultChannel: _native.getDefaultChannel,
169
+ /**
170
+ * Returns whether the app is currently using a runtime channel override.
171
+ *
172
+ * @returns {boolean} true when a non-default channel has been applied
173
+ */
174
+ isChannelSwitched: _native.isChannelSwitched,
175
+ /**
176
+ * Sets the persisted cohort used for rollout calculations.
177
+ * Call `getCohort()` first if you need to restore the initial value later.
178
+ */
179
+ setCohort: _native.setCohort,
180
+ /**
181
+ * Gets the persisted cohort used for rollout calculations.
182
+ */
183
+ getCohort: _native.getCohort,
184
+ /**
185
+ * Adds a listener to HotUpdater events.
186
+ *
187
+ * @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
188
+ * @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
189
+ * @returns {() => void} A cleanup function that removes the event listener
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * const unsubscribe = hotUpdater.addListener("onProgress", ({ progress }) => {
194
+ * console.log(`Update progress: ${progress * 100}%`);
195
+ * });
196
+ *
197
+ * // Unsubscribe when no longer needed
198
+ * unsubscribe();
199
+ * ```
200
+ */
201
+ addListener: _native.addListener,
202
+ /**
203
+ * Clears the runtime channel override and restores the original bundle.
204
+ *
205
+ * @returns {Promise<boolean>} Resolves with true if reset was successful
206
+ */
207
+ resetChannel: async () => {
208
+ const ok = await (0, _native.resetChannel)();
209
+ if (ok) {
210
+ _store.hotUpdaterStore.setState({
211
+ artifactType: null,
212
+ details: null,
213
+ isUpdateDownloaded: false,
214
+ progress: 0
215
+ });
94
216
  }
95
- throw createMissingNetworkConfigError("wrap");
96
- };
97
- const normalizeInitOptions = options => {
98
- const {
99
- updateMode: _updateMode,
100
- ...rest
101
- } = options;
102
- if (rest.baseURL) {
103
- const {
104
- baseURL,
105
- ...baseURLRest
106
- } = rest;
107
- return {
108
- ...baseURLRest,
109
- insights: baseURLRest.insights ?? true,
110
- client: (0, _httpClient.createHttpClient)(baseURL)
111
- };
112
- }
113
- throw createMissingNetworkConfigError("init");
114
- };
115
- const configureGlobal = (normalizedOptions, options) => {
116
- globalConfig.insights = normalizedOptions.insights ?? true;
117
- globalConfig.client = normalizedOptions.client;
118
- globalConfig.requestHeaders = options.requestHeaders;
119
- globalConfig.requestTimeout = options.requestTimeout;
120
- globalConfig.onError = options.onError;
121
- };
122
- const reportMixedConfiguration = nextAPI => {
123
- if (configurationAPI !== null && configurationAPI !== nextAPI && !mixedConfigurationReported) {
124
- mixedConfigurationReported = true;
125
- console.error("[HotUpdater] HotUpdater.init() and HotUpdater.wrap() must not be used together. " + "For custom or manual update flows, use HotUpdater.init() with " + "HotUpdater.checkForUpdate(). For the automatic HOC flow, use " + "HotUpdater.wrap().");
126
- }
127
- configurationAPI ??= nextAPI;
128
- };
129
- const ensureGlobalClient = methodName => {
130
- if (!globalConfig.client) {
131
- throw new Error(`[HotUpdater] ${methodName} requires HotUpdater.wrap() or HotUpdater.init() to be used.\n\n` + `To fix this issue, configure HotUpdater before calling ${methodName}:\n\n` + `Option 1: With HotUpdater.wrap()\n` + ` export default HotUpdater.wrap({\n` + ` baseURL: "<your-update-server-url>",\n` + ` updateStrategy: "appVersion"\n` + ` })(App);\n\n` + `Option 2: With HotUpdater.init() for custom runtimes\n` + ` HotUpdater.init({\n` + ` baseURL: "<your-update-server-url>",\n` + ` });\n\n` + `For manual update flows, visit: https://hot-updater.dev/docs/guides/custom-update`);
132
- }
133
- return globalConfig.client;
134
- };
135
- return {
136
- /**
137
- * `HotUpdater.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
138
- *
139
- * @param {object} options - Configuration options
140
- * @param {string} options.source - Update server URL
141
- * @param {object} [options.requestHeaders] - Request headers
142
- * @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
143
- * @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
144
- * @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
145
- * @param {Function} [options.onProgress] - Callback to track bundle download progress
146
- * @returns {Function} Higher-order component that wraps the app component
147
- *
148
- * @example
149
- * ```tsx
150
- * export default HotUpdater.wrap({
151
- * baseURL: "<your-update-server-url>",
152
- * updateStrategy: "appVersion",
153
- * requestHeaders: {
154
- * "x-api-key": "<your-api-key>",
155
- * },
156
- * })(App);
157
- * ```
158
- */
159
- wrap: options => {
160
- const normalizedOptions = normalizeOptions(options);
161
- reportMixedConfiguration("wrap");
162
- configureGlobal(normalizedOptions, options);
163
- return (0, _wrap.wrap)(normalizedOptions);
164
- },
165
- /**
166
- * Initializes HotUpdater without wrapping a React component.
167
- *
168
- * Use this for manual update flows in runtimes where a root component HOC
169
- * is not convenient. Use this instead of wrapping the root component.
170
- *
171
- * @example
172
- * ```tsx
173
- * HotUpdater.init({
174
- * baseURL: "<your-update-server-url>",
175
- * });
176
- *
177
- * export default App;
178
- * ```
179
- */
180
- init: options => {
181
- const normalizedOptions = normalizeInitOptions(options);
182
- reportMixedConfiguration("init");
183
- configureGlobal(normalizedOptions, options);
184
- (0, _wrap.init)(normalizedOptions);
217
+ return ok;
218
+ },
219
+ /**
220
+ * Fetches the fingerprint of the app.
221
+ *
222
+ * @returns {string} The fingerprint of the app
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * const fingerprint = hotUpdater.getFingerprintHash();
227
+ * console.log(`Fingerprint: ${fingerprint}`);
228
+ * ```
229
+ */
230
+ getFingerprintHash: _native.getFingerprintHash,
231
+ /**
232
+ * Fetches the persisted install id for this app installation.
233
+ */
234
+ getInstallId: _native.getInstallId,
235
+ /**
236
+ * Reads the native launch report for the current process.
237
+ */
238
+ notifyAppReady: _native.notifyAppReady,
239
+ /**
240
+ * Gets the list of bundle IDs that have been marked as crashed.
241
+ * These bundles will be rejected if attempted to install again.
242
+ *
243
+ * @returns {string[]} Array of crashed bundle IDs
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * const crashedBundles = hotUpdater.getCrashHistory();
248
+ * console.log("Crashed bundles:", crashedBundles);
249
+ * ```
250
+ */
251
+ getCrashHistory: _native.getCrashHistory,
252
+ /**
253
+ * Clears the crashed bundle history, allowing previously crashed bundles
254
+ * to be installed again.
255
+ *
256
+ * @returns {boolean} true if clearing was successful
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * // Clear crash history to allow retrying a previously failed bundle
261
+ * hotUpdater.clearCrashHistory();
262
+ * ```
263
+ */
264
+ clearCrashHistory: _native.clearCrashHistory
265
+ };
266
+
267
+ /** What an instance's own methods use: its server, settings, and launch. */
268
+
269
+ /** The methods that use the instance's own configuration and plugins. */
270
+ const createConfiguredMethods = config => {
271
+ const check = options => (0, _checkForUpdate.checkForUpdate)({
272
+ ...options,
273
+ client: config.client,
274
+ emit: config.launch.emit,
275
+ requestHeaders: {
276
+ ...config.requestHeaders,
277
+ ...options.requestHeaders
185
278
  },
279
+ requestTimeout: options.requestTimeout ?? config.requestTimeout,
280
+ onError: options.onError ?? config.onError
281
+ });
282
+ return {
186
283
  /**
187
- * Reloads the app.
188
- */
189
- reload: _native.reload,
190
- /**
191
- * Configures how `HotUpdater.reload()` behaves.
192
- *
193
- * This can be called unconditionally on both platforms.
194
- * The default is `processRestart`.
195
- *
196
- * - `reload`: built-in React Native reload on both platforms
197
- * - `processRestart`: Android process restart, iOS behaves like normal reload
198
- * - `custom`: run a custom JS handler on both platforms
199
- */
200
- setReloadBehavior: _native.setReloadBehavior,
201
- /**
202
- * Returns whether an update has finished downloading in this app session.
203
- *
204
- * When it returns true, calling `HotUpdater.reload()` (or restarting the app)
205
- * will apply the downloaded update bundle.
206
- *
207
- * - Derived from `progress` reaching 1.0
208
- * - Resets to false when a new download starts (progress < 1)
209
- *
210
- * @returns {boolean} True if a downloaded update is ready to apply
211
- * @example
212
- * ```ts
213
- * if (HotUpdater.isUpdateDownloaded()) {
214
- * await HotUpdater.reload();
215
- * }
216
- * ```
217
- */
218
- isUpdateDownloaded: () => _store.hotUpdaterStore.getSnapshot().isUpdateDownloaded,
219
- /**
220
- * Fetches the current app version.
221
- */
222
- getAppVersion: _native.getAppVersion,
223
- /** Reads the active and stable Release/Bundle state. */
224
- getActiveUpdateState: async () => (0, _native.getPublicActiveUpdateState)(),
225
- /**
226
- * Returns the selected update ID, matching the ID shown in the console.
227
- * A staged update can change this ID before the app reloads.
228
- */
229
- getBundleId: _native.getUpdateId,
230
- /** Returns the minimum bundle ID based on the native app build time. */
231
- getMinBundleId: _native.getMinBundleId,
232
- /**
233
- * Fetches the current manifest for the active bundle.
234
- */
235
- getManifest: _native.getManifest,
236
- /**
237
- * Fetches the current channel of the app.
238
- *
239
- * If no channel is specified, the app is assigned to the 'production' channel.
240
- *
241
- * @returns {string} The current release channel of the app
242
- * @default "production"
243
- * @example
244
- * ```ts
245
- * const channel = HotUpdater.getChannel();
246
- * console.log(`Current channel: ${channel}`);
247
- * ```
248
- */
249
- getChannel: _native.getChannel,
250
- /**
251
- * Fetches the build-time default channel of the app.
252
- *
253
- * This value does not change when a runtime channel override is active.
254
- *
255
- * @returns {string} The default release channel embedded in the app
256
- * @example
257
- * ```ts
258
- * const defaultChannel = HotUpdater.getDefaultChannel();
259
- * console.log(`Default channel: ${defaultChannel}`);
260
- * ```
261
- */
262
- getDefaultChannel: _native.getDefaultChannel,
263
- /**
264
- * Returns whether the app is currently using a runtime channel override.
265
- *
266
- * @returns {boolean} true when a non-default channel has been applied
267
- */
268
- isChannelSwitched: _native.isChannelSwitched,
269
- /**
270
- * Sets the persisted cohort used for rollout calculations.
271
- * Call `getCohort()` first if you need to restore the initial value later.
272
- */
273
- setCohort: _native.setCohort,
274
- /**
275
- * Gets the persisted cohort used for rollout calculations.
276
- */
277
- getCohort: _native.getCohort,
278
- /**
279
- * Adds a listener to HotUpdater events.
280
- *
281
- * @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
282
- * @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
283
- * @returns {() => void} A cleanup function that removes the event listener
284
- *
285
- * @example
286
- * ```ts
287
- * const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
288
- * console.log(`Update progress: ${progress * 100}%`);
289
- * });
290
- *
291
- * // Unsubscribe when no longer needed
292
- * unsubscribe();
293
- * ```
294
- */
295
- addListener: _native.addListener,
296
- /**
297
- * Manually checks for updates.
284
+ * Checks for an update, with this instance's server and request
285
+ * settings.
298
286
  *
299
287
  * @param {Object} config - Update check configuration
300
288
  * @param {string} [config.channel] - Optional channel override for this update check
@@ -304,7 +292,7 @@ function createHotUpdaterClient() {
304
292
  *
305
293
  * @example
306
294
  * ```ts
307
- * const updateInfo = await HotUpdater.checkForUpdate({
295
+ * const updateInfo = await hotUpdater.checkForUpdate({
308
296
  * updateStrategy: "appVersion",
309
297
  * requestHeaders: {
310
298
  * "x-api-key": "<your-api-key>",
@@ -318,37 +306,21 @@ function createHotUpdaterClient() {
318
306
  *
319
307
  * await updateInfo.updateBundle();
320
308
  * if (updateInfo.shouldForceUpdate) {
321
- * await HotUpdater.reload();
309
+ * await hotUpdater.reload();
322
310
  * }
323
311
  * ```
324
312
  */
325
- checkForUpdate: config => {
326
- const client = ensureGlobalClient("checkForUpdate");
327
- const mergedConfig = {
328
- ...config,
329
- insights: globalConfig.insights,
330
- client,
331
- requestHeaders: {
332
- ...globalConfig.requestHeaders,
333
- ...config.requestHeaders
334
- },
335
- requestTimeout: config.requestTimeout ?? globalConfig.requestTimeout,
336
- onError: config.onError ?? globalConfig.onError
337
- };
338
- return (0, _checkForUpdate.checkForUpdate)(mergedConfig);
339
- },
313
+ checkForUpdate: check,
340
314
  /**
341
315
  * Updates the bundle of the app.
342
316
  *
343
317
  * @param {UpdateBundleParams} params - Parameters object required for bundle update
344
318
  * @param {string} params.bundleId - The bundle ID of the app
345
- * @param {string|null} params.fileUrl - The URL of the zip file
346
- *
347
319
  * @returns {Promise<boolean>} Whether the update was successful
348
320
  *
349
321
  * @example
350
322
  * ```ts
351
- * const updateInfo = await HotUpdater.checkForUpdate({
323
+ * const updateInfo = await hotUpdater.checkForUpdate({
352
324
  * updateStrategy: "appVersion",
353
325
  * requestHeaders: {
354
326
  * "x-api-key": "<your-api-key>",
@@ -363,84 +335,143 @@ function createHotUpdaterClient() {
363
335
  *
364
336
  * await updateInfo.updateBundle();
365
337
  * if (updateInfo.shouldForceUpdate) {
366
- * await HotUpdater.reload();
338
+ * await hotUpdater.reload();
367
339
  * }
368
340
  * ```
369
341
  */
370
- updateBundle: params => {
371
- ensureGlobalClient("updateBundle");
372
- return (0, _native.updateBundle)(params);
373
- },
374
- /**
375
- * Clears the runtime channel override and restores the original bundle.
376
- *
377
- * @returns {Promise<boolean>} Resolves with true if reset was successful
378
- */
379
- resetChannel: async () => {
380
- const ok = await (0, _native.resetChannel)();
381
- if (ok) {
382
- _store.hotUpdaterStore.setState({
383
- artifactType: null,
384
- details: null,
385
- downloadedBytes: undefined,
386
- isUpdateDownloaded: false,
387
- progress: 0,
388
- totalBytes: undefined
342
+ updateBundle: async params => {
343
+ const fromBundleId = (0, _native.getBundleId)();
344
+ const state = (0, _native.getActiveUpdateState)();
345
+ const active = state.activeSelection;
346
+ const fromReleaseId = active?.bundleId === fromBundleId ? active.releaseId : state.stableSelection?.bundleId === fromBundleId ? state.stableSelection.releaseId : null;
347
+ const channel = params.channel ?? (0, _native.getChannel)();
348
+ const strategyOf = scopeKey => scopeKey?.startsWith("v1:fingerprint:") ? "fingerprint" : "appVersion";
349
+ let delivery;
350
+ try {
351
+ delivery = await (0, _native.stageBundle)(params);
352
+ } catch (error) {
353
+ (0, _checkForUpdate.reportUpdateError)(config.launch.emit, error, "download", undefined, {
354
+ bundleId: fromBundleId,
355
+ channel,
356
+ targetBundleId: params.bundleId,
357
+ targetReleaseId: params.selection?.releaseId ?? null,
358
+ updateStrategy: strategyOf(params.selection?.scopeKey)
359
+ });
360
+ throw error;
361
+ }
362
+ if (delivery !== null && params.bundleId !== fromBundleId) {
363
+ config.launch.emit("onBundleDownloaded", () => {
364
+ const selection = (0, _native.getActiveUpdateState)().activeSelection;
365
+ return {
366
+ channel,
367
+ fromBundleId,
368
+ fromReleaseId,
369
+ toBundleId: params.bundleId,
370
+ toReleaseId: selection?.releaseId ?? null,
371
+ updateStrategy: strategyOf(selection?.scopeKey),
372
+ ...delivery
373
+ };
389
374
  });
390
375
  }
391
- return ok;
376
+ return true;
392
377
  },
393
378
  /**
394
- * Fetches the fingerprint of the app.
395
- *
396
- * @returns {string} The fingerprint of the app
397
- *
398
- * @example
399
- * ```ts
400
- * const fingerprint = HotUpdater.getFingerprintHash();
401
- * console.log(`Fingerprint: ${fingerprint}`);
402
- * ```
403
- */
404
- getFingerprintHash: _native.getFingerprintHash,
405
- /**
406
- * Fetches the persisted install id for this app installation.
407
- */
408
- getInstallId: _native.getInstallId,
409
- /**
410
- * Persists nullable user identity fields associated with this installation.
411
- */
412
- setUser: _native.setUser,
413
- /**
414
- * Reads the native launch report for the current process.
415
- */
416
- notifyAppReady: _native.notifyAppReady,
417
- /**
418
- * Gets the list of bundle IDs that have been marked as crashed.
419
- * These bundles will be rejected if attempted to install again.
420
- *
421
- * @returns {string[]} Array of crashed bundle IDs
422
- *
423
- * @example
424
- * ```ts
425
- * const crashedBundles = HotUpdater.getCrashHistory();
426
- * console.log("Crashed bundles:", crashedBundles);
427
- * ```
428
- */
429
- getCrashHistory: _native.getCrashHistory,
430
- /**
431
- * Clears the crashed bundle history, allowing previously crashed bundles
432
- * to be installed again.
433
- *
434
- * @returns {boolean} true if clearing was successful
379
+ * Wraps the app's root: when it mounts, it checks for an update with
380
+ * this instance's configuration, downloads one, and reloads for a
381
+ * forced update. A `fallbackComponent` replaces the root until the
382
+ * check and a forced update finish.
435
383
  *
436
384
  * @example
437
- * ```ts
438
- * // Clear crash history to allow retrying a previously failed bundle
439
- * HotUpdater.clearCrashHistory();
385
+ * ```tsx
386
+ * export default hotUpdater.wrap({
387
+ * updateStrategy: "appVersion",
388
+ * fallbackComponent: ({ progress }) => <Splash progress={progress} />,
389
+ * })(App);
440
390
  * ```
441
391
  */
442
- clearCrashHistory: _native.clearCrashHistory
392
+ wrap: options => (0, _wrap.wrap)({
393
+ ...options,
394
+ checkForUpdate: check,
395
+ appReady: () => config.launch.appReady,
396
+ onError: error => config.onError?.(error)
397
+ })
443
398
  };
444
- }
445
- const HotUpdater = exports.HotUpdater = createHotUpdaterClient();
399
+ };
400
+
401
+ /** The methods of every instance `HotUpdater.init` returns. */
402
+
403
+ /**
404
+ * The instance `HotUpdater.init` returns: HotUpdater's methods, and each
405
+ * plugin's API under the plugin's id.
406
+ */
407
+
408
+ const HotUpdater = exports.HotUpdater = {
409
+ /**
410
+ * Creates the app's HotUpdater instance: the update server, its request
411
+ * settings, and the client plugins. Each call returns an independent
412
+ * instance with its own configuration and plugins, so create one, at the
413
+ * top level of a module, and export it.
414
+ *
415
+ * The instance has every HotUpdater method, such as `wrap`,
416
+ * `checkForUpdate`, and `reload`, and each plugin's API under the
417
+ * plugin's id, such as `hotUpdater.remoteConfig` for `remoteConfig()`.
418
+ *
419
+ * @example
420
+ * ```tsx
421
+ * export const hotUpdater = HotUpdater.init({
422
+ * baseURL: "<your-update-server-url>",
423
+ * plugins: [remoteConfig({ defaults: { welcome_message: "Hi" } })],
424
+ * });
425
+ *
426
+ * hotUpdater.remoteConfig.getString("welcome_message");
427
+ * ```
428
+ */
429
+ init: options => {
430
+ const {
431
+ baseURL,
432
+ plugins,
433
+ requestHeaders,
434
+ requestTimeout,
435
+ onError,
436
+ onNotifyAppReady
437
+ } = options;
438
+ if (!baseURL) throw createMissingNetworkConfigError();
439
+ const host = (0, _pluginHost.createAppPluginHost)();
440
+ const launch = (0, _appReady.createLaunchReporter)(host);
441
+ const instance = {
442
+ ...nativeMethods,
443
+ ...createConfiguredMethods({
444
+ client: (0, _httpClient.createHttpClient)(baseURL, response => {
445
+ launch.emit("onHttpResponse", () => response);
446
+ }),
447
+ requestHeaders,
448
+ requestTimeout,
449
+ onError,
450
+ launch
451
+ })
452
+ };
453
+ const reservedIds = new Set([...Object.keys(instance), "init"]);
454
+ for (const plugin of plugins ?? []) {
455
+ if (reservedIds.has(plugin.id)) {
456
+ throw new Error(`[HotUpdater] A plugin cannot use the id "${plugin.id}": the HotUpdater instance has its own "${plugin.id}".`);
457
+ }
458
+ }
459
+
460
+ // Plugins are set up before the instance reads the launch they observe.
461
+ const apis = host.configurePlugins(plugins, {
462
+ baseURL,
463
+ requestHeaders,
464
+ requestTimeout,
465
+ onError
466
+ });
467
+ void launch.read({
468
+ onNotifyAppReady,
469
+ onError
470
+ });
471
+ return Object.freeze({
472
+ ...instance,
473
+ ...apis
474
+ });
475
+ }
476
+ };
446
477
  //# sourceMappingURL=index.js.map