@hot-updater/react-native 0.23.1 → 0.24.0
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/src/main/java/com/hotupdater/BundleFileStorageService.kt +393 -49
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +204 -0
- package/android/src/main/java/com/hotupdater/HotUpdater.kt +48 -36
- package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +134 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +168 -95
- package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +15 -3
- package/android/src/main/java/com/hotupdater/SignatureVerifier.kt +17 -12
- package/android/src/newarch/HotUpdaterModule.kt +88 -23
- package/android/src/oldarch/HotUpdaterModule.kt +89 -22
- package/android/src/oldarch/HotUpdaterSpec.kt +6 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +401 -77
- package/ios/HotUpdater/Internal/BundleMetadata.swift +177 -0
- package/ios/HotUpdater/Internal/HotUpdater.mm +213 -47
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +96 -25
- package/ios/HotUpdater/Internal/SignatureVerifier.swift +35 -29
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +2 -2
- package/ios/HotUpdater/Public/HotUpdater.h +8 -2
- package/lib/commonjs/checkForUpdate.js +31 -28
- package/lib/commonjs/checkForUpdate.js.map +1 -1
- package/lib/commonjs/error.js +45 -1
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/fetchUpdateInfo.js +7 -45
- package/lib/commonjs/fetchUpdateInfo.js.map +1 -1
- package/lib/commonjs/index.js +237 -208
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native.js +103 -3
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/wrap.js +39 -1
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/checkForUpdate.js +32 -26
- package/lib/module/checkForUpdate.js.map +1 -1
- package/lib/module/error.js +45 -0
- package/lib/module/error.js.map +1 -1
- package/lib/module/fetchUpdateInfo.js +7 -45
- package/lib/module/fetchUpdateInfo.js.map +1 -1
- package/lib/module/index.js +238 -203
- package/lib/module/index.js.map +1 -1
- package/lib/module/native.js +87 -2
- package/lib/module/native.js.map +1 -1
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/wrap.js +40 -2
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/checkForUpdate.d.ts +11 -13
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/error.d.ts +120 -0
- package/lib/typescript/commonjs/error.d.ts.map +1 -1
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts +3 -5
- package/lib/typescript/commonjs/fetchUpdateInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +35 -41
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +58 -2
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +62 -0
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.d.ts +76 -5
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/module/checkForUpdate.d.ts +11 -13
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/module/error.d.ts +120 -0
- package/lib/typescript/module/error.d.ts.map +1 -1
- package/lib/typescript/module/fetchUpdateInfo.d.ts +3 -5
- package/lib/typescript/module/fetchUpdateInfo.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +35 -41
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +58 -2
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +62 -0
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/wrap.d.ts +76 -5
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/package.json +7 -7
- package/plugin/build/withHotUpdater.js +3 -3
- package/src/checkForUpdate.ts +51 -40
- package/src/error.ts +153 -0
- package/src/fetchUpdateInfo.ts +10 -58
- package/src/index.ts +283 -206
- package/src/native.ts +88 -2
- package/src/specs/NativeHotUpdater.ts +63 -0
- package/src/wrap.tsx +131 -9
- package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +0 -52
- package/ios/HotUpdater/Internal/HotUpdaterFactory.swift +0 -24
- package/lib/commonjs/runUpdateProcess.js +0 -69
- package/lib/commonjs/runUpdateProcess.js.map +0 -1
- package/lib/module/runUpdateProcess.js +0 -64
- package/lib/module/runUpdateProcess.js.map +0 -1
- package/lib/typescript/commonjs/runUpdateProcess.d.ts +0 -49
- package/lib/typescript/commonjs/runUpdateProcess.d.ts.map +0 -1
- package/lib/typescript/module/runUpdateProcess.d.ts +0 -49
- package/lib/typescript/module/runUpdateProcess.d.ts.map +0 -1
- package/src/runUpdateProcess.ts +0 -80
|
@@ -19,8 +19,71 @@ export interface UpdateBundleParams {
|
|
|
19
19
|
export interface Spec extends TurboModule {
|
|
20
20
|
// Methods
|
|
21
21
|
reload(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Downloads and applies a bundle update.
|
|
24
|
+
*
|
|
25
|
+
* @param params - Update bundle parameters
|
|
26
|
+
* @returns Promise that resolves to true if successful
|
|
27
|
+
* @throws {HotUpdaterErrorCode} Rejects with one of the following error codes:
|
|
28
|
+
*
|
|
29
|
+
* Parameter validation:
|
|
30
|
+
* - MISSING_BUNDLE_ID: Missing or empty bundleId
|
|
31
|
+
* - INVALID_FILE_URL: Invalid fileUrl provided
|
|
32
|
+
*
|
|
33
|
+
* Bundle storage:
|
|
34
|
+
* - DIRECTORY_CREATION_FAILED: Failed to create bundle directory
|
|
35
|
+
* - DOWNLOAD_FAILED: Failed to download bundle
|
|
36
|
+
* - INCOMPLETE_DOWNLOAD: Download incomplete (size mismatch)
|
|
37
|
+
* - EXTRACTION_FORMAT_ERROR: Invalid or corrupted archive format
|
|
38
|
+
* - INVALID_BUNDLE: Bundle missing required platform files
|
|
39
|
+
* - INSUFFICIENT_DISK_SPACE: Insufficient disk space
|
|
40
|
+
* - MOVE_OPERATION_FAILED: Failed to move bundle files
|
|
41
|
+
* - BUNDLE_IN_CRASHED_HISTORY: Bundle was previously marked as crashed
|
|
42
|
+
*
|
|
43
|
+
* Signature:
|
|
44
|
+
* - SIGNATURE_VERIFICATION_FAILED: Any signature/hash verification failure
|
|
45
|
+
*
|
|
46
|
+
* Internal:
|
|
47
|
+
* - SELF_DEALLOCATED: Native object was deallocated (iOS)
|
|
48
|
+
* - UNKNOWN_ERROR: Fallback for rare or platform-specific errors
|
|
49
|
+
*
|
|
50
|
+
* Note: iOS normalizes rare signature/storage errors to SIGNATURE_VERIFICATION_FAILED
|
|
51
|
+
* or UNKNOWN_ERROR to keep the JS error surface small.
|
|
52
|
+
*/
|
|
22
53
|
updateBundle(params: UpdateBundleParams): Promise<boolean>;
|
|
23
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Notifies the native side that the app has successfully started with the given bundle.
|
|
57
|
+
* If the bundle matches the staging bundle, it promotes to stable.
|
|
58
|
+
*
|
|
59
|
+
* @param params - Parameters containing the bundle ID
|
|
60
|
+
* @returns Object with status and optional crashedBundleId
|
|
61
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
62
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
63
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
64
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
65
|
+
*/
|
|
66
|
+
notifyAppReady(params: { bundleId: string }): {
|
|
67
|
+
status: "PROMOTED" | "RECOVERED" | "STABLE";
|
|
68
|
+
crashedBundleId?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
73
|
+
* These bundles will be rejected if attempted to install again.
|
|
74
|
+
*
|
|
75
|
+
* @returns Array of crashed bundle IDs
|
|
76
|
+
*/
|
|
77
|
+
getCrashHistory(): string[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
81
|
+
* to be installed again.
|
|
82
|
+
*
|
|
83
|
+
* @returns true if clearing was successful
|
|
84
|
+
*/
|
|
85
|
+
clearCrashHistory(): boolean;
|
|
86
|
+
|
|
24
87
|
// EventEmitter
|
|
25
88
|
addListener(eventName: string): void;
|
|
26
89
|
removeListeners(count: number): void;
|
package/src/wrap.tsx
CHANGED
|
@@ -1,17 +1,93 @@
|
|
|
1
1
|
import React, { useEffect, useLayoutEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { checkForUpdate } from "./checkForUpdate";
|
|
3
3
|
import type { HotUpdaterError } from "./error";
|
|
4
4
|
import { useEventCallback } from "./hooks/useEventCallback";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
getBundleId,
|
|
7
|
+
type NotifyAppReadyResult,
|
|
8
|
+
notifyAppReady as nativeNotifyAppReady,
|
|
9
|
+
reload,
|
|
10
|
+
} from "./native";
|
|
7
11
|
import { useHotUpdaterStore } from "./store";
|
|
8
12
|
|
|
13
|
+
export interface RunUpdateProcessResponse {
|
|
14
|
+
status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
|
|
15
|
+
shouldForceUpdate: boolean;
|
|
16
|
+
message: string | null;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
type UpdateStatus =
|
|
10
21
|
| "CHECK_FOR_UPDATE"
|
|
11
22
|
| "UPDATING"
|
|
12
23
|
| "UPDATE_PROCESS_COMPLETED";
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Common options shared between auto and manual update modes
|
|
27
|
+
*/
|
|
28
|
+
interface CommonHotUpdaterOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Base URL for update server
|
|
31
|
+
* @example "https://update.example.com"
|
|
32
|
+
*/
|
|
33
|
+
baseURL: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Custom request headers for update checks
|
|
37
|
+
*/
|
|
38
|
+
requestHeaders?: Record<string, string>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Request timeout in milliseconds
|
|
42
|
+
* @default 5000
|
|
43
|
+
*/
|
|
44
|
+
requestTimeout?: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Callback invoked when the app is ready and bundle verification completes.
|
|
48
|
+
* Provides information about bundle promotion, recovery from crashes, or stable state.
|
|
49
|
+
*
|
|
50
|
+
* @param result - Bundle state information
|
|
51
|
+
* @param result.status - Current bundle state:
|
|
52
|
+
* - "PROMOTED": Staging bundle was promoted to stable (new update applied)
|
|
53
|
+
* - "RECOVERED": App recovered from a crash, rollback occurred
|
|
54
|
+
* - "STABLE": No changes, bundle is stable
|
|
55
|
+
* @param result.crashedBundleId - Present only when status is "RECOVERED"
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* HotUpdater.wrap({
|
|
60
|
+
* baseURL: "https://api.example.com",
|
|
61
|
+
* updateMode: "manual",
|
|
62
|
+
* onNotifyAppReady: ({ status, crashedBundleId }) => {
|
|
63
|
+
* if (status === "RECOVERED") {
|
|
64
|
+
* analytics.track('bundle_rollback', { crashedBundleId });
|
|
65
|
+
* } else if (status === "PROMOTED") {
|
|
66
|
+
* analytics.track('bundle_promoted');
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* })(App);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
onNotifyAppReady?: (result: NotifyAppReadyResult) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface AutoUpdateOptions extends CommonHotUpdaterOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Update strategy
|
|
78
|
+
* - "fingerprint": Use fingerprint hash to check for updates
|
|
79
|
+
* - "appVersion": Use app version to check for updates
|
|
80
|
+
*/
|
|
81
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Update mode
|
|
85
|
+
* - "auto": Automatically check and download updates
|
|
86
|
+
*/
|
|
87
|
+
updateMode: "auto";
|
|
88
|
+
|
|
89
|
+
onError?: (error: HotUpdaterError | Error | unknown) => void;
|
|
90
|
+
|
|
15
91
|
/**
|
|
16
92
|
* Component to show while downloading a new bundle update.
|
|
17
93
|
*
|
|
@@ -22,7 +98,8 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
22
98
|
*
|
|
23
99
|
* ```tsx
|
|
24
100
|
* HotUpdater.wrap({
|
|
25
|
-
*
|
|
101
|
+
* baseURL: "<update-server-url>",
|
|
102
|
+
* updateStrategy: "appVersion",
|
|
26
103
|
* fallbackComponent: ({ progress = 0 }) => (
|
|
27
104
|
* <View style={styles.container}>
|
|
28
105
|
* <Text style={styles.text}>Updating... {progress}%</Text>
|
|
@@ -38,8 +115,9 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
38
115
|
progress: number;
|
|
39
116
|
message: string | null;
|
|
40
117
|
}>;
|
|
41
|
-
|
|
118
|
+
|
|
42
119
|
onProgress?: (progress: number) => void;
|
|
120
|
+
|
|
43
121
|
/**
|
|
44
122
|
* When a force update exists, the app will automatically reload.
|
|
45
123
|
* If `false`, When a force update exists, the app will not reload. `shouldForceUpdate` will be returned as `true` in `onUpdateProcessCompleted`.
|
|
@@ -47,6 +125,7 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
47
125
|
* @default true
|
|
48
126
|
*/
|
|
49
127
|
reloadOnForceUpdate?: boolean;
|
|
128
|
+
|
|
50
129
|
/**
|
|
51
130
|
* Callback function that is called when the update process is completed.
|
|
52
131
|
*
|
|
@@ -55,9 +134,39 @@ export interface HotUpdaterOptions extends CheckForUpdateOptions {
|
|
|
55
134
|
onUpdateProcessCompleted?: (response: RunUpdateProcessResponse) => void;
|
|
56
135
|
}
|
|
57
136
|
|
|
137
|
+
export interface ManualUpdateOptions extends CommonHotUpdaterOptions {
|
|
138
|
+
/**
|
|
139
|
+
* Update mode
|
|
140
|
+
* - "manual": Only notify app ready, user manually calls checkForUpdate()
|
|
141
|
+
*/
|
|
142
|
+
updateMode: "manual";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type HotUpdaterOptions = AutoUpdateOptions | ManualUpdateOptions;
|
|
146
|
+
|
|
58
147
|
export function wrap<P extends React.JSX.IntrinsicAttributes = object>(
|
|
59
148
|
options: HotUpdaterOptions,
|
|
60
149
|
): (WrappedComponent: React.ComponentType<P>) => React.ComponentType<P> {
|
|
150
|
+
if (options.updateMode === "manual") {
|
|
151
|
+
return (WrappedComponent: React.ComponentType<P>) => {
|
|
152
|
+
const ManualHOC: React.FC<P> = (props: P) => {
|
|
153
|
+
useLayoutEffect(() => {
|
|
154
|
+
try {
|
|
155
|
+
const result = nativeNotifyAppReady();
|
|
156
|
+
options.onNotifyAppReady?.(result);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.warn("[HotUpdater] Failed to notify app ready:", e);
|
|
159
|
+
}
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
return <WrappedComponent {...props} />;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
return ManualHOC as React.ComponentType<P>;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// updateMode: "auto"
|
|
61
170
|
const { reloadOnForceUpdate = true, ...restOptions } = options;
|
|
62
171
|
|
|
63
172
|
return (WrappedComponent: React.ComponentType<P>) => {
|
|
@@ -73,10 +182,12 @@ export function wrap<P extends React.JSX.IntrinsicAttributes = object>(
|
|
|
73
182
|
setUpdateStatus("CHECK_FOR_UPDATE");
|
|
74
183
|
|
|
75
184
|
const updateInfo = await checkForUpdate({
|
|
76
|
-
|
|
185
|
+
baseURL: restOptions.baseURL,
|
|
186
|
+
updateStrategy: restOptions.updateStrategy,
|
|
77
187
|
requestHeaders: restOptions.requestHeaders,
|
|
188
|
+
requestTimeout: restOptions.requestTimeout,
|
|
78
189
|
onError: restOptions.onError,
|
|
79
|
-
});
|
|
190
|
+
} as Parameters<typeof checkForUpdate>[0]);
|
|
80
191
|
|
|
81
192
|
setMessage(updateInfo?.message ?? null);
|
|
82
193
|
|
|
@@ -92,7 +203,7 @@ export function wrap<P extends React.JSX.IntrinsicAttributes = object>(
|
|
|
92
203
|
}
|
|
93
204
|
|
|
94
205
|
if (updateInfo.shouldForceUpdate === false) {
|
|
95
|
-
void updateInfo.updateBundle().catch((error) => {
|
|
206
|
+
void updateInfo.updateBundle().catch((error: unknown) => {
|
|
96
207
|
restOptions.onError?.(error);
|
|
97
208
|
});
|
|
98
209
|
|
|
@@ -137,6 +248,17 @@ export function wrap<P extends React.JSX.IntrinsicAttributes = object>(
|
|
|
137
248
|
restOptions.onProgress?.(progress);
|
|
138
249
|
}, [progress]);
|
|
139
250
|
|
|
251
|
+
// Notify native side that app is ready (JS bundle fully loaded)
|
|
252
|
+
useLayoutEffect(() => {
|
|
253
|
+
try {
|
|
254
|
+
const result = nativeNotifyAppReady();
|
|
255
|
+
restOptions.onNotifyAppReady?.(result);
|
|
256
|
+
} catch (e) {
|
|
257
|
+
console.warn("[HotUpdater] Failed to notify app ready:", e);
|
|
258
|
+
}
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
// Start update check
|
|
140
262
|
useLayoutEffect(() => {
|
|
141
263
|
initHotUpdater();
|
|
142
264
|
}, []);
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
package com.hotupdater
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Factory for creating HotUpdaterImpl instances with proper dependency injection
|
|
7
|
-
*/
|
|
8
|
-
object HotUpdaterFactory {
|
|
9
|
-
@Volatile
|
|
10
|
-
private var instance: HotUpdaterImpl? = null
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Gets the singleton instance of HotUpdaterImpl
|
|
14
|
-
* @param context Application context
|
|
15
|
-
* @return HotUpdaterImpl instance
|
|
16
|
-
*/
|
|
17
|
-
fun getInstance(context: Context): HotUpdaterImpl =
|
|
18
|
-
instance ?: synchronized(this) {
|
|
19
|
-
instance ?: createHotUpdaterImpl(context).also { instance = it }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Creates a new HotUpdaterImpl instance with all dependencies
|
|
24
|
-
* @param context Application context
|
|
25
|
-
* @return New HotUpdaterImpl instance
|
|
26
|
-
*/
|
|
27
|
-
private fun createHotUpdaterImpl(context: Context): HotUpdaterImpl {
|
|
28
|
-
val appContext = context.applicationContext
|
|
29
|
-
|
|
30
|
-
// Get isolation key using the utility method
|
|
31
|
-
val isolationKey = HotUpdaterImpl.getIsolationKey(appContext)
|
|
32
|
-
|
|
33
|
-
// Create services
|
|
34
|
-
val fileSystem = FileManagerService(appContext)
|
|
35
|
-
val preferences = VersionedPreferencesService(appContext, isolationKey)
|
|
36
|
-
val downloadService = OkHttpDownloadService()
|
|
37
|
-
val decompressService = DecompressService()
|
|
38
|
-
|
|
39
|
-
// Create bundle storage with dependencies
|
|
40
|
-
val bundleStorage =
|
|
41
|
-
BundleFileStorageService(
|
|
42
|
-
appContext,
|
|
43
|
-
fileSystem,
|
|
44
|
-
downloadService,
|
|
45
|
-
decompressService,
|
|
46
|
-
preferences,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
// Create and return the implementation
|
|
50
|
-
return HotUpdaterImpl(appContext, bundleStorage, preferences)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
@objcMembers
|
|
4
|
-
public class HotUpdaterFactory: NSObject {
|
|
5
|
-
public static let shared = HotUpdaterFactory()
|
|
6
|
-
|
|
7
|
-
private override init() {}
|
|
8
|
-
|
|
9
|
-
public func create() -> HotUpdaterImpl {
|
|
10
|
-
let fileSystem = FileManagerService()
|
|
11
|
-
let preferences = VersionedPreferencesService()
|
|
12
|
-
let downloadService = URLSessionDownloadService()
|
|
13
|
-
let decompressService = DecompressService()
|
|
14
|
-
|
|
15
|
-
let bundleStorage = BundleFileStorageService(
|
|
16
|
-
fileSystem: fileSystem,
|
|
17
|
-
downloadService: downloadService,
|
|
18
|
-
decompressService: decompressService,
|
|
19
|
-
preferences: preferences
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
return HotUpdaterImpl(bundleStorage: bundleStorage, preferences: preferences)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.runUpdateProcess = void 0;
|
|
7
|
-
var _checkForUpdate = require("./checkForUpdate.js");
|
|
8
|
-
var _native = require("./native.js");
|
|
9
|
-
/**
|
|
10
|
-
* Manually checks and applies updates for the application.
|
|
11
|
-
*
|
|
12
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
13
|
-
* @param {string} config.source - Update server URL
|
|
14
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
15
|
-
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* // Auto reload on force update
|
|
20
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
21
|
-
* source: "<your-update-server-url>",
|
|
22
|
-
* requestHeaders: {
|
|
23
|
-
* // Add necessary headers
|
|
24
|
-
* },
|
|
25
|
-
* reloadOnForceUpdate: true
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Manually handle reload on force update
|
|
29
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
30
|
-
* source: "<your-update-server-url>",
|
|
31
|
-
* reloadOnForceUpdate: false
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
35
|
-
* await HotUpdater.reload();
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
40
|
-
*/
|
|
41
|
-
const runUpdateProcess = async ({
|
|
42
|
-
reloadOnForceUpdate = true,
|
|
43
|
-
...checkForUpdateOptions
|
|
44
|
-
}) => {
|
|
45
|
-
const updateInfo = await (0, _checkForUpdate.checkForUpdate)(checkForUpdateOptions);
|
|
46
|
-
if (!updateInfo) {
|
|
47
|
-
return {
|
|
48
|
-
status: "UP_TO_DATE",
|
|
49
|
-
shouldForceUpdate: false,
|
|
50
|
-
message: null,
|
|
51
|
-
id: (0, _native.getBundleId)()
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const isUpdated = await updateInfo.updateBundle();
|
|
55
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
|
|
56
|
-
await (0, _native.reload)();
|
|
57
|
-
}
|
|
58
|
-
if (!isUpdated) {
|
|
59
|
-
throw new Error("New update was found but failed to download the bundle.");
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
status: updateInfo.status,
|
|
63
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
64
|
-
id: updateInfo.id,
|
|
65
|
-
message: updateInfo.message
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
exports.runUpdateProcess = runUpdateProcess;
|
|
69
|
-
//# sourceMappingURL=runUpdateProcess.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_checkForUpdate","require","_native","runUpdateProcess","reloadOnForceUpdate","checkForUpdateOptions","updateInfo","checkForUpdate","status","shouldForceUpdate","message","id","getBundleId","isUpdated","updateBundle","reload","Error","exports"],"sourceRoot":"../../src","sources":["runUpdateProcess.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,gBAAgB,GAAG,MAAAA,CAAO;EACrCC,mBAAmB,GAAG,IAAI;EAC1B,GAAGC;AACoB,CAAC,KAAwC;EAChE,MAAMC,UAAU,GAAG,MAAM,IAAAC,8BAAc,EAACF,qBAAqB,CAAC;EAC9D,IAAI,CAACC,UAAU,EAAE;IACf,OAAO;MACLE,MAAM,EAAE,YAAY;MACpBC,iBAAiB,EAAE,KAAK;MACxBC,OAAO,EAAE,IAAI;MACbC,EAAE,EAAE,IAAAC,mBAAW,EAAC;IAClB,CAAC;EACH;EAEA,MAAMC,SAAS,GAAG,MAAMP,UAAU,CAACQ,YAAY,CAAC,CAAC;EACjD,IAAID,SAAS,IAAIP,UAAU,CAACG,iBAAiB,IAAIL,mBAAmB,EAAE;IACpE,MAAM,IAAAW,cAAM,EAAC,CAAC;EAChB;EAEA,IAAI,CAACF,SAAS,EAAE;IACd,MAAM,IAAIG,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAO;IACLR,MAAM,EAAEF,UAAU,CAACE,MAAM;IACzBC,iBAAiB,EAAEH,UAAU,CAACG,iBAAiB;IAC/CE,EAAE,EAAEL,UAAU,CAACK,EAAE;IACjBD,OAAO,EAAEJ,UAAU,CAACI;EACtB,CAAC;AACH,CAAC;AAACO,OAAA,CAAAd,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { checkForUpdate } from "./checkForUpdate.js";
|
|
4
|
-
import { getBundleId, reload } from "./native.js";
|
|
5
|
-
/**
|
|
6
|
-
* Manually checks and applies updates for the application.
|
|
7
|
-
*
|
|
8
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
9
|
-
* @param {string} config.source - Update server URL
|
|
10
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
11
|
-
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Auto reload on force update
|
|
16
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
17
|
-
* source: "<your-update-server-url>",
|
|
18
|
-
* requestHeaders: {
|
|
19
|
-
* // Add necessary headers
|
|
20
|
-
* },
|
|
21
|
-
* reloadOnForceUpdate: true
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // Manually handle reload on force update
|
|
25
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
26
|
-
* source: "<your-update-server-url>",
|
|
27
|
-
* reloadOnForceUpdate: false
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
31
|
-
* await HotUpdater.reload();
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
36
|
-
*/
|
|
37
|
-
export const runUpdateProcess = async ({
|
|
38
|
-
reloadOnForceUpdate = true,
|
|
39
|
-
...checkForUpdateOptions
|
|
40
|
-
}) => {
|
|
41
|
-
const updateInfo = await checkForUpdate(checkForUpdateOptions);
|
|
42
|
-
if (!updateInfo) {
|
|
43
|
-
return {
|
|
44
|
-
status: "UP_TO_DATE",
|
|
45
|
-
shouldForceUpdate: false,
|
|
46
|
-
message: null,
|
|
47
|
-
id: getBundleId()
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const isUpdated = await updateInfo.updateBundle();
|
|
51
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
|
|
52
|
-
await reload();
|
|
53
|
-
}
|
|
54
|
-
if (!isUpdated) {
|
|
55
|
-
throw new Error("New update was found but failed to download the bundle.");
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
status: updateInfo.status,
|
|
59
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
60
|
-
id: updateInfo.id,
|
|
61
|
-
message: updateInfo.message
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=runUpdateProcess.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["checkForUpdate","getBundleId","reload","runUpdateProcess","reloadOnForceUpdate","checkForUpdateOptions","updateInfo","status","shouldForceUpdate","message","id","isUpdated","updateBundle","Error"],"sourceRoot":"../../src","sources":["runUpdateProcess.ts"],"mappings":";;AAAA,SAAqCA,cAAc,QAAQ,qBAAkB;AAC7E,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAU;AAkB9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAO;EACrCC,mBAAmB,GAAG,IAAI;EAC1B,GAAGC;AACoB,CAAC,KAAwC;EAChE,MAAMC,UAAU,GAAG,MAAMN,cAAc,CAACK,qBAAqB,CAAC;EAC9D,IAAI,CAACC,UAAU,EAAE;IACf,OAAO;MACLC,MAAM,EAAE,YAAY;MACpBC,iBAAiB,EAAE,KAAK;MACxBC,OAAO,EAAE,IAAI;MACbC,EAAE,EAAET,WAAW,CAAC;IAClB,CAAC;EACH;EAEA,MAAMU,SAAS,GAAG,MAAML,UAAU,CAACM,YAAY,CAAC,CAAC;EACjD,IAAID,SAAS,IAAIL,UAAU,CAACE,iBAAiB,IAAIJ,mBAAmB,EAAE;IACpE,MAAMF,MAAM,CAAC,CAAC;EAChB;EAEA,IAAI,CAACS,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAO;IACLN,MAAM,EAAED,UAAU,CAACC,MAAM;IACzBC,iBAAiB,EAAEF,UAAU,CAACE,iBAAiB;IAC/CE,EAAE,EAAEJ,UAAU,CAACI,EAAE;IACjBD,OAAO,EAAEH,UAAU,CAACG;EACtB,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type CheckForUpdateOptions } from "./checkForUpdate";
|
|
2
|
-
export interface RunUpdateProcessResponse {
|
|
3
|
-
status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
|
|
4
|
-
shouldForceUpdate: boolean;
|
|
5
|
-
message: string | null;
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
|
|
9
|
-
/**
|
|
10
|
-
* If `true`, the app will be reloaded when the downloaded bundle is a force update.
|
|
11
|
-
* If `false`, shouldForceUpdate will be returned as true but the app won't reload.
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
reloadOnForceUpdate?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Manually checks and applies updates for the application.
|
|
18
|
-
*
|
|
19
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
20
|
-
* @param {string} config.source - Update server URL
|
|
21
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
22
|
-
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // Auto reload on force update
|
|
27
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
28
|
-
* source: "<your-update-server-url>",
|
|
29
|
-
* requestHeaders: {
|
|
30
|
-
* // Add necessary headers
|
|
31
|
-
* },
|
|
32
|
-
* reloadOnForceUpdate: true
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // Manually handle reload on force update
|
|
36
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
37
|
-
* source: "<your-update-server-url>",
|
|
38
|
-
* reloadOnForceUpdate: false
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
42
|
-
* await HotUpdater.reload();
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
47
|
-
*/
|
|
48
|
-
export declare const runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: RunUpdateProcessOptions) => Promise<RunUpdateProcessResponse>;
|
|
49
|
-
//# sourceMappingURL=runUpdateProcess.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runUpdateProcess.d.ts","sourceRoot":"","sources":["../../../src/runUpdateProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAG9E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAU,mDAGpC,uBAAuB,KAAG,OAAO,CAAC,wBAAwB,CAyB5D,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type CheckForUpdateOptions } from "./checkForUpdate";
|
|
2
|
-
export interface RunUpdateProcessResponse {
|
|
3
|
-
status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
|
|
4
|
-
shouldForceUpdate: boolean;
|
|
5
|
-
message: string | null;
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
|
|
9
|
-
/**
|
|
10
|
-
* If `true`, the app will be reloaded when the downloaded bundle is a force update.
|
|
11
|
-
* If `false`, shouldForceUpdate will be returned as true but the app won't reload.
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
reloadOnForceUpdate?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Manually checks and applies updates for the application.
|
|
18
|
-
*
|
|
19
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
20
|
-
* @param {string} config.source - Update server URL
|
|
21
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
22
|
-
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // Auto reload on force update
|
|
27
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
28
|
-
* source: "<your-update-server-url>",
|
|
29
|
-
* requestHeaders: {
|
|
30
|
-
* // Add necessary headers
|
|
31
|
-
* },
|
|
32
|
-
* reloadOnForceUpdate: true
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // Manually handle reload on force update
|
|
36
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
37
|
-
* source: "<your-update-server-url>",
|
|
38
|
-
* reloadOnForceUpdate: false
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
42
|
-
* await HotUpdater.reload();
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
47
|
-
*/
|
|
48
|
-
export declare const runUpdateProcess: ({ reloadOnForceUpdate, ...checkForUpdateOptions }: RunUpdateProcessOptions) => Promise<RunUpdateProcessResponse>;
|
|
49
|
-
//# sourceMappingURL=runUpdateProcess.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runUpdateProcess.d.ts","sourceRoot":"","sources":["../../../src/runUpdateProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,kBAAkB,CAAC;AAG9E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,gBAAgB,GAAU,mDAGpC,uBAAuB,KAAG,OAAO,CAAC,wBAAwB,CAyB5D,CAAC"}
|
package/src/runUpdateProcess.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { type CheckForUpdateOptions, checkForUpdate } from "./checkForUpdate";
|
|
2
|
-
import { getBundleId, reload } from "./native";
|
|
3
|
-
|
|
4
|
-
export interface RunUpdateProcessResponse {
|
|
5
|
-
status: "ROLLBACK" | "UPDATE" | "UP_TO_DATE";
|
|
6
|
-
shouldForceUpdate: boolean;
|
|
7
|
-
message: string | null;
|
|
8
|
-
id: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RunUpdateProcessOptions extends CheckForUpdateOptions {
|
|
12
|
-
/**
|
|
13
|
-
* If `true`, the app will be reloaded when the downloaded bundle is a force update.
|
|
14
|
-
* If `false`, shouldForceUpdate will be returned as true but the app won't reload.
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
17
|
-
reloadOnForceUpdate?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Manually checks and applies updates for the application.
|
|
22
|
-
*
|
|
23
|
-
* @param {RunUpdateProcessConfig} config - Update process configuration
|
|
24
|
-
* @param {string} config.source - Update server URL
|
|
25
|
-
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
26
|
-
* @param {boolean} [config.reloadOnForceUpdate=true] - Whether to automatically reload on force update
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* // Auto reload on force update
|
|
31
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
32
|
-
* source: "<your-update-server-url>",
|
|
33
|
-
* requestHeaders: {
|
|
34
|
-
* // Add necessary headers
|
|
35
|
-
* },
|
|
36
|
-
* reloadOnForceUpdate: true
|
|
37
|
-
* });
|
|
38
|
-
*
|
|
39
|
-
* // Manually handle reload on force update
|
|
40
|
-
* const result = await HotUpdater.runUpdateProcess({
|
|
41
|
-
* source: "<your-update-server-url>",
|
|
42
|
-
* reloadOnForceUpdate: false
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* if(result.status !== "UP_TO_DATE" && result.shouldForceUpdate) {
|
|
46
|
-
* await HotUpdater.reload();
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @returns {Promise<RunUpdateProcessResponse>} The result of the update process
|
|
51
|
-
*/
|
|
52
|
-
export const runUpdateProcess = async ({
|
|
53
|
-
reloadOnForceUpdate = true,
|
|
54
|
-
...checkForUpdateOptions
|
|
55
|
-
}: RunUpdateProcessOptions): Promise<RunUpdateProcessResponse> => {
|
|
56
|
-
const updateInfo = await checkForUpdate(checkForUpdateOptions);
|
|
57
|
-
if (!updateInfo) {
|
|
58
|
-
return {
|
|
59
|
-
status: "UP_TO_DATE",
|
|
60
|
-
shouldForceUpdate: false,
|
|
61
|
-
message: null,
|
|
62
|
-
id: getBundleId(),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const isUpdated = await updateInfo.updateBundle();
|
|
67
|
-
if (isUpdated && updateInfo.shouldForceUpdate && reloadOnForceUpdate) {
|
|
68
|
-
await reload();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!isUpdated) {
|
|
72
|
-
throw new Error("New update was found but failed to download the bundle.");
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
status: updateInfo.status,
|
|
76
|
-
shouldForceUpdate: updateInfo.shouldForceUpdate,
|
|
77
|
-
id: updateInfo.id,
|
|
78
|
-
message: updateInfo.message,
|
|
79
|
-
};
|
|
80
|
-
};
|