@hot-updater/react-native 1.0.0-rc.3 → 1.0.0-rc.30

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 (300) hide show
  1. package/android/proguard-rules.pro +17 -2
  2. package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
  3. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +954 -837
  4. package/android/src/main/java/com/hotupdater/BundleMetadata.kt +15 -11
  5. package/android/src/main/java/com/hotupdater/FileManagerService.kt +45 -0
  6. package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +287 -22
  7. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +43 -31
  8. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +37 -54
  9. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryState.kt +64 -0
  10. package/android/src/main/java/com/hotupdater/InstallIdentityService.kt +37 -0
  11. package/android/src/main/java/com/hotupdater/KeyValueStorageService.kt +86 -0
  12. package/android/src/main/java/com/hotupdater/NetworkState.kt +31 -0
  13. package/android/src/main/java/com/hotupdater/NoBackupStorage.kt +17 -0
  14. package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +127 -50
  15. package/android/src/main/java/com/hotupdater/PreviousProcessExit.kt +89 -0
  16. package/android/src/main/java/com/hotupdater/ReactNativeValueConverters.kt +34 -0
  17. package/android/src/main/java/com/hotupdater/TarArchiveInputStream.kt +214 -375
  18. package/android/src/main/java/com/hotupdater/TarBrArchiveExtractor.kt +119 -0
  19. package/android/src/newarch/HotUpdater.kt +7 -9
  20. package/android/src/newarch/HotUpdaterModule.kt +109 -84
  21. package/android/src/oldarch/HotUpdater.kt +7 -9
  22. package/android/src/oldarch/HotUpdaterModule.kt +98 -74
  23. package/android/src/oldarch/HotUpdaterSpec.kt +4 -6
  24. package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
  25. package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
  26. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +950 -1112
  27. package/ios/HotUpdater/Internal/BundleMetadata.swift +8 -53
  28. package/ios/HotUpdater/Internal/FileManagerService.swift +48 -0
  29. package/ios/HotUpdater/Internal/FileUtilities.swift +64 -0
  30. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +0 -1
  31. package/ios/HotUpdater/Internal/HotUpdater.mm +13 -45
  32. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +190 -73
  33. package/ios/HotUpdater/Internal/KeyValueStorageService.swift +71 -0
  34. package/ios/HotUpdater/Internal/NotificationExtension.swift +0 -2
  35. package/ios/HotUpdater/Internal/TarArchiveExtractor.swift +182 -311
  36. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +119 -71
  37. package/ios/HotUpdater/Internal/UpdateFailure.swift +390 -0
  38. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.h +16 -0
  39. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.mm +83 -0
  40. package/ios/HotUpdater/Recovery/HotUpdaterRecoveryHooks.mm +49 -0
  41. package/lib/commonjs/appReady.js +111 -0
  42. package/lib/commonjs/appReady.js.map +1 -0
  43. package/lib/commonjs/checkForUpdate.js +124 -69
  44. package/lib/commonjs/checkForUpdate.js.map +1 -1
  45. package/lib/commonjs/clientPlugin.js +13 -0
  46. package/lib/commonjs/clientPlugin.js.map +1 -0
  47. package/lib/commonjs/error.js +4 -13
  48. package/lib/commonjs/error.js.map +1 -1
  49. package/lib/commonjs/fetchJSON.js +16 -27
  50. package/lib/commonjs/fetchJSON.js.map +1 -1
  51. package/lib/commonjs/fetchUpdateResponse.js +54 -0
  52. package/lib/commonjs/fetchUpdateResponse.js.map +1 -0
  53. package/lib/commonjs/httpClient.js +63 -94
  54. package/lib/commonjs/httpClient.js.map +1 -1
  55. package/lib/commonjs/index.js +71 -18
  56. package/lib/commonjs/index.js.map +1 -1
  57. package/lib/commonjs/native.js +78 -60
  58. package/lib/commonjs/native.js.map +1 -1
  59. package/lib/commonjs/pluginHost.js +44 -0
  60. package/lib/commonjs/pluginHost.js.map +1 -0
  61. package/lib/commonjs/releaseCatalogCache.js +36 -87
  62. package/lib/commonjs/releaseCatalogCache.js.map +1 -1
  63. package/lib/commonjs/sdkVersion.js +1 -1
  64. package/lib/commonjs/sdkVersion.js.map +1 -1
  65. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  66. package/lib/commonjs/store.js +3 -10
  67. package/lib/commonjs/store.js.map +1 -1
  68. package/lib/commonjs/updateError.js +132 -0
  69. package/lib/commonjs/updateError.js.map +1 -0
  70. package/lib/commonjs/wrap.js +43 -26
  71. package/lib/commonjs/wrap.js.map +1 -1
  72. package/lib/module/appReady.js +103 -0
  73. package/lib/module/appReady.js.map +1 -0
  74. package/lib/module/checkForUpdate.js +117 -64
  75. package/lib/module/checkForUpdate.js.map +1 -1
  76. package/lib/module/clientPlugin.js +4 -0
  77. package/lib/module/clientPlugin.js.map +1 -0
  78. package/lib/module/error.js +4 -13
  79. package/lib/module/error.js.map +1 -1
  80. package/lib/module/fetchJSON.js +14 -26
  81. package/lib/module/fetchJSON.js.map +1 -1
  82. package/lib/module/fetchUpdateResponse.js +49 -0
  83. package/lib/module/fetchUpdateResponse.js.map +1 -0
  84. package/lib/module/httpClient.js +62 -93
  85. package/lib/module/httpClient.js.map +1 -1
  86. package/lib/module/index.js +58 -20
  87. package/lib/module/index.js.map +1 -1
  88. package/lib/module/native.js +71 -53
  89. package/lib/module/native.js.map +1 -1
  90. package/lib/module/pluginHost.js +35 -0
  91. package/lib/module/pluginHost.js.map +1 -0
  92. package/lib/module/releaseCatalogCache.js +32 -82
  93. package/lib/module/releaseCatalogCache.js.map +1 -1
  94. package/lib/module/sdkVersion.js +1 -1
  95. package/lib/module/sdkVersion.js.map +1 -1
  96. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  97. package/lib/module/store.js +3 -10
  98. package/lib/module/store.js.map +1 -1
  99. package/lib/module/updateError.js +126 -0
  100. package/lib/module/updateError.js.map +1 -0
  101. package/lib/module/wrap.js +43 -26
  102. package/lib/module/wrap.js.map +1 -1
  103. package/lib/typescript/commonjs/appReady.d.ts +23 -0
  104. package/lib/typescript/commonjs/appReady.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/checkForUpdate.d.ts +16 -4
  106. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/clientPlugin.d.ts +2 -0
  108. package/lib/typescript/commonjs/clientPlugin.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/error.d.ts +4 -13
  110. package/lib/typescript/commonjs/error.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/fetchJSON.d.ts +5 -5
  112. package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/fetchUpdateResponse.d.ts +14 -0
  114. package/lib/typescript/commonjs/fetchUpdateResponse.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/httpClient.d.ts +4 -33
  116. package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/index.d.ts +4 -8
  118. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/native.d.ts +31 -22
  120. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/pluginHost.d.ts +4 -0
  122. package/lib/typescript/commonjs/pluginHost.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/releaseCatalogCache.d.ts +8 -14
  124. package/lib/typescript/commonjs/releaseCatalogCache.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
  126. package/lib/typescript/commonjs/sdkVersion.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +42 -47
  128. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/store.d.ts +1 -3
  130. package/lib/typescript/commonjs/store.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/types.d.ts +1 -1
  132. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/updateError.d.ts +26 -0
  134. package/lib/typescript/commonjs/updateError.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/wrap.types.d.ts +6 -7
  137. package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
  138. package/lib/typescript/module/appReady.d.ts +23 -0
  139. package/lib/typescript/module/appReady.d.ts.map +1 -0
  140. package/lib/typescript/module/checkForUpdate.d.ts +16 -4
  141. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  142. package/lib/typescript/module/clientPlugin.d.ts +2 -0
  143. package/lib/typescript/module/clientPlugin.d.ts.map +1 -0
  144. package/lib/typescript/module/error.d.ts +4 -13
  145. package/lib/typescript/module/error.d.ts.map +1 -1
  146. package/lib/typescript/module/fetchJSON.d.ts +5 -5
  147. package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
  148. package/lib/typescript/module/fetchUpdateResponse.d.ts +14 -0
  149. package/lib/typescript/module/fetchUpdateResponse.d.ts.map +1 -0
  150. package/lib/typescript/module/httpClient.d.ts +4 -33
  151. package/lib/typescript/module/httpClient.d.ts.map +1 -1
  152. package/lib/typescript/module/index.d.ts +4 -8
  153. package/lib/typescript/module/index.d.ts.map +1 -1
  154. package/lib/typescript/module/native.d.ts +31 -22
  155. package/lib/typescript/module/native.d.ts.map +1 -1
  156. package/lib/typescript/module/pluginHost.d.ts +4 -0
  157. package/lib/typescript/module/pluginHost.d.ts.map +1 -0
  158. package/lib/typescript/module/releaseCatalogCache.d.ts +8 -14
  159. package/lib/typescript/module/releaseCatalogCache.d.ts.map +1 -1
  160. package/lib/typescript/module/sdkVersion.d.ts +1 -1
  161. package/lib/typescript/module/sdkVersion.d.ts.map +1 -1
  162. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +42 -47
  163. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  164. package/lib/typescript/module/store.d.ts +1 -3
  165. package/lib/typescript/module/store.d.ts.map +1 -1
  166. package/lib/typescript/module/types.d.ts +1 -1
  167. package/lib/typescript/module/types.d.ts.map +1 -1
  168. package/lib/typescript/module/updateError.d.ts +26 -0
  169. package/lib/typescript/module/updateError.d.ts.map +1 -0
  170. package/lib/typescript/module/wrap.d.ts.map +1 -1
  171. package/lib/typescript/module/wrap.types.d.ts +6 -7
  172. package/lib/typescript/module/wrap.types.d.ts.map +1 -1
  173. package/package.json +7 -4
  174. package/src/appReady.ts +149 -0
  175. package/src/checkForUpdate.ts +151 -88
  176. package/src/clientPlugin.ts +18 -0
  177. package/src/error.ts +4 -14
  178. package/src/fetchJSON.ts +14 -30
  179. package/src/fetchUpdateResponse.ts +54 -0
  180. package/src/httpClient.ts +88 -159
  181. package/src/index.ts +90 -24
  182. package/src/native.ts +106 -102
  183. package/src/pluginHost.ts +45 -0
  184. package/src/releaseCatalogCache.ts +43 -172
  185. package/src/sdkVersion.ts +1 -1
  186. package/src/specs/NativeHotUpdater.ts +41 -48
  187. package/src/store.ts +2 -23
  188. package/src/types.ts +1 -1
  189. package/src/updateError.ts +153 -0
  190. package/src/wrap.tsx +57 -26
  191. package/src/wrap.types.ts +6 -7
  192. package/android/src/main/java/com/hotupdater/DecompressService.kt +0 -89
  193. package/android/src/main/java/com/hotupdater/DecompressionStrategy.kt +0 -26
  194. package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +0 -117
  195. package/android/src/main/java/com/hotupdater/TarGzDecompressionStrategy.kt +0 -117
  196. package/android/src/main/java/com/hotupdater/ZipDecompressionStrategy.kt +0 -192
  197. package/android/src/test/java/com/hotupdater/BsdiffPatchTest.kt +0 -46
  198. package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +0 -799
  199. package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +0 -273
  200. package/android/src/test/java/com/hotupdater/NativeConfigUtilsTest.kt +0 -20
  201. package/android/src/test/java/com/hotupdater/OkHttpDownloadServiceTest.kt +0 -111
  202. package/android/src/test/java/com/hotupdater/RelativePathResolverTest.kt +0 -41
  203. package/android/src/test/java/com/hotupdater/ReleaseCatalogCacheServiceTest.kt +0 -118
  204. package/android/src/test/java/com/hotupdater/TarArchiveInputStreamTest.kt +0 -68
  205. package/ios/HotUpdater/Internal/ArchiveExtractionUtilities.swift +0 -178
  206. package/ios/HotUpdater/Internal/DecompressService.swift +0 -112
  207. package/ios/HotUpdater/Internal/DecompressionStrategy.swift +0 -22
  208. package/ios/HotUpdater/Internal/StreamingTarArchiveExtractor.swift +0 -370
  209. package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +0 -39
  210. package/ios/HotUpdater/Internal/TarGzDecompressionStrategy.swift +0 -59
  211. package/ios/HotUpdater/Internal/ZipArchiveExtractor.swift +0 -482
  212. package/ios/HotUpdater/Internal/ZipDecompressionStrategy.swift +0 -56
  213. package/lib/commonjs/catalogCacheNative.spec.js +0 -31
  214. package/lib/commonjs/catalogCacheNative.spec.js.map +0 -1
  215. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +0 -615
  216. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +0 -1
  217. package/lib/commonjs/httpClient.spec.js +0 -102
  218. package/lib/commonjs/httpClient.spec.js.map +0 -1
  219. package/lib/commonjs/index.spec.js +0 -302
  220. package/lib/commonjs/index.spec.js.map +0 -1
  221. package/lib/commonjs/iosInterop.spec.js +0 -18
  222. package/lib/commonjs/iosInterop.spec.js.map +0 -1
  223. package/lib/commonjs/native.spec.js +0 -883
  224. package/lib/commonjs/native.spec.js.map +0 -1
  225. package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js +0 -218
  226. package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +0 -1
  227. package/lib/commonjs/notifyAppReadyInsights.js +0 -133
  228. package/lib/commonjs/notifyAppReadyInsights.js.map +0 -1
  229. package/lib/commonjs/notifyAppReadyInsights.spec.js +0 -246
  230. package/lib/commonjs/notifyAppReadyInsights.spec.js.map +0 -1
  231. package/lib/commonjs/notifyAppReadyInsights.test-utils.js +0 -24
  232. package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +0 -1
  233. package/lib/commonjs/notifyAppReadyInsights.transport.spec.js +0 -117
  234. package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +0 -1
  235. package/lib/commonjs/releaseCatalogCache.spec.js +0 -195
  236. package/lib/commonjs/releaseCatalogCache.spec.js.map +0 -1
  237. package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js +0 -64
  238. package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js.map +0 -1
  239. package/lib/commonjs/store.notification.spec.js +0 -76
  240. package/lib/commonjs/store.notification.spec.js.map +0 -1
  241. package/lib/commonjs/store.spec.js +0 -316
  242. package/lib/commonjs/store.spec.js.map +0 -1
  243. package/lib/commonjs/wrap.spec.js +0 -329
  244. package/lib/commonjs/wrap.spec.js.map +0 -1
  245. package/lib/module/catalogCacheNative.spec.js +0 -31
  246. package/lib/module/catalogCacheNative.spec.js.map +0 -1
  247. package/lib/module/checkForUpdate.releaseCatalog.spec.js +0 -614
  248. package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +0 -1
  249. package/lib/module/httpClient.spec.js +0 -102
  250. package/lib/module/httpClient.spec.js.map +0 -1
  251. package/lib/module/index.spec.js +0 -301
  252. package/lib/module/index.spec.js.map +0 -1
  253. package/lib/module/iosInterop.spec.js +0 -18
  254. package/lib/module/iosInterop.spec.js.map +0 -1
  255. package/lib/module/native.spec.js +0 -882
  256. package/lib/module/native.spec.js.map +0 -1
  257. package/lib/module/notifyAppReadyInsights.boundary.spec.js +0 -217
  258. package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +0 -1
  259. package/lib/module/notifyAppReadyInsights.js +0 -128
  260. package/lib/module/notifyAppReadyInsights.js.map +0 -1
  261. package/lib/module/notifyAppReadyInsights.spec.js +0 -245
  262. package/lib/module/notifyAppReadyInsights.spec.js.map +0 -1
  263. package/lib/module/notifyAppReadyInsights.test-utils.js +0 -18
  264. package/lib/module/notifyAppReadyInsights.test-utils.js.map +0 -1
  265. package/lib/module/notifyAppReadyInsights.transport.spec.js +0 -116
  266. package/lib/module/notifyAppReadyInsights.transport.spec.js.map +0 -1
  267. package/lib/module/releaseCatalogCache.spec.js +0 -195
  268. package/lib/module/releaseCatalogCache.spec.js.map +0 -1
  269. package/lib/module/releaseCatalogCacheNativeContract.spec.js +0 -64
  270. package/lib/module/releaseCatalogCacheNativeContract.spec.js.map +0 -1
  271. package/lib/module/store.notification.spec.js +0 -77
  272. package/lib/module/store.notification.spec.js.map +0 -1
  273. package/lib/module/store.spec.js +0 -315
  274. package/lib/module/store.spec.js.map +0 -1
  275. package/lib/module/wrap.spec.js +0 -330
  276. package/lib/module/wrap.spec.js.map +0 -1
  277. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +0 -13
  278. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +0 -1
  279. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +0 -8
  280. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
  281. package/lib/typescript/module/notifyAppReadyInsights.d.ts +0 -13
  282. package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +0 -1
  283. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +0 -8
  284. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
  285. package/src/catalogCacheNative.spec.ts +0 -63
  286. package/src/checkForUpdate.releaseCatalog.spec.ts +0 -611
  287. package/src/httpClient.spec.ts +0 -132
  288. package/src/index.spec.ts +0 -337
  289. package/src/iosInterop.spec.ts +0 -30
  290. package/src/native.spec.ts +0 -945
  291. package/src/notifyAppReadyInsights.boundary.spec.ts +0 -234
  292. package/src/notifyAppReadyInsights.spec.ts +0 -243
  293. package/src/notifyAppReadyInsights.test-utils.ts +0 -31
  294. package/src/notifyAppReadyInsights.transport.spec.ts +0 -130
  295. package/src/notifyAppReadyInsights.ts +0 -194
  296. package/src/releaseCatalogCache.spec.ts +0 -282
  297. package/src/releaseCatalogCacheNativeContract.spec.ts +0 -80
  298. package/src/store.notification.spec.ts +0 -92
  299. package/src/store.spec.ts +0 -372
  300. package/src/wrap.spec.ts +0 -406
