@hot-updater/react-native 1.0.0-rc.4 → 1.0.0-rc.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +13 -2
- package/android/proguard-rules.pro +8 -2
- package/android/src/bridge/BridgeReactInstance.kt +38 -0
- package/android/src/bridgeless/BridgeReactInstance.kt +24 -0
- package/android/src/main/java/com/hotupdater/ActivityStartGate.kt +94 -0
- package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
- package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +1064 -844
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +50 -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 +46 -30
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +75 -192
- 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/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/newarch/JavaScriptExceptionHooks.kt +48 -0
- package/android/src/newarch/ReactIntegrationManager.kt +6 -32
- 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/android/src/oldarch/JavaScriptExceptionHooks.kt +71 -0
- package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
- package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +1032 -1116
- package/ios/HotUpdater/Internal/BundleMetadata.swift +61 -54
- 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 +32 -67
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +229 -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 +96 -0
- package/lib/commonjs/appReady.js.map +1 -0
- package/lib/commonjs/checkForUpdate.js +121 -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 +5 -14
- 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 +60 -0
- package/lib/commonjs/fetchUpdateResponse.js.map +1 -0
- package/lib/commonjs/httpClient.js +64 -95
- package/lib/commonjs/httpClient.js.map +1 -1
- package/lib/commonjs/index.js +355 -324
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.types.js +6 -0
- package/lib/commonjs/init.types.js.map +1 -0
- package/lib/commonjs/native.js +77 -63
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/pluginHost.js +41 -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 +145 -0
- package/lib/commonjs/updateError.js.map +1 -0
- package/lib/commonjs/wrap.js +46 -38
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/appReady.js +90 -0
- package/lib/module/appReady.js.map +1 -0
- package/lib/module/checkForUpdate.js +114 -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 +5 -14
- 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 +55 -0
- package/lib/module/fetchUpdateResponse.js.map +1 -0
- package/lib/module/httpClient.js +63 -94
- package/lib/module/httpClient.js.map +1 -1
- package/lib/module/index.js +335 -327
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.types.js +4 -0
- package/lib/module/init.types.js.map +1 -0
- package/lib/module/native.js +70 -56
- package/lib/module/native.js.map +1 -1
- package/lib/module/pluginHost.js +36 -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 +139 -0
- package/lib/module/updateError.js.map +1 -0
- package/lib/module/wrap.js +47 -38
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/appReady.d.ts +30 -0
- package/lib/typescript/commonjs/appReady.d.ts.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +20 -6
- 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 +5 -14
- 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 +5 -34
- package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +124 -116
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/init.types.d.ts +21 -0
- package/lib/typescript/commonjs/init.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/native.d.ts +32 -25
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/pluginHost.d.ts +8 -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 +35 -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 +2 -3
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.types.d.ts +13 -41
- package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
- package/lib/typescript/module/appReady.d.ts +30 -0
- package/lib/typescript/module/appReady.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +20 -6
- 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 +5 -14
- 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 +5 -34
- package/lib/typescript/module/httpClient.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +124 -116
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/init.types.d.ts +21 -0
- package/lib/typescript/module/init.types.d.ts.map +1 -0
- package/lib/typescript/module/native.d.ts +32 -25
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/pluginHost.d.ts +8 -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 +35 -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 +2 -3
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/lib/typescript/module/wrap.types.d.ts +13 -41
- package/lib/typescript/module/wrap.types.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/appReady.ts +147 -0
- package/src/checkForUpdate.ts +156 -89
- package/src/clientPlugin.ts +21 -0
- package/src/error.ts +5 -15
- package/src/fetchJSON.ts +14 -30
- package/src/fetchUpdateResponse.ts +60 -0
- package/src/httpClient.ts +89 -160
- package/src/index.ts +413 -425
- package/src/init.types.ts +24 -0
- package/src/native.ts +101 -105
- package/src/pluginHost.ts +52 -0
- package/src/releaseCatalogCache.ts +43 -172
- package/src/sdkVersion.ts +1 -1
- package/src/specs/NativeHotUpdater.ts +34 -48
- package/src/store.ts +2 -23
- package/src/types.ts +1 -1
- package/src/updateError.ts +167 -0
- package/src/wrap.tsx +60 -43
- package/src/wrap.types.ts +18 -46
- 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 -616
- 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 -615
- 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 -612
- 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/lib/module/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createLaunchReporter } from "./appReady.js";
|
|
4
|
+
import { checkForUpdate, reportUpdateError } from "./checkForUpdate.js";
|
|
4
5
|
import { createHttpClient } from "./httpClient.js";
|
|
5
|
-
import { addListener, getPublicActiveUpdateState, clearCrashHistory, getAppVersion, getBaseURL, getUpdateId, getChannel, getCohort, getCrashHistory, getDefaultChannel, getFingerprintHash, getInstallId, getManifest, getMinBundleId, isChannelSwitched, notifyAppReady, reload, resetChannel, setCohort, setReloadBehavior,
|
|
6
|
+
import { addListener, getPublicActiveUpdateState, getActiveUpdateState, getBundleId, clearCrashHistory, getAppVersion, getBaseURL, getUpdateId, getChannel, getCohort, getCrashHistory, getDefaultChannel, getFingerprintHash, getInstallId, getManifest, getMinBundleId, isChannelSwitched, notifyAppReady, reload, resetChannel, setCohort, setReloadBehavior, stageBundle } from "./native.js";
|
|
7
|
+
import { createAppPluginHost } from "./pluginHost.js";
|
|
6
8
|
import { hotUpdaterStore } from "./store.js";
|
|
7
|
-
import {
|
|
9
|
+
import { wrap } from "./wrap.js";
|
|
10
|
+
export { defineClientPlugin } from "./clientPlugin.js";
|
|
11
|
+
// The built-in Insights client plugin, for HotUpdater.init({ plugins }).
|
|
12
|
+
export { insights } from "@hot-updater/plugin-insights/client";
|
|
13
|
+
// The built-in Remote Config client plugin, for HotUpdater.init({ plugins }).
|
|
14
|
+
export { remoteConfig } from "@hot-updater/plugin-remote-config/client";
|
|
8
15
|
export * from "./store.js";
|
|
9
16
|
export { extractSignatureFailure, isSignatureVerificationError } from "./types.js";
|
|
10
17
|
/**
|
|
@@ -24,246 +31,204 @@ const registerGlobalGetBaseURL = () => {
|
|
|
24
31
|
|
|
25
32
|
// Call registration immediately on module load
|
|
26
33
|
registerGlobalGetBaseURL();
|
|
27
|
-
|
|
28
|
-
* Creates a HotUpdater client instance with all update management methods.
|
|
29
|
-
* This function is called once on module initialization to create a singleton instance.
|
|
30
|
-
*/
|
|
31
|
-
function createHotUpdaterClient() {
|
|
32
|
-
let configurationAPI = null;
|
|
33
|
-
let mixedConfigurationReported = false;
|
|
34
|
+
const createMissingNetworkConfigError = () => new Error(`[HotUpdater] baseURL must be provided.\n\n` + `Configure HotUpdater with the standard baseURL setup:\n\n` + ` export const hotUpdater = HotUpdater.init({\n` + ` baseURL: "<your-update-server-url>",\n` + ` });\n\n` + `See https://hot-updater.dev/docs/react-native-api/init`);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
36
|
+
/** The methods that read or change native state, the same on every instance. */
|
|
37
|
+
const nativeMethods = {
|
|
38
|
+
/**
|
|
39
|
+
* Reloads the app.
|
|
40
|
+
*/
|
|
41
|
+
reload,
|
|
42
|
+
/**
|
|
43
|
+
* Configures how `hotUpdater.reload()` behaves.
|
|
44
|
+
*
|
|
45
|
+
* This can be called unconditionally on both platforms.
|
|
46
|
+
* The default is `processRestart`.
|
|
47
|
+
*
|
|
48
|
+
* - `reload`: built-in React Native reload on both platforms
|
|
49
|
+
* - `processRestart`: Android process restart, iOS behaves like normal reload
|
|
50
|
+
* - `custom`: run a custom JS handler on both platforms
|
|
51
|
+
*/
|
|
52
|
+
setReloadBehavior,
|
|
53
|
+
/**
|
|
54
|
+
* Returns whether an update has finished downloading in this app session.
|
|
55
|
+
*
|
|
56
|
+
* When it returns true, calling `hotUpdater.reload()` (or restarting the app)
|
|
57
|
+
* will apply the downloaded update bundle.
|
|
58
|
+
*
|
|
59
|
+
* - Derived from `progress` reaching 1.0
|
|
60
|
+
* - Resets to false when a new download starts (progress < 1)
|
|
61
|
+
*
|
|
62
|
+
* @returns {boolean} True if a downloaded update is ready to apply
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* if (hotUpdater.isUpdateDownloaded()) {
|
|
66
|
+
* await hotUpdater.reload();
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
isUpdateDownloaded: () => hotUpdaterStore.getSnapshot().isUpdateDownloaded,
|
|
71
|
+
/**
|
|
72
|
+
* Fetches the current app version.
|
|
73
|
+
*/
|
|
74
|
+
getAppVersion,
|
|
75
|
+
/** Reads the active and stable Release/Bundle state. */
|
|
76
|
+
getActiveUpdateState: async () => getPublicActiveUpdateState(),
|
|
77
|
+
/**
|
|
78
|
+
* Returns the selected update ID, matching the ID shown in the console.
|
|
79
|
+
* A staged update can change this ID before the app reloads.
|
|
80
|
+
*/
|
|
81
|
+
getBundleId: getUpdateId,
|
|
82
|
+
/** Returns the minimum bundle ID based on the native app build time. */
|
|
83
|
+
getMinBundleId,
|
|
84
|
+
/**
|
|
85
|
+
* Fetches the current manifest for the active bundle.
|
|
86
|
+
*/
|
|
87
|
+
getManifest,
|
|
88
|
+
/**
|
|
89
|
+
* Fetches the current channel of the app.
|
|
90
|
+
*
|
|
91
|
+
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
92
|
+
*
|
|
93
|
+
* @returns {string} The current release channel of the app
|
|
94
|
+
* @default "production"
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const channel = hotUpdater.getChannel();
|
|
98
|
+
* console.log(`Current channel: ${channel}`);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
getChannel,
|
|
102
|
+
/**
|
|
103
|
+
* Fetches the build-time default channel of the app.
|
|
104
|
+
*
|
|
105
|
+
* This value does not change when a runtime channel override is active.
|
|
106
|
+
*
|
|
107
|
+
* @returns {string} The default release channel embedded in the app
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const defaultChannel = hotUpdater.getDefaultChannel();
|
|
111
|
+
* console.log(`Default channel: ${defaultChannel}`);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
getDefaultChannel,
|
|
115
|
+
/**
|
|
116
|
+
* Returns whether the app is currently using a runtime channel override.
|
|
117
|
+
*
|
|
118
|
+
* @returns {boolean} true when a non-default channel has been applied
|
|
119
|
+
*/
|
|
120
|
+
isChannelSwitched,
|
|
121
|
+
/**
|
|
122
|
+
* Sets the persisted cohort used for rollout calculations.
|
|
123
|
+
* Call `getCohort()` first if you need to restore the initial value later.
|
|
124
|
+
*/
|
|
125
|
+
setCohort,
|
|
126
|
+
/**
|
|
127
|
+
* Gets the persisted cohort used for rollout calculations.
|
|
128
|
+
*/
|
|
129
|
+
getCohort,
|
|
130
|
+
/**
|
|
131
|
+
* Adds a listener to HotUpdater events.
|
|
132
|
+
*
|
|
133
|
+
* @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
|
|
134
|
+
* @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
|
|
135
|
+
* @returns {() => void} A cleanup function that removes the event listener
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const unsubscribe = hotUpdater.addListener("onProgress", ({ progress }) => {
|
|
140
|
+
* console.log(`Update progress: ${progress * 100}%`);
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* // Unsubscribe when no longer needed
|
|
144
|
+
* unsubscribe();
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
addListener,
|
|
148
|
+
/**
|
|
149
|
+
* Clears the runtime channel override and restores the original bundle.
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise<boolean>} Resolves with true if reset was successful
|
|
152
|
+
*/
|
|
153
|
+
resetChannel: async () => {
|
|
154
|
+
const ok = await resetChannel();
|
|
155
|
+
if (ok) {
|
|
156
|
+
hotUpdaterStore.setState({
|
|
157
|
+
artifactType: null,
|
|
158
|
+
details: null,
|
|
159
|
+
isUpdateDownloaded: false,
|
|
160
|
+
progress: 0
|
|
161
|
+
});
|
|
81
162
|
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
* baseURL: "<your-update-server-url>",
|
|
144
|
-
* });
|
|
145
|
-
*
|
|
146
|
-
* export default App;
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
init: options => {
|
|
150
|
-
const normalizedOptions = normalizeInitOptions(options);
|
|
151
|
-
reportMixedConfiguration("init");
|
|
152
|
-
configureGlobal(normalizedOptions, options);
|
|
153
|
-
init(normalizedOptions);
|
|
163
|
+
return ok;
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Fetches the fingerprint of the app.
|
|
167
|
+
*
|
|
168
|
+
* @returns {string} The fingerprint of the app
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const fingerprint = hotUpdater.getFingerprintHash();
|
|
173
|
+
* console.log(`Fingerprint: ${fingerprint}`);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
getFingerprintHash,
|
|
177
|
+
/**
|
|
178
|
+
* Fetches the persisted install id for this app installation.
|
|
179
|
+
*/
|
|
180
|
+
getInstallId,
|
|
181
|
+
/**
|
|
182
|
+
* Reads the native launch report for the current process.
|
|
183
|
+
*/
|
|
184
|
+
notifyAppReady,
|
|
185
|
+
/**
|
|
186
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
187
|
+
* These bundles will be rejected if attempted to install again.
|
|
188
|
+
*
|
|
189
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const crashedBundles = hotUpdater.getCrashHistory();
|
|
194
|
+
* console.log("Crashed bundles:", crashedBundles);
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
getCrashHistory,
|
|
198
|
+
/**
|
|
199
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
200
|
+
* to be installed again.
|
|
201
|
+
*
|
|
202
|
+
* @returns {boolean} true if clearing was successful
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* // Clear crash history to allow retrying a previously failed bundle
|
|
207
|
+
* hotUpdater.clearCrashHistory();
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
clearCrashHistory
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/** What an instance's own methods use: its server, settings, and launch. */
|
|
214
|
+
|
|
215
|
+
/** The methods that use the instance's own configuration and plugins. */
|
|
216
|
+
const createConfiguredMethods = config => {
|
|
217
|
+
const check = options => checkForUpdate({
|
|
218
|
+
...options,
|
|
219
|
+
client: config.client,
|
|
220
|
+
emit: config.launch.emit,
|
|
221
|
+
requestHeaders: {
|
|
222
|
+
...config.requestHeaders,
|
|
223
|
+
...options.requestHeaders
|
|
154
224
|
},
|
|
225
|
+
requestTimeout: options.requestTimeout ?? config.requestTimeout,
|
|
226
|
+
onError: options.onError ?? config.onError
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
155
229
|
/**
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
reload,
|
|
159
|
-
/**
|
|
160
|
-
* Configures how `HotUpdater.reload()` behaves.
|
|
161
|
-
*
|
|
162
|
-
* This can be called unconditionally on both platforms.
|
|
163
|
-
* The default is `processRestart`.
|
|
164
|
-
*
|
|
165
|
-
* - `reload`: built-in React Native reload on both platforms
|
|
166
|
-
* - `processRestart`: Android process restart, iOS behaves like normal reload
|
|
167
|
-
* - `custom`: run a custom JS handler on both platforms
|
|
168
|
-
*/
|
|
169
|
-
setReloadBehavior,
|
|
170
|
-
/**
|
|
171
|
-
* Returns whether an update has finished downloading in this app session.
|
|
172
|
-
*
|
|
173
|
-
* When it returns true, calling `HotUpdater.reload()` (or restarting the app)
|
|
174
|
-
* will apply the downloaded update bundle.
|
|
175
|
-
*
|
|
176
|
-
* - Derived from `progress` reaching 1.0
|
|
177
|
-
* - Resets to false when a new download starts (progress < 1)
|
|
178
|
-
*
|
|
179
|
-
* @returns {boolean} True if a downloaded update is ready to apply
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* if (HotUpdater.isUpdateDownloaded()) {
|
|
183
|
-
* await HotUpdater.reload();
|
|
184
|
-
* }
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
isUpdateDownloaded: () => hotUpdaterStore.getSnapshot().isUpdateDownloaded,
|
|
188
|
-
/**
|
|
189
|
-
* Fetches the current app version.
|
|
190
|
-
*/
|
|
191
|
-
getAppVersion,
|
|
192
|
-
/** Reads the active and stable Release/Bundle state. */
|
|
193
|
-
getActiveUpdateState: async () => getPublicActiveUpdateState(),
|
|
194
|
-
/**
|
|
195
|
-
* Returns the selected update ID, matching the ID shown in the console.
|
|
196
|
-
* A staged update can change this ID before the app reloads.
|
|
197
|
-
*/
|
|
198
|
-
getBundleId: getUpdateId,
|
|
199
|
-
/** Returns the minimum bundle ID based on the native app build time. */
|
|
200
|
-
getMinBundleId,
|
|
201
|
-
/**
|
|
202
|
-
* Fetches the current manifest for the active bundle.
|
|
203
|
-
*/
|
|
204
|
-
getManifest,
|
|
205
|
-
/**
|
|
206
|
-
* Fetches the current channel of the app.
|
|
207
|
-
*
|
|
208
|
-
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
209
|
-
*
|
|
210
|
-
* @returns {string} The current release channel of the app
|
|
211
|
-
* @default "production"
|
|
212
|
-
* @example
|
|
213
|
-
* ```ts
|
|
214
|
-
* const channel = HotUpdater.getChannel();
|
|
215
|
-
* console.log(`Current channel: ${channel}`);
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
getChannel,
|
|
219
|
-
/**
|
|
220
|
-
* Fetches the build-time default channel of the app.
|
|
221
|
-
*
|
|
222
|
-
* This value does not change when a runtime channel override is active.
|
|
223
|
-
*
|
|
224
|
-
* @returns {string} The default release channel embedded in the app
|
|
225
|
-
* @example
|
|
226
|
-
* ```ts
|
|
227
|
-
* const defaultChannel = HotUpdater.getDefaultChannel();
|
|
228
|
-
* console.log(`Default channel: ${defaultChannel}`);
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
getDefaultChannel,
|
|
232
|
-
/**
|
|
233
|
-
* Returns whether the app is currently using a runtime channel override.
|
|
234
|
-
*
|
|
235
|
-
* @returns {boolean} true when a non-default channel has been applied
|
|
236
|
-
*/
|
|
237
|
-
isChannelSwitched,
|
|
238
|
-
/**
|
|
239
|
-
* Sets the persisted cohort used for rollout calculations.
|
|
240
|
-
* Call `getCohort()` first if you need to restore the initial value later.
|
|
241
|
-
*/
|
|
242
|
-
setCohort,
|
|
243
|
-
/**
|
|
244
|
-
* Gets the persisted cohort used for rollout calculations.
|
|
245
|
-
*/
|
|
246
|
-
getCohort,
|
|
247
|
-
/**
|
|
248
|
-
* Adds a listener to HotUpdater events.
|
|
249
|
-
*
|
|
250
|
-
* @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
|
|
251
|
-
* @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
|
|
252
|
-
* @returns {() => void} A cleanup function that removes the event listener
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
|
|
257
|
-
* console.log(`Update progress: ${progress * 100}%`);
|
|
258
|
-
* });
|
|
259
|
-
*
|
|
260
|
-
* // Unsubscribe when no longer needed
|
|
261
|
-
* unsubscribe();
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
addListener,
|
|
265
|
-
/**
|
|
266
|
-
* Manually checks for updates.
|
|
230
|
+
* Checks for an update, with this instance's server and request
|
|
231
|
+
* settings.
|
|
267
232
|
*
|
|
268
233
|
* @param {Object} config - Update check configuration
|
|
269
234
|
* @param {string} [config.channel] - Optional channel override for this update check
|
|
@@ -273,7 +238,7 @@ function createHotUpdaterClient() {
|
|
|
273
238
|
*
|
|
274
239
|
* @example
|
|
275
240
|
* ```ts
|
|
276
|
-
* const updateInfo = await
|
|
241
|
+
* const updateInfo = await hotUpdater.checkForUpdate({
|
|
277
242
|
* updateStrategy: "appVersion",
|
|
278
243
|
* requestHeaders: {
|
|
279
244
|
* "x-api-key": "<your-api-key>",
|
|
@@ -287,37 +252,21 @@ function createHotUpdaterClient() {
|
|
|
287
252
|
*
|
|
288
253
|
* await updateInfo.updateBundle();
|
|
289
254
|
* if (updateInfo.shouldForceUpdate) {
|
|
290
|
-
* await
|
|
255
|
+
* await hotUpdater.reload();
|
|
291
256
|
* }
|
|
292
257
|
* ```
|
|
293
258
|
*/
|
|
294
|
-
checkForUpdate:
|
|
295
|
-
const client = ensureGlobalClient("checkForUpdate");
|
|
296
|
-
const mergedConfig = {
|
|
297
|
-
...config,
|
|
298
|
-
insights: globalConfig.insights,
|
|
299
|
-
client,
|
|
300
|
-
requestHeaders: {
|
|
301
|
-
...globalConfig.requestHeaders,
|
|
302
|
-
...config.requestHeaders
|
|
303
|
-
},
|
|
304
|
-
requestTimeout: config.requestTimeout ?? globalConfig.requestTimeout,
|
|
305
|
-
onError: config.onError ?? globalConfig.onError
|
|
306
|
-
};
|
|
307
|
-
return checkForUpdate(mergedConfig);
|
|
308
|
-
},
|
|
259
|
+
checkForUpdate: check,
|
|
309
260
|
/**
|
|
310
261
|
* Updates the bundle of the app.
|
|
311
262
|
*
|
|
312
263
|
* @param {UpdateBundleParams} params - Parameters object required for bundle update
|
|
313
264
|
* @param {string} params.bundleId - The bundle ID of the app
|
|
314
|
-
* @param {string|null} params.fileUrl - The URL of the zip file
|
|
315
|
-
*
|
|
316
265
|
* @returns {Promise<boolean>} Whether the update was successful
|
|
317
266
|
*
|
|
318
267
|
* @example
|
|
319
268
|
* ```ts
|
|
320
|
-
* const updateInfo = await
|
|
269
|
+
* const updateInfo = await hotUpdater.checkForUpdate({
|
|
321
270
|
* updateStrategy: "appVersion",
|
|
322
271
|
* requestHeaders: {
|
|
323
272
|
* "x-api-key": "<your-api-key>",
|
|
@@ -332,84 +281,143 @@ function createHotUpdaterClient() {
|
|
|
332
281
|
*
|
|
333
282
|
* await updateInfo.updateBundle();
|
|
334
283
|
* if (updateInfo.shouldForceUpdate) {
|
|
335
|
-
* await
|
|
284
|
+
* await hotUpdater.reload();
|
|
336
285
|
* }
|
|
337
286
|
* ```
|
|
338
287
|
*/
|
|
339
|
-
updateBundle: params => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
288
|
+
updateBundle: async params => {
|
|
289
|
+
const fromBundleId = getBundleId();
|
|
290
|
+
const state = getActiveUpdateState();
|
|
291
|
+
const active = state.activeSelection;
|
|
292
|
+
const fromReleaseId = active?.bundleId === fromBundleId ? active.releaseId : state.stableSelection?.bundleId === fromBundleId ? state.stableSelection.releaseId : null;
|
|
293
|
+
const channel = params.channel ?? getChannel();
|
|
294
|
+
const strategyOf = scopeKey => scopeKey?.startsWith("v1:fingerprint:") ? "fingerprint" : "appVersion";
|
|
295
|
+
let delivery;
|
|
296
|
+
try {
|
|
297
|
+
delivery = await stageBundle(params);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
reportUpdateError(config.launch.emit, error, "download", undefined, {
|
|
300
|
+
bundleId: fromBundleId,
|
|
301
|
+
channel,
|
|
302
|
+
targetBundleId: params.bundleId,
|
|
303
|
+
targetReleaseId: params.selection?.releaseId ?? null,
|
|
304
|
+
updateStrategy: strategyOf(params.selection?.scopeKey)
|
|
305
|
+
});
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
if (delivery !== null && params.bundleId !== fromBundleId) {
|
|
309
|
+
config.launch.emit("onBundleDownloaded", () => {
|
|
310
|
+
const selection = getActiveUpdateState().activeSelection;
|
|
311
|
+
return {
|
|
312
|
+
channel,
|
|
313
|
+
fromBundleId,
|
|
314
|
+
fromReleaseId,
|
|
315
|
+
toBundleId: params.bundleId,
|
|
316
|
+
toReleaseId: selection?.releaseId ?? null,
|
|
317
|
+
updateStrategy: strategyOf(selection?.scopeKey),
|
|
318
|
+
...delivery
|
|
319
|
+
};
|
|
358
320
|
});
|
|
359
321
|
}
|
|
360
|
-
return
|
|
322
|
+
return true;
|
|
361
323
|
},
|
|
362
324
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* ```ts
|
|
369
|
-
* const fingerprint = HotUpdater.getFingerprintHash();
|
|
370
|
-
* console.log(`Fingerprint: ${fingerprint}`);
|
|
371
|
-
* ```
|
|
372
|
-
*/
|
|
373
|
-
getFingerprintHash,
|
|
374
|
-
/**
|
|
375
|
-
* Fetches the persisted install id for this app installation.
|
|
376
|
-
*/
|
|
377
|
-
getInstallId,
|
|
378
|
-
/**
|
|
379
|
-
* Persists nullable user identity fields associated with this installation.
|
|
380
|
-
*/
|
|
381
|
-
setUser,
|
|
382
|
-
/**
|
|
383
|
-
* Reads the native launch report for the current process.
|
|
384
|
-
*/
|
|
385
|
-
notifyAppReady,
|
|
386
|
-
/**
|
|
387
|
-
* Gets the list of bundle IDs that have been marked as crashed.
|
|
388
|
-
* These bundles will be rejected if attempted to install again.
|
|
389
|
-
*
|
|
390
|
-
* @returns {string[]} Array of crashed bundle IDs
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* ```ts
|
|
394
|
-
* const crashedBundles = HotUpdater.getCrashHistory();
|
|
395
|
-
* console.log("Crashed bundles:", crashedBundles);
|
|
396
|
-
* ```
|
|
397
|
-
*/
|
|
398
|
-
getCrashHistory,
|
|
399
|
-
/**
|
|
400
|
-
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
401
|
-
* to be installed again.
|
|
402
|
-
*
|
|
403
|
-
* @returns {boolean} true if clearing was successful
|
|
325
|
+
* Wraps the app's root: when it mounts, it checks for an update with
|
|
326
|
+
* this instance's configuration, downloads one, and reloads for a
|
|
327
|
+
* forced update. A `fallbackComponent` replaces the root until the
|
|
328
|
+
* check and a forced update finish.
|
|
404
329
|
*
|
|
405
330
|
* @example
|
|
406
|
-
* ```
|
|
407
|
-
*
|
|
408
|
-
*
|
|
331
|
+
* ```tsx
|
|
332
|
+
* export default hotUpdater.wrap({
|
|
333
|
+
* updateStrategy: "appVersion",
|
|
334
|
+
* fallbackComponent: ({ progress }) => <Splash progress={progress} />,
|
|
335
|
+
* })(App);
|
|
409
336
|
* ```
|
|
410
337
|
*/
|
|
411
|
-
|
|
338
|
+
wrap: options => wrap({
|
|
339
|
+
...options,
|
|
340
|
+
checkForUpdate: check,
|
|
341
|
+
appReady: () => config.launch.appReady,
|
|
342
|
+
onError: error => config.onError?.(error)
|
|
343
|
+
})
|
|
412
344
|
};
|
|
413
|
-
}
|
|
414
|
-
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/** The methods of every instance `HotUpdater.init` returns. */
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The instance `HotUpdater.init` returns: HotUpdater's methods, and each
|
|
351
|
+
* plugin's API under the plugin's id.
|
|
352
|
+
*/
|
|
353
|
+
|
|
354
|
+
export const HotUpdater = {
|
|
355
|
+
/**
|
|
356
|
+
* Creates the app's HotUpdater instance: the update server, its request
|
|
357
|
+
* settings, and the client plugins. Each call returns an independent
|
|
358
|
+
* instance with its own configuration and plugins, so create one, at the
|
|
359
|
+
* top level of a module, and export it.
|
|
360
|
+
*
|
|
361
|
+
* The instance has every HotUpdater method, such as `wrap`,
|
|
362
|
+
* `checkForUpdate`, and `reload`, and each plugin's API under the
|
|
363
|
+
* plugin's id, such as `hotUpdater.remoteConfig` for `remoteConfig()`.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* export const hotUpdater = HotUpdater.init({
|
|
368
|
+
* baseURL: "<your-update-server-url>",
|
|
369
|
+
* plugins: [remoteConfig({ defaults: { welcome_message: "Hi" } })],
|
|
370
|
+
* });
|
|
371
|
+
*
|
|
372
|
+
* hotUpdater.remoteConfig.getString("welcome_message");
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
init: options => {
|
|
376
|
+
const {
|
|
377
|
+
baseURL,
|
|
378
|
+
plugins,
|
|
379
|
+
requestHeaders,
|
|
380
|
+
requestTimeout,
|
|
381
|
+
onError,
|
|
382
|
+
onNotifyAppReady
|
|
383
|
+
} = options;
|
|
384
|
+
if (!baseURL) throw createMissingNetworkConfigError();
|
|
385
|
+
const host = createAppPluginHost();
|
|
386
|
+
const launch = createLaunchReporter(host);
|
|
387
|
+
const instance = {
|
|
388
|
+
...nativeMethods,
|
|
389
|
+
...createConfiguredMethods({
|
|
390
|
+
client: createHttpClient(baseURL, response => {
|
|
391
|
+
launch.emit("onHttpResponse", () => response);
|
|
392
|
+
}),
|
|
393
|
+
requestHeaders,
|
|
394
|
+
requestTimeout,
|
|
395
|
+
onError,
|
|
396
|
+
launch
|
|
397
|
+
})
|
|
398
|
+
};
|
|
399
|
+
const reservedIds = new Set([...Object.keys(instance), "init"]);
|
|
400
|
+
for (const plugin of plugins ?? []) {
|
|
401
|
+
if (reservedIds.has(plugin.id)) {
|
|
402
|
+
throw new Error(`[HotUpdater] A plugin cannot use the id "${plugin.id}": the HotUpdater instance has its own "${plugin.id}".`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Plugins are set up before the instance reads the launch they observe.
|
|
407
|
+
const apis = host.configurePlugins(plugins, {
|
|
408
|
+
baseURL,
|
|
409
|
+
requestHeaders,
|
|
410
|
+
requestTimeout,
|
|
411
|
+
onError
|
|
412
|
+
});
|
|
413
|
+
void launch.read({
|
|
414
|
+
onNotifyAppReady,
|
|
415
|
+
onError
|
|
416
|
+
});
|
|
417
|
+
return Object.freeze({
|
|
418
|
+
...instance,
|
|
419
|
+
...apis
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
};
|
|
415
423
|
//# sourceMappingURL=index.js.map
|