airborne-react-native 0.15.6 → 0.18.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/build.gradle +4 -1
- package/android/src/latest/java/in/juspay/airborneplugin/AirborneReactHostDelegate.kt +7 -16
- package/android/src/latest/java/in/juspay/airborneplugin/AirborneReactNativeHost.kt +5 -0
- package/android/src/main/java/in/juspay/airborneplugin/AirborneReactActivityDelegate.kt +10 -9
- package/android/src/main/java/in/juspay/airborneplugin/{AirborneReactNativeHost.kt → AirborneReactNativeHostBase.kt} +2 -9
- package/android/src/rn77/java/in/juspay/airborneplugin/AirborneReactHostDelegate.kt +7 -8
- package/android/src/rn77/java/in/juspay/airborneplugin/AirborneReactNativeHost.kt +12 -0
- package/android/src/rn80/java/in/juspay/airborneplugin/AirborneReactHostDelegate.kt +64 -0
- package/android/src/rn80/java/in/juspay/airborneplugin/AirborneReactNativeHost.kt +11 -0
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -90,8 +90,11 @@ android {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
def rnMinorVersion = findReactNativeVersion().tokenize('.')[1].toInteger()
|
|
94
|
+
if (rnMinorVersion >= 81) {
|
|
94
95
|
sourceSets.main.java.srcDirs += "src/latest/java"
|
|
96
|
+
} else if (rnMinorVersion >= 78 && rnMinorVersion < 81) {
|
|
97
|
+
sourceSets.main.java.srcDirs += "src/rn80/java"
|
|
95
98
|
} else {
|
|
96
99
|
sourceSets.main.java.srcDirs += "src/rn77/java"
|
|
97
100
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
package `in`.juspay.airborneplugin
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import android.util.Log
|
|
5
|
-
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
6
4
|
import com.facebook.react.ReactNativeHost
|
|
7
5
|
import com.facebook.react.ReactPackage
|
|
8
6
|
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
|
|
@@ -10,15 +8,13 @@ import com.facebook.react.bridge.JSBundleLoader
|
|
|
10
8
|
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
11
9
|
import com.facebook.react.defaults.DefaultTurboModuleManagerDelegate
|
|
12
10
|
import com.facebook.react.runtime.BindingsInstaller
|
|
13
|
-
import com.facebook.react.runtime.JSCInstance
|
|
14
11
|
import com.facebook.react.runtime.JSRuntimeFactory
|
|
15
12
|
import com.facebook.react.runtime.ReactHostDelegate
|
|
16
13
|
import com.facebook.react.runtime.hermes.HermesInstance
|
|
17
|
-
import java.lang.ref.WeakReference
|
|
18
14
|
|
|
19
15
|
@OptIn(UnstableReactNativeAPI::class)
|
|
20
16
|
class AirborneReactHostDelegate(
|
|
21
|
-
private val
|
|
17
|
+
private val context: Context,
|
|
22
18
|
private val reactNativeHostWrapper: ReactNativeHost,
|
|
23
19
|
override val bindingsInstaller: BindingsInstaller? = null,
|
|
24
20
|
override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder =
|
|
@@ -27,12 +23,11 @@ class AirborneReactHostDelegate(
|
|
|
27
23
|
|
|
28
24
|
override val jsBundleLoader: JSBundleLoader
|
|
29
25
|
get() {
|
|
30
|
-
val bundleName =
|
|
31
|
-
(reactNativeHostWrapper as AirborneReactNativeHost).jsBundleFile
|
|
26
|
+
val bundleName = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsBundleFile
|
|
32
27
|
bundleName?.let {
|
|
33
28
|
return if (bundleName.startsWith("assets://")) {
|
|
34
29
|
JSBundleLoader.createAssetLoader(
|
|
35
|
-
|
|
30
|
+
context,
|
|
36
31
|
bundleName,
|
|
37
32
|
false
|
|
38
33
|
)
|
|
@@ -41,24 +36,20 @@ class AirborneReactHostDelegate(
|
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
return JSBundleLoader.createAssetLoader(
|
|
44
|
-
|
|
39
|
+
context,
|
|
45
40
|
"assets://index.android.bundle",
|
|
46
41
|
false
|
|
47
42
|
)
|
|
48
43
|
}
|
|
49
44
|
|
|
50
45
|
override val jsMainModulePath: String
|
|
51
|
-
get() = (reactNativeHostWrapper as AirborneReactNativeHost)
|
|
46
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsMainModuleName ?: "index"
|
|
52
47
|
|
|
53
48
|
override val jsRuntimeFactory: JSRuntimeFactory
|
|
54
|
-
get() =
|
|
55
|
-
HermesInstance()
|
|
56
|
-
} else {
|
|
57
|
-
JSCInstance()
|
|
58
|
-
}
|
|
49
|
+
get() = HermesInstance()
|
|
59
50
|
|
|
60
51
|
override val reactPackages: List<ReactPackage>
|
|
61
|
-
get() = (reactNativeHostWrapper as AirborneReactNativeHost)
|
|
52
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.packages ?: emptyList()
|
|
62
53
|
|
|
63
54
|
override fun handleInstanceException(error: Exception) {
|
|
64
55
|
}
|
|
@@ -13,8 +13,9 @@ class AirborneReactActivityDelegate(
|
|
|
13
13
|
fabricEnabled: Boolean
|
|
14
14
|
) : DefaultReactActivityDelegate(activity, mainComponentName, fabricEnabled) {
|
|
15
15
|
|
|
16
|
-
private var appState = AppState.BEFORE_APPLOAD
|
|
17
|
-
|
|
16
|
+
private var appState = AppState.BEFORE_APPLOAD
|
|
17
|
+
private val TAG = "AirborneReactActivityDelegate"
|
|
18
|
+
override fun loadApp(appKey: String?) {
|
|
18
19
|
if (reactNativeHost is AirborneReactNativeHost) {
|
|
19
20
|
CoroutineScope(Dispatchers.Default).launch {
|
|
20
21
|
|
|
@@ -30,7 +31,7 @@ class AirborneReactActivityDelegate(
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
private fun callLoadApp(appKey: String) {
|
|
34
|
+
private fun callLoadApp(appKey: String?) {
|
|
34
35
|
super.loadApp(appKey)
|
|
35
36
|
appState = AppState.APP_LOADED
|
|
36
37
|
onResume()
|
|
@@ -41,10 +42,10 @@ class AirborneReactActivityDelegate(
|
|
|
41
42
|
if (appState == AppState.ONRESUME_CALLED) {
|
|
42
43
|
super.onPause()
|
|
43
44
|
} else {
|
|
44
|
-
Log.d(
|
|
45
|
+
Log.d(TAG, "skipping onPause as onResume is not yet called")
|
|
45
46
|
}
|
|
46
47
|
} catch (e: Exception) {
|
|
47
|
-
Log.e(
|
|
48
|
+
Log.e( TAG, "Exception in onPause: ${e.message}")
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -54,10 +55,10 @@ class AirborneReactActivityDelegate(
|
|
|
54
55
|
super.onResume()
|
|
55
56
|
appState = AppState.ONRESUME_CALLED
|
|
56
57
|
} else {
|
|
57
|
-
Log.d(
|
|
58
|
+
Log.d(TAG, "skipping onResume as app is not yet loaded")
|
|
58
59
|
}
|
|
59
60
|
} catch (e: Exception) {
|
|
60
|
-
Log.e(
|
|
61
|
+
Log.e(TAG, "Exception in onResume: ${e.message}")
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -66,10 +67,10 @@ class AirborneReactActivityDelegate(
|
|
|
66
67
|
if (appState == AppState.ONRESUME_CALLED) {
|
|
67
68
|
super.onDestroy()
|
|
68
69
|
} else {
|
|
69
|
-
Log.d(
|
|
70
|
+
Log.d(TAG, "skipping onDestroy as onResume is not yet called")
|
|
70
71
|
}
|
|
71
72
|
} catch (e: Exception) {
|
|
72
|
-
Log.e(
|
|
73
|
+
Log.e(TAG, "Exception in onDestroy: ${e.message}")
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -2,12 +2,9 @@ package `in`.juspay.airborneplugin
|
|
|
2
2
|
|
|
3
3
|
import android.app.Application
|
|
4
4
|
import android.content.Context
|
|
5
|
-
import android.util.Log
|
|
6
|
-
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
7
5
|
import com.facebook.react.ReactHost
|
|
8
6
|
import com.facebook.react.ReactNativeHost
|
|
9
7
|
import com.facebook.react.ReactPackage
|
|
10
|
-
import com.facebook.react.bridge.JSExceptionHandler
|
|
11
8
|
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
12
9
|
import com.facebook.react.defaults.DefaultComponentsRegistry
|
|
13
10
|
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
@@ -15,7 +12,7 @@ import com.facebook.react.fabric.ComponentFactory
|
|
|
15
12
|
import com.facebook.react.runtime.ReactHostImpl
|
|
16
13
|
import java.lang.ref.WeakReference
|
|
17
14
|
|
|
18
|
-
abstract class
|
|
15
|
+
abstract class AirborneReactNativeHostBase(application: Application) :
|
|
19
16
|
DefaultReactNativeHost(application) {
|
|
20
17
|
|
|
21
18
|
public override fun getPackages(): List<ReactPackage> {
|
|
@@ -26,10 +23,6 @@ abstract class AirborneReactNativeHost(application: Application) :
|
|
|
26
23
|
return super.getJSBundleFile()
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
public override fun getJSEngineResolutionAlgorithm(): JSEngineResolutionAlgorithm? {
|
|
30
|
-
return super.getJSEngineResolutionAlgorithm()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
26
|
public override fun getJSMainModuleName(): String {
|
|
34
27
|
return super.getJSMainModuleName()
|
|
35
28
|
}
|
|
@@ -38,7 +31,7 @@ abstract class AirborneReactNativeHost(application: Application) :
|
|
|
38
31
|
@OptIn(UnstableReactNativeAPI::class)
|
|
39
32
|
fun getReactHost(context: Context, reactNativeHost: ReactNativeHost): ReactHost {
|
|
40
33
|
val reactHostDelegate =
|
|
41
|
-
AirborneReactHostDelegate(
|
|
34
|
+
AirborneReactHostDelegate(context, reactNativeHost)
|
|
42
35
|
val componentFactory = ComponentFactory()
|
|
43
36
|
DefaultComponentsRegistry.register(componentFactory)
|
|
44
37
|
val reactHostImpl =
|
|
@@ -19,7 +19,7 @@ import java.lang.ref.WeakReference
|
|
|
19
19
|
|
|
20
20
|
@OptIn(UnstableReactNativeAPI::class)
|
|
21
21
|
class AirborneReactHostDelegate(
|
|
22
|
-
private val
|
|
22
|
+
private val context: Context,
|
|
23
23
|
private val reactNativeHostWrapper: ReactNativeHost,
|
|
24
24
|
override val bindingsInstaller: BindingsInstaller? = null,
|
|
25
25
|
private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG,
|
|
@@ -29,12 +29,11 @@ class AirborneReactHostDelegate(
|
|
|
29
29
|
|
|
30
30
|
override val jsBundleLoader: JSBundleLoader
|
|
31
31
|
get() {
|
|
32
|
-
val bundleName =
|
|
33
|
-
(reactNativeHostWrapper as AirborneReactNativeHost).jsBundleFile
|
|
32
|
+
val bundleName = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsBundleFile
|
|
34
33
|
bundleName?.let {
|
|
35
34
|
return if (bundleName.startsWith("assets://")) {
|
|
36
35
|
JSBundleLoader.createAssetLoader(
|
|
37
|
-
|
|
36
|
+
context,
|
|
38
37
|
bundleName,
|
|
39
38
|
false
|
|
40
39
|
)
|
|
@@ -43,24 +42,24 @@ class AirborneReactHostDelegate(
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
return JSBundleLoader.createAssetLoader(
|
|
46
|
-
|
|
45
|
+
context,
|
|
47
46
|
"assets://index.android.bundle",
|
|
48
47
|
false
|
|
49
48
|
)
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
override val jsMainModulePath: String
|
|
53
|
-
get() = (reactNativeHostWrapper as AirborneReactNativeHost)
|
|
52
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsMainModuleName ?: "index"
|
|
54
53
|
|
|
55
54
|
override val jsRuntimeFactory: JSRuntimeFactory
|
|
56
|
-
get() = if ((reactNativeHostWrapper as AirborneReactNativeHost)
|
|
55
|
+
get() = if ((reactNativeHostWrapper as? AirborneReactNativeHost)?.jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
|
|
57
56
|
HermesInstance()
|
|
58
57
|
} else {
|
|
59
58
|
JSCInstance()
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
override val reactPackages: List<ReactPackage>
|
|
63
|
-
get() = (reactNativeHostWrapper as AirborneReactNativeHost)
|
|
62
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.packages ?: emptyList()
|
|
64
63
|
|
|
65
64
|
override fun getReactNativeConfig(): ReactNativeConfig {
|
|
66
65
|
return reactNativeConfig
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package `in`.juspay.airborneplugin
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
5
|
+
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
6
|
+
|
|
7
|
+
abstract class AirborneReactNativeHost(application: Application) :
|
|
8
|
+
AirborneReactNativeHostBase(application) {
|
|
9
|
+
override fun getJSEngineResolutionAlgorithm(): JSEngineResolutionAlgorithm? {
|
|
10
|
+
return super.getJSEngineResolutionAlgorithm()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package `in`.juspay.airborneplugin
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
6
|
+
import com.facebook.react.ReactNativeHost
|
|
7
|
+
import com.facebook.react.ReactPackage
|
|
8
|
+
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
|
|
9
|
+
import com.facebook.react.bridge.JSBundleLoader
|
|
10
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
11
|
+
import com.facebook.react.defaults.DefaultTurboModuleManagerDelegate
|
|
12
|
+
import com.facebook.react.runtime.BindingsInstaller
|
|
13
|
+
import com.facebook.react.runtime.JSCInstance
|
|
14
|
+
import com.facebook.react.runtime.JSRuntimeFactory
|
|
15
|
+
import com.facebook.react.runtime.ReactHostDelegate
|
|
16
|
+
import com.facebook.react.runtime.hermes.HermesInstance
|
|
17
|
+
import java.lang.ref.WeakReference
|
|
18
|
+
|
|
19
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
20
|
+
class AirborneReactHostDelegate(
|
|
21
|
+
private val context: Context,
|
|
22
|
+
private val reactNativeHostWrapper: ReactNativeHost,
|
|
23
|
+
override val bindingsInstaller: BindingsInstaller? = null,
|
|
24
|
+
override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder =
|
|
25
|
+
DefaultTurboModuleManagerDelegate.Builder()
|
|
26
|
+
) : ReactHostDelegate {
|
|
27
|
+
|
|
28
|
+
override val jsBundleLoader: JSBundleLoader
|
|
29
|
+
get() {
|
|
30
|
+
val bundleName = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsBundleFile
|
|
31
|
+
bundleName?.let {
|
|
32
|
+
return if (bundleName.startsWith("assets://")) {
|
|
33
|
+
JSBundleLoader.createAssetLoader(
|
|
34
|
+
context,
|
|
35
|
+
bundleName,
|
|
36
|
+
false
|
|
37
|
+
)
|
|
38
|
+
} else {
|
|
39
|
+
JSBundleLoader.createFileLoader(bundleName)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return JSBundleLoader.createAssetLoader(
|
|
43
|
+
context,
|
|
44
|
+
"assets://index.android.bundle",
|
|
45
|
+
false
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override val jsMainModulePath: String
|
|
50
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.jsMainModuleName ?: "index"
|
|
51
|
+
|
|
52
|
+
override val jsRuntimeFactory: JSRuntimeFactory
|
|
53
|
+
get() = if ((reactNativeHostWrapper as? AirborneReactNativeHost)?.jsEngineResolutionAlgorithm == JSEngineResolutionAlgorithm.HERMES) {
|
|
54
|
+
HermesInstance()
|
|
55
|
+
} else {
|
|
56
|
+
JSCInstance()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override val reactPackages: List<ReactPackage>
|
|
60
|
+
get() = (reactNativeHostWrapper as? AirborneReactNativeHost)?.packages ?: emptyList()
|
|
61
|
+
|
|
62
|
+
override fun handleInstanceException(error: Exception) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package `in`.juspay.airborneplugin
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import com.facebook.react.JSEngineResolutionAlgorithm
|
|
5
|
+
|
|
6
|
+
abstract class AirborneReactNativeHost(application: Application) :
|
|
7
|
+
AirborneReactNativeHostBase(application) {
|
|
8
|
+
public override fun getJSEngineResolutionAlgorithm(): JSEngineResolutionAlgorithm? {
|
|
9
|
+
return super.getJSEngineResolutionAlgorithm()
|
|
10
|
+
}
|
|
11
|
+
}
|