@onekeyfe/react-native-bundle-update 1.1.47 → 1.1.48
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/margelo/nitro/reactnativebundleupdate/ReactNativeBundleUpdate.kt +123 -12
- package/ios/ReactNativeBundleUpdate.swift +165 -13
- package/lib/typescript/src/ReactNativeBundleUpdate.nitro.d.ts +2 -0
- package/lib/typescript/src/ReactNativeBundleUpdate.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridReactNativeBundleUpdateSpec.cpp +21 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeBundleUpdateSpec.hpp +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/HybridReactNativeBundleUpdateSpec.kt +8 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeBundleUpdateSpecSwift.hpp +16 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeBundleUpdateSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeBundleUpdateSpec_cxx.swift +31 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeBundleUpdateSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeBundleUpdateSpec.hpp +2 -0
- package/package.json +1 -1
- package/src/ReactNativeBundleUpdate.nitro.ts +2 -0
package/android/src/main/java/com/margelo/nitro/reactnativebundleupdate/ReactNativeBundleUpdate.kt
CHANGED
|
@@ -97,6 +97,11 @@ object BundleUpdateStoreAndroid {
|
|
|
97
97
|
private const val PREFS_NAME = "BundleUpdatePrefs"
|
|
98
98
|
internal const val NATIVE_VERSION_PREFS_NAME = "NativeVersionPrefs"
|
|
99
99
|
private const val CURRENT_BUNDLE_VERSION_KEY = "currentBundleVersion"
|
|
100
|
+
private const val MAIN_JS_BUNDLE_FILE_NAME = "main.jsbundle.hbc"
|
|
101
|
+
private const val BACKGROUND_BUNDLE_FILE_NAME = "background.bundle"
|
|
102
|
+
private const val METADATA_REQUIRES_BACKGROUND_BUNDLE_KEY = "requiresBackgroundBundle"
|
|
103
|
+
private const val METADATA_BACKGROUND_PROTOCOL_VERSION_KEY = "backgroundProtocolVersion"
|
|
104
|
+
private const val SUPPORTED_BACKGROUND_PROTOCOL_VERSION = "1"
|
|
100
105
|
|
|
101
106
|
fun getDownloadBundleDir(context: Context): String {
|
|
102
107
|
val dir = File(context.filesDir, "onekey-bundle-download")
|
|
@@ -401,6 +406,26 @@ object BundleUpdateStoreAndroid {
|
|
|
401
406
|
return metadata
|
|
402
407
|
}
|
|
403
408
|
|
|
409
|
+
private fun isReservedMetadataKey(key: String): Boolean {
|
|
410
|
+
return key == METADATA_REQUIRES_BACKGROUND_BUNDLE_KEY ||
|
|
411
|
+
key == METADATA_BACKGROUND_PROTOCOL_VERSION_KEY
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private fun getFileMetadataEntries(metadata: Map<String, String>): Map<String, String> {
|
|
415
|
+
return metadata.filterKeys { key -> !isReservedMetadataKey(key) }
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
private fun metadataRequiresBackgroundBundle(metadata: Map<String, String>): Boolean {
|
|
419
|
+
return metadata[METADATA_REQUIRES_BACKGROUND_BUNDLE_KEY]
|
|
420
|
+
?.lowercase()
|
|
421
|
+
?.let { value -> value == "1" || value == "true" || value == "yes" }
|
|
422
|
+
?: false
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private fun metadataBackgroundProtocolVersion(metadata: Map<String, String>): String {
|
|
426
|
+
return metadata[METADATA_BACKGROUND_PROTOCOL_VERSION_KEY] ?: ""
|
|
427
|
+
}
|
|
428
|
+
|
|
404
429
|
fun readMetadataFileSha256(signature: String?): String? {
|
|
405
430
|
if (signature.isNullOrEmpty()) return null
|
|
406
431
|
|
|
@@ -534,11 +559,12 @@ object BundleUpdateStoreAndroid {
|
|
|
534
559
|
val parentBundleDir = getBundleDir(context)
|
|
535
560
|
val folderName = "$appVersion-$bundleVersion"
|
|
536
561
|
val jsBundleDir = File(parentBundleDir, folderName).absolutePath + "/"
|
|
562
|
+
val fileEntries = getFileMetadataEntries(metadata)
|
|
537
563
|
|
|
538
|
-
if (!validateFilesRecursive(dir,
|
|
564
|
+
if (!validateFilesRecursive(dir, fileEntries, jsBundleDir)) return false
|
|
539
565
|
|
|
540
566
|
// Verify completeness
|
|
541
|
-
for (entry in
|
|
567
|
+
for (entry in fileEntries.entries) {
|
|
542
568
|
val expectedFile = File(jsBundleDir + entry.key)
|
|
543
569
|
if (!expectedFile.exists()) {
|
|
544
570
|
OneKeyLog.error("BundleUpdate", "[bundle-verify] File listed in metadata but missing on disk: ${entry.key}")
|
|
@@ -637,7 +663,48 @@ object BundleUpdateStoreAndroid {
|
|
|
637
663
|
}
|
|
638
664
|
}
|
|
639
665
|
|
|
640
|
-
fun
|
|
666
|
+
fun validateBundlePairCompatibility(bundleDir: String, metadata: Map<String, String>): Boolean {
|
|
667
|
+
val mainBundleFile = File(bundleDir, MAIN_JS_BUNDLE_FILE_NAME)
|
|
668
|
+
if (!mainBundleFile.exists()) {
|
|
669
|
+
OneKeyLog.error(
|
|
670
|
+
"BundleUpdate",
|
|
671
|
+
"bundle pair invalid: main.jsbundle.hbc is missing at ${mainBundleFile.absolutePath}",
|
|
672
|
+
)
|
|
673
|
+
return false
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (!metadataRequiresBackgroundBundle(metadata)) {
|
|
677
|
+
return true
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
val protocolVersion = metadataBackgroundProtocolVersion(metadata)
|
|
681
|
+
if (protocolVersion.isEmpty() || protocolVersion != SUPPORTED_BACKGROUND_PROTOCOL_VERSION) {
|
|
682
|
+
OneKeyLog.error(
|
|
683
|
+
"BundleUpdate",
|
|
684
|
+
"backgroundProtocolVersion mismatch: expected=$SUPPORTED_BACKGROUND_PROTOCOL_VERSION, actual=$protocolVersion",
|
|
685
|
+
)
|
|
686
|
+
return false
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
val backgroundBundleFile = File(bundleDir, BACKGROUND_BUNDLE_FILE_NAME)
|
|
690
|
+
if (!backgroundBundleFile.exists()) {
|
|
691
|
+
OneKeyLog.error(
|
|
692
|
+
"BundleUpdate",
|
|
693
|
+
"requiresBackgroundBundle is true but background.bundle is missing at ${backgroundBundleFile.absolutePath}",
|
|
694
|
+
)
|
|
695
|
+
return false
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return true
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
private data class ValidatedBundleInfo(
|
|
702
|
+
val bundleDir: String,
|
|
703
|
+
val currentBundleVersion: String,
|
|
704
|
+
val metadata: Map<String, String>,
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
private fun getValidatedCurrentBundleInfo(context: Context): ValidatedBundleInfo? {
|
|
641
708
|
processPreLaunchPendingTask(context)
|
|
642
709
|
return try {
|
|
643
710
|
val currentAppVersion = getAppVersion(context)
|
|
@@ -651,7 +718,7 @@ object BundleUpdateStoreAndroid {
|
|
|
651
718
|
val prevNativeVersion = getNativeVersion(context)
|
|
652
719
|
if (prevNativeVersion.isEmpty()) {
|
|
653
720
|
OneKeyLog.warn("BundleUpdate", "getJsBundlePath: prevNativeVersion is empty")
|
|
654
|
-
return
|
|
721
|
+
return null
|
|
655
722
|
}
|
|
656
723
|
|
|
657
724
|
if (currentAppVersion != prevNativeVersion) {
|
|
@@ -707,23 +774,42 @@ object BundleUpdateStoreAndroid {
|
|
|
707
774
|
}
|
|
708
775
|
}
|
|
709
776
|
|
|
710
|
-
|
|
711
|
-
val mainJSBundlePath = mainJSBundleFile.absolutePath
|
|
712
|
-
OneKeyLog.info("BundleUpdate", "mainJSBundlePath: $mainJSBundlePath")
|
|
713
|
-
if (!mainJSBundleFile.exists()) {
|
|
714
|
-
OneKeyLog.info("BundleUpdate", "mainJSBundleFile does not exist")
|
|
777
|
+
if (!validateBundlePairCompatibility(bundleDir, metadata)) {
|
|
715
778
|
return null
|
|
716
779
|
}
|
|
717
|
-
|
|
780
|
+
|
|
781
|
+
ValidatedBundleInfo(
|
|
782
|
+
bundleDir = bundleDir,
|
|
783
|
+
currentBundleVersion = currentBundleVersion,
|
|
784
|
+
metadata = metadata,
|
|
785
|
+
)
|
|
718
786
|
} catch (e: Exception) {
|
|
719
787
|
OneKeyLog.error("BundleUpdate", "Error getting bundle: ${e.message}")
|
|
720
788
|
null
|
|
721
789
|
}
|
|
722
790
|
}
|
|
723
791
|
|
|
792
|
+
fun getCurrentBundleEntryPath(context: Context, entryFileName: String): String? {
|
|
793
|
+
val bundleInfo = getValidatedCurrentBundleInfo(context) ?: return null
|
|
794
|
+
val entryFile = File(bundleInfo.bundleDir, entryFileName)
|
|
795
|
+
if (!entryFile.exists()) {
|
|
796
|
+
OneKeyLog.info("BundleUpdate", "$entryFileName does not exist")
|
|
797
|
+
return null
|
|
798
|
+
}
|
|
799
|
+
return entryFile.absolutePath
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
fun getCurrentBundleMainJSBundle(context: Context): String? {
|
|
803
|
+
return getCurrentBundleEntryPath(context, MAIN_JS_BUNDLE_FILE_NAME)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
fun getCurrentBundleBackgroundJSBundle(context: Context): String? {
|
|
807
|
+
return getCurrentBundleEntryPath(context, BACKGROUND_BUNDLE_FILE_NAME)
|
|
808
|
+
}
|
|
809
|
+
|
|
724
810
|
fun getWebEmbedPath(context: Context): String {
|
|
725
|
-
val
|
|
726
|
-
return File(
|
|
811
|
+
val bundleInfo = getValidatedCurrentBundleInfo(context) ?: return ""
|
|
812
|
+
return File(bundleInfo.bundleDir, "web-embed").absolutePath
|
|
727
813
|
}
|
|
728
814
|
|
|
729
815
|
/**
|
|
@@ -1098,6 +1184,11 @@ class ReactNativeBundleUpdate : HybridReactNativeBundleUpdateSpec() {
|
|
|
1098
1184
|
BundleUpdateStoreAndroid.deleteDir(destinationDir)
|
|
1099
1185
|
throw Exception("Extracted files verification against metadata failed")
|
|
1100
1186
|
}
|
|
1187
|
+
if (!BundleUpdateStoreAndroid.validateBundlePairCompatibility(destination, metadata)) {
|
|
1188
|
+
OneKeyLog.error("BundleUpdate", "verifyBundleASC: bundle pair compatibility check failed")
|
|
1189
|
+
BundleUpdateStoreAndroid.deleteDir(destinationDir)
|
|
1190
|
+
throw Exception("Bundle pair compatibility check failed")
|
|
1191
|
+
}
|
|
1101
1192
|
|
|
1102
1193
|
OneKeyLog.info("BundleUpdate", "verifyBundleASC: all verifications passed, appVersion=$appVersion, bundleVersion=$bundleVersion")
|
|
1103
1194
|
} catch (e: Exception) {
|
|
@@ -1366,6 +1457,22 @@ class ReactNativeBundleUpdate : HybridReactNativeBundleUpdateSpec() {
|
|
|
1366
1457
|
}
|
|
1367
1458
|
}
|
|
1368
1459
|
|
|
1460
|
+
override fun getBackgroundJsBundlePath(): String {
|
|
1461
|
+
val context = NitroModules.applicationContext ?: return ""
|
|
1462
|
+
val path = BundleUpdateStoreAndroid.getCurrentBundleBackgroundJSBundle(context) ?: ""
|
|
1463
|
+
OneKeyLog.debug("BundleUpdate", "getBackgroundJsBundlePath: ${if (path.isEmpty()) "(empty/no bundle)" else path}")
|
|
1464
|
+
return path
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
override fun getBackgroundJsBundlePathAsync(): Promise<String> {
|
|
1468
|
+
return Promise.async {
|
|
1469
|
+
val context = getContext()
|
|
1470
|
+
val path = BundleUpdateStoreAndroid.getCurrentBundleBackgroundJSBundle(context) ?: ""
|
|
1471
|
+
OneKeyLog.info("BundleUpdate", "getBackgroundJsBundlePathAsync: ${if (path.isEmpty()) "(empty/no bundle)" else path}")
|
|
1472
|
+
path
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1369
1476
|
override fun getNativeAppVersion(): Promise<String> {
|
|
1370
1477
|
return Promise.async {
|
|
1371
1478
|
val context = getContext()
|
|
@@ -1480,6 +1587,10 @@ n2DMz6gqk326W6SFynYtvuiXo7wG4Cmn3SuIU8xfv9rJqunpZGYchMd7nZektmEJ
|
|
|
1480
1587
|
OneKeyLog.error("BundleUpdate", "verifyExtractedBundle: file integrity check failed")
|
|
1481
1588
|
throw Exception("File integrity check failed")
|
|
1482
1589
|
}
|
|
1590
|
+
if (!BundleUpdateStoreAndroid.validateBundlePairCompatibility(bundlePath.absolutePath, metadata)) {
|
|
1591
|
+
OneKeyLog.error("BundleUpdate", "verifyExtractedBundle: bundle pair compatibility check failed")
|
|
1592
|
+
throw Exception("Bundle pair compatibility check failed")
|
|
1593
|
+
}
|
|
1483
1594
|
OneKeyLog.info("BundleUpdate", "verifyExtractedBundle: all files verified OK, fileCount=${metadata.size}")
|
|
1484
1595
|
}
|
|
1485
1596
|
}
|
|
@@ -68,6 +68,11 @@ public class BundleUpdateStore: NSObject {
|
|
|
68
68
|
private static let bundlePrefsKey = "currentBundleVersion"
|
|
69
69
|
private static let nativeVersionKey = "nativeVersion"
|
|
70
70
|
private static let nativeBuildNumberKey = "nativeBuildNumber"
|
|
71
|
+
private static let mainBundleEntryFileName = "main.jsbundle.hbc"
|
|
72
|
+
private static let backgroundBundleEntryFileName = "background.bundle"
|
|
73
|
+
private static let metadataRequiresBackgroundBundleKey = "requiresBackgroundBundle"
|
|
74
|
+
private static let metadataBackgroundProtocolVersionKey = "backgroundProtocolVersion"
|
|
75
|
+
private static let supportedBackgroundProtocolVersion = "1"
|
|
71
76
|
|
|
72
77
|
public static func documentDirectory() -> String {
|
|
73
78
|
NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
|
|
@@ -147,8 +152,8 @@ public class BundleUpdateStore: NSObject {
|
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
public static func getWebEmbedPath() -> String {
|
|
150
|
-
guard let
|
|
151
|
-
return (
|
|
155
|
+
guard let bundleInfo = validatedCurrentBundleInfo() else { return "" }
|
|
156
|
+
return (bundleInfo.bundleDirPath as NSString).appendingPathComponent("web-embed")
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
public static func calculateSHA256(_ filePath: String) -> String? {
|
|
@@ -310,13 +315,65 @@ public class BundleUpdateStore: NSObject {
|
|
|
310
315
|
return metadataPath
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
public static func getMetadataFileContent(_ currentBundleVersion: String) -> [String:
|
|
318
|
+
public static func getMetadataFileContent(_ currentBundleVersion: String) -> [String: Any]? {
|
|
314
319
|
guard let path = getMetadataFilePath(currentBundleVersion),
|
|
315
320
|
let data = FileManager.default.contents(atPath: path),
|
|
316
|
-
let json = try? JSONSerialization.jsonObject(with: data) as? [String:
|
|
321
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else { return nil }
|
|
317
322
|
return json
|
|
318
323
|
}
|
|
319
324
|
|
|
325
|
+
private static func isReservedMetadataKey(_ key: String) -> Bool {
|
|
326
|
+
key == metadataRequiresBackgroundBundleKey || key == metadataBackgroundProtocolVersionKey
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private static func metadataStringValue(
|
|
330
|
+
_ metadata: [String: Any],
|
|
331
|
+
key: String,
|
|
332
|
+
) -> String? {
|
|
333
|
+
if let value = metadata[key] as? String {
|
|
334
|
+
return value
|
|
335
|
+
}
|
|
336
|
+
if let value = metadata[key] as? NSNumber {
|
|
337
|
+
return value.stringValue
|
|
338
|
+
}
|
|
339
|
+
if let value = metadata[key] as? Bool {
|
|
340
|
+
return value ? "true" : "false"
|
|
341
|
+
}
|
|
342
|
+
return nil
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private static func metadataBoolValue(
|
|
346
|
+
_ metadata: [String: Any],
|
|
347
|
+
key: String,
|
|
348
|
+
) -> Bool {
|
|
349
|
+
if let value = metadata[key] as? Bool {
|
|
350
|
+
return value
|
|
351
|
+
}
|
|
352
|
+
if let value = metadata[key] as? NSNumber {
|
|
353
|
+
return value.boolValue
|
|
354
|
+
}
|
|
355
|
+
if let value = metadata[key] as? String {
|
|
356
|
+
return ["1", "true", "yes"].contains(value.lowercased())
|
|
357
|
+
}
|
|
358
|
+
return false
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private static func fileMetadataEntries(
|
|
362
|
+
from metadata: [String: Any],
|
|
363
|
+
) -> [String: String] {
|
|
364
|
+
var entries: [String: String] = [:]
|
|
365
|
+
for (key, value) in metadata {
|
|
366
|
+
if isReservedMetadataKey(key) {
|
|
367
|
+
continue
|
|
368
|
+
}
|
|
369
|
+
guard let hash = value as? String else {
|
|
370
|
+
continue
|
|
371
|
+
}
|
|
372
|
+
entries[key] = hash
|
|
373
|
+
}
|
|
374
|
+
return entries
|
|
375
|
+
}
|
|
376
|
+
|
|
320
377
|
/// Returns true if OneKey developer mode (DevSettings) is enabled.
|
|
321
378
|
/// Reads the persisted value from MMKV storage written by the JS ServiceDevSetting layer.
|
|
322
379
|
public static func isDevSettingsEnabled() -> Bool {
|
|
@@ -466,11 +523,12 @@ public class BundleUpdateStore: NSObject {
|
|
|
466
523
|
return true
|
|
467
524
|
}
|
|
468
525
|
|
|
469
|
-
public static func validateAllFilesInDir(_ dirPath: String, metadata: [String:
|
|
526
|
+
public static func validateAllFilesInDir(_ dirPath: String, metadata: [String: Any], appVersion: String, bundleVersion: String) -> Bool {
|
|
470
527
|
let parentBundleDir = bundleDir()
|
|
471
528
|
let folderName = "\(appVersion)-\(bundleVersion)"
|
|
472
529
|
let jsBundleDir = (parentBundleDir as NSString).appendingPathComponent(folderName) + "/"
|
|
473
530
|
let fm = FileManager.default
|
|
531
|
+
let fileEntries = fileMetadataEntries(from: metadata)
|
|
474
532
|
|
|
475
533
|
guard let enumerator = fm.enumerator(atPath: dirPath) else { return false }
|
|
476
534
|
while let file = enumerator.nextObject() as? String {
|
|
@@ -480,7 +538,7 @@ public class BundleUpdateStore: NSObject {
|
|
|
480
538
|
if fm.fileExists(atPath: fullPath, isDirectory: &isDir), isDir.boolValue { continue }
|
|
481
539
|
|
|
482
540
|
let relativePath = fullPath.replacingOccurrences(of: jsBundleDir, with: "")
|
|
483
|
-
guard let expectedSHA256 =
|
|
541
|
+
guard let expectedSHA256 = fileEntries[relativePath] else {
|
|
484
542
|
OneKeyLog.error("BundleUpdate", "[bundle-verify] File on disk not found in metadata: \(relativePath)")
|
|
485
543
|
return false
|
|
486
544
|
}
|
|
@@ -495,7 +553,7 @@ public class BundleUpdateStore: NSObject {
|
|
|
495
553
|
}
|
|
496
554
|
|
|
497
555
|
// Verify completeness
|
|
498
|
-
for key in
|
|
556
|
+
for key in fileEntries.keys {
|
|
499
557
|
let expectedFilePath = jsBundleDir + key
|
|
500
558
|
if !fm.fileExists(atPath: expectedFilePath) {
|
|
501
559
|
OneKeyLog.error("BundleUpdate", "[bundle-verify] File listed in metadata but missing on disk: \(key)")
|
|
@@ -505,7 +563,58 @@ public class BundleUpdateStore: NSObject {
|
|
|
505
563
|
return true
|
|
506
564
|
}
|
|
507
565
|
|
|
508
|
-
|
|
566
|
+
static func validateBundlePairCompatibility(
|
|
567
|
+
bundleDirPath: String,
|
|
568
|
+
metadata: [String: Any],
|
|
569
|
+
) -> Bool {
|
|
570
|
+
let mainBundlePath = (bundleDirPath as NSString)
|
|
571
|
+
.appendingPathComponent(mainBundleEntryFileName)
|
|
572
|
+
guard FileManager.default.fileExists(atPath: mainBundlePath) else {
|
|
573
|
+
OneKeyLog.error(
|
|
574
|
+
"BundleUpdate",
|
|
575
|
+
"bundle pair invalid: main.jsbundle.hbc is missing at \(mainBundlePath)",
|
|
576
|
+
)
|
|
577
|
+
return false
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
let requiresBackgroundBundle = metadataBoolValue(
|
|
581
|
+
metadata,
|
|
582
|
+
key: metadataRequiresBackgroundBundleKey,
|
|
583
|
+
)
|
|
584
|
+
if !requiresBackgroundBundle {
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
let protocolVersion = metadataStringValue(
|
|
589
|
+
metadata,
|
|
590
|
+
key: metadataBackgroundProtocolVersionKey,
|
|
591
|
+
) ?? ""
|
|
592
|
+
if protocolVersion.isEmpty || protocolVersion != supportedBackgroundProtocolVersion {
|
|
593
|
+
OneKeyLog.error(
|
|
594
|
+
"BundleUpdate",
|
|
595
|
+
"backgroundProtocolVersion mismatch: expected=\(supportedBackgroundProtocolVersion), actual=\(protocolVersion)",
|
|
596
|
+
)
|
|
597
|
+
return false
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
let backgroundBundlePath = (bundleDirPath as NSString)
|
|
601
|
+
.appendingPathComponent(backgroundBundleEntryFileName)
|
|
602
|
+
guard FileManager.default.fileExists(atPath: backgroundBundlePath) else {
|
|
603
|
+
OneKeyLog.error(
|
|
604
|
+
"BundleUpdate",
|
|
605
|
+
"requiresBackgroundBundle is true but background.bundle is missing at \(backgroundBundlePath)",
|
|
606
|
+
)
|
|
607
|
+
return false
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return true
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private static func validatedCurrentBundleInfo() -> (
|
|
614
|
+
bundleDirPath: String,
|
|
615
|
+
currentBundleVersion: String,
|
|
616
|
+
metadata: [String: Any]
|
|
617
|
+
)? {
|
|
509
618
|
processPreLaunchPendingTask()
|
|
510
619
|
guard let currentBundleVer = currentBundleVersion() else {
|
|
511
620
|
OneKeyLog.warn("BundleUpdate", "getJsBundlePath: no currentBundleVersion stored")
|
|
@@ -582,12 +691,32 @@ public class BundleUpdateStore: NSObject {
|
|
|
582
691
|
}
|
|
583
692
|
}
|
|
584
693
|
|
|
585
|
-
|
|
586
|
-
guard FileManager.default.fileExists(atPath: mainJSBundle) else {
|
|
587
|
-
OneKeyLog.info("BundleUpdate", "mainJSBundleFile does not exist")
|
|
694
|
+
if !validateBundlePairCompatibility(bundleDirPath: folderName, metadata: metadata) {
|
|
588
695
|
return nil
|
|
589
696
|
}
|
|
590
|
-
|
|
697
|
+
|
|
698
|
+
return (folderName, currentBundleVer, metadata)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
private static func currentBundleEntryPath(_ entryFileName: String) -> String? {
|
|
702
|
+
guard let bundleInfo = validatedCurrentBundleInfo() else {
|
|
703
|
+
return nil
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
let entryPath = (bundleInfo.bundleDirPath as NSString).appendingPathComponent(entryFileName)
|
|
707
|
+
guard FileManager.default.fileExists(atPath: entryPath) else {
|
|
708
|
+
OneKeyLog.info("BundleUpdate", "\(entryFileName) does not exist")
|
|
709
|
+
return nil
|
|
710
|
+
}
|
|
711
|
+
return entryPath
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
public static func currentBundleMainJSBundle() -> String? {
|
|
715
|
+
currentBundleEntryPath(mainBundleEntryFileName)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
public static func currentBundleBackgroundJSBundle() -> String? {
|
|
719
|
+
currentBundleEntryPath(backgroundBundleEntryFileName)
|
|
591
720
|
}
|
|
592
721
|
|
|
593
722
|
// Fallback data management
|
|
@@ -1050,6 +1179,11 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1050
1179
|
try? FileManager.default.removeItem(atPath: destination)
|
|
1051
1180
|
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "Extracted files verification against metadata failed"])
|
|
1052
1181
|
}
|
|
1182
|
+
if !BundleUpdateStore.validateBundlePairCompatibility(bundleDirPath: destination, metadata: metadata) {
|
|
1183
|
+
OneKeyLog.error("BundleUpdate", "verifyBundleASC: bundle pair compatibility check failed")
|
|
1184
|
+
try? FileManager.default.removeItem(atPath: destination)
|
|
1185
|
+
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "Bundle pair compatibility check failed"])
|
|
1186
|
+
}
|
|
1053
1187
|
|
|
1054
1188
|
OneKeyLog.info("BundleUpdate", "verifyBundleASC: all verifications passed, appVersion=\(appVersion), bundleVersion=\(bundleVersion)")
|
|
1055
1189
|
}
|
|
@@ -1314,6 +1448,20 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1314
1448
|
}
|
|
1315
1449
|
}
|
|
1316
1450
|
|
|
1451
|
+
func getBackgroundJsBundlePath() throws -> String {
|
|
1452
|
+
let path = BundleUpdateStore.currentBundleBackgroundJSBundle() ?? ""
|
|
1453
|
+
OneKeyLog.debug("BundleUpdate", "getBackgroundJsBundlePath: \(path.isEmpty ? "(empty/no bundle)" : path)")
|
|
1454
|
+
return path
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
func getBackgroundJsBundlePathAsync() throws -> Promise<String> {
|
|
1458
|
+
return Promise.async {
|
|
1459
|
+
let path = BundleUpdateStore.currentBundleBackgroundJSBundle() ?? ""
|
|
1460
|
+
OneKeyLog.info("BundleUpdate", "getBackgroundJsBundlePathAsync: \(path.isEmpty ? "(empty/no bundle)" : path)")
|
|
1461
|
+
return path
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1317
1465
|
func getNativeAppVersion() throws -> Promise<String> {
|
|
1318
1466
|
return Promise.async {
|
|
1319
1467
|
let version = BundleUpdateStore.getCurrentNativeVersion()
|
|
@@ -1422,7 +1570,7 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1422
1570
|
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "metadata.json not found"])
|
|
1423
1571
|
}
|
|
1424
1572
|
guard let data = FileManager.default.contents(atPath: metadataJsonPath),
|
|
1425
|
-
let metadata = try? JSONSerialization.jsonObject(with: data) as? [String:
|
|
1573
|
+
let metadata = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
|
|
1426
1574
|
OneKeyLog.error("BundleUpdate", "verifyExtractedBundle: failed to parse metadata.json")
|
|
1427
1575
|
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to parse metadata.json"])
|
|
1428
1576
|
}
|
|
@@ -1431,6 +1579,10 @@ class ReactNativeBundleUpdate: HybridReactNativeBundleUpdateSpec {
|
|
|
1431
1579
|
OneKeyLog.error("BundleUpdate", "verifyExtractedBundle: file integrity check failed")
|
|
1432
1580
|
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "File integrity check failed"])
|
|
1433
1581
|
}
|
|
1582
|
+
if !BundleUpdateStore.validateBundlePairCompatibility(bundleDirPath: bundlePath, metadata: metadata) {
|
|
1583
|
+
OneKeyLog.error("BundleUpdate", "verifyExtractedBundle: bundle pair compatibility check failed")
|
|
1584
|
+
throw NSError(domain: "BundleUpdate", code: -1, userInfo: [NSLocalizedDescriptionKey: "Bundle pair compatibility check failed"])
|
|
1585
|
+
}
|
|
1434
1586
|
OneKeyLog.info("BundleUpdate", "verifyExtractedBundle: all files verified OK, fileCount=\(metadata.count)")
|
|
1435
1587
|
}
|
|
1436
1588
|
}
|
|
@@ -87,6 +87,8 @@ export interface ReactNativeBundleUpdate extends HybridObject<{
|
|
|
87
87
|
getWebEmbedPathAsync(): Promise<string>;
|
|
88
88
|
getJsBundlePath(): string;
|
|
89
89
|
getJsBundlePathAsync(): Promise<string>;
|
|
90
|
+
getBackgroundJsBundlePath(): string;
|
|
91
|
+
getBackgroundJsBundlePathAsync(): Promise<string>;
|
|
90
92
|
getNativeAppVersion(): Promise<string>;
|
|
91
93
|
getNativeBuildNumber(): Promise<string>;
|
|
92
94
|
getBuiltinBundleVersion(): Promise<string>;
|
|
@@ -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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AC;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,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,CA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AY,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"}
|
|
@@ -315,6 +315,27 @@ namespace margelo::nitro::reactnativebundleupdate {
|
|
|
315
315
|
return __promise;
|
|
316
316
|
}();
|
|
317
317
|
}
|
|
318
|
+
std::string JHybridReactNativeBundleUpdateSpec::getBackgroundJsBundlePath() {
|
|
319
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBackgroundJsBundlePath");
|
|
320
|
+
auto __result = method(_javaPart);
|
|
321
|
+
return __result->toStdString();
|
|
322
|
+
}
|
|
323
|
+
std::shared_ptr<Promise<std::string>> JHybridReactNativeBundleUpdateSpec::getBackgroundJsBundlePathAsync() {
|
|
324
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getBackgroundJsBundlePathAsync");
|
|
325
|
+
auto __result = method(_javaPart);
|
|
326
|
+
return [&]() {
|
|
327
|
+
auto __promise = Promise<std::string>::create();
|
|
328
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
329
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
330
|
+
__promise->resolve(__result->toStdString());
|
|
331
|
+
});
|
|
332
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
333
|
+
jni::JniException __jniError(__throwable);
|
|
334
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
335
|
+
});
|
|
336
|
+
return __promise;
|
|
337
|
+
}();
|
|
338
|
+
}
|
|
318
339
|
std::shared_ptr<Promise<std::string>> JHybridReactNativeBundleUpdateSpec::getNativeAppVersion() {
|
|
319
340
|
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getNativeAppVersion");
|
|
320
341
|
auto __result = method(_javaPart);
|
|
@@ -69,6 +69,8 @@ namespace margelo::nitro::reactnativebundleupdate {
|
|
|
69
69
|
std::shared_ptr<Promise<std::string>> getWebEmbedPathAsync() override;
|
|
70
70
|
std::string getJsBundlePath() override;
|
|
71
71
|
std::shared_ptr<Promise<std::string>> getJsBundlePathAsync() override;
|
|
72
|
+
std::string getBackgroundJsBundlePath() override;
|
|
73
|
+
std::shared_ptr<Promise<std::string>> getBackgroundJsBundlePathAsync() override;
|
|
72
74
|
std::shared_ptr<Promise<std::string>> getNativeAppVersion() override;
|
|
73
75
|
std::shared_ptr<Promise<std::string>> getNativeBuildNumber() override;
|
|
74
76
|
std::shared_ptr<Promise<std::string>> getBuiltinBundleVersion() override;
|
|
@@ -106,6 +106,14 @@ abstract class HybridReactNativeBundleUpdateSpec: HybridObject() {
|
|
|
106
106
|
@Keep
|
|
107
107
|
abstract fun getJsBundlePathAsync(): Promise<String>
|
|
108
108
|
|
|
109
|
+
@DoNotStrip
|
|
110
|
+
@Keep
|
|
111
|
+
abstract fun getBackgroundJsBundlePath(): String
|
|
112
|
+
|
|
113
|
+
@DoNotStrip
|
|
114
|
+
@Keep
|
|
115
|
+
abstract fun getBackgroundJsBundlePathAsync(): Promise<String>
|
|
116
|
+
|
|
109
117
|
@DoNotStrip
|
|
110
118
|
@Keep
|
|
111
119
|
abstract fun getNativeAppVersion(): Promise<String>
|
|
@@ -218,6 +218,22 @@ namespace margelo::nitro::reactnativebundleupdate {
|
|
|
218
218
|
auto __value = std::move(__result.value());
|
|
219
219
|
return __value;
|
|
220
220
|
}
|
|
221
|
+
inline std::string getBackgroundJsBundlePath() override {
|
|
222
|
+
auto __result = _swiftPart.getBackgroundJsBundlePath();
|
|
223
|
+
if (__result.hasError()) [[unlikely]] {
|
|
224
|
+
std::rethrow_exception(__result.error());
|
|
225
|
+
}
|
|
226
|
+
auto __value = std::move(__result.value());
|
|
227
|
+
return __value;
|
|
228
|
+
}
|
|
229
|
+
inline std::shared_ptr<Promise<std::string>> getBackgroundJsBundlePathAsync() override {
|
|
230
|
+
auto __result = _swiftPart.getBackgroundJsBundlePathAsync();
|
|
231
|
+
if (__result.hasError()) [[unlikely]] {
|
|
232
|
+
std::rethrow_exception(__result.error());
|
|
233
|
+
}
|
|
234
|
+
auto __value = std::move(__result.value());
|
|
235
|
+
return __value;
|
|
236
|
+
}
|
|
221
237
|
inline std::shared_ptr<Promise<std::string>> getNativeAppVersion() override {
|
|
222
238
|
auto __result = _swiftPart.getNativeAppVersion();
|
|
223
239
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -29,6 +29,8 @@ public protocol HybridReactNativeBundleUpdateSpec_protocol: HybridObject {
|
|
|
29
29
|
func getWebEmbedPathAsync() throws -> Promise<String>
|
|
30
30
|
func getJsBundlePath() throws -> String
|
|
31
31
|
func getJsBundlePathAsync() throws -> Promise<String>
|
|
32
|
+
func getBackgroundJsBundlePath() throws -> String
|
|
33
|
+
func getBackgroundJsBundlePathAsync() throws -> Promise<String>
|
|
32
34
|
func getNativeAppVersion() throws -> Promise<String>
|
|
33
35
|
func getNativeBuildNumber() throws -> Promise<String>
|
|
34
36
|
func getBuiltinBundleVersion() throws -> Promise<String>
|
|
@@ -394,6 +394,37 @@ open class HybridReactNativeBundleUpdateSpec_cxx {
|
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
@inline(__always)
|
|
398
|
+
public final func getBackgroundJsBundlePath() -> bridge.Result_std__string_ {
|
|
399
|
+
do {
|
|
400
|
+
let __result = try self.__implementation.getBackgroundJsBundlePath()
|
|
401
|
+
let __resultCpp = std.string(__result)
|
|
402
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
403
|
+
} catch (let __error) {
|
|
404
|
+
let __exceptionPtr = __error.toCpp()
|
|
405
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@inline(__always)
|
|
410
|
+
public final func getBackgroundJsBundlePathAsync() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
411
|
+
do {
|
|
412
|
+
let __result = try self.__implementation.getBackgroundJsBundlePathAsync()
|
|
413
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
414
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
415
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
416
|
+
__result
|
|
417
|
+
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
418
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
419
|
+
return __promise
|
|
420
|
+
}()
|
|
421
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
422
|
+
} catch (let __error) {
|
|
423
|
+
let __exceptionPtr = __error.toCpp()
|
|
424
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
397
428
|
@inline(__always)
|
|
398
429
|
public final func getNativeAppVersion() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
399
430
|
do {
|
|
@@ -29,6 +29,8 @@ namespace margelo::nitro::reactnativebundleupdate {
|
|
|
29
29
|
prototype.registerHybridMethod("getWebEmbedPathAsync", &HybridReactNativeBundleUpdateSpec::getWebEmbedPathAsync);
|
|
30
30
|
prototype.registerHybridMethod("getJsBundlePath", &HybridReactNativeBundleUpdateSpec::getJsBundlePath);
|
|
31
31
|
prototype.registerHybridMethod("getJsBundlePathAsync", &HybridReactNativeBundleUpdateSpec::getJsBundlePathAsync);
|
|
32
|
+
prototype.registerHybridMethod("getBackgroundJsBundlePath", &HybridReactNativeBundleUpdateSpec::getBackgroundJsBundlePath);
|
|
33
|
+
prototype.registerHybridMethod("getBackgroundJsBundlePathAsync", &HybridReactNativeBundleUpdateSpec::getBackgroundJsBundlePathAsync);
|
|
32
34
|
prototype.registerHybridMethod("getNativeAppVersion", &HybridReactNativeBundleUpdateSpec::getNativeAppVersion);
|
|
33
35
|
prototype.registerHybridMethod("getNativeBuildNumber", &HybridReactNativeBundleUpdateSpec::getNativeBuildNumber);
|
|
34
36
|
prototype.registerHybridMethod("getBuiltinBundleVersion", &HybridReactNativeBundleUpdateSpec::getBuiltinBundleVersion);
|
|
@@ -101,6 +101,8 @@ namespace margelo::nitro::reactnativebundleupdate {
|
|
|
101
101
|
virtual std::shared_ptr<Promise<std::string>> getWebEmbedPathAsync() = 0;
|
|
102
102
|
virtual std::string getJsBundlePath() = 0;
|
|
103
103
|
virtual std::shared_ptr<Promise<std::string>> getJsBundlePathAsync() = 0;
|
|
104
|
+
virtual std::string getBackgroundJsBundlePath() = 0;
|
|
105
|
+
virtual std::shared_ptr<Promise<std::string>> getBackgroundJsBundlePathAsync() = 0;
|
|
104
106
|
virtual std::shared_ptr<Promise<std::string>> getNativeAppVersion() = 0;
|
|
105
107
|
virtual std::shared_ptr<Promise<std::string>> getNativeBuildNumber() = 0;
|
|
106
108
|
virtual std::shared_ptr<Promise<std::string>> getBuiltinBundleVersion() = 0;
|
package/package.json
CHANGED
|
@@ -109,6 +109,8 @@ export interface ReactNativeBundleUpdate
|
|
|
109
109
|
getWebEmbedPathAsync(): Promise<string>;
|
|
110
110
|
getJsBundlePath(): string;
|
|
111
111
|
getJsBundlePathAsync(): Promise<string>;
|
|
112
|
+
getBackgroundJsBundlePath(): string;
|
|
113
|
+
getBackgroundJsBundlePathAsync(): Promise<string>;
|
|
112
114
|
getNativeAppVersion(): Promise<string>;
|
|
113
115
|
getNativeBuildNumber(): Promise<string>;
|
|
114
116
|
getBuiltinBundleVersion(): Promise<string>;
|