@onekeyfe/react-native-bundle-update 1.1.41 → 1.1.43

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.
@@ -241,13 +241,107 @@ object BundleUpdateStoreAndroid {
241
241
  fun getBuiltinBundleVersion(context: Context): String {
242
242
  return try {
243
243
  val appInfo = context.packageManager.getApplicationInfo(context.packageName, android.content.pm.PackageManager.GET_META_DATA)
244
- appInfo.metaData?.getString("BUNDLE_VERSION") ?: ""
244
+ appInfo.metaData?.get("BUNDLE_VERSION")?.toString() ?: ""
245
245
  } catch (e: Exception) {
246
246
  OneKeyLog.error("BundleUpdate", "Error getting builtin bundle version: ${e.message}")
247
247
  ""
248
248
  }
249
249
  }
250
250
 
251
+ // Pre-launch pending task processing
252
+
253
+ @Volatile
254
+ private var didProcessPreLaunchTask = false
255
+
256
+ /**
257
+ * Checks MMKV for a pending bundle-switch task and applies it before JS runtime starts.
258
+ * Only handles the happy path (status=pending, bundle exists, env matches).
259
+ * All complex logic (retry, download, error handling) remains in JS layer.
260
+ */
261
+ fun processPreLaunchPendingTask(context: Context) {
262
+ if (didProcessPreLaunchTask) return
263
+ didProcessPreLaunchTask = true
264
+ try {
265
+ // 1. Read MMKV
266
+ MMKV.initialize(context)
267
+ val mmkv = MMKV.mmkvWithID("onekey-app-setting") ?: return
268
+ val taskJson = mmkv.decodeString("onekey_pending_install_task") ?: return
269
+ val taskObj = JSONObject(taskJson)
270
+
271
+ // 2. Validate task fields
272
+ if (taskObj.optString("status") != "pending") return
273
+ if (taskObj.optString("action") != "switch-bundle") return
274
+ if (taskObj.optString("type") != "jsbundle-switch") return
275
+
276
+ val now = System.currentTimeMillis()
277
+ if (taskObj.optLong("expiresAt", 0) <= now) return
278
+ val nextRetryAt = taskObj.optLong("nextRetryAt", 0)
279
+ if (nextRetryAt > 0 && nextRetryAt > now) return
280
+
281
+ // 3. Verify scheduledEnv matches current state
282
+ val currentAppVersion = getAppVersion(context) ?: return
283
+ if (taskObj.optString("scheduledEnvAppVersion") != currentAppVersion) return
284
+
285
+ val currentBV = getCurrentBundleVersion(context)
286
+ val currentBundleVersionStr = if (currentBV != null) {
287
+ val idx = currentBV.lastIndexOf("-")
288
+ if (idx > 0) currentBV.substring(idx + 1) else getBuiltinBundleVersion(context)
289
+ } else {
290
+ getBuiltinBundleVersion(context)
291
+ }
292
+ if (taskObj.optString("scheduledEnvBundleVersion") != currentBundleVersionStr) return
293
+
294
+ // 4. Extract payload
295
+ val payload = taskObj.optJSONObject("payload") ?: return
296
+ val appVersion = payload.optString("appVersion")
297
+ val bundleVersion = payload.optString("bundleVersion")
298
+ val signature = payload.optString("signature")
299
+ if (appVersion.isEmpty() || bundleVersion.isEmpty()) return
300
+
301
+ // 5. Verify bundle directory and entry file exist
302
+ val folderName = "$appVersion-$bundleVersion"
303
+ val bundleDirPath = File(getBundleDir(context), folderName)
304
+ if (!bundleDirPath.exists()) return
305
+ val entryFile = File(bundleDirPath, "main.jsbundle.hbc")
306
+ if (!entryFile.exists()) {
307
+ OneKeyLog.warn("BundleUpdate", "processPreLaunchPendingTask: bundle dir exists but entry file missing: ${entryFile.absolutePath}")
308
+ return
309
+ }
310
+
311
+ // 6. Apply (same as installBundle) — use commit() for synchronous writes
312
+ // to ensure all prefs are persisted atomically before proceeding.
313
+ val bundlePrefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
314
+ val versionPrefs = context.getSharedPreferences(NATIVE_VERSION_PREFS_NAME, Context.MODE_PRIVATE)
315
+ val currentVersion = bundlePrefs.getString(CURRENT_BUNDLE_VERSION_KEY, "")
316
+ bundlePrefs.edit()
317
+ .putString(CURRENT_BUNDLE_VERSION_KEY, folderName)
318
+ .apply {
319
+ if (!currentVersion.isNullOrEmpty()) {
320
+ remove(currentVersion) // legacy signature key cleanup
321
+ }
322
+ }
323
+ .commit()
324
+ if (!signature.isNullOrEmpty()) {
325
+ writeSignatureFile(context, folderName, signature)
326
+ }
327
+ versionPrefs.edit()
328
+ .putString("nativeVersion", currentAppVersion)
329
+ .putString("nativeBuildNumber", getBuildNumber(context))
330
+ .commit()
331
+
332
+ // 7. Update MMKV task status → applied_waiting_verify
333
+ // Do NOT set runningStartedAt — a falsy value lets JS skip the
334
+ // 10-minute grace period and verify alignment immediately on boot.
335
+ taskObj.put("status", "applied_waiting_verify")
336
+ taskObj.remove("runningStartedAt")
337
+ mmkv.encode("onekey_pending_install_task", taskObj.toString())
338
+
339
+ OneKeyLog.info("BundleUpdate", "processPreLaunchPendingTask: switched to $folderName")
340
+ } catch (e: Exception) {
341
+ OneKeyLog.error("BundleUpdate", "processPreLaunchPendingTask failed: ${e.message}")
342
+ }
343
+ }
344
+
251
345
  fun calculateSHA256(filePath: String): String? {
252
346
  return try {
253
347
  val digest = MessageDigest.getInstance("SHA-256")
@@ -536,6 +630,7 @@ object BundleUpdateStoreAndroid {
536
630
  }
537
631
 
538
632
  fun getCurrentBundleMainJSBundle(context: Context): String? {
633
+ processPreLaunchPendingTask(context)
539
634
  return try {
540
635
  val currentAppVersion = getAppVersion(context)
541
636
  val currentBundleVersion = getCurrentBundleVersion(context) ?: run {
@@ -1103,16 +1198,37 @@ class ReactNativeBundleUpdate : HybridReactNativeBundleUpdateSpec() {
1103
1198
  }
1104
1199
  }
1105
1200
 
1201
+ override fun clearDownload(): Promise<Unit> {
1202
+ return Promise.async {
1203
+ OneKeyLog.info("BundleUpdate", "clearDownload: clearing download directory...")
1204
+ val context = getContext()
1205
+ val downloadDir = File(BundleUpdateStoreAndroid.getDownloadBundleDir(context))
1206
+ if (downloadDir.exists()) {
1207
+ BundleUpdateStoreAndroid.deleteDir(downloadDir)
1208
+ OneKeyLog.info("BundleUpdate", "clearDownload: download directory deleted")
1209
+ } else {
1210
+ OneKeyLog.info("BundleUpdate", "clearDownload: download directory does not exist, skipping")
1211
+ }
1212
+ isDownloading.set(false)
1213
+ OneKeyLog.info("BundleUpdate", "clearDownload: completed")
1214
+ }
1215
+ }
1216
+
1106
1217
  override fun clearBundle(): Promise<Unit> {
1107
1218
  return Promise.async {
1108
- OneKeyLog.info("BundleUpdate", "clearBundle: clearing download directory...")
1219
+ OneKeyLog.info("BundleUpdate", "clearBundle: clearing download and bundle directories...")
1109
1220
  val context = getContext()
1221
+ // Clear download directory
1110
1222
  val downloadDir = File(BundleUpdateStoreAndroid.getDownloadBundleDir(context))
1111
1223
  if (downloadDir.exists()) {
1112
1224
  BundleUpdateStoreAndroid.deleteDir(downloadDir)
1113
1225
  OneKeyLog.info("BundleUpdate", "clearBundle: download directory deleted")
1114
- } else {
1115
- OneKeyLog.info("BundleUpdate", "clearBundle: download directory does not exist, skipping")
1226
+ }
1227
+ // Clear installed bundle directory
1228
+ val bundleDir = File(BundleUpdateStoreAndroid.getBundleDir(context))
1229
+ if (bundleDir.exists()) {
1230
+ BundleUpdateStoreAndroid.deleteDir(bundleDir)
1231
+ OneKeyLog.info("BundleUpdate", "clearBundle: bundle directory deleted")
1116
1232
  }
1117
1233
  isDownloading.set(false)
1118
1234
  OneKeyLog.info("BundleUpdate", "clearBundle: completed")
@@ -202,6 +202,98 @@ public class BundleUpdateStore: NSObject {
202
202
  Bundle.main.infoDictionary?["BUNDLE_VERSION"] as? String ?? ""
203
203
  }
204
204
 
205
+ // MARK: - Pre-launch pending task processing
206
+
207
+ private static var didProcessPreLaunchTask = false
208
+
209
+ /// Checks MMKV for a pending bundle-switch task and applies it before JS runtime starts.
210
+ /// Only handles the happy path (status=pending, bundle exists, env matches).
211
+ /// All complex logic (retry, download, error handling) remains in JS layer.
212
+ public static func processPreLaunchPendingTask() {
213
+ guard !didProcessPreLaunchTask else { return }
214
+ didProcessPreLaunchTask = true
215
+
216
+ do {
217
+ // 1. Read MMKV (same pattern as isDevSettingsEnabled)
218
+ MMKV.initialize(rootDir: nil)
219
+ guard let mmkv = MMKV(mmapID: "onekey-app-setting"),
220
+ let taskJson = mmkv.string(forKey: "onekey_pending_install_task"),
221
+ let data = taskJson.data(using: .utf8),
222
+ let taskDict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
223
+ else { return }
224
+
225
+ // 2. Validate task fields
226
+ guard taskDict["status"] as? String == "pending",
227
+ taskDict["action"] as? String == "switch-bundle",
228
+ taskDict["type"] as? String == "jsbundle-switch"
229
+ else { return }
230
+
231
+ let now = Int64(Date().timeIntervalSince1970 * 1000)
232
+ guard let expiresAtNum = taskDict["expiresAt"] as? NSNumber else { return }
233
+ let expiresAt = expiresAtNum.int64Value
234
+ guard expiresAt > now else { return }
235
+ if let nextRetryAtNum = taskDict["nextRetryAt"] as? NSNumber {
236
+ if nextRetryAtNum.int64Value > now { return }
237
+ }
238
+
239
+ // 3. Verify scheduledEnv matches current state
240
+ let currentAppVersion = getCurrentNativeVersion()
241
+ guard taskDict["scheduledEnvAppVersion"] as? String == currentAppVersion else { return }
242
+
243
+ let currentBundleVersionStr: String
244
+ if let cbv = currentBundleVersion(),
245
+ let dashRange = cbv.range(of: "-", options: .backwards) {
246
+ currentBundleVersionStr = String(cbv[dashRange.upperBound...])
247
+ } else {
248
+ currentBundleVersionStr = getBuiltinBundleVersion()
249
+ }
250
+ guard taskDict["scheduledEnvBundleVersion"] as? String == currentBundleVersionStr else { return }
251
+
252
+ // 4. Extract payload
253
+ guard let payload = taskDict["payload"] as? [String: Any],
254
+ let appVersion = payload["appVersion"] as? String,
255
+ let bundleVersion = payload["bundleVersion"] as? String,
256
+ let signature = payload["signature"] as? String,
257
+ !appVersion.isEmpty, !bundleVersion.isEmpty
258
+ else { return }
259
+
260
+ // 5. Verify bundle directory and entry file exist
261
+ let folderName = "\(appVersion)-\(bundleVersion)"
262
+ let bundleDirPath = (bundleDir() as NSString).appendingPathComponent(folderName)
263
+ guard FileManager.default.fileExists(atPath: bundleDirPath) else { return }
264
+ let entryFilePath = (bundleDirPath as NSString).appendingPathComponent("main.jsbundle.hbc")
265
+ guard FileManager.default.fileExists(atPath: entryFilePath) else {
266
+ OneKeyLog.warn("BundleUpdate", "processPreLaunchPendingTask: bundle dir exists but entry file missing: \(entryFilePath)")
267
+ return
268
+ }
269
+
270
+ // 6. Apply: set currentBundleVersion (same as installBundle)
271
+ let ud = UserDefaults.standard
272
+ ud.set(folderName, forKey: bundlePrefsKey)
273
+ if !signature.isEmpty {
274
+ writeSignatureFile(folderName, signature: signature)
275
+ }
276
+ setNativeVersion(currentAppVersion)
277
+ setNativeBuildNumber(getCurrentNativeBuildNumber())
278
+ ud.synchronize()
279
+
280
+ // 7. Update MMKV task status → applied_waiting_verify
281
+ // Do NOT set runningStartedAt — a falsy value lets JS skip the
282
+ // 10-minute grace period and verify alignment immediately on boot.
283
+ var updatedTask = taskDict
284
+ updatedTask["status"] = "applied_waiting_verify"
285
+ updatedTask.removeValue(forKey: "runningStartedAt")
286
+ let jsonData = try JSONSerialization.data(withJSONObject: updatedTask)
287
+ if let jsonStr = String(data: jsonData, encoding: .utf8) {
288
+ mmkv.set(jsonStr, forKey: "onekey_pending_install_task")
289
+ }
290
+
291
+ OneKeyLog.info("BundleUpdate", "processPreLaunchPendingTask: switched to \(folderName)")
292
+ } catch {
293
+ OneKeyLog.error("BundleUpdate", "processPreLaunchPendingTask failed: \(error)")
294
+ }
295
+ }
296
+
205
297
  public static func getMetadataFilePath(_ currentBundleVersion: String) -> String? {
206
298
  let path = (bundleDir() as NSString)
207
299
  .appendingPathComponent(currentBundleVersion)
@@ -406,6 +498,7 @@ public class BundleUpdateStore: NSObject {
406
498
  }
407
499
 
408
500
  public static func currentBundleMainJSBundle() -> String? {
501
+ processPreLaunchPendingTask()
409
502
  guard let currentBundleVer = currentBundleVersion() else {
410
503
  OneKeyLog.warn("BundleUpdate", "getJsBundlePath: no currentBundleVersion stored")
411
504
  return nil
@@ -1052,15 +1145,38 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
1052
1145
  }
1053
1146
  }
1054
1147
 
1148
+ func clearDownload() throws -> Promise<Void> {
1149
+ return Promise.async { [weak self] in
1150
+ OneKeyLog.info("BundleUpdate", "clearDownload: clearing download directory and cancelling downloads...")
1151
+ let downloadDir = BundleUpdateStore.downloadBundleDir()
1152
+ if FileManager.default.fileExists(atPath: downloadDir) {
1153
+ try FileManager.default.removeItem(atPath: downloadDir)
1154
+ OneKeyLog.info("BundleUpdate", "clearDownload: download directory deleted")
1155
+ } else {
1156
+ OneKeyLog.info("BundleUpdate", "clearDownload: download directory does not exist, skipping")
1157
+ }
1158
+ // Cancel all in-flight downloads by invalidating the session
1159
+ self?.urlSession?.invalidateAndCancel()
1160
+ self?.urlSession = self?.createURLSession()
1161
+ self?.stateQueue.sync { self?.isDownloading = false }
1162
+ OneKeyLog.info("BundleUpdate", "clearDownload: completed")
1163
+ }
1164
+ }
1165
+
1055
1166
  func clearBundle() throws -> Promise<Void> {
1056
1167
  return Promise.async { [weak self] in
1057
- OneKeyLog.info("BundleUpdate", "clearBundle: clearing download directory and cancelling downloads...")
1168
+ OneKeyLog.info("BundleUpdate", "clearBundle: clearing download and bundle directories...")
1169
+ // Clear download directory
1058
1170
  let downloadDir = BundleUpdateStore.downloadBundleDir()
1059
1171
  if FileManager.default.fileExists(atPath: downloadDir) {
1060
1172
  try FileManager.default.removeItem(atPath: downloadDir)
1061
1173
  OneKeyLog.info("BundleUpdate", "clearBundle: download directory deleted")
1062
- } else {
1063
- OneKeyLog.info("BundleUpdate", "clearBundle: download directory does not exist, skipping")
1174
+ }
1175
+ // Clear installed bundle directory
1176
+ let bundleDir = BundleUpdateStore.bundleDir()
1177
+ if FileManager.default.fileExists(atPath: bundleDir) {
1178
+ try FileManager.default.removeItem(atPath: bundleDir)
1179
+ OneKeyLog.info("BundleUpdate", "clearBundle: bundle directory deleted")
1064
1180
  }
1065
1181
  // Cancel all in-flight downloads by invalidating the session
1066
1182
  self?.urlSession?.invalidateAndCancel()
@@ -77,6 +77,7 @@ export interface ReactNativeBundleUpdate extends HybridObject<{
77
77
  verifyBundleASC(params: BundleVerifyASCParams): Promise<void>;
78
78
  downloadBundleASC(params: BundleDownloadASCParams): Promise<void>;
79
79
  installBundle(params: BundleInstallParams): Promise<void>;
80
+ clearDownload(): Promise<void>;
80
81
  clearBundle(): Promise<void>;
81
82
  clearAllJSBundleData(): Promise<TestResult>;
82
83
  resetToBuiltInBundle(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeBundleUpdate.nitro.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeBundleUpdate.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;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,CAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,sBAAsB,CACpB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,sBAAsB,CACpB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,0BAA0B,CACxB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IAGvB,mBAAmB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAAG,MAAM,CAAC;IAC5E,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C"}
1
+ {"version":3,"file":"ReactNativeBundleUpdate.nitro.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeBundleUpdate.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,W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BAA4B,IAAI,OAAO,CAAC;IACxC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5E,qBAAqB,CACnB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,gBAAgB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC/C,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACvC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAGzD,kBAAkB,CAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,sBAAsB,CACpB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,sBAAsB,CACpB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,0BAA0B,CACxB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IAGvB,mBAAmB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAAG,MAAM,CAAC;IAC5E,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C"}
@@ -172,6 +172,21 @@ namespace margelo::nitro::reactnativebundleupdate {
172
172
  return __promise;
173
173
  }();
174
174
  }
175
+ std::shared_ptr<Promise<void>> JHybridReactNativeBundleUpdateSpec::clearDownload() {
176
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("clearDownload");
177
+ auto __result = method(_javaPart);
178
+ return [&]() {
179
+ auto __promise = Promise<void>::create();
180
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
181
+ __promise->resolve();
182
+ });
183
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
184
+ jni::JniException __jniError(__throwable);
185
+ __promise->reject(std::make_exception_ptr(__jniError));
186
+ });
187
+ return __promise;
188
+ }();
189
+ }
175
190
  std::shared_ptr<Promise<void>> JHybridReactNativeBundleUpdateSpec::clearBundle() {
176
191
  static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("clearBundle");
177
192
  auto __result = method(_javaPart);
@@ -59,6 +59,7 @@ namespace margelo::nitro::reactnativebundleupdate {
59
59
  std::shared_ptr<Promise<void>> verifyBundleASC(const BundleVerifyASCParams& params) override;
60
60
  std::shared_ptr<Promise<void>> downloadBundleASC(const BundleDownloadASCParams& params) override;
61
61
  std::shared_ptr<Promise<void>> installBundle(const BundleInstallParams& params) override;
62
+ std::shared_ptr<Promise<void>> clearDownload() override;
62
63
  std::shared_ptr<Promise<void>> clearBundle() override;
63
64
  std::shared_ptr<Promise<TestResult>> clearAllJSBundleData() override;
64
65
  std::shared_ptr<Promise<void>> resetToBuiltInBundle() override;
@@ -66,6 +66,10 @@ abstract class HybridReactNativeBundleUpdateSpec: HybridObject() {
66
66
  @Keep
67
67
  abstract fun installBundle(params: BundleInstallParams): Promise<Unit>
68
68
 
69
+ @DoNotStrip
70
+ @Keep
71
+ abstract fun clearDownload(): Promise<Unit>
72
+
69
73
  @DoNotStrip
70
74
  @Keep
71
75
  abstract fun clearBundle(): Promise<Unit>
@@ -138,6 +138,14 @@ namespace margelo::nitro::reactnativebundleupdate {
138
138
  auto __value = std::move(__result.value());
139
139
  return __value;
140
140
  }
141
+ inline std::shared_ptr<Promise<void>> clearDownload() override {
142
+ auto __result = _swiftPart.clearDownload();
143
+ if (__result.hasError()) [[unlikely]] {
144
+ std::rethrow_exception(__result.error());
145
+ }
146
+ auto __value = std::move(__result.value());
147
+ return __value;
148
+ }
141
149
  inline std::shared_ptr<Promise<void>> clearBundle() override {
142
150
  auto __result = _swiftPart.clearBundle();
143
151
  if (__result.hasError()) [[unlikely]] {
@@ -19,6 +19,7 @@ public protocol HybridReactNativeBundleUpdateSpec_protocol: HybridObject {
19
19
  func verifyBundleASC(params: BundleVerifyASCParams) throws -> Promise<Void>
20
20
  func downloadBundleASC(params: BundleDownloadASCParams) throws -> Promise<Void>
21
21
  func installBundle(params: BundleInstallParams) throws -> Promise<Void>
22
+ func clearDownload() throws -> Promise<Void>
22
23
  func clearBundle() throws -> Promise<Void>
23
24
  func clearAllJSBundleData() throws -> Promise<TestResult>
24
25
  func resetToBuiltInBundle() throws -> Promise<Void>
@@ -212,6 +212,25 @@ open class HybridReactNativeBundleUpdateSpec_cxx {
212
212
  }
213
213
  }
214
214
 
215
+ @inline(__always)
216
+ public final func clearDownload() -> bridge.Result_std__shared_ptr_Promise_void___ {
217
+ do {
218
+ let __result = try self.__implementation.clearDownload()
219
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
220
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
221
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
222
+ __result
223
+ .then({ __result in __promiseHolder.resolve() })
224
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
225
+ return __promise
226
+ }()
227
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
228
+ } catch (let __error) {
229
+ let __exceptionPtr = __error.toCpp()
230
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
231
+ }
232
+ }
233
+
215
234
  @inline(__always)
216
235
  public final func clearBundle() -> bridge.Result_std__shared_ptr_Promise_void___ {
217
236
  do {
@@ -19,6 +19,7 @@ namespace margelo::nitro::reactnativebundleupdate {
19
19
  prototype.registerHybridMethod("verifyBundleASC", &HybridReactNativeBundleUpdateSpec::verifyBundleASC);
20
20
  prototype.registerHybridMethod("downloadBundleASC", &HybridReactNativeBundleUpdateSpec::downloadBundleASC);
21
21
  prototype.registerHybridMethod("installBundle", &HybridReactNativeBundleUpdateSpec::installBundle);
22
+ prototype.registerHybridMethod("clearDownload", &HybridReactNativeBundleUpdateSpec::clearDownload);
22
23
  prototype.registerHybridMethod("clearBundle", &HybridReactNativeBundleUpdateSpec::clearBundle);
23
24
  prototype.registerHybridMethod("clearAllJSBundleData", &HybridReactNativeBundleUpdateSpec::clearAllJSBundleData);
24
25
  prototype.registerHybridMethod("resetToBuiltInBundle", &HybridReactNativeBundleUpdateSpec::resetToBuiltInBundle);
@@ -91,6 +91,7 @@ namespace margelo::nitro::reactnativebundleupdate {
91
91
  virtual std::shared_ptr<Promise<void>> verifyBundleASC(const BundleVerifyASCParams& params) = 0;
92
92
  virtual std::shared_ptr<Promise<void>> downloadBundleASC(const BundleDownloadASCParams& params) = 0;
93
93
  virtual std::shared_ptr<Promise<void>> installBundle(const BundleInstallParams& params) = 0;
94
+ virtual std::shared_ptr<Promise<void>> clearDownload() = 0;
94
95
  virtual std::shared_ptr<Promise<void>> clearBundle() = 0;
95
96
  virtual std::shared_ptr<Promise<TestResult>> clearAllJSBundleData() = 0;
96
97
  virtual std::shared_ptr<Promise<void>> resetToBuiltInBundle() = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-bundle-update",
3
- "version": "1.1.41",
3
+ "version": "1.1.43",
4
4
  "description": "react-native-bundle-update",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -95,6 +95,7 @@ export interface ReactNativeBundleUpdate
95
95
  installBundle(params: BundleInstallParams): Promise<void>;
96
96
 
97
97
  // Clear
98
+ clearDownload(): Promise<void>;
98
99
  clearBundle(): Promise<void>;
99
100
  clearAllJSBundleData(): Promise<TestResult>;
100
101
  resetToBuiltInBundle(): Promise<void>;