@hot-updater/react-native 1.0.0-rc.2 → 1.0.0-rc.22

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