@hot-updater/react-native 0.23.1 → 0.24.1
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/DefaultResolver.js +38 -0
- package/lib/commonjs/DefaultResolver.js.map +1 -0
- package/lib/commonjs/checkForUpdate.js +33 -45
- 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 +249 -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/types.js +12 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/wrap.js +70 -1
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/module/DefaultResolver.js +34 -0
- package/lib/module/DefaultResolver.js.map +1 -0
- package/lib/module/checkForUpdate.js +34 -43
- 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 +250 -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/types.js +12 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/wrap.js +71 -2
- package/lib/module/wrap.js.map +1 -1
- package/lib/typescript/commonjs/DefaultResolver.d.ts +10 -0
- package/lib/typescript/commonjs/DefaultResolver.d.ts.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +12 -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 +38 -44
- 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/types.d.ts +115 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.d.ts +132 -7
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/module/DefaultResolver.d.ts +10 -0
- package/lib/typescript/module/DefaultResolver.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +12 -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 +38 -44
- 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/types.d.ts +115 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/wrap.d.ts +132 -7
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin/build/withHotUpdater.js +3 -3
- package/src/DefaultResolver.ts +36 -0
- package/src/checkForUpdate.ts +51 -56
- package/src/error.ts +153 -0
- package/src/fetchUpdateInfo.ts +10 -58
- package/src/index.ts +315 -206
- package/src/native.ts +88 -2
- package/src/specs/NativeHotUpdater.ts +63 -0
- package/src/types.ts +135 -0
- package/src/wrap.tsx +245 -34
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["fetchUpdateInfo","url","requestHeaders","onError","requestTimeout","controller","AbortController","timeoutId","setTimeout","abort","headers","response","fetch","signal","clearTimeout","status","Error","statusText","json","error","name","exports"],"sourceRoot":"../../src","sources":["fetchUpdateInfo.ts"],"mappings":";;;;;;AAEO,MAAMA,eAAe,GAAG,MAAAA,CAAO;EACpCC,GAAG;EACHC,cAAc;EACdC,OAAO;EACPC,cAAc,GAAG;AAMnB,CAAC,KAAoC;EACnC,IAAI;IACF,MAAMC,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;IACxC,MAAMC,SAAS,GAAGC,UAAU,CAAC,MAAM;MACjCH,UAAU,CAACI,KAAK,CAAC,CAAC;IACpB,CAAC,EAAEL,cAAc,CAAC;IAElB,MAAMM,OAAO,GAAG;MACd,cAAc,EAAE,kBAAkB;MAClC,GAAGR;IACL,CAAC;IAED,MAAMS,QAAQ,GAAG,MAAMC,KAAK,CAACX,GAAG,EAAE;MAChCY,MAAM,EAAER,UAAU,CAACQ,MAAM;MACzBH;IACF,CAAC,CAAC;IACFI,YAAY,CAACP,SAAS,CAAC;IAEvB,IAAII,QAAQ,CAACI,MAAM,KAAK,GAAG,EAAE;MAC3B,MAAM,IAAIC,KAAK,CAACL,QAAQ,CAACM,UAAU,CAAC;IACtC;IACA,OAAON,QAAQ,CAACO,IAAI,CAAC,CAAC;EACxB,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,IAAIA,KAAK,YAAYH,KAAK,IAAIG,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;MACzDjB,OAAO,GAAG,IAAIa,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC,MAAM;MACLb,OAAO,GAAGgB,KAAc,CAAC;IAC3B;IACA,OAAO,IAAI;EACb;AACF,CAAC;AAACE,OAAA,CAAArB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
HotUpdater: true,
|
|
8
|
-
getUpdateSource: true,
|
|
9
8
|
extractSignatureFailure: true,
|
|
10
9
|
isSignatureVerificationError: true
|
|
11
10
|
};
|
|
@@ -16,12 +15,6 @@ Object.defineProperty(exports, "extractSignatureFailure", {
|
|
|
16
15
|
return _types.extractSignatureFailure;
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
|
-
Object.defineProperty(exports, "getUpdateSource", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _checkForUpdate.getUpdateSource;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
18
|
Object.defineProperty(exports, "isSignatureVerificationError", {
|
|
26
19
|
enumerable: true,
|
|
27
20
|
get: function () {
|
|
@@ -29,8 +22,8 @@ Object.defineProperty(exports, "isSignatureVerificationError", {
|
|
|
29
22
|
}
|
|
30
23
|
});
|
|
31
24
|
var _checkForUpdate = require("./checkForUpdate.js");
|
|
25
|
+
var _DefaultResolver = require("./DefaultResolver.js");
|
|
32
26
|
var _native = require("./native.js");
|
|
33
|
-
var _runUpdateProcess = require("./runUpdateProcess.js");
|
|
34
27
|
var _store = require("./store.js");
|
|
35
28
|
Object.keys(_store).forEach(function (key) {
|
|
36
29
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -52,204 +45,252 @@ var _types = require("./types.js");
|
|
|
52
45
|
progress
|
|
53
46
|
});
|
|
54
47
|
});
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a HotUpdater client instance with all update management methods.
|
|
51
|
+
* This function is called once on module initialization to create a singleton instance.
|
|
52
|
+
*/
|
|
53
|
+
function createHotUpdaterClient() {
|
|
54
|
+
// Global configuration stored from wrap
|
|
55
|
+
const globalConfig = {
|
|
56
|
+
resolver: null
|
|
57
|
+
};
|
|
58
|
+
const ensureGlobalResolver = methodName => {
|
|
59
|
+
if (!globalConfig.resolver) {
|
|
60
|
+
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`);
|
|
61
|
+
}
|
|
62
|
+
return globalConfig.resolver;
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
/**
|
|
66
|
+
* `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.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} options - Configuration options
|
|
69
|
+
* @param {string} options.source - Update server URL
|
|
70
|
+
* @param {object} [options.requestHeaders] - Request headers
|
|
71
|
+
* @param {React.ComponentType} [options.fallbackComponent] - Component to display during updates
|
|
72
|
+
* @param {boolean} [options.reloadOnForceUpdate=true] - Whether to automatically reload the app on force updates
|
|
73
|
+
* @param {Function} [options.onUpdateProcessCompleted] - Callback after update process completes
|
|
74
|
+
* @param {Function} [options.onProgress] - Callback to track bundle download progress
|
|
75
|
+
* @returns {Function} Higher-order component that wraps the app component
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* export default HotUpdater.wrap({
|
|
80
|
+
* baseURL: "<your-update-server-url>",
|
|
81
|
+
* updateStrategy: "appVersion",
|
|
82
|
+
* updateMode: "auto",
|
|
83
|
+
* requestHeaders: {
|
|
84
|
+
* "Authorization": "Bearer <your-access-token>",
|
|
85
|
+
* },
|
|
86
|
+
* })(App);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
wrap: options => {
|
|
90
|
+
let normalizedOptions;
|
|
91
|
+
if ("baseURL" in options && options.baseURL) {
|
|
92
|
+
const {
|
|
93
|
+
baseURL,
|
|
94
|
+
...rest
|
|
95
|
+
} = options;
|
|
96
|
+
normalizedOptions = {
|
|
97
|
+
...rest,
|
|
98
|
+
resolver: (0, _DefaultResolver.createDefaultResolver)(baseURL)
|
|
99
|
+
};
|
|
100
|
+
} else if ("resolver" in options && options.resolver) {
|
|
101
|
+
normalizedOptions = options;
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error(`[HotUpdater] Either baseURL or resolver must be provided.\n\n` + `Option 1: Using baseURL (recommended for most cases)\n` + ` export default HotUpdater.wrap({\n` + ` baseURL: "<your-update-server-url>",\n` + ` updateStrategy: "appVersion",\n` + ` updateMode: "auto"\n` + ` })(App);\n\n` + `Option 2: Using custom resolver (advanced)\n` + ` export default HotUpdater.wrap({\n` + ` resolver: {\n` + ` checkUpdate: async (params) => { /* custom logic */ },\n` + ` notifyAppReady: async (params) => { /* custom logic */ }\n` + ` },\n` + ` updateMode: "manual"\n` + ` })(App);\n\n` + `For more information, visit: https://hot-updater.dev/docs/react-native-api/wrap`);
|
|
104
|
+
}
|
|
105
|
+
globalConfig.resolver = normalizedOptions.resolver;
|
|
106
|
+
globalConfig.requestHeaders = options.requestHeaders;
|
|
107
|
+
globalConfig.requestTimeout = options.requestTimeout;
|
|
108
|
+
return (0, _wrap.wrap)(normalizedOptions);
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Reloads the app.
|
|
112
|
+
*/
|
|
113
|
+
reload: _native.reload,
|
|
114
|
+
/**
|
|
115
|
+
* Returns whether an update has finished downloading in this app session.
|
|
116
|
+
*
|
|
117
|
+
* When it returns true, calling `HotUpdater.reload()` (or restarting the app)
|
|
118
|
+
* will apply the downloaded update bundle.
|
|
119
|
+
*
|
|
120
|
+
* - Derived from `progress` reaching 1.0
|
|
121
|
+
* - Resets to false when a new download starts (progress < 1)
|
|
122
|
+
*
|
|
123
|
+
* @returns {boolean} True if a downloaded update is ready to apply
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* if (HotUpdater.isUpdateDownloaded()) {
|
|
127
|
+
* await HotUpdater.reload();
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
isUpdateDownloaded: () => _store.hotUpdaterStore.getSnapshot().isUpdateDownloaded,
|
|
132
|
+
/**
|
|
133
|
+
* Fetches the current app version.
|
|
134
|
+
*/
|
|
135
|
+
getAppVersion: _native.getAppVersion,
|
|
136
|
+
/**
|
|
137
|
+
* Fetches the current bundle ID of the app.
|
|
138
|
+
*/
|
|
139
|
+
getBundleId: _native.getBundleId,
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves the initial bundle ID based on the build time of the native app.
|
|
142
|
+
*/
|
|
143
|
+
getMinBundleId: _native.getMinBundleId,
|
|
144
|
+
/**
|
|
145
|
+
* Fetches the current channel of the app.
|
|
146
|
+
*
|
|
147
|
+
* If no channel is specified, the app is assigned to the 'production' channel.
|
|
148
|
+
*
|
|
149
|
+
* @returns {string} The current release channel of the app
|
|
150
|
+
* @default "production"
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const channel = HotUpdater.getChannel();
|
|
154
|
+
* console.log(`Current channel: ${channel}`);
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
getChannel: _native.getChannel,
|
|
158
|
+
/**
|
|
159
|
+
* Adds a listener to HotUpdater events.
|
|
160
|
+
*
|
|
161
|
+
* @param {keyof HotUpdaterEvent} eventName - The name of the event to listen for
|
|
162
|
+
* @param {(event: HotUpdaterEvent[T]) => void} listener - The callback function to handle the event
|
|
163
|
+
* @returns {() => void} A cleanup function that removes the event listener
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const unsubscribe = HotUpdater.addListener("onProgress", ({ progress }) => {
|
|
168
|
+
* console.log(`Update progress: ${progress * 100}%`);
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
* // Unsubscribe when no longer needed
|
|
172
|
+
* unsubscribe();
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
addListener: _native.addListener,
|
|
176
|
+
/**
|
|
177
|
+
* Manually checks for updates.
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} config - Update check configuration
|
|
180
|
+
* @param {string} config.source - Update server URL
|
|
181
|
+
* @param {Record<string, string>} [config.requestHeaders] - Request headers
|
|
182
|
+
*
|
|
183
|
+
* @returns {Promise<UpdateInfo | null>} Update information or null if up to date
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const updateInfo = await HotUpdater.checkForUpdate({
|
|
188
|
+
* source: "<your-update-server-url>",
|
|
189
|
+
* requestHeaders: {
|
|
190
|
+
* Authorization: "Bearer <your-access-token>",
|
|
191
|
+
* },
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* if (!updateInfo) {
|
|
195
|
+
* console.log("App is up to date");
|
|
196
|
+
* return;
|
|
197
|
+
* }
|
|
198
|
+
*
|
|
199
|
+
* await HotUpdater.updateBundle(updateInfo.id, updateInfo.fileUrl);
|
|
200
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
201
|
+
* await HotUpdater.reload();
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
checkForUpdate: config => {
|
|
206
|
+
const resolver = ensureGlobalResolver("checkForUpdate");
|
|
207
|
+
const mergedConfig = {
|
|
208
|
+
...config,
|
|
209
|
+
resolver,
|
|
210
|
+
requestHeaders: {
|
|
211
|
+
...globalConfig.requestHeaders,
|
|
212
|
+
...config.requestHeaders
|
|
213
|
+
},
|
|
214
|
+
requestTimeout: config.requestTimeout ?? globalConfig.requestTimeout
|
|
215
|
+
};
|
|
216
|
+
return (0, _checkForUpdate.checkForUpdate)(mergedConfig);
|
|
217
|
+
},
|
|
218
|
+
/**
|
|
219
|
+
* Updates the bundle of the app.
|
|
220
|
+
*
|
|
221
|
+
* @param {UpdateBundleParams} params - Parameters object required for bundle update
|
|
222
|
+
* @param {string} params.bundleId - The bundle ID of the app
|
|
223
|
+
* @param {string|null} params.fileUrl - The URL of the zip file
|
|
224
|
+
*
|
|
225
|
+
* @returns {Promise<boolean>} Whether the update was successful
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const updateInfo = await HotUpdater.checkForUpdate({
|
|
230
|
+
* source: "<your-update-server-url>",
|
|
231
|
+
* requestHeaders: {
|
|
232
|
+
* Authorization: "Bearer <your-access-token>",
|
|
233
|
+
* },
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* if (!updateInfo) {
|
|
237
|
+
* return {
|
|
238
|
+
* status: "UP_TO_DATE",
|
|
239
|
+
* };
|
|
240
|
+
* }
|
|
241
|
+
*
|
|
242
|
+
* await HotUpdater.updateBundle({
|
|
243
|
+
* bundleId: updateInfo.id,
|
|
244
|
+
* fileUrl: updateInfo.fileUrl
|
|
245
|
+
* });
|
|
246
|
+
* if (updateInfo.shouldForceUpdate) {
|
|
247
|
+
* await HotUpdater.reload();
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
updateBundle: params => {
|
|
252
|
+
ensureGlobalResolver("updateBundle");
|
|
253
|
+
return (0, _native.updateBundle)(params);
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* Fetches the fingerprint of the app.
|
|
257
|
+
*
|
|
258
|
+
* @returns {string} The fingerprint of the app
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const fingerprint = HotUpdater.getFingerprintHash();
|
|
263
|
+
* console.log(`Fingerprint: ${fingerprint}`);
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
getFingerprintHash: _native.getFingerprintHash,
|
|
267
|
+
/**
|
|
268
|
+
* Gets the list of bundle IDs that have been marked as crashed.
|
|
269
|
+
* These bundles will be rejected if attempted to install again.
|
|
270
|
+
*
|
|
271
|
+
* @returns {string[]} Array of crashed bundle IDs
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* const crashedBundles = HotUpdater.getCrashHistory();
|
|
276
|
+
* console.log("Crashed bundles:", crashedBundles);
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
getCrashHistory: _native.getCrashHistory,
|
|
280
|
+
/**
|
|
281
|
+
* Clears the crashed bundle history, allowing previously crashed bundles
|
|
282
|
+
* to be installed again.
|
|
283
|
+
*
|
|
284
|
+
* @returns {boolean} true if clearing was successful
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* // Clear crash history to allow retrying a previously failed bundle
|
|
289
|
+
* HotUpdater.clearCrashHistory();
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
clearCrashHistory: _native.clearCrashHistory
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const HotUpdater = exports.HotUpdater = createHotUpdaterClient();
|
|
255
296
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_checkForUpdate","require","
|
|
1
|
+
{"version":3,"names":["_checkForUpdate","require","_DefaultResolver","_native","_store","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_wrap","_types","addListener","progress","hotUpdaterStore","setState","createHotUpdaterClient","globalConfig","resolver","ensureGlobalResolver","methodName","Error","wrap","options","normalizedOptions","baseURL","rest","createDefaultResolver","requestHeaders","requestTimeout","reload","isUpdateDownloaded","getSnapshot","getAppVersion","getBundleId","getMinBundleId","getChannel","checkForUpdate","config","mergedConfig","updateBundle","params","getFingerprintHash","getCrashHistory","clearCrashHistory","HotUpdater"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;A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,CAAC,CAACD,kBAAkB;IAE1E;AACJ;AACA;IACIE,aAAa,EAAbA,qBAAa;IAEb;AACJ;AACA;IACIC,WAAW,EAAXA,mBAAW;IAEX;AACJ;AACA;IACIC,cAAc,EAAdA,sBAAc;IAEd;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIC,UAAU,EAAVA,kBAAU;IAEV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIxB,WAAW,EAAXA,mBAAW;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;IACIyB,cAAc,EAAGC,MAA6B,IAAK;MACjD,MAAMpB,QAAQ,GAAGC,oBAAoB,CAAC,gBAAgB,CAAC;MAEvD,MAAMoB,YAA2C,GAAG;QAClD,GAAGD,MAAM;QACTpB,QAAQ;QACRU,cAAc,EAAE;UACd,GAAGX,YAAY,CAACW,cAAc;UAC9B,GAAGU,MAAM,CAACV;QACZ,CAAC;QACDC,cAAc,EAAES,MAAM,CAACT,cAAc,IAAIZ,YAAY,CAACY;MACxD,CAAC;MAED,OAAO,IAAAQ,8BAAc,EAACE,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;IACIC,YAAY,EAAGC,MAAoB,IAAK;MACtCtB,oBAAoB,CAAC,cAAc,CAAC;MACpC,OAAO,IAAAqB,oBAAY,EAACC,MAAM,CAAC;IAC7B,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIC,kBAAkB,EAAlBA,0BAAkB;IAElB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIC,eAAe,EAAfA,uBAAe;IAEf;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACIC,iBAAiB,EAAjBA;EACF,CAAC;AACH;AAEO,MAAMC,UAAU,GAAAvC,OAAA,CAAAuC,UAAA,GAAG7B,sBAAsB,CAAC,CAAC","ignoreList":[]}
|