@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.
- package/android/proguard-rules.pro +17 -2
- package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
- package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +954 -837
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +15 -11
- package/android/src/main/java/com/hotupdater/FileManagerService.kt +45 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +287 -22
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +43 -31
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +37 -54
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryState.kt +64 -0
- package/android/src/main/java/com/hotupdater/InstallIdentityService.kt +37 -0
- package/android/src/main/java/com/hotupdater/KeyValueStorageService.kt +86 -0
- package/android/src/main/java/com/hotupdater/NetworkState.kt +31 -0
- package/android/src/main/java/com/hotupdater/NoBackupStorage.kt +17 -0
- package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +127 -50
- package/android/src/main/java/com/hotupdater/PreviousProcessExit.kt +89 -0
- package/android/src/main/java/com/hotupdater/ReactNativeValueConverters.kt +34 -0
- package/android/src/main/java/com/hotupdater/TarArchiveInputStream.kt +214 -375
- package/android/src/main/java/com/hotupdater/TarBrArchiveExtractor.kt +119 -0
- package/android/src/newarch/HotUpdater.kt +7 -9
- package/android/src/newarch/HotUpdaterModule.kt +109 -84
- package/android/src/oldarch/HotUpdater.kt +7 -9
- package/android/src/oldarch/HotUpdaterModule.kt +98 -74
- package/android/src/oldarch/HotUpdaterSpec.kt +4 -6
- package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
- package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +950 -1112
- package/ios/HotUpdater/Internal/BundleMetadata.swift +8 -53
- package/ios/HotUpdater/Internal/FileManagerService.swift +48 -0
- package/ios/HotUpdater/Internal/FileUtilities.swift +64 -0
- package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +0 -1
- package/ios/HotUpdater/Internal/HotUpdater.mm +13 -45
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +190 -73
- package/ios/HotUpdater/Internal/KeyValueStorageService.swift +71 -0
- package/ios/HotUpdater/Internal/NotificationExtension.swift +0 -2
- package/ios/HotUpdater/Internal/TarArchiveExtractor.swift +182 -311
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +119 -71
- package/ios/HotUpdater/Internal/UpdateFailure.swift +390 -0
- package/ios/HotUpdater/Recovery/HotUpdaterRecovery.h +16 -0
- package/ios/HotUpdater/Recovery/HotUpdaterRecovery.mm +83 -0
- package/ios/HotUpdater/Recovery/HotUpdaterRecoveryHooks.mm +49 -0
- package/lib/commonjs/appReady.js +111 -0
- package/lib/commonjs/appReady.js.map +1 -0
- package/lib/commonjs/checkForUpdate.js +124 -69
- package/lib/commonjs/checkForUpdate.js.map +1 -1
- package/lib/commonjs/clientPlugin.js +13 -0
- package/lib/commonjs/clientPlugin.js.map +1 -0
- package/lib/commonjs/error.js +4 -13
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/fetchJSON.js +16 -27
- package/lib/commonjs/fetchJSON.js.map +1 -1
- package/lib/commonjs/fetchUpdateResponse.js +54 -0
- package/lib/commonjs/fetchUpdateResponse.js.map +1 -0
- package/lib/commonjs/httpClient.js +63 -94
- package/lib/commonjs/httpClient.js.map +1 -1
- package/lib/commonjs/index.js +71 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native.js +78 -60
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/pluginHost.js +44 -0
- package/lib/commonjs/pluginHost.js.map +1 -0
- package/lib/commonjs/releaseCatalogCache.js +36 -87
- package/lib/commonjs/releaseCatalogCache.js.map +1 -1
- package/lib/commonjs/sdkVersion.js +1 -1
- package/lib/commonjs/sdkVersion.js.map +1 -1
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/store.js +3 -10
- package/lib/commonjs/store.js.map +1 -1
- package/lib/commonjs/updateError.js +132 -0
- package/lib/commonjs/updateError.js.map +1 -0
- package/lib/commonjs/wrap.js +43 -26
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/appReady.js +103 -0
- package/lib/module/appReady.js.map +1 -0
- package/lib/module/checkForUpdate.js +117 -64
- package/lib/module/checkForUpdate.js.map +1 -1
- package/lib/module/clientPlugin.js +4 -0
- package/lib/module/clientPlugin.js.map +1 -0
- package/lib/module/error.js +4 -13
- package/lib/module/error.js.map +1 -1
- package/lib/module/fetchJSON.js +14 -26
- package/lib/module/fetchJSON.js.map +1 -1
- package/lib/module/fetchUpdateResponse.js +49 -0
- package/lib/module/fetchUpdateResponse.js.map +1 -0
- package/lib/module/httpClient.js +62 -93
- package/lib/module/httpClient.js.map +1 -1
- package/lib/module/index.js +58 -20
- package/lib/module/index.js.map +1 -1
- package/lib/module/native.js +71 -53
- package/lib/module/native.js.map +1 -1
- package/lib/module/pluginHost.js +35 -0
- package/lib/module/pluginHost.js.map +1 -0
- package/lib/module/releaseCatalogCache.js +32 -82
- package/lib/module/releaseCatalogCache.js.map +1 -1
- package/lib/module/sdkVersion.js +1 -1
- package/lib/module/sdkVersion.js.map +1 -1
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/store.js +3 -10
- package/lib/module/store.js.map +1 -1
- package/lib/module/updateError.js +126 -0
- package/lib/module/updateError.js.map +1 -0
- package/lib/module/wrap.js +43 -26
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/appReady.d.ts +23 -0
- package/lib/typescript/commonjs/appReady.d.ts.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +16 -4
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/clientPlugin.d.ts +2 -0
- package/lib/typescript/commonjs/clientPlugin.d.ts.map +1 -0
- package/lib/typescript/commonjs/error.d.ts +4 -13
- package/lib/typescript/commonjs/error.d.ts.map +1 -1
- package/lib/typescript/commonjs/fetchJSON.d.ts +5 -5
- package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/commonjs/fetchUpdateResponse.d.ts +14 -0
- package/lib/typescript/commonjs/fetchUpdateResponse.d.ts.map +1 -0
- package/lib/typescript/commonjs/httpClient.d.ts +4 -33
- package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -8
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +31 -22
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/pluginHost.d.ts +4 -0
- package/lib/typescript/commonjs/pluginHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/releaseCatalogCache.d.ts +8 -14
- package/lib/typescript/commonjs/releaseCatalogCache.d.ts.map +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +42 -47
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/store.d.ts +1 -3
- package/lib/typescript/commonjs/store.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +1 -1
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/updateError.d.ts +26 -0
- package/lib/typescript/commonjs/updateError.d.ts.map +1 -0
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.types.d.ts +6 -7
- package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
- package/lib/typescript/module/appReady.d.ts +23 -0
- package/lib/typescript/module/appReady.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +16 -4
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/module/clientPlugin.d.ts +2 -0
- package/lib/typescript/module/clientPlugin.d.ts.map +1 -0
- package/lib/typescript/module/error.d.ts +4 -13
- package/lib/typescript/module/error.d.ts.map +1 -1
- package/lib/typescript/module/fetchJSON.d.ts +5 -5
- package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/module/fetchUpdateResponse.d.ts +14 -0
- package/lib/typescript/module/fetchUpdateResponse.d.ts.map +1 -0
- package/lib/typescript/module/httpClient.d.ts +4 -33
- package/lib/typescript/module/httpClient.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -8
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +31 -22
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/pluginHost.d.ts +4 -0
- package/lib/typescript/module/pluginHost.d.ts.map +1 -0
- package/lib/typescript/module/releaseCatalogCache.d.ts +8 -14
- package/lib/typescript/module/releaseCatalogCache.d.ts.map +1 -1
- package/lib/typescript/module/sdkVersion.d.ts +1 -1
- package/lib/typescript/module/sdkVersion.d.ts.map +1 -1
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +42 -47
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/store.d.ts +1 -3
- package/lib/typescript/module/store.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +1 -1
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/updateError.d.ts +26 -0
- package/lib/typescript/module/updateError.d.ts.map +1 -0
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/lib/typescript/module/wrap.types.d.ts +6 -7
- package/lib/typescript/module/wrap.types.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/appReady.ts +149 -0
- package/src/checkForUpdate.ts +151 -88
- package/src/clientPlugin.ts +18 -0
- package/src/error.ts +4 -14
- package/src/fetchJSON.ts +14 -30
- package/src/fetchUpdateResponse.ts +54 -0
- package/src/httpClient.ts +88 -159
- package/src/index.ts +90 -24
- package/src/native.ts +106 -102
- package/src/pluginHost.ts +45 -0
- package/src/releaseCatalogCache.ts +43 -172
- package/src/sdkVersion.ts +1 -1
- package/src/specs/NativeHotUpdater.ts +41 -48
- package/src/store.ts +2 -23
- package/src/types.ts +1 -1
- package/src/updateError.ts +153 -0
- package/src/wrap.tsx +57 -26
- package/src/wrap.types.ts +6 -7
- package/android/src/main/java/com/hotupdater/DecompressService.kt +0 -89
- package/android/src/main/java/com/hotupdater/DecompressionStrategy.kt +0 -26
- package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +0 -117
- package/android/src/main/java/com/hotupdater/TarGzDecompressionStrategy.kt +0 -117
- package/android/src/main/java/com/hotupdater/ZipDecompressionStrategy.kt +0 -192
- package/android/src/test/java/com/hotupdater/BsdiffPatchTest.kt +0 -46
- package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +0 -799
- package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +0 -273
- package/android/src/test/java/com/hotupdater/NativeConfigUtilsTest.kt +0 -20
- package/android/src/test/java/com/hotupdater/OkHttpDownloadServiceTest.kt +0 -111
- package/android/src/test/java/com/hotupdater/RelativePathResolverTest.kt +0 -41
- package/android/src/test/java/com/hotupdater/ReleaseCatalogCacheServiceTest.kt +0 -118
- package/android/src/test/java/com/hotupdater/TarArchiveInputStreamTest.kt +0 -68
- package/ios/HotUpdater/Internal/ArchiveExtractionUtilities.swift +0 -178
- package/ios/HotUpdater/Internal/DecompressService.swift +0 -112
- package/ios/HotUpdater/Internal/DecompressionStrategy.swift +0 -22
- package/ios/HotUpdater/Internal/StreamingTarArchiveExtractor.swift +0 -370
- package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +0 -39
- package/ios/HotUpdater/Internal/TarGzDecompressionStrategy.swift +0 -59
- package/ios/HotUpdater/Internal/ZipArchiveExtractor.swift +0 -482
- package/ios/HotUpdater/Internal/ZipDecompressionStrategy.swift +0 -56
- package/lib/commonjs/catalogCacheNative.spec.js +0 -31
- package/lib/commonjs/catalogCacheNative.spec.js.map +0 -1
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +0 -615
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +0 -1
- package/lib/commonjs/httpClient.spec.js +0 -102
- package/lib/commonjs/httpClient.spec.js.map +0 -1
- package/lib/commonjs/index.spec.js +0 -302
- package/lib/commonjs/index.spec.js.map +0 -1
- package/lib/commonjs/iosInterop.spec.js +0 -18
- package/lib/commonjs/iosInterop.spec.js.map +0 -1
- package/lib/commonjs/native.spec.js +0 -883
- package/lib/commonjs/native.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js +0 -218
- package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.js +0 -133
- package/lib/commonjs/notifyAppReadyInsights.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.spec.js +0 -246
- package/lib/commonjs/notifyAppReadyInsights.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.test-utils.js +0 -24
- package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.transport.spec.js +0 -117
- package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +0 -1
- package/lib/commonjs/releaseCatalogCache.spec.js +0 -195
- package/lib/commonjs/releaseCatalogCache.spec.js.map +0 -1
- package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js +0 -64
- package/lib/commonjs/releaseCatalogCacheNativeContract.spec.js.map +0 -1
- package/lib/commonjs/store.notification.spec.js +0 -76
- package/lib/commonjs/store.notification.spec.js.map +0 -1
- package/lib/commonjs/store.spec.js +0 -316
- package/lib/commonjs/store.spec.js.map +0 -1
- package/lib/commonjs/wrap.spec.js +0 -329
- package/lib/commonjs/wrap.spec.js.map +0 -1
- package/lib/module/catalogCacheNative.spec.js +0 -31
- package/lib/module/catalogCacheNative.spec.js.map +0 -1
- package/lib/module/checkForUpdate.releaseCatalog.spec.js +0 -614
- package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +0 -1
- package/lib/module/httpClient.spec.js +0 -102
- package/lib/module/httpClient.spec.js.map +0 -1
- package/lib/module/index.spec.js +0 -301
- package/lib/module/index.spec.js.map +0 -1
- package/lib/module/iosInterop.spec.js +0 -18
- package/lib/module/iosInterop.spec.js.map +0 -1
- package/lib/module/native.spec.js +0 -882
- package/lib/module/native.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.boundary.spec.js +0 -217
- package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.js +0 -128
- package/lib/module/notifyAppReadyInsights.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.spec.js +0 -245
- package/lib/module/notifyAppReadyInsights.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.test-utils.js +0 -18
- package/lib/module/notifyAppReadyInsights.test-utils.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.transport.spec.js +0 -116
- package/lib/module/notifyAppReadyInsights.transport.spec.js.map +0 -1
- package/lib/module/releaseCatalogCache.spec.js +0 -195
- package/lib/module/releaseCatalogCache.spec.js.map +0 -1
- package/lib/module/releaseCatalogCacheNativeContract.spec.js +0 -64
- package/lib/module/releaseCatalogCacheNativeContract.spec.js.map +0 -1
- package/lib/module/store.notification.spec.js +0 -77
- package/lib/module/store.notification.spec.js.map +0 -1
- package/lib/module/store.spec.js +0 -315
- package/lib/module/store.spec.js.map +0 -1
- package/lib/module/wrap.spec.js +0 -330
- package/lib/module/wrap.spec.js.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +0 -13
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +0 -8
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyInsights.d.ts +0 -13
- package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +0 -8
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
- package/src/catalogCacheNative.spec.ts +0 -63
- package/src/checkForUpdate.releaseCatalog.spec.ts +0 -611
- package/src/httpClient.spec.ts +0 -132
- package/src/index.spec.ts +0 -337
- package/src/iosInterop.spec.ts +0 -30
- package/src/native.spec.ts +0 -945
- package/src/notifyAppReadyInsights.boundary.spec.ts +0 -234
- package/src/notifyAppReadyInsights.spec.ts +0 -243
- package/src/notifyAppReadyInsights.test-utils.ts +0 -31
- package/src/notifyAppReadyInsights.transport.spec.ts +0 -130
- package/src/notifyAppReadyInsights.ts +0 -194
- package/src/releaseCatalogCache.spec.ts +0 -282
- package/src/releaseCatalogCacheNativeContract.spec.ts +0 -80
- package/src/store.notification.spec.ts +0 -92
- package/src/store.spec.ts +0 -372
- package/src/wrap.spec.ts +0 -406
package/src/wrap.spec.ts
DELETED
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
|
|
3
|
-
import { cleanup, render, waitFor } from "@testing-library/react";
|
|
4
|
-
import { createElement, type ComponentType } from "react";
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
NotifyAppReadyInsightsEvent,
|
|
9
|
-
NotifyAppReadyResult,
|
|
10
|
-
} from "./native";
|
|
11
|
-
import type { HotUpdaterOptions } from "./wrap";
|
|
12
|
-
|
|
13
|
-
vi.mock("react-native", () => ({
|
|
14
|
-
Platform: {
|
|
15
|
-
OS: "ios",
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const createNotifyReadResult = (
|
|
20
|
-
result: NotifyAppReadyResult = { status: "UNCHANGED" },
|
|
21
|
-
insightsEvent: NotifyAppReadyInsightsEvent | null = null,
|
|
22
|
-
pending = false,
|
|
23
|
-
): {
|
|
24
|
-
insightsEvent: NotifyAppReadyInsightsEvent | null;
|
|
25
|
-
pending: boolean;
|
|
26
|
-
result: NotifyAppReadyResult;
|
|
27
|
-
} => ({
|
|
28
|
-
insightsEvent,
|
|
29
|
-
pending,
|
|
30
|
-
result,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const mocks = vi.hoisted(() => ({
|
|
34
|
-
addListener: vi.fn(() => () => {}),
|
|
35
|
-
checkForUpdate: vi.fn(),
|
|
36
|
-
getAppVersion: vi.fn(() => "1.0.0"),
|
|
37
|
-
getBundleId: vi.fn(() => "bundle-id"),
|
|
38
|
-
getUpdateId: vi.fn(() => "release-id"),
|
|
39
|
-
getChannel: vi.fn(() => "production"),
|
|
40
|
-
getCohort: vi.fn(() => "123"),
|
|
41
|
-
getFingerprintHash: vi.fn(() => "fingerprint-hash"),
|
|
42
|
-
getInstallId: vi.fn(() => "install-id"),
|
|
43
|
-
getPersistedUserIdentity: vi.fn(() => ({})),
|
|
44
|
-
readNotifyAppReady: vi.fn<
|
|
45
|
-
() => {
|
|
46
|
-
insightsEvent: NotifyAppReadyInsightsEvent | null;
|
|
47
|
-
pending: boolean;
|
|
48
|
-
result: NotifyAppReadyResult;
|
|
49
|
-
}
|
|
50
|
-
>(() => createNotifyReadResult()),
|
|
51
|
-
reload: vi.fn(),
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
vi.mock("./checkForUpdate", () => ({
|
|
55
|
-
checkForUpdate: mocks.checkForUpdate,
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
vi.mock("./native", () => ({
|
|
59
|
-
addListener: mocks.addListener,
|
|
60
|
-
getAppVersion: mocks.getAppVersion,
|
|
61
|
-
getBundleId: mocks.getBundleId,
|
|
62
|
-
getUpdateId: mocks.getUpdateId,
|
|
63
|
-
getChannel: mocks.getChannel,
|
|
64
|
-
getCohort: mocks.getCohort,
|
|
65
|
-
getFingerprintHash: mocks.getFingerprintHash,
|
|
66
|
-
getInstallId: mocks.getInstallId,
|
|
67
|
-
getPersistedUserIdentity: mocks.getPersistedUserIdentity,
|
|
68
|
-
readNotifyAppReady: mocks.readNotifyAppReady,
|
|
69
|
-
reload: mocks.reload,
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
const createClient = (
|
|
73
|
-
sendInsightsEvent = vi.fn().mockResolvedValue(undefined),
|
|
74
|
-
) => ({
|
|
75
|
-
client: {
|
|
76
|
-
createSession: vi.fn(async () => ({
|
|
77
|
-
fetchReleaseCatalog: vi.fn(),
|
|
78
|
-
resolveArtifact: vi.fn(),
|
|
79
|
-
sendInsightsEvent,
|
|
80
|
-
})),
|
|
81
|
-
},
|
|
82
|
-
sendInsightsEvent,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("HotUpdater wrap initialization", () => {
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
vi.resetModules();
|
|
88
|
-
vi.unstubAllGlobals();
|
|
89
|
-
vi.useRealTimers();
|
|
90
|
-
|
|
91
|
-
for (const mock of Object.values(mocks)) {
|
|
92
|
-
mock.mockReset();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
mocks.checkForUpdate.mockResolvedValue(null);
|
|
96
|
-
mocks.addListener.mockReturnValue(() => {});
|
|
97
|
-
mocks.getAppVersion.mockReturnValue("1.0.0");
|
|
98
|
-
mocks.getPersistedUserIdentity.mockReturnValue({});
|
|
99
|
-
mocks.getBundleId.mockReturnValue("bundle-id");
|
|
100
|
-
mocks.getUpdateId.mockReturnValue("release-id");
|
|
101
|
-
mocks.getChannel.mockReturnValue("production");
|
|
102
|
-
mocks.getCohort.mockReturnValue("123");
|
|
103
|
-
mocks.getFingerprintHash.mockReturnValue("fingerprint-hash");
|
|
104
|
-
mocks.getInstallId.mockReturnValue("install-id");
|
|
105
|
-
mocks.readNotifyAppReady.mockReturnValue(createNotifyReadResult());
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
afterEach(cleanup);
|
|
109
|
-
|
|
110
|
-
it("reports the console ID when up to date while retaining file IDs in insights", async () => {
|
|
111
|
-
const onUpdateProcessCompleted = vi.fn();
|
|
112
|
-
const { client, sendInsightsEvent } = createClient();
|
|
113
|
-
const { wrap } = await import("./wrap");
|
|
114
|
-
const WrappedComponent = wrap({
|
|
115
|
-
insights: true,
|
|
116
|
-
client,
|
|
117
|
-
onUpdateProcessCompleted,
|
|
118
|
-
updateStrategy: "appVersion",
|
|
119
|
-
})(() => null);
|
|
120
|
-
|
|
121
|
-
render(createElement(WrappedComponent));
|
|
122
|
-
|
|
123
|
-
await waitFor(() =>
|
|
124
|
-
expect(onUpdateProcessCompleted).toHaveBeenCalledWith({
|
|
125
|
-
id: "release-id",
|
|
126
|
-
message: null,
|
|
127
|
-
shouldForceUpdate: false,
|
|
128
|
-
status: "UP_TO_DATE",
|
|
129
|
-
}),
|
|
130
|
-
);
|
|
131
|
-
await waitFor(() =>
|
|
132
|
-
expect(sendInsightsEvent).toHaveBeenCalledWith(
|
|
133
|
-
expect.objectContaining({
|
|
134
|
-
toBundleId: "bundle-id",
|
|
135
|
-
type: "UNCHANGED",
|
|
136
|
-
}),
|
|
137
|
-
),
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("returns void from init and defers notifyAppReady to the next frame", async () => {
|
|
142
|
-
vi.useFakeTimers();
|
|
143
|
-
|
|
144
|
-
const requestAnimationFrame = vi.fn(
|
|
145
|
-
(callback: (timestamp: number) => void) => {
|
|
146
|
-
setTimeout(() => callback(0), 0);
|
|
147
|
-
return 1;
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
vi.stubGlobal("requestAnimationFrame", requestAnimationFrame);
|
|
151
|
-
|
|
152
|
-
const { client, sendInsightsEvent } = createClient();
|
|
153
|
-
const { init } = await import("./wrap");
|
|
154
|
-
|
|
155
|
-
const result = init({
|
|
156
|
-
client,
|
|
157
|
-
requestHeaders: {
|
|
158
|
-
Authorization: "Bearer token",
|
|
159
|
-
},
|
|
160
|
-
requestTimeout: 1000,
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
expect(result).toBeUndefined();
|
|
164
|
-
expect(mocks.readNotifyAppReady).not.toHaveBeenCalled();
|
|
165
|
-
expect(sendInsightsEvent).not.toHaveBeenCalled();
|
|
166
|
-
|
|
167
|
-
expect(requestAnimationFrame).toHaveBeenCalled();
|
|
168
|
-
|
|
169
|
-
await vi.runOnlyPendingTimersAsync();
|
|
170
|
-
|
|
171
|
-
expect(mocks.readNotifyAppReady).toHaveBeenCalledWith();
|
|
172
|
-
expect(sendInsightsEvent).not.toHaveBeenCalled();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("waits for native launch verification before sending insights", async () => {
|
|
176
|
-
vi.useFakeTimers();
|
|
177
|
-
|
|
178
|
-
vi.stubGlobal(
|
|
179
|
-
"requestAnimationFrame",
|
|
180
|
-
vi.fn((callback: (timestamp: number) => void) => {
|
|
181
|
-
setTimeout(() => callback(0), 0);
|
|
182
|
-
return 1;
|
|
183
|
-
}),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
mocks.readNotifyAppReady
|
|
187
|
-
.mockReturnValueOnce(createNotifyReadResult(undefined, null, true))
|
|
188
|
-
.mockReturnValueOnce(
|
|
189
|
-
createNotifyReadResult(
|
|
190
|
-
{
|
|
191
|
-
fromBundleId: "bundle-a",
|
|
192
|
-
status: "UPDATE_APPLIED",
|
|
193
|
-
toBundleId: "bundle-b",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
fromBundleId: "bundle-a",
|
|
197
|
-
toBundleId: "bundle-b",
|
|
198
|
-
type: "UPDATE_APPLIED",
|
|
199
|
-
updateStrategy: "appVersion",
|
|
200
|
-
},
|
|
201
|
-
),
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const { client, sendInsightsEvent } = createClient();
|
|
205
|
-
const { init } = await import("./wrap");
|
|
206
|
-
|
|
207
|
-
init({ insights: true, client });
|
|
208
|
-
|
|
209
|
-
await vi.runAllTimersAsync();
|
|
210
|
-
|
|
211
|
-
expect(mocks.readNotifyAppReady).toHaveBeenCalledTimes(2);
|
|
212
|
-
expect(sendInsightsEvent).toHaveBeenCalledTimes(1);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("sends automatic insights only from init when enabled", async () => {
|
|
216
|
-
vi.useFakeTimers();
|
|
217
|
-
|
|
218
|
-
vi.stubGlobal(
|
|
219
|
-
"requestAnimationFrame",
|
|
220
|
-
vi.fn((callback: (timestamp: number) => void) => {
|
|
221
|
-
setTimeout(() => callback(0), 0);
|
|
222
|
-
return 1;
|
|
223
|
-
}),
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
mocks.readNotifyAppReady.mockReturnValue(
|
|
227
|
-
createNotifyReadResult(
|
|
228
|
-
{
|
|
229
|
-
fromBundleId: "bundle-a",
|
|
230
|
-
status: "UPDATE_APPLIED",
|
|
231
|
-
toBundleId: "bundle-b",
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
fromBundleId: "bundle-a",
|
|
235
|
-
toBundleId: "bundle-b",
|
|
236
|
-
type: "UPDATE_APPLIED",
|
|
237
|
-
updateStrategy: "fingerprint",
|
|
238
|
-
},
|
|
239
|
-
),
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
mocks.getPersistedUserIdentity.mockReturnValue({
|
|
243
|
-
userId: "user-123",
|
|
244
|
-
username: "alice",
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const { client, sendInsightsEvent } = createClient();
|
|
248
|
-
const { init } = await import("./wrap");
|
|
249
|
-
|
|
250
|
-
init({
|
|
251
|
-
insights: true,
|
|
252
|
-
requestHeaders: {
|
|
253
|
-
Authorization: "Bearer token",
|
|
254
|
-
},
|
|
255
|
-
requestTimeout: 1000,
|
|
256
|
-
client,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
await vi.runOnlyPendingTimersAsync();
|
|
260
|
-
|
|
261
|
-
expect(sendInsightsEvent).toHaveBeenCalledWith({
|
|
262
|
-
appVersion: "1.0.0",
|
|
263
|
-
channel: "production",
|
|
264
|
-
cohort: "123",
|
|
265
|
-
fingerprintHash: "fingerprint-hash",
|
|
266
|
-
fromBundleId: "bundle-a",
|
|
267
|
-
fromReleaseId: null,
|
|
268
|
-
installId: "install-id",
|
|
269
|
-
platform: "ios",
|
|
270
|
-
requestHeaders: {
|
|
271
|
-
Authorization: "Bearer token",
|
|
272
|
-
},
|
|
273
|
-
requestTimeout: 1000,
|
|
274
|
-
toBundleId: "bundle-b",
|
|
275
|
-
toReleaseId: null,
|
|
276
|
-
type: "UPDATE_APPLIED",
|
|
277
|
-
updateStrategy: "fingerprint",
|
|
278
|
-
userId: "user-123",
|
|
279
|
-
username: "alice",
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it("guards automatic insights to a single delivery attempt per runtime", async () => {
|
|
284
|
-
vi.useFakeTimers();
|
|
285
|
-
|
|
286
|
-
vi.stubGlobal(
|
|
287
|
-
"requestAnimationFrame",
|
|
288
|
-
vi.fn((callback: (timestamp: number) => void) => {
|
|
289
|
-
setTimeout(() => callback(0), 0);
|
|
290
|
-
return 1;
|
|
291
|
-
}),
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
mocks.readNotifyAppReady.mockReturnValue(
|
|
295
|
-
createNotifyReadResult(
|
|
296
|
-
{
|
|
297
|
-
fromBundleId: "bundle-a",
|
|
298
|
-
status: "RECOVERED",
|
|
299
|
-
toBundleId: "bundle-b",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
fromBundleId: "bundle-a",
|
|
303
|
-
toBundleId: "bundle-b",
|
|
304
|
-
type: "RECOVERED",
|
|
305
|
-
updateStrategy: "appVersion",
|
|
306
|
-
},
|
|
307
|
-
),
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
const { client, sendInsightsEvent } = createClient();
|
|
311
|
-
const { init } = await import("./wrap");
|
|
312
|
-
|
|
313
|
-
init({ insights: true, client });
|
|
314
|
-
init({ insights: true, client });
|
|
315
|
-
|
|
316
|
-
await vi.runOnlyPendingTimersAsync();
|
|
317
|
-
|
|
318
|
-
expect(sendInsightsEvent).toHaveBeenCalledTimes(1);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it("warns without interrupting app readiness when insights transport fails", async () => {
|
|
322
|
-
vi.useFakeTimers();
|
|
323
|
-
|
|
324
|
-
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
325
|
-
const error = new Error("Expected HTTP 204 from /events, received 404");
|
|
326
|
-
const onError = vi.fn();
|
|
327
|
-
const onNotifyAppReady = vi.fn();
|
|
328
|
-
vi.stubGlobal(
|
|
329
|
-
"requestAnimationFrame",
|
|
330
|
-
vi.fn((callback: (timestamp: number) => void) => {
|
|
331
|
-
setTimeout(() => callback(0), 0);
|
|
332
|
-
return 1;
|
|
333
|
-
}),
|
|
334
|
-
);
|
|
335
|
-
mocks.readNotifyAppReady.mockReturnValue(
|
|
336
|
-
createNotifyReadResult(
|
|
337
|
-
{
|
|
338
|
-
fromBundleId: "bundle-a",
|
|
339
|
-
status: "UPDATE_APPLIED",
|
|
340
|
-
toBundleId: "bundle-b",
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
fromBundleId: "bundle-a",
|
|
344
|
-
toBundleId: "bundle-b",
|
|
345
|
-
type: "UPDATE_APPLIED",
|
|
346
|
-
updateStrategy: "appVersion",
|
|
347
|
-
},
|
|
348
|
-
),
|
|
349
|
-
);
|
|
350
|
-
const { client } = createClient(vi.fn().mockRejectedValue(error));
|
|
351
|
-
const { init } = await import("./wrap");
|
|
352
|
-
|
|
353
|
-
init({
|
|
354
|
-
insights: true,
|
|
355
|
-
onError,
|
|
356
|
-
onNotifyAppReady,
|
|
357
|
-
client,
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
await vi.runOnlyPendingTimersAsync();
|
|
361
|
-
|
|
362
|
-
expect(onError).not.toHaveBeenCalled();
|
|
363
|
-
expect(warn).toHaveBeenCalledWith(
|
|
364
|
-
"[HotUpdater] Automatic notifyAppReady insights failed:",
|
|
365
|
-
error,
|
|
366
|
-
);
|
|
367
|
-
expect(onNotifyAppReady).toHaveBeenCalledWith({
|
|
368
|
-
fromBundleId: "bundle-a",
|
|
369
|
-
status: "UPDATE_APPLIED",
|
|
370
|
-
toBundleId: "bundle-b",
|
|
371
|
-
});
|
|
372
|
-
warn.mockRestore();
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it("does not accept a manual wrap HOC", async () => {
|
|
376
|
-
const { wrap } = await import("./wrap");
|
|
377
|
-
|
|
378
|
-
wrap({
|
|
379
|
-
client: createClient().client,
|
|
380
|
-
updateStrategy: "appVersion",
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it("preserves wrapped component prop inference", async () => {
|
|
385
|
-
const { wrap } = await import("./wrap");
|
|
386
|
-
const Component: ComponentType<{ title: string }> = () => null;
|
|
387
|
-
|
|
388
|
-
const WrappedComponent = wrap({
|
|
389
|
-
client: createClient().client,
|
|
390
|
-
updateStrategy: "appVersion",
|
|
391
|
-
})(Component);
|
|
392
|
-
|
|
393
|
-
const acceptsTitleProps: ComponentType<{ title: string }> =
|
|
394
|
-
WrappedComponent;
|
|
395
|
-
expect(acceptsTitleProps).toBe(WrappedComponent);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it("types public wrap options as automatic mode by default", () => {
|
|
399
|
-
const autoOptions = {
|
|
400
|
-
baseURL: "https://updates.example.com",
|
|
401
|
-
updateStrategy: "appVersion",
|
|
402
|
-
} satisfies HotUpdaterOptions;
|
|
403
|
-
|
|
404
|
-
expect(autoOptions.updateStrategy).toBe("appVersion");
|
|
405
|
-
});
|
|
406
|
-
});
|