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