@@ -1,883 +0,0 @@
1
- "use strict";
2
-
3
- var _core = require("@hot-updater/core");
4
- var _vitest = require("vitest");
5
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
6
- const nativeModuleMock = _vitest.vi.hoisted(() => {
7
- const getManifest = _vitest.vi.fn();
8
- const getCrashHistory = _vitest.vi.fn(() => []);
9
- return {
10
- getActiveUpdateState: _vitest.vi.fn(),
11
- clearCrashHistory: _vitest.vi.fn(() => true),
12
- getBaseURL: _vitest.vi.fn(() => null),
13
- getBundleId: _vitest.vi.fn(() => "bundle-id"),
14
- getCohort: _vitest.vi.fn(() => "123"),
15
- getInstallId: _vitest.vi.fn(() => "install-id"),
16
- getUserId: _vitest.vi.fn(() => null),
17
- getUsername: _vitest.vi.fn(() => null),
18
- getManifest,
19
- getCrashHistory,
20
- getConstants: _vitest.vi.fn(() => ({
21
- APP_VERSION: null,
22
- CHANNEL: "production",
23
- DEFAULT_CHANNEL: "production",
24
- FINGERPRINT_HASH: null,
25
- MIN_BUNDLE_ID: "min-bundle-id"
26
- })),
27
- notifyAppReady: _vitest.vi.fn(),
28
- reload: _vitest.vi.fn(),
29
- resetChannel: _vitest.vi.fn(),
30
- setCohort: _vitest.vi.fn(),
31
- setUser: _vitest.vi.fn(),
32
- setBundleURL: _vitest.vi.fn(),
33
- switchChannel: _vitest.vi.fn(),
34
- updateBundle: _vitest.vi.fn()
35
- };
36
- });
37
- _vitest.vi.mock("react-native", () => ({
38
- NativeEventEmitter: class {
39
- addListener() {
40
- return {
41
- remove: () => {}
42
- };
43
- }
44
- },
45
- Platform: {
46
- OS: "ios"
47
- }
48
- }));
49
- _vitest.vi.mock("./specs/NativeHotUpdater", () => ({
50
- default: nativeModuleMock
51
- }));
52
- (0, _vitest.describe)("notifyAppReady", () => {
53
- (0, _vitest.beforeEach)(() => {
54
- _vitest.vi.resetModules();
55
- nativeModuleMock.getActiveUpdateState.mockReset();
56
- nativeModuleMock.getActiveUpdateState.mockReturnValue({
57
- activeSelection: null,
58
- stableSelection: null,
59
- verificationPending: false,
60
- highestSeenCatalogs: {}
61
- });
62
- nativeModuleMock.notifyAppReady.mockReset();
63
- nativeModuleMock.getBaseURL.mockReset();
64
- nativeModuleMock.getBundleId.mockReset();
65
- nativeModuleMock.getCrashHistory.mockReset();
66
- nativeModuleMock.getConstants.mockReturnValue({
67
- APP_VERSION: null,
68
- CHANNEL: "production",
69
- DEFAULT_CHANNEL: "production",
70
- FINGERPRINT_HASH: null,
71
- MIN_BUNDLE_ID: "min-bundle-id"
72
- });
73
- nativeModuleMock.getBundleId.mockReturnValue("bundle-id");
74
- nativeModuleMock.getBaseURL.mockReturnValue(null);
75
- nativeModuleMock.getCrashHistory.mockReturnValue([]);
76
- nativeModuleMock.getCohort.mockReset();
77
- nativeModuleMock.getCohort.mockReturnValue("123");
78
- nativeModuleMock.getInstallId.mockReset();
79
- nativeModuleMock.getInstallId.mockReturnValue("install-id");
80
- nativeModuleMock.getManifest.mockReset();
81
- nativeModuleMock.getManifest.mockReturnValue({
82
- assets: {
83
- "index.android.bundle": {
84
- fileHash: "hash-123"
85
- }
86
- },
87
- bundleId: "bundle-id"
88
- });
89
- nativeModuleMock.resetChannel.mockReset();
90
- nativeModuleMock.setCohort.mockReset();
91
- nativeModuleMock.setUser.mockReset();
92
- nativeModuleMock.updateBundle.mockReset();
93
- });
94
- (0, _vitest.it)("exposes active Release state without internal Catalog identity or history", async () => {
95
- const receipt = {
96
- bundleId: "bundle-123",
97
- releaseId: "release-123",
98
- kind: "BUNDLE",
99
- channel: "production",
100
- catalogId: "private-catalog",
101
- scopeKey: "private-scope",
102
- generation: 10,
103
- catalogHash: "private-hash",
104
- selectionContextHash: "private-context"
105
- };
106
- nativeModuleMock.getActiveUpdateState.mockReturnValue({
107
- activeSelection: receipt,
108
- stableSelection: receipt,
109
- verificationPending: true,
110
- highestSeenCatalogs: {
111
- "private-catalog|private-scope": {
112
- generation: 10,
113
- catalogHash: "private-hash"
114
- }
115
- }
116
- });
117
- const {
118
- getPublicActiveUpdateState
119
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
120
- const selection = {
121
- bundleId: "bundle-123",
122
- releaseId: "release-123",
123
- kind: "BUNDLE",
124
- channel: "production"
125
- };
126
- (0, _vitest.expect)(getPublicActiveUpdateState()).toEqual({
127
- activeSelection: selection,
128
- stableSelection: selection,
129
- verificationPending: true
130
- });
131
- });
132
- (0, _vitest.it)("tracks same-file promotions without changing artifact or crash identities", async () => {
133
- const state = {
134
- activeSelection: {
135
- kind: "BUNDLE",
136
- bundleId: "bundle-123",
137
- releaseId: "release-1"
138
- }
139
- };
140
- nativeModuleMock.getActiveUpdateState.mockImplementation(() => state);
141
- nativeModuleMock.getBundleId.mockReturnValue("bundle-123");
142
- nativeModuleMock.getManifest.mockReturnValue({
143
- assets: {}
144
- });
145
- nativeModuleMock.getCrashHistory.mockReturnValue(["bundle-failed"]);
146
- const {
147
- getUpdateId,
148
- getBundleId,
149
- getManifest,
150
- getCrashHistory
151
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
152
- (0, _vitest.expect)(getUpdateId()).toBe("release-1");
153
- state.activeSelection.releaseId = "release-2";
154
- (0, _vitest.expect)(getUpdateId()).toBe("release-2");
155
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
156
- (0, _vitest.expect)(getManifest().bundleId).toBe("bundle-123");
157
- (0, _vitest.expect)(getCrashHistory()).toEqual(["bundle-failed"]);
158
- });
159
- _vitest.it.each([[null, "min-bundle-id"], ["legacy-bundle", "legacy-bundle"]])("preserves the fallback ID for native bundle %s", async (bundleId, expected) => {
160
- nativeModuleMock.getBundleId.mockReturnValue(bundleId);
161
- const {
162
- getUpdateId
163
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
164
- (0, _vitest.expect)(getUpdateId()).toBe(expected);
165
- });
166
- (0, _vitest.it)("reports a staged update while the manifest still identifies the running file", async () => {
167
- const runningSelection = {
168
- kind: "BUNDLE",
169
- bundleId: "running-file",
170
- releaseId: "running-update"
171
- };
172
- const state = {
173
- activeSelection: runningSelection,
174
- stableSelection: runningSelection
175
- };
176
- nativeModuleMock.getActiveUpdateState.mockImplementation(() => state);
177
- nativeModuleMock.getBundleId.mockReturnValue("running-file");
178
- nativeModuleMock.getManifest.mockReturnValue({
179
- assets: {},
180
- bundleId: "running-file"
181
- });
182
- const {
183
- getUpdateId,
184
- getBundleId,
185
- getManifest
186
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
187
- (0, _vitest.expect)(getUpdateId()).toBe("running-update");
188
- state.activeSelection = {
189
- kind: "BUNDLE",
190
- bundleId: "staged-file",
191
- releaseId: "staged-update"
192
- };
193
- (0, _vitest.expect)(getUpdateId()).toBe("staged-update");
194
- (0, _vitest.expect)(getBundleId()).toBe("running-file");
195
- (0, _vitest.expect)(getManifest().bundleId).toBe("running-file");
196
- });
197
- (0, _vitest.it)("reports an explicit built-in rollback by its update ID", async () => {
198
- nativeModuleMock.getActiveUpdateState.mockReturnValue(JSON.stringify({
199
- activeSelection: {
200
- kind: "EMBEDDED",
201
- releaseId: "rollback-1",
202
- bundleId: "min-bundle-id"
203
- }
204
- }));
205
- nativeModuleMock.getBundleId.mockReturnValue(null);
206
- const {
207
- getUpdateId,
208
- getBundleId
209
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
210
- (0, _vitest.expect)(getUpdateId()).toBe("rollback-1");
211
- (0, _vitest.expect)(getBundleId()).toBe("min-bundle-id");
212
- });
213
- (0, _vitest.it)("normalizes legacy PROMOTED launch reports to UPDATE_APPLIED", async () => {
214
- nativeModuleMock.notifyAppReady.mockReturnValue(JSON.stringify({
215
- fromBundleId: "bundle-123",
216
- status: "PROMOTED",
217
- toBundleId: "bundle-456"
218
- }));
219
- const {
220
- notifyAppReady
221
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
222
- (0, _vitest.expect)(notifyAppReady()).toEqual({
223
- fromBundleId: "bundle-123",
224
- status: "UPDATE_APPLIED",
225
- toBundleId: "bundle-456"
226
- });
227
- (0, _vitest.expect)(nativeModuleMock.notifyAppReady).toHaveBeenCalledWith();
228
- });
229
- (0, _vitest.it)("returns RECOVERED launch reports with directional ids", async () => {
230
- nativeModuleMock.notifyAppReady.mockReturnValue({
231
- fromBundleId: "bundle-123",
232
- status: "RECOVERED",
233
- toBundleId: "bundle-122",
234
- updateStrategy: "appVersion"
235
- });
236
- const {
237
- notifyAppReady,
238
- readNotifyAppReady
239
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
240
- (0, _vitest.expect)(notifyAppReady()).toEqual({
241
- fromBundleId: "bundle-123",
242
- status: "RECOVERED",
243
- toBundleId: "bundle-122"
244
- });
245
- (0, _vitest.expect)(readNotifyAppReady()).toEqual({
246
- insightsEvent: {
247
- fromBundleId: "bundle-123",
248
- toBundleId: "bundle-122",
249
- type: "RECOVERED",
250
- updateStrategy: "appVersion"
251
- },
252
- pending: false,
253
- result: {
254
- fromBundleId: "bundle-123",
255
- status: "RECOVERED",
256
- toBundleId: "bundle-122"
257
- }
258
- });
259
- });
260
- (0, _vitest.it)("returns UNCHANGED for incomplete recovery payloads", async () => {
261
- nativeModuleMock.notifyAppReady.mockReturnValue({
262
- fromBundleId: "bundle-123",
263
- status: "RECOVERED",
264
- toBundleId: null,
265
- updateStrategy: "appVersion"
266
- });
267
- const {
268
- notifyAppReady,
269
- readNotifyAppReady
270
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
271
- (0, _vitest.expect)(notifyAppReady()).toEqual({
272
- status: "UNCHANGED"
273
- });
274
- (0, _vitest.expect)(readNotifyAppReady()).toEqual({
275
- insightsEvent: null,
276
- pending: false,
277
- result: {
278
- status: "UNCHANGED"
279
- }
280
- });
281
- });
282
- (0, _vitest.it)("returns UNCHANGED when automatic insights metadata is incomplete", async () => {
283
- nativeModuleMock.notifyAppReady.mockReturnValue({
284
- status: "UPDATE_APPLIED"
285
- });
286
- const {
287
- notifyAppReady,
288
- readNotifyAppReady
289
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
290
- (0, _vitest.expect)(notifyAppReady()).toEqual({
291
- status: "UNCHANGED"
292
- });
293
- (0, _vitest.expect)(readNotifyAppReady()).toEqual({
294
- insightsEvent: null,
295
- pending: false,
296
- result: {
297
- status: "UNCHANGED"
298
- }
299
- });
300
- });
301
- (0, _vitest.it)("normalizes malformed old-arch notifyAppReady payloads to UNCHANGED", async () => {
302
- nativeModuleMock.notifyAppReady.mockReturnValue("{");
303
- const {
304
- notifyAppReady,
305
- readNotifyAppReady
306
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
307
- (0, _vitest.expect)(notifyAppReady()).toEqual({
308
- status: "UNCHANGED"
309
- });
310
- (0, _vitest.expect)(readNotifyAppReady()).toEqual({
311
- insightsEvent: null,
312
- pending: false,
313
- result: {
314
- status: "UNCHANGED"
315
- }
316
- });
317
- });
318
- (0, _vitest.it)("keeps the internal pending state out of the public result", async () => {
319
- nativeModuleMock.notifyAppReady.mockReturnValue({
320
- status: "PENDING"
321
- });
322
- const {
323
- notifyAppReady,
324
- readNotifyAppReady
325
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
326
- (0, _vitest.expect)(notifyAppReady()).toEqual({
327
- status: "UNCHANGED"
328
- });
329
- (0, _vitest.expect)(readNotifyAppReady()).toEqual({
330
- insightsEvent: null,
331
- pending: true,
332
- result: {
333
- status: "UNCHANGED"
334
- }
335
- });
336
- });
337
- (0, _vitest.it)("returns the native bundle id when available", async () => {
338
- nativeModuleMock.getBundleId.mockReturnValue("bundle-123");
339
- const {
340
- getBundleId
341
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
342
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
343
- });
344
- (0, _vitest.it)("throws when native SDK does not expose getBundleId", async () => {
345
- const nativeModule = nativeModuleMock;
346
- const originalGetBundleId = nativeModule.getBundleId;
347
- nativeModule.getBundleId = null;
348
- try {
349
- const {
350
- getBundleId
351
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
352
- (0, _vitest.expect)(() => getBundleId()).toThrow("Native module is missing 'getBundleId()'");
353
- } finally {
354
- nativeModule.getBundleId = originalGetBundleId;
355
- }
356
- });
357
- (0, _vitest.it)("falls back to MIN_BUNDLE_ID when native reports an empty bundle id", async () => {
358
- nativeModuleMock.getBundleId.mockReturnValue("");
359
- const {
360
- getBundleId
361
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
362
- (0, _vitest.expect)(getBundleId()).toBe("min-bundle-id");
363
- });
364
- (0, _vitest.it)("falls back to MIN_BUNDLE_ID when native bundle id is null", async () => {
365
- nativeModuleMock.getBundleId.mockReturnValue(null);
366
- const {
367
- getBundleId
368
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
369
- (0, _vitest.expect)(getBundleId()).toBe("min-bundle-id");
370
- });
371
- (0, _vitest.it)("falls back to MIN_BUNDLE_ID for legacy NIL_UUID bundle ids", async () => {
372
- nativeModuleMock.getBundleId.mockReturnValue("00000000-0000-0000-0000-000000000000");
373
- const {
374
- getBundleId
375
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
376
- (0, _vitest.expect)(getBundleId()).toBe("min-bundle-id");
377
- });
378
- (0, _vitest.it)("returns manifest from native objects", async () => {
379
- nativeModuleMock.getManifest.mockReturnValue({
380
- assets: {
381
- "assets/logo.png": {
382
- fileHash: "hash-logo",
383
- signature: "sig-logo"
384
- },
385
- "index.android.bundle": {
386
- fileHash: "hash-bundle"
387
- }
388
- },
389
- bundleId: "bundle-123"
390
- });
391
- const {
392
- getManifest
393
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
394
- (0, _vitest.expect)(getManifest()).toEqual({
395
- assets: {
396
- "assets/logo.png": {
397
- fileHash: "hash-logo",
398
- signature: "sig-logo"
399
- },
400
- "index.android.bundle": {
401
- fileHash: "hash-bundle"
402
- }
403
- },
404
- bundleId: "bundle-123"
405
- });
406
- });
407
- (0, _vitest.it)("normalizes legacy manifest asset entries from native objects", async () => {
408
- nativeModuleMock.getManifest.mockReturnValue({
409
- assets: {
410
- "assets/logo.png": "hash-logo"
411
- },
412
- bundleId: "bundle-123"
413
- });
414
- const {
415
- getManifest
416
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
417
- (0, _vitest.expect)(getManifest()).toEqual({
418
- assets: {
419
- "assets/logo.png": {
420
- fileHash: "hash-logo"
421
- }
422
- },
423
- bundleId: "bundle-123"
424
- });
425
- });
426
- (0, _vitest.it)("parses manifest from old-arch JSON payloads", async () => {
427
- nativeModuleMock.getManifest.mockReturnValue(JSON.stringify({
428
- assets: {
429
- "assets/logo.png": {
430
- fileHash: "hash-logo"
431
- }
432
- },
433
- bundleId: "bundle-123"
434
- }));
435
- const {
436
- getManifest
437
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
438
- (0, _vitest.expect)(getManifest()).toEqual({
439
- assets: {
440
- "assets/logo.png": {
441
- fileHash: "hash-logo"
442
- }
443
- },
444
- bundleId: "bundle-123"
445
- });
446
- });
447
- (0, _vitest.it)("normalizes legacy manifest asset entries from old-arch JSON payloads", async () => {
448
- nativeModuleMock.getManifest.mockReturnValue(JSON.stringify({
449
- assets: {
450
- "assets/logo.png": "hash-logo"
451
- },
452
- bundleId: "bundle-123"
453
- }));
454
- const {
455
- getManifest
456
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
457
- (0, _vitest.expect)(getManifest()).toEqual({
458
- assets: {
459
- "assets/logo.png": {
460
- fileHash: "hash-logo"
461
- }
462
- },
463
- bundleId: "bundle-123"
464
- });
465
- });
466
- (0, _vitest.it)("returns an empty-assets manifest for malformed payloads", async () => {
467
- nativeModuleMock.getManifest.mockReturnValue("{");
468
- const {
469
- getManifest
470
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
471
- (0, _vitest.expect)(getManifest()).toEqual({
472
- assets: {},
473
- bundleId: "bundle-id"
474
- });
475
- });
476
- (0, _vitest.it)("caches active bundle getters within a JS runtime", async () => {
477
- nativeModuleMock.getBundleId.mockReturnValue("bundle-123");
478
- nativeModuleMock.getManifest.mockReturnValue({
479
- assets: {
480
- "assets/logo.png": {
481
- fileHash: "hash-logo"
482
- }
483
- },
484
- bundleId: "bundle-123"
485
- });
486
- nativeModuleMock.getBaseURL.mockReturnValue("file:///bundle-123");
487
- const {
488
- getBaseURL,
489
- getBundleId,
490
- getManifest
491
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
492
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
493
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
494
- (0, _vitest.expect)(nativeModuleMock.getBundleId).toHaveBeenCalledTimes(1);
495
- const firstManifest = getManifest();
496
- firstManifest.assets["assets/logo.png"] = {
497
- fileHash: "mutated-hash"
498
- };
499
- (0, _vitest.expect)(getManifest()).toEqual({
500
- assets: {
501
- "assets/logo.png": {
502
- fileHash: "hash-logo"
503
- }
504
- },
505
- bundleId: "bundle-123"
506
- });
507
- (0, _vitest.expect)(nativeModuleMock.getManifest).toHaveBeenCalledTimes(1);
508
- (0, _vitest.expect)(getBaseURL()).toBe("file:///bundle-123");
509
- (0, _vitest.expect)(getBaseURL()).toBe("file:///bundle-123");
510
- (0, _vitest.expect)(nativeModuleMock.getBaseURL).toHaveBeenCalledTimes(1);
511
- });
512
- (0, _vitest.it)("uses the launched bundle reported by native after updateBundle succeeds", async () => {
513
- nativeModuleMock.getBundleId.mockReturnValue("bundle-123");
514
- nativeModuleMock.getManifest.mockReturnValue({
515
- assets: {},
516
- bundleId: "bundle-123"
517
- });
518
- nativeModuleMock.getBaseURL.mockReturnValue("file:///bundle-123");
519
- nativeModuleMock.updateBundle.mockResolvedValue(true);
520
- const {
521
- getBaseURL,
522
- getBundleId,
523
- getManifest,
524
- updateBundle
525
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
526
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
527
- (0, _vitest.expect)(getManifest()).toEqual({
528
- assets: {},
529
- bundleId: "bundle-123"
530
- });
531
- (0, _vitest.expect)(getBaseURL()).toBe("file:///bundle-123");
532
- await updateBundle({
533
- bundleId: "bundle-456",
534
- fileHash: null,
535
- fileUrl: "https://example.com/bundle.zip",
536
- status: "UPDATE"
537
- });
538
- (0, _vitest.expect)(getBundleId()).toBe("bundle-123");
539
- (0, _vitest.expect)(getManifest()).toEqual({
540
- assets: {},
541
- bundleId: "bundle-123"
542
- });
543
- (0, _vitest.expect)(getBaseURL()).toBe("file:///bundle-123");
544
- (0, _vitest.expect)(nativeModuleMock.getBundleId).toHaveBeenCalledTimes(3);
545
- (0, _vitest.expect)(nativeModuleMock.getManifest).toHaveBeenCalledTimes(2);
546
- (0, _vitest.expect)(nativeModuleMock.getBaseURL).toHaveBeenCalledTimes(2);
547
- });
548
- (0, _vitest.it)("reinstalls a session-installed bundle after native resets to built-in", async () => {
549
- nativeModuleMock.getConstants.mockReturnValue({
550
- APP_VERSION: null,
551
- CHANNEL: "production",
552
- DEFAULT_CHANNEL: "production",
553
- FINGERPRINT_HASH: null,
554
- MIN_BUNDLE_ID: "00000000-0000-0000-0000-000000000001"
555
- });
556
- nativeModuleMock.getBundleId.mockReturnValue("00000000-0000-0000-0000-000000000002");
557
- nativeModuleMock.updateBundle.mockResolvedValue(true);
558
- const {
559
- getBundleId,
560
- updateBundle
561
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
562
- await updateBundle({
563
- bundleId: "00000000-0000-0000-0000-000000000003",
564
- fileHash: null,
565
- fileUrl: "https://example.com/bundle.zip",
566
- status: "UPDATE"
567
- });
568
- nativeModuleMock.getBundleId.mockReturnValue("00000000-0000-0000-0000-000000000003");
569
- (0, _vitest.expect)(getBundleId()).toBe("00000000-0000-0000-0000-000000000003");
570
- nativeModuleMock.getBundleId.mockReturnValue(null);
571
- await (0, _vitest.expect)(updateBundle({
572
- bundleId: "00000000-0000-0000-0000-000000000003",
573
- fileHash: null,
574
- fileUrl: "https://example.com/bundle.zip",
575
- status: "UPDATE"
576
- })).resolves.toBe(true);
577
- (0, _vitest.expect)(nativeModuleMock.updateBundle).toHaveBeenCalledTimes(2);
578
- });
579
- (0, _vitest.it)("skips a session-installed bundle when native still reports it active", async () => {
580
- nativeModuleMock.getConstants.mockReturnValue({
581
- APP_VERSION: null,
582
- CHANNEL: "production",
583
- DEFAULT_CHANNEL: "production",
584
- FINGERPRINT_HASH: null,
585
- MIN_BUNDLE_ID: "00000000-0000-0000-0000-000000000001"
586
- });
587
- nativeModuleMock.getBundleId.mockReturnValue("00000000-0000-0000-0000-000000000002");
588
- nativeModuleMock.updateBundle.mockResolvedValue(true);
589
- const {
590
- updateBundle
591
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
592
- await updateBundle({
593
- bundleId: "00000000-0000-0000-0000-000000000003",
594
- fileHash: null,
595
- fileUrl: "https://example.com/bundle.zip",
596
- status: "UPDATE"
597
- });
598
- nativeModuleMock.getBundleId.mockReturnValue("00000000-0000-0000-0000-000000000003");
599
- await (0, _vitest.expect)(updateBundle({
600
- bundleId: "00000000-0000-0000-0000-000000000003",
601
- fileHash: null,
602
- fileUrl: "https://example.com/bundle.zip",
603
- status: "UPDATE"
604
- })).resolves.toBe(true);
605
- (0, _vitest.expect)(nativeModuleMock.updateBundle).toHaveBeenCalledTimes(1);
606
- });
607
- (0, _vitest.it)("forwards manifest artifact parameters to native updateBundle", async () => {
608
- nativeModuleMock.getBundleId.mockReturnValue("bundle-123");
609
- nativeModuleMock.updateBundle.mockResolvedValue(true);
610
- const {
611
- updateBundle
612
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
613
- await updateBundle({
614
- bundleId: "bundle-789",
615
- changedAssets: {
616
- "index.ios.bundle": {
617
- file: {
618
- compression: "br",
619
- url: "https://example.com/files/index.ios.bundle.br"
620
- },
621
- fileHash: "hash-next",
622
- patch: {
623
- algorithm: "bsdiff",
624
- baseBundleId: "bundle-123",
625
- baseFileHash: "hash-prev",
626
- patchFileHash: "hash-patch",
627
- patchUrl: "https://example.com/files/index.ios.bundle.bsdiff"
628
- }
629
- }
630
- },
631
- fileHash: "sig:archive",
632
- fileUrl: "https://example.com/bundle.zip",
633
- manifestFileHash: "sig:manifest",
634
- manifestUrl: "https://example.com/manifest.json",
635
- status: "UPDATE"
636
- });
637
- (0, _vitest.expect)(nativeModuleMock.updateBundle).toHaveBeenCalledWith({
638
- bundleId: "bundle-789",
639
- changedAssets: {
640
- "index.ios.bundle": {
641
- file: {
642
- compression: "br",
643
- url: "https://example.com/files/index.ios.bundle.br"
644
- },
645
- fileHash: "hash-next",
646
- patch: {
647
- algorithm: "bsdiff",
648
- baseBundleId: "bundle-123",
649
- baseFileHash: "hash-prev",
650
- patchFileHash: "hash-patch",
651
- patchUrl: "https://example.com/files/index.ios.bundle.bsdiff"
652
- }
653
- }
654
- },
655
- channel: undefined,
656
- fileHash: "sig:archive",
657
- fileUrl: "https://example.com/bundle.zip",
658
- manifestFileHash: "sig:manifest",
659
- manifestUrl: "https://example.com/manifest.json"
660
- });
661
- });
662
- (0, _vitest.it)("invalidates cached bundle getters after resetChannel succeeds", async () => {
663
- nativeModuleMock.getConstants.mockReturnValue({
664
- APP_VERSION: null,
665
- CHANNEL: "beta",
666
- DEFAULT_CHANNEL: "production",
667
- FINGERPRINT_HASH: null,
668
- MIN_BUNDLE_ID: "min-bundle-id"
669
- });
670
- nativeModuleMock.getBundleId.mockReturnValue("bundle-beta");
671
- nativeModuleMock.getManifest.mockReturnValue({
672
- assets: {},
673
- bundleId: "bundle-beta"
674
- });
675
- nativeModuleMock.getBaseURL.mockReturnValue("file:///bundle-beta");
676
- nativeModuleMock.resetChannel.mockResolvedValue(true);
677
- const {
678
- getBaseURL,
679
- getBundleId,
680
- getManifest,
681
- resetChannel
682
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
683
- (0, _vitest.expect)(getBundleId()).toBe("bundle-beta");
684
- (0, _vitest.expect)(getManifest()).toEqual({
685
- assets: {},
686
- bundleId: "bundle-beta"
687
- });
688
- (0, _vitest.expect)(getBaseURL()).toBe("file:///bundle-beta");
689
- nativeModuleMock.getBundleId.mockReturnValue(null);
690
- nativeModuleMock.getManifest.mockReturnValue({});
691
- nativeModuleMock.getBaseURL.mockReturnValue("");
692
- await (0, _vitest.expect)(resetChannel()).resolves.toBe(true);
693
- (0, _vitest.expect)(getBundleId()).toBe("min-bundle-id");
694
- (0, _vitest.expect)(getManifest()).toEqual({
695
- assets: {},
696
- bundleId: "min-bundle-id"
697
- });
698
- (0, _vitest.expect)(getBaseURL()).toBeNull();
699
- (0, _vitest.expect)(nativeModuleMock.getBundleId).toHaveBeenCalledTimes(2);
700
- (0, _vitest.expect)(nativeModuleMock.getManifest).toHaveBeenCalledTimes(2);
701
- (0, _vitest.expect)(nativeModuleMock.getBaseURL).toHaveBeenCalledTimes(2);
702
- });
703
- (0, _vitest.it)("delegates resetChannel to native even when exported channel constants already match", async () => {
704
- nativeModuleMock.getConstants.mockReturnValue({
705
- APP_VERSION: null,
706
- CHANNEL: "beta",
707
- DEFAULT_CHANNEL: "beta",
708
- FINGERPRINT_HASH: null,
709
- MIN_BUNDLE_ID: "min-bundle-id"
710
- });
711
- nativeModuleMock.resetChannel.mockResolvedValue(true);
712
- const {
713
- resetChannel
714
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
715
- await (0, _vitest.expect)(resetChannel()).resolves.toBe(true);
716
- (0, _vitest.expect)(nativeModuleMock.resetChannel).toHaveBeenCalledTimes(1);
717
- });
718
- (0, _vitest.it)("parses crash history from legacy JSON payloads", async () => {
719
- nativeModuleMock.getCrashHistory.mockReturnValue(JSON.stringify(["bundle-1", "bundle-2"]));
720
- const {
721
- getCrashHistory
722
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
723
- (0, _vitest.expect)(getCrashHistory()).toEqual(["bundle-1", "bundle-2"]);
724
- });
725
- (0, _vitest.it)("falls back to an empty crash history for malformed payloads", async () => {
726
- nativeModuleMock.getCrashHistory.mockReturnValue("{");
727
- const {
728
- getCrashHistory
729
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
730
- (0, _vitest.expect)(getCrashHistory()).toEqual([]);
731
- });
732
- (0, _vitest.it)("passes normalized cohort overrides to native", async () => {
733
- const {
734
- setCohort
735
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
736
- setCohort(" QA-Group ");
737
- (0, _vitest.expect)(nativeModuleMock.setCohort).toHaveBeenCalledWith("qa-group");
738
- });
739
- (0, _vitest.it)("returns the most recently set cohort before native reads catch up", async () => {
740
- nativeModuleMock.getCohort.mockReturnValue("123");
741
- const {
742
- getCohort,
743
- setCohort
744
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
745
- setCohort(" QA-Group ");
746
- (0, _vitest.expect)(getCohort()).toBe("qa-group");
747
- (0, _vitest.expect)(nativeModuleMock.getCohort).not.toHaveBeenCalled();
748
- });
749
- (0, _vitest.it)("throws when attempting to clear the cohort with an empty value", async () => {
750
- const {
751
- setCohort
752
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
753
- (0, _vitest.expect)(() => setCohort("")).toThrow(_core.INVALID_COHORT_ERROR_MESSAGE);
754
- (0, _vitest.expect)(nativeModuleMock.setCohort).not.toHaveBeenCalled();
755
- });
756
- (0, _vitest.it)("throws for invalid cohort overrides", async () => {
757
- const {
758
- setCohort
759
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
760
- (0, _vitest.expect)(() => setCohort("Bad Cohort")).toThrow(_core.INVALID_COHORT_ERROR_MESSAGE);
761
- (0, _vitest.expect)(nativeModuleMock.setCohort).not.toHaveBeenCalled();
762
- });
763
- (0, _vitest.it)("throws for cohort overrides longer than the limit", async () => {
764
- const {
765
- setCohort
766
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
767
- (0, _vitest.expect)(() => setCohort("a".repeat(65))).toThrow(_core.INVALID_COHORT_ERROR_MESSAGE);
768
- (0, _vitest.expect)(nativeModuleMock.setCohort).not.toHaveBeenCalled();
769
- });
770
- (0, _vitest.it)("returns the install id reported by native", async () => {
771
- nativeModuleMock.getInstallId.mockReturnValue("install-123");
772
- const {
773
- getInstallId
774
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
775
- (0, _vitest.expect)(getInstallId()).toBe("install-123");
776
- });
777
- (0, _vitest.it)("normalizes an omitted native fingerprint constant to null", async () => {
778
- nativeModuleMock.getConstants.mockReturnValue({
779
- APP_VERSION: null,
780
- CHANNEL: "production",
781
- DEFAULT_CHANNEL: "production",
782
- FINGERPRINT_HASH: undefined,
783
- MIN_BUNDLE_ID: "min-bundle-id"
784
- });
785
- const {
786
- getFingerprintHash
787
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
788
- (0, _vitest.expect)(getFingerprintHash()).toBeNull();
789
- });
790
- (0, _vitest.it)("throws when native SDK does not expose getInstallId", async () => {
791
- const nativeModule = nativeModuleMock;
792
- const originalGetInstallId = nativeModule.getInstallId;
793
- nativeModule.getInstallId = null;
794
- try {
795
- const {
796
- getInstallId
797
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
798
- (0, _vitest.expect)(() => getInstallId()).toThrow("Native module is missing 'getInstallId()'");
799
- } finally {
800
- nativeModule.getInstallId = originalGetInstallId;
801
- }
802
- });
803
- (0, _vitest.it)("passes nullable user identity through to native", async () => {
804
- const {
805
- setUser
806
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
807
- setUser({
808
- userId: "user-123",
809
- username: "alice"
810
- });
811
- setUser({
812
- userId: 42,
813
- username: "bob"
814
- });
815
- setUser({});
816
- setUser(null);
817
- (0, _vitest.expect)(nativeModuleMock.setUser).toHaveBeenNthCalledWith(1, "user-123", "alice");
818
- (0, _vitest.expect)(nativeModuleMock.setUser).toHaveBeenNthCalledWith(2, "42", "bob");
819
- (0, _vitest.expect)(nativeModuleMock.setUser).toHaveBeenNthCalledWith(3, null, null);
820
- (0, _vitest.expect)(nativeModuleMock.setUser).toHaveBeenNthCalledWith(4, null, null);
821
- });
822
- (0, _vitest.it)("reads persisted user identity from native when available", async () => {
823
- nativeModuleMock.getUserId.mockReturnValue("user-123");
824
- nativeModuleMock.getUsername.mockReturnValue("alice");
825
- const {
826
- getPersistedUserIdentity
827
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
828
- (0, _vitest.expect)(getPersistedUserIdentity()).toEqual({
829
- userId: "user-123",
830
- username: "alice"
831
- });
832
- });
833
- (0, _vitest.it)("throws when native SDK does not expose persisted user identity getters", async () => {
834
- const nativeModule = nativeModuleMock;
835
- const originalGetUserId = nativeModule.getUserId;
836
- nativeModule.getUserId = null;
837
- try {
838
- const {
839
- getPersistedUserIdentity
840
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
841
- (0, _vitest.expect)(() => getPersistedUserIdentity()).toThrow("Native module is missing 'getUserId()' or 'getUsername()'");
842
- } finally {
843
- nativeModule.getUserId = originalGetUserId;
844
- }
845
- });
846
- (0, _vitest.it)("throws when native SDK does not expose setUser", async () => {
847
- const nativeModule = nativeModuleMock;
848
- const originalSetUser = nativeModule.setUser;
849
- nativeModule.setUser = null;
850
- try {
851
- const {
852
- setUser
853
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
854
- (0, _vitest.expect)(() => setUser({
855
- userId: "user-123"
856
- })).toThrow("Native module is missing 'setUser()'");
857
- } finally {
858
- nativeModule.setUser = originalSetUser;
859
- }
860
- });
861
- (0, _vitest.it)("returns the cohort reported by native", async () => {
862
- nativeModuleMock.getCohort.mockReturnValue("qa-group");
863
- const {
864
- getCohort
865
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
866
- (0, _vitest.expect)(getCohort()).toBe("qa-group");
867
- });
868
- (0, _vitest.it)("normalizes the cohort reported by native", async () => {
869
- nativeModuleMock.getCohort.mockReturnValue(" QA-GROUP ");
870
- const {
871
- getCohort
872
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
873
- (0, _vitest.expect)(getCohort()).toBe("qa-group");
874
- });
875
- (0, _vitest.it)("throws when native reports an invalid cohort", async () => {
876
- nativeModuleMock.getCohort.mockReturnValue("1001");
877
- const {
878
- getCohort
879
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./native")));
880
- (0, _vitest.expect)(() => getCohort()).toThrow(_core.INVALID_COHORT_ERROR_MESSAGE);
881
- });
882
- });
883
- //# sourceMappingURL=native.spec.js.map