@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
package/lib/module/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { checkForUpdate } from "./checkForUpdate.js";
|
|
4
|
-
import { addListener, getAppVersion, getBundleId, getChannel, getFingerprintHash, getMinBundleId, reload, updateBundle } from "./native.js";
|
|
5
|
-
import { runUpdateProcess } from "./runUpdateProcess.js";
|
|
4
|
+
import { addListener, clearCrashHistory, getAppVersion, getBundleId, getChannel, getCrashHistory, getFingerprintHash, getMinBundleId, reload, updateBundle } from "./native.js";
|
|
6
5
|
import { hotUpdaterStore } from "./store.js";
|
|
7
6
|
import { wrap } from "./wrap.js";
|
|
8
7
|
export * from "./store.js";
|
|
@@ -14,205 +13,241 @@ addListener("onProgress", ({
|
|
|
14
13
|
progress
|
|
15
14
|
});
|
|
16
15
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a HotUpdater client instance with all update management methods.
|
|
19
|
+
* This function is called once on module initialization to create a singleton instance.
|
|
20
|
+
*/
|
|
21
|
+
function createHotUpdaterClient() {
|
|
22
|
+
// Global configuration stored from wrap
|
|
23
|
+
const globalConfig = {
|
|
24
|
+
baseURL: null
|
|
25
|
+
};
|
|
26
|
+
function ensureGlobalBaseURL(methodName) {
|
|
27
|
+
if (globalConfig.baseURL === null) {
|
|
28
|
+
throw new Error(`[HotUpdater] ${methodName} requires HotUpdater.wrap() to be used.\n\n` + `To fix this issue, wrap your root component with HotUpdater.wrap():\n\n` + `Option 1: With automatic updates\n` + ` export default HotUpdater.wrap({\n` + ` baseURL: "<your-update-server-url>",\n` + ` updateStrategy: "appVersion",\n` + ` updateMode: "auto"\n` + ` })(App);\n\n` + `Option 2: Manual updates only (custom flow)\n` + ` export default HotUpdater.wrap({\n` + ` baseURL: "<your-update-server-url>",\n` + ` updateMode: "manual"\n` + ` })(App);\n\n` + `For more information, visit: https://hot-updater.dev/docs/react-native-api/wrap`);
|
|
29
|
+
}
|
|
30
|
+
return globalConfig.baseURL;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
/**
|
|
34
|
+
* `HotUpdater.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} options - Configuration options
|
|
37
|
+
* @param {string} options.source - Update server URL
|
|
38
|
+
* @param {object} [options.requestHeaders] - Request headers
|
|
39
|
+
* @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
|
|
40
|
+
* @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
|
|
41
|
+
* @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
|
|
42
|
+
* @param {Function} [options.onProgress] - Callback to track bundle download progress
|
|
43
|
+
* @returns {Function} Higher-order component that wraps the app component
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* export default HotUpdater.wrap({
|
|
48
|
+
* baseURL: "<your-update-server-url>",
|
|
49
|
+
* updateStrategy: "appVersion",
|
|
50
|
+
* updateMode: "auto",
|
|
51
|
+
* requestHeaders: {
|
|
52
|
+
* "Authorization": "Bearer <your-access-token>",
|
|
53
|
+
* },
|
|
54
|
+
* })(App);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
wrap: options => {
|
|
58
|
+
globalConfig.baseURL = options.baseURL;
|
|
59
|
+
globalConfig.requestHeaders = options.requestHeaders;
|
|
60
|
+
globalConfig.requestTimeout = options.requestTimeout;
|
|
61
|
+
return wrap(options);
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Reloads the app.
|
|
65
|
+
*/
|
|
66
|
+
reload,
|
|
67
|
+
/**
|
|
68
|
+
* Returns whether an update has finished downloading in this app session.
|
|
69
|
+
*
|
|
70
|
+
* When it returns true, calling `HotUpdater.reload()` (or restarting the app)
|
|
71
|
+
* will apply the downloaded update bundle.
|
|
72
|
+
*
|
|
73
|
+
* - Derived from `progress` reaching 1.0
|
|
74
|
+
* - Resets to false when a new download starts (progress < 1)
|
|
75
|
+
*
|
|
76
|
+
* @returns {boolean} True if a downloaded update is ready to apply
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* if (HotUpdater.isUpdateDownloaded()) {
|
|
80
|
+
* await HotUpdater.reload();
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
isUpdateDownloaded: () => hotUpdaterStore.getSnapshot().isUpdateDownloaded,
|
|
85
|
+
/**
|
|
86
|
+
* Fetches the current app version.
|
|
87
|
+
*/
|
|
88
|
+
getAppVersion,
|
|
89
|
+
/**
|
|
90
|
+
* Fetches the current bundle ID of the app.
|
|
91
|
+
*/
|
|
92
|
+
getBundleId,
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves the initial bundle ID based on the build time of the native app.
|
|
95
|
+
*/
|
|
96
|
+
getMinBundleId,
|
|
97
|
+
/**
|
|
98
|
+
* Fetches the current channel of the app.
|
|
99
|
+
*
|
|
100
|
+
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
101
|
+
*
|
|
102
|
+
* @returns {string} The current release channel of the app
|
|
103
|
+
* @default "production"
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const channel = HotUpdater.getChannel();
|
|
107
|
+
* console.log(`Current channel: ${channel}`);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
getChannel,
|
|
111
|
+
/**
|
|
112
|
+
* Adds a listener to HotUpdater events.
|
|
113
|
+
*
|
|
114
|
+
* @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
|
|
115
|
+
* @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
|
|
116
|
+
* @returns {() => void} A cleanup function that removes the event listener
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
|
|
121
|
+
* console.log(`Update progress: ${progress * 100}%`);
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // Unsubscribe when no longer needed
|
|
125
|
+
* unsubscribe();
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
addListener,
|
|
129
|
+
/**
|
|
130
|
+
* Manually checks for updates.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} config - Update check configuration
|
|
133
|
+
* @param {string} config.source - Update server URL
|
|
134
|
+
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
135
|
+
*
|
|
136
|
+
* @returns {Promise<UpdateInfo | null>} Update information or null if up to date
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* const updateInfo = await HotUpdater.checkForUpdate({
|
|
141
|
+
* source: "<your-update-server-url>",
|
|
142
|
+
* requestHeaders: {
|
|
143
|
+
* Authorization: "Bearer <your-access-token>",
|
|
144
|
+
* },
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* if (!updateInfo) {
|
|
148
|
+
* console.log("App is up to date");
|
|
149
|
+
* return;
|
|
150
|
+
* }
|
|
151
|
+
*
|
|
152
|
+
* await HotUpdater.updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
153
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
154
|
+
* await HotUpdater.reload();
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
checkForUpdate: config => {
|
|
159
|
+
const baseURL = ensureGlobalBaseURL("checkForUpdate");
|
|
160
|
+
|
|
161
|
+
// Merge globalConfig with provided config
|
|
162
|
+
// baseURL is always from wrap (globalConfig)
|
|
163
|
+
// requestHeaders/requestTimeout from wrap are used as defaults, but can be overridden
|
|
164
|
+
const mergedConfig = {
|
|
165
|
+
...config,
|
|
166
|
+
baseURL,
|
|
167
|
+
requestHeaders: {
|
|
168
|
+
...globalConfig.requestHeaders,
|
|
169
|
+
...config.requestHeaders
|
|
170
|
+
},
|
|
171
|
+
requestTimeout: config.requestTimeout ?? globalConfig.requestTimeout
|
|
172
|
+
};
|
|
173
|
+
return checkForUpdate(mergedConfig);
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Updates the bundle of the app.
|
|
177
|
+
*
|
|
178
|
+
* @param {UpdateBundleParams} params - Parameters object required for bundle update
|
|
179
|
+
* @param {string} params.bundleId - The bundle ID of the app
|
|
180
|
+
* @param {string|null} params.fileUrl - The URL of the zip file
|
|
181
|
+
*
|
|
182
|
+
* @returns {Promise<boolean>} Whether the update was successful
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const updateInfo = await HotUpdater.checkForUpdate({
|
|
187
|
+
* source: "<your-update-server-url>",
|
|
188
|
+
* requestHeaders: {
|
|
189
|
+
* Authorization: "Bearer <your-access-token>",
|
|
190
|
+
* },
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* if (!updateInfo) {
|
|
194
|
+
* return {
|
|
195
|
+
* status: "UP_TO_DATE",
|
|
196
|
+
* };
|
|
197
|
+
* }
|
|
198
|
+
*
|
|
199
|
+
* await HotUpdater.updateBundle({
|
|
200
|
+
* bundleId: updateInfo.id,
|
|
201
|
+
* fileUrl: updateInfo.fileUrl
|
|
202
|
+
* });
|
|
203
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
204
|
+
* await HotUpdater.reload();
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
updateBundle: params => {
|
|
209
|
+
ensureGlobalBaseURL("updateBundle");
|
|
210
|
+
return updateBundle(params);
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* Fetches the fingerprint of the app.
|
|
214
|
+
*
|
|
215
|
+
* @returns {string} The fingerprint of the app
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const fingerprint = HotUpdater.getFingerprintHash();
|
|
220
|
+
* console.log(`Fingerprint: ${fingerprint}`);
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
getFingerprintHash,
|
|
224
|
+
/**
|
|
225
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
226
|
+
* These bundles will be rejected if attempted to install again.
|
|
227
|
+
*
|
|
228
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const crashedBundles = HotUpdater.getCrashHistory();
|
|
233
|
+
* console.log("Crashed bundles:", crashedBundles);
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
getCrashHistory,
|
|
237
|
+
/**
|
|
238
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
239
|
+
* to be installed again.
|
|
240
|
+
*
|
|
241
|
+
* @returns {boolean} true if clearing was successful
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* // Clear crash history to allow retrying a previously failed bundle
|
|
246
|
+
* HotUpdater.clearCrashHistory();
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
clearCrashHistory
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export const HotUpdater = createHotUpdaterClient();
|
|
218
253
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["checkForUpdate","addListener","getAppVersion","getBundleId","getChannel","getFingerprintHash","getMinBundleId","reload","updateBundle","
|
|
1
|
+
{"version":3,"names":["checkForUpdate","addListener","clearCrashHistory","getAppVersion","getBundleId","getChannel","getCrashHistory","getFingerprintHash","getMinBundleId","reload","updateBundle","hotUpdaterStore","wrap","extractSignatureFailure","isSignatureVerificationError","progress","setState","createHotUpdaterClient","globalConfig","baseURL","ensureGlobalBaseURL","methodName","Error","options","requestHeaders","requestTimeout","isUpdateDownloaded","getSnapshot","config","mergedConfig","params","HotUpdater"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAEEA,cAAc,QAET,qBAAkB;AACzB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,EACdC,MAAM,EAENC,YAAY,QACP,aAAU;AACjB,SAASC,eAAe,QAAQ,YAAS;AACzC,SAAiCC,IAAI,QAAQ,WAAQ;AAGrD,cAAc,YAAS;AACvB,SACEC,uBAAuB,EACvBC,4BAA4B,QAEvB,YAAS;AAGhBb,WAAW,CAAC,YAAY,EAAE,CAAC;EAAEc;AAAS,CAAC,KAAK;EAC1CJ,eAAe,CAACK,QAAQ,CAAC;IACvBD;EACF,CAAC,CAAC;AACJ,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,SAASE,sBAAsBA,CAAA,EAAG;EAChC;EACA,MAAMC,YAIL,GAAG;IACFC,OAAO,EAAE;EACX,CAAC;EAED,SAASC,mBAAmBA,CAACC,UAAkB,EAAE;IAC/C,IAAIH,YAAY,CAACC,OAAO,KAAK,IAAI,EAAE;MACjC,MAAM,IAAIG,KAAK,CACb,gBAAgBD,UAAU,6CAA6C,GACrE,yEAAyE,GACzE,oCAAoC,GACpC,sCAAsC,GACtC,4CAA4C,GAC5C,qCAAqC,GACrC,0BAA0B,GAC1B,gBAAgB,GAChB,+CAA+C,GAC/C,sCAAsC,GACtC,4CAA4C,GAC5C,4BAA4B,GAC5B,gBAAgB,GAChB,iFACJ,CAAC;IACH;IAEA,OAAOH,YAAY,CAACC,OAAO;EAC7B;EAEA,OAAO;IACL;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIP,IAAI,EAAIW,OAA0B,IAAK;MACrCL,YAAY,CAACC,OAAO,GAAGI,OAAO,CAACJ,OAAO;MACtCD,YAAY,CAACM,cAAc,GAAGD,OAAO,CAACC,cAAc;MACpDN,YAAY,CAACO,cAAc,GAAGF,OAAO,CAACE,cAAc;MACpD,OAAOb,IAAI,CAACW,OAAO,CAAC;IACtB,CAAiB;IAEjB;AACJ;AACA;IACId,MAAM;IAEN;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIiB,kBAAkB,EAAEA,CAAA,KAAMf,eAAe,CAACgB,WAAW,CAAC,CAAC,CAACD,kBAAkB;IAE1E;AACJ;AACA;IACIvB,aAAa;IAEb;AACJ;AACA;IACIC,WAAW;IAEX;AACJ;AACA;IACII,cAAc;IAEd;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIH,UAAU;IAEV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIJ,WAAW;IAEX;AACJ;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;IACID,cAAc,EAAG4B,MAA6B,IAAK;MACjD,MAAMT,OAAO,GAAGC,mBAAmB,CAAC,gBAAgB,CAAC;;MAErD;MACA;MACA;MACA,MAAMS,YAA2C,GAAG;QAClD,GAAGD,MAAM;QACTT,OAAO;QACPK,cAAc,EAAE;UACd,GAAGN,YAAY,CAACM,cAAc;UAC9B,GAAGI,MAAM,CAACJ;QACZ,CAAC;QACDC,cAAc,EAAEG,MAAM,CAACH,cAAc,IAAIP,YAAY,CAACO;MACxD,CAAC;MAED,OAAOzB,cAAc,CAAC6B,YAAY,CAAC;IACrC,CAAC;IAED;AACJ;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;IACInB,YAAY,EAAGoB,MAAoB,IAAK;MACtCV,mBAAmB,CAAC,cAAc,CAAC;MAEnC,OAAOV,YAAY,CAACoB,MAAM,CAAC;IAC7B,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIvB,kBAAkB;IAElB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACID,eAAe;IAEf;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIJ;EACF,CAAC;AACH;AAEA,OAAO,MAAM6B,UAAU,GAAGd,sBAAsB,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/native.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { NativeEventEmitter } from "react-native";
|
|
4
|
+
import { HotUpdaterErrorCode, isHotUpdaterError } from "./error.js";
|
|
4
5
|
import HotUpdaterNative from "./specs/NativeHotUpdater.js";
|
|
6
|
+
export { HotUpdaterErrorCode, isHotUpdaterError };
|
|
5
7
|
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
6
8
|
export const HotUpdaterConstants = {
|
|
7
9
|
HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID
|
|
@@ -22,7 +24,8 @@ let lastInstalledBundleId = null;
|
|
|
22
24
|
* Downloads files and applies them to the app.
|
|
23
25
|
*
|
|
24
26
|
* @param {UpdateParams} params - Parameters object required for bundle update
|
|
25
|
-
* @returns {Promise<boolean>} Resolves with true if download was successful
|
|
27
|
+
* @returns {Promise<boolean>} Resolves with true if download was successful
|
|
28
|
+
* @throws {Error} Rejects with error.code from HotUpdaterErrorCode enum and error.message
|
|
26
29
|
*/
|
|
27
30
|
|
|
28
31
|
/**
|
|
@@ -98,7 +101,7 @@ export const getMinBundleId = () => {
|
|
|
98
101
|
* Fetches the current bundle version id.
|
|
99
102
|
*
|
|
100
103
|
* @async
|
|
101
|
-
* @returns {
|
|
104
|
+
* @returns {string} Resolves with the current version id or null if not available.
|
|
102
105
|
*/
|
|
103
106
|
export const getBundleId = () => {
|
|
104
107
|
return HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID === NIL_UUID ? getMinBundleId() : HotUpdaterConstants.HOT_UPDATER_BUNDLE_ID;
|
|
@@ -123,4 +126,86 @@ export const getFingerprintHash = () => {
|
|
|
123
126
|
const constants = HotUpdaterNative.getConstants();
|
|
124
127
|
return constants.FINGERPRINT_HASH;
|
|
125
128
|
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Result returned by notifyAppReady()
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Notifies the native side that the app has successfully started with the current bundle.
|
|
136
|
+
* If the bundle matches the staging bundle, it promotes to stable.
|
|
137
|
+
*
|
|
138
|
+
* This function is called automatically when the module loads.
|
|
139
|
+
*
|
|
140
|
+
* @returns {NotifyAppReadyResult} Bundle state information
|
|
141
|
+
* - `status: "PROMOTED"` - Staging bundle was promoted to stable (ACTIVE event)
|
|
142
|
+
* - `status: "RECOVERED"` - App recovered from crash, rollback occurred (ROLLBACK event)
|
|
143
|
+
* - `status: "STABLE"` - No changes, already stable
|
|
144
|
+
* - `crashedBundleId` - Present only when status is "RECOVERED"
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const result = HotUpdater.notifyAppReady();
|
|
149
|
+
*
|
|
150
|
+
* switch (result.status) {
|
|
151
|
+
* case "PROMOTED":
|
|
152
|
+
* // Send ACTIVE analytics event
|
|
153
|
+
* analytics.track('bundle_active', { bundleId: HotUpdater.getBundleId() });
|
|
154
|
+
* break;
|
|
155
|
+
* case "RECOVERED":
|
|
156
|
+
* // Send ROLLBACK analytics event
|
|
157
|
+
* analytics.track('bundle_rollback', { crashedBundleId: result.crashedBundleId });
|
|
158
|
+
* break;
|
|
159
|
+
* case "STABLE":
|
|
160
|
+
* // No special action needed
|
|
161
|
+
* break;
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export const notifyAppReady = () => {
|
|
166
|
+
const bundleId = getBundleId();
|
|
167
|
+
const result = HotUpdaterNative.notifyAppReady({
|
|
168
|
+
bundleId
|
|
169
|
+
});
|
|
170
|
+
// Oldarch returns JSON string, newarch returns array
|
|
171
|
+
if (typeof result === "string") {
|
|
172
|
+
try {
|
|
173
|
+
return JSON.parse(result);
|
|
174
|
+
} catch {
|
|
175
|
+
return {
|
|
176
|
+
status: "STABLE"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
185
|
+
* These bundles will be rejected if attempted to install again.
|
|
186
|
+
*
|
|
187
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
188
|
+
*/
|
|
189
|
+
export const getCrashHistory = () => {
|
|
190
|
+
const result = HotUpdaterNative.getCrashHistory();
|
|
191
|
+
// Oldarch returns JSON string, newarch returns array
|
|
192
|
+
if (typeof result === "string") {
|
|
193
|
+
try {
|
|
194
|
+
return JSON.parse(result);
|
|
195
|
+
} catch {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
204
|
+
* to be installed again.
|
|
205
|
+
*
|
|
206
|
+
* @returns {boolean} true if clearing was successful
|
|
207
|
+
*/
|
|
208
|
+
export const clearCrashHistory = () => {
|
|
209
|
+
return HotUpdaterNative.clearCrashHistory();
|
|
210
|
+
};
|
|
126
211
|
//# sourceMappingURL=native.js.map
|
package/lib/module/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","HotUpdaterNative","NIL_UUID","HotUpdaterConstants","HOT_UPDATER_BUNDLE_ID","__HOT_UPDATER_BUNDLE_ID","addListener","eventName","listener","eventEmitter","subscription","remove","inflightUpdates","Map","lastInstalledBundleId","updateBundle","paramsOrBundleId","fileUrl","updateBundleId","bundleId","status","currentBundleId","getBundleId","localeCompare","Error","existing","get","targetFileUrl","targetFileHash","undefined","fileHash","promise","ok","delete","set","getAppVersion","constants","getConstants","APP_VERSION","reload","getMinBundleId","MIN_BUNDLE_ID","getChannel","CHANNEL","getFingerprintHash","FINGERPRINT_HASH"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;AACA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,gBAAgB,MAEhB,6BAA0B;AAEjC,
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","HotUpdaterErrorCode","isHotUpdaterError","HotUpdaterNative","NIL_UUID","HotUpdaterConstants","HOT_UPDATER_BUNDLE_ID","__HOT_UPDATER_BUNDLE_ID","addListener","eventName","listener","eventEmitter","subscription","remove","inflightUpdates","Map","lastInstalledBundleId","updateBundle","paramsOrBundleId","fileUrl","updateBundleId","bundleId","status","currentBundleId","getBundleId","localeCompare","Error","existing","get","targetFileUrl","targetFileHash","undefined","fileHash","promise","ok","delete","set","getAppVersion","constants","getConstants","APP_VERSION","reload","getMinBundleId","MIN_BUNDLE_ID","getChannel","CHANNEL","getFingerprintHash","FINGERPRINT_HASH","notifyAppReady","result","JSON","parse","getCrashHistory","clearCrashHistory"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;AACA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,YAAS;AAChE,OAAOC,gBAAgB,MAEhB,6BAA0B;AAEjC,SAASF,mBAAmB,EAAEC,iBAAiB;AAE/C,MAAME,QAAQ,GAAG,sCAAsC;AAIvD,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,qBAAqB,EAAEC,uBAAuB,IAAIH;AACpD,CAAC;AAQD,OAAO,MAAMI,WAAW,GAAGA,CACzBC,SAAY,EACZC,QAA6C,KAC1C;EACH,MAAMC,YAAY,GAAG,IAAIX,kBAAkB,CAACG,gBAAgB,CAAC;EAC7D,MAAMS,YAAY,GAAGD,YAAY,CAACH,WAAW,CAACC,SAAS,EAAEC,QAAQ,CAAC;EAElE,OAAO,MAAM;IACXE,YAAY,CAACC,MAAM,CAAC,CAAC;EACvB,CAAC;AACH,CAAC;AAMD;AACA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAA2B,CAAC;AAC3D;AACA,IAAIC,qBAAoC,GAAG,IAAI;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAKA,OAAO,eAAeC,YAAYA,CAChCC,gBAAuC,EACvCC,OAAuB,EACL;EAClB,MAAMC,cAAc,GAClB,OAAOF,gBAAgB,KAAK,QAAQ,GAChCA,gBAAgB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AQ,GAAGG,WAAW,CAAC,CAAC;EAC9B,MAAMyB,MAAM,GAAG9C,gBAAgB,CAAC6C,cAAc,CAAC;IAAE3B;EAAS,CAAC,CAAC;EAC5D;EACA,IAAI,OAAO4B,MAAM,KAAK,QAAQ,EAAE;IAC9B,IAAI;MACF,OAAOC,IAAI,CAACC,KAAK,CAACF,MAAM,CAAC;IAC3B,CAAC,CAAC,MAAM;MACN,OAAO;QAAE3B,MAAM,EAAE;MAAS,CAAC;IAC7B;EACF;EACA,OAAO2B,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,eAAe,GAAGA,CAAA,KAAgB;EAC7C,MAAMH,MAAM,GAAG9C,gBAAgB,CAACiD,eAAe,CAAC,CAAC;EACjD;EACA,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE;IAC9B,IAAI;MACF,OAAOC,IAAI,CAACC,KAAK,CAACF,MAAM,CAAC;IAC3B,CAAC,CAAC,MAAM;MACN,OAAO,EAAE;IACX;EACF;EACA,OAAOA,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,iBAAiB,GAAGA,CAAA,KAAe;EAC9C,OAAOlD,gBAAgB,CAACkD,iBAAiB,CAAC,CAAC;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeHotUpdater.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["specs/NativeHotUpdater.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAgGlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}
|